Fix delete button not working

pull/13/head
singerdmx 4 years ago
parent 1bcd727765
commit 0d203b3fd0
  1. 7
      lib/models/documents/nodes/container.dart
  2. 2
      lib/models/documents/nodes/line.dart
  3. 7
      lib/widgets/controller.dart

@ -59,7 +59,12 @@ abstract class Container<T extends Node> extends Node {
}
ChildQuery queryChild(int offset, bool inclusive) {
assert(offset >= 0 && offset <= length);
if (offset < 0) {
throw ('Offset cannot be negative');
}
if (offset > length) {
throw ('offset $offset > $length');
}
for (Node node in children) {
int len = node.length;

@ -128,7 +128,7 @@ class Line extends Container<Leaf> {
super.delete(index, local);
}
int remain = length - local;
int remain = len - local;
if (remain > 0) {
assert(nextLine != null);
nextLine.delete(0, remain);

@ -34,7 +34,12 @@ class QuillController extends ChangeNotifier {
Delta delta;
if (len > 0 || data is! String || (data as String).isNotEmpty) {
delta = document.replace(index, len, data);
try {
delta = document.replace(index, len, data);
} catch (e) {
print ('document.replace failed: $e');
throw e;
}
if (delta != null &&
toggledStyle.isNotEmpty &&
delta.isNotEmpty &&

Loading…
Cancel
Save