This commit is contained in:
Leandro Facchinetti 2021-04-12 11:43:09 +01:00
parent 23f6ee7c86
commit e3950b61fd
1 changed files with 15 additions and 19 deletions

View File

@ -212,25 +212,21 @@ export default function killTheNewsletter(
for (const copyable of document.querySelectorAll(".copyable")) for (const copyable of document.querySelectorAll(".copyable"))
copyable.insertAdjacentHTML( copyable.insertAdjacentHTML(
"afterend", "afterend",
$${"`"} $${"`"}$${html`<br />
$${html` <button
<br /> type="button"
<button onclick="${javascript`
type="button" (async () => {
onclick="${javascript` await navigator.clipboard.writeText("\${copyable.textContent}");
(async () => { const originalTextContent = this.textContent;
await navigator.clipboard.writeText("\${copyable.textContent}"); this.textContent = "Copied";
const originalTextContent = this.textContent; await new Promise(resolve => window.setTimeout(resolve, 500));
this.textContent = "Copied"; this.textContent = originalTextContent;
await new Promise(resolve => window.setTimeout(resolve, 500)); })();
this.textContent = originalTextContent; `}"
})(); >
`}" Copy
> </button>`}$${"`"}
Copy
</button>
`}
$${"`"}
); );
</script> </script>
</body> </body>