fix(editor): keep editor open when emptying content from the outside
This commit is contained in:
parent
af13d68c48
commit
9efe860f26
@ -394,7 +394,7 @@ watch(
|
||||
return
|
||||
}
|
||||
|
||||
editor.value.commands.setContent(value, false)
|
||||
setModeAndValue(value)
|
||||
},
|
||||
{immediate: true},
|
||||
)
|
||||
@ -501,8 +501,7 @@ onMounted(async () => {
|
||||
const input = tiptapInstanceRef.value?.querySelectorAll('.tiptap__editor')[0]?.children[0]
|
||||
input?.addEventListener('paste', handleImagePaste)
|
||||
|
||||
internalMode.value = isEditorContentEmpty(modelValue) ? 'edit' : 'preview'
|
||||
editor.value?.commands.setContent(modelValue, false)
|
||||
setModeAndValue(modelValue)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@ -515,6 +514,11 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
})
|
||||
|
||||
function setModeAndValue(value: string) {
|
||||
internalMode.value = isEditorContentEmpty(value) ? 'edit' : 'preview'
|
||||
editor.value?.commands.setContent(value, false)
|
||||
}
|
||||
|
||||
function handleImagePaste(event) {
|
||||
if (event?.clipboardData?.items?.length === 0) {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user