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 = (
|
export const fileSave = (
|
||||||
blob: Blob,
|
blob: Blob | Promise<Blob>,
|
||||||
opts: {
|
opts: {
|
||||||
/** supply without the extension */
|
/** supply without the extension */
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -100,7 +100,7 @@ export const exportCanvas = async (
|
||||||
throw new Error(t("alerts.cannotExportEmptyCanvas"));
|
throw new Error(t("alerts.cannotExportEmptyCanvas"));
|
||||||
}
|
}
|
||||||
if (type === "svg" || type === "clipboard-svg") {
|
if (type === "svg" || type === "clipboard-svg") {
|
||||||
const tempSvg = await exportToSvg(
|
const svgPromise = exportToSvg(
|
||||||
elements,
|
elements,
|
||||||
{
|
{
|
||||||
exportBackground,
|
exportBackground,
|
||||||
|
@ -113,9 +113,12 @@ export const exportCanvas = async (
|
||||||
files,
|
files,
|
||||||
{ exportingFrame },
|
{ exportingFrame },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (type === "svg") {
|
if (type === "svg") {
|
||||||
return await fileSave(
|
return fileSave(
|
||||||
new Blob([tempSvg.outerHTML], { type: MIME_TYPES.svg }),
|
svgPromise.then((svg) => {
|
||||||
|
return new Blob([svg.outerHTML], { type: MIME_TYPES.svg });
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
description: "Export to SVG",
|
description: "Export to SVG",
|
||||||
name,
|
name,
|
||||||
|
@ -124,7 +127,9 @@ export const exportCanvas = async (
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else if (type === "clipboard-svg") {
|
} else if (type === "clipboard-svg") {
|
||||||
await copyTextToSystemClipboard(tempSvg.outerHTML);
|
await copyTextToSystemClipboard(
|
||||||
|
await svgPromise.then((svg) => svg.outerHTML),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,17 +142,20 @@ export const exportCanvas = async (
|
||||||
});
|
});
|
||||||
|
|
||||||
if (type === "png") {
|
if (type === "png") {
|
||||||
let blob = await canvasToBlob(tempCanvas);
|
let blob = canvasToBlob(tempCanvas);
|
||||||
|
|
||||||
if (appState.exportEmbedScene) {
|
if (appState.exportEmbedScene) {
|
||||||
blob = await (
|
blob = blob.then((blob) =>
|
||||||
await import("./image")
|
import("./image").then(({ encodePngMetadata }) =>
|
||||||
).encodePngMetadata({
|
encodePngMetadata({
|
||||||
blob,
|
blob,
|
||||||
metadata: serializeAsJSON(elements, appState, files, "local"),
|
metadata: serializeAsJSON(elements, appState, files, "local"),
|
||||||
});
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await fileSave(blob, {
|
return fileSave(blob, {
|
||||||
description: "Export to PNG",
|
description: "Export to PNG",
|
||||||
name,
|
name,
|
||||||
// FIXME reintroduce `excalidraw.png` when most people upgrade away
|
// FIXME reintroduce `excalidraw.png` when most people upgrade away
|
||||||
|
|
Loading…
Add table
Reference in a new issue