diff options
author | Jimmy Cai <github@jimmycai.com> | 2022-10-29 18:14:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-29 18:14:19 +0300 |
commit | b03390d237427a2b9cfee55949cb1da62f1a6856 (patch) | |
tree | fd7da57cfcebc07d16483f3e9c3d71aee3562138 /assets/ts/codeblock.ts | |
parent | 8a597a5c9c861d2bce22a5e06c7667cd9c8e263a (diff) |
Revert "Merge branch 'canary' into master" (#712)
Revert "Merge branch 'canary' into master (#711)"
This reverts commit 8a597a5c9c861d2bce22a5e06c7667cd9c8e263a.
Diffstat (limited to 'assets/ts/codeblock.ts')
-rw-r--r-- | assets/ts/codeblock.ts | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/assets/ts/codeblock.ts b/assets/ts/codeblock.ts deleted file mode 100644 index 08c3328..0000000 --- a/assets/ts/codeblock.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copy button for code blocks -*/ -export default () => { - const copyButtons = document.querySelectorAll('.codeblock-copy'); - copyButtons.forEach(button => { - const codeblockID = button.getAttribute('data-id'), - copyText = button.textContent, - copiedText = button.getAttribute('data-copied-text'); - if (!codeblockID) return; - button.addEventListener('click', (e) => { - e.preventDefault(); - const codeblock = document.getElementById(codeblockID) as HTMLElement; - if (!codeblockID) return; - navigator.clipboard.writeText(codeblock.textContent) - .then(() => { - button.textContent = copiedText; - setTimeout(() => { - button.textContent = copyText; - }, 1000); - }) - .catch(err => { - alert(err) - console.log('Something went wrong', err); - }); - }, false); - }); -}
\ No newline at end of file |