From 132d13ef4244c7274d0c9ab5b4bbf27516801eca Mon Sep 17 00:00:00 2001 From: zwt13703 Date: Mon, 6 Jul 2026 22:05:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Editor=20=E5=9B=9E=E6=98=BE=20-=20key+in?= =?UTF-8?q?itialValue=20=E6=9B=BF=E4=BB=A3=20value=20=E5=8F=97=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - key={id} 确保切换模板时 Editor 重新挂载加载正确内容 - initialValue 仅首次加载,无 value 避免编辑被覆盖 - 移除 setup.init 重复调用(已由 onInit 处理) --- web/src/pages/TemplateEditor.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/web/src/pages/TemplateEditor.tsx b/web/src/pages/TemplateEditor.tsx index 2da8808..54c5b8b 100644 --- a/web/src/pages/TemplateEditor.tsx +++ b/web/src/pages/TemplateEditor.tsx @@ -337,11 +337,10 @@ export default function TemplateEditor() { )} { - handleEditorInit(null, editor); - if (htmlContent) editor.setContent(htmlContent); - }} + initialValue={htmlContent} + onInit={handleEditorInit} init={{ height: "100%", menubar: true, @@ -355,11 +354,7 @@ export default function TemplateEditor() { toolbar: "undo redo | blocks | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help", content_style: "body { font-family: Arial, sans-serif; font-size: 14px; }", - setup: (editor) => { - editor.on("init", () => { - handleEditorInit(null, editor); - }); - }, + }} }} />