Why does a QullJS delta appear out of order?

Viewed 117

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?

1 Answers
Related