@tauri-apps/plugin-clipboard-manager 2.1.0-beta.5 → 2.2.0
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/README.md +20 -6
- package/dist-js/index.cjs +32 -11
- package/dist-js/index.d.ts +24 -3
- package/dist-js/index.js +32 -11
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Read and write to the system clipboard.
|
|
4
4
|
|
|
5
|
+
| Platform | Supported |
|
|
6
|
+
| -------- | --------- |
|
|
7
|
+
| Linux | ✓ |
|
|
8
|
+
| Windows | ✓ |
|
|
9
|
+
| macOS | ✓ |
|
|
10
|
+
| Android | ✓ |
|
|
11
|
+
| iOS | ✓ |
|
|
12
|
+
|
|
5
13
|
## Install
|
|
6
14
|
|
|
7
|
-
_This plugin requires a Rust version of at least **1.
|
|
15
|
+
_This plugin requires a Rust version of at least **1.77.2**_
|
|
8
16
|
|
|
9
17
|
There are three general methods of installation that we can recommend.
|
|
10
18
|
|
|
@@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file:
|
|
|
18
26
|
|
|
19
27
|
```toml
|
|
20
28
|
[dependencies]
|
|
21
|
-
tauri-plugin-clipboard-manager = "2.0.0
|
|
29
|
+
tauri-plugin-clipboard-manager = "2.0.0"
|
|
22
30
|
# alternatively with Git:
|
|
23
31
|
tauri-plugin-clipboard-manager = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
|
24
32
|
```
|
|
@@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-clipboard-manager#v2
|
|
|
46
54
|
|
|
47
55
|
First you need to register the core plugin with Tauri:
|
|
48
56
|
|
|
49
|
-
`src-tauri/src/
|
|
57
|
+
`src-tauri/src/lib.rs`
|
|
50
58
|
|
|
51
59
|
```rust
|
|
52
60
|
fn main() {
|
|
@@ -60,9 +68,15 @@ fn main() {
|
|
|
60
68
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
|
61
69
|
|
|
62
70
|
```javascript
|
|
63
|
-
import {
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
import {
|
|
72
|
+
writeText,
|
|
73
|
+
readText,
|
|
74
|
+
writeHtml,
|
|
75
|
+
readHtml,
|
|
76
|
+
clear
|
|
77
|
+
} from '@tauri-apps/plugin-clipboard-manager'
|
|
78
|
+
await writeText('Tauri is awesome!')
|
|
79
|
+
assert(await readText(), 'Tauri is awesome!')
|
|
66
80
|
```
|
|
67
81
|
|
|
68
82
|
## Contributing
|
package/dist-js/index.cjs
CHANGED
|
@@ -25,9 +25,9 @@ var image = require('@tauri-apps/api/image');
|
|
|
25
25
|
* @since 2.0.0
|
|
26
26
|
*/
|
|
27
27
|
async function writeText(text, opts) {
|
|
28
|
-
await core.invoke(
|
|
28
|
+
await core.invoke('plugin:clipboard-manager|write_text', {
|
|
29
29
|
label: opts?.label,
|
|
30
|
-
text
|
|
30
|
+
text
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -40,10 +40,15 @@ async function writeText(text, opts) {
|
|
|
40
40
|
* @since 2.0.0
|
|
41
41
|
*/
|
|
42
42
|
async function readText() {
|
|
43
|
-
return await core.invoke(
|
|
43
|
+
return await core.invoke('plugin:clipboard-manager|read_text');
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Writes image buffer to the clipboard.
|
|
47
|
+
*
|
|
48
|
+
* #### Platform-specific
|
|
49
|
+
*
|
|
50
|
+
* - **Android / iOS:** Not supported.
|
|
51
|
+
*
|
|
47
52
|
* @example
|
|
48
53
|
* ```typescript
|
|
49
54
|
* import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -55,33 +60,44 @@ async function readText() {
|
|
|
55
60
|
* 0, 255, 0, 255,
|
|
56
61
|
* ];
|
|
57
62
|
* await writeImage(buffer);
|
|
63
|
+
* ```
|
|
58
64
|
*
|
|
59
65
|
* @returns A promise indicating the success or failure of the operation.
|
|
60
66
|
*
|
|
61
67
|
* @since 2.0.0
|
|
62
68
|
*/
|
|
63
69
|
async function writeImage(image$1) {
|
|
64
|
-
await core.invoke(
|
|
65
|
-
image: image.transformImage(image$1)
|
|
70
|
+
await core.invoke('plugin:clipboard-manager|write_image', {
|
|
71
|
+
image: image.transformImage(image$1)
|
|
66
72
|
});
|
|
67
73
|
}
|
|
68
74
|
/**
|
|
69
75
|
* Gets the clipboard content as Uint8Array image.
|
|
76
|
+
*
|
|
77
|
+
* #### Platform-specific
|
|
78
|
+
*
|
|
79
|
+
* - **Android / iOS:** Not supported.
|
|
80
|
+
*
|
|
70
81
|
* @example
|
|
71
82
|
* ```typescript
|
|
72
83
|
* import { readImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
73
84
|
*
|
|
74
85
|
* const clipboardImage = await readImage();
|
|
75
|
-
* const blob = new Blob([clipboardImage.
|
|
86
|
+
* const blob = new Blob([await clipboardImage.rbga()], { type: 'image' })
|
|
76
87
|
* const url = URL.createObjectURL(blob)
|
|
77
88
|
* ```
|
|
78
89
|
* @since 2.0.0
|
|
79
90
|
*/
|
|
80
91
|
async function readImage() {
|
|
81
|
-
return await core.invoke(
|
|
92
|
+
return await core.invoke('plugin:clipboard-manager|read_image').then((rid) => new image.Image(rid));
|
|
82
93
|
}
|
|
83
94
|
/**
|
|
84
95
|
* * Writes HTML or fallbacks to write provided plain text to the clipboard.
|
|
96
|
+
*
|
|
97
|
+
* #### Platform-specific
|
|
98
|
+
*
|
|
99
|
+
* - **Android / iOS:** Not supported.
|
|
100
|
+
*
|
|
85
101
|
* @example
|
|
86
102
|
* ```typescript
|
|
87
103
|
* import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -94,14 +110,19 @@ async function readImage() {
|
|
|
94
110
|
*
|
|
95
111
|
* @since 2.0.0
|
|
96
112
|
*/
|
|
97
|
-
async function writeHtml(html,
|
|
98
|
-
await core.invoke(
|
|
113
|
+
async function writeHtml(html, altText) {
|
|
114
|
+
await core.invoke('plugin:clipboard-manager|write_html', {
|
|
99
115
|
html,
|
|
100
|
-
|
|
116
|
+
altText
|
|
101
117
|
});
|
|
102
118
|
}
|
|
103
119
|
/**
|
|
104
120
|
* Clears the clipboard.
|
|
121
|
+
*
|
|
122
|
+
* #### Platform-specific
|
|
123
|
+
*
|
|
124
|
+
* - **Android:** Only supported on SDK 28+. For older releases we write an empty string to the clipboard instead.
|
|
125
|
+
*
|
|
105
126
|
* @example
|
|
106
127
|
* ```typescript
|
|
107
128
|
* import { clear } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -110,7 +131,7 @@ async function writeHtml(html, altHtml) {
|
|
|
110
131
|
* @since 2.0.0
|
|
111
132
|
*/
|
|
112
133
|
async function clear() {
|
|
113
|
-
await core.invoke(
|
|
134
|
+
await core.invoke('plugin:clipboard-manager|clear');
|
|
114
135
|
}
|
|
115
136
|
|
|
116
137
|
exports.clear = clear;
|
package/dist-js/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Image } from
|
|
1
|
+
import { Image } from '@tauri-apps/api/image';
|
|
2
2
|
/**
|
|
3
3
|
* Writes plain text to the clipboard.
|
|
4
4
|
* @example
|
|
@@ -27,6 +27,11 @@ declare function writeText(text: string, opts?: {
|
|
|
27
27
|
declare function readText(): Promise<string>;
|
|
28
28
|
/**
|
|
29
29
|
* Writes image buffer to the clipboard.
|
|
30
|
+
*
|
|
31
|
+
* #### Platform-specific
|
|
32
|
+
*
|
|
33
|
+
* - **Android / iOS:** Not supported.
|
|
34
|
+
*
|
|
30
35
|
* @example
|
|
31
36
|
* ```typescript
|
|
32
37
|
* import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -38,6 +43,7 @@ declare function readText(): Promise<string>;
|
|
|
38
43
|
* 0, 255, 0, 255,
|
|
39
44
|
* ];
|
|
40
45
|
* await writeImage(buffer);
|
|
46
|
+
* ```
|
|
41
47
|
*
|
|
42
48
|
* @returns A promise indicating the success or failure of the operation.
|
|
43
49
|
*
|
|
@@ -46,12 +52,17 @@ declare function readText(): Promise<string>;
|
|
|
46
52
|
declare function writeImage(image: string | Image | Uint8Array | ArrayBuffer | number[]): Promise<void>;
|
|
47
53
|
/**
|
|
48
54
|
* Gets the clipboard content as Uint8Array image.
|
|
55
|
+
*
|
|
56
|
+
* #### Platform-specific
|
|
57
|
+
*
|
|
58
|
+
* - **Android / iOS:** Not supported.
|
|
59
|
+
*
|
|
49
60
|
* @example
|
|
50
61
|
* ```typescript
|
|
51
62
|
* import { readImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
52
63
|
*
|
|
53
64
|
* const clipboardImage = await readImage();
|
|
54
|
-
* const blob = new Blob([clipboardImage.
|
|
65
|
+
* const blob = new Blob([await clipboardImage.rbga()], { type: 'image' })
|
|
55
66
|
* const url = URL.createObjectURL(blob)
|
|
56
67
|
* ```
|
|
57
68
|
* @since 2.0.0
|
|
@@ -59,6 +70,11 @@ declare function writeImage(image: string | Image | Uint8Array | ArrayBuffer | n
|
|
|
59
70
|
declare function readImage(): Promise<Image>;
|
|
60
71
|
/**
|
|
61
72
|
* * Writes HTML or fallbacks to write provided plain text to the clipboard.
|
|
73
|
+
*
|
|
74
|
+
* #### Platform-specific
|
|
75
|
+
*
|
|
76
|
+
* - **Android / iOS:** Not supported.
|
|
77
|
+
*
|
|
62
78
|
* @example
|
|
63
79
|
* ```typescript
|
|
64
80
|
* import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -71,9 +87,14 @@ declare function readImage(): Promise<Image>;
|
|
|
71
87
|
*
|
|
72
88
|
* @since 2.0.0
|
|
73
89
|
*/
|
|
74
|
-
declare function writeHtml(html: string,
|
|
90
|
+
declare function writeHtml(html: string, altText?: string): Promise<void>;
|
|
75
91
|
/**
|
|
76
92
|
* Clears the clipboard.
|
|
93
|
+
*
|
|
94
|
+
* #### Platform-specific
|
|
95
|
+
*
|
|
96
|
+
* - **Android:** Only supported on SDK 28+. For older releases we write an empty string to the clipboard instead.
|
|
97
|
+
*
|
|
77
98
|
* @example
|
|
78
99
|
* ```typescript
|
|
79
100
|
* import { clear } from '@tauri-apps/plugin-clipboard-manager';
|
package/dist-js/index.js
CHANGED
|
@@ -23,9 +23,9 @@ import { transformImage, Image } from '@tauri-apps/api/image';
|
|
|
23
23
|
* @since 2.0.0
|
|
24
24
|
*/
|
|
25
25
|
async function writeText(text, opts) {
|
|
26
|
-
await invoke(
|
|
26
|
+
await invoke('plugin:clipboard-manager|write_text', {
|
|
27
27
|
label: opts?.label,
|
|
28
|
-
text
|
|
28
|
+
text
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -38,10 +38,15 @@ async function writeText(text, opts) {
|
|
|
38
38
|
* @since 2.0.0
|
|
39
39
|
*/
|
|
40
40
|
async function readText() {
|
|
41
|
-
return await invoke(
|
|
41
|
+
return await invoke('plugin:clipboard-manager|read_text');
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Writes image buffer to the clipboard.
|
|
45
|
+
*
|
|
46
|
+
* #### Platform-specific
|
|
47
|
+
*
|
|
48
|
+
* - **Android / iOS:** Not supported.
|
|
49
|
+
*
|
|
45
50
|
* @example
|
|
46
51
|
* ```typescript
|
|
47
52
|
* import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -53,33 +58,44 @@ async function readText() {
|
|
|
53
58
|
* 0, 255, 0, 255,
|
|
54
59
|
* ];
|
|
55
60
|
* await writeImage(buffer);
|
|
61
|
+
* ```
|
|
56
62
|
*
|
|
57
63
|
* @returns A promise indicating the success or failure of the operation.
|
|
58
64
|
*
|
|
59
65
|
* @since 2.0.0
|
|
60
66
|
*/
|
|
61
67
|
async function writeImage(image) {
|
|
62
|
-
await invoke(
|
|
63
|
-
image: transformImage(image)
|
|
68
|
+
await invoke('plugin:clipboard-manager|write_image', {
|
|
69
|
+
image: transformImage(image)
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
73
|
* Gets the clipboard content as Uint8Array image.
|
|
74
|
+
*
|
|
75
|
+
* #### Platform-specific
|
|
76
|
+
*
|
|
77
|
+
* - **Android / iOS:** Not supported.
|
|
78
|
+
*
|
|
68
79
|
* @example
|
|
69
80
|
* ```typescript
|
|
70
81
|
* import { readImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
71
82
|
*
|
|
72
83
|
* const clipboardImage = await readImage();
|
|
73
|
-
* const blob = new Blob([clipboardImage.
|
|
84
|
+
* const blob = new Blob([await clipboardImage.rbga()], { type: 'image' })
|
|
74
85
|
* const url = URL.createObjectURL(blob)
|
|
75
86
|
* ```
|
|
76
87
|
* @since 2.0.0
|
|
77
88
|
*/
|
|
78
89
|
async function readImage() {
|
|
79
|
-
return await invoke(
|
|
90
|
+
return await invoke('plugin:clipboard-manager|read_image').then((rid) => new Image(rid));
|
|
80
91
|
}
|
|
81
92
|
/**
|
|
82
93
|
* * Writes HTML or fallbacks to write provided plain text to the clipboard.
|
|
94
|
+
*
|
|
95
|
+
* #### Platform-specific
|
|
96
|
+
*
|
|
97
|
+
* - **Android / iOS:** Not supported.
|
|
98
|
+
*
|
|
83
99
|
* @example
|
|
84
100
|
* ```typescript
|
|
85
101
|
* import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -92,14 +108,19 @@ async function readImage() {
|
|
|
92
108
|
*
|
|
93
109
|
* @since 2.0.0
|
|
94
110
|
*/
|
|
95
|
-
async function writeHtml(html,
|
|
96
|
-
await invoke(
|
|
111
|
+
async function writeHtml(html, altText) {
|
|
112
|
+
await invoke('plugin:clipboard-manager|write_html', {
|
|
97
113
|
html,
|
|
98
|
-
|
|
114
|
+
altText
|
|
99
115
|
});
|
|
100
116
|
}
|
|
101
117
|
/**
|
|
102
118
|
* Clears the clipboard.
|
|
119
|
+
*
|
|
120
|
+
* #### Platform-specific
|
|
121
|
+
*
|
|
122
|
+
* - **Android:** Only supported on SDK 28+. For older releases we write an empty string to the clipboard instead.
|
|
123
|
+
*
|
|
103
124
|
* @example
|
|
104
125
|
* ```typescript
|
|
105
126
|
* import { clear } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -108,7 +129,7 @@ async function writeHtml(html, altHtml) {
|
|
|
108
129
|
* @since 2.0.0
|
|
109
130
|
*/
|
|
110
131
|
async function clear() {
|
|
111
|
-
await invoke(
|
|
132
|
+
await invoke('plugin:clipboard-manager|clear');
|
|
112
133
|
}
|
|
113
134
|
|
|
114
135
|
export { clear, readImage, readText, writeHtml, writeImage, writeText };
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-clipboard-manager",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"license": "MIT
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"license": "MIT OR Apache-2.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Tauri Programme within The Commons Conservancy"
|
|
7
7
|
],
|
|
8
|
+
"repository": "https://github.com/tauri-apps/plugins-workspace",
|
|
8
9
|
"type": "module",
|
|
9
10
|
"types": "./dist-js/index.d.ts",
|
|
10
11
|
"main": "./dist-js/index.cjs",
|
|
@@ -14,15 +15,15 @@
|
|
|
14
15
|
"import": "./dist-js/index.js",
|
|
15
16
|
"require": "./dist-js/index.cjs"
|
|
16
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rollup -c"
|
|
20
|
+
},
|
|
17
21
|
"files": [
|
|
18
22
|
"dist-js",
|
|
19
23
|
"README.md",
|
|
20
24
|
"LICENSE"
|
|
21
25
|
],
|
|
22
26
|
"dependencies": {
|
|
23
|
-
"@tauri-apps/api": "2.0.0
|
|
24
|
-
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "rollup -c"
|
|
27
|
+
"@tauri-apps/api": "^2.0.0"
|
|
27
28
|
}
|
|
28
|
-
}
|
|
29
|
+
}
|