diff --git a/lib/src/document/nodes/node.dart b/lib/src/document/nodes/node.dart index 947d3f1dc..45ba7a58f 100644 --- a/lib/src/document/nodes/node.dart +++ b/lib/src/document/nodes/node.dart @@ -51,6 +51,8 @@ abstract base class Node extends LinkedListEntry { Node clone() => newInstance()..applyStyle(style); + Node cloneWithOffset() => clone()..parent = parent.._offset = offset; + int? _offset; /// Offset in characters of this node relative to [parent] node. diff --git a/lib/src/editor/widgets/text/text_line.dart b/lib/src/editor/widgets/text/text_line.dart index ee09dcc49..c5d4f06d6 100644 --- a/lib/src/editor/widgets/text/text_line.dart +++ b/lib/src/editor/widgets/text/text_line.dart @@ -251,7 +251,7 @@ class _TextLineState extends State { } // here child is Text node and its value is cloned - textNodes.add(child.clone()); + textNodes.add(child.cloneWithOffset()); } if (textNodes.isNotEmpty) {