yjs / y-prosemirror

ProseMirror editor binding for Yjs
https://demos.yjs.dev/prosemirror/prosemirror.html
MIT License
355 stars 124 forks source link

Sometimes moving the caret does not work #146

Open vitmf opened 1 year ago

vitmf commented 1 year ago

Describe the bug Sometimes, after moving the caret when another user is editing the document, the caret returns to the previous spot. I think the following is happenning: After changing selection, prosemirror updates its state after receiving the event selectionchange. Also, after updating the document, y-prosemirror restores the saved caret position. However, if the user is moving the caret (by clicking, for example) and another user is editing the document, we may have the mousedown event, then y-prosemirror updates the prosemirror document and restores selection, and only then the selectionchange related to the click is dispatched. However, the original caret change has been overridden by y-prosemirror.

To Reproduce

Expected behavior The caret should always stay in the clicked place.

Environment Information Chrome 116.0.5845.110 Firefox 116.0.3 yjs 13.5.52 y-websocket 1.5.0 y-prosemirror 1.2.1