@@ -15,7 +15,14 @@ class Editor {
applyDelta(delta) {
this.scroll.update();
let scrollLength = this.scroll.length();
- this.scroll.batchStart();
+
+ // Check if a batch already exists (e.g. during composition)
+ const isAlreadyBatching = Boolean(this.scroll.batch);
+
+ if (!isAlreadyBatching) {
+ this.scroll.batchStart();
+ }
+
const normalizedDelta = normalizeDelta(delta);
const deleteDelta = new Delta();
const normalizedOps = splitOpLines(normalizedDelta.ops.slice());
@@ -93,7 +100,11 @@ class Editor {
}
return index + Op.length(op);
}, 0);
- this.scroll.batchEnd();
+
+ if (!isAlreadyBatching) {
+ this.scroll.batchEnd();
+ }
+
this.scroll.optimize();
return this.update(normalizedDelta);
}