如何为窗口小部件按钮指定单独的工具栏组?

Ros*_*102 5 widget toolbar ckeditor

默认情况下,CKEditor将小部件按钮放在工具栏的"插入"组中.我想在工具栏上为我的小部件按钮指定一个自定义组.我怎样才能做到这一点?

Rei*_*mar 5

在这种情况下,您需要自己注册按钮,以便完全控制它.

  1. 窗口小部件定义中,不指定button属性.
  2. 使用该ui.addButton()方法添加按钮.此按钮应使用基于窗口小部件名称自动创建的窗口小部件命令.

所以它看起来像这样:

editor.widget.add( 'myWidget', {
    // For the widget command to work you have to
    // specify at least template or insert() callback. 
    template: 'foo',

    ...
} );

editor.ui.addButton( 'MyWidget', {
    label: 'My Widget',
    command: 'myWidget',
    toolbar: 'basicstyles,1'
} )
Run Code Online (Sandbox Code Playgroud)