Sfoglia il codice sorgente

fix: normalize file on paste/drop (#9959)

David Luzar 22 ore fa
parent
commit
414182f599
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      packages/excalidraw/clipboard.ts

+ 7 - 1
packages/excalidraw/clipboard.ts

@@ -30,6 +30,7 @@ import {
   createFile,
   createFile,
   getFileHandle,
   getFileHandle,
   isSupportedImageFileType,
   isSupportedImageFileType,
+  normalizeFile,
 } from "./data/blob";
 } from "./data/blob";
 
 
 import { tryParseSpreadsheet, VALID_SPREADSHEET } from "./charts";
 import { tryParseSpreadsheet, VALID_SPREADSHEET } from "./charts";
@@ -472,7 +473,12 @@ export const parseDataTransferEvent = async (
             const file = item.getAsFile();
             const file = item.getAsFile();
             if (file) {
             if (file) {
               const fileHandle = await getFileHandle(item);
               const fileHandle = await getFileHandle(item);
-              return { type: file.type, kind: "file", file, fileHandle };
+              return {
+                type: file.type,
+                kind: "file",
+                file: await normalizeFile(file),
+                fileHandle,
+              };
             }
             }
           } else if (item.kind === "string") {
           } else if (item.kind === "string") {
             const { type } = item;
             const { type } = item;