mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Fix library dnd (#2314)
This commit is contained in:
parent
8a50916ef2
commit
ba3f548b91
16 changed files with 261 additions and 168 deletions
|
@ -55,13 +55,24 @@ export const parseFileContents = async (blob: Blob | File) => {
|
|||
return contents;
|
||||
};
|
||||
|
||||
const getMimeType = (blob: Blob): string => {
|
||||
if (blob.type) {
|
||||
return blob.type;
|
||||
export const getMimeType = (blob: Blob | string): string => {
|
||||
let name: string;
|
||||
if (typeof blob === "string") {
|
||||
name = blob;
|
||||
} else {
|
||||
if (blob.type) {
|
||||
return blob.type;
|
||||
}
|
||||
name = blob.name || "";
|
||||
}
|
||||
const name = blob.name || "";
|
||||
if (/\.(excalidraw|json)$/.test(name)) {
|
||||
return "application/json";
|
||||
} else if (/\.png$/.test(name)) {
|
||||
return "image/png";
|
||||
} else if (/\.jpe?g$/.test(name)) {
|
||||
return "image/jpeg";
|
||||
} else if (/\.svg$/.test(name)) {
|
||||
return "image/svg+xml";
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue