CKEditor - 在实例化之前获取默认工具栏数组BACK

时间:2017-08-02 22:07:58

标签: javascript ckeditor

我没有在CKEditor文档中找到这个,并且相当确定它可以完成。我知道如果在实例化编辑器时明确地将toolbar:传递给CKEditor,则可以控制工具栏配置。

我想要做的是首先获取默认工具栏并根据一些用户要求删除按钮。我如何首先获取CKEDITOR工具栏数组 ?谢谢!

(注意:我认为可能会在CKEDITOR.config.toolbar_Full中找到此链接here,但显示为 undefined ;我正在使用CKE 4.7.1。)

(注2:事实证明你可以使用removeButtons属性负面地构建一个菜单,但是我会把问题留下来,因为将整个菜单作为一个数组可能仍然有用。例如:

CKEDITOR.replace('my-region', { removeButtons: 'Save,Copy,About,Source' });

1 个答案:

答案 0 :(得分:0)

我也在使用4.7.1版。我还有与用户要求相关的自定义工具栏。这是片段 在配置定义中:

initToolbarSets(config);
config.toolbar = 'Default';

用于构建不同工具栏集(包括自定义插件)的功能:

function initToolbarSets(config) {
    config.toolbar_Empty = [];
    config.toolbar_Default = [
        { name: '1', items: ['Cut','Copy','Paste','PasteText','PasteFromWord'] },
        { name: '2', items: ['Undo','Redo','-','Find','Replace'] },
        { name: '3', items: ['DataTF', 'DataCB', 'Select', 'Table', 'Image','HorizontalRule'] },
        '/',
        { name: '4', items: ['Bold','Italic','Underline','Strike'] },
        { name: '5', items: ['NumberedList','BulletedList','-','Outdent','Indent'] },
        { name: '6', items: ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'] },
        { name: '7', items: ['SpecialChar','PageBreak'] },
        { name: '8', items: ['Font','FontSize'] },
        { name: '9', items: ['TextColor','BGColor'] },
        { name: '10', items: ['Maximize'] }
    ];

    config.toolbar_Mail= [
        { name: '1', items: ['Cut','Copy','Paste','PasteText','Preview'] },
        { name: '2', items: ['Undo','Redo','-','Find','Replace'] },
        { name: '3', items: ['TextField', 'Checkbox', 'Select', 'Table','Image', 'HorizontalRule', 'Link'] },
        '/',
        { name: '4', items: ['Bold', 'Italic', 'MyPlugin', 'Strike', 'Subscript', 'Superscript', 'RemoveFormat'] },
        { name: '5', items: ['NumberedList','BulletedList','-','Outdent','Indent'] },
        { name: '6', items: ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'] },
        { name: '7', items: ['SpecialChar', 'PageBreak'] },
        { name: '8', items: ['Font', 'FontSize', 'Styles'] },
        { name: '9', items: ['TextColor','BGColor'] },
        { name: '10', items: ['Maximize'] }
    ];
    config.toolbar_Helpdoc= [
        { name: '1', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'Preview'] },
        { name: '2', items: ['Undo', 'Redo', '-', 'Find', 'Replace'] },
        { name: '3', items: ['Table', 'HorizontalRule', 'Link'] },
        '/',
        { name: '4', items: ['Bold', 'Underline', 'Strike', 'MyPlugin', 'Superscript', 'RemoveFormat'] },
        { name: '5', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent'] },
        { name: '6', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] },
        { name: '7', items: ['SpecialChar', 'PageBreak'] },
        { name: '8', items: ['Styles']},
        { name: '9', items: ['Maximize'] }
    ];

    //...some other toolbar profiles
};

现在取决于你如何继续。您可以开发一个逻辑(可能在配置中)来决定哪个工具栏配置文件必须是当前用户。另一种方法可以是封装整个CKEditor的控件。在我的情况下(ASP.NET),编辑器嵌入如下:

<mynamespace:MyHTMLTextEditor ID="ckE" runat="server" Toolbar="Helpdoc" StylesSet="helpdoc" ForcePasteAsPlainText="true"/>