mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
fix: file save timing out with big file sizes (#7649)
This commit is contained in:
parent
0c3dffb082
commit
d67eaa8710
2 changed files with 21 additions and 13 deletions
|
@ -76,7 +76,7 @@ export const fileOpen = <M extends boolean | undefined = false>(opts: {
|
|||
};
|
||||
|
||||
export const fileSave = (
|
||||
blob: Blob,
|
||||
blob: Blob | Promise<Blob>,
|
||||
opts: {
|
||||
/** supply without the extension */
|
||||
name: string;
|
||||
|
|
|
@ -100,7 +100,7 @@ export const exportCanvas = async (
|
|||
throw new Error(t("alerts.cannotExportEmptyCanvas"));
|
||||
}
|
||||
if (type === "svg" || type === "clipboard-svg") {
|
||||
const tempSvg = await exportToSvg(
|
||||
const svgPromise = exportToSvg(
|
||||
elements,
|
||||
{
|
||||
exportBackground,
|
||||
|
@ -113,9 +113,12 @@ export const exportCanvas = async (
|
|||
files,
|
||||
{ exportingFrame },
|
||||
);
|
||||
|
||||
if (type === "svg") {
|
||||
return await fileSave(
|
||||
new Blob([tempSvg.outerHTML], { type: MIME_TYPES.svg }),
|
||||
return fileSave(
|
||||
svgPromise.then((svg) => {
|
||||
return new Blob([svg.outerHTML], { type: MIME_TYPES.svg });
|
||||
}),
|
||||
{
|
||||
description: "Export to SVG",
|
||||
name,
|
||||
|
@ -124,7 +127,9 @@ export const exportCanvas = async (
|
|||
},
|
||||
);
|
||||
} else if (type === "clipboard-svg") {
|
||||
await copyTextToSystemClipboard(tempSvg.outerHTML);
|
||||
await copyTextToSystemClipboard(
|
||||
await svgPromise.then((svg) => svg.outerHTML),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -137,17 +142,20 @@ export const exportCanvas = async (
|
|||
});
|
||||
|
||||
if (type === "png") {
|
||||
let blob = await canvasToBlob(tempCanvas);
|
||||
let blob = canvasToBlob(tempCanvas);
|
||||
|
||||
if (appState.exportEmbedScene) {
|
||||
blob = await (
|
||||
await import("./image")
|
||||
).encodePngMetadata({
|
||||
blob = blob.then((blob) =>
|
||||
import("./image").then(({ encodePngMetadata }) =>
|
||||
encodePngMetadata({
|
||||
blob,
|
||||
metadata: serializeAsJSON(elements, appState, files, "local"),
|
||||
});
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return await fileSave(blob, {
|
||||
return fileSave(blob, {
|
||||
description: "Export to PNG",
|
||||
name,
|
||||
// FIXME reintroduce `excalidraw.png` when most people upgrade away
|
||||
|
|
Loading…
Add table
Reference in a new issue