From 12c39d1034f696dcade2c66115392543a3985d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=95=9C=EB=B3=84?= <78421872+2hanbyeol1@users.noreply.github.com> Date: Mon, 6 Jan 2025 06:12:07 +0900 Subject: [PATCH] feat: add mimeTypes on file save (#8946) --- packages/excalidraw/data/filesystem.ts | 4 +++- packages/excalidraw/data/index.ts | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/excalidraw/data/filesystem.ts b/packages/excalidraw/data/filesystem.ts index 89a18c299b..186d587347 100644 --- a/packages/excalidraw/data/filesystem.ts +++ b/packages/excalidraw/data/filesystem.ts @@ -82,6 +82,7 @@ export const fileSave = ( name: string; /** file extension */ extension: FILE_EXTENSION; + mimeTypes?: string[]; description: string; /** existing FileSystemHandle */ fileHandle?: FileSystemHandle | null; @@ -93,10 +94,11 @@ export const fileSave = ( fileName: `${opts.name}.${opts.extension}`, description: opts.description, extensions: [`.${opts.extension}`], + mimeTypes: opts.mimeTypes, }, opts.fileHandle, ); }; -export type { FileSystemHandle }; export { nativeFileSystemSupported }; +export type { FileSystemHandle }; diff --git a/packages/excalidraw/data/index.ts b/packages/excalidraw/data/index.ts index 9aae145358..3db930cc26 100644 --- a/packages/excalidraw/data/index.ts +++ b/packages/excalidraw/data/index.ts @@ -5,6 +5,7 @@ import { import { DEFAULT_EXPORT_PADDING, DEFAULT_FILENAME, + IMAGE_MIME_TYPES, isFirefox, MIME_TYPES, } from "../constants"; @@ -15,8 +16,9 @@ import type { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement, } from "../element/types"; +import { getElementsOverlappingFrame } from "../frame"; import { t } from "../i18n"; -import { isSomeElementSelected, getSelectedElements } from "../scene"; +import { getSelectedElements, isSomeElementSelected } from "../scene"; import { exportToCanvas, exportToSvg } from "../scene/export"; import type { ExportType } from "../scene/types"; import type { AppState, BinaryFiles } from "../types"; @@ -25,7 +27,6 @@ import { canvasToBlob } from "./blob"; import type { FileSystemHandle } from "./filesystem"; import { fileSave } from "./filesystem"; import { serializeAsJSON } from "./json"; -import { getElementsOverlappingFrame } from "../frame"; export { loadFromBlob } from "./blob"; export { loadFromJSON, saveAsJSON } from "./json"; @@ -130,6 +131,7 @@ export const exportCanvas = async ( description: "Export to SVG", name, extension: appState.exportEmbedScene ? "excalidraw.svg" : "svg", + mimeTypes: [IMAGE_MIME_TYPES.svg], fileHandle, }, ); @@ -171,6 +173,7 @@ export const exportCanvas = async ( // FIXME reintroduce `excalidraw.png` when most people upgrade away // from 111.0.5563.64 (arm64), see #6349 extension: /* appState.exportEmbedScene ? "excalidraw.png" : */ "png", + mimeTypes: [IMAGE_MIME_TYPES.png], fileHandle, }); } else if (type === "clipboard") {