Change CKEditor toolbar dynamically

后端 未结 10 1723
猫巷女王i
猫巷女王i 2020-12-09 04:30

How do you change the CKEditor toolbar dynamically (without using a pre-defined toolbar)?

The CKEditor Developer\'s Guide only tells you how to set the toolbar durin

10条回答
  •  庸人自扰
    2020-12-09 05:21

    I am assuming you want to add button via plugin file. Here is how. Add your button to ui.

    editor.ui.addButton('ButtonName', {
      label: lang.lockediting.locked,
      icon: this.path + 'icons/locked.png',
      command: 'lockediting'});
    

    Then you can push ButtonName to toolbar.

    //Here it is pushed as a new group
    editor.config.toolbar.push(['ButtonName']);
    

    If you check console.log(editor.config.toolbar); you will see toolbar ise an object with toolbar groups as arrays [Array[10], Array[2], Array[5]]. [Array[10] means there are 10 button in first group. You can push your button into any of those arrays.

提交回复
热议问题