1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! WASM-specific in-process clipboard buffer.
//!
//! Because `arboard` (the native clipboard crate) does not work in a browser
//! context, WASM clipboard operations use a thread-local `String` as the
//! in-process buffer. The JS harness in `demo-wasm` bridges this buffer to
//! the browser's system clipboard:
//!
//! * **Copy / Cut**: the Rust `clipboard_set` stub writes selected text here;
//! the JS `copy`/`cut` DOM event handler reads it via `wasm_clipboard_get()`
//! and places it in `event.clipboardData`, which lands in the system clipboard.
//!
//! * **Paste**: the JS `paste` DOM event handler reads the system clipboard text
//! from `event.clipboardData` and writes it here via `wasm_clipboard_set()`;
//! it then synthesises a Ctrl+V key event so Rust's paste handler picks it up.
//!
//! This module is compiled only when `target_arch = "wasm32"`.
use RefCell;
thread_local!
/// Read the current clipboard buffer. Returns `None` when the buffer is empty.
/// Read the current HTML clipboard buffer. Returns `None` when empty.
/// Overwrite the clipboard buffer with `text`.
/// Overwrite the clipboard buffers with plain text and rendered HTML.