cmsmanage/membershipworks/js/upcoming_events_post_generator.entry.ts

20 lines
632 B
TypeScript
Raw Normal View History

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);