STUDIP.domReady(() => { // replace areas visible on page load replaceVisibleTextareas(); // update the height of the editor view on focus changes in dialogs $(document).on('focus blur', '.studip-dialog .ck-editor__editable_inline', function(event) { let height = this.clientHeight; let editor = this.ckeditorInstance; // this is needed on Chrome, see https://gitlab.studip.de/studip/studip/-/issues/3510 setTimeout(() => { editor.editing.view.change(writer => { writer.setStyle('height', height + 'px', editor.editing.view.document.getRoot()); }); }); }); // replace areas that are created or shown after page load // remove editors that become hidden after page load // show, hide and create do not raise an event, use interval timer setInterval(replaceVisibleTextareas, 300); // when attaching to hidden textareas, or textareas who's parents are // hidden, the editor does not function properly; therefore attach to // visible textareas only function replaceVisibleTextareas() { const textareas = document.querySelectorAll('textarea.wysiwyg:not(.has-editor)'); textareas.forEach(node => { STUDIP.wysiwyg.replace(node); node.classList.add('has-editor'); }); } });