fix: ensure ClipboardItem created in the same tick to fix safari (#7066)

This commit is contained in:
David Luzar
2023-10-16 11:38:57 +02:00
committed by GitHub
parent aaf73c8ff3
commit 5b94cffc74
2 changed files with 7 additions and 10 deletions

View File

@@ -66,17 +66,14 @@ export const exportCanvas = async (
}
}
const tempCanvas = await exportToCanvas(elements, appState, files, {
const tempCanvas = exportToCanvas(elements, appState, files, {
exportBackground,
viewBackgroundColor,
exportPadding,
});
tempCanvas.style.display = "none";
document.body.appendChild(tempCanvas);
if (type === "png") {
let blob = await canvasToBlob(tempCanvas);
tempCanvas.remove();
if (appState.exportEmbedScene) {
blob = await (
await import(/* webpackChunkName: "image" */ "./image")
@@ -114,11 +111,8 @@ export const exportCanvas = async (
} else {
throw new Error(t("alerts.couldNotCopyToClipboard"));
}
} finally {
tempCanvas.remove();
}
} else {
tempCanvas.remove();
// shouldn't happen
throw new Error("Unsupported export type");
}