@lvce-editor/explorer-view 2.19.0 → 2.20.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.
@@ -1986,7 +1986,7 @@ const focusPrevious = state => {
1986
1986
  }
1987
1987
  };
1988
1988
 
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'];
1989
+ 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
1990
 
1991
1991
  const getCommandIds = () => {
1992
1992
  return commandIds;
@@ -2220,6 +2220,46 @@ const getMenuEntries2 = uid => {
2220
2220
  return getMenuEntries(newState);
2221
2221
  };
2222
2222
 
2223
+ const Keyboard = -1;
2224
+ const LeftClick = 0;
2225
+
2226
+ const getMouseActions = () => {
2227
+ return [{
2228
+ id: 'explorer.openFile',
2229
+ description: 'Open file on click',
2230
+ button: LeftClick,
2231
+ modifiers: {},
2232
+ command: 'Explorer.openFile',
2233
+ when: FocusExplorer
2234
+ }, {
2235
+ id: 'explorer.toggleSelection',
2236
+ description: 'Toggle selection with Ctrl+Click',
2237
+ button: LeftClick,
2238
+ modifiers: {
2239
+ ctrl: true
2240
+ },
2241
+ command: 'Explorer.toggleSelection',
2242
+ when: FocusExplorer
2243
+ }, {
2244
+ id: 'explorer.rangeSelection',
2245
+ description: 'Select range with Shift+Click',
2246
+ button: LeftClick,
2247
+ modifiers: {
2248
+ shift: true
2249
+ },
2250
+ command: 'Explorer.rangeSelection',
2251
+ 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
+ }];
2261
+ };
2262
+
2223
2263
  const getParentStartIndex = (dirents, index) => {
2224
2264
  const dirent = dirents[index];
2225
2265
  let startIndex = index - 1;
@@ -2559,14 +2599,44 @@ const getIndexFromPosition = (state, eventX, eventY) => {
2559
2599
  return index;
2560
2600
  };
2561
2601
 
2562
- const Keyboard = -1;
2563
- const LeftClick = 0;
2602
+ /**
2603
+ * Handles range selection in the explorer.
2604
+ * @param state The current explorer state
2605
+ * @param startIndex The starting index of the range (must be ≤ endIndex)
2606
+ * @param endIndex The ending index of the range (must be ≥ startIndex)
2607
+ * @throws Error if startIndex > endIndex
2608
+ */
2609
+ const handleRangeSelection = (state, startIndex, endIndex) => {
2610
+ if (startIndex > endIndex) {
2611
+ throw new Error('startIndex must be less than or equal to endIndex');
2612
+ }
2613
+ const {
2614
+ items
2615
+ } = state;
2616
+ const newItems = items.map((item, i) => ({
2617
+ ...item,
2618
+ selected: i >= startIndex && i <= endIndex ? true : item.selected
2619
+ }));
2620
+ return {
2621
+ ...state,
2622
+ items: newItems
2623
+ };
2624
+ };
2564
2625
 
2565
2626
  const handleClickAt = (state, button, ctrlKey, shiftKey, x, y) => {
2566
2627
  if (button !== LeftClick) {
2567
2628
  return state;
2568
2629
  }
2569
2630
  const index = getIndexFromPosition(state, x, y);
2631
+ if (shiftKey) {
2632
+ const firstSelectedIndex = state.items.findIndex(item => item.selected);
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);
2639
+ }
2570
2640
  return handleClick(state, index);
2571
2641
  };
2572
2642
 
@@ -4487,6 +4557,7 @@ const commandMap = {
4487
4557
  'Explorer.handleClickCurrentButKeepFocus': wrapCommand(handleClickCurrentButKeepFocus),
4488
4558
  'Explorer.handleClickOpenFolder': wrapCommand(handleClickOpenFolder),
4489
4559
  'Explorer.handleContextMenu': wrapCommand(handleContextMenu),
4560
+ 'Explorer.getMouseActions': getMouseActions,
4490
4561
  'Explorer.handleContextMenuKeyboard': wrapCommand(handleContextMenuKeyboard),
4491
4562
  'Explorer.handleCopy': wrapCommand(handleCopy),
4492
4563
  '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.20.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",