mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-28 23:50:41 +08:00
fix(NodePos): add validation for target position within document range (#6487)
* fix(NodePos): add validation for target position within document range * Create rich-jeans-check.md * fix: lint --------- Co-authored-by: bdbch <6538827+bdbch@users.noreply.github.com>
This commit is contained in:
parent
3835976faa
commit
9390e024ed
5
.changeset/rich-jeans-check.md
Normal file
5
.changeset/rich-jeans-check.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tiptap/core": patch
|
||||
---
|
||||
|
||||
Add validation for target position within document range when trying to access children of a `NodePos` instance
|
@ -138,6 +138,12 @@ export class NodePos {
|
||||
const isNonTextAtom = node.isAtom && !node.isText
|
||||
|
||||
const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1)
|
||||
|
||||
// Check if targetPos is within valid document range
|
||||
if (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) {
|
||||
return
|
||||
}
|
||||
|
||||
const $pos = this.resolvedPos.doc.resolve(targetPos)
|
||||
|
||||
if (!isBlock && $pos.depth <= this.depth) {
|
||||
|
Loading…
Reference in New Issue
Block a user