Commit 7393e427 authored by webchick's avatar webchick

Issue #2239419 by thpoul, Wim Leers, webchick, maczizek, xjm, mlewand, Jeff...

Issue #2239419 by thpoul, Wim Leers, webchick, maczizek, xjm, mlewand, Jeff Burnz, tstoeckler, Tade0, Bojhan, yoroy, tkoleary, darketaine, hass, sun, maxilein, nod_, alexpott, Feuerwagen, oleq: Include CKEditor's AutoGrow plug-in
parent 7f4cbc43
......@@ -58,7 +58,6 @@ var CKBUILDER_CONFIG = {
'blockquote' : 1,
'clipboard' : 1,
'contextmenu' : 1,
'resize' : 1,
'toolbar' : 1,
'elementspath' : 1,
'enterkey' : 1,
......@@ -92,6 +91,7 @@ var CKBUILDER_CONFIG = {
'sharedspace' : 1,
'sourcedialog' : 1,
'widget' : 1,
'image2' : 1
'image2' : 1,
'autogrow' : 1
}
};
This diff is collapsed.
......@@ -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,15 @@
}
});
// 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 autoGrow to make the editor grow the moment it is created.
CKEDITOR.config.autoGrow_onStartup = true;
// 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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment