@tauri-apps/plugin-clipboard-manager 2.0.0-beta.0 → 2.0.0-beta.2

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
@@ -4,7 +4,7 @@ Read and write to the system clipboard.
4
4
 
5
5
  ## Install
6
6
 
7
- _This plugin requires a Rust version of at least **1.70**_
7
+ _This plugin requires a Rust version of at least **1.75**_
8
8
 
9
9
  There are three general methods of installation that we can recommend.
10
10
 
@@ -60,7 +60,7 @@ fn main() {
60
60
  Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
61
61
 
62
62
  ```javascript
63
- import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager";
63
+ import { writeText, readText, writeHtml, readHtml, clear } from "@tauri-apps/plugin-clipboard-manager";
64
64
  await writeText("Tauri is awesome!");
65
65
  assert(await readText(), "Tauri is awesome!");
66
66
  ```
package/dist-js/index.cjs CHANGED
@@ -46,6 +46,45 @@ async function readText() {
46
46
  const kind = await core.invoke("plugin:clipboard-manager|read");
47
47
  return kind.plainText.text;
48
48
  }
49
+ /**
50
+ * Writes HTML or fallbacks to write provided plain text to the clipboard.
51
+ * @example
52
+ * ```typescript
53
+ * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
54
+ * await writeHtml('<h1>Tauri is awesome!</h1>', 'plaintext');
55
+ * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>'); // Will write "<h1>Tauri is awesome</h1>" as plain text
56
+ * assert(await readText(), '<h1>Tauri is awesome!</h1>');
57
+ * ```
58
+ *
59
+ * @returns A promise indicating the success or failure of the operation.
60
+ *
61
+ * @since 2.0.0
62
+ */
63
+ async function writeHtml(html, altHtml) {
64
+ return core.invoke("plugin:clipboard-manager|write_html", {
65
+ data: {
66
+ html: {
67
+ html,
68
+ altHtml,
69
+ },
70
+ },
71
+ });
72
+ }
73
+ /**
74
+ * Clears the clipboard.
75
+ * @example
76
+ * ```typescript
77
+ * import { clear } from '@tauri-apps/plugin-clipboard-manager';
78
+ * await clear();
79
+ * ```
80
+ * @since 2.0.0
81
+ */
82
+ async function clear() {
83
+ await core.invoke("plugin:clipboard-manager|clear");
84
+ return;
85
+ }
49
86
 
87
+ exports.clear = clear;
50
88
  exports.readText = readText;
89
+ exports.writeHtml = writeHtml;
51
90
  exports.writeText = writeText;
@@ -24,4 +24,29 @@ declare function writeText(text: string, opts?: {
24
24
  * @since 2.0.0
25
25
  */
26
26
  declare function readText(): Promise<string>;
27
- export { writeText, readText };
27
+ /**
28
+ * Writes HTML or fallbacks to write provided plain text to the clipboard.
29
+ * @example
30
+ * ```typescript
31
+ * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
32
+ * await writeHtml('<h1>Tauri is awesome!</h1>', 'plaintext');
33
+ * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>'); // Will write "<h1>Tauri is awesome</h1>" as plain text
34
+ * assert(await readText(), '<h1>Tauri is awesome!</h1>');
35
+ * ```
36
+ *
37
+ * @returns A promise indicating the success or failure of the operation.
38
+ *
39
+ * @since 2.0.0
40
+ */
41
+ declare function writeHtml(html: string, altHtml?: string): Promise<void>;
42
+ /**
43
+ * Clears the clipboard.
44
+ * @example
45
+ * ```typescript
46
+ * import { clear } from '@tauri-apps/plugin-clipboard-manager';
47
+ * await clear();
48
+ * ```
49
+ * @since 2.0.0
50
+ */
51
+ declare function clear(): Promise<void>;
52
+ export { writeText, readText, writeHtml, clear };
package/dist-js/index.js CHANGED
@@ -44,5 +44,42 @@ async function readText() {
44
44
  const kind = await invoke("plugin:clipboard-manager|read");
45
45
  return kind.plainText.text;
46
46
  }
47
+ /**
48
+ * Writes HTML or fallbacks to write provided plain text to the clipboard.
49
+ * @example
50
+ * ```typescript
51
+ * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
52
+ * await writeHtml('<h1>Tauri is awesome!</h1>', 'plaintext');
53
+ * await writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>'); // Will write "<h1>Tauri is awesome</h1>" as plain text
54
+ * assert(await readText(), '<h1>Tauri is awesome!</h1>');
55
+ * ```
56
+ *
57
+ * @returns A promise indicating the success or failure of the operation.
58
+ *
59
+ * @since 2.0.0
60
+ */
61
+ async function writeHtml(html, altHtml) {
62
+ return invoke("plugin:clipboard-manager|write_html", {
63
+ data: {
64
+ html: {
65
+ html,
66
+ altHtml,
67
+ },
68
+ },
69
+ });
70
+ }
71
+ /**
72
+ * Clears the clipboard.
73
+ * @example
74
+ * ```typescript
75
+ * import { clear } from '@tauri-apps/plugin-clipboard-manager';
76
+ * await clear();
77
+ * ```
78
+ * @since 2.0.0
79
+ */
80
+ async function clear() {
81
+ await invoke("plugin:clipboard-manager|clear");
82
+ return;
83
+ }
47
84
 
48
- export { readText, writeText };
85
+ export { clear, readText, writeHtml, writeText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-clipboard-manager",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.2",
4
4
  "license": "MIT or APACHE-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
@@ -20,7 +20,7 @@
20
20
  "LICENSE"
21
21
  ],
22
22
  "dependencies": {
23
- "@tauri-apps/api": "2.0.0-beta.0"
23
+ "@tauri-apps/api": "2.0.0-beta.4"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "rollup -c"