如何使用 CKEditor 将新按钮添加到组中

How can I add a new button into a group with CKEditor

本文关键字:添加 按钮 CKEditor 何使用 新按钮      更新时间:2023-09-26

>我正在使用以下配置:

config.toolbarGroups = [
        { name: 'document', groups: ['mode', 'document', 'doctools', 'maximize'] },
        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
        { name: 'forms' },
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'justify' ] },
        // { name: 'links' },
        { name: 'insert' },
        { name: 'styles' },
        { name: 'colors' },
        { name: 'tools' },
        { name: 'others' }
        // ,
        //{ name: 'about' }
    ];
    // The default plugins included in the basic setup define some buttons that
    // we don't want too have in a basic editor. We remove them here.
    // config.removeButtons = 'Cut,Copy,Paste,Undo,Redo,Anchor,Underline,Strike,Subscript,Superscript';
    config.removeButtons = 'Strike,Subscript,Superscript';
    // Let's have it basic on dialogs as well.
    config.removeDialogTabs = 'link:advanced';
    config.extraPlugins = 'insertpre,format,justify,maximize';

一切正常,但最大化按钮始终位于工具栏的第二行。有没有办法让它最大化与其他一些按钮(例如插入按钮)旁边的组合?

您必须逐项配置工具栏以控制每个按钮的确切位置。默认情况下,最大化属于tools组,因此您也可以将整个组放在工具栏的顶部,如下所示:

config.toolbarGroups = [
        { name: 'document', groups: [ 'tools', 'mode', 'document', 'doctools', 'maximize'] },
        ...
];