cmsmanage/membershipworks/js/upcoming_events_post_generator.entry.ts
Adam Goldsmith 1827d10bf4
Some checks failed
Ruff / ruff (push) Successful in 1m38s
Test / test (push) Failing after 3m43s
membershipworks: Fix script in upcoming events post generator
2024-08-09 01:47:07 -04:00

20 lines
632 B
TypeScript

import { Popover } from "bootstrap";
async function copyToClipboard(event: MouseEvent) {
// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API
const data = new ClipboardItem({
"text/plain": new Blob([document.getElementById("preview")!.innerHTML], {
type: "text/plain",
}),
});
await navigator.clipboard.write([data]);
let popover = Popover.getInstance(event.target as Element)!;
popover.show();
setTimeout(() => popover.hide(), 1000);
}
const button = document.getElementById("copy-button")!;
new Popover(button, { trigger: "manual" });
button.addEventListener("click", copyToClipboard);