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