diff --git a/CHANGELOG.md b/CHANGELOG.md index f1daded5..2d1656cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# [7.2.18] +- Fix paste block text in words apply same style. + # [7.2.17] - Fix paste text mess up style. - Add support copy/cut block text. diff --git a/lib/src/models/documents/nodes/line.dart b/lib/src/models/documents/nodes/line.dart index f20c7c59..09380853 100644 --- a/lib/src/models/documents/nodes/line.dart +++ b/lib/src/models/documents/nodes/line.dart @@ -421,10 +421,10 @@ class Line extends Container { } pos += node.length; } - } - if (style.isNotEmpty) { - result.add(OffsetValue(beg, style)); + if (style.isNotEmpty) { + result.add(OffsetValue(beg, style, pos)); + } } final remaining = len - local; diff --git a/lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart b/lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart index 52619f0b..363b9d31 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart @@ -49,17 +49,22 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState final offset = pasteStyleAndEmbed[i].offset; final styleAndEmbed = pasteStyleAndEmbed[i].value; + final local = pos + offset; if (styleAndEmbed is Embeddable) { - widget.controller.replaceText(pos + offset, 0, styleAndEmbed, null); + widget.controller.replaceText(local, 0, styleAndEmbed, null); } else { final style = styleAndEmbed as Style; if (style.isInline) { - widget.controller.formatTextStyle( - pos + offset, pasteStyleAndEmbed[i].length!, style); + widget.controller + .formatTextStyle(local, pasteStyleAndEmbed[i].length!, style); } else if (style.isBlock) { - style.values.forEach((attribute) { - widget.controller.document.format(pos + offset, 0, attribute); - }); + final node = widget.controller.document.queryChild(local).node; + if (node != null && + pasteStyleAndEmbed[i].length == node.length - 1) { + style.values.forEach((attribute) { + widget.controller.document.format(local, 0, attribute); + }); + } } } } diff --git a/pubspec.yaml b/pubspec.yaml index 6a8b8a8c..e9972932 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_quill description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us) -version: 7.2.17 +version: 7.2.18 #author: bulletjournal homepage: https://bulletjournal.us/home/index.html repository: https://github.com/singerdmx/flutter-quill