@lvce-editor/explorer-view 2.22.0 → 2.24.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 +216 -58
- package/package.json +1 -1
|
@@ -985,6 +985,8 @@ const getPath = dirent => {
|
|
|
985
985
|
return dirent.path;
|
|
986
986
|
};
|
|
987
987
|
|
|
988
|
+
const DELTA_EDITING = 100;
|
|
989
|
+
|
|
988
990
|
const BlockDevice = 1;
|
|
989
991
|
const CharacterDevice = 2;
|
|
990
992
|
const Directory = 3;
|
|
@@ -996,6 +998,8 @@ const Symlink = 9;
|
|
|
996
998
|
const SymLinkFile = 10;
|
|
997
999
|
const SymLinkFolder = 11;
|
|
998
1000
|
const Unknown = 12;
|
|
1001
|
+
const EditingFile = File + DELTA_EDITING;
|
|
1002
|
+
const EditingFolder = Directory + DELTA_EDITING;
|
|
999
1003
|
|
|
1000
1004
|
const RendererWorker = 1;
|
|
1001
1005
|
|
|
@@ -1013,12 +1017,20 @@ const invoke = (method, ...params) => {
|
|
|
1013
1017
|
return rpc.invoke(method, ...params);
|
|
1014
1018
|
};
|
|
1015
1019
|
|
|
1020
|
+
const getFileIcon = async name => {
|
|
1021
|
+
return invoke('IconTheme.getFileIcon', {
|
|
1022
|
+
name
|
|
1023
|
+
});
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
const getFolderIcon = async name => {
|
|
1027
|
+
return invoke('IconTheme.getFolderIcon', {
|
|
1028
|
+
name
|
|
1029
|
+
});
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1016
1032
|
const requestFileIcons = async requests => {
|
|
1017
|
-
const promises = requests.map(request => request.type === File ?
|
|
1018
|
-
name: request.name
|
|
1019
|
-
}) : invoke('IconTheme.getFolderIcon', {
|
|
1020
|
-
name: request.name
|
|
1021
|
-
}));
|
|
1033
|
+
const promises = requests.map(request => request.type === File ? getFileIcon(request.name) : getFolderIcon(request.name));
|
|
1022
1034
|
return Promise.all(promises);
|
|
1023
1035
|
};
|
|
1024
1036
|
|
|
@@ -1156,7 +1168,7 @@ const getNewDirentsAccept = async (state, newDirentType, createFn) => {
|
|
|
1156
1168
|
newDirent.posInSet = posInSet;
|
|
1157
1169
|
// @ts-ignore
|
|
1158
1170
|
items.splice(insertIndex + 1, 0, newDirent);
|
|
1159
|
-
const newDirents = [...items];
|
|
1171
|
+
const newDirents = [...items].filter(item => item.type !== EditingFile && item.type !== EditingFolder);
|
|
1160
1172
|
return {
|
|
1161
1173
|
dirents: newDirents,
|
|
1162
1174
|
newFocusedIndex: insertIndex + 1
|
|
@@ -1406,12 +1418,41 @@ const acceptEdit = async state => {
|
|
|
1406
1418
|
}
|
|
1407
1419
|
};
|
|
1408
1420
|
|
|
1421
|
+
const getNewDirentsForCancelRename = (items, editingIndex) => {
|
|
1422
|
+
const item = items[editingIndex];
|
|
1423
|
+
const newItems = [...items];
|
|
1424
|
+
newItems[editingIndex] = {
|
|
1425
|
+
...item,
|
|
1426
|
+
type: item.type - DELTA_EDITING
|
|
1427
|
+
};
|
|
1428
|
+
return newItems;
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
const isNormalItem = item => {
|
|
1432
|
+
return item.type !== EditingFile && item.type !== EditingFolder;
|
|
1433
|
+
};
|
|
1409
1434
|
const cancelEdit = state => {
|
|
1410
1435
|
const {
|
|
1411
|
-
editingIndex
|
|
1436
|
+
editingIndex,
|
|
1437
|
+
editingType
|
|
1412
1438
|
} = state;
|
|
1439
|
+
if (editingType === Rename$1) {
|
|
1440
|
+
const newItems = getNewDirentsForCancelRename(state.items, editingIndex);
|
|
1441
|
+
return {
|
|
1442
|
+
...state,
|
|
1443
|
+
items: newItems,
|
|
1444
|
+
focusedIndex: editingIndex,
|
|
1445
|
+
focused: true,
|
|
1446
|
+
editingIndex: -1,
|
|
1447
|
+
editingValue: '',
|
|
1448
|
+
editingType: None$5,
|
|
1449
|
+
focus: List
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
const filteredItems = state.items.filter(isNormalItem);
|
|
1413
1453
|
return {
|
|
1414
1454
|
...state,
|
|
1455
|
+
items: filteredItems,
|
|
1415
1456
|
focusedIndex: editingIndex,
|
|
1416
1457
|
focused: true,
|
|
1417
1458
|
editingIndex: -1,
|
|
@@ -1977,6 +2018,16 @@ const focusNext = state => {
|
|
|
1977
2018
|
return focusIndex(state, focusedIndex + 1);
|
|
1978
2019
|
};
|
|
1979
2020
|
|
|
2021
|
+
const focusNone = state => {
|
|
2022
|
+
const {
|
|
2023
|
+
focusedIndex
|
|
2024
|
+
} = state;
|
|
2025
|
+
if (focusedIndex === -1) {
|
|
2026
|
+
return state;
|
|
2027
|
+
}
|
|
2028
|
+
return focusIndex(state, -1);
|
|
2029
|
+
};
|
|
2030
|
+
|
|
1980
2031
|
const focusPrevious = state => {
|
|
1981
2032
|
const {
|
|
1982
2033
|
focusedIndex,
|
|
@@ -1995,7 +2046,7 @@ const focusPrevious = state => {
|
|
|
1995
2046
|
}
|
|
1996
2047
|
};
|
|
1997
2048
|
|
|
1998
|
-
const commandIds = ['acceptEdit', 'cancelEdit', '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', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', '
|
|
2049
|
+
const commandIds = ['acceptEdit', 'cancelEdit', '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', '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'];
|
|
1999
2050
|
|
|
2000
2051
|
const getCommandIds = () => {
|
|
2001
2052
|
return commandIds;
|
|
@@ -2079,7 +2130,7 @@ const getKeyBindings = () => {
|
|
|
2079
2130
|
when: FocusExplorer
|
|
2080
2131
|
}, {
|
|
2081
2132
|
key: F2,
|
|
2082
|
-
command: 'Explorer.
|
|
2133
|
+
command: 'Explorer.renameDirent',
|
|
2083
2134
|
when: FocusExplorer
|
|
2084
2135
|
}, {
|
|
2085
2136
|
key: Escape,
|
|
@@ -3187,6 +3238,10 @@ const handleIconThemeChange = state => {
|
|
|
3187
3238
|
return updateIcons(state);
|
|
3188
3239
|
};
|
|
3189
3240
|
|
|
3241
|
+
const handleInputBlur = state => {
|
|
3242
|
+
return cancelEdit(state);
|
|
3243
|
+
};
|
|
3244
|
+
|
|
3190
3245
|
// TODO add lots of tests for this
|
|
3191
3246
|
const updateRoot = async state1 => {
|
|
3192
3247
|
// @ts-ignore
|
|
@@ -3540,28 +3595,118 @@ const handleWorkspaceChange = async state => {
|
|
|
3540
3595
|
|
|
3541
3596
|
const ExplorerEditBox = FocusExplorerEditBox;
|
|
3542
3597
|
|
|
3598
|
+
const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntType) => {
|
|
3599
|
+
// Get existing children or query them if they don't exist
|
|
3600
|
+
let existingChildren = items.filter(item => item.depth === depth && item.path.startsWith(parentPath));
|
|
3601
|
+
if (existingChildren.length === 0) {
|
|
3602
|
+
const childDirents = await readDirWithFileTypes(parentPath);
|
|
3603
|
+
existingChildren = childDirents.map((dirent, index) => ({
|
|
3604
|
+
name: dirent.name,
|
|
3605
|
+
type: dirent.type,
|
|
3606
|
+
path: `${parentPath}/${dirent.name}`,
|
|
3607
|
+
depth,
|
|
3608
|
+
selected: false,
|
|
3609
|
+
posInSet: index + 1,
|
|
3610
|
+
setSize: childDirents.length,
|
|
3611
|
+
icon: ''
|
|
3612
|
+
}));
|
|
3613
|
+
}
|
|
3614
|
+
const updatedChildren = existingChildren.map((child, index) => ({
|
|
3615
|
+
...child,
|
|
3616
|
+
posInSet: index + 1,
|
|
3617
|
+
setSize: existingChildren.length + 2
|
|
3618
|
+
}));
|
|
3619
|
+
const newDirent = {
|
|
3620
|
+
name: '',
|
|
3621
|
+
type: direntType,
|
|
3622
|
+
path: parentPath,
|
|
3623
|
+
depth,
|
|
3624
|
+
selected: false,
|
|
3625
|
+
posInSet: updatedChildren.length + 1,
|
|
3626
|
+
setSize: existingChildren.length + 2,
|
|
3627
|
+
icon: ''
|
|
3628
|
+
};
|
|
3629
|
+
const allChildDirents = [...updatedChildren, newDirent];
|
|
3630
|
+
return allChildDirents;
|
|
3631
|
+
};
|
|
3632
|
+
|
|
3633
|
+
const getNewDirentsForNewDirent = async (items, focusedIndex, type, root) => {
|
|
3634
|
+
if (items.length === 0 || focusedIndex === -1) {
|
|
3635
|
+
const newDirent = {
|
|
3636
|
+
name: '',
|
|
3637
|
+
type,
|
|
3638
|
+
path: root,
|
|
3639
|
+
depth: 0,
|
|
3640
|
+
selected: false,
|
|
3641
|
+
posInSet: 1,
|
|
3642
|
+
setSize: 1,
|
|
3643
|
+
icon: ''
|
|
3644
|
+
};
|
|
3645
|
+
return [...items, newDirent];
|
|
3646
|
+
}
|
|
3647
|
+
const focusedItem = items[focusedIndex];
|
|
3648
|
+
if (!focusedItem) {
|
|
3649
|
+
return items;
|
|
3650
|
+
}
|
|
3651
|
+
const parentPath = focusedItem.path;
|
|
3652
|
+
const depth = focusedItem.depth + 1;
|
|
3653
|
+
const updatedChildren = await getNewChildDirentsForNewDirent(items, depth, parentPath, type);
|
|
3654
|
+
|
|
3655
|
+
// Create new array with updated items
|
|
3656
|
+
const parentIndex = focusedIndex;
|
|
3657
|
+
const itemsBeforeParent = items.slice(0, parentIndex);
|
|
3658
|
+
const itemsAfterChildren = items.slice(parentIndex + updatedChildren.length);
|
|
3659
|
+
const updatedParent = {
|
|
3660
|
+
...items[parentIndex],
|
|
3661
|
+
setSize: (items[parentIndex]?.setSize || 0) + 1
|
|
3662
|
+
};
|
|
3663
|
+
return [...itemsBeforeParent, updatedParent, ...updatedChildren, ...itemsAfterChildren];
|
|
3664
|
+
};
|
|
3665
|
+
|
|
3666
|
+
const getNewDirentType = editingType => {
|
|
3667
|
+
switch (editingType) {
|
|
3668
|
+
case CreateFile:
|
|
3669
|
+
return EditingFile;
|
|
3670
|
+
case CreateFolder:
|
|
3671
|
+
return EditingFolder;
|
|
3672
|
+
default:
|
|
3673
|
+
return File;
|
|
3674
|
+
}
|
|
3675
|
+
};
|
|
3676
|
+
|
|
3543
3677
|
const newDirent = async (state, editingType) => {
|
|
3544
3678
|
// TODO make focus functional instead of side effect
|
|
3545
3679
|
await setFocus(ExplorerEditBox);
|
|
3546
3680
|
// TODO do it like vscode, select position between folders and files
|
|
3547
3681
|
const {
|
|
3548
3682
|
focusedIndex,
|
|
3549
|
-
items
|
|
3683
|
+
items,
|
|
3684
|
+
minLineY,
|
|
3685
|
+
height,
|
|
3686
|
+
itemHeight,
|
|
3687
|
+
fileIconCache,
|
|
3688
|
+
root
|
|
3550
3689
|
} = state;
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
}
|
|
3690
|
+
const direntType = getNewDirentType(editingType);
|
|
3691
|
+
const newDirents = await getNewDirentsForNewDirent(items, focusedIndex, direntType, root);
|
|
3692
|
+
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
|
|
3693
|
+
const visible = newDirents.slice(minLineY, maxLineY);
|
|
3694
|
+
const {
|
|
3695
|
+
icons,
|
|
3696
|
+
newFileIconCache
|
|
3697
|
+
} = await getFileIcons(visible, fileIconCache);
|
|
3698
|
+
const editingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
|
|
3559
3699
|
return {
|
|
3560
3700
|
...state,
|
|
3561
|
-
|
|
3701
|
+
items: newDirents,
|
|
3702
|
+
editingIndex,
|
|
3562
3703
|
editingType,
|
|
3563
3704
|
editingValue: '',
|
|
3564
|
-
|
|
3705
|
+
focusedIndex: editingIndex,
|
|
3706
|
+
focus: Input$1,
|
|
3707
|
+
icons,
|
|
3708
|
+
fileIconCache: newFileIconCache,
|
|
3709
|
+
maxLineY
|
|
3565
3710
|
};
|
|
3566
3711
|
};
|
|
3567
3712
|
|
|
@@ -3665,6 +3810,17 @@ const removeDirent = async state => {
|
|
|
3665
3810
|
};
|
|
3666
3811
|
};
|
|
3667
3812
|
|
|
3813
|
+
const getNewDirentsForRename = (items, focusedIndex) => {
|
|
3814
|
+
const item = items[focusedIndex];
|
|
3815
|
+
const newItems = [...items];
|
|
3816
|
+
const editingType = item.type === File ? EditingFile : EditingFolder;
|
|
3817
|
+
newItems[focusedIndex] = {
|
|
3818
|
+
...item,
|
|
3819
|
+
type: editingType
|
|
3820
|
+
};
|
|
3821
|
+
return newItems;
|
|
3822
|
+
};
|
|
3823
|
+
|
|
3668
3824
|
const User = 1;
|
|
3669
3825
|
const Script = 2;
|
|
3670
3826
|
|
|
@@ -3673,9 +3829,14 @@ const renameDirent = state => {
|
|
|
3673
3829
|
focusedIndex,
|
|
3674
3830
|
items
|
|
3675
3831
|
} = state;
|
|
3832
|
+
if (items.length === 0) {
|
|
3833
|
+
return state;
|
|
3834
|
+
}
|
|
3676
3835
|
const item = items[focusedIndex];
|
|
3836
|
+
const newItems = getNewDirentsForRename(items, focusedIndex);
|
|
3677
3837
|
return {
|
|
3678
3838
|
...state,
|
|
3839
|
+
items: newItems,
|
|
3679
3840
|
editingIndex: focusedIndex,
|
|
3680
3841
|
editingType: Rename$1,
|
|
3681
3842
|
editingValue: item.name,
|
|
@@ -3756,14 +3917,15 @@ const WelcomeMessage = 'WelcomeMessage';
|
|
|
3756
3917
|
const HandleClick = 'handleClick';
|
|
3757
3918
|
const HandleClickOpenFolder = 'handleClickOpenFolder';
|
|
3758
3919
|
const HandleContextMenu = 'handleContextMenu';
|
|
3920
|
+
const HandleDragLeave = 'handleDragLeave';
|
|
3921
|
+
const HandleDragOver = 'handleDragOver';
|
|
3922
|
+
const HandleDrop = 'handleDrop';
|
|
3759
3923
|
const HandleEditingInput = 'handleEditingInput';
|
|
3924
|
+
const HandleInputBlur = 'handleInputBlur';
|
|
3760
3925
|
const HandleListBlur = 'handleListBlur';
|
|
3761
3926
|
const HandleListFocus = 'handleListFocus';
|
|
3762
3927
|
const HandlePointerDown = 'handlePointerDown';
|
|
3763
3928
|
const HandleWheel = 'handleWheel';
|
|
3764
|
-
const HandleDragOver = 'handleDragOver';
|
|
3765
|
-
const HandleDrop = 'handleDrop';
|
|
3766
|
-
const HandleDragLeave = 'handleDragLeave';
|
|
3767
3929
|
|
|
3768
3930
|
const mergeClassNames = (...classNames) => {
|
|
3769
3931
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -3822,6 +3984,7 @@ const getInputDom = hasEditingError => {
|
|
|
3822
3984
|
className: getClassName$2(hasEditingError),
|
|
3823
3985
|
id: 'ExplorerInput',
|
|
3824
3986
|
onInput: HandleEditingInput,
|
|
3987
|
+
onBlur: HandleInputBlur,
|
|
3825
3988
|
childCount: 0,
|
|
3826
3989
|
name: ExplorerInput
|
|
3827
3990
|
}];
|
|
@@ -4002,13 +4165,12 @@ const getClassName = (isSelected, isFocused) => {
|
|
|
4002
4165
|
}
|
|
4003
4166
|
return TreeItem;
|
|
4004
4167
|
};
|
|
4005
|
-
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets) => {
|
|
4168
|
+
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon) => {
|
|
4006
4169
|
const visible = [];
|
|
4007
4170
|
const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
|
|
4008
4171
|
let iconIndex = 0;
|
|
4009
4172
|
for (let i = minLineY; i < Math.min(maxLineY, items.length); i++) {
|
|
4010
4173
|
const item = items[i];
|
|
4011
|
-
const icon = icons[iconIndex++];
|
|
4012
4174
|
const chevron = getChevronType(item.type, useChevrons);
|
|
4013
4175
|
const indent = indentFn(item.depth, chevron);
|
|
4014
4176
|
const isFocused = i === focusedIndex;
|
|
@@ -4017,12 +4179,17 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
4017
4179
|
const className = getClassName(isSelected, isFocused);
|
|
4018
4180
|
const expanded = getExpandedType(item.type);
|
|
4019
4181
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
4020
|
-
|
|
4021
|
-
|
|
4182
|
+
const isEditing = i === editingIndex;
|
|
4183
|
+
let icon = icons[iconIndex++];
|
|
4184
|
+
if (isEditing) {
|
|
4185
|
+
icon = editingIcon;
|
|
4186
|
+
}
|
|
4022
4187
|
visible.push({
|
|
4023
4188
|
...item,
|
|
4024
|
-
|
|
4025
|
-
|
|
4189
|
+
posInSet: item.posInSet ?? i + 1,
|
|
4190
|
+
setSize: item.setSize ?? items.length,
|
|
4191
|
+
isEditing: isEditing,
|
|
4192
|
+
hasEditingError: isEditing && Boolean(editingErrorMessage),
|
|
4026
4193
|
icon,
|
|
4027
4194
|
indent,
|
|
4028
4195
|
ariaExpanded,
|
|
@@ -4031,29 +4198,11 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
4031
4198
|
className
|
|
4032
4199
|
});
|
|
4033
4200
|
}
|
|
4034
|
-
if (editingType !== None$5 && editingIndex === -1) {
|
|
4035
|
-
visible.push({
|
|
4036
|
-
depth: 3,
|
|
4037
|
-
posInSet: 1,
|
|
4038
|
-
setSize: 1,
|
|
4039
|
-
icon: '',
|
|
4040
|
-
name: 'new',
|
|
4041
|
-
path: '/test/new',
|
|
4042
|
-
isEditing: true,
|
|
4043
|
-
hasEditingError: Boolean(editingErrorMessage),
|
|
4044
|
-
indent: '',
|
|
4045
|
-
ariaExpanded: undefined,
|
|
4046
|
-
chevron: 0,
|
|
4047
|
-
id: undefined,
|
|
4048
|
-
className: TreeItem,
|
|
4049
|
-
selected: false
|
|
4050
|
-
});
|
|
4051
|
-
}
|
|
4052
4201
|
return visible;
|
|
4053
4202
|
};
|
|
4054
4203
|
|
|
4055
4204
|
const renderItems = (oldState, newState) => {
|
|
4056
|
-
const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.editingErrorMessage, newState.icons, newState.useChevrons);
|
|
4205
|
+
const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.editingErrorMessage, newState.icons, newState.useChevrons, newState.dropTargets, newState.editingIcon);
|
|
4057
4206
|
const isWide = newState.width > 450;
|
|
4058
4207
|
const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide, newState.focused, newState.dropTargets);
|
|
4059
4208
|
return ['Viewlet.setDom2', dom];
|
|
@@ -4193,8 +4342,8 @@ const renderActions = uid => {
|
|
|
4193
4342
|
|
|
4194
4343
|
const renderEventListeners = () => {
|
|
4195
4344
|
return [{
|
|
4196
|
-
name:
|
|
4197
|
-
params: ['
|
|
4345
|
+
name: HandleInputBlur,
|
|
4346
|
+
params: ['handleInputBlur']
|
|
4198
4347
|
}, {
|
|
4199
4348
|
name: HandleListFocus,
|
|
4200
4349
|
params: ['handleFocus', 'event.isTrusted', 'event.target.className']
|
|
@@ -4555,18 +4704,25 @@ const terminate = () => {
|
|
|
4555
4704
|
};
|
|
4556
4705
|
|
|
4557
4706
|
const getEditingIcon = async (editingType, value) => {
|
|
4558
|
-
if (editingType ===
|
|
4707
|
+
if (editingType === CreateFile) {
|
|
4708
|
+
return invoke('IconTheme.getFileIcon', {
|
|
4709
|
+
name: value
|
|
4710
|
+
});
|
|
4711
|
+
}
|
|
4712
|
+
// TODO need renamefile and renamefolder type
|
|
4713
|
+
if (editingType === Rename$1) {
|
|
4559
4714
|
return invoke('IconTheme.getFileIcon', {
|
|
4560
4715
|
name: value
|
|
4561
4716
|
});
|
|
4562
4717
|
}
|
|
4563
|
-
if (editingType ===
|
|
4718
|
+
if (editingType === CreateFolder) {
|
|
4564
4719
|
return invoke('IconTheme.getFolderIcon', {
|
|
4565
4720
|
name: value
|
|
4566
4721
|
});
|
|
4567
4722
|
}
|
|
4568
4723
|
return '';
|
|
4569
4724
|
};
|
|
4725
|
+
|
|
4570
4726
|
const updateEditingValue = async (state, value, inputSource = User) => {
|
|
4571
4727
|
const editingIcon = await getEditingIcon(state.editingType, value);
|
|
4572
4728
|
return {
|
|
@@ -4592,10 +4748,10 @@ const wrapCommand = fn => {
|
|
|
4592
4748
|
};
|
|
4593
4749
|
|
|
4594
4750
|
const commandMap = {
|
|
4595
|
-
'Explorer.getMenuEntries2': getMenuEntries2,
|
|
4596
4751
|
'Explorer.acceptEdit': wrapCommand(acceptEdit),
|
|
4597
4752
|
'Explorer.cancelEdit': wrapCommand(cancelEdit),
|
|
4598
4753
|
'Explorer.collapseAll': wrapCommand(collapseAll),
|
|
4754
|
+
'Explorer.handleInputBlur': wrapCommand(handleInputBlur),
|
|
4599
4755
|
'Explorer.copyPath': wrapCommand(copyPath),
|
|
4600
4756
|
'Explorer.copyRelativePath': wrapCommand(copyRelativePath),
|
|
4601
4757
|
'Explorer.expandAll': wrapCommand(expandAll),
|
|
@@ -4604,21 +4760,20 @@ const commandMap = {
|
|
|
4604
4760
|
'Explorer.focusIndex': wrapCommand(focusIndex),
|
|
4605
4761
|
'Explorer.focusLast': wrapCommand(focusLast),
|
|
4606
4762
|
'Explorer.focusNext': wrapCommand(focusNext),
|
|
4763
|
+
'Explorer.focusNone': wrapCommand(focusNone),
|
|
4607
4764
|
'Explorer.focusPrevious': wrapCommand(focusPrevious),
|
|
4608
4765
|
'Explorer.getCommandIds': getCommandIds,
|
|
4766
|
+
'Explorer.getMenuEntries2': getMenuEntries2,
|
|
4767
|
+
'Explorer.getMouseActions': getMouseActions,
|
|
4609
4768
|
'Explorer.handleArrowLeft': wrapCommand(handleArrowLeft),
|
|
4610
4769
|
'Explorer.handleArrowRight': wrapCommand(handleArrowRight),
|
|
4611
4770
|
'Explorer.handleBlur': wrapCommand(handleBlur),
|
|
4612
|
-
'Explorer.selectUp': wrapCommand(selectUp),
|
|
4613
|
-
'Explorer.selectDown': wrapCommand(selectDown),
|
|
4614
|
-
'Explorer.selectAll': wrapCommand(selectAll),
|
|
4615
4771
|
'Explorer.handleClick': wrapCommand(handleClick),
|
|
4616
4772
|
'Explorer.handleClickAt': wrapCommand(handleClickAt),
|
|
4617
4773
|
'Explorer.handleClickCurrent': wrapCommand(handleClickCurrent),
|
|
4618
4774
|
'Explorer.handleClickCurrentButKeepFocus': wrapCommand(handleClickCurrentButKeepFocus),
|
|
4619
4775
|
'Explorer.handleClickOpenFolder': wrapCommand(handleClickOpenFolder),
|
|
4620
4776
|
'Explorer.handleContextMenu': wrapCommand(handleContextMenu),
|
|
4621
|
-
'Explorer.getMouseActions': getMouseActions,
|
|
4622
4777
|
'Explorer.handleContextMenuKeyboard': wrapCommand(handleContextMenuKeyboard),
|
|
4623
4778
|
'Explorer.handleCopy': wrapCommand(handleCopy),
|
|
4624
4779
|
'Explorer.handleDragLeave': wrapCommand(handleDragLeave),
|
|
@@ -4640,10 +4795,13 @@ const commandMap = {
|
|
|
4640
4795
|
'Explorer.renameDirent': wrapCommand(renameDirent),
|
|
4641
4796
|
'Explorer.restoreState': restoreState,
|
|
4642
4797
|
'Explorer.revealItem': wrapCommand(revealItem),
|
|
4798
|
+
'Explorer.selectAll': wrapCommand(selectAll),
|
|
4799
|
+
'Explorer.selectDown': wrapCommand(selectDown),
|
|
4800
|
+
'Explorer.selectUp': wrapCommand(selectUp),
|
|
4643
4801
|
'Explorer.setDeltaY': wrapCommand(setDeltaY),
|
|
4802
|
+
'Explorer.setSelectedIndices': wrapCommand(setSelectedIndices),
|
|
4644
4803
|
'Explorer.updateEditingValue': wrapCommand(updateEditingValue),
|
|
4645
4804
|
'Explorer.updateIcons': wrapCommand(updateIcons),
|
|
4646
|
-
'Explorer.setSelectedIndices': wrapCommand(setSelectedIndices),
|
|
4647
4805
|
// not wrapped
|
|
4648
4806
|
'Explorer.create2': create2,
|
|
4649
4807
|
'Explorer.diff2': diff2,
|