Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

copy-code.js 527 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  1. export default () => {
  2. const buttons = Array.from(document.querySelectorAll('button.js-btn-copy'))
  3. if (!buttons) return
  4. buttons.forEach(button =>
  5. button.addEventListener('click', async evt => {
  6. const text = button.dataset.clipboardText
  7. await navigator.clipboard.writeText(text)
  8. const beforeTooltip = button.getAttribute('aria-label')
  9. button.setAttribute('aria-label', 'Copied!')
  10. setTimeout(() => {
  11. button.setAttribute('aria-label', beforeTooltip)
  12. }, 2000)
  13. })
  14. )
  15. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...