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

时间:2013-09-16 11:47:32

标签: javascript ckeditor inline toolbar contenteditable

我有一个使用contenteditable属性的内联内容编辑器。 我想要的是重新排列默认自动生成的工具栏。 通常的方法是创建类似的东西:

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: [ '-' ] },
];

在config.js。

问题是我不知道在哪里可以找到已经自动生成的工具栏,以便按照我想要的方式进行更改。所以我不知道工具栏中使用的名称是什么,因此我无法按照我想要的方式制作它。

(上面使用的代码显然不是我想要的代码..)

提前致谢!

1 个答案:

答案 0 :(得分:0)

你见过Setting Configuration guide吗?您可以在初始化编辑器时加载的config.js文件中设置工具栏,也可以直接在CKEDITOR.inline中设置工具栏,但要使用此方法,您需要禁用自动编辑器创建:

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

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

如果您不知道按钮名称,请查看此问题:What toolbar buttons are available in CKEditor 4?

注意:您可以重新排列按钮组,而不是重新排列整个工具栏 - 请在Toolbar Customization guide中阅读更多内容。

相关问题