@lvce-editor/explorer-view 2.21.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.
@@ -1995,7 +1995,7 @@ const focusPrevious = state => {
1995
1995
  }
1996
1996
  };
1997
1997
 
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'];
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'];
1999
1999
 
2000
2000
  const getCommandIds = () => {
2001
2001
  return commandIds;
@@ -2011,6 +2011,7 @@ const UpArrow = 14;
2011
2011
  const RightArrow = 15;
2012
2012
  const DownArrow = 16;
2013
2013
  const Delete = 18;
2014
+ const KeyA = 29;
2014
2015
  const KeyC = 31;
2015
2016
  const KeyV = 50;
2016
2017
  const F2 = 58;
@@ -2104,6 +2105,10 @@ const getKeyBindings = () => {
2104
2105
  key: Enter,
2105
2106
  command: 'Explorer.handleClickCurrent',
2106
2107
  when: FocusExplorer
2108
+ }, {
2109
+ key: CtrlCmd | KeyA,
2110
+ command: 'Explorer.selectAll',
2111
+ when: FocusExplorer
2107
2112
  }];
2108
2113
  };
2109
2114
 
@@ -2854,6 +2859,7 @@ const applyOperation = operation => {
2854
2859
  }
2855
2860
  return writeFile(operation.path, operation.text);
2856
2861
  };
2862
+
2857
2863
  const applyFileOperations = async operations => {
2858
2864
  // TODO run operations in parallel if possible
2859
2865
  for (const operation of operations) {
@@ -4466,13 +4472,36 @@ const saveState = uid => {
4466
4472
  };
4467
4473
  };
4468
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
+ };
4469
4498
  const selectDown = state => {
4470
4499
  const {
4471
4500
  items,
4472
4501
  focusedIndex
4473
4502
  } = state;
4474
- const firstSelectedIndex = items.findIndex(item => item.selected);
4475
- const targetIndex = firstSelectedIndex === -1 ? focusedIndex : firstSelectedIndex;
4503
+ const lastSelectedIndex = getLastSelectedIndex(items);
4504
+ const targetIndex = lastSelectedIndex === -1 ? focusedIndex : lastSelectedIndex;
4476
4505
  if (targetIndex >= items.length - 1) {
4477
4506
  return state;
4478
4507
  }
@@ -4480,6 +4509,21 @@ const selectDown = state => {
4480
4509
  ...item,
4481
4510
  selected: i === targetIndex + 1 ? true : item.selected
4482
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
+ }));
4483
4527
  return {
4484
4528
  ...state,
4485
4529
  items: newItems
@@ -4567,6 +4611,7 @@ const commandMap = {
4567
4611
  'Explorer.handleBlur': wrapCommand(handleBlur),
4568
4612
  'Explorer.selectUp': wrapCommand(selectUp),
4569
4613
  'Explorer.selectDown': wrapCommand(selectDown),
4614
+ 'Explorer.selectAll': wrapCommand(selectAll),
4570
4615
  'Explorer.handleClick': wrapCommand(handleClick),
4571
4616
  'Explorer.handleClickAt': wrapCommand(handleClickAt),
4572
4617
  'Explorer.handleClickCurrent': wrapCommand(handleClickCurrent),
@@ -4598,6 +4643,7 @@ const commandMap = {
4598
4643
  'Explorer.setDeltaY': wrapCommand(setDeltaY),
4599
4644
  'Explorer.updateEditingValue': wrapCommand(updateEditingValue),
4600
4645
  'Explorer.updateIcons': wrapCommand(updateIcons),
4646
+ 'Explorer.setSelectedIndices': wrapCommand(setSelectedIndices),
4601
4647
  // not wrapped
4602
4648
  'Explorer.create2': create2,
4603
4649
  'Explorer.diff2': diff2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.21.0",
3
+ "version": "2.22.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",