@lvce-editor/explorer-view 2.19.0 → 2.21.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.
@@ -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$1 = RenderFocus;
1584
- const isEqual$2 = (oldState, newState) => {
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$1 = (oldState, newState) => {
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 modules = [isEqual$1, isEqual$2, isEqual$2];
1594
- const numbers = [diffType, diffType$1, RenderFocusContext];
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', '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'];
1998
+ const commandIds = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'selectUp', 'selectDown', 'getMouseActions', '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'];
1990
1999
 
1991
2000
  const getCommandIds = () => {
1992
2001
  return commandIds;
@@ -2220,6 +2229,35 @@ const getMenuEntries2 = uid => {
2220
2229
  return getMenuEntries(newState);
2221
2230
  };
2222
2231
 
2232
+ const Keyboard = -1;
2233
+ const LeftClick = 0;
2234
+
2235
+ const getMouseActions = () => {
2236
+ return [{
2237
+ description: 'Open file on click',
2238
+ button: LeftClick,
2239
+ modifiers: {},
2240
+ command: 'Explorer.openFile',
2241
+ when: FocusExplorer
2242
+ }, {
2243
+ description: 'Toggle selection with Ctrl+Click',
2244
+ button: LeftClick,
2245
+ modifiers: {
2246
+ ctrl: true
2247
+ },
2248
+ command: 'Explorer.toggleSelection',
2249
+ when: FocusExplorer
2250
+ }, {
2251
+ description: 'Select range with Shift+Click',
2252
+ button: LeftClick,
2253
+ modifiers: {
2254
+ shift: true
2255
+ },
2256
+ command: 'Explorer.rangeSelection',
2257
+ when: FocusExplorer
2258
+ }];
2259
+ };
2260
+
2223
2261
  const getParentStartIndex = (dirents, index) => {
2224
2262
  const dirent = dirents[index];
2225
2263
  let startIndex = index - 1;
@@ -2559,14 +2597,48 @@ const getIndexFromPosition = (state, eventX, eventY) => {
2559
2597
  return index;
2560
2598
  };
2561
2599
 
2562
- const Keyboard = -1;
2563
- const LeftClick = 0;
2600
+ /**
2601
+ * Handles range selection in the explorer.
2602
+ * @param state The current explorer state
2603
+ * @param startIndex The starting index of the range (must be ≤ endIndex)
2604
+ * @param endIndex The ending index of the range (must be ≥ startIndex)
2605
+ * @throws Error if startIndex > endIndex
2606
+ */
2607
+ const handleRangeSelection = (state, startIndex, endIndex) => {
2608
+ if (startIndex > endIndex) {
2609
+ throw new Error('startIndex must be less than or equal to endIndex');
2610
+ }
2611
+ const {
2612
+ items
2613
+ } = state;
2614
+ const newItems = items.map((item, i) => ({
2615
+ ...item,
2616
+ selected: i >= startIndex && i <= endIndex ? true : item.selected
2617
+ }));
2618
+ return {
2619
+ ...state,
2620
+ items: newItems
2621
+ };
2622
+ };
2623
+
2624
+ const handleClickAtRangeSelection = async (state, index) => {
2625
+ const firstSelectedIndex = state.items.findIndex(item => item.selected);
2626
+ if (firstSelectedIndex === -1) {
2627
+ return handleRangeSelection(state, index, index);
2628
+ }
2629
+ const min = Math.min(firstSelectedIndex, index);
2630
+ const max = Math.min(firstSelectedIndex, index);
2631
+ return handleRangeSelection(state, min, max);
2632
+ };
2564
2633
 
2565
- const handleClickAt = (state, button, ctrlKey, shiftKey, x, y) => {
2634
+ const handleClickAt = async (state, button, ctrlKey, shiftKey, x, y) => {
2566
2635
  if (button !== LeftClick) {
2567
2636
  return state;
2568
2637
  }
2569
2638
  const index = getIndexFromPosition(state, x, y);
2639
+ if (shiftKey) {
2640
+ return handleClickAtRangeSelection(state, index);
2641
+ }
2570
2642
  return handleClick(state, index);
2571
2643
  };
2572
2644
 
@@ -3587,6 +3659,9 @@ const removeDirent = async state => {
3587
3659
  };
3588
3660
  };
3589
3661
 
3662
+ const User = 1;
3663
+ const Script = 2;
3664
+
3590
3665
  const renameDirent = state => {
3591
3666
  const {
3592
3667
  focusedIndex,
@@ -3598,14 +3673,13 @@ const renameDirent = state => {
3598
3673
  editingIndex: focusedIndex,
3599
3674
  editingType: Rename$1,
3600
3675
  editingValue: item.name,
3601
- focus: Input$1
3676
+ focus: Input$1,
3677
+ inputSource: Script
3602
3678
  };
3603
3679
  };
3604
3680
 
3605
3681
  const ExplorerInput = 'ExplorerInput';
3606
3682
 
3607
- const User = 1;
3608
-
3609
3683
  const renderFocus$1 = (oldState, newState) => {
3610
3684
  if (newState.inputSource === User) {
3611
3685
  return [];
@@ -3979,6 +4053,16 @@ const renderItems = (oldState, newState) => {
3979
4053
  return ['Viewlet.setDom2', dom];
3980
4054
  };
3981
4055
 
4056
+ const renderValue = (oldState, newState) => {
4057
+ if (newState.inputSource === User) {
4058
+ return [];
4059
+ }
4060
+ if (newState.focus === Input$1) {
4061
+ return ['Viewlet.setValueByName', ExplorerInput, newState.editingValue];
4062
+ }
4063
+ return [];
4064
+ };
4065
+
3982
4066
  const getRenderer = diffType => {
3983
4067
  switch (diffType) {
3984
4068
  case RenderItems:
@@ -3987,6 +4071,8 @@ const getRenderer = diffType => {
3987
4071
  return renderFocus$1;
3988
4072
  case RenderFocusContext:
3989
4073
  return renderFocus;
4074
+ case RenderValue:
4075
+ return renderValue;
3990
4076
  default:
3991
4077
  throw new Error('unknown renderer');
3992
4078
  }
@@ -4487,6 +4573,7 @@ const commandMap = {
4487
4573
  'Explorer.handleClickCurrentButKeepFocus': wrapCommand(handleClickCurrentButKeepFocus),
4488
4574
  'Explorer.handleClickOpenFolder': wrapCommand(handleClickOpenFolder),
4489
4575
  'Explorer.handleContextMenu': wrapCommand(handleContextMenu),
4576
+ 'Explorer.getMouseActions': getMouseActions,
4490
4577
  'Explorer.handleContextMenuKeyboard': wrapCommand(handleContextMenuKeyboard),
4491
4578
  'Explorer.handleCopy': wrapCommand(handleCopy),
4492
4579
  'Explorer.handleDragLeave': wrapCommand(handleDragLeave),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.19.0",
3
+ "version": "2.21.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",