fix: Editor 回显 - key+initialValue 替代 value 受控

- key={id} 确保切换模板时 Editor 重新挂载加载正确内容
- initialValue 仅首次加载,无 value 避免编辑被覆盖
- 移除 setup.init 重复调用(已由 onInit 处理)
This commit is contained in:
zwt13703 2026-07-06 22:05:05 +08:00
parent 7826a1af38
commit 132d13ef42
1 changed files with 4 additions and 9 deletions

View File

@ -337,11 +337,10 @@ export default function TemplateEditor() {
</div>
)}
<Editor
key={id}
tinymceScriptSrc="/tinymce/tinymce.min.js"
onInit={(_evt, editor) => {
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);
});
},
}}
}}
/>
</Content>