@lvce-editor/explorer-view 2.41.0 → 2.42.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.
- package/dist/explorerViewWorkerMain.js +146 -114
- package/package.json +1 -1
|
@@ -1001,92 +1001,6 @@ const CreateFile = 1;
|
|
|
1001
1001
|
const CreateFolder = 2;
|
|
1002
1002
|
const Rename$1 = 3;
|
|
1003
1003
|
|
|
1004
|
-
const emptyObject = {};
|
|
1005
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1006
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1007
|
-
if (placeholders === emptyObject) {
|
|
1008
|
-
return key;
|
|
1009
|
-
}
|
|
1010
|
-
const replacer = (match, rest) => {
|
|
1011
|
-
return placeholders[rest];
|
|
1012
|
-
};
|
|
1013
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
|
-
const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
|
|
1017
|
-
const Copy$1 = 'Copy';
|
|
1018
|
-
const CopyPath = 'Copy Path';
|
|
1019
|
-
const CopyRelativePath = 'Copy Relative Path';
|
|
1020
|
-
const Cut$1 = 'Cut';
|
|
1021
|
-
const Delete$1 = 'Delete';
|
|
1022
|
-
const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
|
|
1023
|
-
const FilesExplorer = 'Files Explorer';
|
|
1024
|
-
const NewFile$1 = 'New File...';
|
|
1025
|
-
const NewFolder$1 = 'New Folder...';
|
|
1026
|
-
const OpenContainingFolder = 'Open Containing Folder';
|
|
1027
|
-
const OpenFolder = 'Open folder';
|
|
1028
|
-
const OpenInIntegratedTerminal = 'Open in integrated Terminal';
|
|
1029
|
-
const Paste = 'Paste';
|
|
1030
|
-
const RefreshExplorer = 'Refresh Explorer';
|
|
1031
|
-
const Rename = 'Rename';
|
|
1032
|
-
const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
|
|
1033
|
-
const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
|
|
1034
|
-
|
|
1035
|
-
const newFile$1 = () => {
|
|
1036
|
-
return i18nString(NewFile$1);
|
|
1037
|
-
};
|
|
1038
|
-
const newFolder$1 = () => {
|
|
1039
|
-
return i18nString(NewFolder$1);
|
|
1040
|
-
};
|
|
1041
|
-
const openContainingFolder$1 = () => {
|
|
1042
|
-
return i18nString(OpenContainingFolder);
|
|
1043
|
-
};
|
|
1044
|
-
const openInIntegratedTerminal = () => {
|
|
1045
|
-
return i18nString(OpenInIntegratedTerminal);
|
|
1046
|
-
};
|
|
1047
|
-
const cut = () => {
|
|
1048
|
-
return i18nString(Cut$1);
|
|
1049
|
-
};
|
|
1050
|
-
const copy = () => {
|
|
1051
|
-
return i18nString(Copy$1);
|
|
1052
|
-
};
|
|
1053
|
-
const paste = () => {
|
|
1054
|
-
return i18nString(Paste);
|
|
1055
|
-
};
|
|
1056
|
-
const copyPath$1 = () => {
|
|
1057
|
-
return i18nString(CopyPath);
|
|
1058
|
-
};
|
|
1059
|
-
const copyRelativePath$1 = () => {
|
|
1060
|
-
return i18nString(CopyRelativePath);
|
|
1061
|
-
};
|
|
1062
|
-
const rename = () => {
|
|
1063
|
-
return i18nString(Rename);
|
|
1064
|
-
};
|
|
1065
|
-
const deleteItem = () => {
|
|
1066
|
-
return i18nString(Delete$1);
|
|
1067
|
-
};
|
|
1068
|
-
const refresh$1 = () => {
|
|
1069
|
-
return i18nString(RefreshExplorer);
|
|
1070
|
-
};
|
|
1071
|
-
const collapseAll$1 = () => {
|
|
1072
|
-
return i18nString(CollapseAllFoldersInExplorer);
|
|
1073
|
-
};
|
|
1074
|
-
const filesExplorer = () => {
|
|
1075
|
-
return i18nString(FilesExplorer);
|
|
1076
|
-
};
|
|
1077
|
-
const youHaveNotYetOpenedAFolder = () => {
|
|
1078
|
-
return i18nString(YouHaveNotYetOpenedAFolder);
|
|
1079
|
-
};
|
|
1080
|
-
const openFolder$1 = () => {
|
|
1081
|
-
return i18nString(OpenFolder);
|
|
1082
|
-
};
|
|
1083
|
-
const fileOrFolderNameMustBeProvided = () => {
|
|
1084
|
-
return i18nString(FileOrFolderNameMustBeProvider);
|
|
1085
|
-
};
|
|
1086
|
-
const typeAFileName = () => {
|
|
1087
|
-
return i18nString(TypeAFileName);
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
1004
|
const List = 1;
|
|
1091
1005
|
const Input$1 = 2;
|
|
1092
1006
|
|
|
@@ -1447,6 +1361,100 @@ const treeToArray = (map, root) => {
|
|
|
1447
1361
|
return items;
|
|
1448
1362
|
};
|
|
1449
1363
|
|
|
1364
|
+
const emptyObject = {};
|
|
1365
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1366
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1367
|
+
if (placeholders === emptyObject) {
|
|
1368
|
+
return key;
|
|
1369
|
+
}
|
|
1370
|
+
const replacer = (match, rest) => {
|
|
1371
|
+
return placeholders[rest];
|
|
1372
|
+
};
|
|
1373
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
|
|
1377
|
+
const Copy$1 = 'Copy';
|
|
1378
|
+
const CopyPath = 'Copy Path';
|
|
1379
|
+
const CopyRelativePath = 'Copy Relative Path';
|
|
1380
|
+
const Cut$1 = 'Cut';
|
|
1381
|
+
const Delete$1 = 'Delete';
|
|
1382
|
+
const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
|
|
1383
|
+
const FilesExplorer = 'Files Explorer';
|
|
1384
|
+
const NewFile$1 = 'New File...';
|
|
1385
|
+
const NewFolder$1 = 'New Folder...';
|
|
1386
|
+
const OpenContainingFolder = 'Open Containing Folder';
|
|
1387
|
+
const OpenFolder = 'Open folder';
|
|
1388
|
+
const OpenInIntegratedTerminal = 'Open in integrated Terminal';
|
|
1389
|
+
const Paste = 'Paste';
|
|
1390
|
+
const RefreshExplorer = 'Refresh Explorer';
|
|
1391
|
+
const Rename = 'Rename';
|
|
1392
|
+
const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
|
|
1393
|
+
const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
|
|
1394
|
+
|
|
1395
|
+
const newFile$1 = () => {
|
|
1396
|
+
return i18nString(NewFile$1);
|
|
1397
|
+
};
|
|
1398
|
+
const newFolder$1 = () => {
|
|
1399
|
+
return i18nString(NewFolder$1);
|
|
1400
|
+
};
|
|
1401
|
+
const openContainingFolder$1 = () => {
|
|
1402
|
+
return i18nString(OpenContainingFolder);
|
|
1403
|
+
};
|
|
1404
|
+
const openInIntegratedTerminal = () => {
|
|
1405
|
+
return i18nString(OpenInIntegratedTerminal);
|
|
1406
|
+
};
|
|
1407
|
+
const cut = () => {
|
|
1408
|
+
return i18nString(Cut$1);
|
|
1409
|
+
};
|
|
1410
|
+
const copy = () => {
|
|
1411
|
+
return i18nString(Copy$1);
|
|
1412
|
+
};
|
|
1413
|
+
const paste = () => {
|
|
1414
|
+
return i18nString(Paste);
|
|
1415
|
+
};
|
|
1416
|
+
const copyPath$1 = () => {
|
|
1417
|
+
return i18nString(CopyPath);
|
|
1418
|
+
};
|
|
1419
|
+
const copyRelativePath$1 = () => {
|
|
1420
|
+
return i18nString(CopyRelativePath);
|
|
1421
|
+
};
|
|
1422
|
+
const rename = () => {
|
|
1423
|
+
return i18nString(Rename);
|
|
1424
|
+
};
|
|
1425
|
+
const deleteItem = () => {
|
|
1426
|
+
return i18nString(Delete$1);
|
|
1427
|
+
};
|
|
1428
|
+
const refresh$1 = () => {
|
|
1429
|
+
return i18nString(RefreshExplorer);
|
|
1430
|
+
};
|
|
1431
|
+
const collapseAll$1 = () => {
|
|
1432
|
+
return i18nString(CollapseAllFoldersInExplorer);
|
|
1433
|
+
};
|
|
1434
|
+
const filesExplorer = () => {
|
|
1435
|
+
return i18nString(FilesExplorer);
|
|
1436
|
+
};
|
|
1437
|
+
const youHaveNotYetOpenedAFolder = () => {
|
|
1438
|
+
return i18nString(YouHaveNotYetOpenedAFolder);
|
|
1439
|
+
};
|
|
1440
|
+
const openFolder$1 = () => {
|
|
1441
|
+
return i18nString(OpenFolder);
|
|
1442
|
+
};
|
|
1443
|
+
const fileOrFolderNameMustBeProvided = () => {
|
|
1444
|
+
return i18nString(FileOrFolderNameMustBeProvider);
|
|
1445
|
+
};
|
|
1446
|
+
const typeAFileName = () => {
|
|
1447
|
+
return i18nString(TypeAFileName);
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1450
|
+
const validateFileName2 = name => {
|
|
1451
|
+
if (!name) {
|
|
1452
|
+
const editingErrorMessage = fileOrFolderNameMustBeProvided();
|
|
1453
|
+
return editingErrorMessage;
|
|
1454
|
+
}
|
|
1455
|
+
return '';
|
|
1456
|
+
};
|
|
1457
|
+
|
|
1450
1458
|
const acceptCreate = async (state, newDirentType, createFn) => {
|
|
1451
1459
|
const {
|
|
1452
1460
|
editingValue,
|
|
@@ -1460,11 +1468,8 @@ const acceptCreate = async (state, newDirentType, createFn) => {
|
|
|
1460
1468
|
items
|
|
1461
1469
|
} = state;
|
|
1462
1470
|
const newFileName = editingValue;
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
// below input box
|
|
1466
|
-
// await ErrorHandling.showErrorDialog(new Error('file name must not be empty'))
|
|
1467
|
-
const editingErrorMessage = fileOrFolderNameMustBeProvided();
|
|
1471
|
+
const editingErrorMessage = validateFileName2(newFileName);
|
|
1472
|
+
if (editingErrorMessage) {
|
|
1468
1473
|
return {
|
|
1469
1474
|
...state,
|
|
1470
1475
|
editingErrorMessage
|
|
@@ -1552,6 +1557,13 @@ const acceptRename = async state => {
|
|
|
1552
1557
|
itemHeight,
|
|
1553
1558
|
fileIconCache
|
|
1554
1559
|
} = state;
|
|
1560
|
+
const editingErrorMessage = validateFileName2(editingValue);
|
|
1561
|
+
if (editingErrorMessage) {
|
|
1562
|
+
return {
|
|
1563
|
+
...state,
|
|
1564
|
+
editingErrorMessage
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1555
1567
|
const renamedDirent = items[editingIndex];
|
|
1556
1568
|
const successful = await createNewDirentsRename(renamedDirent, editingValue);
|
|
1557
1569
|
if (!successful) {
|
|
@@ -1581,7 +1593,9 @@ const acceptRename = async state => {
|
|
|
1581
1593
|
focus: List,
|
|
1582
1594
|
items: newDirents,
|
|
1583
1595
|
icons,
|
|
1584
|
-
fileIconCache: newFileIconCache
|
|
1596
|
+
fileIconCache: newFileIconCache,
|
|
1597
|
+
editingSelectionEnd: 0,
|
|
1598
|
+
editingSelectionStart: 0
|
|
1585
1599
|
};
|
|
1586
1600
|
};
|
|
1587
1601
|
|
|
@@ -1656,7 +1670,9 @@ const cancelEditRename = (state, keepFocus) => {
|
|
|
1656
1670
|
editingValue: '',
|
|
1657
1671
|
editingType: None$5,
|
|
1658
1672
|
editingErrorMessage: '',
|
|
1659
|
-
focus: List
|
|
1673
|
+
focus: List,
|
|
1674
|
+
editingSelectionStart: 0,
|
|
1675
|
+
editingSelectionEnd: 0
|
|
1660
1676
|
};
|
|
1661
1677
|
};
|
|
1662
1678
|
|
|
@@ -1844,10 +1860,8 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
1844
1860
|
focus: 0,
|
|
1845
1861
|
editingErrorMessage: '',
|
|
1846
1862
|
inputSource: 0,
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
end: 0
|
|
1850
|
-
},
|
|
1863
|
+
editingSelectionEnd: 0,
|
|
1864
|
+
editingSelectionStart: 0,
|
|
1851
1865
|
focusWord: '',
|
|
1852
1866
|
focusWordTimeout: 800,
|
|
1853
1867
|
finalDeltaY: 0,
|
|
@@ -1891,10 +1905,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1891
1905
|
focus: 0,
|
|
1892
1906
|
editingErrorMessage: '',
|
|
1893
1907
|
inputSource: 0,
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
end: 0
|
|
1897
|
-
},
|
|
1908
|
+
editingSelectionStart: 0,
|
|
1909
|
+
editingSelectionEnd: 0,
|
|
1898
1910
|
focusWord: '',
|
|
1899
1911
|
focusWordTimeout: 800,
|
|
1900
1912
|
finalDeltaY: 0,
|
|
@@ -1924,7 +1936,7 @@ const isEqual$3 = (oldState, newState) => {
|
|
|
1924
1936
|
|
|
1925
1937
|
const diffType$1 = RenderSelection;
|
|
1926
1938
|
const isEqual$2 = (oldState, newState) => {
|
|
1927
|
-
return oldState.
|
|
1939
|
+
return oldState.editingSelectionStart === newState.editingSelectionStart && oldState.editingSelectionEnd === newState.editingSelectionEnd;
|
|
1928
1940
|
};
|
|
1929
1941
|
|
|
1930
1942
|
const diffType = RenderValue;
|
|
@@ -4131,6 +4143,7 @@ const getNewDirentsForRename = (items, focusedIndex) => {
|
|
|
4131
4143
|
const item = items[focusedIndex];
|
|
4132
4144
|
const newItems = [...items];
|
|
4133
4145
|
const editingType = item.type === File ? EditingFile : EditingFolder;
|
|
4146
|
+
// TODO avoid mutation
|
|
4134
4147
|
newItems[focusedIndex] = {
|
|
4135
4148
|
...item,
|
|
4136
4149
|
type: editingType
|
|
@@ -4138,6 +4151,20 @@ const getNewDirentsForRename = (items, focusedIndex) => {
|
|
|
4138
4151
|
return newItems;
|
|
4139
4152
|
};
|
|
4140
4153
|
|
|
4154
|
+
const getRenameSelectionRange = name => {
|
|
4155
|
+
const dotIndex = name.lastIndexOf('.');
|
|
4156
|
+
if (dotIndex === -1) {
|
|
4157
|
+
return {
|
|
4158
|
+
start: 0,
|
|
4159
|
+
end: name.length
|
|
4160
|
+
};
|
|
4161
|
+
}
|
|
4162
|
+
return {
|
|
4163
|
+
start: 0,
|
|
4164
|
+
end: dotIndex
|
|
4165
|
+
};
|
|
4166
|
+
};
|
|
4167
|
+
|
|
4141
4168
|
const User = 1;
|
|
4142
4169
|
const Script = 2;
|
|
4143
4170
|
|
|
@@ -4153,6 +4180,10 @@ const renameDirent = state => {
|
|
|
4153
4180
|
}
|
|
4154
4181
|
const item = items[focusedIndex];
|
|
4155
4182
|
const newItems = getNewDirentsForRename(items, focusedIndex);
|
|
4183
|
+
const {
|
|
4184
|
+
start,
|
|
4185
|
+
end
|
|
4186
|
+
} = getRenameSelectionRange(item.name);
|
|
4156
4187
|
return {
|
|
4157
4188
|
...state,
|
|
4158
4189
|
items: newItems,
|
|
@@ -4160,21 +4191,24 @@ const renameDirent = state => {
|
|
|
4160
4191
|
editingType: Rename$1,
|
|
4161
4192
|
editingValue: item.name,
|
|
4162
4193
|
editingIcon: icons[focusedIndex - minLineY],
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
end: item.name.length
|
|
4166
|
-
},
|
|
4194
|
+
editingSelectionStart: start,
|
|
4195
|
+
editingSelectionEnd: end,
|
|
4167
4196
|
focus: Input$1,
|
|
4168
4197
|
inputSource: Script
|
|
4169
4198
|
};
|
|
4170
4199
|
};
|
|
4171
4200
|
|
|
4201
|
+
const ExplorerInput = 'ExplorerInput';
|
|
4202
|
+
|
|
4172
4203
|
const renderEditingSelection = (oldState, newState) => {
|
|
4173
|
-
|
|
4204
|
+
const {
|
|
4205
|
+
editingSelectionStart,
|
|
4206
|
+
editingSelectionEnd,
|
|
4207
|
+
uid
|
|
4208
|
+
} = newState;
|
|
4209
|
+
return ['Viewlet.setSelectionByName', uid, ExplorerInput, editingSelectionStart, editingSelectionEnd];
|
|
4174
4210
|
};
|
|
4175
4211
|
|
|
4176
|
-
const ExplorerInput = 'ExplorerInput';
|
|
4177
|
-
|
|
4178
4212
|
const renderFocus$1 = (oldState, newState) => {
|
|
4179
4213
|
if (newState.inputSource === User) {
|
|
4180
4214
|
return [];
|
|
@@ -4682,10 +4716,6 @@ const getRenderer = diffType => {
|
|
|
4682
4716
|
const applyRender = (oldState, newState, diffResult) => {
|
|
4683
4717
|
const commands = [];
|
|
4684
4718
|
for (const item of diffResult) {
|
|
4685
|
-
if (item === RenderSelection) {
|
|
4686
|
-
// TODO support this in the future
|
|
4687
|
-
continue;
|
|
4688
|
-
}
|
|
4689
4719
|
const fn = getRenderer(item);
|
|
4690
4720
|
const result = fn(oldState, newState);
|
|
4691
4721
|
if (result.length > 0) {
|
|
@@ -5145,10 +5175,12 @@ const updateEditingValue = async (state, value, inputSource = User) => {
|
|
|
5145
5175
|
editingIndex
|
|
5146
5176
|
} = state;
|
|
5147
5177
|
const editingIcon = await getEditingIcon(editingType, value, items[editingIndex]?.type);
|
|
5178
|
+
const editingErrorMessage = validateFileName2(value);
|
|
5148
5179
|
return {
|
|
5149
5180
|
...state,
|
|
5150
5181
|
editingValue: value,
|
|
5151
|
-
editingIcon
|
|
5182
|
+
editingIcon,
|
|
5183
|
+
editingErrorMessage
|
|
5152
5184
|
};
|
|
5153
5185
|
};
|
|
5154
5186
|
|