refactor: reduce passing-around of canvas in export code (#3571)

This commit is contained in:
David Laban 2021-05-13 18:21:15 +01:00 committed by GitHub
parent 3b9290831a
commit f1cf28a84e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 28 deletions

View file

@ -6,7 +6,6 @@ import { getSelectedElements } from "./scene";
import { AppState } from "./types";
import { SVG_EXPORT_TAG } from "./scene/export";
import { tryParseSpreadsheet, Spreadsheet, VALID_SPREADSHEET } from "./charts";
import { canvasToBlob } from "./data/blob";
import { EXPORT_DATA_TYPES } from "./constants";
type ElementsClipboard = {
@ -152,8 +151,7 @@ export const parseClipboard = async (
}
};
export const copyCanvasToClipboardAsPng = async (canvas: HTMLCanvasElement) => {
const blob = await canvasToBlob(canvas);
export const copyBlobToClipboardAsPng = async (blob: Blob) => {
await navigator.clipboard.write([
new window.ClipboardItem({ "image/png": blob }),
]);