Fix Container insert

pull/13/head
singerdmx 4 years ago
parent 63056546b2
commit 4d4cdab520
  1. 10
      lib/models/documents/document.dart
  2. 1
      lib/models/documents/nodes/container.dart

@ -32,7 +32,8 @@ class Document {
Stream<Tuple3> get changes => _observer.stream;
Document() : _delta = Delta()..insert('\n') {
Document() : _delta = Delta()
..insert('\n') {
_loadDocument(_delta);
}
@ -138,7 +139,11 @@ class Document {
offset += op.length;
}
}
try {
_delta = _delta.compose(delta);
} catch (e) {
throw ('_delta compose failed');
}
if (_delta != _root.toDelta()) {
throw ('Compose failed');
@ -179,7 +184,8 @@ class Document {
_root.insert(offset, data, style);
} else {
throw ArgumentError.value(doc,
'Document Delta can only contain insert operations but ${op.key} found.');
'Document Delta can only contain insert operations but ${op
.key} found.');
}
offset += op.length;
}

@ -84,6 +84,7 @@ abstract class Container<T extends Node> extends Node {
if (isNotEmpty) {
ChildQuery child = queryChild(index, false);
child.node.insert(child.offset, data, style);
return;
}
// empty

Loading…
Cancel
Save