简体   繁体   English

CKEditor内联重新排列自动生成的工具栏

[英]CKEditor inline rearrange auto-generated toolbar

I have an inline content editor by using the contenteditable attribute. 通过使用contenteditable属性,我有一个内联内容编辑器。 What I want is to rearrange the default auto-generated toolbar. 我想要的是重新排列默认的自动生成工具栏。 The usual method is to create something like: 通常的方法是创建如下内容:

config.toolbar = [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source', '-', '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: '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' ] },
{ 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: [ '-' ] },
];

in the config.js. 在config.js中。

The problem is that I don't know where to find the already auto-generated toolbar so as to change it the way I want. 问题是我不知道在哪里可以找到已经自动生成的工具栏,以便以所需的方式对其进行更改。 So I don't know what are the names used in the toolbar and therefore I can't make it how I want. 因此,我不知道工具栏中使用的名称是什么,因此无法按照我的意愿进行设置。

(the code used above is not the one I want obviously..) (上面使用的代码显然不是我想要的代码。)

Thanks in advance! 提前致谢!

Have you seen the Setting Configuration guide ? 您看过《 设置配置指南》吗? You can either set toolbar in the config.js file which will be loaded while initializing editor or directly in CKEDITOR.inline , but to use this method you need to disable automatic editors creation: 您可以在初始化编辑器时加载的config.js文件中设置工具栏,也可以直接在CKEDITOR.inline设置工具栏,但是要使用此方法,您需要禁用自动创建编辑器:

// We need to turn off the automatic editor creation first.
CKEDITOR.disableAutoInline = true;

var editor = CKEDITOR.inline( 'editable', {
    toolbar: [ ... ]
} );

If you don't know button names, then check out this question: What toolbar buttons are available in CKEditor 4? 如果您不知道按钮名称,请查看以下问题: CKEditor 4中提供哪些工具栏按钮?

Note: instead of rearranging entire toolbar, you can just rearrange groups of buttons – read more in the Toolbar Customization guide . 注意:您可以重新排列按钮组,而不必重新排列整个工具栏–请阅读《 工具栏自定义指南》中的更多内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM