When pasting, I try to get the range affected by the current paste transaction. When using prosemirror-changeset
, it seems that in some cases, the range I read is “incorrect.” However, using the utility functions provided by Tiptap, I can get the range I expect.
Here is the CodeSandbox that reproduces the issue.
https://codesandbox.io/p/sandbox/prosemirror-changset-wrong-range-3yp2pn
Here’s a screen recording.
I try pasting a table into the editor. Under normal circumstances, the ranges reported by both ProseMirror and Tiptap are the same.
But when I place the cursor at the beginning of an empty paragraph and perform the paste, I get different results. Tiptap returns a range that matches my expectation — the end position of the change range is right after the inserted table. ProseMirror, however, returns a result that’s off by 1.
Is this an intentional design of ProseMirror, or am I using changeset
incorrectly?