diff options
author | foxfire52 <foxfire52@virgilio.it> | 2024-10-26 13:26:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-26 13:26:04 +0200 |
commit | 75e9a237261f7175e5add7d8ee1f81f35e095224 (patch) | |
tree | afa19aa0a18e1d26b67f9e9514789bf6177c7d84 /g4f/gui/client/static/js | |
parent | Clean up chat.v1.js (diff) | |
download | gpt4free-75e9a237261f7175e5add7d8ee1f81f35e095224.tar gpt4free-75e9a237261f7175e5add7d8ee1f81f35e095224.tar.gz gpt4free-75e9a237261f7175e5add7d8ee1f81f35e095224.tar.bz2 gpt4free-75e9a237261f7175e5add7d8ee1f81f35e095224.tar.lz gpt4free-75e9a237261f7175e5add7d8ee1f81f35e095224.tar.xz gpt4free-75e9a237261f7175e5add7d8ee1f81f35e095224.tar.zst gpt4free-75e9a237261f7175e5add7d8ee1f81f35e095224.zip |
Diffstat (limited to '')
-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); |