最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - CKEDITOR: Prevent image properties dialog from appearing on <img> double click - Stack Overflow

programmeradmin0浏览0评论

I'm working with CKEDITOR 4.5.1 and would like to disable the image properties dialog from appearing when an image is double-clicked within the editor.

After searching I came across what looked to be the solution, which is the following:

 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.

The code does trigger and does set dialog to null, however, the default image properties dialog still appears. My assumption is the listener within CKEDITOR is running after the above code executes and sets the dialog. I've tried different values in place of 10000 with no success.

I'm working with CKEDITOR 4.5.1 and would like to disable the image properties dialog from appearing when an image is double-clicked within the editor.

After searching I came across what looked to be the solution, which is the following:

 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.

The code does trigger and does set dialog to null, however, the default image properties dialog still appears. My assumption is the listener within CKEDITOR is running after the above code executes and sets the dialog. I've tried different values in place of 10000 with no success.

Share Improve this question asked Sep 4, 2015 at 23:26 emgeeemgee 5204 silver badges19 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

this config worked for me

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

I have version 4.5.4

If you want to programmatically disable the image popup on some condition you must set the event priority to 998 (and e.data.dialog = null).

The dialog plugin runs with priority 999 (https://github./ckeditor/ckeditor-dev/blob/major/plugins/dialog/plugin.js#L3355) so anything after that will have no effect and anything below 998 might run before e.data.dialog being set.

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./ckeditor/ckeditor-dev/blob/major/plugins/dialog/plugin.js#L3355)
);
发布评论

评论列表(0)

  1. 暂无评论