mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: abstract and fix legacy fs (#4032)
This commit is contained in:
parent
75aeaa6c38
commit
54739cd2df
13 changed files with 179 additions and 50 deletions
|
@ -1,4 +1,3 @@
|
|||
import { fileSave, FileSystemHandle } from "browser-fs-access";
|
||||
import {
|
||||
copyBlobToClipboardAsPng,
|
||||
copyTextToSystemClipboard,
|
||||
|
@ -10,6 +9,7 @@ import { exportToCanvas, exportToSvg } from "../scene/export";
|
|||
import { ExportType } from "../scene/types";
|
||||
import { AppState } from "../types";
|
||||
import { canvasToBlob } from "./blob";
|
||||
import { fileSave, FileSystemHandle } from "./filesystem";
|
||||
import { serializeAsJSON } from "./json";
|
||||
|
||||
export { loadFromBlob } from "./blob";
|
||||
|
@ -49,10 +49,10 @@ export const exportCanvas = async (
|
|||
return await fileSave(
|
||||
new Blob([tempSvg.outerHTML], { type: "image/svg+xml" }),
|
||||
{
|
||||
fileName: `${name}.svg`,
|
||||
extensions: [".svg"],
|
||||
name,
|
||||
extension: "svg",
|
||||
fileHandle,
|
||||
},
|
||||
fileHandle,
|
||||
);
|
||||
} else if (type === "clipboard-svg") {
|
||||
await copyTextToSystemClipboard(tempSvg.outerHTML);
|
||||
|
@ -71,7 +71,6 @@ export const exportCanvas = async (
|
|||
tempCanvas.remove();
|
||||
|
||||
if (type === "png") {
|
||||
const fileName = `${name}.png`;
|
||||
if (appState.exportEmbedScene) {
|
||||
blob = await (
|
||||
await import(/* webpackChunkName: "image" */ "./image")
|
||||
|
@ -81,14 +80,11 @@ export const exportCanvas = async (
|
|||
});
|
||||
}
|
||||
|
||||
return await fileSave(
|
||||
blob,
|
||||
{
|
||||
fileName,
|
||||
extensions: [".png"],
|
||||
},
|
||||
return await fileSave(blob, {
|
||||
name,
|
||||
extension: "png",
|
||||
fileHandle,
|
||||
);
|
||||
});
|
||||
} else if (type === "clipboard") {
|
||||
try {
|
||||
await copyBlobToClipboardAsPng(blob);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue