fix: Tinymce切换菜单会造成disabled失效 https://gitee.com/dapppp/ruoyi-plus-vben5/issues/IAL8BD

This commit is contained in:
孟彦祖 2024-08-29 16:28:04 +08:00 committed by 玲娜贝er
parent 9056f6a543
commit 5c569939c6

View File

@ -5,6 +5,7 @@ import type { Editor as EditorType } from 'tinymce/tinymce';
import { import {
computed, computed,
nextTick, nextTick,
onActivated,
onBeforeUnmount, onBeforeUnmount,
onDeactivated, onDeactivated,
onMounted, onMounted,
@ -120,9 +121,7 @@ watch(
nextTick(() => { nextTick(() => {
init.value = true; init.value = true;
setTimeout(() => { setTimeout(() => {
// / setEditorMode();
const mode = props.options.readonly ? 'readonly' : 'design';
editorRef.value?.mode.set(mode);
}); });
}); });
}, },
@ -220,6 +219,7 @@ onMounted(() => {
nextTick(() => { nextTick(() => {
setTimeout(() => { setTimeout(() => {
initEditor(); initEditor();
setEditorMode();
}, 30); }, 30);
}); });
}); });
@ -232,6 +232,18 @@ onDeactivated(() => {
destroy(); destroy();
}); });
onActivated(() => {
setEditorMode();
});
function setEditorMode() {
const editor = unref(editorRef);
if (editor) {
const mode = props.options.readonly ? 'readonly' : 'design';
editor.mode.set(mode);
}
}
function destroy() { function destroy() {
const editor = unref(editorRef); const editor = unref(editorRef);
editor?.destroy(); editor?.destroy();