@tauri-apps/plugin-clipboard-manager 2.1.0-beta.6 → 2.2.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/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.75**_
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-beta"
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/main.rs`
57
+ `src-tauri/src/lib.rs`
50
58
 
51
59
  ```rust
52
60
  fn main() {
@@ -60,9 +68,14 @@ fn main() {
60
68
  Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
61
69
 
62
70
  ```javascript
63
- import { writeText, readText, writeHtml, readHtml, clear } from "@tauri-apps/plugin-clipboard-manager";
64
- await writeText("Tauri is awesome!");
65
- assert(await readText(), "Tauri is awesome!");
71
+ import {
72
+ writeText,
73
+ readText,
74
+ writeHtml,
75
+ clear
76
+ } from '@tauri-apps/plugin-clipboard-manager'
77
+ await writeText('Tauri is awesome!')
78
+ assert(await readText(), 'Tauri is awesome!')
66
79
  ```
67
80
 
68
81
  ## 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("plugin:clipboard-manager|write_text", {
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("plugin:clipboard-manager|read_text");
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,38 +60,51 @@ 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("plugin:clipboard-manager|write_image", {
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.bytes], { type: 'image' })
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("plugin:clipboard-manager|read_image").then((rid) => new image.Image(rid));
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
- * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
103
+ * import { writeHtml } from '@tauri-apps/plugin-clipboard-manager';
88
104
  * await writeHtml('<h1>Tauri is awesome!</h1>', 'plaintext');
89
- * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>'); // Will write "<h1>Tauri is awesome</h1>" as plain text
105
+ * // The following will write "<h1>Tauri is awesome</h1>" as plain text
106
+ * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>');
107
+ * // we can read html data only as a string so there's just readText(), no readHtml()
90
108
  * assert(await readText(), '<h1>Tauri is awesome!</h1>');
91
109
  * ```
92
110
  *
@@ -94,14 +112,19 @@ async function readImage() {
94
112
  *
95
113
  * @since 2.0.0
96
114
  */
97
- async function writeHtml(html, altHtml) {
98
- await core.invoke("plugin:clipboard-manager|write_html", {
115
+ async function writeHtml(html, altText) {
116
+ await core.invoke('plugin:clipboard-manager|write_html', {
99
117
  html,
100
- altHtml,
118
+ altText
101
119
  });
102
120
  }
103
121
  /**
104
122
  * Clears the clipboard.
123
+ *
124
+ * #### Platform-specific
125
+ *
126
+ * - **Android:** Only supported on SDK 28+. For older releases we write an empty string to the clipboard instead.
127
+ *
105
128
  * @example
106
129
  * ```typescript
107
130
  * import { clear } from '@tauri-apps/plugin-clipboard-manager';
@@ -110,7 +133,7 @@ async function writeHtml(html, altHtml) {
110
133
  * @since 2.0.0
111
134
  */
112
135
  async function clear() {
113
- await core.invoke("plugin:clipboard-manager|clear");
136
+ await core.invoke('plugin:clipboard-manager|clear');
114
137
  }
115
138
 
116
139
  exports.clear = clear;
@@ -1,4 +1,4 @@
1
- import { Image } from "@tauri-apps/api/image";
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.bytes], { type: 'image' })
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,11 +70,18 @@ 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
- * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
80
+ * import { writeHtml } from '@tauri-apps/plugin-clipboard-manager';
65
81
  * await writeHtml('<h1>Tauri is awesome!</h1>', 'plaintext');
66
- * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>'); // Will write "<h1>Tauri is awesome</h1>" as plain text
82
+ * // The following will write "<h1>Tauri is awesome</h1>" as plain text
83
+ * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>');
84
+ * // we can read html data only as a string so there's just readText(), no readHtml()
67
85
  * assert(await readText(), '<h1>Tauri is awesome!</h1>');
68
86
  * ```
69
87
  *
@@ -71,9 +89,14 @@ declare function readImage(): Promise<Image>;
71
89
  *
72
90
  * @since 2.0.0
73
91
  */
74
- declare function writeHtml(html: string, altHtml?: string): Promise<void>;
92
+ declare function writeHtml(html: string, altText?: string): Promise<void>;
75
93
  /**
76
94
  * Clears the clipboard.
95
+ *
96
+ * #### Platform-specific
97
+ *
98
+ * - **Android:** Only supported on SDK 28+. For older releases we write an empty string to the clipboard instead.
99
+ *
77
100
  * @example
78
101
  * ```typescript
79
102
  * 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("plugin:clipboard-manager|write_text", {
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("plugin:clipboard-manager|read_text");
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,38 +58,51 @@ 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("plugin:clipboard-manager|write_image", {
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.bytes], { type: 'image' })
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("plugin:clipboard-manager|read_image").then((rid) => new Image(rid));
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
- * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
101
+ * import { writeHtml } from '@tauri-apps/plugin-clipboard-manager';
86
102
  * await writeHtml('<h1>Tauri is awesome!</h1>', 'plaintext');
87
- * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>'); // Will write "<h1>Tauri is awesome</h1>" as plain text
103
+ * // The following will write "<h1>Tauri is awesome</h1>" as plain text
104
+ * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>');
105
+ * // we can read html data only as a string so there's just readText(), no readHtml()
88
106
  * assert(await readText(), '<h1>Tauri is awesome!</h1>');
89
107
  * ```
90
108
  *
@@ -92,14 +110,19 @@ async function readImage() {
92
110
  *
93
111
  * @since 2.0.0
94
112
  */
95
- async function writeHtml(html, altHtml) {
96
- await invoke("plugin:clipboard-manager|write_html", {
113
+ async function writeHtml(html, altText) {
114
+ await invoke('plugin:clipboard-manager|write_html', {
97
115
  html,
98
- altHtml,
116
+ altText
99
117
  });
100
118
  }
101
119
  /**
102
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
+ *
103
126
  * @example
104
127
  * ```typescript
105
128
  * import { clear } from '@tauri-apps/plugin-clipboard-manager';
@@ -108,7 +131,7 @@ async function writeHtml(html, altHtml) {
108
131
  * @since 2.0.0
109
132
  */
110
133
  async function clear() {
111
- await invoke("plugin:clipboard-manager|clear");
134
+ await invoke('plugin:clipboard-manager|clear');
112
135
  }
113
136
 
114
137
  export { clear, readImage, readText, writeHtml, writeImage, writeText };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-clipboard-manager",
3
- "version": "2.1.0-beta.6",
4
- "license": "MIT or APACHE-2.0",
3
+ "version": "2.2.1",
4
+ "license": "MIT OR Apache-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
7
7
  ],
@@ -24,6 +24,6 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "dependencies": {
27
- "@tauri-apps/api": "^2.0.0-beta.16"
27
+ "@tauri-apps/api": "^2.0.0"
28
28
  }
29
29
  }