From 13c350e2b5584a0e99cbe0785a2dc717a015adf4 Mon Sep 17 00:00:00 2001 From: surinder singh Date: Sat, 14 Sep 2024 04:45:02 +0530 Subject: [PATCH] web-sys 0.3.70 support --- crates/eframe/src/web/mod.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/crates/eframe/src/web/mod.rs b/crates/eframe/src/web/mod.rs index 07339d7e081..bd9c306c386 100644 --- a/crates/eframe/src/web/mod.rs +++ b/crates/eframe/src/web/mod.rs @@ -184,23 +184,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); } }