@lvce-editor/explorer-view 6.2.0 → 6.3.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.
@@ -941,6 +941,7 @@ const OpenFolder$1 = 'Open folder';
941
941
  const OpenInIntegratedTerminal = 'Open in integrated Terminal';
942
942
  const Paste = 'Paste';
943
943
  const RefreshExplorer = 'Refresh Explorer';
944
+ const RemoveFolderFromWorkspace = 'Remove folder from workspace';
944
945
  const Rename = 'Rename';
945
946
  const TheNameIsNotValid = 'The name **{0}** is not valid as a file or folder name. Please choose a different name.';
946
947
  const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
@@ -982,6 +983,9 @@ const deleteItem = () => {
982
983
  const refresh$1 = () => {
983
984
  return i18nString(RefreshExplorer);
984
985
  };
986
+ const removeFolderFromWorkspace = () => {
987
+ return i18nString(RemoveFolderFromWorkspace);
988
+ };
985
989
  const collapseAll$1 = () => {
986
990
  return i18nString(CollapseAllFoldersInExplorer);
987
991
  };
@@ -1325,14 +1329,9 @@ const getFocusedDirent$1 = state => {
1325
1329
 
1326
1330
  const copyPath = async state => {
1327
1331
  const dirent = getFocusedDirent$1(state);
1328
- if (!dirent) {
1329
- return state;
1330
- }
1331
1332
  // TODO windows paths
1332
1333
  // TODO handle error
1333
- const {
1334
- path
1335
- } = dirent;
1334
+ const path = dirent ? dirent.path : state.root;
1336
1335
  await writeClipBoardText(path);
1337
1336
  return state;
1338
1337
  };
@@ -2556,6 +2555,12 @@ const menuEntryDelete = {
2556
2555
  id: 'delete',
2557
2556
  label: deleteItem()
2558
2557
  };
2558
+ const menuEntryRemoveFolderFromWorkspace = {
2559
+ command: 'Workspace.close',
2560
+ flags: None$2,
2561
+ id: 'removeFolderFromWorkspace',
2562
+ label: removeFolderFromWorkspace()
2563
+ };
2559
2564
  const ALL_ENTRIES = [menuEntryNewFile, menuEntryNewFolder, menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryRename, menuEntryDelete];
2560
2565
 
2561
2566
  // TODO there are two possible ways of getting the focused dirent of explorer
@@ -2576,13 +2581,17 @@ const getMenuEntriesFile = () => {
2576
2581
  const getMenuEntriesDefault = () => {
2577
2582
  return ALL_ENTRIES;
2578
2583
  };
2579
- const getMenuEntriesRoot = () => {
2580
- return [menuEntryNewFile, menuEntryNewFolder, menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath];
2584
+ const getMenuEntriesRoot = root => {
2585
+ const entries = [menuEntryNewFile, menuEntryNewFolder, menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath];
2586
+ if (root) {
2587
+ entries.push(menuEntrySeparator, menuEntryRemoveFolderFromWorkspace);
2588
+ }
2589
+ return entries;
2581
2590
  };
2582
2591
  const getMenuEntries = state => {
2583
2592
  const focusedDirent = getFocusedDirent(state);
2584
2593
  if (!focusedDirent) {
2585
- return getMenuEntriesRoot();
2594
+ return getMenuEntriesRoot(state.root);
2586
2595
  }
2587
2596
  switch (focusedDirent.type) {
2588
2597
  case Directory:
@@ -3829,16 +3838,24 @@ const getFileOperations = (root, uploadTree) => {
3829
3838
  };
3830
3839
 
3831
3840
  const isDroppedFile = item => {
3832
- return item.kind === 'file' && 'value' in item && item.value instanceof FileSystemHandle;
3841
+ return item.kind === 'file' && 'value' in item;
3842
+ };
3843
+ const getFileSystemHandle = item => {
3844
+ if (isDroppedFile(item)) {
3845
+ return item.value;
3846
+ }
3847
+ return item;
3848
+ };
3849
+ const getDroppedName = item => {
3850
+ if (isDroppedFile(item)) {
3851
+ return item.value.name;
3852
+ }
3853
+ return item.name;
3833
3854
  };
3834
3855
  const getFileSystemHandlesNormalized = fileSystemHandles => {
3835
3856
  const normalized = [];
3836
3857
  for (const item of fileSystemHandles) {
3837
- if (isDroppedFile(item)) {
3838
- normalized.push(item.value);
3839
- } else {
3840
- normalized.push(item);
3841
- }
3858
+ normalized.push(getFileSystemHandle(item));
3842
3859
  }
3843
3860
  return normalized;
3844
3861
  };
@@ -3870,7 +3887,7 @@ const getMergedDirents$2 = async (root, pathSeparator, dirents) => {
3870
3887
  const getDroppedDirectoryWorkspacePath = fileHandle => {
3871
3888
  return `html://${fileHandle.name}`;
3872
3889
  };
3873
- const openDroppedDirectoryAsWorkspace = async (state, fileHandle) => {
3890
+ const openDroppedDirectoryAsWorkspace$1 = async (state, fileHandle) => {
3874
3891
  const path = getDroppedDirectoryWorkspacePath(fileHandle);
3875
3892
  await invoke$2('PersistentFileHandle.addHandle', fileHandle.name, fileHandle);
3876
3893
  await invoke$2('Workspace.setPath', path);
@@ -3884,17 +3901,15 @@ const getFirstDroppedDirectory = (state, fileHandles) => {
3884
3901
  if (state.root !== '') {
3885
3902
  return undefined;
3886
3903
  }
3887
- for (const fileHandle of fileHandles) {
3904
+ for (const item of fileHandles) {
3905
+ const fileHandle = getFileSystemHandle(item);
3888
3906
  if (isDirectoryHandle(fileHandle)) {
3889
3907
  return fileHandle;
3890
3908
  }
3891
3909
  }
3892
3910
  return undefined;
3893
3911
  };
3894
- const shouldIgnoreDroppedHandles = (state, fileHandles) => {
3895
- return state.root === '' && fileHandles.length > 0 && !getFirstDroppedDirectory(state, fileHandles);
3896
- };
3897
- const handleDrop$2 = async (state, fileHandles, files) => {
3912
+ const handleDrop$2 = async (state, fileHandles, files, paths) => {
3898
3913
  const {
3899
3914
  items,
3900
3915
  pathSeparator,
@@ -3902,9 +3917,9 @@ const handleDrop$2 = async (state, fileHandles, files) => {
3902
3917
  } = state;
3903
3918
  const droppedDirectory = getFirstDroppedDirectory(state, fileHandles);
3904
3919
  if (droppedDirectory) {
3905
- return openDroppedDirectoryAsWorkspace(state, droppedDirectory);
3920
+ return openDroppedDirectoryAsWorkspace$1(state, droppedDirectory);
3906
3921
  }
3907
- if (shouldIgnoreDroppedHandles(state, fileHandles)) {
3922
+ if (root === '') {
3908
3923
  return {
3909
3924
  ...state,
3910
3925
  dropTargets: []
@@ -3930,9 +3945,7 @@ const getFileOperationsElectron = async (root, paths, fileHandles, pathSeparator
3930
3945
  const operations = [];
3931
3946
  for (let i = 0; i < paths.length; i++) {
3932
3947
  const fileHandle = fileHandles[i];
3933
- const {
3934
- name
3935
- } = fileHandle;
3948
+ const name = getDroppedName(fileHandle);
3936
3949
  const path = paths[i];
3937
3950
  operations.push({
3938
3951
  from: path,
@@ -3958,12 +3971,42 @@ const getMergedDirents$1 = async (root, pathSeparator, dirents) => {
3958
3971
  const mergedDirents = mergeDirents(dirents, childDirents);
3959
3972
  return mergedDirents;
3960
3973
  };
3974
+ const openDroppedDirectoryAsWorkspace = async (state, path) => {
3975
+ await invoke$2('Workspace.setPath', path);
3976
+ const updated = await loadContent(state, undefined);
3977
+ return {
3978
+ ...updated,
3979
+ dropTargets: []
3980
+ };
3981
+ };
3982
+ const getFirstDroppedDirectoryPath = (state, fileHandles, paths) => {
3983
+ if (state.root !== '') {
3984
+ return undefined;
3985
+ }
3986
+ for (let i = 0; i < fileHandles.length; i++) {
3987
+ const fileHandle = getFileSystemHandle(fileHandles[i]);
3988
+ if (isDirectoryHandle(fileHandle)) {
3989
+ return paths[i];
3990
+ }
3991
+ }
3992
+ return undefined;
3993
+ };
3961
3994
  const handleDrop$1 = async (state, fileHandles, files, paths) => {
3962
3995
  const {
3963
3996
  items,
3964
3997
  pathSeparator,
3965
3998
  root
3966
3999
  } = state;
4000
+ const droppedDirectoryPath = getFirstDroppedDirectoryPath(state, fileHandles, paths);
4001
+ if (droppedDirectoryPath) {
4002
+ return openDroppedDirectoryAsWorkspace(state, droppedDirectoryPath);
4003
+ }
4004
+ if (root === '') {
4005
+ return {
4006
+ ...state,
4007
+ dropTargets: []
4008
+ };
4009
+ }
3967
4010
  await copyFilesElectron(root, fileHandles, files, paths);
3968
4011
  const mergedDirents = await getMergedDirents$1(root, pathSeparator, items);
3969
4012
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",