File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 509
509
$ . each ( e . originalEvent . dataTransfer . files , function ( index , file ) {
510
510
var fileReader = new FileReader ( ) ;
511
511
fileReader . onload = ( function ( file ) {
512
+ var type = file . type . split ( '/' ) [ 0 ] ;
512
513
return function ( e ) {
513
514
var text = textarea . val ( ) ;
514
- textarea . val ( text . substring ( 0 , caretPos ) + '\n<img src="' + e . target . result + '" />\n' + text . substring ( caretPos ) ) ;
515
+ if ( type === 'image' )
516
+ textarea . val ( text . substring ( 0 , caretPos ) + '\n<img src="' + e . target . result + '" />\n' + text . substring ( caretPos ) ) ;
517
+ else
518
+ textarea . val ( text . substring ( 0 , caretPos ) + '\n<a href="' + e . target . result + '">Download ' + file . name + '</a>\n' + text . substring ( caretPos ) ) ;
515
519
} ;
516
520
} ) ( file ) ;
517
521
fileReader . readAsDataURL ( file ) ;
You can’t perform that action at this time.
0 commit comments