@@ -5,10 +5,100 @@ description: Read and write to the system clipboard.
5
5
6
6
import Stub from ' @components/Stub.astro' ;
7
7
import PluginLinks from ' @components/PluginLinks.astro' ;
8
+ import { Tabs , TabItem } from ' @astrojs/starlight/components' ;
9
+ import CommandTabs from ' @components/CommandTabs.astro' ;
8
10
9
11
<PluginLinks plugin = " clipboard-manager" />
10
12
11
- <Stub >
12
- Based on
13
- https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/clipboard-manager
14
- </Stub >
13
+ Read and write to the system clipboard using the clipboard plugin.
14
+
15
+ ## Setup
16
+
17
+ Install the clipboard plugin to get started.
18
+
19
+ <Tabs >
20
+ <TabItem label = " Automatic" >
21
+
22
+ 1 . Use your project's package manager to add the dependency:
23
+
24
+ <CommandTabs npm = " npm run tauri add clipboard-manager"
25
+ yarn = " yarn run tauri add clipboard-manager"
26
+ pnpm = " pnpm tauri add clipboard-manager"
27
+ cargo = " cargo tauri add clipboard-manager" />
28
+
29
+ 2 . Modify ` lib.rs ` to initialize the plugin:
30
+
31
+ { /* TODO: Revise once https://github.com/tauri-apps/tauri/issues/7696 is in */ }
32
+
33
+ ``` rust
34
+ #[cfg_attr(mobile, tauri:: mobile_entry_point)]
35
+ pub fn run () {
36
+ tauri :: Builder :: default ()
37
+ // Initialize the plugin
38
+ . plugin (tauri_plugin_clipboard_manager :: init ())
39
+ . run (tauri :: generate_context! ())
40
+ . expect (" error while running tauri application" );
41
+ }
42
+ ```
43
+
44
+ </TabItem >
45
+ <TabItem label = " Manual" >
46
+
47
+ 1 . Run ` cargo add tauri-plugin-clipboard-manager ` to add the plugin to the project's dependencies in ` Cargo.toml ` .
48
+
49
+ 2 . Modify ` lib.rs ` to initialize the plugin:
50
+
51
+ ``` rust
52
+ // lib.rs
53
+ #[cfg_attr(mobile, tauri:: mobile_entry_point)]
54
+ pub fn run () {
55
+ tauri :: Builder :: default ()
56
+ // Initialize the plugin
57
+ . plugin (tauri_plugin_clipboard_manager :: init ())
58
+ . run (tauri :: generate_context! ())
59
+ . expect (" error while running tauri application" );
60
+ }
61
+ ```
62
+
63
+ 3 . If you'd like to manage the clipboard in JavaScript then install the npm package as well:
64
+
65
+ <CommandTabs
66
+ npm = " npm install @tauri-apps/plugin-clipboard-manager"
67
+ yarn = " yarn add @tauri-apps/plugin-clipboard-manager"
68
+ pnpm = " pnpm add @tauri-apps/plugin-clipboard-manager"
69
+ />
70
+
71
+ </TabItem >
72
+
73
+ </Tabs >
74
+
75
+ ## Usage
76
+
77
+ { /* TODO: Link to which language to use, frontend vs. backend guide when it's made */ }
78
+
79
+ The clipboard plugin is available in both JavaScript and Rust.
80
+
81
+ <Tabs >
82
+ <TabItem label = " JavaScript" >
83
+
84
+ ``` js
85
+ import { writeText , readText } from ' @tauri-apps/plugin-clipboard-manager' ;
86
+
87
+ // Write text to the clipboard
88
+ await writeText (' Tauri is awesome!' );
89
+
90
+ // Read text from the clipboard
91
+ const content = await readText ()
92
+ console .log (content)
93
+ // Prints "Tauri is awesome!" to the console
94
+ ```
95
+
96
+ </TabItem >
97
+ <TabItem label = " Rust" >
98
+
99
+ { /* TODO: */ }
100
+
101
+ <Stub />
102
+
103
+ </TabItem >
104
+ </Tabs >
0 commit comments