插入每个新控件后的CKEDITOR触发对话框

时间:2018-07-06 20:01:41

标签: javascript ckeditor

我正在使用insertHTML方法将标记(带有标题的图像)插入CKEDITOR。我已经创建了一个小部件定义,所以这个新标记被转换/转换为ckeditor小部件。

我还在这些小部件上定义了一个对话框,该对话框允许通过对话框窗口来编辑内容。

我可以将新的小部件插入ckeditor中。当我双击每个窗口小部件时,对话框将打开,并且当我更改对话框字段中的值时,它将更新窗口小部件。

但是我需要强迫用户使用对话框在插入的窗口小部件内容中添加值。

问题: 通过insertHTML方法将新的小部件添加到ckeditor时,如何触发为小部件定义的编辑对话框?

plugin.js

(function($){ CKEDITOR.plugins.add('insert_img', {
init: function(editor) {

  editor.addCommand('insert_img', new CKEDITOR.dialogCommand('insertImgDialog'));

  // Register the widget.
  editor.widgets.add('insert_img', {
    // The divs with these classes can be found in the theme template files.
    allowedContent: 'div(!insertArea); div(!caption); div(!insertArea--origin)',
    dialog: 'insertImgDialog',
    upcast: function(element, data) {
      if (element.name == 'div' && element.hasClass('insertArea')) {
        return true;
      }
      else {
        return false;
      }
    },
    init: function() {
      this.on('ready', function() {
      //   this.edit();
        this.fire('doubleclick');
      });
    }
  });

  CKEDITOR.dialog.add('insertImgDialog', this.path + 'dialogs/insert_img.js');
}  }); })(jQuery);

我尝试使用edit()并触发doublclick事件(这将打开对话框),但是它没有为正确的窗口小部件实例打开对话框。它有时是编辑器中的第一个窗口小部件实例,有时似乎为未定义的窗口小部件打开对话框。

0 个答案:

没有答案
相关问题