CKEditor 4 - 如何将字体系列和字体大小控件添加到工具栏

时间:2013-04-24 05:45:01

标签: ckeditor

我在config.js中有一个config.toolbarGroups设置,但我不知道用于组添加字体系列/字体大小控件的名称。 (似乎缺乏这方面的文件)。我发现了一些建议,我应该使用CKBuilder创建一个已包含它的软件包,但我不能重新部署整个ckeditor只是为了添加几个按钮。

编辑:我的CKEditor是版本4

有什么建议吗?

谢谢!

4 个答案:

答案 0 :(得分:5)

有两种(互斥)方式来配置工具栏。请查看以下内容:

http://ckeditor.com/latest/samples/plugins/toolbar/toolbar.html

我首先尝试使用config.toolbarGroups,但最终使用了config.toolbar。这是我最终使用的内容:

config.toolbar = [
                { name: 'save', items: [ 'savebtn','Undo','Redo' ] },
                { name: 'clipboard', items: [ 'Cut','Copy','Paste','PasteText','PasteFromWord'] },
                { name: 'document', items: [ 'Find','Replace'] },
                '/',
                { name: 'lists', items: [ 'NumberedList','BulletedList','Outdent','Indent'] },
                { name: 'insert', items: [ 'Image','Table','Smiley','SpecialChar'] },
                { name: 'link', items: ['Link','Unlink'] },
                '/',
                { name: 'basicstyles', items: [ 'Font','FontSize','Bold','Italic','Underline','Strike','Subscript','Superscript'] },
                //'/',
                { name: 'align', items: [ 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'] }
        ];

请注意,我使用的是由kasper Taeymans慷慨捐赠的保存插件,可以在以下位置找到:

How to add an ajax save button with loading gif to CKeditor 4.2.1. [Working Sample Plugin]

我还发现以下文档非常有用,即使它与版本3相关:

http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar

我使用本文中的信息来生成我的配置(我使用的是版本4.2.1),特别是项目的名称(例如剪切,复制,粘贴),因为这是我案例中缺少的链接。

答案 1 :(得分:3)

config.extraPlugins = 'font';

你必须添加插件......

答案 2 :(得分:0)

这可用于在Ck​​Editor中添加字体系列和字体大小。

这将在config.js中完成。

另见docs

    config.font_names = 'Arial;Times New Roman;Verdana;' +  CKEDITOR.config.font_names;

config.toolbar_Full =
[
     { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },

    { name: 'paragraph', items : [ 'Outdent','Indent','-','Blockquote','CreateDiv','-',
                'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] }    

];

config.toolbar = 'Full';

答案 3 :(得分:0)

我花了很长时间才弄清楚我明确地必须将FontSize添加到工具栏中 - 似乎只与Font一起使用。