CKEditor - Widget - 为按钮设置工具栏
CKEditor - Widget - set a toolbar for the button
在 CKEditor 插件中,您可以通过以下方式为按钮指定工具栏:
init:function(editor){
editor.ui.addButton('myplug',{
label:'my plug',
command:'myplug',
toolbar:'mytoolbar'
使用小部件,我没有发现这种可能性。有没有在JS中不移动节点的方法,有点复杂?
您可以对小部件执行相同的操作。这是一个小部件的 plugin.js 文件,在 init 函数下有一个按钮和工具栏声明:
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'
});
}
} );
您需要在 config.js 文件中添加 "mytoolbar" 工具栏,但我想您已经添加了,因为您提到能够为插件添加按钮。
在 CKEditor 插件中,您可以通过以下方式为按钮指定工具栏:
init:function(editor){
editor.ui.addButton('myplug',{
label:'my plug',
command:'myplug',
toolbar:'mytoolbar'
使用小部件,我没有发现这种可能性。有没有在JS中不移动节点的方法,有点复杂?
您可以对小部件执行相同的操作。这是一个小部件的 plugin.js 文件,在 init 函数下有一个按钮和工具栏声明:
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'
});
}
} );
您需要在 config.js 文件中添加 "mytoolbar" 工具栏,但我想您已经添加了,因为您提到能够为插件添加按钮。