diff options
Diffstat (limited to 'g4f/gui/client/static')
-rw-r--r-- | g4f/gui/client/static/js/highlightjs-copy.min.js | 10 |
1 files changed, 4 insertions, 6 deletions
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); |