@@ -304,32 +304,34 @@ function handleAttachmentDrop (codeEditor, storageKey, noteKey, dropEvent) {
304
304
}
305
305
} ) )
306
306
} else {
307
- promise = Promise . all ( Array . from ( dropEvent . dataTransfer . items ) . map ( item => {
308
- if ( item . type === 'text/html' ) {
309
- const html = dropEvent . dataTransfer . getData ( 'text/html' )
310
-
311
- const match = / < i m g [ ^ > ] * [ \s " ' ] s r c = " ( [ ^ " ] + ) " / . exec ( html )
312
- if ( match ) {
313
- const imageURL = match [ 1 ]
314
-
315
- return getImage ( imageURL )
316
- . then ( image => {
317
- const canvas = document . createElement ( 'canvas' )
318
- const context = canvas . getContext ( '2d' )
319
- canvas . width = image . width
320
- canvas . height = image . height
321
- context . drawImage ( image , 0 , 0 )
322
-
323
- return copyAttachment ( { type : 'base64' , data : canvas . toDataURL ( ) , sourceFilePath : imageURL } , storageKey , noteKey )
324
- } )
325
- . then ( fileName => ( {
326
- fileName,
327
- title : imageURL ,
328
- isImage : true
329
- } ) )
330
- }
307
+ let imageURL = dropEvent . dataTransfer . getData ( 'text/plain' )
308
+
309
+ if ( ! imageURL ) {
310
+ const match = / < i m g [ ^ > ] * [ \s " ' ] s r c = " ( [ ^ " ] + ) " / . exec ( dropEvent . dataTransfer . getData ( 'text/html' ) )
311
+ if ( match ) {
312
+ imageURL = match [ 1 ]
331
313
}
332
- } ) )
314
+ }
315
+
316
+ if ( ! imageURL ) {
317
+ return
318
+ }
319
+
320
+ promise = Promise . all ( [ getImage ( imageURL )
321
+ . then ( image => {
322
+ const canvas = document . createElement ( 'canvas' )
323
+ const context = canvas . getContext ( '2d' )
324
+ canvas . width = image . width
325
+ canvas . height = image . height
326
+ context . drawImage ( image , 0 , 0 )
327
+
328
+ return copyAttachment ( { type : 'base64' , data : canvas . toDataURL ( ) , sourceFilePath : imageURL } , storageKey , noteKey )
329
+ } )
330
+ . then ( fileName => ( {
331
+ fileName,
332
+ title : imageURL ,
333
+ isImage : true
334
+ } ) ) ] )
333
335
}
334
336
335
337
promise . then ( files => {
0 commit comments