@@ -14,10 +14,15 @@ export class MessageList extends Component {
1414 this . state = {
1515 scrollBottom : 0 ,
1616 downButton : false ,
17+ onDrag : false ,
1718 } ;
1819
1920 this . loadRef = this . loadRef . bind ( this ) ;
2021 this . onScroll = this . onScroll . bind ( this ) ;
22+ this . onDragEnter = this . onDragEnter . bind ( this ) ;
23+ this . onDragOver = this . onDragOver . bind ( this ) ;
24+ this . onDragLeave = this . onDragLeave . bind ( this ) ;
25+ this . onDrop = this . onDrop . bind ( this ) ;
2126 }
2227
2328 checkScroll ( ) {
@@ -160,55 +165,101 @@ export class MessageList extends Component {
160165 this . props . onMeetingLinkClick ( item , i , e ) ;
161166 }
162167
168+ onDragOver ( e ) {
169+ e . preventDefault ( ) ;
170+ if ( this . props . onDragOver instanceof Function )
171+ this . props . onDragOver ( e )
172+ }
173+
174+ onDragEnter ( e ) {
175+ e . preventDefault ( ) ;
176+ if ( this . props . onDragEnter instanceof Function )
177+ this . props . onDragEnter ( e )
178+ if ( ! this . state . onDrag )
179+ this . setState ( { onDrag : true } )
180+ }
181+
182+
183+ onDragLeave ( e ) {
184+ e . preventDefault ( ) ;
185+ if ( this . props . onDragLeave instanceof Function )
186+ this . props . onDragLeave ( e )
187+ if ( this . state . onDrag )
188+ this . setState ( { onDrag : false } )
189+ }
190+
191+ onDrop ( e ) {
192+ e . preventDefault ( ) ;
193+ if ( this . props . onDrop instanceof Function )
194+ this . props . onDrop ( e )
195+ if ( this . state . onDrag )
196+ this . setState ( { onDrag : false } )
197+ }
198+
163199 render ( ) {
164200 return (
165201 < div
166- className = { classNames ( [ 'rce-container-mlist' , this . props . className ] ) } >
167- < div
168- ref = { this . loadRef }
169- onScroll = { this . onScroll }
170- className = 'rce-mlist' >
171- {
172- this . props . dataSource . map ( ( x , i ) => (
173- < MessageBox
174- key = { i }
175- { ...x }
176- onOpen = { this . props . onOpen && ( ( e ) => this . onOpen ( x , i , e ) ) }
177- onPhotoError = { this . props . onPhotoError && ( ( e ) => this . onPhotoError ( x , i , e ) ) }
178- onDownload = { this . props . onDownload && ( ( e ) => this . onDownload ( x , i , e ) ) }
179- onTitleClick = { this . props . onTitleClick && ( ( e ) => this . onTitleClick ( x , i , e ) ) }
180- onForwardClick = { this . props . onForwardClick && ( ( e ) => this . onForwardClick ( x , i , e ) ) }
181- onReplyClick = { this . props . onReplyClick && ( ( e ) => this . onReplyClick ( x , i , e ) ) }
182- onReplyMessageClick = { this . props . onReplyMessageClick && ( ( e ) => this . onReplyMessageClick ( x , i , e ) ) }
183- onRemoveMessageClick = { this . props . onRemoveMessageClick && ( ( e ) => this . onRemoveMessageClick ( x , i , e ) ) }
184- onClick = { this . props . onClick && ( ( e ) => this . onClick ( x , i , e ) ) }
185- onContextMenu = { this . props . onContextMenu && ( ( e ) => this . onContextMenu ( x , i , e ) ) }
186- onMeetingMoreSelect = { this . props . onMeetingMoreSelect && ( ( e ) => this . onMeetingMoreSelect ( x , i , e ) ) }
187- onMessageFocused = { this . props . onMessageFocused && ( ( e ) => this . onMessageFocused ( x , i , e ) ) }
188- onMeetingMessageClick = { this . props . onMeetingMessageClick && ( ( e ) => this . onMeetingMessageClick ( x , i , e ) ) }
189- onMeetingTitleClick = { this . props . onMeetingTitleClick }
190- onMeetingVideoLinkClick = { this . props . onMeetingVideoLinkClick }
191- onMeetingLinkClick = { this . props . onMeetingLinkClick && ( ( e ) => this . onMeetingLinkClick ( x , i , e ) ) }
192- />
193- ) )
194- }
195- </ div >
202+ className = { classNames ( [ 'rce-container-mlist' , this . props . className ] ) }
203+ onDragOver = { this . onDragOver }
204+ onDragEnter = { this . onDragEnter }
205+ onDragLeave = { this . onDragLeave }
206+ onDrop = { this . onDrop } >
207+ {
208+ ! ! this . props . onDragComponent && this . state . onDrag &&
209+ this . props . onDragComponent ( )
210+ }
196211 {
197- this . props . downButton === true &&
198- this . state . downButton &&
199- this . props . toBottomHeight !== '100%' &&
200- < div
201- className = 'rce-mlist-down-button'
202- onClick = { this . toBottom . bind ( this ) } >
203- < FaChevronDown />
204- {
205- this . props . downButtonBadge &&
206- < span
207- className = 'rce-mlist-down-button--badge' >
208- { this . props . downButtonBadge }
209- </ span >
210- }
211- </ div >
212+ ( ( this . state . onDrag && ! this . props . onDragComponent ) || ! this . state . onDrag ) &&
213+ [
214+ < div
215+ ref = { this . loadRef }
216+ onScroll = { this . onScroll }
217+ className = 'rce-mlist'
218+ onDragOver = { this . onDragOver }
219+ onDragEnter = { this . onDragEnter }
220+ onDragLeave = { this . onDragLeave }
221+ onDrop = { this . onDrop } >
222+ {
223+ this . props . dataSource . map ( ( x , i ) => (
224+ < MessageBox
225+ key = { i }
226+ { ...x }
227+ onOpen = { this . props . onOpen && ( ( e ) => this . onOpen ( x , i , e ) ) }
228+ onPhotoError = { this . props . onPhotoError && ( ( e ) => this . onPhotoError ( x , i , e ) ) }
229+ onDownload = { this . props . onDownload && ( ( e ) => this . onDownload ( x , i , e ) ) }
230+ onTitleClick = { this . props . onTitleClick && ( ( e ) => this . onTitleClick ( x , i , e ) ) }
231+ onForwardClick = { this . props . onForwardClick && ( ( e ) => this . onForwardClick ( x , i , e ) ) }
232+ onReplyClick = { this . props . onReplyClick && ( ( e ) => this . onReplyClick ( x , i , e ) ) }
233+ onReplyMessageClick = { this . props . onReplyMessageClick && ( ( e ) => this . onReplyMessageClick ( x , i , e ) ) }
234+ onRemoveMessageClick = { this . props . onRemoveMessageClick && ( ( e ) => this . onRemoveMessageClick ( x , i , e ) ) }
235+ onClick = { this . props . onClick && ( ( e ) => this . onClick ( x , i , e ) ) }
236+ onContextMenu = { this . props . onContextMenu && ( ( e ) => this . onContextMenu ( x , i , e ) ) }
237+ onMeetingMoreSelect = { this . props . onMeetingMoreSelect && ( ( e ) => this . onMeetingMoreSelect ( x , i , e ) ) }
238+ onMessageFocused = { this . props . onMessageFocused && ( ( e ) => this . onMessageFocused ( x , i , e ) ) }
239+ onMeetingMessageClick = { this . props . onMeetingMessageClick && ( ( e ) => this . onMeetingMessageClick ( x , i , e ) ) }
240+ onMeetingTitleClick = { this . props . onMeetingTitleClick }
241+ onMeetingVideoLinkClick = { this . props . onMeetingVideoLinkClick }
242+ onMeetingLinkClick = { this . props . onMeetingLinkClick && ( ( e ) => this . onMeetingLinkClick ( x , i , e ) ) }
243+ />
244+ ) )
245+ }
246+ </ div > ,
247+ this . props . downButton === true &&
248+ this . state . downButton &&
249+ this . props . toBottomHeight !== '100%' &&
250+ < div
251+ className = 'rce-mlist-down-button'
252+ onClick = { this . toBottom . bind ( this ) } >
253+ < FaChevronDown />
254+ {
255+ this . props . downButtonBadge &&
256+ < span
257+ className = 'rce-mlist-down-button--badge' >
258+ { this . props . downButtonBadge }
259+ </ span >
260+ }
261+ </ div >
262+ ]
212263 }
213264 </ div >
214265 ) ;
@@ -231,6 +282,11 @@ MessageList.defaultProps = {
231282 toBottomHeight : 300 ,
232283 downButton : true ,
233284 downButtonBadge : null ,
285+ onDragOver : ( ) => void ( 0 ) ,
286+ onDrop : ( ) => void ( 0 ) ,
287+ onDragEnter : ( ) => void ( 0 ) ,
288+ onDragLeave : ( ) => void ( 0 ) ,
289+ onDragComponent : null ,
234290} ;
235291
236292export default MessageList ;
0 commit comments