Skip to content

Commit 94ccf0b

Browse files
authored
revert!: magnifier (singerdmx#2413)
* revert: mobile magnifier feature (singerdmx#2026) This reverts commit af691e6. * revert: Copying TapAndPanGestureRecognizer from TextField (singerdmx#2128) This reverts commit 2937dc8. * docs(migration): document removal of magnifier * chore: remove magnifierConfiguration from QuillEditorConfig * docs(changelog): reflect the change * chore: remove unused _replaceText() from raw_editor_state.dart as it is in editor_keyboard_shortcut_actions_manager.dart and added back due to git revert * chore: update onTapDown and onTapUp, document the revert in CHANGELOG.md and in the migration guide
1 parent acd8de4 commit 94ccf0b

File tree

12 files changed

+302
-1156
lines changed

12 files changed

+302
-1156
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Changed
1414

1515
- **BREAKING**: Change the `options` parameter class type from `QuillToolbarToggleStyleButtonOptions` to `QuillToolbarClipboardButtonOptions` in `QuillToolbarClipboardButton`. To migrate, use `QuillToolbarClipboardButtonOptions` instead of `QuillToolbarToggleStyleButtonOptions` [#2433](https://github.com/singerdmx/flutter-quill/pull/2433).
16+
- **BREAKING**: Change the `onTapDown` to accept `TapDownDetails` instead of `TapDragDownDetails` (revert [#2128](https://github.com/singerdmx/flutter-quill/pull/2128/files#diff-49ca9b0fdd0d380a06b34d5aed7674bbfb27fede500831b3e1279615a9edd06dL259-L261) due to regressions).
17+
- **BREAKING**: Change the `onTapUp` to accept `TapUpDetails` instead of `TapDragUpDetails` (revert [#2128](https://github.com/singerdmx/flutter-quill/pull/2128/files#diff-49ca9b0fdd0d380a06b34d5aed7674bbfb27fede500831b3e1279615a9edd06dL263-L265) due to regressions).
18+
19+
### Removed
20+
21+
- **BREAKING**: The magnifier feature due to buggy behavior [#2413](https://github.com/singerdmx/flutter-quill/pull/2413). See [#2406](https://github.com/singerdmx/flutter-quill/issues/2406) for a list of reasons.
1622

1723
## [11.0.0-dev.19] - 2025-01-10
1824

doc/migration/10_to_11.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ required for **custom toolbars**.
352352
- Moved `onClipboardPaste` from `QuillControllerConfig` to `QuillClipboardConfig`. Added `clipboardConfig` property to `QuillControllerConfig`.
353353
- Moved `onImagePaste` and `onGifPaste` from the editor's config (`QuillEditorConfig` or `QuillRawEditorConfig`) to the clipboard's config (`QuillClipboardConfig`), which is part of the controller's config (`QuillControllerConfig`).
354354
- Changed the options type from `QuillToolbarToggleStyleButtonOptions` to `QuillToolbarClipboardButtonOptions` in `QuillToolbarClipboardButton`, use the new options class.
355+
- Change the `onTapDown` to accept `TapDownDetails` instead of `TapDragDownDetails` (revert [#2128](https://github.com/singerdmx/flutter-quill/pull/2128/files#diff-49ca9b0fdd0d380a06b34d5aed7674bbfb27fede500831b3e1279615a9edd06dL259-L261) due to regressions).
356+
- Change the `onTapUp` to accept `TapUpDetails` instead of `TapDragUpDetails` (revert [#2128](https://github.com/singerdmx/flutter-quill/pull/2128/files#diff-49ca9b0fdd0d380a06b34d5aed7674bbfb27fede500831b3e1279615a9edd06dL263-L265) due to regressions).
355357

356358
## 💥 Breaking behavior
357359

@@ -483,6 +485,23 @@ QuillSimpleToolbar(
483485
)
484486
```
485487

488+
### 5. Removal of the magnifier feature
489+
490+
Unfortunately, **due to the high volume of issues and bugs introduced by the magnifier**, this feature has been removed to ensure stability.
491+
492+
This feature was introduced in [9.6.0](https://pub.dev/packages/flutter_quill/versions/9.6.0/changelog#960) which supports Android and iOS only.
493+
494+
For more details, refer to [#2406](https://github.com/singerdmx/flutter-quill/issues/2406).
495+
496+
```diff
497+
QuillEditorConfig(
498+
- magnifierConfiguration: TextMagnifierConfiguration()
499+
)
500+
// No longer supported, subscribe to https://github.com/singerdmx/flutter-quill/issues/1504 for updates
501+
```
502+
503+
In the future, new features will be implemented with more caution to avoid possible issues.
504+
486505
## 🚧 Experimental
487506

488507
APIs that were indicated as stable but are now updated to indicate
@@ -494,7 +513,6 @@ in non-major releases:
494513
- The `QuillEditorConfig.characterShortcutEvents` and `QuillEditorConfig.spaceShortcutEvents`.
495514
- The `QuillControllerConfig.onClipboardPaste`.
496515
- The `QuillEditorConfig.customLeadingBlockBuilder`.
497-
- The magnifier feature including `QuillEditorConfig.magnifierConfiguration`.
498516
- The `shouldNotifyListeners` in `QuillController.replaceText()`, `QuillController.replaceText()`, `QuillController.formatSelection()`.
499517
- The `QuillController.clipboardSelection()`.
500518
- The `CopyCutServiceProvider`, `CopyCutService`, and `DefaultCopyCutService`.

lib/src/editor/config/editor_config.dart

Lines changed: 4 additions & 17 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

@@ -73,7 +72,6 @@ class QuillEditorConfig {
7372
this.contextMenuBuilder,
7473
this.editorKey,
7574
this.requestKeyboardFocusOnCheckListChanged = false,
76-
@experimental this.magnifierConfiguration,
7775
this.textInputAction = TextInputAction.newline,
7876
this.enableScribble = false,
7977
this.onScribbleActivated,
@@ -338,12 +336,11 @@ class QuillEditorConfig {
338336

339337
// Returns whether gesture is handled
340338
final bool Function(
341-
TapDragDownDetails details, TextPosition Function(Offset offset))?
342-
onTapDown;
339+
TapDownDetails details, TextPosition Function(Offset offset))? onTapDown;
343340

344341
// Returns whether gesture is handled
345342
final bool Function(
346-
TapDragUpDetails details, TextPosition Function(Offset offset))? onTapUp;
343+
TapUpDetails details, TextPosition Function(Offset offset))? onTapUp;
347344

348345
// Returns whether gesture is handled
349346
final bool Function(
@@ -436,11 +433,6 @@ class QuillEditorConfig {
436433
/// should we request keyboard focus??
437434
final bool requestKeyboardFocusOnCheckListChanged;
438435

439-
/// This feature is currently experimental and only supported
440-
/// on **Android** and **iOS**.
441-
@experimental
442-
final TextMagnifierConfiguration? magnifierConfiguration;
443-
444436
/// Default to [TextInputAction.newline]
445437
final TextInputAction textInputAction;
446438

@@ -488,11 +480,9 @@ class QuillEditorConfig {
488480
Brightness? keyboardAppearance,
489481
ScrollPhysics? scrollPhysics,
490482
ValueChanged<String>? onLaunchUrl,
491-
bool Function(
492-
TapDragDownDetails details, TextPosition Function(Offset offset))?
483+
bool Function(TapDownDetails details, TextPosition Function(Offset offset))?
493484
onTapDown,
494-
bool Function(
495-
TapDragUpDetails details, TextPosition Function(Offset offset))?
485+
bool Function(TapUpDetails details, TextPosition Function(Offset offset))?
496486
onTapUp,
497487
Iterable<EmbedBuilder>? embedBuilders,
498488
EmbedBuilder? unknownEmbedBuilder,
@@ -512,7 +502,6 @@ class QuillEditorConfig {
512502
GlobalKey<EditorState>? editorKey,
513503
TextSelectionThemeData? textSelectionThemeData,
514504
bool? requestKeyboardFocusOnCheckListChanged,
515-
TextMagnifierConfiguration? magnifierConfiguration,
516505
TextInputAction? textInputAction,
517506
bool? enableScribble,
518507
void Function()? onScribbleActivated,
@@ -581,8 +570,6 @@ class QuillEditorConfig {
581570
requestKeyboardFocusOnCheckListChanged:
582571
requestKeyboardFocusOnCheckListChanged ??
583572
this.requestKeyboardFocusOnCheckListChanged,
584-
magnifierConfiguration:
585-
magnifierConfiguration ?? this.magnifierConfiguration,
586573
textInputAction: textInputAction ?? this.textInputAction,
587574
enableScribble: enableScribble ?? this.enableScribble,
588575
onScribbleActivated: onScribbleActivated ?? this.onScribbleActivated,

lib/src/editor/editor.dart

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

33
import 'package:flutter/cupertino.dart'
44
show CupertinoTheme, cupertinoTextSelectionControls;
5-
import 'package:flutter/foundation.dart' show ValueListenable, kIsWeb;
5+
import 'package:flutter/foundation.dart';
66
import 'package:flutter/gestures.dart';
77
import 'package:flutter/material.dart';
88
import 'package:flutter/rendering.dart';
@@ -16,7 +16,6 @@ import '../document/nodes/container.dart' as container_node;
1616
import '../document/nodes/leaf.dart';
1717
import 'config/editor_config.dart';
1818
import 'embed/embed_editor_builder.dart';
19-
import 'magnifier/magnifier_platform_support.dart';
2019
import 'raw_editor/config/raw_editor_config.dart';
2120
import 'raw_editor/raw_editor.dart';
2221
import 'widgets/box.dart';
@@ -320,7 +319,6 @@ class QuillEditorState extends State<QuillEditor>
320319
onScribbleActivated: configurations.onScribbleActivated,
321320
scribbleAreaInsets: configurations.scribbleAreaInsets,
322321
readOnlyMouseCursor: configurations.readOnlyMouseCursor,
323-
magnifierConfiguration: configurations.magnifierConfiguration,
324322
textInputAction: configurations.textInputAction,
325323
onPerformAction: configurations.onPerformAction,
326324
),
@@ -448,10 +446,9 @@ class _QuillEditorSelectionGestureDetectorBuilder
448446
SelectionChangedCause.longPress,
449447
);
450448
}
451-
editor?.updateMagnifier(details.globalPosition);
452449
}
453450

454-
bool _isPositionSelected(TapDragUpDetails details) {
451+
bool _isPositionSelected(TapUpDetails details) {
455452
if (_state.controller.document.isEmpty()) {
456453
return false;
457454
}
@@ -474,7 +471,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
474471
}
475472

476473
@override
477-
void onTapDown(TapDragDownDetails details) {
474+
void onTapDown(TapDownDetails details) {
478475
if (_state.configurations.onTapDown != null) {
479476
if (renderEditor != null &&
480477
_state.configurations.onTapDown!(
@@ -495,7 +492,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
495492
}
496493

497494
@override
498-
void onSingleTapUp(TapDragUpDetails details) {
495+
void onSingleTapUp(TapUpDetails details) {
499496
if (_state.configurations.onTapUp != null &&
500497
renderEditor != null &&
501498
_state.configurations.onTapUp!(
@@ -582,8 +579,6 @@ class _QuillEditorSelectionGestureDetectorBuilder
582579
Feedback.forLongPress(_state.context);
583580
}
584581
}
585-
586-
_showMagnifierIfSupported(details.globalPosition);
587582
}
588583

589584
@override
@@ -602,21 +597,8 @@ class _QuillEditorSelectionGestureDetectorBuilder
602597
}
603598
}
604599
}
605-
_hideMagnifierIfSupported();
606600
super.onSingleLongTapEnd(details);
607601
}
608-
609-
void _showMagnifierIfSupported(Offset positionToShow) {
610-
if (magnifierSupported) {
611-
editor?.showMagnifier(positionToShow);
612-
}
613-
}
614-
615-
void _hideMagnifierIfSupported() {
616-
if (magnifierSupported) {
617-
editor?.hideMagnifier();
618-
}
619-
}
620602
}
621603

622604
/// Signature for the callback that reports when the user changes the selection
@@ -689,7 +671,6 @@ class RenderEditor extends RenderEditableContainerBox
689671
Document document;
690672
TextSelection selection;
691673
bool _hasFocus = false;
692-
bool get hasFocus => _hasFocus;
693674
LayerLink _startHandleLayerLink;
694675
LayerLink _endHandleLayerLink;
695676

@@ -896,28 +877,20 @@ class RenderEditor extends RenderEditableContainerBox
896877
}
897878

898879
Offset? _lastTapDownPosition;
899-
Offset? _lastSecondaryTapDownPosition;
900-
901-
Offset? get lastSecondaryTapDownPosition => _lastSecondaryTapDownPosition;
902880

903881
// Used on Desktop (mouse and keyboard enabled platforms) as base offset
904882
// for extending selection, either with combination of `Shift` + Click or
905883
// by dragging
906884
TextSelection? _extendSelectionOrigin;
907885

908-
void handleSecondaryTapDown(TapDownDetails details) {
909-
_lastTapDownPosition = details.globalPosition;
910-
_lastSecondaryTapDownPosition = details.globalPosition;
911-
}
912-
913886
@override
914887
void handleTapDown(TapDownDetails details) {
915888
_lastTapDownPosition = details.globalPosition;
916889
}
917890

918891
bool _isDragging = false;
919892

920-
void handleDragStart(TapDragStartDetails details) {
893+
void handleDragStart(DragStartDetails details) {
921894
_isDragging = true;
922895

923896
final newSelection = selectPositionAt(
@@ -930,7 +903,7 @@ class RenderEditor extends RenderEditableContainerBox
930903
_extendSelectionOrigin = newSelection;
931904
}
932905

933-
void handleDragEnd(TapDragEndDetails details) {
906+
void handleDragEnd(DragEndDetails details) {
934907
_isDragging = false;
935908
onSelectionCompleted();
936909
}

lib/src/editor/magnifier/magnifier_platform_support.dart

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/src/editor/magnifier/text_selection_magnifier_ext.dart

Lines changed: 0 additions & 106 deletions
This file was deleted.

lib/src/editor/raw_editor/config/raw_editor_config.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class QuillRawEditorConfig {
6666
this.onScribbleActivated,
6767
this.scribbleAreaInsets,
6868
this.readOnlyMouseCursor = SystemMouseCursors.text,
69-
@experimental this.magnifierConfiguration,
7069
this.onPerformAction,
7170
@experimental this.customLeadingBuilder,
7271
});
@@ -402,11 +401,6 @@ class QuillRawEditorConfig {
402401
/// Optional insets for the scribble area.
403402
final EdgeInsets? scribbleAreaInsets;
404403

405-
/// This feature is currently experimental and only supported
406-
/// on **Android** and **iOS**.
407-
@experimental
408-
final TextMagnifierConfiguration? magnifierConfiguration;
409-
410404
/// Called when a text input action is performed.
411405
final void Function(TextInputAction action)? onPerformAction;
412406
}

0 commit comments

Comments
 (0)