mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 14:13:21 +08:00
fix: prevent error in toggleList command, fix #2279
This commit is contained in:
parent
47b25a626d
commit
66eb2f2a47
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user