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"))
copyable.insertAdjacentHTML(
"afterend",
$${"`"}
$${html`
<br />
<button
type="button"
onclick="${javascript`
(async () => {
await navigator.clipboard.writeText("\${copyable.textContent}");
const originalTextContent = this.textContent;
this.textContent = "Copied";
await new Promise(resolve => window.setTimeout(resolve, 500));
this.textContent = originalTextContent;
})();
`}"
>
Copy
</button>
`}
$${"`"}
$${"`"}$${html`<br />
<button
type="button"
onclick="${javascript`
(async () => {
await navigator.clipboard.writeText("\${copyable.textContent}");
const originalTextContent = this.textContent;
this.textContent = "Copied";
await new Promise(resolve => window.setTimeout(resolve, 500));
this.textContent = originalTextContent;
})();
`}"
>
Copy
</button>`}$${"`"}
);
</script>
</body>