@lvce-editor/explorer-view 3.0.0 → 3.2.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.
@@ -895,6 +895,7 @@ const CreateFolder$1 = 1;
895
895
  const CreateFile$1 = 2;
896
896
  const Copy$1 = 3;
897
897
  const Rename$2 = 4;
898
+ const Remove = 5;
898
899
 
899
900
  const rpcs = Object.create(null);
900
901
  const set$g = (id, rpc) => {
@@ -1004,6 +1005,9 @@ const applyOperation = operation => {
1004
1005
  if (operation.type === Rename$2) {
1005
1006
  return rename$1(operation.from || '', operation.path);
1006
1007
  }
1008
+ if (operation.type === Remove) {
1009
+ return remove(operation.path);
1010
+ }
1007
1011
  return writeFile(operation.path, operation.text);
1008
1012
  };
1009
1013
 
@@ -2416,7 +2420,7 @@ const focusPrevious = state => {
2416
2420
  }
2417
2421
  };
2418
2422
 
2419
- const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', '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', 'handleCut', 'handleDragLeave', 'handleDragOver', 'handleDragStart', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleInputBlur', 'handleInputClick', 'handleInputKeyDown', 'handleKeyDown', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectIndices', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'toggleIndividualSelection', 'updateEditingValue', 'updateIcons'];
2423
+ const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', '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', 'handleCut', 'handleDragLeave', 'handleDragOver', 'handleDragOverIndex', 'handleDragStart', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleInputBlur', 'handleInputClick', 'handleInputKeyDown', 'handleKeyDown', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectIndices', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'toggleIndividualSelection', 'updateEditingValue', 'updateIcons'];
2420
2424
 
2421
2425
  const getCommandIds = () => {
2422
2426
  return commandIds;
@@ -3294,19 +3298,28 @@ const canBeDroppedInto = dirent => {
3294
3298
  }
3295
3299
  };
3296
3300
 
3301
+ const countInRange = (start, end) => {
3302
+ const items = [];
3303
+ for (let i = start; i < end; i++) {
3304
+ items.push(i);
3305
+ }
3306
+ return items;
3307
+ };
3308
+
3297
3309
  const dropTargetFull = [-1];
3298
3310
 
3299
- const getNewDropTargets = (state, x, y) => {
3311
+ const getNewDropTargets = (state, index) => {
3300
3312
  const {
3301
3313
  items
3302
3314
  } = state;
3303
- const index = getIndexFromPosition(state, x, y);
3304
3315
  if (index === -1) {
3305
3316
  return dropTargetFull;
3306
3317
  }
3307
3318
  const item = items[index];
3308
3319
  if (!canBeDroppedInto(item)) {
3309
- return [];
3320
+ const startIndex = getParentStartIndex(items, index);
3321
+ const endIndex = getParentEndIndex(items, index);
3322
+ return countInRange(startIndex, endIndex);
3310
3323
  }
3311
3324
  const newDropTargets = [index];
3312
3325
  return newDropTargets;
@@ -3327,13 +3340,11 @@ const isEqual = (a, b) => {
3327
3340
  return true;
3328
3341
  };
3329
3342
 
3330
- const handleDragOver = (state, x, y) => {
3331
- number(x);
3332
- number(y);
3343
+ const handleDragOverIndex = (state, index) => {
3333
3344
  const {
3334
3345
  dropTargets
3335
3346
  } = state;
3336
- const newDropTargets = getNewDropTargets(state, x, y);
3347
+ const newDropTargets = getNewDropTargets(state, index);
3337
3348
  if (isEqual(dropTargets, newDropTargets)) {
3338
3349
  return state;
3339
3350
  }
@@ -3343,6 +3354,13 @@ const handleDragOver = (state, x, y) => {
3343
3354
  };
3344
3355
  };
3345
3356
 
3357
+ const handleDragOver = (state, x, y) => {
3358
+ number(x);
3359
+ number(y);
3360
+ const index = getIndexFromPosition(state, x, y);
3361
+ return handleDragOverIndex(state, index);
3362
+ };
3363
+
3346
3364
  const handleDragStart = state => {
3347
3365
  return state;
3348
3366
  };
@@ -4523,16 +4541,6 @@ const confirmDelete = async paths => {
4523
4541
  return result === true;
4524
4542
  };
4525
4543
 
4526
- const removePaths = async paths => {
4527
- for (const item of paths) {
4528
- try {
4529
- await remove(item);
4530
- } catch {
4531
- // ignore
4532
- }
4533
- }
4534
- };
4535
-
4536
4544
  const removeDirent = async state => {
4537
4545
  const {
4538
4546
  items,
@@ -4550,9 +4558,18 @@ const removeDirent = async state => {
4550
4558
  return state;
4551
4559
  }
4552
4560
  }
4553
-
4554
- // TODO use file operations, bulk edit and explorer refresh
4555
- await removePaths(toRemove);
4561
+ const fileOperations = toRemove.map(item => {
4562
+ return {
4563
+ type: Remove,
4564
+ path: item
4565
+ };
4566
+ });
4567
+ // TODO use bulk edit and explorer refresh
4568
+ const errorMessage = await applyFileOperations(fileOperations);
4569
+ if (errorMessage) {
4570
+ await confirm(errorMessage);
4571
+ return state;
4572
+ }
4556
4573
  const newState = await refresh(state);
4557
4574
  return {
4558
4575
  ...newState,
@@ -4629,7 +4646,7 @@ const renameDirent = state => {
4629
4646
 
4630
4647
  const getDragLabel = urls => {
4631
4648
  if (urls.length === 1) {
4632
- return urls[0];
4649
+ return getBaseName('/', urls[0]);
4633
4650
  }
4634
4651
  return `${urls.length}`;
4635
4652
  };
@@ -5673,6 +5690,7 @@ const commandMap = {
5673
5690
  'Explorer.focusIndex': wrapCommand(focusIndex),
5674
5691
  'Explorer.focusLast': wrapCommand(focusLast),
5675
5692
  'Explorer.handleDragStart': wrapCommand(handleDragStart),
5693
+ 'Explorer.handleDragOverIndex': wrapCommand(handleDragOverIndex),
5676
5694
  'Explorer.focusNext': wrapCommand(focusNext),
5677
5695
  'Explorer.focusNone': wrapCommand(focusNone),
5678
5696
  'Explorer.focusPrevious': wrapCommand(focusPrevious),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",