collectAllIndividualStyles method
Returns each node segment's offset in selection with its corresponding style as a list
Implementation
List<OffsetValue<Style>> collectAllIndividualStyles(int offset, int len, {int beg = 0}) {
final local = math.min(length - offset, len);
final result = <OffsetValue<Style>>[];
final data = queryChild(offset, true);
var node = data.node as Leaf?;
if (node != null) {
var pos = 0;
if (node is NodeText) {
pos = node.length - data.offset;
result.add(OffsetValue(beg, node.style));
}
while (!node!.isLast && pos < local) {
node = node.next as Leaf;
if (node is NodeText) {
result.add(OffsetValue(pos + beg, node.style));
pos += node.length;
}
}
}
// TODO: add line style and parent's block style
final remaining = len - local;
if (remaining > 0 && nextLine != null) {
final rest = nextLine!.collectAllIndividualStyles(0, remaining, beg: local);
result.addAll(rest);
}
return result;
}