yjs / y-prosemirror

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

Sometimes moving the caret does not work #146

Open vitmf opened 10 months ago

vitmf commented 10 months 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