@capawesome/capacitor-clipboard 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapawesomeCapacitorClipboard.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +220 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/Clipboard.java +141 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/ClipboardPlugin.java +96 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/classes/ClipboardContentType.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/classes/CustomExceptions.java +12 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/classes/options/WriteOptions.java +60 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/classes/results/ReadResult.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/interfaces/EmptyCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/clipboard/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +249 -0
- package/dist/esm/definitions.d.ts +144 -0
- package/dist/esm/definitions.js +57 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +16 -0
- package/dist/esm/web.js +109 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +179 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +182 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/Options/WriteOptions.swift +19 -0
- package/ios/Plugin/Classes/Results/ReadResult.swift +19 -0
- package/ios/Plugin/Clipboard.swift +74 -0
- package/ios/Plugin/ClipboardPlugin.swift +62 -0
- package/ios/Plugin/Enums/ClipboardContentType.swift +8 -0
- package/ios/Plugin/Enums/CustomError.swift +36 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +5 -0
- package/package.json +94 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.clipboard.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.clipboard.classes.CustomExceptions;
|
|
7
|
+
|
|
8
|
+
public class WriteOptions {
|
|
9
|
+
|
|
10
|
+
@Nullable
|
|
11
|
+
private final String html;
|
|
12
|
+
|
|
13
|
+
@Nullable
|
|
14
|
+
private final String image;
|
|
15
|
+
|
|
16
|
+
@Nullable
|
|
17
|
+
private final String label;
|
|
18
|
+
|
|
19
|
+
@Nullable
|
|
20
|
+
private final String text;
|
|
21
|
+
|
|
22
|
+
@Nullable
|
|
23
|
+
private final String url;
|
|
24
|
+
|
|
25
|
+
public WriteOptions(@NonNull PluginCall call) throws Exception {
|
|
26
|
+
this.html = call.getString("html");
|
|
27
|
+
this.image = call.getString("image");
|
|
28
|
+
this.label = call.getString("label");
|
|
29
|
+
this.text = call.getString("text");
|
|
30
|
+
this.url = call.getString("url");
|
|
31
|
+
if (html == null && image == null && text == null && url == null) {
|
|
32
|
+
throw CustomExceptions.CONTENT_MISSING;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Nullable
|
|
37
|
+
public String getHtml() {
|
|
38
|
+
return html;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Nullable
|
|
42
|
+
public String getImage() {
|
|
43
|
+
return image;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Nullable
|
|
47
|
+
public String getLabel() {
|
|
48
|
+
return label;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Nullable
|
|
52
|
+
public String getText() {
|
|
53
|
+
return text;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@Nullable
|
|
57
|
+
public String getUrl() {
|
|
58
|
+
return url;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.clipboard.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.clipboard.classes.ClipboardContentType;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.clipboard.interfaces.Result;
|
|
7
|
+
|
|
8
|
+
public class ReadResult implements Result {
|
|
9
|
+
|
|
10
|
+
@NonNull
|
|
11
|
+
private final ClipboardContentType type;
|
|
12
|
+
|
|
13
|
+
@NonNull
|
|
14
|
+
private final String value;
|
|
15
|
+
|
|
16
|
+
public ReadResult(@NonNull ClipboardContentType type, @NonNull String value) {
|
|
17
|
+
this.type = type;
|
|
18
|
+
this.value = value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Override
|
|
22
|
+
@NonNull
|
|
23
|
+
public JSObject toJSObject() {
|
|
24
|
+
JSObject result = new JSObject();
|
|
25
|
+
result.put("type", type.getValue());
|
|
26
|
+
result.put("value", value);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "ClipboardPlugin",
|
|
4
|
+
"slug": "clipboardplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "read",
|
|
10
|
+
"signature": "() => Promise<ReadResult>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<ReadResult>",
|
|
13
|
+
"tags": [
|
|
14
|
+
{
|
|
15
|
+
"name": "since",
|
|
16
|
+
"text": "0.1.0"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"docs": "Read the current content of the system clipboard.\n\nOn Android, reading the clipboard is only possible while the app is in the\nforeground.\n\nOn iOS, reading the clipboard displays a system paste notification. This is\nexpected behavior and cannot be suppressed.",
|
|
20
|
+
"complexTypes": [
|
|
21
|
+
"ReadResult"
|
|
22
|
+
],
|
|
23
|
+
"slug": "read"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "write",
|
|
27
|
+
"signature": "(options: WriteOptions) => Promise<void>",
|
|
28
|
+
"parameters": [
|
|
29
|
+
{
|
|
30
|
+
"name": "options",
|
|
31
|
+
"docs": "",
|
|
32
|
+
"type": "WriteOptions"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"returns": "Promise<void>",
|
|
36
|
+
"tags": [
|
|
37
|
+
{
|
|
38
|
+
"name": "since",
|
|
39
|
+
"text": "0.1.0"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"docs": "Write content to the system clipboard.\n\nExactly one of `text`, `html`, `image` or `url` must be provided. The\n`html` property may additionally be combined with `text` to provide a\nplain-text fallback.",
|
|
43
|
+
"complexTypes": [
|
|
44
|
+
"WriteOptions"
|
|
45
|
+
],
|
|
46
|
+
"slug": "write"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"properties": []
|
|
50
|
+
},
|
|
51
|
+
"interfaces": [
|
|
52
|
+
{
|
|
53
|
+
"name": "ReadResult",
|
|
54
|
+
"slug": "readresult",
|
|
55
|
+
"docs": "",
|
|
56
|
+
"tags": [
|
|
57
|
+
{
|
|
58
|
+
"text": "0.1.0",
|
|
59
|
+
"name": "since"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"methods": [],
|
|
63
|
+
"properties": [
|
|
64
|
+
{
|
|
65
|
+
"name": "type",
|
|
66
|
+
"tags": [
|
|
67
|
+
{
|
|
68
|
+
"text": "0.1.0",
|
|
69
|
+
"name": "since"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"text": "'TEXT'",
|
|
73
|
+
"name": "example"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"docs": "The type of the content that was read from the clipboard.",
|
|
77
|
+
"complexTypes": [
|
|
78
|
+
"ClipboardContentType"
|
|
79
|
+
],
|
|
80
|
+
"type": "ClipboardContentType"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "value",
|
|
84
|
+
"tags": [
|
|
85
|
+
{
|
|
86
|
+
"text": "0.1.0",
|
|
87
|
+
"name": "since"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"text": "'Hello World'",
|
|
91
|
+
"name": "example"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"docs": "The content that was read from the clipboard.\n\nImages are returned as a Base64-encoded data URL.",
|
|
95
|
+
"complexTypes": [],
|
|
96
|
+
"type": "string"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "WriteOptions",
|
|
102
|
+
"slug": "writeoptions",
|
|
103
|
+
"docs": "",
|
|
104
|
+
"tags": [
|
|
105
|
+
{
|
|
106
|
+
"text": "0.1.0",
|
|
107
|
+
"name": "since"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"methods": [],
|
|
111
|
+
"properties": [
|
|
112
|
+
{
|
|
113
|
+
"name": "html",
|
|
114
|
+
"tags": [
|
|
115
|
+
{
|
|
116
|
+
"text": "0.1.0",
|
|
117
|
+
"name": "since"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"text": "'<b>Hello World</b>'",
|
|
121
|
+
"name": "example"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"docs": "The HTML content to write to the clipboard.\n\nCombine this with `text` to provide a plain-text fallback for apps that\ncannot handle HTML content.",
|
|
125
|
+
"complexTypes": [],
|
|
126
|
+
"type": "string | undefined"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "image",
|
|
130
|
+
"tags": [
|
|
131
|
+
{
|
|
132
|
+
"text": "0.1.0",
|
|
133
|
+
"name": "since"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"text": "'data:image/png;base64,iVBORw0KGgo...'",
|
|
137
|
+
"name": "example"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"docs": "The image to write to the clipboard as a Base64-encoded data URL.",
|
|
141
|
+
"complexTypes": [],
|
|
142
|
+
"type": "string | undefined"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "label",
|
|
146
|
+
"tags": [
|
|
147
|
+
{
|
|
148
|
+
"text": "0.1.0",
|
|
149
|
+
"name": "since"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"text": "'My label'",
|
|
153
|
+
"name": "example"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"docs": "The label used to describe the clipboard content.\n\nOnly available on Android.",
|
|
157
|
+
"complexTypes": [],
|
|
158
|
+
"type": "string | undefined"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "text",
|
|
162
|
+
"tags": [
|
|
163
|
+
{
|
|
164
|
+
"text": "0.1.0",
|
|
165
|
+
"name": "since"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"text": "'Hello World'",
|
|
169
|
+
"name": "example"
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"docs": "The plain text to write to the clipboard.",
|
|
173
|
+
"complexTypes": [],
|
|
174
|
+
"type": "string | undefined"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "url",
|
|
178
|
+
"tags": [
|
|
179
|
+
{
|
|
180
|
+
"text": "0.1.0",
|
|
181
|
+
"name": "since"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"text": "'https://capawesome.io'",
|
|
185
|
+
"name": "example"
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"docs": "The URL to write to the clipboard.",
|
|
189
|
+
"complexTypes": [],
|
|
190
|
+
"type": "string | undefined"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"enums": [
|
|
196
|
+
{
|
|
197
|
+
"name": "ClipboardContentType",
|
|
198
|
+
"slug": "clipboardcontenttype",
|
|
199
|
+
"members": [
|
|
200
|
+
{
|
|
201
|
+
"name": "Html",
|
|
202
|
+
"value": "'HTML'",
|
|
203
|
+
"tags": [
|
|
204
|
+
{
|
|
205
|
+
"text": "0.1.0",
|
|
206
|
+
"name": "since"
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
"docs": "The content is HTML."
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"name": "Image",
|
|
213
|
+
"value": "'IMAGE'",
|
|
214
|
+
"tags": [
|
|
215
|
+
{
|
|
216
|
+
"text": "0.1.0",
|
|
217
|
+
"name": "since"
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
"docs": "The content is an image, returned as a Base64-encoded data URL."
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"name": "Text",
|
|
224
|
+
"value": "'TEXT'",
|
|
225
|
+
"tags": [
|
|
226
|
+
{
|
|
227
|
+
"text": "0.1.0",
|
|
228
|
+
"name": "since"
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"docs": "The content is plain text."
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"name": "Url",
|
|
235
|
+
"value": "'URL'",
|
|
236
|
+
"tags": [
|
|
237
|
+
{
|
|
238
|
+
"text": "0.1.0",
|
|
239
|
+
"name": "since"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"docs": "The content is a URL."
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
"typeAliases": [],
|
|
248
|
+
"pluginConfigs": []
|
|
249
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export interface ClipboardPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Read the current content of the system clipboard.
|
|
4
|
+
*
|
|
5
|
+
* On Android, reading the clipboard is only possible while the app is in the
|
|
6
|
+
* foreground.
|
|
7
|
+
*
|
|
8
|
+
* On iOS, reading the clipboard displays a system paste notification. This is
|
|
9
|
+
* expected behavior and cannot be suppressed.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
read(): Promise<ReadResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Write content to the system clipboard.
|
|
16
|
+
*
|
|
17
|
+
* Exactly one of `text`, `html`, `image` or `url` must be provided. The
|
|
18
|
+
* `html` property may additionally be combined with `text` to provide a
|
|
19
|
+
* plain-text fallback.
|
|
20
|
+
*
|
|
21
|
+
* @since 0.1.0
|
|
22
|
+
*/
|
|
23
|
+
write(options: WriteOptions): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @since 0.1.0
|
|
27
|
+
*/
|
|
28
|
+
export interface ReadResult {
|
|
29
|
+
/**
|
|
30
|
+
* The type of the content that was read from the clipboard.
|
|
31
|
+
*
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
* @example 'TEXT'
|
|
34
|
+
*/
|
|
35
|
+
type: ClipboardContentType;
|
|
36
|
+
/**
|
|
37
|
+
* The content that was read from the clipboard.
|
|
38
|
+
*
|
|
39
|
+
* Images are returned as a Base64-encoded data URL.
|
|
40
|
+
*
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
* @example 'Hello World'
|
|
43
|
+
*/
|
|
44
|
+
value: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @since 0.1.0
|
|
48
|
+
*/
|
|
49
|
+
export interface WriteOptions {
|
|
50
|
+
/**
|
|
51
|
+
* The HTML content to write to the clipboard.
|
|
52
|
+
*
|
|
53
|
+
* Combine this with `text` to provide a plain-text fallback for apps that
|
|
54
|
+
* cannot handle HTML content.
|
|
55
|
+
*
|
|
56
|
+
* @since 0.1.0
|
|
57
|
+
* @example '<b>Hello World</b>'
|
|
58
|
+
*/
|
|
59
|
+
html?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The image to write to the clipboard as a Base64-encoded data URL.
|
|
62
|
+
*
|
|
63
|
+
* @since 0.1.0
|
|
64
|
+
* @example 'data:image/png;base64,iVBORw0KGgo...'
|
|
65
|
+
*/
|
|
66
|
+
image?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The label used to describe the clipboard content.
|
|
69
|
+
*
|
|
70
|
+
* Only available on Android.
|
|
71
|
+
*
|
|
72
|
+
* @since 0.1.0
|
|
73
|
+
* @example 'My label'
|
|
74
|
+
*/
|
|
75
|
+
label?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The plain text to write to the clipboard.
|
|
78
|
+
*
|
|
79
|
+
* @since 0.1.0
|
|
80
|
+
* @example 'Hello World'
|
|
81
|
+
*/
|
|
82
|
+
text?: string;
|
|
83
|
+
/**
|
|
84
|
+
* The URL to write to the clipboard.
|
|
85
|
+
*
|
|
86
|
+
* @since 0.1.0
|
|
87
|
+
* @example 'https://capawesome.io'
|
|
88
|
+
*/
|
|
89
|
+
url?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The type of content stored on the clipboard.
|
|
93
|
+
*
|
|
94
|
+
* @since 0.1.0
|
|
95
|
+
*/
|
|
96
|
+
export declare enum ClipboardContentType {
|
|
97
|
+
/**
|
|
98
|
+
* The content is HTML.
|
|
99
|
+
*
|
|
100
|
+
* @since 0.1.0
|
|
101
|
+
*/
|
|
102
|
+
Html = "HTML",
|
|
103
|
+
/**
|
|
104
|
+
* The content is an image, returned as a Base64-encoded data URL.
|
|
105
|
+
*
|
|
106
|
+
* @since 0.1.0
|
|
107
|
+
*/
|
|
108
|
+
Image = "IMAGE",
|
|
109
|
+
/**
|
|
110
|
+
* The content is plain text.
|
|
111
|
+
*
|
|
112
|
+
* @since 0.1.0
|
|
113
|
+
*/
|
|
114
|
+
Text = "TEXT",
|
|
115
|
+
/**
|
|
116
|
+
* The content is a URL.
|
|
117
|
+
*
|
|
118
|
+
* @since 0.1.0
|
|
119
|
+
*/
|
|
120
|
+
Url = "URL"
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @since 0.1.0
|
|
124
|
+
*/
|
|
125
|
+
export declare enum ErrorCode {
|
|
126
|
+
/**
|
|
127
|
+
* The clipboard is empty.
|
|
128
|
+
*
|
|
129
|
+
* @since 0.1.0
|
|
130
|
+
*/
|
|
131
|
+
EmptyClipboard = "EMPTY_CLIPBOARD",
|
|
132
|
+
/**
|
|
133
|
+
* The clipboard content could not be read.
|
|
134
|
+
*
|
|
135
|
+
* @since 0.1.0
|
|
136
|
+
*/
|
|
137
|
+
ReadFailed = "READ_FAILED",
|
|
138
|
+
/**
|
|
139
|
+
* The content could not be written to the clipboard.
|
|
140
|
+
*
|
|
141
|
+
* @since 0.1.0
|
|
142
|
+
*/
|
|
143
|
+
WriteFailed = "WRITE_FAILED"
|
|
144
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The type of content stored on the clipboard.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
export var ClipboardContentType;
|
|
7
|
+
(function (ClipboardContentType) {
|
|
8
|
+
/**
|
|
9
|
+
* The content is HTML.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
ClipboardContentType["Html"] = "HTML";
|
|
14
|
+
/**
|
|
15
|
+
* The content is an image, returned as a Base64-encoded data URL.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
*/
|
|
19
|
+
ClipboardContentType["Image"] = "IMAGE";
|
|
20
|
+
/**
|
|
21
|
+
* The content is plain text.
|
|
22
|
+
*
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
*/
|
|
25
|
+
ClipboardContentType["Text"] = "TEXT";
|
|
26
|
+
/**
|
|
27
|
+
* The content is a URL.
|
|
28
|
+
*
|
|
29
|
+
* @since 0.1.0
|
|
30
|
+
*/
|
|
31
|
+
ClipboardContentType["Url"] = "URL";
|
|
32
|
+
})(ClipboardContentType || (ClipboardContentType = {}));
|
|
33
|
+
/**
|
|
34
|
+
* @since 0.1.0
|
|
35
|
+
*/
|
|
36
|
+
export var ErrorCode;
|
|
37
|
+
(function (ErrorCode) {
|
|
38
|
+
/**
|
|
39
|
+
* The clipboard is empty.
|
|
40
|
+
*
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
*/
|
|
43
|
+
ErrorCode["EmptyClipboard"] = "EMPTY_CLIPBOARD";
|
|
44
|
+
/**
|
|
45
|
+
* The clipboard content could not be read.
|
|
46
|
+
*
|
|
47
|
+
* @since 0.1.0
|
|
48
|
+
*/
|
|
49
|
+
ErrorCode["ReadFailed"] = "READ_FAILED";
|
|
50
|
+
/**
|
|
51
|
+
* The content could not be written to the clipboard.
|
|
52
|
+
*
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
ErrorCode["WriteFailed"] = "WRITE_FAILED";
|
|
56
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
57
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA6FA;;;;GAIG;AACH,MAAM,CAAN,IAAY,oBAyBX;AAzBD,WAAY,oBAAoB;IAC9B;;;;OAIG;IACH,qCAAa,CAAA;IACb;;;;OAIG;IACH,uCAAe,CAAA;IACf;;;;OAIG;IACH,qCAAa,CAAA;IACb;;;;OAIG;IACH,mCAAW,CAAA;AACb,CAAC,EAzBW,oBAAoB,KAApB,oBAAoB,QAyB/B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAmBX;AAnBD,WAAY,SAAS;IACnB;;;;OAIG;IACH,+CAAkC,CAAA;IAClC;;;;OAIG;IACH,uCAA0B,CAAA;IAC1B;;;;OAIG;IACH,yCAA4B,CAAA;AAC9B,CAAC,EAnBW,SAAS,KAAT,SAAS,QAmBpB","sourcesContent":["export interface ClipboardPlugin {\n /**\n * Read the current content of the system clipboard.\n *\n * On Android, reading the clipboard is only possible while the app is in the\n * foreground.\n *\n * On iOS, reading the clipboard displays a system paste notification. This is\n * expected behavior and cannot be suppressed.\n *\n * @since 0.1.0\n */\n read(): Promise<ReadResult>;\n /**\n * Write content to the system clipboard.\n *\n * Exactly one of `text`, `html`, `image` or `url` must be provided. The\n * `html` property may additionally be combined with `text` to provide a\n * plain-text fallback.\n *\n * @since 0.1.0\n */\n write(options: WriteOptions): Promise<void>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface ReadResult {\n /**\n * The type of the content that was read from the clipboard.\n *\n * @since 0.1.0\n * @example 'TEXT'\n */\n type: ClipboardContentType;\n /**\n * The content that was read from the clipboard.\n *\n * Images are returned as a Base64-encoded data URL.\n *\n * @since 0.1.0\n * @example 'Hello World'\n */\n value: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface WriteOptions {\n /**\n * The HTML content to write to the clipboard.\n *\n * Combine this with `text` to provide a plain-text fallback for apps that\n * cannot handle HTML content.\n *\n * @since 0.1.0\n * @example '<b>Hello World</b>'\n */\n html?: string;\n /**\n * The image to write to the clipboard as a Base64-encoded data URL.\n *\n * @since 0.1.0\n * @example 'data:image/png;base64,iVBORw0KGgo...'\n */\n image?: string;\n /**\n * The label used to describe the clipboard content.\n *\n * Only available on Android.\n *\n * @since 0.1.0\n * @example 'My label'\n */\n label?: string;\n /**\n * The plain text to write to the clipboard.\n *\n * @since 0.1.0\n * @example 'Hello World'\n */\n text?: string;\n /**\n * The URL to write to the clipboard.\n *\n * @since 0.1.0\n * @example 'https://capawesome.io'\n */\n url?: string;\n}\n\n/**\n * The type of content stored on the clipboard.\n *\n * @since 0.1.0\n */\nexport enum ClipboardContentType {\n /**\n * The content is HTML.\n *\n * @since 0.1.0\n */\n Html = 'HTML',\n /**\n * The content is an image, returned as a Base64-encoded data URL.\n *\n * @since 0.1.0\n */\n Image = 'IMAGE',\n /**\n * The content is plain text.\n *\n * @since 0.1.0\n */\n Text = 'TEXT',\n /**\n * The content is a URL.\n *\n * @since 0.1.0\n */\n Url = 'URL',\n}\n\n/**\n * @since 0.1.0\n */\nexport enum ErrorCode {\n /**\n * The clipboard is empty.\n *\n * @since 0.1.0\n */\n EmptyClipboard = 'EMPTY_CLIPBOARD',\n /**\n * The clipboard content could not be read.\n *\n * @since 0.1.0\n */\n ReadFailed = 'READ_FAILED',\n /**\n * The content could not be written to the clipboard.\n *\n * @since 0.1.0\n */\n WriteFailed = 'WRITE_FAILED',\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,SAAS,GAAG,cAAc,CAAkB,WAAW,EAAE;IAC7D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC;CAC3D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { ClipboardPlugin } from './definitions';\n\nconst Clipboard = registerPlugin<ClipboardPlugin>('Clipboard', {\n web: () => import('./web').then(m => new m.ClipboardWeb()),\n});\n\nexport * from './definitions';\nexport { Clipboard };\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { ClipboardPlugin, ReadResult, WriteOptions } from './definitions';
|
|
3
|
+
export declare class ClipboardWeb extends WebPlugin implements ClipboardPlugin {
|
|
4
|
+
private static readonly errorContentMissing;
|
|
5
|
+
private static readonly errorEmptyClipboard;
|
|
6
|
+
private static readonly errorReadFailed;
|
|
7
|
+
private static readonly errorRichContentNotSupported;
|
|
8
|
+
private static readonly errorWriteFailed;
|
|
9
|
+
read(): Promise<ReadResult>;
|
|
10
|
+
write(options: WriteOptions): Promise<void>;
|
|
11
|
+
private static convertBlobToDataUrl;
|
|
12
|
+
private static convertDataUrlToBlob;
|
|
13
|
+
private static createException;
|
|
14
|
+
private static resolveTextType;
|
|
15
|
+
private static writeRichContent;
|
|
16
|
+
}
|