mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-05-01 23:56:41 +07:00
added dropzones for comments and node editors
This commit is contained in:
parent
fb8ad315c0
commit
f10a1fa2d8
23 changed files with 247 additions and 41 deletions
|
@ -39,10 +39,12 @@ export const useDelayedReady = (setReady: (val: boolean) => void, delay: number
|
|||
* @param onUpload -- upload callback
|
||||
* @param allowedTypes -- list of allowed types
|
||||
*/
|
||||
export const useDropZone = (onUpload: (file: File[]) => void, allowedTypes?: string[]) => {
|
||||
export const useFileDropZone = (onUpload: (file: File[]) => void, allowedTypes?: string[]) => {
|
||||
return useCallback(
|
||||
event => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const files: File[] = Array.from((event.dataTransfer?.files as File[]) || []).filter(
|
||||
(file: File) => file?.type && (!allowedTypes || allowedTypes.includes(file.type))
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue