Closed taylorhadden closed 2 years ago
This is my current fallback:
const change = editor.change
if (isCollapsed) {
change.insert(at, '\n' + newLinePrefix)
}
else {
change.delete(selection)
change.insert(at, '\n').insert(at + 1, newLinePrefix)
}
change.apply()
Got a fix in. Releasing in 0.6.44
e.g. If you have a word selected and call
editor.insert('first\nsecond')
, you will get the following deltaThis does not happen if you make the same insert call with a collapsed selection.
This appears to be an artifact of how deltas compose themselves when target insertion indices overlap when the insertion position is behind the change's current delta.
Reversing
this.delta.compose(applicator(new Delta().retain(at)))
toapplicator(new Delta().retain(at)).compose(this.delta)
inTextChange.compose()
causes the inserted text to be in the right order, but the start of the inserted text will be eaten by the delete Op.