ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
25.39k stars 2.17k forks source link

[Bug]: RangeError Position x outside of fragment when deleting text from draggable paragraph #5203

Open ArlatPS opened 1 month ago

ArlatPS commented 1 month ago

Affected Packages

core, react, extension-paragraph

Version(s)

2.4.0

Bug Description

When more than last paragraph is selected by cursor starting from the end (it has to be from the end, otherwise it works fine) and backspace is pressed Range Error Position x outside of fragment occurs. Paragraph is custom and it extends @tiptap/extension-paragraph and uses ReactNodeViewRenderer with NodeViewContent and NodeViewWrapper. If the component is set to draggable: false the issue does not occur. Code Sandbox is provided with bug present. From what I've found the error occurs at: https://github.com/ueberdosis/tiptap/blob/1e562ec7dae682cc720619d87c91302442baeff5/packages/core/src/extensions/keymap.ts#L43

Browser Used

Chrome

Code Example URL

https://codesandbox.io/p/sandbox/upbeat-dew-68ntql?file=%2Fsrc%2FApp.js%3A41%2C176

Expected Behavior

Expected to delete fragment of the text.

Additional Context (Optional)

https://github.com/ueberdosis/tiptap/assets/121439146/70427932-74d3-4512-a33d-f7eecd0ed836

Dependency Updates

cheemooo commented 3 weeks ago

@ArlatPS Perhaps you can try the following temporary solution.

addKeyboardShortcuts() {
  return {
    Delete: () => {
      this.editor.view.dragging = null;
    },
    Backspace: () => {
      this.editor.view.dragging = null;
    },
  };
},