Javascript CKEditor-小部件-为按钮设置工具栏

Javascript CKEditor-小部件-为按钮设置工具栏,javascript,ckeditor,ckeditor4.x,Javascript,Ckeditor,Ckeditor4.x,在CKEditor插件中,您可以使用以下命令为按钮指定工具栏: init:function(editor){ editor.ui.addButton('myplug',{ label:'my plug', command:'myplug', toolbar:'mytoolbar' 对于widget,我没有发现这种可能性。在JS中有没有一种不移动节点的方法,这有点复杂?你可以用小部件来做同样的事情。下

在CKEditor插件中,您可以使用以下命令为按钮指定工具栏:

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

对于widget,我没有发现这种可能性。在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”工具栏,但我想您已经添加了,因为您提到了可以为插件添加按钮。

您可以对小部件执行相同的操作。下面是一个小部件的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”工具栏,但我想您已经添加了,因为您提到可以为插件添加按钮