| 15 | let {dropProps, isDropTarget} = useDrop({ |
| 16 | ref, |
| 17 | async onDrop(e) { |
| 18 | let items = await Promise.all( |
| 19 | (e.items as TextDropItem[]) |
| 20 | .filter( |
| 21 | item => |
| 22 | item.kind === 'text' && |
| 23 | (item.types.has('text/plain') || item.types.has('my-app-custom-type')) |
| 24 | ) |
| 25 | .map(async (item: TextDropItem) => { |
| 26 | if (item.types.has('my-app-custom-type')) { |
| 27 | return JSON.parse(await item.getText('my-app-custom-type')); |
| 28 | } else { |
| 29 | return {message: await item.getText('text/plain')}; |
| 30 | } |
| 31 | }) |
| 32 | ); |
| 33 | setDropped(items); |
| 34 | } |
| 35 | }); |
| 36 | |
| 37 | let message: ReactNode = <div key="drop here">'Drop here'</div>; |