|
|
@ -108,7 +108,7 @@ const editor = useEditor({ |
|
|
|
editable: !props.readonly, |
|
|
|
editable: !props.readonly, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const setEditorContent = (contentMd: any) => { |
|
|
|
const setEditorContent = (contentMd: any, focusEndOfDoc?: boolean) => { |
|
|
|
if (!editor.value) return |
|
|
|
if (!editor.value) return |
|
|
|
|
|
|
|
|
|
|
|
const selection = editor.value.view.state.selection |
|
|
|
const selection = editor.value.view.state.selection |
|
|
@ -120,6 +120,15 @@ const setEditorContent = (contentMd: any) => { |
|
|
|
editor.value.chain().setContent(content).setTextSelection(selection.to).run() |
|
|
|
editor.value.chain().setContent(content).setTextSelection(selection.to).run() |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
if (focusEndOfDoc) { |
|
|
|
|
|
|
|
const docSize = editor.value!.state.doc.nodeSize |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
editor.value |
|
|
|
|
|
|
|
?.chain() |
|
|
|
|
|
|
|
.setTextSelection(docSize - 1) |
|
|
|
|
|
|
|
.run() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
;(editor.value!.state as any).history$.prevRanges = null |
|
|
|
;(editor.value!.state as any).history$.prevRanges = null |
|
|
|
;(editor.value!.state as any).history$.done.eventCount = 0 |
|
|
|
;(editor.value!.state as any).history$.done.eventCount = 0 |
|
|
|
}, 100) |
|
|
|
}, 100) |
|
|
@ -134,7 +143,7 @@ if (props.syncValueChange) { |
|
|
|
watch(editorDom, () => { |
|
|
|
watch(editorDom, () => { |
|
|
|
if (!editorDom.value) return |
|
|
|
if (!editorDom.value) return |
|
|
|
|
|
|
|
|
|
|
|
setEditorContent(vModel.value) |
|
|
|
setEditorContent(vModel.value, true) |
|
|
|
|
|
|
|
|
|
|
|
// Focus editor after editor is mounted |
|
|
|
// Focus editor after editor is mounted |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|