文档并没有清楚地回答这个问题。
基于reinmar的答案并在此处进行了测试,以下是更好的答案。将其添加到您的 ckeditor config.js:
config.removeButtons = 'Underline,JustifyCenter';
参考此处可找到完整的 CKeditor 4 按钮列表: http://ckeditor.com/comment/123266#comment-123266
我终于找到了方法,但我不喜欢这种方式,因为它不是通过移除您不想要的内容,而是定义您想要的按钮(并简单地不放置您不想要的内容)。
当您调用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' ] }
]
});
(供参考,这是标准完整工具栏) 每个项目都代表一个按钮,因此只需删除不需要的项目即可。 就是这样。
有更好的答案吗?
经过手动删除按钮并编辑config.js
文件以调整工具栏样式后,我找到了ToolBar Configurator。
通过它,您可以轻松地启用或禁用按钮,更改按钮组顺序并添加分隔符。
它位于ckeditor
文件夹的/samples/toolbarconfigurator
中。只需启动index.html
即可。Toolbar Configurator包含在下载页面上所有不同的下载包中。
创建完工具栏后,只需单击获取工具栏配置
并将样式复制到位于主ckeditor
文件夹中的config.js
文件中即可。
位于/samples/toolbarconfigurator
的部分。特别棒的是,在“高级模式”下,您可以将按钮排列在任何您想要的位置,任何行,任何地方。 - Ilia要删除按钮,请尝试:
$(document).ready(function() {
CKEDITOR.config.removePlugins = 'Save,Print,Preview,Find,About,Maximize,ShowBlocks';
});
逗号分隔的列表必须包含您想要删除的每个按钮的名称。下面的链接是包含ckeditor工具栏中所有按钮的完整列表:
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';
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';
};
默认情况下,CKEditor捆绑了一个非常方便的工具,可以在ckeditor/samples/toolbarconfigurator/index.html
路径下找到。使用该工具,您可以通过GUI配置工具栏。
config.js
文件。CKEDITOR.editorConfig = function (config) {
config.removePlugins = 'save,newpage,flash,about,iframe,language';
//The options which you don't need in the toolbar, you can add them in the above remove plugins list.
};
通过以下步骤,您可以创建自己的工具栏,并按照您想要的顺序添加任何按钮:
设置专属工具栏
CKEDITOR.config.toolbar_MA = [ ['Source','-','Cut','Copy','Paste','-','Undo','Redo','RemoveFormat','-','Link','Unlink','Anchor','-','Image','Table','HorizontalRule','SpecialChar'], '/', ['Format','Templates','Bold','Italic','Underline','-','Superscript','-',['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], '-','NumberedList','BulletedList','-','Outdent','Indent'] ];
2)创建ck编辑器实例时选择它
CKEDITOR.replace( 'myeditor',{ toolbar:'MA' });
尝试一下
config.removeButtons = 'Save';
这将完全删除保存按钮。
removeButtons
进行grep。我提到这一点是因为我正在维护一个代码库,其中包含CKEditor配置的文件并非全部命名为config.js
。(之前将各种来源组合在一起的人)此外,如果您找不到removeButtons
,请查找toolbarGroups
或toolbar
(根据版本而定),然后从那里开始。 - floer32