resize CKEditor4 by windows.resize events

2019-09-18 07:41发布

问题:

I not need the "user ability to resize", but an automatic resize triggered by windows.resize events.

Translating my necessity into an hipothetical/intentional code (it not works!), for my applicartion:

    $( window ).resize(function() {
        editor = CKEDITOR.instances.editor1;
        editor.height = window.innerHeight - 106;
        editor.width  = window.innerWidth  - 253;
    });

How to implement this kind of resize with CKEditor4? I am using standard editor at textarea.


PS: the name of the behaviour is perhaps "Change the Size of the Editor on the Fly", but my necessity is not about config by percentual width, see the required subtractions.

回答1:

Well... just use the editor.resize() method ;)

$( window ).resize(function() {
    editor = CKEDITOR.instances.editor1;
    editor.resize( window.innerWidth  - 253, window.innerHeight - 106 );
});