Closed ocavue closed 1 year ago
This issue should share the same underlying reason as https://github.com/yjs/y-prosemirror/issues/113
+1 - It appears now that due to the same commit, NodeSelections are converted to TextSelections anytime the document changes, as the _typeChanged
mux function ends up getting called and actually replaces the entire document (like a remote change).
Any updates on this one?
This one seems quite important @dmonad - and I think @ocavue has a PR that fixes it.
Fixed and released :+1:
Amazing! Thank you.
Checklist
Describe the bug
After updating y-prosemirror from 1.0.20 to 1.1.0, every keypress will trigger the
update
method for every plugin twice. This causes a lot of issues if a plugin want to compare the current state with the prev state.To Reproduce
I wrote a minimal reproduction to show this issue. In this example, I have a ProseMirror plugin to show whether or not the cursor is changed in the last operation. The code of this plugin is in
prosemirror.ts
.Is your cursor changed? true
. While in the 1.1.2 window, you will seefalse
.Expected behavior
Every keypress will only trigger one plugin update, as what we used to have in y-prosemirror 1.0.20
Screenshots
https://share.cleanshot.com/NJlBDh
Additional context
In commit 2d06ece86f8359b14e9f6b27bb5746e2ca2efc82,
pluginState.doc.transact
was added insidesyncPlugin
'supdate
function. CallingpluginState.doc.transact
will trigger_typeChanged
because it has been observed.tr.replace
will be called in_typeChanged
, which causes the second update.