Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: NodePos depth is not set correctly #5117

Open
2 tasks done
furkan3ayraktar opened this issue May 6, 2024 · 0 comments
Open
2 tasks done

[Bug]: NodePos depth is not set correctly #5117

furkan3ayraktar opened this issue May 6, 2024 · 0 comments
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@furkan3ayraktar
Copy link
Contributor

Which packages did you experience the bug in?

core

What Tiptap version are you using?

2.3.1

What’s the bug you are facing?

The depth of the NodePos is not set correctly. You can see it in the below snippet:

get children(): NodePos[] {
const children: NodePos[] = []
this.node.content.forEach((node, offset) => {
const isBlock = node.isBlock && !node.isTextblock
const targetPos = this.pos + offset + 1
const $pos = this.resolvedPos.doc.resolve(targetPos)
if (!isBlock && $pos.depth <= this.depth) {
return
}
const childNodePos = new NodePos($pos, this.editor, isBlock, isBlock ? node : null)
if (isBlock) {
childNodePos.actualDepth = this.depth + 1
}
children.push(new NodePos($pos, this.editor, isBlock, isBlock ? node : null))
})
return children

In line 149, the actualDepth of the childNodePos is set correctly. However, in line 152, the childNodePos is not pushed to the children array. Instead, a brand new NodePos instance is created. As a result, the actualDepth is never set.

Simply, replacing line 152 with children.push(childNodePos) will solve the issue.

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

The depth of the NodePos is set correctly.

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@furkan3ayraktar furkan3ayraktar added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Triage open
Development

No branches or pull requests

1 participant