1import type { Chart } from "chart.js";
2
3export async function saveToClipboard(chart: Chart): Promise<void> {
4  const image = chart.toBase64Image('image/png', 1);
5  return fetch(image)
6    .then(response => response.blob())
7    .then((blob: Blob) => {
8      const type = blob.type;
9      return new ClipboardItem({
10        [type]: blob
11      });
12    }).then(item => navigator.clipboard.write([item]));
13}
14