-
Notifications
You must be signed in to change notification settings - Fork 857
/
Copy pathquill_clipboard_config.dart
95 lines (86 loc) · 3.1 KB
/
quill_clipboard_config.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import 'package:flutter/foundation.dart';
import 'package:meta/meta.dart';
import '../../../quill_delta.dart';
@immutable
@experimental
class QuillClipboardConfig {
const QuillClipboardConfig({
@experimental this.onClipboardPaste,
@experimental this.onUnprocessedPaste,
this.onImagePaste,
@experimental this.onGifPaste,
@experimental this.onDeltaPaste,
@experimental this.onPlainTextPaste,
@experimental this.enableExternalRichPaste,
});
/// Callback to allow overriding the default clipboard paste handling.
///
/// A minimal example of removing the plain text if it exists in the
/// system clipboard, otherwise fallback to the default handling:
///
/// ```dart
/// onClipboardPaste: () async {
/// final clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
/// if (clipboardData != null) {
/// await Clipboard.setData(const ClipboardData(text: ''));
/// // The paste operation was handled
/// return true;
/// }
/// // Fallback to the default handling
/// return false;
/// }
/// ```
///
/// An example of disabling the clipboard paste:
///
/// ```dart
/// onClipboardPaste: () async {
/// return true;
/// }
/// ```
///
/// Return `true` if the paste operation was handled or `false` to
/// fallback to the default clipboard paste handling.
@experimental
final Future<bool> Function()? onClipboardPaste;
/// Callback when the user pastes and data has not already been processed.
///
/// Return `true` if the paste operation was handled.
@experimental
final Future<bool> Function()? onUnprocessedPaste;
/// Callback when the user pastes the given image.
///
/// Returns the URL of the image if the image should be inserted.
final Future<String?> Function(Uint8List imageBytes)? onImagePaste;
/// Callback when the user pastes the given GIF.
///
/// Supports **Android** and **iOS** only.
///
/// Returns the URL of the image if the GIF image should be inserted.
@experimental
final Future<String?> Function(Uint8List imageBytes)? onGifPaste;
/// Callback triggered when pasting a [Delta] to the editor.
///
/// Return a modified [Delta] to override the pasted content, or `null` to use the default.
@experimental
final Future<Delta?> Function(Delta delta)? onDeltaPaste;
/// Callback triggered when pasting plain text into the editor.
///
/// Return modified text to override the pasted content, or `null` to use the default.
@experimental
final Future<String?> Function(String plainText)? onPlainTextPaste;
/// Determines if rich text pasting from external sources (system clipboard) is enabled.
///
/// When enabled, rich text content from other apps can be pasted into the editor,
/// using platform APIs to access the system clipboard.
///
/// Will convert the **HTML** (from the system clipboard) to [Delta]
/// and then paste it, use [onDeltaPaste] to customize the [Delta]
/// before pasting it.
///
/// Defaults to `true`.
///
/// See also: https://pub.dev/packages/flutter_quill#-rich-text-paste
@experimental
final bool? enableExternalRichPaste;
}