mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-13 07:42:31 +02:00
support image drop for upload
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user