UNPKG

@thoschu/canvas-web-component

Version:

Web Components made by Tom S. with Stencil.js

29 lines (28 loc) 951 B
import html2canvas from "html2canvas"; export async function clipboard(dataUrl) { return await navigator.clipboard .writeText(dataUrl) .then(() => true) .catch((err) => { console.error(err); return false; }); } export const appendTemp = (elements, temp) => { elements.forEach((element) => temp.appendChild(element)); return document.body.appendChild(temp); }; export const getElements = (hostHTMLElement) => { const { shadowRoot } = hostHTMLElement; const template = shadowRoot.querySelector("template"); const slotElement = template.querySelector("slot"); const elements = slotElement.assignedElements({ flatten: true }); return { elements }; }; export const getCanvas = async (element, config) => { const canvasPromise = html2canvas(element, config); return await canvasPromise.then((canvas) => { return canvas; }); }; //# sourceMappingURL=utils.js.map