@lvce-editor/explorer-view 2.24.0 → 2.26.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 +161 -54
- package/package.json +1 -1
|
@@ -894,6 +894,7 @@ const OpenInIntegratedTerminal = 'Open in integrated Terminal';
|
|
|
894
894
|
const Paste = 'Paste';
|
|
895
895
|
const RefreshExplorer = 'Refresh Explorer';
|
|
896
896
|
const Rename = 'Rename';
|
|
897
|
+
const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
|
|
897
898
|
const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
|
|
898
899
|
|
|
899
900
|
const newFile$1 = () => {
|
|
@@ -947,6 +948,9 @@ const openFolder$1 = () => {
|
|
|
947
948
|
const fileOrFolderNameMustBeProvided = () => {
|
|
948
949
|
return i18nString(FileOrFolderNameMustBeProvider);
|
|
949
950
|
};
|
|
951
|
+
const typeAFileName = () => {
|
|
952
|
+
return i18nString(TypeAFileName);
|
|
953
|
+
};
|
|
950
954
|
|
|
951
955
|
const List = 1;
|
|
952
956
|
const Input$1 = 2;
|
|
@@ -1000,6 +1004,7 @@ const SymLinkFolder = 11;
|
|
|
1000
1004
|
const Unknown = 12;
|
|
1001
1005
|
const EditingFile = File + DELTA_EDITING;
|
|
1002
1006
|
const EditingFolder = Directory + DELTA_EDITING;
|
|
1007
|
+
const EditingDirectoryExpanded = DirectoryExpanded + DELTA_EDITING;
|
|
1003
1008
|
|
|
1004
1009
|
const RendererWorker = 1;
|
|
1005
1010
|
|
|
@@ -1418,12 +1423,19 @@ const acceptEdit = async state => {
|
|
|
1418
1423
|
}
|
|
1419
1424
|
};
|
|
1420
1425
|
|
|
1426
|
+
const normalizeDirentType = direntType => {
|
|
1427
|
+
if (direntType > DELTA_EDITING) {
|
|
1428
|
+
return direntType - DELTA_EDITING;
|
|
1429
|
+
}
|
|
1430
|
+
return direntType;
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1421
1433
|
const getNewDirentsForCancelRename = (items, editingIndex) => {
|
|
1422
1434
|
const item = items[editingIndex];
|
|
1423
1435
|
const newItems = [...items];
|
|
1424
1436
|
newItems[editingIndex] = {
|
|
1425
1437
|
...item,
|
|
1426
|
-
type: item.type
|
|
1438
|
+
type: normalizeDirentType(item.type)
|
|
1427
1439
|
};
|
|
1428
1440
|
return newItems;
|
|
1429
1441
|
};
|
|
@@ -1574,7 +1586,11 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
1574
1586
|
platform,
|
|
1575
1587
|
focus: 0,
|
|
1576
1588
|
editingErrorMessage: '',
|
|
1577
|
-
inputSource: 0
|
|
1589
|
+
inputSource: 0,
|
|
1590
|
+
editingSelection: {
|
|
1591
|
+
start: 0,
|
|
1592
|
+
end: 0
|
|
1593
|
+
}
|
|
1578
1594
|
};
|
|
1579
1595
|
set(uid, state, state);
|
|
1580
1596
|
};
|
|
@@ -1611,7 +1627,11 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1611
1627
|
platform,
|
|
1612
1628
|
focus: 0,
|
|
1613
1629
|
editingErrorMessage: '',
|
|
1614
|
-
inputSource: 0
|
|
1630
|
+
inputSource: 0,
|
|
1631
|
+
editingSelection: {
|
|
1632
|
+
start: 0,
|
|
1633
|
+
end: 0
|
|
1634
|
+
}
|
|
1615
1635
|
};
|
|
1616
1636
|
set(state.uid, state, state);
|
|
1617
1637
|
return state;
|
|
@@ -1621,15 +1641,21 @@ const RenderItems = 4;
|
|
|
1621
1641
|
const RenderFocus = 6;
|
|
1622
1642
|
const RenderFocusContext = 7;
|
|
1623
1643
|
const RenderValue = 8;
|
|
1644
|
+
const RenderSelection = 9;
|
|
1624
1645
|
|
|
1625
|
-
const diffType$
|
|
1626
|
-
const isEqual$
|
|
1646
|
+
const diffType$3 = RenderFocus;
|
|
1647
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1627
1648
|
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
1628
1649
|
};
|
|
1629
1650
|
|
|
1630
|
-
const diffType$
|
|
1651
|
+
const diffType$2 = RenderItems;
|
|
1652
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1653
|
+
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;
|
|
1654
|
+
};
|
|
1655
|
+
|
|
1656
|
+
const diffType$1 = RenderSelection;
|
|
1631
1657
|
const isEqual$2 = (oldState, newState) => {
|
|
1632
|
-
return oldState.
|
|
1658
|
+
return oldState.editingSelection.start === newState.editingSelection.start && oldState.editingSelection.end === newState.editingSelection.end;
|
|
1633
1659
|
};
|
|
1634
1660
|
|
|
1635
1661
|
const diffType = RenderValue;
|
|
@@ -1640,8 +1666,8 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1640
1666
|
return oldState.focus === Input$1 && newState.focus === Input$1 && oldState.editingValue === newState.editingValue;
|
|
1641
1667
|
};
|
|
1642
1668
|
|
|
1643
|
-
const modules = [isEqual$
|
|
1644
|
-
const numbers = [diffType$
|
|
1669
|
+
const modules = [isEqual$3, isEqual$4, isEqual$4, isEqual$1, isEqual$2];
|
|
1670
|
+
const numbers = [diffType$2, diffType$3, RenderFocusContext, diffType, diffType$1];
|
|
1645
1671
|
|
|
1646
1672
|
const diff = (oldState, newState) => {
|
|
1647
1673
|
const diffResult = [];
|
|
@@ -2046,7 +2072,7 @@ const focusPrevious = state => {
|
|
|
2046
2072
|
}
|
|
2047
2073
|
};
|
|
2048
2074
|
|
|
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'];
|
|
2075
|
+
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', 'handleInputClick', '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'];
|
|
2050
2076
|
|
|
2051
2077
|
const getCommandIds = () => {
|
|
2052
2078
|
return commandIds;
|
|
@@ -2597,6 +2623,18 @@ const getClickFn = direntType => {
|
|
|
2597
2623
|
}
|
|
2598
2624
|
};
|
|
2599
2625
|
|
|
2626
|
+
const resetEditing = {
|
|
2627
|
+
editingIndex: -1,
|
|
2628
|
+
editingValue: '',
|
|
2629
|
+
editingType: None$5,
|
|
2630
|
+
editingIcon: '',
|
|
2631
|
+
editingErrorMessage: '',
|
|
2632
|
+
editingSelection: {
|
|
2633
|
+
start: 0,
|
|
2634
|
+
end: 0
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
|
|
2600
2638
|
// TODO viewlet should only have create and refresh functions
|
|
2601
2639
|
// every thing else can be in a separate module <viewlet>.lazy.js
|
|
2602
2640
|
// and <viewlet>.ipc.js
|
|
@@ -2626,8 +2664,16 @@ const handleClick = async (state, index, keepFocus = false) => {
|
|
|
2626
2664
|
console.warn(`[explorer] dirent at index ${actualIndex} not found`, state);
|
|
2627
2665
|
return state;
|
|
2628
2666
|
}
|
|
2629
|
-
const
|
|
2630
|
-
|
|
2667
|
+
const normalizedType = normalizeDirentType(dirent.type);
|
|
2668
|
+
const clickFn = getClickFn(normalizedType);
|
|
2669
|
+
const newState = await clickFn(state, dirent, actualIndex, keepFocus);
|
|
2670
|
+
if (newState.editingIndex === -1) {
|
|
2671
|
+
return newState;
|
|
2672
|
+
}
|
|
2673
|
+
return {
|
|
2674
|
+
...newState,
|
|
2675
|
+
...resetEditing
|
|
2676
|
+
};
|
|
2631
2677
|
};
|
|
2632
2678
|
|
|
2633
2679
|
// export const handleBlur=()=>{}
|
|
@@ -2687,7 +2733,10 @@ const handleClickAtRangeSelection = async (state, index) => {
|
|
|
2687
2733
|
return handleRangeSelection(state, min, max);
|
|
2688
2734
|
};
|
|
2689
2735
|
|
|
2690
|
-
const handleClickAt = async (state, button, ctrlKey, shiftKey, x, y) => {
|
|
2736
|
+
const handleClickAt = async (state, defaultPrevented, button, ctrlKey, shiftKey, x, y) => {
|
|
2737
|
+
if (defaultPrevented) {
|
|
2738
|
+
return state;
|
|
2739
|
+
}
|
|
2691
2740
|
if (button !== LeftClick) {
|
|
2692
2741
|
return state;
|
|
2693
2742
|
}
|
|
@@ -3242,6 +3291,10 @@ const handleInputBlur = state => {
|
|
|
3242
3291
|
return cancelEdit(state);
|
|
3243
3292
|
};
|
|
3244
3293
|
|
|
3294
|
+
const handleInputClick = state => {
|
|
3295
|
+
return state;
|
|
3296
|
+
};
|
|
3297
|
+
|
|
3245
3298
|
// TODO add lots of tests for this
|
|
3246
3299
|
const updateRoot = async state1 => {
|
|
3247
3300
|
// @ts-ignore
|
|
@@ -3827,7 +3880,9 @@ const Script = 2;
|
|
|
3827
3880
|
const renameDirent = state => {
|
|
3828
3881
|
const {
|
|
3829
3882
|
focusedIndex,
|
|
3830
|
-
items
|
|
3883
|
+
items,
|
|
3884
|
+
icons,
|
|
3885
|
+
minLineY
|
|
3831
3886
|
} = state;
|
|
3832
3887
|
if (items.length === 0) {
|
|
3833
3888
|
return state;
|
|
@@ -3840,11 +3895,20 @@ const renameDirent = state => {
|
|
|
3840
3895
|
editingIndex: focusedIndex,
|
|
3841
3896
|
editingType: Rename$1,
|
|
3842
3897
|
editingValue: item.name,
|
|
3898
|
+
editingIcon: icons[focusedIndex - minLineY],
|
|
3899
|
+
editingSelection: {
|
|
3900
|
+
start: 0,
|
|
3901
|
+
end: item.name.length
|
|
3902
|
+
},
|
|
3843
3903
|
focus: Input$1,
|
|
3844
3904
|
inputSource: Script
|
|
3845
3905
|
};
|
|
3846
3906
|
};
|
|
3847
3907
|
|
|
3908
|
+
const renderEditingSelection = (oldState, newState) => {
|
|
3909
|
+
return ['Viewlet.setSelection', newState.editingSelection];
|
|
3910
|
+
};
|
|
3911
|
+
|
|
3848
3912
|
const ExplorerInput = 'ExplorerInput';
|
|
3849
3913
|
|
|
3850
3914
|
const renderFocus$1 = (oldState, newState) => {
|
|
@@ -3892,6 +3956,7 @@ const FocusOutline = 'FocusOutline';
|
|
|
3892
3956
|
const ListItems = 'ListItems';
|
|
3893
3957
|
const IconButton = 'IconButton';
|
|
3894
3958
|
const InputBox = 'InputBox';
|
|
3959
|
+
const ExplorerInputBox = 'ExplorerInputBox';
|
|
3895
3960
|
const InputValidationError = 'InputValidationError';
|
|
3896
3961
|
const Label = 'Label';
|
|
3897
3962
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
@@ -3922,6 +3987,7 @@ const HandleDragOver = 'handleDragOver';
|
|
|
3922
3987
|
const HandleDrop = 'handleDrop';
|
|
3923
3988
|
const HandleEditingInput = 'handleEditingInput';
|
|
3924
3989
|
const HandleInputBlur = 'handleInputBlur';
|
|
3990
|
+
const HandleInputClick = 'handleInputClick';
|
|
3925
3991
|
const HandleListBlur = 'handleListBlur';
|
|
3926
3992
|
const HandleListFocus = 'handleListFocus';
|
|
3927
3993
|
const HandlePointerDown = 'handlePointerDown';
|
|
@@ -3972,21 +4038,28 @@ const getFileIconVirtualDom = icon => {
|
|
|
3972
4038
|
};
|
|
3973
4039
|
};
|
|
3974
4040
|
|
|
3975
|
-
const
|
|
4041
|
+
const getInputClassName = hasEditingError => {
|
|
3976
4042
|
if (hasEditingError) {
|
|
3977
|
-
return mergeClassNames(InputBox, InputValidationError);
|
|
4043
|
+
return mergeClassNames(InputBox, ExplorerInputBox, InputValidationError);
|
|
3978
4044
|
}
|
|
3979
|
-
return InputBox;
|
|
4045
|
+
return mergeClassNames(InputBox, ExplorerInputBox);
|
|
3980
4046
|
};
|
|
4047
|
+
|
|
3981
4048
|
const getInputDom = hasEditingError => {
|
|
4049
|
+
const ariaLabel = typeAFileName();
|
|
3982
4050
|
return [{
|
|
3983
4051
|
type: Input,
|
|
3984
|
-
|
|
4052
|
+
ariaLabel: ariaLabel,
|
|
4053
|
+
autocapitalize: 'off',
|
|
4054
|
+
autocorrect: 'off',
|
|
4055
|
+
childCount: 0,
|
|
4056
|
+
className: getInputClassName(hasEditingError),
|
|
3985
4057
|
id: 'ExplorerInput',
|
|
3986
|
-
|
|
4058
|
+
name: ExplorerInput,
|
|
3987
4059
|
onBlur: HandleInputBlur,
|
|
3988
|
-
|
|
3989
|
-
|
|
4060
|
+
onClick: HandleInputClick,
|
|
4061
|
+
onInput: HandleEditingInput,
|
|
4062
|
+
spellcheck: 'false'
|
|
3990
4063
|
}];
|
|
3991
4064
|
};
|
|
3992
4065
|
|
|
@@ -3995,31 +4068,35 @@ const label = {
|
|
|
3995
4068
|
className: Label,
|
|
3996
4069
|
childCount: 1
|
|
3997
4070
|
};
|
|
4071
|
+
const getLabelDom = name => {
|
|
4072
|
+
return [label, text(name)];
|
|
4073
|
+
};
|
|
4074
|
+
|
|
3998
4075
|
const getInputOrLabelDom = (isEditing, hasEditingError, name) => {
|
|
3999
4076
|
if (isEditing) {
|
|
4000
4077
|
return getInputDom(hasEditingError);
|
|
4001
4078
|
}
|
|
4002
|
-
return
|
|
4079
|
+
return getLabelDom(name);
|
|
4003
4080
|
};
|
|
4004
4081
|
|
|
4005
4082
|
const getExplorerItemVirtualDom = item => {
|
|
4006
4083
|
const {
|
|
4007
|
-
|
|
4008
|
-
setSize,
|
|
4009
|
-
icon,
|
|
4010
|
-
name,
|
|
4011
|
-
path,
|
|
4012
|
-
depth,
|
|
4013
|
-
indent,
|
|
4084
|
+
ariaExpanded,
|
|
4014
4085
|
chevron,
|
|
4015
|
-
id,
|
|
4016
4086
|
className,
|
|
4087
|
+
depth,
|
|
4088
|
+
hasEditingError,
|
|
4089
|
+
icon,
|
|
4090
|
+
id,
|
|
4091
|
+
indent,
|
|
4017
4092
|
isEditing,
|
|
4018
|
-
|
|
4019
|
-
|
|
4093
|
+
name,
|
|
4094
|
+
path,
|
|
4095
|
+
setSize,
|
|
4096
|
+
posInSet
|
|
4020
4097
|
} = item;
|
|
4021
4098
|
const chevronDom = getChevronVirtualDom(chevron);
|
|
4022
|
-
|
|
4099
|
+
return [{
|
|
4023
4100
|
type: Div,
|
|
4024
4101
|
role: TreeItem$1,
|
|
4025
4102
|
className,
|
|
@@ -4035,7 +4112,6 @@ const getExplorerItemVirtualDom = item => {
|
|
|
4035
4112
|
ariaDescription: '',
|
|
4036
4113
|
id
|
|
4037
4114
|
}, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name)];
|
|
4038
|
-
return dom;
|
|
4039
4115
|
};
|
|
4040
4116
|
|
|
4041
4117
|
const getExplorerWelcomeVirtualDom = isWide => {
|
|
@@ -4066,7 +4142,7 @@ const getActiveDescendant = focusedIndex => {
|
|
|
4066
4142
|
}
|
|
4067
4143
|
return undefined;
|
|
4068
4144
|
};
|
|
4069
|
-
const getClassName
|
|
4145
|
+
const getClassName = (focused, focusedIndex, dropTarget) => {
|
|
4070
4146
|
const extraClass1 = focused && focusedIndex === -1 ? FocusOutline : Empty;
|
|
4071
4147
|
const extraClass2 = dropTarget === dropTargetFull ? ExplorerDropTarget : Empty;
|
|
4072
4148
|
const className = mergeClassNames(ListItems, extraClass1, extraClass2);
|
|
@@ -4084,7 +4160,7 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
|
|
|
4084
4160
|
}
|
|
4085
4161
|
const dom = [parentNode, {
|
|
4086
4162
|
type: Div,
|
|
4087
|
-
className: getClassName
|
|
4163
|
+
className: getClassName(focused, focusedIndex, dropTargets),
|
|
4088
4164
|
tabIndex: 0,
|
|
4089
4165
|
role: Tree,
|
|
4090
4166
|
ariaLabel: filesExplorer(),
|
|
@@ -4138,6 +4214,18 @@ const getExpandedType = type => {
|
|
|
4138
4214
|
}
|
|
4139
4215
|
};
|
|
4140
4216
|
|
|
4217
|
+
const focused = mergeClassNames(TreeItem, TreeItemActive);
|
|
4218
|
+
const selected = mergeClassNames(TreeItem, TreeItemActive);
|
|
4219
|
+
const getTreeItemClassName = (isSelected, isFocused) => {
|
|
4220
|
+
if (isFocused) {
|
|
4221
|
+
return focused;
|
|
4222
|
+
}
|
|
4223
|
+
if (isSelected) {
|
|
4224
|
+
return selected;
|
|
4225
|
+
}
|
|
4226
|
+
return TreeItem;
|
|
4227
|
+
};
|
|
4228
|
+
|
|
4141
4229
|
const defaultIndent$1 = 1;
|
|
4142
4230
|
const getTreeItemIndent = depth => {
|
|
4143
4231
|
return `${depth * defaultIndent$1}rem`;
|
|
@@ -4156,14 +4244,15 @@ const getTreeItemIndentWithChevron = (depth, chevron) => {
|
|
|
4156
4244
|
};
|
|
4157
4245
|
|
|
4158
4246
|
const ariaExpandedValues = [undefined, 'true', 'false'];
|
|
4159
|
-
const
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4247
|
+
const getEditingChevron = direntType => {
|
|
4248
|
+
switch (direntType) {
|
|
4249
|
+
case EditingDirectoryExpanded:
|
|
4250
|
+
return Down;
|
|
4251
|
+
case EditingFolder:
|
|
4252
|
+
return Right;
|
|
4253
|
+
default:
|
|
4254
|
+
return None$1;
|
|
4165
4255
|
}
|
|
4166
|
-
return TreeItem;
|
|
4167
4256
|
};
|
|
4168
4257
|
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon) => {
|
|
4169
4258
|
const visible = [];
|
|
@@ -4171,19 +4260,20 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
4171
4260
|
let iconIndex = 0;
|
|
4172
4261
|
for (let i = minLineY; i < Math.min(maxLineY, items.length); i++) {
|
|
4173
4262
|
const item = items[i];
|
|
4174
|
-
|
|
4175
|
-
const indent = indentFn(item.depth, chevron);
|
|
4263
|
+
let chevron = getChevronType(item.type, useChevrons);
|
|
4176
4264
|
const isFocused = i === focusedIndex;
|
|
4177
4265
|
const id = isFocused ? 'TreeItemActive' : undefined;
|
|
4178
4266
|
const isSelected = item.selected;
|
|
4179
|
-
const className =
|
|
4267
|
+
const className = getTreeItemClassName(isSelected, isFocused);
|
|
4180
4268
|
const expanded = getExpandedType(item.type);
|
|
4181
4269
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
4182
4270
|
const isEditing = i === editingIndex;
|
|
4183
4271
|
let icon = icons[iconIndex++];
|
|
4184
4272
|
if (isEditing) {
|
|
4185
4273
|
icon = editingIcon;
|
|
4274
|
+
chevron = getEditingChevron(item.type);
|
|
4186
4275
|
}
|
|
4276
|
+
const indent = indentFn(item.depth, chevron);
|
|
4187
4277
|
visible.push({
|
|
4188
4278
|
...item,
|
|
4189
4279
|
posInSet: item.posInSet ?? i + 1,
|
|
@@ -4228,6 +4318,8 @@ const getRenderer = diffType => {
|
|
|
4228
4318
|
return renderFocus;
|
|
4229
4319
|
case RenderValue:
|
|
4230
4320
|
return renderValue;
|
|
4321
|
+
case RenderSelection:
|
|
4322
|
+
return renderEditingSelection;
|
|
4231
4323
|
default:
|
|
4232
4324
|
throw new Error('unknown renderer');
|
|
4233
4325
|
}
|
|
@@ -4236,6 +4328,10 @@ const getRenderer = diffType => {
|
|
|
4236
4328
|
const applyRender = (oldState, newState, diffResult) => {
|
|
4237
4329
|
const commands = [];
|
|
4238
4330
|
for (const item of diffResult) {
|
|
4331
|
+
if (item === RenderSelection) {
|
|
4332
|
+
// TODO support this in the future
|
|
4333
|
+
continue;
|
|
4334
|
+
}
|
|
4239
4335
|
const fn = getRenderer(item);
|
|
4240
4336
|
const result = fn(oldState, newState);
|
|
4241
4337
|
if (result.length > 0) {
|
|
@@ -4352,7 +4448,11 @@ const renderEventListeners = () => {
|
|
|
4352
4448
|
params: ['handleBlur']
|
|
4353
4449
|
}, {
|
|
4354
4450
|
name: HandleClick,
|
|
4355
|
-
params: ['handleClickAt', 'event.button', 'event.ctrlKey', 'event.shiftKey', 'event.clientX', 'event.clientY'],
|
|
4451
|
+
params: ['handleClickAt', 'event.defaultPrevented', 'event.button', 'event.ctrlKey', 'event.shiftKey', 'event.clientX', 'event.clientY'],
|
|
4452
|
+
preventDefault: true
|
|
4453
|
+
}, {
|
|
4454
|
+
name: HandleInputClick,
|
|
4455
|
+
params: ['handleInputClick'],
|
|
4356
4456
|
preventDefault: true
|
|
4357
4457
|
}, {
|
|
4358
4458
|
name: HandleClickOpenFolder,
|
|
@@ -4703,17 +4803,23 @@ const terminate = () => {
|
|
|
4703
4803
|
globalThis.close();
|
|
4704
4804
|
};
|
|
4705
4805
|
|
|
4706
|
-
const getEditingIcon = async (editingType, value) => {
|
|
4806
|
+
const getEditingIcon = async (editingType, value, direntType) => {
|
|
4707
4807
|
if (editingType === CreateFile) {
|
|
4708
4808
|
return invoke('IconTheme.getFileIcon', {
|
|
4709
4809
|
name: value
|
|
4710
4810
|
});
|
|
4711
4811
|
}
|
|
4712
|
-
// TODO need renamefile and renamefolder type
|
|
4713
4812
|
if (editingType === Rename$1) {
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4813
|
+
if (direntType === File || direntType === EditingFile) {
|
|
4814
|
+
return invoke('IconTheme.getFileIcon', {
|
|
4815
|
+
name: value
|
|
4816
|
+
});
|
|
4817
|
+
}
|
|
4818
|
+
if (direntType === Directory || direntType === EditingFolder) {
|
|
4819
|
+
return invoke('IconTheme.getFolderIcon', {
|
|
4820
|
+
name: value
|
|
4821
|
+
});
|
|
4822
|
+
}
|
|
4717
4823
|
}
|
|
4718
4824
|
if (editingType === CreateFolder) {
|
|
4719
4825
|
return invoke('IconTheme.getFolderIcon', {
|
|
@@ -4724,7 +4830,7 @@ const getEditingIcon = async (editingType, value) => {
|
|
|
4724
4830
|
};
|
|
4725
4831
|
|
|
4726
4832
|
const updateEditingValue = async (state, value, inputSource = User) => {
|
|
4727
|
-
const editingIcon = await getEditingIcon(state.editingType, value);
|
|
4833
|
+
const editingIcon = await getEditingIcon(state.editingType, value, state.items[state.editingIndex]?.type);
|
|
4728
4834
|
return {
|
|
4729
4835
|
...state,
|
|
4730
4836
|
editingValue: value,
|
|
@@ -4751,7 +4857,6 @@ const commandMap = {
|
|
|
4751
4857
|
'Explorer.acceptEdit': wrapCommand(acceptEdit),
|
|
4752
4858
|
'Explorer.cancelEdit': wrapCommand(cancelEdit),
|
|
4753
4859
|
'Explorer.collapseAll': wrapCommand(collapseAll),
|
|
4754
|
-
'Explorer.handleInputBlur': wrapCommand(handleInputBlur),
|
|
4755
4860
|
'Explorer.copyPath': wrapCommand(copyPath),
|
|
4756
4861
|
'Explorer.copyRelativePath': wrapCommand(copyRelativePath),
|
|
4757
4862
|
'Explorer.expandAll': wrapCommand(expandAll),
|
|
@@ -4781,6 +4886,8 @@ const commandMap = {
|
|
|
4781
4886
|
'Explorer.handleDrop': wrapCommand(handleDrop),
|
|
4782
4887
|
'Explorer.handleFocus': wrapCommand(handleFocus),
|
|
4783
4888
|
'Explorer.handleIconThemeChange': wrapCommand(handleIconThemeChange),
|
|
4889
|
+
'Explorer.handleInputBlur': wrapCommand(handleInputBlur),
|
|
4890
|
+
'Explorer.handleInputClick': wrapCommand(handleInputClick),
|
|
4784
4891
|
'Explorer.handlePaste': wrapCommand(handlePaste),
|
|
4785
4892
|
'Explorer.handlePointerDown': wrapCommand(handlePointerDown),
|
|
4786
4893
|
'Explorer.handleUpload': wrapCommand(handleUpload),
|