fix: Editor 回显 - key+initialValue 替代 value 受控
- key={id} 确保切换模板时 Editor 重新挂载加载正确内容
- initialValue 仅首次加载,无 value 避免编辑被覆盖
- 移除 setup.init 重复调用(已由 onInit 处理)
This commit is contained in:
parent
7826a1af38
commit
132d13ef42
|
|
@ -337,11 +337,10 @@ export default function TemplateEditor() {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Editor
|
<Editor
|
||||||
|
key={id}
|
||||||
tinymceScriptSrc="/tinymce/tinymce.min.js"
|
tinymceScriptSrc="/tinymce/tinymce.min.js"
|
||||||
onInit={(_evt, editor) => {
|
initialValue={htmlContent}
|
||||||
handleEditorInit(null, editor);
|
onInit={handleEditorInit}
|
||||||
if (htmlContent) editor.setContent(htmlContent);
|
|
||||||
}}
|
|
||||||
init={{
|
init={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
menubar: true,
|
menubar: true,
|
||||||
|
|
@ -355,11 +354,7 @@ export default function TemplateEditor() {
|
||||||
toolbar:
|
toolbar:
|
||||||
"undo redo | blocks | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help",
|
"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; }",
|
content_style: "body { font-family: Arial, sans-serif; font-size: 14px; }",
|
||||||
setup: (editor) => {
|
}}
|
||||||
editor.on("init", () => {
|
|
||||||
handleEditorInit(null, editor);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue