@lvce-editor/explorer-view 2.20.0 → 2.22.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 +93 -31
- package/package.json +1 -1
|
@@ -1579,19 +1579,28 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1579
1579
|
const RenderItems = 4;
|
|
1580
1580
|
const RenderFocus = 6;
|
|
1581
1581
|
const RenderFocusContext = 7;
|
|
1582
|
+
const RenderValue = 8;
|
|
1582
1583
|
|
|
1583
|
-
const diffType$
|
|
1584
|
-
const isEqual$
|
|
1584
|
+
const diffType$2 = RenderFocus;
|
|
1585
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1585
1586
|
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
1586
1587
|
};
|
|
1587
1588
|
|
|
1588
|
-
const diffType = RenderItems;
|
|
1589
|
-
const isEqual$
|
|
1589
|
+
const diffType$1 = RenderItems;
|
|
1590
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1590
1591
|
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;
|
|
1591
1592
|
};
|
|
1592
1593
|
|
|
1593
|
-
const
|
|
1594
|
-
const
|
|
1594
|
+
const diffType = RenderValue;
|
|
1595
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1596
|
+
if (newState.focus !== Input$1) {
|
|
1597
|
+
return true;
|
|
1598
|
+
}
|
|
1599
|
+
return oldState.focus === Input$1 && newState.focus === Input$1 && oldState.editingValue === newState.editingValue;
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1602
|
+
const modules = [isEqual$2, isEqual$3, isEqual$3, isEqual$1];
|
|
1603
|
+
const numbers = [diffType$1, diffType$2, RenderFocusContext, diffType];
|
|
1595
1604
|
|
|
1596
1605
|
const diff = (oldState, newState) => {
|
|
1597
1606
|
const diffResult = [];
|
|
@@ -1986,7 +1995,7 @@ const focusPrevious = state => {
|
|
|
1986
1995
|
}
|
|
1987
1996
|
};
|
|
1988
1997
|
|
|
1989
|
-
const commandIds = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', '
|
|
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', 'setSelectedIndices', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectUp', 'setDeltaY', 'updateEditingValue', 'updateIcons'];
|
|
1990
1999
|
|
|
1991
2000
|
const getCommandIds = () => {
|
|
1992
2001
|
return commandIds;
|
|
@@ -2002,6 +2011,7 @@ const UpArrow = 14;
|
|
|
2002
2011
|
const RightArrow = 15;
|
|
2003
2012
|
const DownArrow = 16;
|
|
2004
2013
|
const Delete = 18;
|
|
2014
|
+
const KeyA = 29;
|
|
2005
2015
|
const KeyC = 31;
|
|
2006
2016
|
const KeyV = 50;
|
|
2007
2017
|
const F2 = 58;
|
|
@@ -2095,6 +2105,10 @@ const getKeyBindings = () => {
|
|
|
2095
2105
|
key: Enter,
|
|
2096
2106
|
command: 'Explorer.handleClickCurrent',
|
|
2097
2107
|
when: FocusExplorer
|
|
2108
|
+
}, {
|
|
2109
|
+
key: CtrlCmd | KeyA,
|
|
2110
|
+
command: 'Explorer.selectAll',
|
|
2111
|
+
when: FocusExplorer
|
|
2098
2112
|
}];
|
|
2099
2113
|
};
|
|
2100
2114
|
|
|
@@ -2225,14 +2239,12 @@ const LeftClick = 0;
|
|
|
2225
2239
|
|
|
2226
2240
|
const getMouseActions = () => {
|
|
2227
2241
|
return [{
|
|
2228
|
-
id: 'explorer.openFile',
|
|
2229
2242
|
description: 'Open file on click',
|
|
2230
2243
|
button: LeftClick,
|
|
2231
2244
|
modifiers: {},
|
|
2232
2245
|
command: 'Explorer.openFile',
|
|
2233
2246
|
when: FocusExplorer
|
|
2234
2247
|
}, {
|
|
2235
|
-
id: 'explorer.toggleSelection',
|
|
2236
2248
|
description: 'Toggle selection with Ctrl+Click',
|
|
2237
2249
|
button: LeftClick,
|
|
2238
2250
|
modifiers: {
|
|
@@ -2241,7 +2253,6 @@ const getMouseActions = () => {
|
|
|
2241
2253
|
command: 'Explorer.toggleSelection',
|
|
2242
2254
|
when: FocusExplorer
|
|
2243
2255
|
}, {
|
|
2244
|
-
id: 'explorer.rangeSelection',
|
|
2245
2256
|
description: 'Select range with Shift+Click',
|
|
2246
2257
|
button: LeftClick,
|
|
2247
2258
|
modifiers: {
|
|
@@ -2249,14 +2260,6 @@ const getMouseActions = () => {
|
|
|
2249
2260
|
},
|
|
2250
2261
|
command: 'Explorer.rangeSelection',
|
|
2251
2262
|
when: FocusExplorer
|
|
2252
|
-
}, {
|
|
2253
|
-
id: 'explorer.contextMenu',
|
|
2254
|
-
description: 'Show context menu on right click',
|
|
2255
|
-
button: 2,
|
|
2256
|
-
// Right click
|
|
2257
|
-
modifiers: {},
|
|
2258
|
-
command: 'Explorer.showContextMenu',
|
|
2259
|
-
when: FocusExplorer
|
|
2260
2263
|
}];
|
|
2261
2264
|
};
|
|
2262
2265
|
|
|
@@ -2623,19 +2626,23 @@ const handleRangeSelection = (state, startIndex, endIndex) => {
|
|
|
2623
2626
|
};
|
|
2624
2627
|
};
|
|
2625
2628
|
|
|
2626
|
-
const
|
|
2629
|
+
const handleClickAtRangeSelection = async (state, index) => {
|
|
2630
|
+
const firstSelectedIndex = state.items.findIndex(item => item.selected);
|
|
2631
|
+
if (firstSelectedIndex === -1) {
|
|
2632
|
+
return handleRangeSelection(state, index, index);
|
|
2633
|
+
}
|
|
2634
|
+
const min = Math.min(firstSelectedIndex, index);
|
|
2635
|
+
const max = Math.min(firstSelectedIndex, index);
|
|
2636
|
+
return handleRangeSelection(state, min, max);
|
|
2637
|
+
};
|
|
2638
|
+
|
|
2639
|
+
const handleClickAt = async (state, button, ctrlKey, shiftKey, x, y) => {
|
|
2627
2640
|
if (button !== LeftClick) {
|
|
2628
2641
|
return state;
|
|
2629
2642
|
}
|
|
2630
2643
|
const index = getIndexFromPosition(state, x, y);
|
|
2631
2644
|
if (shiftKey) {
|
|
2632
|
-
|
|
2633
|
-
if (firstSelectedIndex === -1) {
|
|
2634
|
-
return handleRangeSelection(state, index, index);
|
|
2635
|
-
}
|
|
2636
|
-
const min = Math.min(firstSelectedIndex, index);
|
|
2637
|
-
const max = Math.min(firstSelectedIndex, index);
|
|
2638
|
-
return handleRangeSelection(state, min, max);
|
|
2645
|
+
return handleClickAtRangeSelection(state, index);
|
|
2639
2646
|
}
|
|
2640
2647
|
return handleClick(state, index);
|
|
2641
2648
|
};
|
|
@@ -2852,6 +2859,7 @@ const applyOperation = operation => {
|
|
|
2852
2859
|
}
|
|
2853
2860
|
return writeFile(operation.path, operation.text);
|
|
2854
2861
|
};
|
|
2862
|
+
|
|
2855
2863
|
const applyFileOperations = async operations => {
|
|
2856
2864
|
// TODO run operations in parallel if possible
|
|
2857
2865
|
for (const operation of operations) {
|
|
@@ -3657,6 +3665,9 @@ const removeDirent = async state => {
|
|
|
3657
3665
|
};
|
|
3658
3666
|
};
|
|
3659
3667
|
|
|
3668
|
+
const User = 1;
|
|
3669
|
+
const Script = 2;
|
|
3670
|
+
|
|
3660
3671
|
const renameDirent = state => {
|
|
3661
3672
|
const {
|
|
3662
3673
|
focusedIndex,
|
|
@@ -3668,14 +3679,13 @@ const renameDirent = state => {
|
|
|
3668
3679
|
editingIndex: focusedIndex,
|
|
3669
3680
|
editingType: Rename$1,
|
|
3670
3681
|
editingValue: item.name,
|
|
3671
|
-
focus: Input$1
|
|
3682
|
+
focus: Input$1,
|
|
3683
|
+
inputSource: Script
|
|
3672
3684
|
};
|
|
3673
3685
|
};
|
|
3674
3686
|
|
|
3675
3687
|
const ExplorerInput = 'ExplorerInput';
|
|
3676
3688
|
|
|
3677
|
-
const User = 1;
|
|
3678
|
-
|
|
3679
3689
|
const renderFocus$1 = (oldState, newState) => {
|
|
3680
3690
|
if (newState.inputSource === User) {
|
|
3681
3691
|
return [];
|
|
@@ -4049,6 +4059,16 @@ const renderItems = (oldState, newState) => {
|
|
|
4049
4059
|
return ['Viewlet.setDom2', dom];
|
|
4050
4060
|
};
|
|
4051
4061
|
|
|
4062
|
+
const renderValue = (oldState, newState) => {
|
|
4063
|
+
if (newState.inputSource === User) {
|
|
4064
|
+
return [];
|
|
4065
|
+
}
|
|
4066
|
+
if (newState.focus === Input$1) {
|
|
4067
|
+
return ['Viewlet.setValueByName', ExplorerInput, newState.editingValue];
|
|
4068
|
+
}
|
|
4069
|
+
return [];
|
|
4070
|
+
};
|
|
4071
|
+
|
|
4052
4072
|
const getRenderer = diffType => {
|
|
4053
4073
|
switch (diffType) {
|
|
4054
4074
|
case RenderItems:
|
|
@@ -4057,6 +4077,8 @@ const getRenderer = diffType => {
|
|
|
4057
4077
|
return renderFocus$1;
|
|
4058
4078
|
case RenderFocusContext:
|
|
4059
4079
|
return renderFocus;
|
|
4080
|
+
case RenderValue:
|
|
4081
|
+
return renderValue;
|
|
4060
4082
|
default:
|
|
4061
4083
|
throw new Error('unknown renderer');
|
|
4062
4084
|
}
|
|
@@ -4450,13 +4472,36 @@ const saveState = uid => {
|
|
|
4450
4472
|
};
|
|
4451
4473
|
};
|
|
4452
4474
|
|
|
4475
|
+
const selectAll = state => {
|
|
4476
|
+
const {
|
|
4477
|
+
items
|
|
4478
|
+
} = state;
|
|
4479
|
+
const newItems = items.map(item => ({
|
|
4480
|
+
...item,
|
|
4481
|
+
selected: true
|
|
4482
|
+
}));
|
|
4483
|
+
return {
|
|
4484
|
+
...state,
|
|
4485
|
+
items: newItems
|
|
4486
|
+
};
|
|
4487
|
+
};
|
|
4488
|
+
|
|
4489
|
+
const getLastSelectedIndex = items => {
|
|
4490
|
+
let lastSelectedIndex = -1;
|
|
4491
|
+
for (let index = 0; index < items.length; index++) {
|
|
4492
|
+
if (items[index].selected) {
|
|
4493
|
+
lastSelectedIndex = index;
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
return lastSelectedIndex;
|
|
4497
|
+
};
|
|
4453
4498
|
const selectDown = state => {
|
|
4454
4499
|
const {
|
|
4455
4500
|
items,
|
|
4456
4501
|
focusedIndex
|
|
4457
4502
|
} = state;
|
|
4458
|
-
const
|
|
4459
|
-
const targetIndex =
|
|
4503
|
+
const lastSelectedIndex = getLastSelectedIndex(items);
|
|
4504
|
+
const targetIndex = lastSelectedIndex === -1 ? focusedIndex : lastSelectedIndex;
|
|
4460
4505
|
if (targetIndex >= items.length - 1) {
|
|
4461
4506
|
return state;
|
|
4462
4507
|
}
|
|
@@ -4464,6 +4509,21 @@ const selectDown = state => {
|
|
|
4464
4509
|
...item,
|
|
4465
4510
|
selected: i === targetIndex + 1 ? true : item.selected
|
|
4466
4511
|
}));
|
|
4512
|
+
return {
|
|
4513
|
+
...state,
|
|
4514
|
+
items: newItems,
|
|
4515
|
+
focusedIndex: targetIndex + 1
|
|
4516
|
+
};
|
|
4517
|
+
};
|
|
4518
|
+
|
|
4519
|
+
const setSelectedIndices = (state, indices) => {
|
|
4520
|
+
const {
|
|
4521
|
+
items
|
|
4522
|
+
} = state;
|
|
4523
|
+
const newItems = items.map((item, i) => ({
|
|
4524
|
+
...item,
|
|
4525
|
+
selected: indices.includes(i)
|
|
4526
|
+
}));
|
|
4467
4527
|
return {
|
|
4468
4528
|
...state,
|
|
4469
4529
|
items: newItems
|
|
@@ -4551,6 +4611,7 @@ const commandMap = {
|
|
|
4551
4611
|
'Explorer.handleBlur': wrapCommand(handleBlur),
|
|
4552
4612
|
'Explorer.selectUp': wrapCommand(selectUp),
|
|
4553
4613
|
'Explorer.selectDown': wrapCommand(selectDown),
|
|
4614
|
+
'Explorer.selectAll': wrapCommand(selectAll),
|
|
4554
4615
|
'Explorer.handleClick': wrapCommand(handleClick),
|
|
4555
4616
|
'Explorer.handleClickAt': wrapCommand(handleClickAt),
|
|
4556
4617
|
'Explorer.handleClickCurrent': wrapCommand(handleClickCurrent),
|
|
@@ -4582,6 +4643,7 @@ const commandMap = {
|
|
|
4582
4643
|
'Explorer.setDeltaY': wrapCommand(setDeltaY),
|
|
4583
4644
|
'Explorer.updateEditingValue': wrapCommand(updateEditingValue),
|
|
4584
4645
|
'Explorer.updateIcons': wrapCommand(updateIcons),
|
|
4646
|
+
'Explorer.setSelectedIndices': wrapCommand(setSelectedIndices),
|
|
4585
4647
|
// not wrapped
|
|
4586
4648
|
'Explorer.create2': create2,
|
|
4587
4649
|
'Explorer.diff2': diff2,
|