Programmatically set the position of CKEditor's dialogs

跟風遠走 提交于 2020-01-30 06:11:28

问题


I'm trying to find a way to programmatically set the position of a CKEditor dialog whenever a new one is opened up. The actual setting of the position part seems easy, but what I can't seem to figure out is how to trap the event of a new CKEditor dialog being created and shown.

I'm assuming it will be something along the lines of...

CKEDITOR.on('dialogCreated', function(e) { ... } );

But can't seem to actually find it in the documentation.


回答1:


After spending several hours today, I was able to figure this out by complete luck. Dialog definitions can be manipulated at load time. Within your config.js file, add the following:

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

    dialogDefinition.onShow = function() {
        // Calculate your newX and newY ...
        this.move(newX, newY);
    }
}

If you want to adjust the position for a specific dialog you can use dialogName to test for it.



来源:https://stackoverflow.com/questions/3407896/programmatically-set-the-position-of-ckeditors-dialogs

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