The problem of binding quill with yjs by myself

I want to know how to bind quill, so I have a try. But unfortunately, I can’t directly apply the delta of quill to ytext by using ytext.appDelta(delta).(The following code.) But ‘ The Text-Delta is equivalent to Quills’ Delta format.’
I print the data of ytext.toDelta() when Every time I type a character, but I only got the delta of ytext all strings instead of a single modification operation.
So how to use Delta?

my code:
this.quill.on(‘text-change’, function(delta, oldDelta, source) {
if (source == ‘api’|source ==‘user’) {
ytext.applyDelta(delta)
console.log(ytext.toString())
}

Solved. After I saw the source code of y-quill, I got it.

new code:
this.quill.on(‘text-change’, function(delta, oldDelta, source) {
if (source == ‘api’|source ==‘user’) {
console.log(delta.ops)
ytext.applyDelta(delta.ops)
console.log(ytext.toString())
}

1 Like