Skip to content
Snippets Groups Projects
Commit 081369a5 authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

do not destroy the editor when it is hidden, fixes #3434

Closes #3434

Merge request studip/studip!2350
parent ac94824e
No related branches found
No related tags found
No related merge requests found
......@@ -33,36 +33,19 @@ const wysiwyg = {
getEditor,
hasEditor,
replace(textarea) {
if (!hasEditor(textarea)) {
if (isTextareaVisible(textarea)) {
replaceTextarea(textarea);
}
} else if (isEditorHidden(textarea)) {
destroyTextarea(textarea);
}
},
replace: replaceTextarea,
};
export default wysiwyg;
function isTextareaVisible(textarea) {
return $(textarea).is(':visible');
}
function isEditorHidden(textarea) {
if (!hasEditor(textarea)) {
return false;
}
const editor = getEditor(textarea);
return editor && editor.ui && $(editor.ui.element).is(':hidden');
}
async function replaceTextarea(textarea) {
await loadMathJax();
if (hasEditor(textarea)) {
return getEditor(textarea);
}
setEditor(textarea, {});
await loadMathJax();
const chunk = await STUDIP.loadChunk('wysiwyg');
const $textarea = textarea instanceof jQuery ? textarea : $(textarea);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment