@lvce-editor/explorer-view 2.56.0 → 2.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/explorerViewWorkerMain.js +223 -112
- package/package.json +1 -1
|
@@ -885,7 +885,7 @@ const WebWorkerRpcClient = {
|
|
|
885
885
|
|
|
886
886
|
const CreateFolder$1 = 1;
|
|
887
887
|
const CreateFile$1 = 2;
|
|
888
|
-
const Copy$
|
|
888
|
+
const Copy$1 = 3;
|
|
889
889
|
const Rename$2 = 4;
|
|
890
890
|
|
|
891
891
|
const rpcs = Object.create(null);
|
|
@@ -973,7 +973,7 @@ const applyOperation = operation => {
|
|
|
973
973
|
if (operation.type === CreateFolder$1) {
|
|
974
974
|
return mkdir(operation.path);
|
|
975
975
|
}
|
|
976
|
-
if (operation.type === Copy$
|
|
976
|
+
if (operation.type === Copy$1) {
|
|
977
977
|
return copy$1(operation.from || '', operation.path);
|
|
978
978
|
}
|
|
979
979
|
if (operation.type === Rename$2) {
|
|
@@ -1460,10 +1460,10 @@ const i18nString = (key, placeholders = emptyObject) => {
|
|
|
1460
1460
|
};
|
|
1461
1461
|
|
|
1462
1462
|
const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
|
|
1463
|
-
const Copy
|
|
1463
|
+
const Copy = 'Copy';
|
|
1464
1464
|
const CopyPath = 'Copy Path';
|
|
1465
1465
|
const CopyRelativePath = 'Copy Relative Path';
|
|
1466
|
-
const Cut
|
|
1466
|
+
const Cut = 'Cut';
|
|
1467
1467
|
const Delete$1 = 'Delete';
|
|
1468
1468
|
const FileNameCannotStartWithSlash = 'A file or folder name cannot start with a slash.';
|
|
1469
1469
|
const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
|
|
@@ -1492,10 +1492,10 @@ const openInIntegratedTerminal = () => {
|
|
|
1492
1492
|
return i18nString(OpenInIntegratedTerminal);
|
|
1493
1493
|
};
|
|
1494
1494
|
const cut = () => {
|
|
1495
|
-
return i18nString(Cut
|
|
1495
|
+
return i18nString(Cut);
|
|
1496
1496
|
};
|
|
1497
1497
|
const copy = () => {
|
|
1498
|
-
return i18nString(Copy
|
|
1498
|
+
return i18nString(Copy);
|
|
1499
1499
|
};
|
|
1500
1500
|
const paste = () => {
|
|
1501
1501
|
return i18nString(Paste);
|
|
@@ -1994,7 +1994,9 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
1994
1994
|
handleOffset: 0,
|
|
1995
1995
|
scrollBarActive: false,
|
|
1996
1996
|
scrollBarHeight: 0,
|
|
1997
|
-
confirmPaste: false
|
|
1997
|
+
confirmPaste: false,
|
|
1998
|
+
pasteShouldMove: false,
|
|
1999
|
+
cutItems: []
|
|
1998
2000
|
};
|
|
1999
2001
|
set(uid, state, state);
|
|
2000
2002
|
};
|
|
@@ -2041,7 +2043,9 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
2041
2043
|
handleOffset: 0,
|
|
2042
2044
|
scrollBarActive: false,
|
|
2043
2045
|
scrollBarHeight: 0,
|
|
2044
|
-
confirmPaste: false
|
|
2046
|
+
confirmPaste: false,
|
|
2047
|
+
pasteShouldMove: false,
|
|
2048
|
+
cutItems: []
|
|
2045
2049
|
};
|
|
2046
2050
|
set(state.uid, state, state);
|
|
2047
2051
|
return state;
|
|
@@ -2060,7 +2064,7 @@ const isEqual$4 = (oldState, newState) => {
|
|
|
2060
2064
|
|
|
2061
2065
|
const diffType$2 = RenderItems;
|
|
2062
2066
|
const isEqual$3 = (oldState, newState) => {
|
|
2063
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.editingErrorMessage === newState.editingErrorMessage && oldState.width === newState.width && oldState.focused === newState.focused && oldState.dropTargets === newState.dropTargets && oldState.icons === newState.icons;
|
|
2067
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.editingErrorMessage === newState.editingErrorMessage && oldState.width === newState.width && oldState.focused === newState.focused && oldState.dropTargets === newState.dropTargets && oldState.icons === newState.icons && oldState.cutItems === newState.cutItems;
|
|
2064
2068
|
};
|
|
2065
2069
|
|
|
2066
2070
|
const diffType$1 = RenderSelection;
|
|
@@ -2379,7 +2383,7 @@ const focusPrevious = state => {
|
|
|
2379
2383
|
}
|
|
2380
2384
|
};
|
|
2381
2385
|
|
|
2382
|
-
const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', 'getMouseActions', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleCopy', 'handleDragLeave', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleInputBlur', 'handleInputClick', 'handleInputKeyDown', 'handleKeyDown', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'updateEditingValue', 'updateIcons'];
|
|
2386
|
+
const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'handleCut', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', 'getMouseActions', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleCopy', 'handleDragLeave', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleInputBlur', 'handleInputClick', 'handleInputKeyDown', 'handleKeyDown', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'updateEditingValue', 'updateIcons'];
|
|
2383
2387
|
|
|
2384
2388
|
const getCommandIds = () => {
|
|
2385
2389
|
return commandIds;
|
|
@@ -2398,8 +2402,45 @@ const Delete = 18;
|
|
|
2398
2402
|
const KeyA = 29;
|
|
2399
2403
|
const KeyC = 31;
|
|
2400
2404
|
const KeyV = 50;
|
|
2405
|
+
const KeyX = 52;
|
|
2401
2406
|
const F2 = 58;
|
|
2402
2407
|
const Star = 131;
|
|
2408
|
+
const KeyCode = {
|
|
2409
|
+
__proto__: null,
|
|
2410
|
+
Delete,
|
|
2411
|
+
DownArrow,
|
|
2412
|
+
End,
|
|
2413
|
+
Enter,
|
|
2414
|
+
Escape,
|
|
2415
|
+
F2,
|
|
2416
|
+
Home,
|
|
2417
|
+
KeyA,
|
|
2418
|
+
KeyC,
|
|
2419
|
+
KeyV,
|
|
2420
|
+
KeyX,
|
|
2421
|
+
LeftArrow,
|
|
2422
|
+
RightArrow,
|
|
2423
|
+
Space,
|
|
2424
|
+
Star,
|
|
2425
|
+
UpArrow
|
|
2426
|
+
};
|
|
2427
|
+
const mergeClassNames = (...classNames) => {
|
|
2428
|
+
return classNames.filter(Boolean).join(' ');
|
|
2429
|
+
};
|
|
2430
|
+
const px = value => {
|
|
2431
|
+
return `${value}px`;
|
|
2432
|
+
};
|
|
2433
|
+
const position = (x, y) => {
|
|
2434
|
+
return `${x}px ${y}px`;
|
|
2435
|
+
};
|
|
2436
|
+
const Text = 12;
|
|
2437
|
+
const text = data => {
|
|
2438
|
+
return {
|
|
2439
|
+
type: Text,
|
|
2440
|
+
text: data,
|
|
2441
|
+
childCount: 0
|
|
2442
|
+
};
|
|
2443
|
+
};
|
|
2403
2444
|
|
|
2404
2445
|
const CtrlCmd = 1 << 11 >>> 0;
|
|
2405
2446
|
const Shift = 1 << 10 >>> 0;
|
|
@@ -2410,87 +2451,91 @@ const FocusExplorerEditBox = 14;
|
|
|
2410
2451
|
|
|
2411
2452
|
const getKeyBindings = () => {
|
|
2412
2453
|
return [{
|
|
2413
|
-
key: Shift | UpArrow,
|
|
2454
|
+
key: Shift | KeyCode.UpArrow,
|
|
2414
2455
|
command: 'Explorer.selectUp',
|
|
2415
2456
|
when: FocusExplorer
|
|
2416
2457
|
}, {
|
|
2417
|
-
key: Shift | DownArrow,
|
|
2458
|
+
key: Shift | KeyCode.DownArrow,
|
|
2418
2459
|
command: 'Explorer.selectDown',
|
|
2419
2460
|
when: FocusExplorer
|
|
2420
2461
|
}, {
|
|
2421
|
-
key: RightArrow,
|
|
2462
|
+
key: KeyCode.RightArrow,
|
|
2422
2463
|
command: 'Explorer.handleArrowRight',
|
|
2423
2464
|
when: FocusExplorer
|
|
2424
2465
|
}, {
|
|
2425
|
-
key: LeftArrow,
|
|
2466
|
+
key: KeyCode.LeftArrow,
|
|
2426
2467
|
command: 'Explorer.handleArrowLeft',
|
|
2427
2468
|
when: FocusExplorer
|
|
2428
2469
|
}, {
|
|
2429
|
-
key: Home,
|
|
2470
|
+
key: KeyCode.Home,
|
|
2430
2471
|
command: 'Explorer.focusFirst',
|
|
2431
2472
|
when: FocusExplorer
|
|
2432
2473
|
}, {
|
|
2433
|
-
key: End,
|
|
2474
|
+
key: KeyCode.End,
|
|
2434
2475
|
command: 'Explorer.focusLast',
|
|
2435
2476
|
when: FocusExplorer
|
|
2436
2477
|
}, {
|
|
2437
|
-
key: UpArrow,
|
|
2478
|
+
key: KeyCode.UpArrow,
|
|
2438
2479
|
command: 'Explorer.focusPrevious',
|
|
2439
2480
|
when: FocusExplorer
|
|
2440
2481
|
}, {
|
|
2441
|
-
key: DownArrow,
|
|
2482
|
+
key: KeyCode.DownArrow,
|
|
2442
2483
|
command: 'Explorer.focusNext',
|
|
2443
2484
|
when: FocusExplorer
|
|
2444
2485
|
}, {
|
|
2445
|
-
key: CtrlCmd | Star,
|
|
2486
|
+
key: CtrlCmd | KeyCode.Star,
|
|
2446
2487
|
command: 'Explorer.expandAll',
|
|
2447
2488
|
when: FocusExplorer
|
|
2448
2489
|
}, {
|
|
2449
|
-
key: Alt | RightArrow,
|
|
2490
|
+
key: Alt | KeyCode.RightArrow,
|
|
2450
2491
|
command: 'Explorer.expandRecursively',
|
|
2451
2492
|
when: FocusExplorer
|
|
2452
2493
|
}, {
|
|
2453
|
-
key: CtrlCmd | LeftArrow,
|
|
2494
|
+
key: CtrlCmd | KeyCode.LeftArrow,
|
|
2454
2495
|
command: 'Explorer.collapseAll',
|
|
2455
2496
|
when: FocusExplorer
|
|
2456
2497
|
}, {
|
|
2457
|
-
key: CtrlCmd | KeyV,
|
|
2498
|
+
key: CtrlCmd | KeyCode.KeyV,
|
|
2458
2499
|
command: 'Explorer.handlePaste',
|
|
2459
2500
|
when: FocusExplorer
|
|
2460
2501
|
}, {
|
|
2461
|
-
key: CtrlCmd | KeyC,
|
|
2502
|
+
key: CtrlCmd | KeyCode.KeyC,
|
|
2462
2503
|
command: 'Explorer.handleCopy',
|
|
2463
2504
|
when: FocusExplorer
|
|
2464
2505
|
}, {
|
|
2465
|
-
key:
|
|
2506
|
+
key: CtrlCmd | KeyCode.KeyX,
|
|
2507
|
+
command: 'Explorer.handleCut',
|
|
2508
|
+
when: FocusExplorer
|
|
2509
|
+
}, {
|
|
2510
|
+
key: KeyCode.F2,
|
|
2466
2511
|
command: 'Explorer.renameDirent',
|
|
2467
2512
|
when: FocusExplorer
|
|
2468
2513
|
}, {
|
|
2469
|
-
key: Escape,
|
|
2514
|
+
key: KeyCode.Escape,
|
|
2470
2515
|
command: 'Explorer.cancelEdit',
|
|
2471
2516
|
when: FocusExplorerEditBox
|
|
2472
2517
|
}, {
|
|
2473
|
-
key: Enter,
|
|
2518
|
+
key: KeyCode.Enter,
|
|
2474
2519
|
command: 'Explorer.acceptEdit',
|
|
2475
2520
|
when: FocusExplorerEditBox
|
|
2476
2521
|
}, {
|
|
2477
|
-
key: Delete,
|
|
2522
|
+
key: KeyCode.Delete,
|
|
2478
2523
|
command: 'Explorer.removeDirent',
|
|
2479
2524
|
when: FocusExplorer
|
|
2480
2525
|
}, {
|
|
2481
|
-
key: Escape,
|
|
2526
|
+
key: KeyCode.Escape,
|
|
2482
2527
|
command: 'Explorer.focusNone',
|
|
2483
2528
|
when: FocusExplorer
|
|
2484
2529
|
}, {
|
|
2485
|
-
key: Space,
|
|
2530
|
+
key: KeyCode.Space,
|
|
2486
2531
|
command: 'Explorer.handleClickCurrentButKeepFocus',
|
|
2487
2532
|
when: FocusExplorer
|
|
2488
2533
|
}, {
|
|
2489
|
-
key: Enter,
|
|
2534
|
+
key: KeyCode.Enter,
|
|
2490
2535
|
command: 'Explorer.handleClickCurrent',
|
|
2491
2536
|
when: FocusExplorer
|
|
2492
2537
|
}, {
|
|
2493
|
-
key: CtrlCmd | KeyA,
|
|
2538
|
+
key: CtrlCmd | KeyCode.KeyA,
|
|
2494
2539
|
command: 'Explorer.selectAll',
|
|
2495
2540
|
when: FocusExplorer
|
|
2496
2541
|
}];
|
|
@@ -2535,7 +2580,7 @@ const menuEntryCut = {
|
|
|
2535
2580
|
id: 'cut',
|
|
2536
2581
|
label: cut(),
|
|
2537
2582
|
flags: RestoreFocus,
|
|
2538
|
-
command:
|
|
2583
|
+
command: 'Explorer.handleCut'
|
|
2539
2584
|
};
|
|
2540
2585
|
const menuEntryCopy = {
|
|
2541
2586
|
id: 'copy',
|
|
@@ -3126,7 +3171,29 @@ const handleCopy = async state => {
|
|
|
3126
3171
|
// TODO handle copy error gracefully
|
|
3127
3172
|
const files = [absolutePath];
|
|
3128
3173
|
await writeNativeFiles('copy', files);
|
|
3129
|
-
return
|
|
3174
|
+
return {
|
|
3175
|
+
...state,
|
|
3176
|
+
pasteShouldMove: false
|
|
3177
|
+
};
|
|
3178
|
+
};
|
|
3179
|
+
|
|
3180
|
+
const handleCut = async state => {
|
|
3181
|
+
// TODO handle multiple files
|
|
3182
|
+
// TODO if not file is selected, what happens?
|
|
3183
|
+
const dirent = getFocusedDirent$1(state);
|
|
3184
|
+
if (!dirent) {
|
|
3185
|
+
console.error('[ViewletExplorer/handleCut] no dirent selected');
|
|
3186
|
+
return state;
|
|
3187
|
+
}
|
|
3188
|
+
const absolutePath = dirent.path;
|
|
3189
|
+
// TODO handle cut error gracefully
|
|
3190
|
+
const files = [absolutePath];
|
|
3191
|
+
await writeNativeFiles('cut', files);
|
|
3192
|
+
return {
|
|
3193
|
+
...state,
|
|
3194
|
+
pasteShouldMove: true,
|
|
3195
|
+
cutItems: files
|
|
3196
|
+
};
|
|
3130
3197
|
};
|
|
3131
3198
|
|
|
3132
3199
|
const handleDragLeave = state => {
|
|
@@ -3422,7 +3489,7 @@ const getFileOperationsElectron = async (root, paths, fileHandles) => {
|
|
|
3422
3489
|
} = fileHandle;
|
|
3423
3490
|
const path = paths[i];
|
|
3424
3491
|
operations.push({
|
|
3425
|
-
type: Copy$
|
|
3492
|
+
type: Copy$1,
|
|
3426
3493
|
path: join2(root, name),
|
|
3427
3494
|
from: path
|
|
3428
3495
|
});
|
|
@@ -3793,7 +3860,7 @@ const getFileOperationsCopy = (root, existingUris, files) => {
|
|
|
3793
3860
|
const uniqueName = generateUniqueName(baseName, existingUris, root);
|
|
3794
3861
|
const newUri = join2(root, uniqueName);
|
|
3795
3862
|
operations.push({
|
|
3796
|
-
type: Copy$
|
|
3863
|
+
type: Copy$1,
|
|
3797
3864
|
from: file,
|
|
3798
3865
|
// TODO ensure file is uri
|
|
3799
3866
|
path: newUri
|
|
@@ -3829,24 +3896,57 @@ const handlePasteCopy = async (state, nativeFiles) => {
|
|
|
3829
3896
|
const firstNewFilePath = newFilePaths[0];
|
|
3830
3897
|
const newFileIndex = getIndex(latestState.items, firstNewFilePath);
|
|
3831
3898
|
if (newFileIndex !== -1) {
|
|
3832
|
-
|
|
3899
|
+
const adjustedState = adjustScrollAfterPaste(latestState, newFileIndex);
|
|
3900
|
+
return {
|
|
3901
|
+
...adjustedState,
|
|
3902
|
+
pasteShouldMove: false
|
|
3903
|
+
};
|
|
3833
3904
|
}
|
|
3834
3905
|
}
|
|
3835
3906
|
// If there are no items, ensure focusedIndex is 0
|
|
3836
3907
|
if (latestState.items.length === 0) {
|
|
3837
3908
|
return {
|
|
3838
3909
|
...latestState,
|
|
3839
|
-
focusedIndex: 0
|
|
3910
|
+
focusedIndex: 0,
|
|
3911
|
+
pasteShouldMove: false
|
|
3840
3912
|
};
|
|
3841
3913
|
}
|
|
3842
|
-
return
|
|
3914
|
+
return {
|
|
3915
|
+
...latestState,
|
|
3916
|
+
pasteShouldMove: false
|
|
3917
|
+
};
|
|
3843
3918
|
};
|
|
3844
3919
|
|
|
3845
|
-
const
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3920
|
+
const getOperations = (toUri, files) => {
|
|
3921
|
+
const operations = [];
|
|
3922
|
+
for (const file of files) {
|
|
3923
|
+
const baseName = getBaseName('/', file);
|
|
3924
|
+
const newUri = join2(toUri, baseName);
|
|
3925
|
+
operations.push({
|
|
3926
|
+
type: Rename$2,
|
|
3927
|
+
from: file,
|
|
3928
|
+
path: newUri
|
|
3929
|
+
});
|
|
3930
|
+
}
|
|
3931
|
+
return operations;
|
|
3932
|
+
};
|
|
3933
|
+
const getTargetUri = (root, items, index) => {
|
|
3934
|
+
if (index === -1) {
|
|
3935
|
+
return root;
|
|
3849
3936
|
}
|
|
3937
|
+
return items[index].path;
|
|
3938
|
+
};
|
|
3939
|
+
const handlePasteCut = async (state, nativeFiles) => {
|
|
3940
|
+
const {
|
|
3941
|
+
root,
|
|
3942
|
+
pathSeparator,
|
|
3943
|
+
items,
|
|
3944
|
+
focusedIndex
|
|
3945
|
+
} = state;
|
|
3946
|
+
// TODO root is not necessrily target uri
|
|
3947
|
+
const targetUri = getTargetUri(root, items, focusedIndex);
|
|
3948
|
+
const operations = getOperations(targetUri, nativeFiles.files);
|
|
3949
|
+
await applyFileOperations(operations);
|
|
3850
3950
|
|
|
3851
3951
|
// Refresh the state after cut operations
|
|
3852
3952
|
const latestState = await refresh(state);
|
|
@@ -3854,36 +3954,23 @@ const handlePasteCut = async (state, nativeFiles) => {
|
|
|
3854
3954
|
// Focus on the first pasted file and adjust scroll position
|
|
3855
3955
|
if (nativeFiles.files.length > 0) {
|
|
3856
3956
|
const firstPastedFile = nativeFiles.files[0];
|
|
3857
|
-
const targetPath = `${
|
|
3957
|
+
const targetPath = `${root}${pathSeparator}${getBaseName(pathSeparator, firstPastedFile)}`;
|
|
3858
3958
|
const pastedFileIndex = getIndex(latestState.items, targetPath);
|
|
3859
3959
|
if (pastedFileIndex !== -1) {
|
|
3860
|
-
|
|
3960
|
+
const adjustedState = adjustScrollAfterPaste(latestState, pastedFileIndex);
|
|
3961
|
+
return {
|
|
3962
|
+
...adjustedState,
|
|
3963
|
+
pasteShouldMove: false
|
|
3964
|
+
};
|
|
3861
3965
|
}
|
|
3862
3966
|
}
|
|
3863
|
-
return
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
console.error('[ViewletExplorer/handlePaste] no paths detected');
|
|
3868
|
-
return state;
|
|
3967
|
+
return {
|
|
3968
|
+
...latestState,
|
|
3969
|
+
pasteShouldMove: false
|
|
3970
|
+
};
|
|
3869
3971
|
};
|
|
3870
3972
|
|
|
3871
3973
|
const None$3 = 'none';
|
|
3872
|
-
const Copy = 'copy';
|
|
3873
|
-
const Cut = 'cut';
|
|
3874
|
-
|
|
3875
|
-
const getPasteHandler = type => {
|
|
3876
|
-
switch (type) {
|
|
3877
|
-
case None$3:
|
|
3878
|
-
return handlePasteNone;
|
|
3879
|
-
case Copy:
|
|
3880
|
-
return handlePasteCopy;
|
|
3881
|
-
case Cut:
|
|
3882
|
-
return handlePasteCut;
|
|
3883
|
-
default:
|
|
3884
|
-
throw new Error(`unexpected native paste type: ${type}`);
|
|
3885
|
-
}
|
|
3886
|
-
};
|
|
3887
3974
|
|
|
3888
3975
|
const handlePaste = async state => {
|
|
3889
3976
|
const nativeFiles = await readNativeFiles();
|
|
@@ -3902,8 +3989,18 @@ const handlePaste = async state => {
|
|
|
3902
3989
|
// TODO but what if a file is currently selected? Then maybe the parent folder
|
|
3903
3990
|
// TODO but will it work if the folder is a symlink?
|
|
3904
3991
|
// TODO handle error gracefully when copy fails
|
|
3905
|
-
|
|
3906
|
-
return
|
|
3992
|
+
|
|
3993
|
+
// If no files to paste, return original state unchanged
|
|
3994
|
+
if (nativeFiles.type === None$3) {
|
|
3995
|
+
return state;
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
// Use the pasteShouldMove flag to determine whether to cut or copy
|
|
3999
|
+
if (state.pasteShouldMove) {
|
|
4000
|
+
return handlePasteCut(state, nativeFiles);
|
|
4001
|
+
} else {
|
|
4002
|
+
return handlePasteCopy(state, nativeFiles);
|
|
4003
|
+
}
|
|
3907
4004
|
};
|
|
3908
4005
|
|
|
3909
4006
|
const handlePointerDown = (state, button, x, y) => {
|
|
@@ -4503,22 +4600,34 @@ const ToolBar = 'toolbar';
|
|
|
4503
4600
|
const Tree = 'tree';
|
|
4504
4601
|
const TreeItem$1 = 'treeitem';
|
|
4505
4602
|
|
|
4603
|
+
// 0 = 'Button'
|
|
4604
|
+
// 1 = 'IconButton'
|
|
4605
|
+
// 2 = 'Button IconButton'
|
|
4606
|
+
// it could make dom diffing faster, since for classname,
|
|
4607
|
+
// once at start, send all classnames to renderer process
|
|
4608
|
+
// only numbers are compared. it could also make rendering faster,
|
|
4609
|
+
// representing the concatenated strings for example
|
|
4610
|
+
// since less data is transferred to renderer process
|
|
4611
|
+
// then, components uses numeric classname
|
|
4612
|
+
// TODO add option to make classnames numeric
|
|
4613
|
+
// when a component uses multiple classnames, it is a new number
|
|
4506
4614
|
const Actions = 'Actions';
|
|
4507
4615
|
const Button$2 = 'Button';
|
|
4508
4616
|
const ButtonNarrow = 'ButtonNarrow';
|
|
4509
4617
|
const ButtonPrimary = 'ButtonPrimary';
|
|
4510
4618
|
const ButtonWide = 'ButtonWide';
|
|
4511
4619
|
const Chevron = 'Chevron';
|
|
4512
|
-
const ExplorerErrorMessage = 'ExplorerErrorMessage';
|
|
4513
4620
|
const Empty = '';
|
|
4514
4621
|
const Explorer = 'Explorer';
|
|
4515
4622
|
const ExplorerDropTarget = 'DropTarget';
|
|
4623
|
+
const ExplorerErrorMessage = 'ExplorerErrorMessage';
|
|
4516
4624
|
const ExplorerInputBox = 'ExplorerInputBox';
|
|
4517
4625
|
const FileIcon = 'FileIcon';
|
|
4518
4626
|
const FocusOutline = 'FocusOutline';
|
|
4519
4627
|
const IconButton = 'IconButton';
|
|
4520
4628
|
const InputValidationError = 'InputValidationError';
|
|
4521
4629
|
const Label = 'Label';
|
|
4630
|
+
const LabelCut = 'LabelCut';
|
|
4522
4631
|
const ListItems = 'ListItems';
|
|
4523
4632
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
4524
4633
|
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
@@ -4531,36 +4640,6 @@ const Viewlet = 'Viewlet';
|
|
|
4531
4640
|
const Welcome = 'Welcome';
|
|
4532
4641
|
const WelcomeMessage = 'WelcomeMessage';
|
|
4533
4642
|
|
|
4534
|
-
// TODO add option to make classnames numeric
|
|
4535
|
-
// once at start, send all classnames to renderer process
|
|
4536
|
-
// then, components uses numeric classname
|
|
4537
|
-
// when a component uses multiple classnames, it is a new number
|
|
4538
|
-
// representing the concatenated strings for example
|
|
4539
|
-
// 0 = 'Button'
|
|
4540
|
-
// 1 = 'IconButton'
|
|
4541
|
-
// 2 = 'Button IconButton'
|
|
4542
|
-
// it could make dom diffing faster, since for classname,
|
|
4543
|
-
// only numbers are compared. it could also make rendering faster,
|
|
4544
|
-
// since less data is transferred to renderer process
|
|
4545
|
-
|
|
4546
|
-
const mergeClassNames = (...classNames) => {
|
|
4547
|
-
return classNames.filter(Boolean).join(' ');
|
|
4548
|
-
};
|
|
4549
|
-
const px = value => {
|
|
4550
|
-
return `${value}px`;
|
|
4551
|
-
};
|
|
4552
|
-
const position = (x, y) => {
|
|
4553
|
-
return `${x}px ${y}px`;
|
|
4554
|
-
};
|
|
4555
|
-
const Text = 12;
|
|
4556
|
-
const text = data => {
|
|
4557
|
-
return {
|
|
4558
|
-
type: Text,
|
|
4559
|
-
text: data,
|
|
4560
|
-
childCount: 0
|
|
4561
|
-
};
|
|
4562
|
-
};
|
|
4563
|
-
|
|
4564
4643
|
const Button$1 = 1;
|
|
4565
4644
|
const Div = 4;
|
|
4566
4645
|
const Input = 6;
|
|
@@ -4673,15 +4752,22 @@ const label = {
|
|
|
4673
4752
|
className: Label,
|
|
4674
4753
|
childCount: 1
|
|
4675
4754
|
};
|
|
4676
|
-
const getLabelDom = name => {
|
|
4755
|
+
const getLabelDom = (name, isCut) => {
|
|
4756
|
+
if (isCut) {
|
|
4757
|
+
return [{
|
|
4758
|
+
type: Div,
|
|
4759
|
+
className: mergeClassNames(Label, LabelCut),
|
|
4760
|
+
childCount: 1
|
|
4761
|
+
}, text(name)];
|
|
4762
|
+
}
|
|
4677
4763
|
return [label, text(name)];
|
|
4678
4764
|
};
|
|
4679
4765
|
|
|
4680
|
-
const getInputOrLabelDom = (isEditing, hasEditingError, name) => {
|
|
4766
|
+
const getInputOrLabelDom = (isEditing, hasEditingError, name, isCut) => {
|
|
4681
4767
|
if (isEditing) {
|
|
4682
4768
|
return getInputDom(hasEditingError);
|
|
4683
4769
|
}
|
|
4684
|
-
return getLabelDom(name);
|
|
4770
|
+
return getLabelDom(name, isCut);
|
|
4685
4771
|
};
|
|
4686
4772
|
|
|
4687
4773
|
const getExplorerItemVirtualDom = item => {
|
|
@@ -4698,7 +4784,8 @@ const getExplorerItemVirtualDom = item => {
|
|
|
4698
4784
|
name,
|
|
4699
4785
|
path,
|
|
4700
4786
|
setSize,
|
|
4701
|
-
posInSet
|
|
4787
|
+
posInSet,
|
|
4788
|
+
isCut
|
|
4702
4789
|
} = item;
|
|
4703
4790
|
const chevronDom = getChevronVirtualDom(chevron);
|
|
4704
4791
|
return [{
|
|
@@ -4716,7 +4803,7 @@ const getExplorerItemVirtualDom = item => {
|
|
|
4716
4803
|
ariaExpanded,
|
|
4717
4804
|
ariaDescription: '',
|
|
4718
4805
|
id
|
|
4719
|
-
}, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name)];
|
|
4806
|
+
}, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name, isCut)];
|
|
4720
4807
|
};
|
|
4721
4808
|
|
|
4722
4809
|
const getActiveDescendant = focusedIndex => {
|
|
@@ -4890,7 +4977,7 @@ const getEditingChevron = direntType => {
|
|
|
4890
4977
|
return None$1;
|
|
4891
4978
|
}
|
|
4892
4979
|
};
|
|
4893
|
-
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon) => {
|
|
4980
|
+
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems) => {
|
|
4894
4981
|
const visible = [];
|
|
4895
4982
|
const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
|
|
4896
4983
|
let iconIndex = 0;
|
|
@@ -4900,7 +4987,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
4900
4987
|
const isFocused = i === focusedIndex;
|
|
4901
4988
|
const id = isFocused ? 'TreeItemActive' : undefined;
|
|
4902
4989
|
const isSelected = item.selected;
|
|
4903
|
-
const
|
|
4990
|
+
const isCut = cutItems.includes(item.path);
|
|
4991
|
+
const className = getTreeItemClassName(isSelected, isFocused); // TODO compute classname in dom function
|
|
4904
4992
|
const expanded = getExpandedType(item.type);
|
|
4905
4993
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
4906
4994
|
const isEditing = i === editingIndex;
|
|
@@ -4921,17 +5009,39 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
4921
5009
|
ariaExpanded,
|
|
4922
5010
|
chevron,
|
|
4923
5011
|
id,
|
|
4924
|
-
className
|
|
5012
|
+
className,
|
|
5013
|
+
isCut
|
|
4925
5014
|
});
|
|
4926
5015
|
}
|
|
4927
5016
|
return visible;
|
|
4928
5017
|
};
|
|
4929
5018
|
|
|
4930
5019
|
const renderItems = (oldState, newState) => {
|
|
4931
|
-
const
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
5020
|
+
const {
|
|
5021
|
+
items,
|
|
5022
|
+
minLineY,
|
|
5023
|
+
maxLineY,
|
|
5024
|
+
focusedIndex,
|
|
5025
|
+
editingIndex,
|
|
5026
|
+
editingType,
|
|
5027
|
+
editingValue,
|
|
5028
|
+
editingErrorMessage,
|
|
5029
|
+
icons,
|
|
5030
|
+
useChevrons,
|
|
5031
|
+
dropTargets,
|
|
5032
|
+
editingIcon,
|
|
5033
|
+
itemHeight,
|
|
5034
|
+
width,
|
|
5035
|
+
root,
|
|
5036
|
+
deltaY,
|
|
5037
|
+
focused,
|
|
5038
|
+
height,
|
|
5039
|
+
cutItems
|
|
5040
|
+
} = newState;
|
|
5041
|
+
const visibleDirents = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems);
|
|
5042
|
+
const isWide = width > 450;
|
|
5043
|
+
const contentHeight = items.length * itemHeight;
|
|
5044
|
+
const depth = items[focusedIndex]?.depth || 0;
|
|
4935
5045
|
const indent = 8;
|
|
4936
5046
|
const padding = 10;
|
|
4937
5047
|
const fileIconWidth = 16;
|
|
@@ -4940,8 +5050,8 @@ const renderItems = (oldState, newState) => {
|
|
|
4940
5050
|
const {
|
|
4941
5051
|
top,
|
|
4942
5052
|
left
|
|
4943
|
-
} = getErrorMessagePosition(
|
|
4944
|
-
const dom = getExplorerVirtualDom(visibleDirents,
|
|
5053
|
+
} = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace);
|
|
5054
|
+
const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, deltaY, editingErrorMessage, top, left);
|
|
4945
5055
|
return ['Viewlet.setDom2', dom];
|
|
4946
5056
|
};
|
|
4947
5057
|
|
|
@@ -5451,6 +5561,7 @@ const commandMap = {
|
|
|
5451
5561
|
'Explorer.handleContextMenu': wrapCommand(handleContextMenu),
|
|
5452
5562
|
'Explorer.handleContextMenuKeyboard': wrapCommand(handleContextMenuKeyboard),
|
|
5453
5563
|
'Explorer.handleCopy': wrapCommand(handleCopy),
|
|
5564
|
+
'Explorer.handleCut': wrapCommand(handleCut),
|
|
5454
5565
|
'Explorer.handleDragLeave': wrapCommand(handleDragLeave),
|
|
5455
5566
|
'Explorer.handleDragOver': wrapCommand(handleDragOver),
|
|
5456
5567
|
'Explorer.handleDrop': wrapCommand(handleDrop),
|