fix: prevent error in toggleList command, fix #2279

This commit is contained in:
Philipp Kühn 2021-12-15 10:51:23 +01:00
parent 47b25a626d
commit 66eb2f2a47

View File

@ -14,6 +14,11 @@ const joinListBackwards = (tr: Transaction, listType: NodeType): boolean => {
}
const before = tr.doc.resolve(Math.max(0, list.pos - 1)).before(list.depth)
if (before === undefined) {
return true
}
const nodeBefore = tr.doc.nodeAt(before)
const canJoinBackwards = list.node.type === nodeBefore?.type
&& canJoin(tr.doc, list.pos)
@ -35,6 +40,11 @@ const joinListForwards = (tr: Transaction, listType: NodeType): boolean => {
}
const after = tr.doc.resolve(list.start).after(list.depth)
if (after === undefined) {
return true
}
const nodeAfter = tr.doc.nodeAt(after)
const canJoinForwards = list.node.type === nodeAfter?.type
&& canJoin(tr.doc, after)