fix(editor): don't crash when the component isn't completely mounted
This commit is contained in:
parent
f45303c2e3
commit
0c58ea1ade
@ -494,8 +494,8 @@ function setLink() {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
internalMode.value = initialMode
|
internalMode.value = initialMode
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
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)
|
||||||
})
|
})
|
||||||
if (editShortcut !== '') {
|
if (editShortcut !== '') {
|
||||||
document.addEventListener('keydown', setFocusToEditor)
|
document.addEventListener('keydown', setFocusToEditor)
|
||||||
@ -504,8 +504,8 @@ onMounted(() => {
|
|||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const input = tiptapInstanceRef.value.querySelectorAll('.tiptap__editor')[0].children[0]
|
const input = tiptapInstanceRef.value?.querySelectorAll('.tiptap__editor')[0]?.children[0]
|
||||||
input.removeEventListener('paste', handleImagePaste)
|
input?.removeEventListener('paste', handleImagePaste)
|
||||||
})
|
})
|
||||||
if (editShortcut !== '') {
|
if (editShortcut !== '') {
|
||||||
document.removeEventListener('keydown', setFocusToEditor)
|
document.removeEventListener('keydown', setFocusToEditor)
|
||||||
@ -554,7 +554,10 @@ watch(
|
|||||||
() => isEditing.value,
|
() => isEditing.value,
|
||||||
editing => {
|
editing => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const checkboxes = tiptapInstanceRef.value.querySelectorAll('[data-checked]')
|
const checkboxes = tiptapInstanceRef.value?.querySelectorAll('[data-checked]')
|
||||||
|
if (typeof checkboxes === 'undefined' || checkboxes.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (editing) {
|
if (editing) {
|
||||||
checkboxes.forEach(check => {
|
checkboxes.forEach(check => {
|
||||||
if (check.children.length < 2) {
|
if (check.children.length < 2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user