Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the height of CKEditor 5 (Classic Editor)

In CKEditor 4 to change the editor height there was a configuration option: config.height.

How do I change the height of CKEditor 5? (the Classic Editor)

like image 356
Wiktor Walc Avatar asked Oct 04 '17 07:10

Wiktor Walc


People also ask

How do I change CKEditor height?

The CKEDITOR. config. height option sets the height of the editing area with CKEditor 4 content — it does not include the toolbar or the bottom bar. This configuration option accepts an integer (to denote a value in pixels) or any CSS-defined length unit except percent ( % ) values which are not supported.

How do I make CKEditor smaller?

This plugin allows you to resize the classic editor instance by dragging the resize handle (◢) located in the bottom right (or bottom left in the Right-to-Left mode) corner of the editor. It can be configured to make the editor resizable only in one direction (horizontally, vertically) or in both.

How do I add plugins to CKEditor 5?

Adding a plugin to a buildClone the build repository. Install the plugin package. Add it to the build configuration. Bundle the build.


2 Answers

Answering my own question as it might help others.

CKEditor 5 no longer comes with a configuration setting to change its height. The height can be easily controlled with CSS.

There is one tricky thing though, if you use the Classic Editor:

<div id="editor1"></div> 
ClassicEditor     .create( document.querySelector( '#editor1' ) )     .then( editor => {         // console.log( editor );     } )     .catch( error => {         console.error( error );     } ); 

Then the Classic Editor will hide the original element (with id editor1) and render next to it. That's why changing height of #editor1 via CSS will not work.

The simplified HTML structure, after CKEditor 5 (the Classic Editor) renders, looks as follows:

<!-- This one gets hidden --> <div id="editor1" style="display:none"></div>  <div class="ck-reset ck-editor..." ...>     <div ...>         <!-- This is the editable element -->         <div class="ck-blurred ck-editor__editable ck-rounded-corners ck-editor__editable_inline" role="textbox" aria-label="Rich Text Editor, main" contenteditable="true">             ...         </div>     </div> </div> 

In reality the HTML is much more complex, because the whole CKEditor UI is rendered. However the most important element is the "editing area" (or "editing box") marked with a ck-editor__editable_inline class:

<div class="... ck-editor__editable ck-editor__editable_inline ..."> ... </div> 

The "editing area" is the white rectangle where one can enter the text. So to style / change the height of the editing area, it is enough to target the editable element with CSS:

<style> .ck-editor__editable_inline {     min-height: 400px; } </style> 
like image 163
Wiktor Walc Avatar answered Sep 20 '22 04:09

Wiktor Walc


Setting the height via a global stylesheet. Just add to your common .css file (like style.css):

.ck-editor__editable {     min-height: 500px; } 
like image 20
Nikolay Bronskiy Avatar answered Sep 19 '22 04:09

Nikolay Bronskiy