Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triplit / Quill: Quick Inserations #10

Open
MentalGear opened this issue Apr 30, 2024 · 6 comments
Open

Triplit / Quill: Quick Inserations #10

MentalGear opened this issue Apr 30, 2024 · 6 comments

Comments

@MentalGear
Copy link

You described the weird quick insertions bug in the quill / triplit implementation. I was wondering if using microtask could help solve it?

However, the problem is that the text-change event happens after the DOM updates. Currently there are no really built-in such as before-text-change. This similar Issue has more details about problems modifying contents during text-change event. One way is to wrap the updates in queueMicrotask.

source: https://stackoverflow.com/a/77667825/5037146

Reference
Quill Source Code:
https://github.com/quilljs/quill/blob/65ede1e2ecb3335acc14cc73cf54e9898d847d30/packages/quill/src/core/composition.ts#L28
comment:
slab/quill#2558 (comment)

@MentalGear
Copy link
Author

PS: I also just noticed that the demo is using Quill v.1.3. Maybe simply using v.2 would fix the issue ?

@mweidner037
Copy link
Owner

I believe the issues I was seeing were related to Triplit's transactions / live queries; they did not seem Quill related:

// TODO: Despite avoiding overlapping transactions and explicit fetches, I still
// get ReadWriteConflictErrors if I type/delete quickly (by holding down a
// keyboard key). Are tx writes conflicting with subscribe's reads?

Though I do need to update to Quill v2 anyway, because Quill v1 is going to break in Chrome soon 😬️ yjs/y-quill#16

@MentalGear
Copy link
Author

MentalGear commented Apr 30, 2024 via email

@MentalGear
Copy link
Author

One big consideration in collaborative systems is traceability / accountability: knowing which user changed what.

I was wondering if there is a pattern that you can recommend on how to best associate a userId to a change in quill, list-positions & triplit?

@mweidner037
Copy link
Owner

mweidner037 commented Apr 30, 2024

You can track the replicaID used by each session (assign it in Order's constructor) and record which userId it corresponds to. All characters inserted during that session will use a bunchID of the form `${replicaID}_{counter.toString(36)}`, so you'll know later who inserted them (assuming other users are honest and don't steal their replicaID).

For more granular history, you'd probably need to store the actual log of changes somewhere, perhaps batched into ~30 second increments.

@MentalGear
Copy link
Author

MentalGear commented May 2, 2024

Thank you!
(Maybe, if you get to updating to quill 2, you could also build in the id association in the editor as it's a common use.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants