From 28250d2c577803e54793aa73cfc6c88a73f65e0e Mon Sep 17 00:00:00 2001 From: li3317 <li3317@purdue.edu> Date: Mon, 18 Jan 2021 19:16:09 -0500 Subject: [PATCH] fix check list cursor --- lib/widgets/editor.dart | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/widgets/editor.dart b/lib/widgets/editor.dart index cf3b0f25..845829a6 100644 --- a/lib/widgets/editor.dart +++ b/lib/widgets/editor.dart @@ -321,13 +321,13 @@ class _QuillEditorSelectionGestureDetectorBuilder } } - _onTapping(TapUpDetails details) { + bool _onTapping(TapUpDetails details) { TextPosition pos = getRenderEditor().getPositionForOffset(details.globalPosition); containerNode.ChildQuery result = getEditor().widget.controller.document.queryChild(pos.offset); if (result.node == null) { - return; + return false; } Line line = result.node as Line; containerNode.ChildQuery segmentResult = @@ -336,8 +336,11 @@ class _QuillEditorSelectionGestureDetectorBuilder if (line.length == 1) { // tapping when no text yet on this line _flipListCheckbox(pos, line, segmentResult); + getEditor().widget.controller.updateSelection( + TextSelection.collapsed(offset: pos.offset), ChangeSource.LOCAL); + return true; } - return; + return false; } Leaf segment = segmentResult.node as Leaf; if (segment.style.containsKey(Attribute.link.key)) { @@ -351,7 +354,7 @@ class _QuillEditorSelectionGestureDetectorBuilder urlRegExp.firstMatch(link.trim()) != null) { launchUrl(link); } - return; + return false; } if (getEditor().widget.readOnly && segment.value is BlockEmbed) { BlockEmbed blockEmbed = segment.value as BlockEmbed; @@ -364,10 +367,10 @@ class _QuillEditorSelectionGestureDetectorBuilder ), ); } - return; + return false; } if (_flipListCheckbox(pos, line, segmentResult)) { - return; + return true; } } @@ -391,6 +394,8 @@ class _QuillEditorSelectionGestureDetectorBuilder .controller .formatText(pos.offset, 0, Attribute.unchecked); } + getEditor().widget.controller.updateSelection( + TextSelection.collapsed(offset: pos.offset), ChangeSource.LOCAL); return true; } @@ -405,9 +410,9 @@ class _QuillEditorSelectionGestureDetectorBuilder onSingleTapUp(TapUpDetails details) { getEditor().hideToolbar(); - _onTapping(details); + bool tapping = _onTapping(details); - if (delegate.getSelectionEnabled()) { + if (delegate.getSelectionEnabled() && !tapping) { switch (Theme.of(_state.context).platform) { case TargetPlatform.iOS: case TargetPlatform.macOS: