CKEditor 自定义工具栏 WITH config.extraPlugins。

问题描述 投票:1回答:3

我目前使用的是CKEeditor 4,我使用的是config.js中设置的自定义工具栏,但我还想添加justify插件。Justify插件在标准编辑器中可以使用,但是当我指定自定义工具栏时,却无法包含它。

我看到的区别是,默认工具栏使用的是toolbarGroups,在这种情况下,我在 "段落 "组中添加了 "对齐"。

自定义工具栏使用nameitems(我无法让它与组一起工作),我尝试使用'align'、'Align'、'justify'、'Justify'等......没有任何显示justify按钮。

下面是config.js的具体部分。

config.toolbarGroups = [
    { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
    { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
    { name: 'links' },
    { name: 'insert' },
    { name: 'forms' },
    { name: 'tools' },
    { name: 'document',    groups: [ 'mode', 'document', 'doctools' ] },
    { name: 'others' },
    '/',
    { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
    { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align' ] },
    { name: 'styles' },
    { name: 'colors' },
    { name: 'about' }
];


config.toolbar = 'ToolsNoImage';
config.toolbar_ToolsNoImage =
[
    { name: 'document', items : [ 'mode', 'document', 'doctools' ] },
    { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
    { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','Scayt' ] },
    { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
    { name: 'insert', items : [ 'Table','HorizontalRule','SpecialChar','PageBreak'] },
    { name: 'tools', items : [ 'Maximize' ] },
    { name: 'tools', items : [ 'Source', '-', 'Preview' ] },
    '/',
    { name: 'basicstyles', items : [ 'Bold','Italic','Strike','-','RemoveFormat' ] },
    { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','Align' ] },
    { name: 'styles', items : [ 'Styles','Format' ] },
    { name: 'tools', items : [ 'About' ] }

];


config.toolbarCanCollapse = true;
config.toolbarStartupExpanded = true;
config.extraPlugins = 'justify';
config.extraPlugins_ToolsNoImage = 'justify';

我感觉是很简单的东西......case问题等。

javascript editor ckeditor
3个回答
2
投票

很简单,确实:D你用错了按钮的名字。组的名字是 'align'但按钮 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock''Align' 你在配置中使用了这个名字)。

而且,这不会有任何影响。

config.extraPlugins_ToolsNoImage = 'justify';

而且这也是不需要的。

config.extraPlugins = 'justify';

但最重要的是按钮名称:)

另外,还有一个问题。有一个 plugins/toolbar/samples/toolbar.html 在每一个 CKEditor 包中都有样本--它可能会帮助你找到正确的名称。


0
投票

这是给那些像我一样为启用alignjustify选项而苦恼的人准备的,要想启用,需要按照hanji的建议做如下操作。

配置.extraPlugins: 'justify' (justify)


-1
投票

只需使用下面的方法就可以自定义ckeditor工具栏的align和justify。

config.toolbar = [
        {name: "paragraph", 
         items: ["NumberedList", "BulletedList","Outdent","Indent","Blockquote","JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"]
        }
    ];

要进一步定制工具栏,你可以参考这个页面,并简单地编辑你的config.js。

http:/ckeditor.comforumsCKEditorComplete-list-of-toolbar-items。

© www.soinside.com 2019 - 2024. All rights reserved.