@lvce-editor/explorer-view 1.9.0 → 1.10.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.
@@ -3293,6 +3293,65 @@ const removeDirent = async state => {
3293
3293
  };
3294
3294
  };
3295
3295
 
3296
+ const canBeDroppedInto = dirent => {
3297
+ if (!dirent) {
3298
+ return false;
3299
+ }
3300
+ switch (dirent.type) {
3301
+ case Directory:
3302
+ case DirectoryExpanded:
3303
+ case DirectoryExpanding:
3304
+ return true;
3305
+ default:
3306
+ return false;
3307
+ }
3308
+ };
3309
+
3310
+ const getNewDropTargets = (state, x, y) => {
3311
+ const {
3312
+ items
3313
+ } = state;
3314
+ const index = getIndexFromPosition(state, x, y);
3315
+ if (index === -1) {
3316
+ return [-1];
3317
+ }
3318
+ const item = items[index];
3319
+ if (!canBeDroppedInto(item)) {
3320
+ return [];
3321
+ }
3322
+ const newDropTargets = [index];
3323
+ return newDropTargets;
3324
+ };
3325
+
3326
+ const isEqual = (a, b) => {
3327
+ if (a.length !== b.length) {
3328
+ return false;
3329
+ }
3330
+ const length = a.length;
3331
+ for (let i = 0; i < length; i++) {
3332
+ if (a[i] !== b[i]) {
3333
+ return false;
3334
+ }
3335
+ }
3336
+ return true;
3337
+ };
3338
+
3339
+ const handleDragOver = (state, x, y) => {
3340
+ number(x);
3341
+ number(y);
3342
+ const {
3343
+ dropTargets
3344
+ } = state;
3345
+ const newDropTargets = getNewDropTargets(state, x, y);
3346
+ if (isEqual(dropTargets, newDropTargets)) {
3347
+ return state;
3348
+ }
3349
+ return {
3350
+ ...state,
3351
+ dropTargets: newDropTargets
3352
+ };
3353
+ };
3354
+
3296
3355
  const renameDirent = state => {
3297
3356
  const {
3298
3357
  focusedIndex,
@@ -3694,6 +3753,7 @@ const commandMap = {
3694
3753
  'Explorer.handleClickOpenFolder': handleClickOpenFolder,
3695
3754
  'Explorer.handleContextMenu': handleContextMenu,
3696
3755
  'Explorer.handleCopy': handleCopy,
3756
+ 'Explorer.handleDragOver': handleDragOver,
3697
3757
  'Explorer.handleDrop': handleDrop,
3698
3758
  'Explorer.handleIconThemeChange': handleIconThemeChange,
3699
3759
  'Explorer.handlePaste': handlePaste,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Explorer Worker",
5
5
  "main": "dist/explorerViewWorkerMain.js",
6
6
  "type": "module",