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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.value.commands.setContent(value, false)
|
setModeAndValue(value)
|
||||||
},
|
},
|
||||||
{immediate: true},
|
{immediate: true},
|
||||||
)
|
)
|
||||||
@ -501,8 +501,7 @@ onMounted(async () => {
|
|||||||
const input = tiptapInstanceRef.value?.querySelectorAll('.tiptap__editor')[0]?.children[0]
|
const input = tiptapInstanceRef.value?.querySelectorAll('.tiptap__editor')[0]?.children[0]
|
||||||
input?.addEventListener('paste', handleImagePaste)
|
input?.addEventListener('paste', handleImagePaste)
|
||||||
|
|
||||||
internalMode.value = isEditorContentEmpty(modelValue) ? 'edit' : 'preview'
|
setModeAndValue(modelValue)
|
||||||
editor.value?.commands.setContent(modelValue, false)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
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) {
|
function handleImagePaste(event) {
|
||||||
if (event?.clipboardData?.items?.length === 0) {
|
if (event?.clipboardData?.items?.length === 0) {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user