CKEditor 3 Dialog Positioning

China☆狼群 提交于 2019-12-10 17:34:58

问题


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:


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.



来源:https://stackoverflow.com/questions/12752180/ckeditor-3-dialog-positioning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!