Search code examples
dialogckeditorundefined

CKEditor: Using dialogDefinition.onShow() throws C.preview not defined


Modifying CKEditor 3.6.2 is not easy, but I tried hard. One problem that is still open is the following:

In config.js we have:

CKEDITOR.on( 'dialogDefinition', function( ev ) {
  var dialogName = ev.data.name;
  var dialogDefinition = ev.data.definition;
  if(dialogName == 'image') {
    dialogDefinition.onShow = function () {
        var dialog = CKEDITOR.dialog.getCurrent(); 

        var elem = dialog.getContentElement('info','htmlPreview');  
        elem.getElement().hide();
        // and more stuff to do...
    };

}
});

After the editor is loaded, and the user has uploaded an image, the following javascript error is thrown:

Error: C.preview is undefined
Source File: wysiwyg-editor/plugins/image/dialogs/image.js?t=B8DJ5M3
Line: 8

dialogDefinition.onShow seems to cause this error, as removing all elements from the code, and only calling onShow brings up the error. Using onLoad does work! Using onShow on other dialogs is working fine, only the image dialog is not working as it should.

Btw, I asked in the CKEditor forum but nobody answered.


Solution

  • Stumbled across this when I was looking for a resolution. Figured I'd post what I ultimately did to solve it, albeit not 100% ideal.

    CKEDITOR.on( 'dialogDefinition', function( ev ) {
      var tab, field, name = ev.data.name,
          definition = ev.data.definition;
    
      if( name == 'image' )
      {
        tab = definition.getContents( 'info' );
        field = tab.get( 'htmlPreview' );
        field.style = 'display: none';
      }
    });
    

    This makes the preview window available for processing, just hides it from the dialog window.