CKEditor 3.0 Height

前端 未结 10 1279
暗喜
暗喜 2020-12-29 08:36

Is there a way to set the height of CKEditor 3.0 to a percentage, such as 100%, such that it takes up the whole window?

I am currently using absolute values, but the

10条回答
  •  生来不讨喜
    2020-12-29 09:26

    I have been looking for a clean way to get the CKEditor window to be the same height as the textarea it is replacing. I'm using Drupal, and this is how I did it ...

    In my theme I load up a javascript file, (using "scripts[] = default.js" in my .info file).

    In this file I have:

    $(document).ready(function(){ 
    
        // Set CKEditor height
        if (typeof CKEDITOR!='undefined') {
            CKEDITOR.on( 'instanceReady', function( e ) {
                e.editor.element.show();
                var elHeight = $(e.editor.element.$).height();
                e.editor.element.hide();
                e.editor.resize('100%', elHeight, true);
            });
        }
    }
    

    The beauty of this is you can then change the height using css.

    I had been changing the settings.height via the wysiwyg module in wysiwyg/editors/js/ckeditor-3.0.js

    Drupal.wysiwyg.editor.attach.ckeditor = function(context, params, settings) {
        // Apply editor instance settings.
        CKEDITOR.config.customConfig = '';
    
        // Match the height of the replaced field
        settings.height = $('#' + params.field).height();
    }
    

    but this would get overwritten during updates, so went with the top solution.

提交回复
热议问题