From b9571fff08e23aceca418bd52f2a733365064de4 Mon Sep 17 00:00:00 2001 From: Mike Allen Date: Mon, 5 Feb 2024 16:04:15 -0800 Subject: [PATCH 1/2] on web platforms, do not call clipboard status update as security measures block that and currently cause safari to display a paste menu --- lib/src/widgets/others/text_selection.dart | 7 ++++++- lib/src/widgets/raw_editor/raw_editor_state.dart | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/src/widgets/others/text_selection.dart b/lib/src/widgets/others/text_selection.dart index 8016201f0..efcaa86bb 100644 --- a/lib/src/widgets/others/text_selection.dart +++ b/lib/src/widgets/others/text_selection.dart @@ -82,7 +82,12 @@ class EditorTextSelectionOverlay { // our listener being created // we won't know the status unless there is forced update // i.e. occasionally no paste - clipboardStatus.update(); + if (!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 + clipboardStatus.update(); + } } TextEditingValue value; diff --git a/lib/src/widgets/raw_editor/raw_editor_state.dart b/lib/src/widgets/raw_editor/raw_editor_state.dart index 37ee67b79..8fd66c34d 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state.dart @@ -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; @@ -97,7 +97,12 @@ class QuillRawEditorState extends EditorState String get pastePlainText => _pastePlainText; String _pastePlainText = ''; - final ClipboardStatusNotifier _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. + final ClipboardStatusNotifier _clipboardStatus = ClipboardStatusNotifier( + value: kIsWeb ? ClipboardStatus.notPasteable : ClipboardStatus.unknown); final LayerLink _toolbarLayerLink = LayerLink(); final LayerLink _startHandleLayerLink = LayerLink(); final LayerLink _endHandleLayerLink = LayerLink(); From 1052bfa7c53a0029408fe73e02dc44e6cbeb6acf Mon Sep 17 00:00:00 2001 From: Mike Allen Date: Mon, 5 Feb 2024 16:08:23 -0800 Subject: [PATCH 2/2] change default for web to pasteable --- lib/src/widgets/raw_editor/raw_editor_state.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/raw_editor/raw_editor_state.dart b/lib/src/widgets/raw_editor/raw_editor_state.dart index 8fd66c34d..80c1569fd 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state.dart @@ -100,9 +100,10 @@ class QuillRawEditorState extends EditorState // 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. + // clipboard status to be checked w/o user interaction which fails. Default + // to pasteable for web. final ClipboardStatusNotifier _clipboardStatus = ClipboardStatusNotifier( - value: kIsWeb ? ClipboardStatus.notPasteable : ClipboardStatus.unknown); + value: kIsWeb ? ClipboardStatus.pasteable : ClipboardStatus.unknown); final LayerLink _toolbarLayerLink = LayerLink(); final LayerLink _startHandleLayerLink = LayerLink(); final LayerLink _endHandleLayerLink = LayerLink();