mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Update blob.ts
This commit is contained in:
parent
2e876e98d7
commit
0aa2608799
1 changed files with 1 additions and 18 deletions
|
@ -107,19 +107,6 @@ export const isImageFileHandle = (handle: FileSystemHandle | null) => {
|
||||||
return type === "png" || type === "svg";
|
return type === "png" || type === "svg";
|
||||||
};
|
};
|
||||||
|
|
||||||
const getExtensionFromFilename = (filename?: string): string | null => {
|
|
||||||
if (!filename) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const ext = filename.split(".").pop()?.toLowerCase();
|
|
||||||
return ext || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const isSupportedExtension = (filename?: string) => {
|
|
||||||
const extension = getExtensionFromFilename(filename);
|
|
||||||
return !!extension && extension in IMAGE_MIME_TYPES;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isSupportedImageFileType = (type: string | null | undefined) => {
|
export const isSupportedImageFileType = (type: string | null | undefined) => {
|
||||||
return !!type && (Object.values(IMAGE_MIME_TYPES) as string[]).includes(type);
|
return !!type && (Object.values(IMAGE_MIME_TYPES) as string[]).includes(type);
|
||||||
};
|
};
|
||||||
|
@ -128,11 +115,7 @@ export const isSupportedImageFile = (
|
||||||
blob: Blob | null | undefined,
|
blob: Blob | null | undefined,
|
||||||
): blob is Blob & { type: ValueOf<typeof IMAGE_MIME_TYPES> } => {
|
): blob is Blob & { type: ValueOf<typeof IMAGE_MIME_TYPES> } => {
|
||||||
const { type } = blob || {};
|
const { type } = blob || {};
|
||||||
if (type) {
|
return isSupportedImageFileType(type);
|
||||||
return isSupportedImageFileType(type);
|
|
||||||
}
|
|
||||||
const { name } = blob || {};
|
|
||||||
return isSupportedExtension(name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const loadSceneOrLibraryFromBlob = async (
|
export const loadSceneOrLibraryFromBlob = async (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue