mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-06 20:32:12 +00:00
parent
b9d15e9f27
commit
70c009ad4b
1 changed files with 7 additions and 5 deletions
|
|
@ -86,13 +86,13 @@ export function useFileUpload({
|
||||||
// Global drag events with counter for robust dragOver state
|
// Global drag events with counter for robust dragOver state
|
||||||
const handleWindowDragEnter = (e: DragEvent) => {
|
const handleWindowDragEnter = (e: DragEvent) => {
|
||||||
if (e.dataTransfer?.types?.includes("Files")) {
|
if (e.dataTransfer?.types?.includes("Files")) {
|
||||||
dragCounter.current++;
|
dragCounter.current += 1;
|
||||||
setDragOver(true);
|
setDragOver(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleWindowDragLeave = (e: DragEvent) => {
|
const handleWindowDragLeave = (e: DragEvent) => {
|
||||||
if (e.dataTransfer?.types?.includes("Files")) {
|
if (e.dataTransfer?.types?.includes("Files")) {
|
||||||
dragCounter.current--;
|
dragCounter.current -= 1;
|
||||||
if (dragCounter.current <= 0) {
|
if (dragCounter.current <= 0) {
|
||||||
setDragOver(false);
|
setDragOver(false);
|
||||||
dragCounter.current = 0;
|
dragCounter.current = 0;
|
||||||
|
|
@ -200,18 +200,20 @@ export function useFileUpload({
|
||||||
const handlePaste = async (
|
const handlePaste = async (
|
||||||
e: React.ClipboardEvent<HTMLTextAreaElement | HTMLInputElement>,
|
e: React.ClipboardEvent<HTMLTextAreaElement | HTMLInputElement>,
|
||||||
) => {
|
) => {
|
||||||
e.preventDefault();
|
|
||||||
const items = e.clipboardData.items;
|
const items = e.clipboardData.items;
|
||||||
if (!items) return;
|
if (!items) return;
|
||||||
const files: File[] = [];
|
const files: File[] = [];
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i += 1) {
|
||||||
const item = items[i];
|
const item = items[i];
|
||||||
if (item.kind === "file") {
|
if (item.kind === "file") {
|
||||||
const file = item.getAsFile();
|
const file = item.getAsFile();
|
||||||
if (file) files.push(file);
|
if (file) files.push(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (files.length === 0) return;
|
if (files.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
const validFiles = files.filter((file) =>
|
const validFiles = files.filter((file) =>
|
||||||
SUPPORTED_FILE_TYPES.includes(file.type),
|
SUPPORTED_FILE_TYPES.includes(file.type),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue