Fix paste block text in words apply same style.

pull/1324/head
hehong 2 years ago
parent 8aca48274f
commit 2e0057a049
  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.17]
- Fix paste block text in words apply same style.
# [7.2.17] # [7.2.17]
- Fix paste text mess up style. - Fix paste text mess up style.
- Add support copy/cut block text. - Add support copy/cut block text.

@ -421,10 +421,10 @@ class Line extends Container<Leaf?> {
} }
pos += node.length; pos += node.length;
} }
}
if (style.isNotEmpty) { if (style.isNotEmpty) {
result.add(OffsetValue(beg, style)); result.add(OffsetValue(beg, style, pos));
}
} }
final remaining = len - local; final remaining = len - local;

@ -49,17 +49,22 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState
final offset = pasteStyleAndEmbed[i].offset; final offset = pasteStyleAndEmbed[i].offset;
final styleAndEmbed = pasteStyleAndEmbed[i].value; final styleAndEmbed = pasteStyleAndEmbed[i].value;
final local = pos + offset;
if (styleAndEmbed is Embeddable) { if (styleAndEmbed is Embeddable) {
widget.controller.replaceText(pos + offset, 0, styleAndEmbed, null); widget.controller.replaceText(local, 0, styleAndEmbed, null);
} else { } else {
final style = styleAndEmbed as Style; final style = styleAndEmbed as Style;
if (style.isInline) { if (style.isInline) {
widget.controller.formatTextStyle( widget.controller
pos + offset, pasteStyleAndEmbed[i].length!, style); .formatTextStyle(local, pasteStyleAndEmbed[i].length!, style);
} else if (style.isBlock) { } else if (style.isBlock) {
style.values.forEach((attribute) { final node = widget.controller.document.queryChild(local).node;
widget.controller.document.format(pos + offset, 0, attribute); 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 name: flutter_quill
description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us) description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us)
version: 7.2.17 version: 7.2.18
#author: bulletjournal #author: bulletjournal
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill repository: https://github.com/singerdmx/flutter-quill

Loading…
Cancel
Save