-
Notifications
You must be signed in to change notification settings - Fork 0
/
ckeditorheight.js
28 lines (25 loc) · 1.09 KB
/
ckeditorheight.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Drupal.editors.ckeditor.attach = function(method, drupalSettings, CKEDITOR, $) {
return function (element, format)
{
var toPx = function(value) {
var element = jQuery('<div style="display: none; font-size: ' + value + '; margin: 0; padding:0; height: auto; line-height: 1; border:0;"> </div>').appendTo('body');
var height = element.height();
element.remove();
return height;
};
var rows = element.getAttribute("rows");
if (rows) {
// Calculate heightInPx.
drupalSettings.ckeditorheight = drupalSettings.ckeditorheight || {};
var heightInPx = toPx((rows * 1.5 + 1) + 'em');
// Override the height.
var editorSettingsOverrides = {
height: heightInPx,
autoGrow_minHeight: heightInPx
};
var overriddenEditorSettings = $.extend({}, format.editorSettings, editorSettingsOverrides);
var overriddenFormat = $.extend({}, format, {editorSettings: overriddenEditorSettings});
}
return method.apply(this, [element, overriddenFormat]);
}
}(Drupal.editors.ckeditor.attach, drupalSettings, CKEDITOR, jQuery);