@@ -29,7 +29,7 @@ import UploadResourceButton from "./ActionButton/UploadResourceButton";
2929import Editor , { EditorRefActions } from "./Editor" ;
3030import RelationListView from "./RelationListView" ;
3131import ResourceListView from "./ResourceListView" ;
32- import { handleEditorKeydownWithMarkdownShortcuts , hyperlinkHighlightedText } from "./handlers" ;
32+ import { handleEditorKeydownWithMarkdownShortcuts , hyperlinkHighlightedText , insertResourceText } from "./handlers" ;
3333import { MemoEditorContext } from "./types" ;
3434import "react-datepicker/dist/react-datepicker.css" ;
3535
@@ -233,7 +233,7 @@ const MemoEditor = observer((props: Props) => {
233233 }
234234 } ;
235235
236- const uploadMultiFiles = async ( files : FileList ) => {
236+ const uploadMultiFiles = async ( files : FileList ) : Promise < Resource [ ] > => {
237237 const uploadedResourceList : Resource [ ] = [ ] ;
238238 for ( const file of files ) {
239239 const resource = await handleUploadResource ( file ) ;
@@ -256,6 +256,7 @@ const MemoEditor = observer((props: Props) => {
256256 resourceList : [ ...prevState . resourceList , ...uploadedResourceList ] ,
257257 } ) ) ;
258258 }
259+ return uploadedResourceList ;
259260 } ;
260261
261262 const handleDropEvent = async ( event : React . DragEvent ) => {
@@ -294,7 +295,20 @@ const MemoEditor = observer((props: Props) => {
294295 const handlePasteEvent = async ( event : React . ClipboardEvent ) => {
295296 if ( event . clipboardData && event . clipboardData . files . length > 0 ) {
296297 event . preventDefault ( ) ;
297- await uploadMultiFiles ( event . clipboardData . files ) ;
298+
299+ const editor = editorRef . current ;
300+ let placeholder = "" ;
301+
302+ if ( editor ) {
303+ placeholder = `<resource_${ Date . now ( ) } >` ;
304+ editor . insertText ( placeholder ) ;
305+ }
306+
307+ const resources = await uploadMultiFiles ( event . clipboardData . files ) ;
308+
309+ if ( editor ) {
310+ insertResourceText ( editor , resources , placeholder ) ;
311+ }
298312 } else if (
299313 editorRef . current != null &&
300314 editorRef . current . getSelectedContent ( ) . length != 0 &&
0 commit comments