Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: clipboard rust guide #1475 #1622

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/content/docs/features/clipboard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Install the clipboard plugin to get started.
}
```



</TabItem>
<TabItem label="Manual">

Expand Down Expand Up @@ -84,10 +86,10 @@ The clipboard plugin is available in both JavaScript and Rust.
```js
import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';

// Write text to the clipboard
// Write content to clipboard
await writeText('Tauri is awesome!');

// Read text from the clipboard
// Read content from clipboard
const content = await readText();
console.log(content);
// Prints "Tauri is awesome!" to the console
Expand All @@ -96,9 +98,23 @@ console.log(content);
</TabItem>
<TabItem label="Rust">

{/* TODO: */}
```rust
use tauri_plugin_clipboard_manager::ClipboardExt;

// Write content to clipboard
let clipboard_content = tauri_plugin_clipboard_manager::ClipKind::PlainText {
label: Some("Label".to_string()),
text: "Tauri is awesome!".to_string(),
};
app.clipboard().write(clipboard_content).unwrap();

<Stub />
// Read content from clipboard
let content = app.clipboard().read();
println!("{:?}", content.unwrap());
// Prints "Tauri is awesome!" to the terminal


```

</TabItem>
</Tabs>