2016-04-23 156 views
0

在CKEditor的插件,你可以用這個按鈕指定一個工具欄:CKEditor的 - 小工具 - 設置工具欄按鈕

init:function(editor){ 
     editor.ui.addButton('myplug',{ 
      label:'my plug', 
      command:'myplug', 
      toolbar:'mytoolbar' 

隨着小部件,我不覺得這種可能性。有沒有辦法做到這一點,而不移動在JS中的節點,這有點複雜?

回答

2

你可以用小工具來做同樣的事情。這裏有一個小部件的plugin.js一個按鈕和工具欄申報文件的初始化函數下:

CKEDITOR.plugins.add('mywidget', { 
    requires: 'widget', 
    icons: 'mywidget', 
    init: function(editor) { 
     CKEDITOR.dialog.add('mywidget', this.path + 'dialogs/mywidget.js') 
     editor.widgets.add('mywidget' , { 
      // 
      // Your widget logic is here ... 
      // 
     }); 

     editor.ui.addButton('mywidget', { 
      label: 'My Widget' 
      command: 'mywidget' 
      toolbar: 'mytoolbar, 1' 
     }); 
    } 
}); 

你需要添加「mytoolbar」工具欄上的config.js文件,但我想你已經有了,因爲你提到能夠爲插件添加按鈕。