Skip to content

Commit

Permalink
revert!: magnifier (#2413)
Browse files Browse the repository at this point in the history
* revert: mobile magnifier feature (#2026)

This reverts commit af691e6.

* revert: Copying TapAndPanGestureRecognizer from TextField (#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
  • Loading branch information
EchoEllet authored Jan 19, 2025
1 parent acd8de4 commit 94ccf0b
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 1,156 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- **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).
- **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).
- **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).

### Removed

- **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.

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

Expand Down
20 changes: 19 additions & 1 deletion doc/migration/10_to_11.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ required for **custom toolbars**.
- Moved `onClipboardPaste` from `QuillControllerConfig` to `QuillClipboardConfig`. Added `clipboardConfig` property to `QuillControllerConfig`.
- 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`).
- Changed the options type from `QuillToolbarToggleStyleButtonOptions` to `QuillToolbarClipboardButtonOptions` in `QuillToolbarClipboardButton`, use the new options class.
- 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).
- 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).

## 💥 Breaking behavior

Expand Down Expand Up @@ -483,6 +485,23 @@ QuillSimpleToolbar(
)
```

### 5. Removal of the magnifier feature

Unfortunately, **due to the high volume of issues and bugs introduced by the magnifier**, this feature has been removed to ensure stability.

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.

