向CKEditor对话框发送数据参数。

5
我需要向对话框发送参数数据。 这是我在插件.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;
                });
            }

我希望右键单击并点击编辑图库时,向editDialog发送任何参数。

最好的祝愿

1个回答

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

plugin.js:

CKEDITOR.dialog.add('editDialog', this.path + 'dialogs/editDialog.js');//

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

editor.addCommand('editCommand', new CKEDITOR.dialogCommand('editDialog'));

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

editDialog.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
  }
},

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接