ueberdosis / tiptap

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

[Bug]: ReplaceStep has wrong `from` and `to` positions and slice with reinserted content when backspacing a character to the left of a space #5844

Open seleckis opened 3 days ago

seleckis commented 3 days ago

Affected Packages

core

Version(s)

2.9.1

Bug Description

Here are two identical examples:

  1. one using Tiptap
  2. and the other plain ProseMirror

To observe the problem, place the cursor somewhere around “World” and start deleting characters. In the Tiptap version, when deleting a character to the left of a space, a collision occurs. The cause seems to be that ReplaceStep returns incorrect from and to positions, and the slice contains content that shouldn’t be there. The plugin code in track-changes.mjs with appendTransaction is absolutely identical. In Prosemirror version with the same appendTransaction there is no collision and the step has correct from and to positions without any content in slice.

Browser Used

Chrome

Code Example URL

https://codesandbox.io/p/sandbox/wsksjg

Expected Behavior

Check track-changes.mjs. When deleting a character to the left of a space, ReplaceStep should return correct from and to positions, and the slice should not contain any content.

Additional Context (Optional)

Video from Prosemirror version: https://github.com/user-attachments/assets/bc1ca47d-4860-40ba-a34a-309bc180c0e6

Video from Tiptap version: https://github.com/user-attachments/assets/cf9095fb-f730-4548-842f-e53641729af9

Dependency Updates

ypoleto commented 3 days ago

Hey, can I try to fix this bug?

nperez0111 commented 2 days ago

feel free @ypoleto

seleckis commented 1 day ago

As a hint, when I changed "data-trackchanges-date" attribute type to number, the issue disappeared. Maybe this can helps.