support image drop for upload

This commit is contained in:
jeffvli
2026-04-06 11:32:03 -07:00
parent 918f453066
commit 6fc7b6b271
8 changed files with 385 additions and 133 deletions
+16
View File
@@ -0,0 +1,16 @@
import type { DragEvent } from 'react';
// OS / native file drag (vs in-app library drag).
export function isNativeFileDrag(event: DragEvent): boolean {
return event.dataTransfer.types.includes('Files');
}
// First file in the list whose MIME type is an image.
export function pickFirstImageFile(files: FileList | null): File | null {
if (!files?.length) return null;
for (let i = 0; i < files.length; i++) {
const f = files.item(i);
if (f?.type.startsWith('image/')) return f;
}
return null;
}