reiji-h 2 лет назад
Родитель
Сommit
6085778b74

+ 1 - 1
packages/editor/src/components/CodeMirrorEditor/CodeMirrorEditor.tsx

@@ -100,7 +100,7 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
 
   }, [codeMirrorEditor]);
 
-  const { getRootProps, open } = useFileDropzone({ onUpload });
+  const { getRootProps, open } = useFileDropzone({ onUpload, acceptedFileType });
 
   return (
     <div {...getRootProps()} className="flex-expand-vert">

+ 5 - 1
packages/editor/src/services/file-dropzone/use-file-dropzone.ts

@@ -1,6 +1,6 @@
 import { useCallback } from 'react';
 
-import { useDropzone } from 'react-dropzone';
+import { useDropzone, Accept } from 'react-dropzone';
 import type { DropzoneState } from 'react-dropzone';
 
 import { AcceptedUploadFileType } from 'src/consts';
@@ -21,10 +21,14 @@ export const useFileDropzone = (props: DropzoneEditor): DropzoneState => {
     onUpload(acceptedFiles);
   }, [onUpload]);
 
+  const accept: Accept = {};
+  accept[(acceptedFileType ?? '')] = [];
+
   return useDropzone({
     noKeyboard: true,
     noClick: true,
     onDrop: dropHandler,
+    accept,
   });
 
 };