Skip to content

Commit

Permalink
Fix paste block text in words apply same style. (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheHeBoy authored Jul 23, 2023
1 parent 8aca482 commit b557155
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/models/documents/nodes/line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,10 @@ class Line extends Container<Leaf?> {
}
pos += node.length;
}
}

if (style.isNotEmpty) {
result.add(OffsetValue(beg, style));
if (style.isNotEmpty) {
result.add(OffsetValue(beg, style, pos));
}
}

final remaining = len - local;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b557155

Please sign in to comment.