|
|
@ -721,9 +721,23 @@ class _QuillEditorSelectionGestureDetectorBuilder |
|
|
|
// On macOS/iOS/iPadOS a touch tap places the cursor at the edge |
|
|
|
// On macOS/iOS/iPadOS a touch tap places the cursor at the edge |
|
|
|
// of the word. |
|
|
|
// of the word. |
|
|
|
if (_detectWordBoundary) { |
|
|
|
if (_detectWordBoundary) { |
|
|
|
renderEditor! |
|
|
|
final TextSelection previousSelection = renderEditor!.selection; |
|
|
|
..selectWordEdge(SelectionChangedCause.tap) |
|
|
|
final TextPosition textPosition = renderEditor!.getPositionForOffset(details.globalPosition); |
|
|
|
..onSelectionCompleted(); |
|
|
|
final bool isAffinityTheSame = textPosition.affinity == previousSelection.affinity; |
|
|
|
|
|
|
|
if (((_positionWasOnSelectionExclusive(textPosition) && !previousSelection.isCollapsed) |
|
|
|
|
|
|
|
|| (_positionWasOnSelectionInclusive(textPosition) && previousSelection.isCollapsed && isAffinityTheSame)) |
|
|
|
|
|
|
|
&& renderEditor!._hasFocus) { |
|
|
|
|
|
|
|
editor!.showToolbar(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
renderEditor! |
|
|
|
|
|
|
|
..selectWordEdge(SelectionChangedCause.tap) |
|
|
|
|
|
|
|
..onSelectionCompleted(); |
|
|
|
|
|
|
|
if (previousSelection == editor!.textEditingValue.selection && renderEditor!._hasFocus) { |
|
|
|
|
|
|
|
editor!.showToolbar(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
editor!.hideToolbar(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
renderEditor! |
|
|
|
renderEditor! |
|
|
|
..selectPosition(cause: SelectionChangedCause.tap) |
|
|
|
..selectPosition(cause: SelectionChangedCause.tap) |
|
|
@ -1932,4 +1946,24 @@ class RenderEditableContainerBox extends RenderBox |
|
|
|
return defaultComputeDistanceToFirstActualBaseline(baseline)! + |
|
|
|
return defaultComputeDistanceToFirstActualBaseline(baseline)! + |
|
|
|
_resolvedPadding!.top; |
|
|
|
_resolvedPadding!.top; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool _positionWasOnSelectionExclusive(TextPosition textPosition) { |
|
|
|
|
|
|
|
final TextSelection? selection = renderEditor!.selection; |
|
|
|
|
|
|
|
if (selection == null) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return selection.start < textPosition.offset |
|
|
|
|
|
|
|
&& selection.end > textPosition.offset; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool _positionWasOnSelectionInclusive(TextPosition textPosition) { |
|
|
|
|
|
|
|
final TextSelection? selection = renderEditor!.selection; |
|
|
|
|
|
|
|
if (selection == null) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return selection.start <= textPosition.offset |
|
|
|
|
|
|
|
&& selection.end >= textPosition.offset; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|