将数据参数发送到ckeditor对话框

abe*_*i98 5 dialog contextmenu ckeditor

我需要将参数数据发送到对话框这是我在plugin.js中的代码(右键单击)

editor.addCommand( 'editDialog', {
            exec: function( editor) {
                CKEDITOR.currentInstance.openDialog('editDialog');
            }
        });

    if ( editor.contextMenu )
            {

                editor.addMenuGroup( 'myGroup' );
                editor.addMenuItem( 'sliderItem',
                {
                    label : 'Edit Gallery',
                    command : 'editDialog',
                    group : 'myGroup'
                });
                editor.contextMenu.addListener( function( element )
                {

                    if ( element ){
                        element = element.getAscendant( 'wscms-gallery', true );
                    }

                    if ( element && !element.isReadOnly() && !element.data( 'cke-realelement' ) ){
                        return { sliderItem : CKEDITOR.TRISTATE_OFF};

                    }

                    return null;
                });
            }
Run Code Online (Sandbox Code Playgroud)

我想在右键单击并单击editgallery时将任何参数发送到editDialog

最好的祝福

nca*_*tro 0

最好的方法是在单独的文件中声明对话框

插件.js:

CKEDITOR.dialog.add('editDialog', this.path + 'dialogs/editDialog.js');//
Run Code Online (Sandbox Code Playgroud)

然后,将命令绑定到对话框实例化:

editor.addCommand('editCommand', new CKEDITOR.dialogCommand('editDialog'));
Run Code Online (Sandbox Code Playgroud)

最后,在对话框中处理 onShow 事件,以确定您是在编辑现有元素还是创建新元素:

编辑对话框.js:

onShow: function () {
  var node = 'wscms-gallery';
  var element = editor.getSelection().getStartElement();// Get the element at the start of the selection.
  if (element) {
    element = element.getAscendant(node, true);// Get the <node> element closest to the selection, if it exists.
  }

  if (!element || element.getName() !== node) {// Create a new <node> element if it does not exist.
    element = editor.document.createElement(node);
    this.insertMode = true;
  } else {
    this.insertMode = false;
  }

  this.element = element;
  console.log(element);
  if (!this.insertMode) {
    this.setupContent(this.element); //you MUST to implement the setup: method to get the parameters
  }
},
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请查看这个简单插件的示例