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

Fix safari clipboard bug #1722

Merged
merged 3 commits into from
Feb 6, 2024
Merged
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
5 changes: 4 additions & 1 deletion lib/src/widgets/others/text_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ class EditorTextSelectionOverlay {
// our listener being created
// we won't know the status unless there is forced update
// i.e. occasionally no paste
if (clipboardStatus != null) {
if (clipboardStatus != null && !kIsWeb) {
// Web - esp Safari Mac/iOS has security measures in place that restrict
// cliboard status checks w/o direct user interaction. So skip this
// for web
Comment on lines +86 to +88
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this issue is specific to Safari (Mac/iOS), shouldn't we only introduce this change for safari instead of all browsers?

clipboardStatus!.update();
}
}
Expand Down
10 changes: 8 additions & 2 deletions lib/src/widgets/raw_editor/raw_editor_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'dart:math' as math;
import 'dart:ui' as ui hide TextStyle;

import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart' show defaultTargetPlatform;
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show RenderAbstractViewport;
import 'package:flutter/scheduler.dart' show SchedulerBinding;
Expand Down Expand Up @@ -524,7 +524,13 @@ class QuillRawEditorState extends EditorState
);

if (!widget.configurations.disableClipboard) {
_clipboardStatus = ClipboardStatusNotifier();
// Web - esp Safari Mac/iOS has security measures in place that restrict
// cliboard status checks w/o direct user interaction. Initializing the
// ClipboardStatusNotifier with a default value of unknown will cause the
// clipboard status to be checked w/o user interaction which fails. Default
// to pasteable for web.
_clipboardStatus = ClipboardStatusNotifier(
value: kIsWeb ? ClipboardStatus.pasteable : ClipboardStatus.unknown);
}

if (widget.configurations.scrollable) {
Expand Down
Loading