CKEditor 3.0 Height

前端 未结 10 1316
暗喜
暗喜 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:08

    First add a function for resizing your edtior:

    function resizeEditor() {
    
      var defaultHeight = 300;
      var newHeight = window.innerHeight-150; 
      var height = defaultHeight > newHeight ? defaultHeight: newHeight;
    
      CKEDITOR.instances.editor1.resize('100%',height);
    }
    

    Note: 150 works for me, maybe change the value from 150 to more or less.

    Call this from the window onresize Event:

    window.onresize = function() {
      resizeEditor();
    }
    

    and add the first call to the constructor of your editor:

    CKEDITOR.replace('editor1',
      {  
        on:
        {
          instanceReady: function(ev)
          {
            setTimeout(resizeEditor, 500);
          }
        }
      });
    

提交回复
热议问题