ckeditor dialog positioning

前端 未结 5 1526
臣服心动
臣服心动 2021-01-17 16:40

Dialog windows for CKEditor by default appear in the middle of the page but if the page is an iframe with a big height the dialogs appear way down the page.

Is it po

5条回答
  •  春和景丽
    2021-01-17 17:19

    I just had the same issue as Yehonatan and found this question really fast via Google. But after using the answer provided by zaf I still didn't get a dialog to appear in the proper position when the editor is loaded within an iframe.

    In stead of the position() method I used the offset() method to place a dialog right under the toolbar. Together with the response of jonespm I came to this code that seems to work very good, also with existing dialogs.

    CKEDITOR.on('dialogDefinition', function(e) {
     var dialogName = e.data.name;
     var dialogDefinition = e.data.definition;
     var onShow = dialogDefinition.onShow;
    
     dialogDefinition.onShow = function() {
    
        this.move(this.getPosition().x, jQuery(this.getParentEditor().container.$).offset().top);
    
        if (typeof onShow !== 'undefined' && typeof onShow.call === 'function')
        {
            return onShow.call(this);
        }
    
     }  
    });
    

    Hopefully this code can help others with the same issue as me.

提交回复
热议问题