Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEDITOR: Prevent image properties dialog from appearing on <img> double click

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.

like image 811
emgee Avatar asked Feb 10 '23 03:02

emgee


2 Answers

this config worked for me

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

I have version 4.5.4

like image 62
Giovanni Avatar answered Feb 11 '23 17:02

Giovanni


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.com/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.com/ckeditor/ckeditor-dev/blob/major/plugins/dialog/plugin.js#L3355)
);
like image 24
NunoMR Avatar answered Feb 11 '23 15:02

NunoMR