Fix safari clipboard bug (#1722)

* on web platforms, do not call clipboard status update as security measures block that and currently cause safari to display a paste menu

* change default for web to pasteable
pull/1729/head
Michael Allen 1 year ago committed by GitHub
parent 5d9dc102f1
commit be84f1ca56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      lib/src/widgets/others/text_selection.dart
  2. 10
      lib/src/widgets/raw_editor/raw_editor_state.dart

@ -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
clipboardStatus!.update();
}
}

@ -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;
@ -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) {

Loading…
Cancel
Save