21
This commit is contained in:
parent
581af8bbbc
commit
c35246e2cc
|
|
@ -164,9 +164,17 @@ const handleCreated = (editor: IDomEditor) => {
|
|||
editorRef.value = editor
|
||||
|
||||
// 如果有内容,设置到编辑器
|
||||
// 使用 nextTick 确保编辑器完全初始化后再设置内容
|
||||
if (formData.content) {
|
||||
console.log('[DanyeFormDialog] Setting initial content to editor:', formData.content.substring(0, 100))
|
||||
editor.setHtml(formData.content)
|
||||
// 先清空编辑器,再设置新内容,避免 operations 历史记录冲突
|
||||
editor.clear()
|
||||
// 使用 setTimeout 确保 clear 操作完成后再设置内容
|
||||
setTimeout(() => {
|
||||
if (!editor.isDestroyed) {
|
||||
editor.setHtml(formData.content)
|
||||
}
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,6 +187,16 @@ watch(() => props.modelValue, (visible) => {
|
|||
console.log('[DanyeFormDialog] formData.content set to:', formData.content.substring(0, 100))
|
||||
console.log('[DanyeFormDialog] editorRef.value:', editorRef.value)
|
||||
console.log('[DanyeFormDialog] editorRef.value?.isDestroyed:', editorRef.value?.isDestroyed)
|
||||
|
||||
// 如果编辑器已存在且未销毁,直接设置内容
|
||||
if (editorRef.value && !editorRef.value.isDestroyed) {
|
||||
editorRef.value.clear()
|
||||
setTimeout(() => {
|
||||
if (editorRef.value && !editorRef.value.isDestroyed) {
|
||||
editorRef.value.setHtml(formData.content)
|
||||
}
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user