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

+ 3 - 11
apps/app/src/components/PageEditor/PageEditor.tsx

@@ -294,15 +294,8 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
   }, [isNotFound, mutateEditorMode, router, save, t, updateStateAfterSave]);
 
 
-  /**
-   * the upload event handler
-   * @param {any} file
-   */
-  const uploadHandler = useCallback((args: File | File[]) => {
-    const files = Array.isArray(args)
-      ? args
-      : [args];
-
+  // the upload event handler
+  const uploadHandler = useCallback((files: File[]) => {
     files.forEach(async(file) => {
       try {
         // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -315,7 +308,6 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
         }
 
         const formData = new FormData();
-        // const { pageId, path } = pageContainer.state;
         formData.append('file', file);
         if (currentPagePath != null) {
           formData.append('path', currentPagePath);
@@ -334,7 +326,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
         let insertText = `[${fileName}](${attachment.filePathProxied})\n`;
         // when image
         if (attachment.fileFormat.startsWith('image/')) {
-        // modify to "![fileName](url)" syntax
+          // modify to "![fileName](url)" syntax
           insertText = `!${insertText}`;
         }
         // TODO: implement

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

@@ -22,7 +22,7 @@ const CodeMirrorEditorContainer = forwardRef<HTMLDivElement>((props, ref) => {
 type Props = {
   editorKey: string | GlobalCodeMirrorEditorKey,
   onChange?: (value: string) => void,
-  onUpload?: (args: File | File[]) => void,
+  onUpload?: (files: File[]) => void,
   indentSize?: number,
 }
 

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

@@ -17,7 +17,7 @@ const additionalExtensions: Extension[] = [
 type Props = {
   onChange?: (value: string) => void,
   onSave?: () => void,
-  onUpload?: (args: File | File[]) => void,
+  onUpload?: (files: File[]) => void,
   indentSize?: number,
 }
 

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

@@ -4,7 +4,7 @@ import { useDropzone } from 'react-dropzone';
 import type { DropzoneState } from 'react-dropzone';
 
 type DropzoneEditor = {
-  onUpload?: (args: File | File[]) => void,
+  onUpload?: (files: File[]) => void,
 }
 
 export const useDropzoneEditor = (props: DropzoneEditor): DropzoneState => {