Fix around image use backspace key can't delete break line. (#1309)

pull/1315/head
He Hong 2 years ago committed by GitHub
parent a353ef1a18
commit 0ab6027fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      CHANGELOG.md
  2. 3
      flutter_quill_extensions/lib/embeds/builders.dart
  3. 19
      lib/src/models/rules/delete.dart
  4. 2
      pubspec.yaml

@ -1,3 +1,9 @@
# [7.2.13]
- Fix around image can't delete line break.
# [7.2.12]
- Add support for copy/cut select image and text together.
# [7.2.12]
- Add support for copy/cut select image and text together.

@ -21,6 +21,9 @@ class ImageEmbedBuilder extends EmbedBuilder {
@override
String get key => BlockEmbed.imageType;
@override
bool get expanded => false;
@override
Widget build(
BuildContext context,

@ -1,4 +1,5 @@
import '../documents/attribute.dart';
import '../documents/nodes/embeddable.dart';
import '../quill_delta.dart';
import 'rule.dart';
@ -108,7 +109,10 @@ class PreserveLineStyleOnMergeRule extends DeleteRule {
}
}
/// Prevents user from merging a line containing an embed with other lines.
/// This rule applies to video, not image
///
/// Prevents user from merging a line containing an video embed with other
/// lines, Corresponds [InsertEmbedsRule].
class EnsureEmbedLineRule extends DeleteRule {
const EnsureEmbedLineRule();
@ -118,6 +122,13 @@ class EnsureEmbedLineRule extends DeleteRule {
final itr = DeltaIterator(document);
var op = itr.skip(index);
final opAfter = itr.skip(index + 1);
//Only video embed need can't merging a line.
if (!_isVideo(op) || !_isVideo(opAfter)) {
return null;
}
int? indexDelta = 0, lengthDelta = 0, remain = len;
var embedFound = op != null && op.data is! String;
final hasLineBreakBefore =
@ -157,4 +168,10 @@ class EnsureEmbedLineRule extends DeleteRule {
..retain(index + indexDelta)
..delete(len! + lengthDelta);
}
bool _isVideo(op) {
return op != null &&
op.data is! String &&
!(op.data as Map).containsKey(BlockEmbed.videoType);
}
}

@ -1,6 +1,6 @@
name: flutter_quill
description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us)
version: 7.2.12
version: 7.2.13
#author: bulletjournal
homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill

Loading…
Cancel
Save