Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save muath-ye/a8515b92f30377137fae53f5a3d619a1 to your computer and use it in GitHub Desktop.
Save muath-ye/a8515b92f30377137fae53f5a3d619a1 to your computer and use it in GitHub Desktop.
How get the height from document body in CKEDITOR
<textarea name="editor1">Type here and show console to see editor's height</textarea>
CKEDITOR.replace( 'editor1' );
CKEDITOR.on( 'instanceReady', function( evt )
{
var editor = evt.editor;
editor.on('change', function (e) {
var contentSpace = editor.ui.space('contents');
var ckeditorFrameCollection = contentSpace.$.getElementsByTagName('iframe');
var ckeditorFrame = ckeditorFrameCollection[0];
var innerDoc = ckeditorFrame.contentDocument;
var innerDocTextAreaHeight = $(innerDoc.body).height();
console.log(innerDocTextAreaHeight);
});
});
<script src="https://cdn.ckeditor.com/4.13.0/standard/ckeditor.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment