如何自定义CK-编辑器的工具菜单吗?(How to customize CK-Editor'

2019-08-01 07:14发布

我想改变CK-编辑工具菜单optons。 例如我删除其中的一些,我不需要使用。 我怎样才能做到这一点 ?

Answer 1:

有一个配置设置,允许你设置将出现按钮。

你只需创建自己的工具栏布局。 我已经包含了默认全工具栏的代码,你可以删除你不希望出现的按钮。

这是最好的复制默认的config.js文件并重新命名它,然后调用您的自定义配置文件和自定义工具栏时加载编辑:

CKEDITOR.replace( 'xxx_textarea_id_xxx',
{
  customConfig : 'xxx_name_of_custom_config_file_xxx.js',
  toolbar : 'XXX_custom_name_XXX'
});

这是配置设置为默认工具栏全面布局。

'/'工具栏内布局意味着突破到一个新行。
name: 'document', items :条目分别示出为一个组,并有条目之间的空间。
'-'创建一个组内的垂直间隔。

演示页会显示该默认工具栏布局的例子:
CKEditor的演示

config.toolbar_Full =
[
    { name: 'document',    items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
    { name: 'clipboard',   items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
    { name: 'editing',     items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
    { name: 'forms',       items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
    '/',
    { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
    { name: 'paragraph',   items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
    { name: 'links',       items : [ 'Link','Unlink','Anchor' ] },
    { name: 'insert',      items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak' ] },
    '/',
    { name: 'styles',      items : [ 'Styles','Format','Font','FontSize' ] },
    { name: 'colors',      items : [ 'TextColor','BGColor' ] },
    { name: 'tools',       items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];

这是一个自定义工具栏配置设置。
当您设置工具栏配置设置您只使用是“toolbar_”后的名称部分。 toolbar : 'XXX_custom_name_XXX'

config.toolbar_XXX_custom_name_XXX =
[
    { name: 'xxx_custom_group_namexxx',    items : ['Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
    { name: 'clipboard',   items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
    { name: 'editing',     items : [ 'Find','Replace','-','SelectAll' ] },
    '/',
    { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
    { name: 'paragraph',   items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
    { name: 'links',       items : [ 'Link','Unlink','Anchor' ] },
    { name: 'insert',      items : [ 'Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak' ] },
    '/',
    { name: 'styles',      items : [ 'Styles','Format','Font','FontSize' ] },
    { name: 'colors',      items : [ 'TextColor','BGColor' ] },
    { name: 'tools',       items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];

这里的链接在开发者指南中的工具栏页:
CKEditor的3.X | 开发人员指南- CKEditor的工具栏


您可能要关闭,你是不是与使用任何功能removePlugins配置设置:

config.removePlugins = 'flash,iframe';

下面是列出了所有的配置设置的CKEditor 3的JavaScript API文档的页面:
命名空间CKEDITOR.config



文章来源: How to customize CK-Editor's tools menu?