@lvce-editor/explorer-view 2.17.0 → 2.19.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 +120 -18
- package/package.json +1 -1
|
@@ -1107,13 +1107,16 @@ const getNewDirentsAccept = async (state, newDirentType, createFn) => {
|
|
|
1107
1107
|
const depth = parentDirent.depth + 1;
|
|
1108
1108
|
const newDirent = {
|
|
1109
1109
|
path: absolutePath,
|
|
1110
|
+
// @ts-ignore
|
|
1110
1111
|
posInSet: -1,
|
|
1111
1112
|
setSize: 1,
|
|
1112
1113
|
depth,
|
|
1113
1114
|
name: newFileName,
|
|
1114
1115
|
type: newDirentType,
|
|
1115
|
-
icon: ''
|
|
1116
|
+
icon: '',
|
|
1117
|
+
selected: false
|
|
1116
1118
|
};
|
|
1119
|
+
// @ts-ignore
|
|
1117
1120
|
newDirent.icon = '';
|
|
1118
1121
|
let insertIndex = state.focusedIndex;
|
|
1119
1122
|
let deltaPosInSet = 0;
|
|
@@ -1147,7 +1150,9 @@ const getNewDirentsAccept = async (state, newDirentType, createFn) => {
|
|
|
1147
1150
|
// @ts-ignore
|
|
1148
1151
|
dirent.posInSet += deltaPosInSet;
|
|
1149
1152
|
}
|
|
1153
|
+
// @ts-ignore
|
|
1150
1154
|
newDirent.setSize = setSize;
|
|
1155
|
+
// @ts-ignore
|
|
1151
1156
|
newDirent.posInSet = posInSet;
|
|
1152
1157
|
// @ts-ignore
|
|
1153
1158
|
items.splice(insertIndex + 1, 0, newDirent);
|
|
@@ -1573,6 +1578,7 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1573
1578
|
|
|
1574
1579
|
const RenderItems = 4;
|
|
1575
1580
|
const RenderFocus = 6;
|
|
1581
|
+
const RenderFocusContext = 7;
|
|
1576
1582
|
|
|
1577
1583
|
const diffType$1 = RenderFocus;
|
|
1578
1584
|
const isEqual$2 = (oldState, newState) => {
|
|
@@ -1584,8 +1590,8 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1584
1590
|
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;
|
|
1585
1591
|
};
|
|
1586
1592
|
|
|
1587
|
-
const modules = [isEqual$1, isEqual$2];
|
|
1588
|
-
const numbers = [diffType, diffType$1];
|
|
1593
|
+
const modules = [isEqual$1, isEqual$2, isEqual$2];
|
|
1594
|
+
const numbers = [diffType, diffType$1, RenderFocusContext];
|
|
1589
1595
|
|
|
1590
1596
|
const diff = (oldState, newState) => {
|
|
1591
1597
|
const diffResult = [];
|
|
@@ -1872,12 +1878,18 @@ const expandRecursively = async state => {
|
|
|
1872
1878
|
const focusIndex = (state, index) => {
|
|
1873
1879
|
const {
|
|
1874
1880
|
minLineY,
|
|
1875
|
-
maxLineY
|
|
1881
|
+
maxLineY,
|
|
1882
|
+
items
|
|
1876
1883
|
} = state;
|
|
1884
|
+
const newItems = items.map((item, i) => ({
|
|
1885
|
+
...item,
|
|
1886
|
+
selected: i === index ? true : false
|
|
1887
|
+
}));
|
|
1877
1888
|
if (index < minLineY) {
|
|
1878
1889
|
if (index < 0) {
|
|
1879
1890
|
return {
|
|
1880
1891
|
...state,
|
|
1892
|
+
items: newItems,
|
|
1881
1893
|
focusedIndex: index,
|
|
1882
1894
|
focused: true
|
|
1883
1895
|
};
|
|
@@ -1885,6 +1897,7 @@ const focusIndex = (state, index) => {
|
|
|
1885
1897
|
const diff = maxLineY - minLineY;
|
|
1886
1898
|
return {
|
|
1887
1899
|
...state,
|
|
1900
|
+
items: newItems,
|
|
1888
1901
|
focusedIndex: index,
|
|
1889
1902
|
focused: true,
|
|
1890
1903
|
minLineY: index,
|
|
@@ -1895,6 +1908,7 @@ const focusIndex = (state, index) => {
|
|
|
1895
1908
|
const diff = maxLineY - minLineY;
|
|
1896
1909
|
return {
|
|
1897
1910
|
...state,
|
|
1911
|
+
items: newItems,
|
|
1898
1912
|
focusedIndex: index,
|
|
1899
1913
|
focused: true,
|
|
1900
1914
|
minLineY: index + 1 - diff,
|
|
@@ -1903,6 +1917,7 @@ const focusIndex = (state, index) => {
|
|
|
1903
1917
|
}
|
|
1904
1918
|
return {
|
|
1905
1919
|
...state,
|
|
1920
|
+
items: newItems,
|
|
1906
1921
|
focusedIndex: index,
|
|
1907
1922
|
focused: true
|
|
1908
1923
|
};
|
|
@@ -1971,7 +1986,7 @@ const focusPrevious = state => {
|
|
|
1971
1986
|
}
|
|
1972
1987
|
};
|
|
1973
1988
|
|
|
1974
|
-
const commandIds = ['
|
|
1989
|
+
const commandIds = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'selectUp', 'selectDown', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', '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', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'setDeltaY', 'updateEditingValue', 'updateIcons'];
|
|
1975
1990
|
|
|
1976
1991
|
const getCommandIds = () => {
|
|
1977
1992
|
return commandIds;
|
|
@@ -1993,6 +2008,7 @@ const F2 = 58;
|
|
|
1993
2008
|
const Star = 131;
|
|
1994
2009
|
|
|
1995
2010
|
const CtrlCmd = 1 << 11 >>> 0;
|
|
2011
|
+
const Shift = 1 << 10 >>> 0;
|
|
1996
2012
|
const Alt = 1 << 9 >>> 0;
|
|
1997
2013
|
|
|
1998
2014
|
const FocusExplorer = 13;
|
|
@@ -2000,6 +2016,14 @@ const FocusExplorerEditBox = 14;
|
|
|
2000
2016
|
|
|
2001
2017
|
const getKeyBindings = () => {
|
|
2002
2018
|
return [{
|
|
2019
|
+
key: Shift | UpArrow,
|
|
2020
|
+
command: 'Explorer.selectUp',
|
|
2021
|
+
when: FocusExplorer
|
|
2022
|
+
}, {
|
|
2023
|
+
key: Shift | DownArrow,
|
|
2024
|
+
command: 'Explorer.selectDown',
|
|
2025
|
+
when: FocusExplorer
|
|
2026
|
+
}, {
|
|
2003
2027
|
key: RightArrow,
|
|
2004
2028
|
command: 'Explorer.handleArrowRight',
|
|
2005
2029
|
when: FocusExplorer
|
|
@@ -2538,7 +2562,7 @@ const getIndexFromPosition = (state, eventX, eventY) => {
|
|
|
2538
2562
|
const Keyboard = -1;
|
|
2539
2563
|
const LeftClick = 0;
|
|
2540
2564
|
|
|
2541
|
-
const handleClickAt = (state, button, x, y) => {
|
|
2565
|
+
const handleClickAt = (state, button, ctrlKey, shiftKey, x, y) => {
|
|
2542
2566
|
if (button !== LeftClick) {
|
|
2543
2567
|
return state;
|
|
2544
2568
|
}
|
|
@@ -3569,12 +3593,12 @@ const renameDirent = state => {
|
|
|
3569
3593
|
items
|
|
3570
3594
|
} = state;
|
|
3571
3595
|
const item = items[focusedIndex];
|
|
3572
|
-
// Focus.setFocus(FocusKey.ExplorerEditBox)
|
|
3573
3596
|
return {
|
|
3574
3597
|
...state,
|
|
3575
3598
|
editingIndex: focusedIndex,
|
|
3576
3599
|
editingType: Rename$1,
|
|
3577
|
-
editingValue: item.name
|
|
3600
|
+
editingValue: item.name,
|
|
3601
|
+
focus: Input$1
|
|
3578
3602
|
};
|
|
3579
3603
|
};
|
|
3580
3604
|
|
|
@@ -3582,7 +3606,7 @@ const ExplorerInput = 'ExplorerInput';
|
|
|
3582
3606
|
|
|
3583
3607
|
const User = 1;
|
|
3584
3608
|
|
|
3585
|
-
const renderFocus = (oldState, newState) => {
|
|
3609
|
+
const renderFocus$1 = (oldState, newState) => {
|
|
3586
3610
|
if (newState.inputSource === User) {
|
|
3587
3611
|
return [];
|
|
3588
3612
|
}
|
|
@@ -3598,6 +3622,16 @@ const renderFocus = (oldState, newState) => {
|
|
|
3598
3622
|
return [];
|
|
3599
3623
|
};
|
|
3600
3624
|
|
|
3625
|
+
const renderFocus = (oldState, newState) => {
|
|
3626
|
+
if (newState.focus === Input$1) {
|
|
3627
|
+
return ['Viewlet.setFocusContext', FocusExplorerEditBox];
|
|
3628
|
+
}
|
|
3629
|
+
if (newState.focus === List) {
|
|
3630
|
+
return ['Viewlet.setFocusContext', FocusExplorer];
|
|
3631
|
+
}
|
|
3632
|
+
return [];
|
|
3633
|
+
};
|
|
3634
|
+
|
|
3601
3635
|
const None$2 = 'none';
|
|
3602
3636
|
const ToolBar = 'toolbar';
|
|
3603
3637
|
const Tree = 'tree';
|
|
@@ -3696,7 +3730,7 @@ const getFileIconVirtualDom = icon => {
|
|
|
3696
3730
|
};
|
|
3697
3731
|
};
|
|
3698
3732
|
|
|
3699
|
-
const getClassName$
|
|
3733
|
+
const getClassName$2 = hasEditingError => {
|
|
3700
3734
|
if (hasEditingError) {
|
|
3701
3735
|
return mergeClassNames(InputBox, InputValidationError);
|
|
3702
3736
|
}
|
|
@@ -3705,7 +3739,7 @@ const getClassName$1 = hasEditingError => {
|
|
|
3705
3739
|
const getInputDom = hasEditingError => {
|
|
3706
3740
|
return [{
|
|
3707
3741
|
type: Input,
|
|
3708
|
-
className: getClassName$
|
|
3742
|
+
className: getClassName$2(hasEditingError),
|
|
3709
3743
|
id: 'ExplorerInput',
|
|
3710
3744
|
onInput: HandleEditingInput,
|
|
3711
3745
|
childCount: 0,
|
|
@@ -3789,7 +3823,7 @@ const getActiveDescendant = focusedIndex => {
|
|
|
3789
3823
|
}
|
|
3790
3824
|
return undefined;
|
|
3791
3825
|
};
|
|
3792
|
-
const getClassName = (focused, focusedIndex, dropTarget) => {
|
|
3826
|
+
const getClassName$1 = (focused, focusedIndex, dropTarget) => {
|
|
3793
3827
|
const extraClass1 = focused && focusedIndex === -1 ? FocusOutline : Empty;
|
|
3794
3828
|
const extraClass2 = dropTarget === dropTargetFull ? ExplorerDropTarget : Empty;
|
|
3795
3829
|
const className = mergeClassNames(ListItems, extraClass1, extraClass2);
|
|
@@ -3807,7 +3841,7 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
|
|
|
3807
3841
|
}
|
|
3808
3842
|
const dom = [parentNode, {
|
|
3809
3843
|
type: Div,
|
|
3810
|
-
className: getClassName(focused, focusedIndex, dropTargets),
|
|
3844
|
+
className: getClassName$1(focused, focusedIndex, dropTargets),
|
|
3811
3845
|
tabIndex: 0,
|
|
3812
3846
|
role: Tree,
|
|
3813
3847
|
ariaLabel: filesExplorer(),
|
|
@@ -3879,6 +3913,15 @@ const getTreeItemIndentWithChevron = (depth, chevron) => {
|
|
|
3879
3913
|
};
|
|
3880
3914
|
|
|
3881
3915
|
const ariaExpandedValues = [undefined, 'true', 'false'];
|
|
3916
|
+
const getClassName = (isSelected, isFocused) => {
|
|
3917
|
+
if (isFocused) {
|
|
3918
|
+
return mergeClassNames(TreeItem, TreeItemActive);
|
|
3919
|
+
}
|
|
3920
|
+
if (isSelected) {
|
|
3921
|
+
return mergeClassNames(TreeItem, TreeItemActive);
|
|
3922
|
+
}
|
|
3923
|
+
return TreeItem;
|
|
3924
|
+
};
|
|
3882
3925
|
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets) => {
|
|
3883
3926
|
const visible = [];
|
|
3884
3927
|
const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
|
|
@@ -3890,7 +3933,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
3890
3933
|
const indent = indentFn(item.depth, chevron);
|
|
3891
3934
|
const isFocused = i === focusedIndex;
|
|
3892
3935
|
const id = isFocused ? 'TreeItemActive' : undefined;
|
|
3893
|
-
const
|
|
3936
|
+
const isSelected = item.selected;
|
|
3937
|
+
const className = getClassName(isSelected, isFocused);
|
|
3894
3938
|
const expanded = getExpandedType(item.type);
|
|
3895
3939
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
3896
3940
|
|
|
@@ -3921,7 +3965,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
3921
3965
|
ariaExpanded: undefined,
|
|
3922
3966
|
chevron: 0,
|
|
3923
3967
|
id: undefined,
|
|
3924
|
-
className: TreeItem
|
|
3968
|
+
className: TreeItem,
|
|
3969
|
+
selected: false
|
|
3925
3970
|
});
|
|
3926
3971
|
}
|
|
3927
3972
|
return visible;
|
|
@@ -3939,6 +3984,8 @@ const getRenderer = diffType => {
|
|
|
3939
3984
|
case RenderItems:
|
|
3940
3985
|
return renderItems;
|
|
3941
3986
|
case RenderFocus:
|
|
3987
|
+
return renderFocus$1;
|
|
3988
|
+
case RenderFocusContext:
|
|
3942
3989
|
return renderFocus;
|
|
3943
3990
|
default:
|
|
3944
3991
|
throw new Error('unknown renderer');
|
|
@@ -4064,7 +4111,7 @@ const renderEventListeners = () => {
|
|
|
4064
4111
|
params: ['handleBlur']
|
|
4065
4112
|
}, {
|
|
4066
4113
|
name: HandleClick,
|
|
4067
|
-
params: ['handleClickAt', 'event.button', 'event.clientX', 'event.clientY'],
|
|
4114
|
+
params: ['handleClickAt', 'event.button', 'event.ctrlKey', 'event.shiftKey', 'event.clientX', 'event.clientY'],
|
|
4068
4115
|
preventDefault: true
|
|
4069
4116
|
}, {
|
|
4070
4117
|
name: HandleClickOpenFolder,
|
|
@@ -4333,12 +4380,65 @@ const saveState = uid => {
|
|
|
4333
4380
|
};
|
|
4334
4381
|
};
|
|
4335
4382
|
|
|
4383
|
+
const selectDown = state => {
|
|
4384
|
+
const {
|
|
4385
|
+
items,
|
|
4386
|
+
focusedIndex
|
|
4387
|
+
} = state;
|
|
4388
|
+
const firstSelectedIndex = items.findIndex(item => item.selected);
|
|
4389
|
+
const targetIndex = firstSelectedIndex === -1 ? focusedIndex : firstSelectedIndex;
|
|
4390
|
+
if (targetIndex >= items.length - 1) {
|
|
4391
|
+
return state;
|
|
4392
|
+
}
|
|
4393
|
+
const newItems = items.map((item, i) => ({
|
|
4394
|
+
...item,
|
|
4395
|
+
selected: i === targetIndex + 1 ? true : item.selected
|
|
4396
|
+
}));
|
|
4397
|
+
return {
|
|
4398
|
+
...state,
|
|
4399
|
+
items: newItems
|
|
4400
|
+
};
|
|
4401
|
+
};
|
|
4402
|
+
|
|
4403
|
+
const selectUp = state => {
|
|
4404
|
+
const {
|
|
4405
|
+
items,
|
|
4406
|
+
focusedIndex
|
|
4407
|
+
} = state;
|
|
4408
|
+
const firstSelectedIndex = items.findIndex(item => item.selected);
|
|
4409
|
+
const targetIndex = firstSelectedIndex === -1 ? focusedIndex : firstSelectedIndex;
|
|
4410
|
+
if (targetIndex <= 0) {
|
|
4411
|
+
return state;
|
|
4412
|
+
}
|
|
4413
|
+
const newItems = items.map((item, i) => ({
|
|
4414
|
+
...item,
|
|
4415
|
+
selected: i === targetIndex - 1 ? true : item.selected
|
|
4416
|
+
}));
|
|
4417
|
+
return {
|
|
4418
|
+
...state,
|
|
4419
|
+
items: newItems
|
|
4420
|
+
};
|
|
4421
|
+
};
|
|
4422
|
+
|
|
4336
4423
|
const terminate = () => {
|
|
4337
4424
|
globalThis.close();
|
|
4338
4425
|
};
|
|
4339
4426
|
|
|
4340
|
-
const
|
|
4341
|
-
|
|
4427
|
+
const getEditingIcon = async (editingType, value) => {
|
|
4428
|
+
if (editingType === File) {
|
|
4429
|
+
return invoke('IconTheme.getFileIcon', {
|
|
4430
|
+
name: value
|
|
4431
|
+
});
|
|
4432
|
+
}
|
|
4433
|
+
if (editingType === Directory) {
|
|
4434
|
+
return invoke('IconTheme.getFolderIcon', {
|
|
4435
|
+
name: value
|
|
4436
|
+
});
|
|
4437
|
+
}
|
|
4438
|
+
return '';
|
|
4439
|
+
};
|
|
4440
|
+
const updateEditingValue = async (state, value, inputSource = User) => {
|
|
4441
|
+
const editingIcon = await getEditingIcon(state.editingType, value);
|
|
4342
4442
|
return {
|
|
4343
4443
|
...state,
|
|
4344
4444
|
editingValue: value,
|
|
@@ -4379,6 +4479,8 @@ const commandMap = {
|
|
|
4379
4479
|
'Explorer.handleArrowLeft': wrapCommand(handleArrowLeft),
|
|
4380
4480
|
'Explorer.handleArrowRight': wrapCommand(handleArrowRight),
|
|
4381
4481
|
'Explorer.handleBlur': wrapCommand(handleBlur),
|
|
4482
|
+
'Explorer.selectUp': wrapCommand(selectUp),
|
|
4483
|
+
'Explorer.selectDown': wrapCommand(selectDown),
|
|
4382
4484
|
'Explorer.handleClick': wrapCommand(handleClick),
|
|
4383
4485
|
'Explorer.handleClickAt': wrapCommand(handleClickAt),
|
|
4384
4486
|
'Explorer.handleClickCurrent': wrapCommand(handleClickCurrent),
|