@tauri-apps/plugin-clipboard-manager 2.0.0-beta.2 → 2.1.0-beta.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/dist-js/index.cjs +48 -3
- package/dist-js/index.d.ts +35 -2
- package/dist-js/index.js +47 -4
- package/package.json +2 -2
package/dist-js/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@tauri-apps/api/core');
|
|
4
|
+
var image = require('@tauri-apps/api/image');
|
|
4
5
|
|
|
5
6
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
6
7
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -24,7 +25,7 @@ var core = require('@tauri-apps/api/core');
|
|
|
24
25
|
* @since 2.0.0
|
|
25
26
|
*/
|
|
26
27
|
async function writeText(text, opts) {
|
|
27
|
-
return core.invoke("plugin:clipboard-manager|
|
|
28
|
+
return core.invoke("plugin:clipboard-manager|write_text", {
|
|
28
29
|
data: {
|
|
29
30
|
plainText: {
|
|
30
31
|
label: opts?.label,
|
|
@@ -43,11 +44,53 @@ async function writeText(text, opts) {
|
|
|
43
44
|
* @since 2.0.0
|
|
44
45
|
*/
|
|
45
46
|
async function readText() {
|
|
46
|
-
const kind = await core.invoke("plugin:clipboard-manager|
|
|
47
|
+
const kind = await core.invoke("plugin:clipboard-manager|read_text");
|
|
47
48
|
return kind.plainText.text;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
+
* Gets the clipboard content as Uint8Array image.
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { readImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
55
|
+
*
|
|
56
|
+
* const clipboardImage = await readImage();
|
|
57
|
+
* const blob = new Blob([clipboardImage.bytes], { type: 'image' })
|
|
58
|
+
* const url = URL.createObjectURL(blob)
|
|
59
|
+
* ```
|
|
60
|
+
* @since 2.0.0
|
|
61
|
+
*/
|
|
62
|
+
async function readImage() {
|
|
63
|
+
return await core.invoke("plugin:clipboard-manager|read_image").then((rid) => new image.Image(rid));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Writes image buffer to the clipboard.
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
70
|
+
* const buffer = [
|
|
71
|
+
* // A red pixel
|
|
72
|
+
* 255, 0, 0, 255,
|
|
73
|
+
*
|
|
74
|
+
* // A green pixel
|
|
75
|
+
* 0, 255, 0, 255,
|
|
76
|
+
* ];
|
|
77
|
+
* await writeImage(buffer);
|
|
78
|
+
*
|
|
79
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
80
|
+
*
|
|
81
|
+
* @since 2.0.0
|
|
82
|
+
*/
|
|
83
|
+
async function writeImage(image$1) {
|
|
84
|
+
return core.invoke("plugin:clipboard-manager|write_image", {
|
|
85
|
+
data: {
|
|
86
|
+
image: {
|
|
87
|
+
image: image.transformImage(image$1),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* * Writes HTML or fallbacks to write provided plain text to the clipboard.
|
|
51
94
|
* @example
|
|
52
95
|
* ```typescript
|
|
53
96
|
* import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -85,6 +128,8 @@ async function clear() {
|
|
|
85
128
|
}
|
|
86
129
|
|
|
87
130
|
exports.clear = clear;
|
|
131
|
+
exports.readImage = readImage;
|
|
88
132
|
exports.readText = readText;
|
|
89
133
|
exports.writeHtml = writeHtml;
|
|
134
|
+
exports.writeImage = writeImage;
|
|
90
135
|
exports.writeText = writeText;
|
package/dist-js/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Image } from "@tauri-apps/api/image";
|
|
1
2
|
/**
|
|
2
3
|
* Writes plain text to the clipboard.
|
|
3
4
|
* @example
|
|
@@ -25,7 +26,39 @@ declare function writeText(text: string, opts?: {
|
|
|
25
26
|
*/
|
|
26
27
|
declare function readText(): Promise<string>;
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* Gets the clipboard content as Uint8Array image.
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { readImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
33
|
+
*
|
|
34
|
+
* const clipboardImage = await readImage();
|
|
35
|
+
* const blob = new Blob([clipboardImage.bytes], { type: 'image' })
|
|
36
|
+
* const url = URL.createObjectURL(blob)
|
|
37
|
+
* ```
|
|
38
|
+
* @since 2.0.0
|
|
39
|
+
*/
|
|
40
|
+
declare function readImage(): Promise<Image>;
|
|
41
|
+
/**
|
|
42
|
+
* Writes image buffer to the clipboard.
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
46
|
+
* const buffer = [
|
|
47
|
+
* // A red pixel
|
|
48
|
+
* 255, 0, 0, 255,
|
|
49
|
+
*
|
|
50
|
+
* // A green pixel
|
|
51
|
+
* 0, 255, 0, 255,
|
|
52
|
+
* ];
|
|
53
|
+
* await writeImage(buffer);
|
|
54
|
+
*
|
|
55
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
56
|
+
*
|
|
57
|
+
* @since 2.0.0
|
|
58
|
+
*/
|
|
59
|
+
declare function writeImage(image: string | Image | Uint8Array | ArrayBuffer | number[]): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* * Writes HTML or fallbacks to write provided plain text to the clipboard.
|
|
29
62
|
* @example
|
|
30
63
|
* ```typescript
|
|
31
64
|
* import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -49,4 +82,4 @@ declare function writeHtml(html: string, altHtml?: string): Promise<void>;
|
|
|
49
82
|
* @since 2.0.0
|
|
50
83
|
*/
|
|
51
84
|
declare function clear(): Promise<void>;
|
|
52
|
-
export { writeText, readText, writeHtml, clear };
|
|
85
|
+
export { writeText, readText, writeHtml, clear, readImage, writeImage };
|
package/dist-js/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { invoke } from '@tauri-apps/api/core';
|
|
2
|
+
import { Image, transformImage } from '@tauri-apps/api/image';
|
|
2
3
|
|
|
3
4
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
4
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -22,7 +23,7 @@ import { invoke } from '@tauri-apps/api/core';
|
|
|
22
23
|
* @since 2.0.0
|
|
23
24
|
*/
|
|
24
25
|
async function writeText(text, opts) {
|
|
25
|
-
return invoke("plugin:clipboard-manager|
|
|
26
|
+
return invoke("plugin:clipboard-manager|write_text", {
|
|
26
27
|
data: {
|
|
27
28
|
plainText: {
|
|
28
29
|
label: opts?.label,
|
|
@@ -41,11 +42,53 @@ async function writeText(text, opts) {
|
|
|
41
42
|
* @since 2.0.0
|
|
42
43
|
*/
|
|
43
44
|
async function readText() {
|
|
44
|
-
const kind = await invoke("plugin:clipboard-manager|
|
|
45
|
+
const kind = await invoke("plugin:clipboard-manager|read_text");
|
|
45
46
|
return kind.plainText.text;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
* Gets the clipboard content as Uint8Array image.
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { readImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
53
|
+
*
|
|
54
|
+
* const clipboardImage = await readImage();
|
|
55
|
+
* const blob = new Blob([clipboardImage.bytes], { type: 'image' })
|
|
56
|
+
* const url = URL.createObjectURL(blob)
|
|
57
|
+
* ```
|
|
58
|
+
* @since 2.0.0
|
|
59
|
+
*/
|
|
60
|
+
async function readImage() {
|
|
61
|
+
return await invoke("plugin:clipboard-manager|read_image").then((rid) => new Image(rid));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Writes image buffer to the clipboard.
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
|
|
68
|
+
* const buffer = [
|
|
69
|
+
* // A red pixel
|
|
70
|
+
* 255, 0, 0, 255,
|
|
71
|
+
*
|
|
72
|
+
* // A green pixel
|
|
73
|
+
* 0, 255, 0, 255,
|
|
74
|
+
* ];
|
|
75
|
+
* await writeImage(buffer);
|
|
76
|
+
*
|
|
77
|
+
* @returns A promise indicating the success or failure of the operation.
|
|
78
|
+
*
|
|
79
|
+
* @since 2.0.0
|
|
80
|
+
*/
|
|
81
|
+
async function writeImage(image) {
|
|
82
|
+
return invoke("plugin:clipboard-manager|write_image", {
|
|
83
|
+
data: {
|
|
84
|
+
image: {
|
|
85
|
+
image: transformImage(image),
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* * Writes HTML or fallbacks to write provided plain text to the clipboard.
|
|
49
92
|
* @example
|
|
50
93
|
* ```typescript
|
|
51
94
|
* import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
|
|
@@ -82,4 +125,4 @@ async function clear() {
|
|
|
82
125
|
return;
|
|
83
126
|
}
|
|
84
127
|
|
|
85
|
-
export { clear, readText, writeHtml, writeText };
|
|
128
|
+
export { clear, readImage, readText, writeHtml, writeImage, writeText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-clipboard-manager",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0-beta.0",
|
|
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.
|
|
23
|
+
"@tauri-apps/api": "2.0.0-beta.6"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "rollup -c"
|