blob: 9e18cf875e1b5a9e82af97515969658fd5c8f6b4 (
plain)
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
29
30
31
32
|
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');
});
}
});
|