11import { clipboard , webUtils } from "electron" ;
22import { dirname , join , extname , basename } from "path/posix" ;
3- import { copyFile , mkdir , move , pathExists , readdir , stat , writeFile , writeJSON } from "fs-extra" ;
3+ import { copyFile , copy , mkdir , move , pathExists , readdir , stat , writeFile , writeJSON } from "fs-extra" ;
44
55import filenamify from "filenamify" ;
66
@@ -820,11 +820,12 @@ export class EditorAssetsBrowser extends Component<IEditorAssetsBrowserProps, IE
820820 private _handleDragOver ( event : DragEvent < HTMLDivElement > ) : void {
821821 event . preventDefault ( ) ;
822822 this . setState ( {
823- dragAndDroppingFiles : event . dataTransfer . types . includes ( "Files" ) ,
823+ dragAndDroppingFiles : event . dataTransfer . types . length === 1 && event . dataTransfer . types [ 0 ] === "Files" ,
824824 } ) ;
825825 }
826826
827827 private async _handleDrop ( event : DragEvent < HTMLDivElement > ) : Promise < void > {
828+ event . persist ( ) ;
828829 event . preventDefault ( ) ;
829830
830831 this . setState ( {
@@ -843,15 +844,22 @@ export class EditorAssetsBrowser extends Component<IEditorAssetsBrowserProps, IE
843844 continue ;
844845 }
845846
846- const path = webUtils . getPathForFile ( file ) ;
847+ const path = webUtils . getPathForFile ( file ) . replace ( / \\ / g , "/" ) ;
847848 const absolutePath = join ( this . state . browsedPath , basename ( path ) ) ;
848849
849850 filesToCopy [ path ] = absolutePath ;
850851 }
851852
852853 await Promise . all (
853854 Object . entries ( filesToCopy ) . map ( async ( [ source , destination ] ) => {
854- await copyFile ( source , destination ) ;
855+ const fStat = await stat ( source ) ;
856+ if ( fStat . isDirectory ( ) ) {
857+ await copy ( source , destination , {
858+ recursive : true ,
859+ } ) ;
860+ } else {
861+ await copyFile ( source , destination ) ;
862+ }
855863 } )
856864 ) ;
857865
0 commit comments