From 63c2ef9d0e2211a7ef2eefe940111d7ae02df71c Mon Sep 17 00:00:00 2001 From: Xin Yao Date: Mon, 12 Apr 2021 08:30:02 -0700 Subject: [PATCH] Upgrade to 1.2.0 --- CHANGELOG.md | 3 ++ lib/models/documents/document.dart | 3 +- lib/widgets/editor.dart | 86 ++++++++++++++++-------------- lib/widgets/text_block.dart | 16 +++--- pubspec.yaml | 2 +- 5 files changed, 61 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01145d24..8937de42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.2.0] +* Fix image button cancel causes crash. + ## [1.1.8] * Fix height of empty line bug. diff --git a/lib/models/documents/document.dart b/lib/models/documents/document.dart index 072b3a44..83f7a0fc 100644 --- a/lib/models/documents/document.dart +++ b/lib/models/documents/document.dart @@ -56,7 +56,8 @@ class Document { return Delta(); } - final delta = _rules.apply(RuleType.INSERT, this, index, data: data, len: replaceLength); + final delta = _rules.apply(RuleType.INSERT, this, index, + data: data, len: replaceLength); compose(delta, ChangeSource.LOCAL); return delta; } diff --git a/lib/widgets/editor.dart b/lib/widgets/editor.dart index 53540eb4..5be0dd24 100644 --- a/lib/widgets/editor.dart +++ b/lib/widgets/editor.dart @@ -114,33 +114,32 @@ Widget _defaultEmbedBuilder(BuildContext context, leaf.Embed node) { } class QuillEditor extends StatefulWidget { - const QuillEditor({ - required this.controller, - required this.focusNode, - required this.scrollController, - required this.scrollable, - required this.scrollBottomInset, - required this.padding, - required this.autoFocus, - required this.readOnly, - required this.expands, - this.showCursor, - this.placeholder, - this.enableInteractiveSelection = true, - this.minHeight, - this.maxHeight, - this.customStyles, - this.textCapitalization = TextCapitalization.sentences, - this.keyboardAppearance = Brightness.light, - this.scrollPhysics, - this.onLaunchUrl, - this.onTapDown, - this.onTapUp, - this.onSingleLongTapStart, - this.onSingleLongTapMoveUpdate, - this.onSingleLongTapEnd, - this.embedBuilder = _defaultEmbedBuilder - }); + const QuillEditor( + {required this.controller, + required this.focusNode, + required this.scrollController, + required this.scrollable, + required this.padding, + required this.autoFocus, + required this.readOnly, + required this.expands, + this.showCursor, + this.placeholder, + this.enableInteractiveSelection = true, + this.scrollBottomInset = 0, + this.minHeight, + this.maxHeight, + this.customStyles, + this.textCapitalization = TextCapitalization.sentences, + this.keyboardAppearance = Brightness.light, + this.scrollPhysics, + this.onLaunchUrl, + this.onTapDown, + this.onTapUp, + this.onSingleLongTapStart, + this.onSingleLongTapMoveUpdate, + this.onSingleLongTapEnd, + this.embedBuilder = _defaultEmbedBuilder}); factory QuillEditor.basic({ required QuillController controller, @@ -154,7 +153,6 @@ class QuillEditor extends StatefulWidget { autoFocus: true, readOnly: readOnly, expands: false, - scrollBottomInset: 0, padding: EdgeInsets.zero); } @@ -178,15 +176,20 @@ class QuillEditor extends StatefulWidget { final ScrollPhysics? scrollPhysics; final ValueChanged? onLaunchUrl; // Returns whether gesture is handled - final bool Function(TapDownDetails details, TextPosition textPosition)? onTapDown; + final bool Function(TapDownDetails details, TextPosition textPosition)? + onTapDown; // Returns whether gesture is handled final bool Function(TapUpDetails details, TextPosition textPosition)? onTapUp; // Returns whether gesture is handled - final bool Function(LongPressStartDetails details, TextPosition textPosition)? onSingleLongTapStart; + final bool Function(LongPressStartDetails details, TextPosition textPosition)? + onSingleLongTapStart; // Returns whether gesture is handled - final bool Function(LongPressMoveUpdateDetails details, TextPosition textPosition)? onSingleLongTapMoveUpdate; + final bool Function( + LongPressMoveUpdateDetails details, TextPosition textPosition)? + onSingleLongTapMoveUpdate; // Returns whether gesture is handled - final bool Function(LongPressEndDetails details, TextPosition textPosition)? onSingleLongTapEnd; + final bool Function(LongPressEndDetails details, TextPosition textPosition)? + onSingleLongTapEnd; final EmbedBuilder embedBuilder; @override @@ -337,8 +340,8 @@ class _QuillEditorSelectionGestureDetectorBuilder if (_state.widget.onSingleLongTapMoveUpdate != null) { final renderEditor = getRenderEditor(); if (renderEditor != null) { - if (_state.widget.onSingleLongTapMoveUpdate!(details, renderEditor.getPositionForOffset(details.globalPosition) - )) { + if (_state.widget.onSingleLongTapMoveUpdate!(details, + renderEditor.getPositionForOffset(details.globalPosition))) { return; } } @@ -467,7 +470,8 @@ class _QuillEditorSelectionGestureDetectorBuilder if (_state.widget.onTapDown != null) { final renderEditor = getRenderEditor(); if (renderEditor != null) { - if (_state.widget.onTapDown!(details, renderEditor.getPositionForOffset(details.globalPosition))) { + if (_state.widget.onTapDown!(details, + renderEditor.getPositionForOffset(details.globalPosition))) { return; } } @@ -480,7 +484,8 @@ class _QuillEditorSelectionGestureDetectorBuilder if (_state.widget.onTapUp != null) { final renderEditor = getRenderEditor(); if (renderEditor != null) { - if (_state.widget.onTapUp!(details, renderEditor.getPositionForOffset(details.globalPosition))) { + if (_state.widget.onTapUp!(details, + renderEditor.getPositionForOffset(details.globalPosition))) { return; } } @@ -522,7 +527,8 @@ class _QuillEditorSelectionGestureDetectorBuilder if (_state.widget.onSingleLongTapStart != null) { final renderEditor = getRenderEditor(); if (renderEditor != null) { - if (_state.widget.onSingleLongTapStart!(details, renderEditor.getPositionForOffset(details.globalPosition))) { + if (_state.widget.onSingleLongTapStart!(details, + renderEditor.getPositionForOffset(details.globalPosition))) { return; } } @@ -556,7 +562,8 @@ class _QuillEditorSelectionGestureDetectorBuilder if (_state.widget.onSingleLongTapEnd != null) { final renderEditor = getRenderEditor(); if (renderEditor != null) { - if (_state.widget.onSingleLongTapEnd!(details, renderEditor.getPositionForOffset(details.globalPosition))) { + if (_state.widget.onSingleLongTapEnd!(details, + renderEditor.getPositionForOffset(details.globalPosition))) { return; } } @@ -927,7 +934,8 @@ class RenderEditor extends RenderEditableContainerBox kMargin + offsetInViewport + scrollBottomInset; - final caretBottom = endpoint.point.dy + kMargin + offsetInViewport + scrollBottomInset; + final caretBottom = + endpoint.point.dy + kMargin + offsetInViewport + scrollBottomInset; double? dy; if (caretTop < scrollOffset) { dy = caretTop; diff --git a/lib/widgets/text_block.dart b/lib/widgets/text_block.dart index d826c9e5..309b9cf8 100644 --- a/lib/widgets/text_block.dart +++ b/lib/widgets/text_block.dart @@ -514,14 +514,14 @@ class RenderEditableTextBlock extends RenderEditableContainerBox class _EditableBlock extends MultiChildRenderObjectWidget { _EditableBlock( - this.block, - this.textDirection, - this.padding, - this.scrollBottomInset, - this.decoration, - this.contentPadding, - List children - ) : super(children: children); + this.block, + this.textDirection, + this.padding, + this.scrollBottomInset, + this.decoration, + this.contentPadding, + List children) + : super(children: children); final Block block; final TextDirection textDirection; diff --git a/pubspec.yaml b/pubspec.yaml index 15c4de29..93bf71be 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: 1.1.8 +version: 1.2.0 #author: bulletjournal homepage: https://bulletjournal.us/home/index.html repository: https://github.com/singerdmx/flutter-quill