mirror of
https://github.com/cloudreve/frontend.git
synced 2025-12-25 19:52:48 +00:00
fix(excalidraw): uploader DnD should be disabled while Excalidraw is open (fix cloudreve/cloudreve#3016)
This commit is contained in:
parent
51bbced0b3
commit
bb2f16bf5f
|
|
@ -47,14 +47,15 @@ const Uploader = () => {
|
||||||
const uploadRawFiles = useAppSelector((state) => state.globalState.uploadRawFiles);
|
const uploadRawFiles = useAppSelector((state) => state.globalState.uploadRawFiles);
|
||||||
|
|
||||||
const displayOpt = useActionDisplayOpt([], ContextMenuTypes.empty, parent, FileManagerIndex.main);
|
const displayOpt = useActionDisplayOpt([], ContextMenuTypes.empty, parent, FileManagerIndex.main);
|
||||||
|
const exclidrawOpen = useAppSelector((state) => state.globalState.excalidrawViewer?.open);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!parent) {
|
if (!parent || exclidrawOpen) {
|
||||||
uploadEnabled.current = false;
|
uploadEnabled.current = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uploadEnabled.current = displayOpt.showUpload ?? false;
|
uploadEnabled.current = displayOpt.showUpload ?? false;
|
||||||
}, [parent, displayOpt.showUpload]);
|
}, [parent, displayOpt.showUpload, exclidrawOpen]);
|
||||||
|
|
||||||
const taskAdded = useCallback(
|
const taskAdded = useCallback(
|
||||||
(original?: Base) => (tasks: Base[]) => {
|
(original?: Base) => (tasks: Base[]) => {
|
||||||
|
|
@ -99,10 +100,11 @@ const Uploader = () => {
|
||||||
},
|
},
|
||||||
onDropLeave: (_e) => {
|
onDropLeave: (_e) => {
|
||||||
if (!uploadEnabled.current) {
|
if (!uploadEnabled.current) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
dragCounter--;
|
dragCounter--;
|
||||||
setDropBgOpen((value) => !value);
|
setDropBgOpen((value) => !value);
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
onProactiveFileAdded: taskAdded(),
|
onProactiveFileAdded: taskAdded(),
|
||||||
onPoolEmpty: () => {
|
onPoolEmpty: () => {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ export interface Option {
|
||||||
overwrite?: boolean;
|
overwrite?: boolean;
|
||||||
dropZone: HTMLElement | null;
|
dropZone: HTMLElement | null;
|
||||||
onDropOver?: (e: DragEvent) => void;
|
onDropOver?: (e: DragEvent) => void;
|
||||||
onDropLeave?: (e: DragEvent) => void;
|
// retuen if current dopped file should be accepted.
|
||||||
|
onDropLeave?: (e: DragEvent) => boolean;
|
||||||
onToast: (type: MessageColor, msg: string) => void;
|
onToast: (type: MessageColor, msg: string) => void;
|
||||||
onPoolEmpty?: () => void;
|
onPoolEmpty?: () => void;
|
||||||
onProactiveFileAdded?: (uploaders: Base[]) => void;
|
onProactiveFileAdded?: (uploaders: Base[]) => void;
|
||||||
|
|
@ -276,7 +277,10 @@ export default class UploadManager {
|
||||||
}
|
}
|
||||||
const containFile = e.dataTransfer && e.dataTransfer.types.includes("Files");
|
const containFile = e.dataTransfer && e.dataTransfer.types.includes("Files");
|
||||||
if (containFile) {
|
if (containFile) {
|
||||||
this.o.onDropLeave && this.o.onDropLeave(e);
|
const shouldAccept = this.o.onDropLeave && this.o.onDropLeave(e);
|
||||||
|
if (!shouldAccept) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const items = await getAllFileEntries(e.dataTransfer!.items);
|
const items = await getAllFileEntries(e.dataTransfer!.items);
|
||||||
const uploaders = await new Promise<Base[]>((resolve, reject) =>
|
const uploaders = await new Promise<Base[]>((resolve, reject) =>
|
||||||
this.addFiles(items, this.currentPath as string, resolve, reject),
|
this.addFiles(items, this.currentPath as string, resolve, reject),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue