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:
Daniel Adeboye 2025-06-21 15:33:51 +01:00 committed by Dominik Biedebach
parent 3835976faa
commit 9390e024ed
2 changed files with 11 additions and 0 deletions

View 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

View File

@ -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) {