The delta that's generated looks like:
{"ops":[{"retain":710},{"insert":" yesterday, and she says—”\n“The clinic?","attributes":{"prediction":"prediction"}},{"delete":28}]}
My code is:
const delta = new Delta()
.retain(documentData?.prediction?.currentPosition)
.delete(previousPredictionText?.length || 0)
.insert(predictionText, { prediction: 'prediction' })
console.log('delta', JSON.stringify(delta))
quillEditor.updateContents(delta)
It looks like I should first retain
, then delete
, then insert
, but the generated delta
seems to do it in a different order. What am I doing wrong?
this is pretty much the same issue you have https://github.com/quilljs/delta/issues/12 they dont do it in steps, they all refer to current document.
In the link there is even a guide how to do this, their way
https://quilljs.com/guides/designing-the-delta-format/