【问题标题】:send data parameter to ckeditor dialog将数据参数发送到 ckeditor 对话框
【发布时间】:2016-08-25 09:20:54
【问题描述】:

我需要将参数数据发送到对话框 这是我在 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;
                });
            }

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

最好的问候

【问题讨论】:

    标签: dialog ckeditor contextmenu


    【解决方案1】:

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

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

    欲了解更多信息,请查看this example of simple plugin

    【讨论】:

      猜你喜欢
      • 2018-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-11
      • 1970-01-01
      • 2012-03-13
      • 1970-01-01
      相关资源
      最近更新 更多