Include autoheight plugin for Tinymce

This commit is contained in:
Diego Najar 2018-10-30 22:40:13 +01:00
parent 7227b85086
commit 47412a651d
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,41 @@
tinymce.PluginManager.add('autoheight', function(editor) {
var editor_container;
var bars_height = 0;
function resizeEditor(e) {
if (typeof(editor_container) === 'undefined') return;
try {
var element_height = parseInt(window.getComputedStyle(editor_container).height);
/*calculate bar height only once*/
if (bars_height === 0) {
var toolbars = editor_container.querySelectorAll('.mce-toolbar, .mce-statusbar, .mce-menubar');
/*IE11 FIX*/
var toolbarsLength = toolbars.length;
for (var i = 0; i < toolbarsLength; i++) {
var toolbar = toolbars[i];
/*skip sidebar*/
if (!toolbar.classList.contains('mce-sidebar-toolbar')) {
var bar_height = parseInt(window.getComputedStyle(toolbar).height);
bars_height += bar_height;
}
}
}
/*the extra 8 is for margin added between the toolbars*/
new_height = element_height - bars_height - 8;
editor.theme.resizeTo('100%', new_height);
} catch (err) {
console.log(err);
}
}
editor.on('ResizeWindow', resizeEditor);
editor.on("init", function() {
try {
editor_container = editor.getContainer().parentNode;
} catch (e) {}
setTimeout(function() {
resizeEditor();
}, 10);
});
});

View File

@ -517,7 +517,7 @@ function install($adminPassword, $timezone)
'position'=>1,
'toolbar1'=>'formatselect bold italic bullist numlist | blockquote alignleft aligncenter alignright | link unlink pagebreak image removeformat code',
'toolbar2'=>'',
'plugins'=>'code autolink image link pagebreak advlist lists textcolor colorpicker textpattern'
'plugins'=>'code autolink image link pagebreak advlist lists textcolor colorpicker textpattern autoheight'
),
JSON_PRETTY_PRINT),
LOCK_EX