@@ -4,11 +4,12 @@ import { marked } from 'marked';
44import { observer } from 'mobx-react' ;
55import { ObservedComponent , reaction } from 'mobx-react-helper' ;
66import { compose , JWTProps , jwtVerifier , RouteProps , router } from 'next-ssr-middleware' ;
7- import { ChangeEvent , ClipboardEvent , createRef , DragEvent , FormEvent , KeyboardEventHandler } from 'react' ;
7+ import { ChangeEvent , FormEvent , KeyboardEventHandler } from 'react' ;
88import { formToJSON , scrollTo , sleep } from 'web-utility' ;
99
1010import { SymbolIcon } from '../../../components/Icon' ;
1111import { PageHead } from '../../../components/PageHead' ;
12+ import { PasteDropBox } from '../../../components/PasteDropBox' ;
1213import { EvaluationDisplay } from '../../../components/Project/EvaluationDisplay' ;
1314import { ScrollList } from '../../../components/ScrollList' ;
1415import { SessionBox } from '../../../components/User/SessionBox' ;
@@ -33,8 +34,6 @@ export default class ProjectEvaluationPage extends ObservedComponent<
3334
3435 messageStore = new ConsultMessageModel ( this . projectId ) ;
3536
36- fileInputRef = createRef < HTMLInputElement > ( ) ;
37-
3837 get menu ( ) {
3938 const { t } = this . observedContext ;
4039
@@ -99,24 +98,6 @@ export default class ProjectEvaluationPage extends ObservedComponent<
9998 if ( files . length > 0 ) await this . handleFiles ( files ) ;
10099 } ;
101100
102- handlePasteDrop = async ( event : ClipboardEvent | DragEvent ) => {
103- const items =
104- event . type === 'paste'
105- ? [ ...( event as ClipboardEvent ) . clipboardData . items ]
106- : [ ...( event as DragEvent ) . dataTransfer . items ] ;
107-
108- const files = items
109- . filter ( item => item . kind === 'file' )
110- . map ( item => item . getAsFile ( ) )
111- . filter ( ( file ) : file is File => file !== null ) ;
112-
113- if ( files . length > 0 ) {
114- event . preventDefault ( ) ;
115-
116- await this . handleFiles ( files ) ;
117- }
118- } ;
119-
120101 renderChatMessage = (
121102 { id, content, evaluation, prototypes, createdAt, createdBy } : ConsultMessage ,
122103 index = 0 ,
@@ -216,36 +197,34 @@ export default class ProjectEvaluationPage extends ObservedComponent<
216197 className = "sticky bottom-0 mx-1 mt-auto mb-1 flex items-end gap-2 p-1.5 sm:mx-0 sm:mb-0 sm:p-2"
217198 onSubmit = { this . handleMessageSubmit }
218199 >
219- < input
220- ref = { this . fileInputRef }
221- type = "file"
222- multiple
223- className = "hidden"
224- onChange = { this . handleFileInputChange }
225- />
226200 < Tooltip title = { t ( 'attach_files' ) } >
227201 < IconButton
202+ component = "label"
228203 size = "small"
229204 disabled = { fileStore . uploading > 0 || messageStore . uploading > 0 }
230- onClick = { ( ) => this . fileInputRef . current ?. click ( ) }
231205 >
232206 < SymbolIcon name = "attach_file" />
207+ < input
208+ type = "file"
209+ multiple
210+ className = "sr-only"
211+ onChange = { this . handleFileInputChange }
212+ />
233213 </ IconButton >
234214 </ Tooltip >
235- < TextField
236- name = "content"
237- placeholder = { t ( 'type_your_message' ) }
238- multiline
239- maxRows = { 4 }
240- fullWidth
241- variant = "outlined"
242- size = "small"
243- required
244- onKeyUp = { this . handleQuickSubmit }
245- onPaste = { this . handlePasteDrop }
246- onDragOver = { e => e . preventDefault ( ) }
247- onDrop = { this . handlePasteDrop }
248- />
215+ < PasteDropBox className = "flex-1 min-w-0" onFiles = { this . handleFiles } >
216+ < TextField
217+ name = "content"
218+ placeholder = { t ( 'type_your_message' ) }
219+ multiline
220+ maxRows = { 4 }
221+ fullWidth
222+ variant = "outlined"
223+ size = "small"
224+ required
225+ onKeyUp = { this . handleQuickSubmit }
226+ />
227+ </ PasteDropBox >
249228 < Button
250229 type = "submit"
251230 variant = "contained"
0 commit comments