如何从CKeditor 4中删除按钮

Tho*_*ony 31 ckeditor

问题出在标题中:如何从CKeditor 4中删除按钮.

文档没有清楚地回答它

Tho*_*ony 44

基于reinmar答案并在此测试是更好的答案.在你的ckeditor config.js中添加:

config.removeButtons = 'Underline,JustifyCenter';
Run Code Online (Sandbox Code Playgroud)

作为参考,您可以在那里找到CKeditor 4按钮的完整列表:http://ckeditor.com/comment/123266#comment-123266

  • 顺便说一句,对于其他阅读此内容并且苦苦挣扎的人,请注意,如果您有多个,则按钮名称之间必须有*NO*空格. (5认同)

Tho*_*ony 38

我最终找到了,但我不喜欢这种方式,而不是删除你不想要的东西,你定义了你想要的按钮(并且根本不放你不想要的东西).当您调用CKeditor.replace时,您可以像这样定义工具栏:

    CKEDITOR.replace( 'YOURE_TEXT_AREA_ID', {
    toolbar: [
    { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates' ] },
    { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
    { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
    { name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
    '/',
    { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
    { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] },
    { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
    { name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe' ] },
    '/',
    { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
    { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
    { name: 'tools', items: [ 'Maximize', 'ShowBlocks' ] },
    { name: 'others', items: [ '-' ] },
    { name: 'about', items: [ 'About' ] }
]
});
Run Code Online (Sandbox Code Playgroud)

(作为参考,这是标准的完整工具栏)项目代表按钮,所以只需删除您不想要的项目.而已.

有没有更好的答案?

  • 请参阅[`config.removeButtons`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-removeButtons).如果删除整个插件,也会删除按钮(使用[`config.removePlugins`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-removePlugins). (4认同)
  • 不知道为什么这个被低估了; 我使用removeButtons从一个最小的CK编辑器实例中删除链接,它删除了链接相关的按钮,但添加了一些额外的按钮,没有特别好的理由,并使用这种技术明确添加我想要的少数是唯一的事情有效. (3认同)

小智 13

要删除按钮,请尝试:

$(document).ready(function() {
   CKEDITOR.config.removePlugins = 'Save,Print,Preview,Find,About,Maximize,ShowBlocks';
});
Run Code Online (Sandbox Code Playgroud)

逗号分隔列表必须包含要删除的每个按钮的名称.以下链接是包含工具栏ckeditor的按钮的完整列表:

列表按钮


use*_*446 9

在项目的scripts/ckeditor /中的config.js文件中,只需按以下方式操作即可

config.removePlugins = 'elementspath,save,image,flash,iframe,link,smiley,tabletools,find,pagebreak,templates,about,maximize,showblocks,newpage,language';

config.removeButtons = 'Copy,Cut,Paste,Undo,Redo,Print,Form,TextField,Textarea,Button,SelectAll,NumberedList,BulletedList,CreateDiv,Table,PasteText,PasteFromWord,Select,HiddenField';
Run Code Online (Sandbox Code Playgroud)


VDW*_*WWD 8

通过编辑config.js文件手动删除按钮并设置工具栏样式后,我找到了ToolBar配置器.

有了它,您可以轻松启用或禁用按钮.更改按钮组顺序并添加分隔符.

它位于/samples/toolbarconfigurator中的ckeditor文件夹中.刚推出index.html.工具栏配置器包含在下载页面上的所有不同下载包中

完成工具栏的创建后,只需单击Get toolbar config该样式并将其复制到config.jsckeditor文件夹中的文件即可.

在此输入图像描述

  • 谢谢,这是最有用的答案。我错过了位于/ samples / toolbarconfigurator中的部分。尤其棒的是,在_高级模式_中,您可以将按钮安排在您想要的任何位置,任何行,任何位置。 (2认同)

小智 7

打开您的 config.js 文件并粘贴此代码

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
    config.removePlugins = 'blockquote,save,flash,iframe,tabletools,pagebreak,templates,about,showblocks,newpage,language,print,div';
    config.removeButtons = 'Print,Form,TextField,Textarea,Button,CreateDiv,PasteText,PasteFromWord,Select,HiddenField,Radio,Checkbox,ImageButton,Anchor,BidiLtr,BidiRtl,Font,Format,Styles,Preview,Indent,Outdent';
};
Run Code Online (Sandbox Code Playgroud)


Hp9*_*p93 5

捆绑包默认提供一个便捷工具,可以在找到ckeditor/samples/toolbarconfigurator/index.html。它允许您使用GUI配置工具栏。