CKEditor 3 Dialog Positioning

2019-06-25 13:24发布

I have checked and tried the method posted here to set where CKEditor dialogs pop up:

Programatically set the position of CKEditor's dialogs

This seems to either be deprecated or incomplete. When attempting this for the 'link' dialog, the dialog box does not format correctly, as if this onShow definition replaces the default action rather than adding to it. Any suggestions to alter this code or a new method to position the link dialog closer to the menu bar?

CKEDITOR.on('dialogDefinition', function(e) {
   var dialogDefinition = e.data.definition;

   dialogDefinition.onShow = function() {
       this.move(200, 100);
   }
})

1条回答
混吃等死
2楼-- · 2019-06-25 14:06

You're right. Your code is overwriting the basic onShow definition.

What you have to do is simply to save a default (generic) onShow, then overwrite it so it calls the saved one and eventually executes your code:

CKEDITOR.on( 'dialogDefinition', function( event ) {
    var dialogDefinition = event.data.definition,
        genericOnShow = dialogDefinition.onShow;

    dialogDefinition.onShow = function() {
        genericOnShow.apply( this );
        this.move( 10, 10 );
        // ...or anything you want ;)
    }
});

Voilà!

PS. Remember to always pass the context with apply or call.

查看更多
登录 后发表回答