@@ -306,6 +306,8 @@ const createApplication = (core, proc, win, $content) => {
306
306
const title = core . make ( 'osjs/locale' )
307
307
. translatableFlat ( proc . metadata . title ) ;
308
308
309
+ const { pathJoin} = core . make ( 'osjs/fs' ) ;
310
+ const vfs = core . make ( 'osjs/vfs' ) ;
309
311
const bus = core . make ( 'osjs/event-handler' , 'FileManager' ) ;
310
312
const dialog = createDialog ( bus , core , proc , win ) ;
311
313
const a = app ( state ( bus , core , proc , win ) ,
@@ -318,11 +320,12 @@ const createApplication = (core, proc, win, $content) => {
318
320
319
321
const upload = f => {
320
322
const uploadpath = currentPath . path . replace ( / \/ ? $ / , '/' ) + f . name ;
321
- return core . make ( 'osjs/ vfs' ) . writefile ( { path : uploadpath } , f ) ;
323
+ return vfs . writefile ( { path : uploadpath } , f ) ;
322
324
} ;
323
325
324
326
const _ = core . make ( 'osjs/locale' ) . translate ;
325
327
const __ = core . make ( 'osjs/locale' ) . translatable ( translations ) ;
328
+ const clipboard = core . make ( 'osjs/clipboard' ) ;
326
329
327
330
const createEditMenuItems = ( item , fromContext ) => {
328
331
const isDirectory = item && item . isDirectory ;
@@ -345,6 +348,42 @@ const createApplication = (core, proc, win, $content) => {
345
348
onclick : ( ) => bus . emit ( 'readFile' , item , true )
346
349
} ] ;
347
350
351
+ const clipboardMenu = [
352
+ {
353
+ label : _ ( 'LBL_COPY' ) ,
354
+ disabled : ! isValidFile ,
355
+ onclick : ( ) => clipboard . set ( item , 'vfs:copy' )
356
+ } ,
357
+ {
358
+ label : _ ( 'LBL_CUT' ) ,
359
+ disabled : ! isValidFile ,
360
+ onclick : ( ) => clipboard . set ( item , 'vfs:move' )
361
+ }
362
+ ] ;
363
+
364
+ if ( ! fromContext ) {
365
+ clipboardMenu . push ( {
366
+ label : _ ( 'LBL_PASTE' ) ,
367
+ disabled : ! clipboard . has ( / ^ v f s : / ) ,
368
+ onclick : ( ) => {
369
+ if ( clipboard . has ( / ^ v f s : / ) ) {
370
+ const move = clipboard . has ( 'vfs:move' ) ;
371
+
372
+ // TODO: Error handling
373
+ clipboard . get ( move )
374
+ . then ( file => {
375
+ const dest = { path : pathJoin ( currentPath . path , file . filename ) } ;
376
+
377
+ return ( move
378
+ ? vfs . move ( file , dest )
379
+ : vfs . copy ( file , dest ) )
380
+ . then ( ( ) => refresh ( ) ) ;
381
+ } ) ;
382
+ }
383
+ }
384
+ } ) ;
385
+ }
386
+
348
387
const menu = [
349
388
...openMenu ,
350
389
{
@@ -356,13 +395,14 @@ const createApplication = (core, proc, win, $content) => {
356
395
label : _ ( 'LBL_DELETE' ) ,
357
396
disabled : ! isValidFile ,
358
397
onclick : ( ) => dialog ( 'delete' , item , ( ) => refresh ( ) )
359
- }
398
+ } ,
399
+ ...clipboardMenu
360
400
] ;
361
401
362
402
menu . push ( {
363
403
label : _ ( 'LBL_DOWNLOAD' ) ,
364
404
disabled : ! item || isDirectory || ! isValidFile ,
365
- onclick : ( ) => core . make ( 'osjs/ vfs' ) . download ( item )
405
+ onclick : ( ) => vfs . download ( item )
366
406
} ) ;
367
407
368
408
return menu ;
@@ -397,10 +437,9 @@ const createApplication = (core, proc, win, $content) => {
397
437
let files ;
398
438
399
439
try {
400
- files = await core . make ( 'osjs/vfs' )
401
- . readdir ( file , {
402
- showHiddenFiles : settings . showHiddenFiles
403
- } ) ;
440
+ files = await vfs . readdir ( file , {
441
+ showHiddenFiles : settings . showHiddenFiles
442
+ } ) ;
404
443
} catch ( e ) {
405
444
console . warn ( e ) ;
406
445
a . setPath ( typeof currentPath === 'string' ? currentPath : currentPath . path ) ;
0 commit comments