mkasberg / script-seed

🌱 Seed scripts for popular (& unpopular) scripting languages.
https://mkasberg.github.io/script-seed/
MIT License
11 stars 23 forks source link

change document.exeCommand to clipboard API #91

Closed AloyBranCheung closed 2 years ago

AloyBranCheung commented 2 years ago

Closes #85

To maintain text highlighting when the button is clicked I kept the origin code.

To switch to clipboard API, I just replaced document.execCommand("copy") with navigator.clipboard.writeText(element.innerText);

AloyBranCheung commented 2 years ago

Will do. In terms of the highlighting, would you like to replace that with something else for better user feedback/UX when clicking the copy button?

AloyBranCheung commented 2 years ago

Ok, I removed the formatting and highlighting.

mkasberg commented 2 years ago

Similar to what GitHub does at the top of this page when you click the little copy icon next to the branch name.