From 75e9a237261f7175e5add7d8ee1f81f35e095224 Mon Sep 17 00:00:00 2001 From: foxfire52 Date: Sat, 26 Oct 2024 13:26:04 +0200 Subject: Update highlightjs-copy.min.js --- g4f/gui/client/static/js/highlightjs-copy.min.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'g4f/gui/client/static/js/highlightjs-copy.min.js') diff --git a/g4f/gui/client/static/js/highlightjs-copy.min.js b/g4f/gui/client/static/js/highlightjs-copy.min.js index 0c3c1cee..cd8ae957 100644 --- a/g4f/gui/client/static/js/highlightjs-copy.min.js +++ b/g4f/gui/client/static/js/highlightjs-copy.min.js @@ -16,16 +16,14 @@ class CopyButtonPlugin { el.parentElement.appendChild(button); el.parentElement.style.setProperty("--hljs-theme-background", window.getComputedStyle(el).backgroundColor); button.onclick = async () => { - if (!navigator.clipboard) { - console.error("navigator.clipboard: Clipboard API unavailable.") - return; - } let newText = text; if (hook && typeof hook === "function") { newText = hook(text, el) || text } - - try { + try { + if (!navigator.clipboard) { + throw new Error("navigator.clipboard: Clipboard API unavailable."); + } await navigator.clipboard.writeText(newText); } catch (e) { console.error(e); -- cgit v1.2.3