【问题标题】:CKEDITOR: Prevent image properties dialog from appearing on <img> double clickCKEDITOR:防止图像属性对话框出现在 <img> 双击
【发布时间】:2015-09-04 23:26:33
【问题描述】:

我正在使用 CKEDITOR 4.5.1,并希望禁止在编辑器中双击图像时出现图像属性对话框。

搜索后,我发现了一个看起来是解决方案的方法,如下所示:

 CKEDITOR.instances.pageContent.on( 'doubleclick', function( evt ) {
    var element = evt.data.element;
    if ( element.is( 'img' ) && !element.data( 'cke-realelement' ) && !element.isReadOnly() ){
       evt.data.dialog = null;
    }
 }, null, null, 10000) ;//priority has to be higher than image priority.

代码确实触发并将对话框设置为空,但是,默认图像属性对话框仍然出现。我的假设是 CKEDITOR 中的侦听器在上述代码执行并设置对话框后运行。我尝试了不同的值来代替 10000,但没有成功。

【问题讨论】:

    标签: javascript jquery ckeditor


    【解决方案1】:

    这个配置对我有用

    CKEDITOR.config.removePlugins = 'image,forms';

    我有 4.5.4 版

    【讨论】:

    • 感谢您的信息。以上结合添加了一个自定义按钮,如图所示here 让我达到了我想要实现的目标。
    【解决方案2】:

    如果您想在某些情况下以编程方式禁用图像弹出窗口,您必须将事件优先级设置为 998(和e.data.dialog = null)。

    对话框插件以优先级 999 (https://github.com/ckeditor/ckeditor-dev/blob/major/plugins/dialog/plugin.js#L3355) 运行,因此之后的任何内容都将无效,低于 998 的任何内容都可能在设置 e.data.dialog 之前运行。

    editor.on(
      'doubleclick',
      function(e) {
        var element = e && e.data && e.data.element;
        if (element && element.is('img') && element.getAttribute('class').indexOf('something') >= 0) {
          e.data.dialog = null;
        }
      },
      null,
      null,
      998 // Needs to be below 999 because thats when the dialog plugin will run (https://github.com/ckeditor/ckeditor-dev/blob/major/plugins/dialog/plugin.js#L3355)
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-02
      • 1970-01-01
      • 1970-01-01
      • 2014-09-09
      • 1970-01-01
      相关资源
      最近更新 更多