reedsy / quill-cursors

A multi cursor module for Quill text editor.
MIT License
250 stars 53 forks source link

Add local cursor transforms on `text-change` #26

Closed alecgibson closed 5 years ago

alecgibson commented 5 years ago

Fixes https://github.com/reedsy/quill-cursors/issues/25

At the moment, we have to wait for clients to report their position before we update it. This is fine on very low-latency connections (like when developing on the same machine), but on high-latency connections, it can lead to some laggy or juddery performance as the cursor drifts out-of-sync with the text-change events received by Quill:

Mar-29-2019 08-44-15

This change adds in a text-change listener that will transform all cursors by the received delta using quill-delta's transformPosition, which is meant for exactly this sort of application.

The example has also been updated to show how a cursor implementation might look on a high-latency connection, using a debounced update to avoid laggy behaviour.

arslnb commented 5 years ago

Hey, any timeline on when this is going to be merged in? In a high latency environment this is invaluable.

alecgibson commented 5 years ago

@arslnb I was waiting for feedback from the original poster in the original issue, but I haven't heard anything.

Would you mind please testing with this test release, and let me know how you get on? I can look into merging some time this week when I have a chance to do some more in-depth testing myself.

ashish0910 commented 5 years ago

@alecgibson first of all thanks for this awesome library . I have done some testing with test-release you provided . It almost works . There is issue while entering new line characters :

I have marked the original position of the cursor in the screenshot below : Screenshot 2019-07-23 at 12 06 35 PM

But it actually shows 2-3 lines below

Screenshot 2019-07-23 at 12 04 45 PM

PS : This issue this issue only happens when the user with red Cursor Stays still and does not type

alecgibson commented 5 years ago

All right. Sorry for the delay on this. Things are happening, just slowly. We need to look into fixing this for ourselves soon, too. And potentially adding support for the upcoming ShareDB presence.

alecgibson commented 5 years ago

@ashish0910 out of interest, what tweaking did you need to do?

ashish0910 commented 5 years ago

@ashish0910 out of interest, what tweaking did you need to do?

Just reducing set timeout values and adding a fake operational transform event whenever a new User joined did the trick .

alecgibson commented 5 years ago

@ashish0910 note that the timeout values in the example are literally just to simulate a slow connection (and keeping in the timeouts will make your cursors artificially laggy). The only number you may need to tweak is the debounce interval.