Fix paste block text in words apply same style. (#1324)

pull/1329/head
He Hong 2 years ago committed by GitHub
parent 8aca48274f
commit b5571559fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 6
      lib/src/models/documents/nodes/line.dart
  3. 17
      lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart
  4. 2
      pubspec.yaml

@ -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.

@ -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;

@ -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);
});
}
}
}
}

@ -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

Loading…
Cancel
Save