Skip to content

Commit

Permalink
Update assets/js/app.js
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
kainlite and coderabbitai[bot] authored Sep 30, 2024
1 parent 0f9309e commit 2e23449
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,23 @@ Hooks.CopyToClipboard = {
let code = block.querySelector("code");
let text = code.innerText;

await navigator.clipboard.writeText(text);

// visual feedback that task is completed
button.innerText = "Code Copied";

setTimeout(() => {
button.innerText = copyButtonLabel;
}, 700);
try {
await navigator.clipboard.writeText(text);

// visual feedback that task is completed
button.innerText = "Code Copied";

setTimeout(() => {
button.innerText = copyButtonLabel;
}, 700);
} catch (err) {
console.error('Failed to copy text: ', err);
button.innerText = "Copy failed";

setTimeout(() => {
button.innerText = copyButtonLabel;
}, 700);
}
}
},
};
Expand Down

0 comments on commit 2e23449

Please sign in to comment.