1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

fix and pin web-sys breakage in Navigator::clipboard (#608)

This commit is contained in:
mental
2021-08-15 17:55:33 +03:00
committed by GitHub
parent 34a11fefd2
commit eefc56c213
3 changed files with 203 additions and 172 deletions

View File

@@ -25,7 +25,9 @@ all-features = true
crate-type = ["cdylib", "rlib"]
[dependencies]
egui = { version = "0.13.0", path = "../egui", default-features = false, features = ["single_threaded"] }
egui = { version = "0.13.0", path = "../egui", default-features = false, features = [
"single_threaded",
] }
epi = { version = "0.13.0", path = "../epi" }
js-sys = "0.3"
ron = { version = "0.6", optional = true }
@@ -52,7 +54,7 @@ persistence = ["egui/persistence", "ron", "serde"]
screen_reader = ["tts"] # experimental
[dependencies.web-sys]
version = "0.3"
version = "0.3.52"
features = [
"Clipboard",
"ClipboardEvent",

View File

@@ -349,15 +349,16 @@ pub fn set_cursor_icon(cursor: egui::CursorIcon) -> Option<()> {
#[cfg(web_sys_unstable_apis)]
pub fn set_clipboard_text(s: &str) {
if let Some(window) = web_sys::window() {
let clipboard = window.navigator().clipboard();
let promise = clipboard.write_text(s);
let future = wasm_bindgen_futures::JsFuture::from(promise);
let future = async move {
if let Err(err) = future.await {
console_error(format!("Copy/cut action denied: {:?}", err));
}
};
wasm_bindgen_futures::spawn_local(future);
if let Some(clipboard) = window.navigator().clipboard() {
let promise = clipboard.write_text(s);
let future = wasm_bindgen_futures::JsFuture::from(promise);
let future = async move {
if let Err(err) = future.await {
console_error(format!("Copy/cut action denied: {:?}", err));
}
};
wasm_bindgen_futures::spawn_local(future);
}
}
}