From 5c569939c67bee5ba492917611c38404a7dc5b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E5=BD=A6=E7=A5=96?= Date: Thu, 29 Aug 2024 16:28:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Tinymce=E5=88=87=E6=8D=A2=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E4=BC=9A=E9=80=A0=E6=88=90disabled=E5=A4=B1=E6=95=88?= =?UTF-8?q?=20https://gitee.com/dapppp/ruoyi-plus-vben5/issues/IAL8BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Tinymce/src/Editor.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/web-antd/src/components/Tinymce/src/Editor.vue b/apps/web-antd/src/components/Tinymce/src/Editor.vue index f1562083..2fa33dd9 100644 --- a/apps/web-antd/src/components/Tinymce/src/Editor.vue +++ b/apps/web-antd/src/components/Tinymce/src/Editor.vue @@ -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();