Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert!: magnifier #2413

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### 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.18] - 2025-01-06

### Changed
Expand Down
18 changes: 17 additions & 1 deletion doc/migration/10_to_11.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,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 @@ -493,7 +510,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
15 changes: 2 additions & 13 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 @@ -506,7 +498,6 @@ class QuillEditorConfig {
GlobalKey<EditorState>? editorKey,
TextSelectionThemeData? textSelectionThemeData,
bool? requestKeyboardFocusOnCheckListChanged,
TextMagnifierConfiguration? magnifierConfiguration,
TextInputAction? textInputAction,
bool? enableScribble,
void Function()? onScribbleActivated,
Expand Down Expand Up @@ -573,8 +564,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;
}
12 changes: 0 additions & 12 deletions lib/src/editor/raw_editor/raw_editor.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart';

import '../../common/structs/offset_value.dart';
import '../../controller/quill_controller.dart';
Expand Down Expand Up @@ -77,15 +76,4 @@ abstract class EditorState extends State<QuillRawEditor>
bool showToolbar();

void requestKeyboard();

@experimental
void showMagnifier(Offset positionToShow);

@experimental
void updateMagnifier(Offset positionToShow);

@experimental
void hideMagnifier();

void toggleToolbar([bool hideHandles = true]);
}
Loading
Loading