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

Update web-sys & wasm-bindgen (#4980)

This PR updates web-sys & wasm to the newest version.

(this was already part of the POC #4954 )

* Closes <https://github.com/emilk/egui/issues/4961>
* Closes <https://github.com/emilk/egui/issues/4958>
* [x] I have followed the instructions in the PR template
This commit is contained in:
Nicolas
2024-08-26 11:38:30 +02:00
committed by GitHub
parent e9522cf765
commit 560b2989a7
7 changed files with 28 additions and 36 deletions

View File

@@ -171,23 +171,14 @@ fn set_cursor_icon(cursor: egui::CursorIcon) -> Option<()> {
#[cfg(web_sys_unstable_apis)]
fn set_clipboard_text(s: &str) {
if let Some(window) = web_sys::window() {
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 {
log::error!("Copy/cut action failed: {}", string_from_js_value(&err));
}
};
wasm_bindgen_futures::spawn_local(future);
} else {
let is_secure_context = window.is_secure_context();
if is_secure_context {
log::warn!("window.navigator.clipboard is null; can't copy text");
} else {
log::warn!("window.navigator.clipboard is null; can't copy text, probably because we're not in a secure context. See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts");
let promise = window.navigator().clipboard().write_text(s);
let future = wasm_bindgen_futures::JsFuture::from(promise);
let future = async move {
if let Err(err) = future.await {
log::error!("Copy/cut action failed: {}", string_from_js_value(&err));
}
}
};
wasm_bindgen_futures::spawn_local(future);
}
}