Open brunolm opened 8 months ago
yarn add html2canvas
let mainDiv: HTMLElement; async function capture() { const canvas = await html2canvas(mainDiv); const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png')); try { await navigator.clipboard.write([ new ClipboardItem({ 'image/png': blob } as any) ]); console.log('Image copied to clipboard'); } catch (err) { console.error(err); } } <button id="capture" on:click={capture}> Copy </button>
yarn add html2canvas