|
|
|
@ -9,6 +9,7 @@ import 'history.dart'; |
|
|
|
|
import 'nodes/block.dart'; |
|
|
|
|
import 'nodes/container.dart'; |
|
|
|
|
import 'nodes/embeddable.dart'; |
|
|
|
|
import 'nodes/leaf.dart'; |
|
|
|
|
import 'nodes/line.dart'; |
|
|
|
|
import 'nodes/node.dart'; |
|
|
|
|
import 'style.dart'; |
|
|
|
@ -136,6 +137,22 @@ class Document { |
|
|
|
|
return block.queryChild(res.offset, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Given offset, find its leaf node in document |
|
|
|
|
Tuple2<Line?, Leaf?> querySegmentLeafNode(int offset) { |
|
|
|
|
final result = queryChild(offset); |
|
|
|
|
if (result.node == null) { |
|
|
|
|
return const Tuple2(null, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final line = result.node as Line; |
|
|
|
|
final segmentResult = line.queryChild(result.offset, false); |
|
|
|
|
if (segmentResult.node == null) { |
|
|
|
|
return Tuple2(line, null); |
|
|
|
|
} |
|
|
|
|
final segment = segmentResult.node as Leaf; |
|
|
|
|
return Tuple2(line, segment); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void compose(Delta delta, ChangeSource changeSource) { |
|
|
|
|
assert(!_observer.isClosed); |
|
|
|
|
delta.trim(); |
|
|
|
|