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]: Position -1 out of range when deleting custom node at the start of content #6166

Open
1 task done
chuckdu21 opened this issue Mar 9, 2025 · 0 comments
Open
1 task done
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

@chuckdu21
Copy link

Affected Packages

vue3

Version(s)

2.11.2 2.11.5

Bug Description

Hi,
I'm facing an issue.
I created custom nodes and when i insert one of them at the start (first position) when i want to delete it with my backspace key i get "Position -1 out of range".

Here's my code:

const enteteComponent = Node.create({
  name: "enteteComponent",
  group: "block",
  atom: true,
  locked: true,
  parseHTML() {
    return [
      { 
        tag: "entete-component",
        getAttrs: dom => ({
          titre: dom.getAttribute("em-titre"),
          cadre: dom.getAttribute("em-cadre")
        })
      }
    ];
  },
  renderHTML({ HTMLAttributes }) {
    return ["entete-component", mergeAttributes(HTMLAttributes)];
  },
  addNodeView() {
    return VueNodeViewRenderer(EnteteComponent);
  },
  addAttributes() {
    return {
      data: {
        default: null,
      },
      titre: {
        default: ""
      },
      cadre: {
        default: ""
      }
    };
  },
});

I figured out when i have my cursor at the first position in the editor the position is 1 but when i insert my node the position is 0, i don't know why...

Also, even with locked: true i can delete the node, it's another problem...

Browser Used

Firefox

Code Example URL

No response

Expected Behavior

expect to delete the node without exception

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@chuckdu21 chuckdu21 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 Mar 9, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Tiptap: Issues Mar 9, 2025
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: Needs Triage
Development

No branches or pull requests

1 participant