summaryrefslogtreecommitdiffstats
path: root/g4f/gui
diff options
context:
space:
mode:
authorfoxfire52 <foxfire52@virgilio.it>2024-10-26 13:26:04 +0200
committerGitHub <noreply@github.com>2024-10-26 13:26:04 +0200
commit75e9a237261f7175e5add7d8ee1f81f35e095224 (patch)
treeafa19aa0a18e1d26b67f9e9514789bf6177c7d84 /g4f/gui
parentClean up chat.v1.js (diff)
downloadgpt4free-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 'g4f/gui')
-rw-r--r--g4f/gui/client/static/js/highlightjs-copy.min.js10
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);