diff --git a/frontend/providers/workorder/src/pages/workorder/detail/components/AppMainInfo.tsx b/frontend/providers/workorder/src/pages/workorder/detail/components/AppMainInfo.tsx index 5516700fa9a..4dcdbcf978e 100644 --- a/frontend/providers/workorder/src/pages/workorder/detail/components/AppMainInfo.tsx +++ b/frontend/providers/workorder/src/pages/workorder/detail/components/AppMainInfo.tsx @@ -23,7 +23,7 @@ import { import { fetchEventSource } from '@fortaine/fetch-event-source'; import { throttle } from 'lodash'; import { useTranslation } from 'next-i18next'; -import { useEffect, useLayoutEffect, useRef, useState } from 'react'; +import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'; const statusAnimation = keyframes` 0% { @@ -331,6 +331,25 @@ const AppMainInfo = ({ } }, [app?.dialogs, isManuallyHandled]); + const handlePaste = useCallback(async (e: React.ClipboardEvent) => { + const items = e.clipboardData.items; + const files: File[] = []; + + for (let i = 0; i < items.length; i++) { + if (items[i].type.indexOf('image') !== -1) { + const blob = items[i].getAsFile(); + if (blob) { + files.push(blob); + } + } + } + + if (files.length > 0) { + e.preventDefault(); + await uploadFiles(files); + } + }, []); + return ( <> @@ -449,6 +468,7 @@ const AppMainInfo = ({ } border={'1px solid #EAEBF0'} flexDirection={'column'} + onPaste={handlePaste} > {uploadedFiles && ( @@ -517,7 +537,7 @@ const AppMainInfo = ({