yjs / y-quill

Quill Editor binding for Yjs
https://demos.yjs.dev/quill/quill.html
MIT License
80 stars 18 forks source link

[Issue #14] Prevent _quillObserver from updating awareness states on silent Quill events #15

Open TJackwood-Jasper opened 2 years ago

TJackwood-Jasper commented 2 years ago

See the related GitHub issue for a detailed explanation of the issue.

TJackwood-Jasper commented 2 years ago

One outstanding issue that may come from this change: On a "paste" event, Quill fires a text-change event that is processed by _quillObserver, however the current selection at the time is null, i.e. this.quill.getSelection() === null.

Because of this, we CLEAR the cursor awareness on a paste event, even though for the user that pasted the content, their cursor ends up at the end of the content they just pasted (due to a 3rd silent selection-change event in this scenario, specifically).

Personally I think this is a fine interaction, since the location of the cursor at the moment after a paste action isn't that particularly relevant, and the awareness is immediately updated and handled correctly on the next action anyways. I don't see a good way of determining whether or not a text-change action comes from a paste, or how to tell the difference between a selection-change event after a paste vs. any other selection-change event.