For more details, refer to [#2406](https://github.com/singerdmx/flutter-quill/issues/2406).

```diff
QuillEditorConfig(
- magnifierConfiguration: TextMagnifierConfiguration()
)
// No longer supported, subscribe to https://github.com/singerdmx/flutter-quill/issues/1504 for updates
```

In the future, new features will be implemented with more caution to avoid possible issues.

## 🚧 Experimental

APIs that were indicated as stable but are now updated to indicate
Expand All @@ -494,7 +513,6 @@ in non-major releases:
- The `QuillEditorConfig.characterShortcutEvents` and `QuillEditorConfig.spaceShortcutEvents`.
- The `QuillControllerConfig.onClipboardPaste`.
- The `QuillEditorConfig.customLeadingBlockBuilder`.
- The magnifier feature including `QuillEditorConfig.magnifierConfiguration`.
- The `shouldNotifyListeners` in `QuillController.replaceText()`, `QuillController.replaceText()`, `QuillController.formatSelection()`.
- The `QuillController.clipboardSelection()`.
- The `CopyCutServiceProvider`, `CopyCutService`, and `DefaultCopyCutService`.
Expand Down
21 changes: 4 additions & 17 deletions lib/src/editor/config/editor_config.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:ui' as ui;

import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart' show experimental;

Expand Down Expand Up @@ -73,7 +72,6 @@ class QuillEditorConfig {
this.contextMenuBuilder,
this.editorKey,
this.requestKeyboardFocusOnCheckListChanged = false,
@experimental this.magnifierConfiguration,
this.textInputAction = TextInputAction.newline,
this.enableScribble = false,
this.onScribbleActivated,
Expand Down Expand Up @@ -338,12 +336,11 @@ class QuillEditorConfig {

// Returns whether gesture is handled
final bool Function(
TapDragDownDetails details, TextPosition Function(Offset offset))?
onTapDown;
TapDownDetails details, TextPosition Function(Offset offset))? onTapDown;

// Returns whether gesture is handled
final bool Function(
TapDragUpDetails details, TextPosition Function(Offset offset))? onTapUp;
TapUpDetails details, TextPosition Function(Offset offset))? onTapUp;

// Returns whether gesture is handled
final bool Function(
Expand Down Expand Up @@ -436,11 +433,6 @@ class QuillEditorConfig {
/// should we request keyboard focus??
final bool requestKeyboardFocusOnCheckListChanged;

/// This feature is currently experimental and only supported
/// on **Android** and **iOS**.
@experimental
final TextMagnifierConfiguration? magnifierConfiguration;

/// Default to [TextInputAction.newline]
final TextInputAction textInputAction;

Expand Down Expand Up @@ -488,11 +480,9 @@ class QuillEditorConfig {
Brightness? keyboardAppearance,
ScrollPhysics? scrollPhysics,
ValueChanged<String>? onLaunchUrl,
bool Function(
TapDragDownDetails details, TextPosition Function(Offset offset))?
bool Function(TapDownDetails details, TextPosition Function(Offset offset))?
onTapDown,
bool Function(
TapDragUpDetails details, TextPosition Function(Offset offset))?
bool Function(TapUpDetails details, TextPosition Function(Offset offset))?
onTapUp,
Iterable<EmbedBuilder>? embedBuilders,
EmbedBuilder? unknownEmbedBuilder,
Expand All @@ -512,7 +502,6 @@ class QuillEditorConfig {
GlobalKey<EditorState>? editorKey,
TextSelectionThemeData? textSelectionThemeData,
bool? requestKeyboardFocusOnCheckListChanged,
TextMagnifierConfiguration? magnifierConfiguration,
TextInputAction? textInputAction,
bool? enableScribble,
void Function()? onScribbleActivated,
Expand Down Expand Up @@ -581,8 +570,6 @@ class QuillEditorConfig {
requestKeyboardFocusOnCheckListChanged:
requestKeyboardFocusOnCheckListChanged ??
this.requestKeyboardFocusOnCheckListChanged,
magnifierConfiguration:
magnifierConfiguration ?? this.magnifierConfiguration,
textInputAction: textInputAction ?? this.textInputAction,
enableScribble: enableScribble ?? this.enableScribble,
onScribbleActivated: onScribbleActivated ?? this.onScribbleActivated,
Expand Down
39 changes: 6 additions & 33 deletions lib/src/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:math' as math;

import 'package:flutter/cupertino.dart'
show CupertinoTheme, cupertinoTextSelectionControls;
import 'package:flutter/foundation.dart' show ValueListenable, kIsWeb;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
Expand All @@ -16,7 +16,6 @@ import '../document/nodes/container.dart' as container_node;
import '../document/nodes/leaf.dart';
import 'config/editor_config.dart';
import 'embed/embed_editor_builder.dart';
import 'magnifier/magnifier_platform_support.dart';
import 'raw_editor/config/raw_editor_config.dart';
import 'raw_editor/raw_editor.dart';
import 'widgets/box.dart';
Expand Down Expand Up @@ -320,7 +319,6 @@ class QuillEditorState extends State<QuillEditor>
onScribbleActivated: configurations.onScribbleActivated,
scribbleAreaInsets: configurations.scribbleAreaInsets,
readOnlyMouseCursor: configurations.readOnlyMouseCursor,
magnifierConfiguration: configurations.magnifierConfiguration,
textInputAction: configurations.textInputAction,
onPerformAction: configurations.onPerformAction,
),
Expand Down Expand Up @@ -448,10 +446,9 @@ class _QuillEditorSelectionGestureDetectorBuilder
SelectionChangedCause.longPress,
);
}
editor?.updateMagnifier(details.globalPosition);
}

bool _isPositionSelected(TapDragUpDetails details) {
bool _isPositionSelected(TapUpDetails details) {
if (_state.controller.document.isEmpty()) {
return false;
}
Expand All @@ -474,7 +471,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
}

@override
void onTapDown(TapDragDownDetails details) {
void onTapDown(TapDownDetails details) {
if (_state.configurations.onTapDown != null) {
if (renderEditor != null &&
_state.configurations.onTapDown!(
Expand All @@ -495,7 +492,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
}

@override
void onSingleTapUp(TapDragUpDetails details) {
void onSingleTapUp(TapUpDetails details) {
if (_state.configurations.onTapUp != null &&
renderEditor != null &&
_state.configurations.onTapUp!(
Expand Down Expand Up @@ -582,8 +579,6 @@ class _QuillEditorSelectionGestureDetectorBuilder
Feedback.forLongPress(_state.context);
}
}

_showMagnifierIfSupported(details.globalPosition);
}

@override
Expand All @@ -602,21 +597,8 @@ class _QuillEditorSelectionGestureDetectorBuilder
}
}
}
_hideMagnifierIfSupported();
super.onSingleLongTapEnd(details);
}

void _showMagnifierIfSupported(Offset positionToShow) {
if (magnifierSupported) {
editor?.showMagnifier(positionToShow);
}
}

void _hideMagnifierIfSupported() {
if (magnifierSupported) {
editor?.hideMagnifier();
}
}
}

/// Signature for the callback that reports when the user changes the selection
Expand Down Expand Up @@ -689,7 +671,6 @@ class RenderEditor extends RenderEditableContainerBox
Document document;
TextSelection selection;
bool _hasFocus = false;
bool get hasFocus => _hasFocus;
LayerLink _startHandleLayerLink;
LayerLink _endHandleLayerLink;

Expand Down Expand Up @@ -896,28 +877,20 @@ class RenderEditor extends RenderEditableContainerBox
}

Offset? _lastTapDownPosition;
Offset? _lastSecondaryTapDownPosition;

Offset? get lastSecondaryTapDownPosition => _lastSecondaryTapDownPosition;

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

void handleSecondaryTapDown(TapDownDetails details) {
_lastTapDownPosition = details.globalPosition;
_lastSecondaryTapDownPosition = details.globalPosition;
}

@override
void handleTapDown(TapDownDetails details) {
_lastTapDownPosition = details.globalPosition;
}

bool _isDragging = false;

void handleDragStart(TapDragStartDetails details) {
void handleDragStart(DragStartDetails details) {
_isDragging = true;

final newSelection = selectPositionAt(
Expand All @@ -930,7 +903,7 @@ class RenderEditor extends RenderEditableContainerBox
_extendSelectionOrigin = newSelection;
}

void handleDragEnd(TapDragEndDetails details) {
void handleDragEnd(DragEndDetails details) {
_isDragging = false;
onSelectionCompleted();
}
Expand Down
4 changes: 0 additions & 4 deletions lib/src/editor/magnifier/magnifier_platform_support.dart

This file was deleted.

106 changes: 0 additions & 106 deletions lib/src/editor/magnifier/text_selection_magnifier_ext.dart

This file was deleted.

6 changes: 0 additions & 6 deletions lib/src/editor/raw_editor/config/raw_editor_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class QuillRawEditorConfig {
this.onScribbleActivated,
this.scribbleAreaInsets,
this.readOnlyMouseCursor = SystemMouseCursors.text,
@experimental this.magnifierConfiguration,
this.onPerformAction,
@experimental this.customLeadingBuilder,
});
Expand Down Expand Up @@ -402,11 +401,6 @@ class QuillRawEditorConfig {
/// Optional insets for the scribble area.
final EdgeInsets? scribbleAreaInsets;

/// This feature is currently experimental and only supported
/// on **Android** and **iOS**.
@experimental
final TextMagnifierConfiguration? magnifierConfiguration;

/// Called when a text input action is performed.
final void Function(TextInputAction action)? onPerformAction;
}
Loading

0 comments on commit 94ccf0b

Please sign in to comment.