diff --git a/core/modules/ckeditor/js/ckeditor.js b/core/modules/ckeditor/js/ckeditor.js index 497393f..bfc560a 100644 --- a/core/modules/ckeditor/js/ckeditor.js +++ b/core/modules/ckeditor/js/ckeditor.js @@ -3,7 +3,7 @@ * CKEditor implementation of {@link Drupal.editors} API. */ -(function (Drupal, debounce, CKEDITOR, $) { +(function (Drupal, debounce, CKEDITOR, $, displace) { 'use strict'; @@ -85,6 +85,26 @@ editor.on('change', debounce(function () { callback(editor.getData()); }, 400)); + + // A temporary workaround to control scrollbar appearance when using + // autoGrow event to control editor's height. + // @todo Remove when http://dev.ckeditor.com/ticket/12120 is fixed. + editor.on('mode', function () { + var editable = editor.editable(); + if (!editable.isInline()) { + editor.on('autoGrow', function (evt) { + var doc = evt.editor.document; + var scrollable = CKEDITOR.env.quirks ? doc.getBody() : doc.getDocumentElement(); + + if (scrollable.$.scrollHeight < scrollable.$.clientHeight) { + scrollable.setStyle('overflow-y', 'hidden'); + } + else { + scrollable.removeStyle('overflow-y'); + } + }, null, null, 10000); + } + }); } return !!editor; }, @@ -273,7 +293,12 @@ } }); + // Formulate a default formula for the maximum autoGrow height. + $(document).on('drupalViewportOffsetChange', function () { + CKEDITOR.config.autoGrow_maxHeight = 0.7 * (window.innerHeight - displace.offsets.top - displace.offsets.bottom); + }); + // Set the CKEditor cache-busting string to the same value as Drupal. CKEDITOR.timestamp = drupalSettings.ckeditor.timestamp; -})(Drupal, Drupal.debounce, CKEDITOR, jQuery); +})(Drupal, Drupal.debounce, CKEDITOR, jQuery, Drupal.displace);