@lvce-editor/explorer-view 3.6.0 → 3.8.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 +69 -26
- package/package.json +1 -1
|
@@ -2038,6 +2038,11 @@ const treeToArray = (map, root) => {
|
|
|
2038
2038
|
return items;
|
|
2039
2039
|
};
|
|
2040
2040
|
|
|
2041
|
+
const EmptyString = '';
|
|
2042
|
+
const Slash$1 = '/';
|
|
2043
|
+
const Dot = '.';
|
|
2044
|
+
const BackSlash = '\\';
|
|
2045
|
+
|
|
2041
2046
|
const emptyObject = {};
|
|
2042
2047
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
2043
2048
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
@@ -2058,6 +2063,8 @@ const Cut = 'Cut';
|
|
|
2058
2063
|
const Delete = 'Delete';
|
|
2059
2064
|
const FileNameCannotStartWithSlash = 'A file or folder name cannot start with a slash.';
|
|
2060
2065
|
const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
|
|
2066
|
+
const FileCannotStartWithDot = 'A file or folder name cannot start with a dot.';
|
|
2067
|
+
const FileCannotStartWithBackSlash = 'A file or folder name cannot start with a backslash.';
|
|
2061
2068
|
const FilesExplorer = 'Files Explorer';
|
|
2062
2069
|
const NewFile$1 = 'New File...';
|
|
2063
2070
|
const NewFolder$1 = 'New Folder...';
|
|
@@ -2124,6 +2131,12 @@ const fileOrFolderNameMustBeProvided = () => {
|
|
|
2124
2131
|
const fileCannotStartWithSlash = () => {
|
|
2125
2132
|
return i18nString(FileNameCannotStartWithSlash);
|
|
2126
2133
|
};
|
|
2134
|
+
const fileCannotStartWithDot = () => {
|
|
2135
|
+
return i18nString(FileCannotStartWithDot);
|
|
2136
|
+
};
|
|
2137
|
+
const fileCannotStartWithBackSlash = () => {
|
|
2138
|
+
return i18nString(FileCannotStartWithBackSlash);
|
|
2139
|
+
};
|
|
2127
2140
|
const typeAFileName = () => {
|
|
2128
2141
|
return i18nString(TypeAFileName);
|
|
2129
2142
|
};
|
|
@@ -2133,9 +2146,15 @@ const validateFileName2 = name => {
|
|
|
2133
2146
|
const editingErrorMessage = fileOrFolderNameMustBeProvided();
|
|
2134
2147
|
return editingErrorMessage;
|
|
2135
2148
|
}
|
|
2136
|
-
if (name.startsWith(
|
|
2149
|
+
if (name.startsWith(Dot)) {
|
|
2150
|
+
return fileCannotStartWithDot();
|
|
2151
|
+
}
|
|
2152
|
+
if (name.startsWith(Slash$1)) {
|
|
2137
2153
|
return fileCannotStartWithSlash();
|
|
2138
2154
|
}
|
|
2155
|
+
if (name.startsWith(BackSlash)) {
|
|
2156
|
+
return fileCannotStartWithBackSlash();
|
|
2157
|
+
}
|
|
2139
2158
|
return '';
|
|
2140
2159
|
};
|
|
2141
2160
|
|
|
@@ -2321,12 +2340,17 @@ const isNormalItem = item => {
|
|
|
2321
2340
|
return item.type !== EditingFile && item.type !== EditingFolder;
|
|
2322
2341
|
};
|
|
2323
2342
|
|
|
2324
|
-
const cancelEditCreate = (state, keepFocus) => {
|
|
2343
|
+
const cancelEditCreate = async (state, keepFocus) => {
|
|
2325
2344
|
const {
|
|
2326
2345
|
editingIndex,
|
|
2327
|
-
items
|
|
2346
|
+
items,
|
|
2347
|
+
fileIconCache
|
|
2328
2348
|
} = state;
|
|
2329
2349
|
const filteredItems = items.filter(isNormalItem);
|
|
2350
|
+
const {
|
|
2351
|
+
icons,
|
|
2352
|
+
newFileIconCache
|
|
2353
|
+
} = await getFileIcons(filteredItems, fileIconCache);
|
|
2330
2354
|
return {
|
|
2331
2355
|
...state,
|
|
2332
2356
|
items: filteredItems,
|
|
@@ -2336,7 +2360,9 @@ const cancelEditCreate = (state, keepFocus) => {
|
|
|
2336
2360
|
editingValue: '',
|
|
2337
2361
|
editingErrorMessage: '',
|
|
2338
2362
|
editingType: None$5,
|
|
2339
|
-
focus: List
|
|
2363
|
+
focus: List,
|
|
2364
|
+
icons,
|
|
2365
|
+
fileIconCache: newFileIconCache
|
|
2340
2366
|
};
|
|
2341
2367
|
};
|
|
2342
2368
|
|
|
@@ -2378,7 +2404,7 @@ const cancelEditRename = (state, keepFocus) => {
|
|
|
2378
2404
|
};
|
|
2379
2405
|
};
|
|
2380
2406
|
|
|
2381
|
-
const cancelEditInternal = (state, keepFocus) => {
|
|
2407
|
+
const cancelEditInternal = async (state, keepFocus) => {
|
|
2382
2408
|
const {
|
|
2383
2409
|
editingType
|
|
2384
2410
|
} = state;
|
|
@@ -2388,7 +2414,7 @@ const cancelEditInternal = (state, keepFocus) => {
|
|
|
2388
2414
|
return cancelEditCreate(state, keepFocus);
|
|
2389
2415
|
};
|
|
2390
2416
|
|
|
2391
|
-
const cancelEdit = state => {
|
|
2417
|
+
const cancelEdit = async state => {
|
|
2392
2418
|
return cancelEditInternal(state, true);
|
|
2393
2419
|
};
|
|
2394
2420
|
|
|
@@ -2563,7 +2589,9 @@ const create$1 = () => {
|
|
|
2563
2589
|
const {
|
|
2564
2590
|
get,
|
|
2565
2591
|
set,
|
|
2566
|
-
wrapCommand
|
|
2592
|
+
wrapCommand,
|
|
2593
|
+
registerCommands,
|
|
2594
|
+
getCommandIds
|
|
2567
2595
|
} = create$1();
|
|
2568
2596
|
|
|
2569
2597
|
const ListItem = 22;
|
|
@@ -3011,12 +3039,6 @@ const focusPrevious = state => {
|
|
|
3011
3039
|
}
|
|
3012
3040
|
};
|
|
3013
3041
|
|
|
3014
|
-
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'];
|
|
3015
|
-
|
|
3016
|
-
const getCommandIds = () => {
|
|
3017
|
-
return commandIds;
|
|
3018
|
-
};
|
|
3019
|
-
|
|
3020
3042
|
const mergeClassNames = (...classNames) => {
|
|
3021
3043
|
return classNames.filter(Boolean).join(' ');
|
|
3022
3044
|
};
|
|
@@ -3124,6 +3146,10 @@ const getKeyBindings = () => {
|
|
|
3124
3146
|
key: Enter,
|
|
3125
3147
|
command: 'Explorer.handleClickCurrent',
|
|
3126
3148
|
when: FocusExplorer
|
|
3149
|
+
}, {
|
|
3150
|
+
key: Escape,
|
|
3151
|
+
command: 'Explorer.handleEscape',
|
|
3152
|
+
when: FocusExplorer
|
|
3127
3153
|
}, {
|
|
3128
3154
|
key: CtrlCmd | KeyA,
|
|
3129
3155
|
command: 'Explorer.selectAll',
|
|
@@ -4305,6 +4331,13 @@ const handleDrop = async (state, x, y, fileIds, fileList) => {
|
|
|
4305
4331
|
}
|
|
4306
4332
|
};
|
|
4307
4333
|
|
|
4334
|
+
const handleEscape = async state => {
|
|
4335
|
+
return {
|
|
4336
|
+
...state,
|
|
4337
|
+
cutItems: []
|
|
4338
|
+
};
|
|
4339
|
+
};
|
|
4340
|
+
|
|
4308
4341
|
const handleFocus = async state => {
|
|
4309
4342
|
await setFocus(FocusExplorer);
|
|
4310
4343
|
return state;
|
|
@@ -4499,18 +4532,26 @@ const generateUniqueName = (baseName, existingPaths, root) => {
|
|
|
4499
4532
|
}
|
|
4500
4533
|
};
|
|
4501
4534
|
|
|
4502
|
-
const getFileOperationsCopy = (root, existingUris, files) => {
|
|
4535
|
+
const getFileOperationsCopy = (root, existingUris, files, focusedUri) => {
|
|
4503
4536
|
const operations = [];
|
|
4504
4537
|
for (const file of files) {
|
|
4505
4538
|
const baseName = getBaseName('/', file);
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4539
|
+
if (existingUris.includes(file)) {
|
|
4540
|
+
operations.push({
|
|
4541
|
+
type: Rename$2,
|
|
4542
|
+
from: file,
|
|
4543
|
+
path: join2(focusedUri, baseName)
|
|
4544
|
+
});
|
|
4545
|
+
} else {
|
|
4546
|
+
const uniqueName = generateUniqueName(baseName, existingUris, root);
|
|
4547
|
+
const newUri = join2(root, uniqueName);
|
|
4548
|
+
operations.push({
|
|
4549
|
+
type: Copy$1,
|
|
4550
|
+
from: file,
|
|
4551
|
+
// TODO ensure file is uri
|
|
4552
|
+
path: newUri
|
|
4553
|
+
});
|
|
4554
|
+
}
|
|
4514
4555
|
}
|
|
4515
4556
|
return operations;
|
|
4516
4557
|
};
|
|
@@ -4525,10 +4566,12 @@ const handlePasteCopy = async (state, nativeFiles) => {
|
|
|
4525
4566
|
// TODO use file operations and bulk edit
|
|
4526
4567
|
const {
|
|
4527
4568
|
items,
|
|
4528
|
-
root
|
|
4569
|
+
root,
|
|
4570
|
+
focusedIndex
|
|
4529
4571
|
} = state;
|
|
4572
|
+
const focusedUri = items[focusedIndex]?.path || root;
|
|
4530
4573
|
const existingUris = items.map(item => item.path);
|
|
4531
|
-
const operations = getFileOperationsCopy(root, existingUris, nativeFiles.files);
|
|
4574
|
+
const operations = getFileOperationsCopy(root, existingUris, nativeFiles.files, focusedUri);
|
|
4532
4575
|
// TODO handle error?
|
|
4533
4576
|
await applyFileOperations(operations);
|
|
4534
4577
|
|
|
@@ -4737,8 +4780,6 @@ const getSettings = async () => {
|
|
|
4737
4780
|
};
|
|
4738
4781
|
};
|
|
4739
4782
|
|
|
4740
|
-
const EmptyString = '';
|
|
4741
|
-
|
|
4742
4783
|
const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
|
|
4743
4784
|
let children = map[path];
|
|
4744
4785
|
if (!children) {
|
|
@@ -6270,6 +6311,7 @@ const commandMap = {
|
|
|
6270
6311
|
'Explorer.getMouseActions': getMouseActions,
|
|
6271
6312
|
'Explorer.handleArrowLeft': wrapCommand(handleArrowLeft),
|
|
6272
6313
|
'Explorer.handleArrowRight': wrapCommand(handleArrowRight),
|
|
6314
|
+
'Explorer.handleEscape': wrapCommand(handleEscape),
|
|
6273
6315
|
'Explorer.handleBlur': wrapCommand(handleBlur),
|
|
6274
6316
|
'Explorer.handleClick': wrapCommand(handleClick),
|
|
6275
6317
|
'Explorer.handleClickAt': wrapCommand(handleClickAt),
|
|
@@ -6328,6 +6370,7 @@ const commandMap = {
|
|
|
6328
6370
|
};
|
|
6329
6371
|
|
|
6330
6372
|
const listen = async () => {
|
|
6373
|
+
registerCommands(commandMap);
|
|
6331
6374
|
const rpc = await WebWorkerRpcClient.create({
|
|
6332
6375
|
commandMap: commandMap
|
|
6333
6376
|
});
|