feat: add mimeTypes on file save (#8946)

pull/8979/head
한별 4 weeks ago committed by GitHub
parent d33e42e3a1
commit 12c39d1034
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -82,6 +82,7 @@ export const fileSave = (
name: string; name: string;
/** file extension */ /** file extension */
extension: FILE_EXTENSION; extension: FILE_EXTENSION;
mimeTypes?: string[];
description: string; description: string;
/** existing FileSystemHandle */ /** existing FileSystemHandle */
fileHandle?: FileSystemHandle | null; fileHandle?: FileSystemHandle | null;
@ -93,10 +94,11 @@ export const fileSave = (
fileName: `${opts.name}.${opts.extension}`, fileName: `${opts.name}.${opts.extension}`,
description: opts.description, description: opts.description,
extensions: [`.${opts.extension}`], extensions: [`.${opts.extension}`],
mimeTypes: opts.mimeTypes,
}, },
opts.fileHandle, opts.fileHandle,
); );
}; };
export type { FileSystemHandle };
export { nativeFileSystemSupported }; export { nativeFileSystemSupported };
export type { FileSystemHandle };

@ -5,6 +5,7 @@ import {
import { import {
DEFAULT_EXPORT_PADDING, DEFAULT_EXPORT_PADDING,
DEFAULT_FILENAME, DEFAULT_FILENAME,
IMAGE_MIME_TYPES,
isFirefox, isFirefox,
MIME_TYPES, MIME_TYPES,
} from "../constants"; } from "../constants";
@ -15,8 +16,9 @@ import type {
ExcalidrawFrameLikeElement, ExcalidrawFrameLikeElement,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
} from "../element/types"; } from "../element/types";
import { getElementsOverlappingFrame } from "../frame";
import { t } from "../i18n"; import { t } from "../i18n";
import { isSomeElementSelected, getSelectedElements } from "../scene"; import { getSelectedElements, isSomeElementSelected } from "../scene";
import { exportToCanvas, exportToSvg } from "../scene/export"; import { exportToCanvas, exportToSvg } from "../scene/export";
import type { ExportType } from "../scene/types"; import type { ExportType } from "../scene/types";
import type { AppState, BinaryFiles } from "../types"; import type { AppState, BinaryFiles } from "../types";
@ -25,7 +27,6 @@ import { canvasToBlob } from "./blob";
import type { FileSystemHandle } from "./filesystem"; import type { FileSystemHandle } from "./filesystem";
import { fileSave } from "./filesystem"; import { fileSave } from "./filesystem";
import { serializeAsJSON } from "./json"; import { serializeAsJSON } from "./json";
import { getElementsOverlappingFrame } from "../frame";
export { loadFromBlob } from "./blob"; export { loadFromBlob } from "./blob";
export { loadFromJSON, saveAsJSON } from "./json"; export { loadFromJSON, saveAsJSON } from "./json";
@ -130,6 +131,7 @@ export const exportCanvas = async (
description: "Export to SVG", description: "Export to SVG",
name, name,
extension: appState.exportEmbedScene ? "excalidraw.svg" : "svg", extension: appState.exportEmbedScene ? "excalidraw.svg" : "svg",
mimeTypes: [IMAGE_MIME_TYPES.svg],
fileHandle, fileHandle,
}, },
); );
@ -171,6 +173,7 @@ export const exportCanvas = async (
// FIXME reintroduce `excalidraw.png` when most people upgrade away // FIXME reintroduce `excalidraw.png` when most people upgrade away
// from 111.0.5563.64 (arm64), see #6349 // from 111.0.5563.64 (arm64), see #6349
extension: /* appState.exportEmbedScene ? "excalidraw.png" : */ "png", extension: /* appState.exportEmbedScene ? "excalidraw.png" : */ "png",
mimeTypes: [IMAGE_MIME_TYPES.png],
fileHandle, fileHandle,
}); });
} else if (type === "clipboard") { } else if (type === "clipboard") {

Loading…
Cancel
Save