Skip to content

Commit 2c67f49

Browse files
committed
revert: Copying TapAndPanGestureRecognizer from TextField (#2128)
This reverts commit 2937dc8.
1 parent 1bfd9ce commit 2c67f49

File tree

5 files changed

+259
-862
lines changed

5 files changed

+259
-862
lines changed

lib/src/editor/config/editor_config.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'dart:ui' as ui;
22

33
import 'package:flutter/cupertino.dart';
4-
import 'package:flutter/gestures.dart';
54
import 'package:flutter/material.dart';
65
import 'package:meta/meta.dart' show experimental;
76

@@ -338,12 +337,11 @@ class QuillEditorConfig {
338337

339338
// Returns whether gesture is handled
340339
final bool Function(
341-
TapDragDownDetails details, TextPosition Function(Offset offset))?
342-
onTapDown;
340+
TapDownDetails details, TextPosition Function(Offset offset))? onTapDown;
343341

344342
// Returns whether gesture is handled
345343
final bool Function(
346-
TapDragUpDetails details, TextPosition Function(Offset offset))? onTapUp;
344+
TapUpDetails details, TextPosition Function(Offset offset))? onTapUp;
347345

348346
// Returns whether gesture is handled
349347
final bool Function(

lib/src/editor/editor.dart

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
448448
}
449449
}
450450

451-
bool _isPositionSelected(TapDragUpDetails details) {
451+
bool _isPositionSelected(TapUpDetails details) {
452452
if (_state.controller.document.isEmpty()) {
453453
return false;
454454
}
@@ -471,7 +471,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
471471
}
472472

473473
@override
474-
void onTapDown(TapDragDownDetails details) {
474+
void onTapDown(TapDownDetails details) {
475475
if (_state.configurations.onTapDown != null) {
476476
if (renderEditor != null &&
477477
_state.configurations.onTapDown!(
@@ -492,7 +492,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
492492
}
493493

494494
@override
495-
void onSingleTapUp(TapDragUpDetails details) {
495+
void onSingleTapUp(TapUpDetails details) {
496496
if (_state.configurations.onTapUp != null &&
497497
renderEditor != null &&
498498
_state.configurations.onTapUp!(
@@ -671,7 +671,6 @@ class RenderEditor extends RenderEditableContainerBox
671671
Document document;
672672
TextSelection selection;
673673
bool _hasFocus = false;
674-
bool get hasFocus => _hasFocus;
675674
LayerLink _startHandleLayerLink;
676675
LayerLink _endHandleLayerLink;
677676

@@ -878,28 +877,20 @@ class RenderEditor extends RenderEditableContainerBox
878877
}
879878

880879
Offset? _lastTapDownPosition;
881-
Offset? _lastSecondaryTapDownPosition;
882-
883-
Offset? get lastSecondaryTapDownPosition => _lastSecondaryTapDownPosition;
884880

885881
// Used on Desktop (mouse and keyboard enabled platforms) as base offset
886882
// for extending selection, either with combination of `Shift` + Click or
887883
// by dragging
888884
TextSelection? _extendSelectionOrigin;
889885

890-
void handleSecondaryTapDown(TapDownDetails details) {
891-
_lastTapDownPosition = details.globalPosition;
892-
_lastSecondaryTapDownPosition = details.globalPosition;
893-
}
894-
895886
@override
896887
void handleTapDown(TapDownDetails details) {
897888
_lastTapDownPosition = details.globalPosition;
898889
}
899890

900891
bool _isDragging = false;
901892

902-
void handleDragStart(TapDragStartDetails details) {
893+
void handleDragStart(DragStartDetails details) {
903894
_isDragging = true;
904895

905896
final newSelection = selectPositionAt(
@@ -912,7 +903,7 @@ class RenderEditor extends RenderEditableContainerBox
912903
_extendSelectionOrigin = newSelection;
913904
}
914905

915-
void handleDragEnd(TapDragEndDetails details) {
906+
void handleDragEnd(DragEndDetails details) {
916907
_isDragging = false;
917908
onSelectionCompleted();
918909
}

lib/src/editor/raw_editor/raw_editor_state.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ class QuillRawEditorState extends EditorState
510510

511511
_selectionOverlay?.handlesVisible = _shouldShowSelectionHandles();
512512

513-
if (!_hasFocus) {
513+
if (!_keyboardVisible) {
514514
// This will show the keyboard for all selection changes on the
515515
// editor, not just changes triggered by user gestures.
516516
requestKeyboard();
@@ -1204,14 +1204,12 @@ class QuillRawEditorState extends EditorState
12041204
return true;
12051205
}
12061206

1207-
@override
1208-
void toggleToolbar([bool hideHandles = true]) {
1209-
final selectionOverlay = _selectionOverlay ??= _createSelectionOverlay();
1210-
if (selectionOverlay.handlesVisible) {
1211-
hideToolbar(hideHandles);
1212-
} else {
1213-
showToolbar();
1214-
}
1207+
void _replaceText(ReplaceTextIntent intent) {
1208+
userUpdateTextEditingValue(
1209+
intent.currentTextEditingValue
1210+
.replaced(intent.replacementRange, intent.replacementText),
1211+
intent.cause,
1212+
);
12151213
}
12161214

12171215
@override

0 commit comments

Comments
 (0)