Closed mkasberg closed 2 years ago
Hey @mkasberg , I just wanted to clarify for this issue, is the goal to change the document.exeCommand("copy")
in copyToClipboard()
so that the user can copy to clipboard the seed script using Clipboard.writeText
instead?
Yes, and it is likely that most of the copyToClipboard()
function will need to be re-written (and might be significantly shorter since we might not need to highlight the text anymore to perform the copy). We want to copy the inner text of document.getElementById("seedScript")
.
I'd like to give it a shot if that's alright.
Sure, that would be great!
Thanks! Do you mind assigning me this?
We're currently copying text to the clipboard like this:
https://github.com/mkasberg/script-seed/blob/f8fc60cfa72a9b666fbbcc80cc96c500a9bcb0c1/main.js#L111-L130
However, the execCommand API is deprecated.
We should replace it with Clipboard.writeText.
I'm not 100% sure, but this might be difficult to test locally if the clipboard API requires HTTPS...
Also, note that we might be able to remove some code that selects the text before executing
copy
since with the new API we can just get the inner text and write it directly to the clipboard.