@lvce-editor/explorer-view 1.17.0 → 1.18.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 +41 -15
- package/package.json +1 -1
|
@@ -1813,6 +1813,7 @@ const ButtonWide = 'ButtonWide';
|
|
|
1813
1813
|
const Chevron = 'Chevron';
|
|
1814
1814
|
const Explorer$1 = 'Explorer';
|
|
1815
1815
|
const FileIcon = 'FileIcon';
|
|
1816
|
+
const FocusOutline = 'FocusOutline';
|
|
1816
1817
|
const IconButton = 'IconButton';
|
|
1817
1818
|
const InputBox = 'InputBox';
|
|
1818
1819
|
const Label = 'Label';
|
|
@@ -1957,13 +1958,14 @@ const getExplorerWelcomeVirtualDom = isWide => {
|
|
|
1957
1958
|
}, text(openFolder$1())];
|
|
1958
1959
|
};
|
|
1959
1960
|
|
|
1960
|
-
const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide) => {
|
|
1961
|
+
const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused) => {
|
|
1961
1962
|
if (!root) {
|
|
1962
1963
|
return getExplorerWelcomeVirtualDom(isWide);
|
|
1963
1964
|
}
|
|
1965
|
+
const extraClass = focused && focusedIndex === -1 ? FocusOutline : '';
|
|
1964
1966
|
const dom = [{
|
|
1965
1967
|
type: Div,
|
|
1966
|
-
className: mergeClassNames(Viewlet, Explorer$1),
|
|
1968
|
+
className: mergeClassNames(Viewlet, Explorer$1, extraClass),
|
|
1967
1969
|
tabIndex: 0,
|
|
1968
1970
|
role: Tree,
|
|
1969
1971
|
ariaLabel: filesExplorer(),
|
|
@@ -2304,6 +2306,7 @@ const handleBlur = state => {
|
|
|
2304
2306
|
};
|
|
2305
2307
|
|
|
2306
2308
|
const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
2309
|
+
// @ts-ignore
|
|
2307
2310
|
dirent.type = DirectoryExpanding;
|
|
2308
2311
|
// TODO handle error
|
|
2309
2312
|
const dirents = await getChildDirents(state.pathSeparator, dirent);
|
|
@@ -2319,7 +2322,9 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
2319
2322
|
}
|
|
2320
2323
|
const newDirents = [...state2.items];
|
|
2321
2324
|
newDirents.splice(newIndex + 1, 0, ...dirents);
|
|
2325
|
+
// @ts-ignore
|
|
2322
2326
|
dirent.type = DirectoryExpanded;
|
|
2327
|
+
// @ts-ignore
|
|
2323
2328
|
dirent.icon = getIcon();
|
|
2324
2329
|
const {
|
|
2325
2330
|
height,
|
|
@@ -2348,9 +2353,12 @@ const handleClickDirectoryExpanded$1 = async (state, dirent, index, keepFocus) =
|
|
|
2348
2353
|
const {
|
|
2349
2354
|
minLineY,
|
|
2350
2355
|
maxLineY,
|
|
2351
|
-
itemHeight
|
|
2356
|
+
itemHeight,
|
|
2357
|
+
fileIconCache
|
|
2352
2358
|
} = state;
|
|
2359
|
+
// @ts-ignore
|
|
2353
2360
|
dirent.type = Directory;
|
|
2361
|
+
// @ts-ignore
|
|
2354
2362
|
dirent.icon = getIcon();
|
|
2355
2363
|
const endIndex = getParentEndIndex(state.items, index);
|
|
2356
2364
|
const removeCount = endIndex - index - 1;
|
|
@@ -2367,7 +2375,7 @@ const handleClickDirectoryExpanded$1 = async (state, dirent, index, keepFocus) =
|
|
|
2367
2375
|
const {
|
|
2368
2376
|
icons,
|
|
2369
2377
|
newFileIconCache
|
|
2370
|
-
} = await getFileIcons(parts,
|
|
2378
|
+
} = await getFileIcons(parts, fileIconCache);
|
|
2371
2379
|
return {
|
|
2372
2380
|
...state,
|
|
2373
2381
|
items: newDirents,
|
|
@@ -2384,7 +2392,7 @@ const handleClickDirectoryExpanded$1 = async (state, dirent, index, keepFocus) =
|
|
|
2384
2392
|
const {
|
|
2385
2393
|
icons,
|
|
2386
2394
|
newFileIconCache
|
|
2387
|
-
} = await getFileIcons(parts,
|
|
2395
|
+
} = await getFileIcons(parts, fileIconCache);
|
|
2388
2396
|
return {
|
|
2389
2397
|
...state,
|
|
2390
2398
|
items: newDirents,
|
|
@@ -2396,7 +2404,9 @@ const handleClickDirectoryExpanded$1 = async (state, dirent, index, keepFocus) =
|
|
|
2396
2404
|
};
|
|
2397
2405
|
|
|
2398
2406
|
const handleClickDirectoryExpanding = async (state, dirent, index, keepFocus) => {
|
|
2407
|
+
// @ts-ignore
|
|
2399
2408
|
dirent.type = Directory;
|
|
2409
|
+
// @ts-ignore
|
|
2400
2410
|
dirent.icon = getIcon();
|
|
2401
2411
|
return {
|
|
2402
2412
|
...state,
|
|
@@ -2405,8 +2415,12 @@ const handleClickDirectoryExpanding = async (state, dirent, index, keepFocus) =>
|
|
|
2405
2415
|
};
|
|
2406
2416
|
};
|
|
2407
2417
|
|
|
2418
|
+
const openUri = async (uri, focus) => {
|
|
2419
|
+
await invoke(/* Main.openAbsolutePath */'Main.openUri', /* absolutePath */uri, /* focus */focus);
|
|
2420
|
+
};
|
|
2421
|
+
|
|
2408
2422
|
const handleClickFile$1 = async (state, dirent, index, keepFocus = false) => {
|
|
2409
|
-
await
|
|
2423
|
+
await openUri(dirent.path, !keepFocus);
|
|
2410
2424
|
return {
|
|
2411
2425
|
...state,
|
|
2412
2426
|
focusedIndex: index,
|
|
@@ -2984,6 +2998,15 @@ const handleDrop = async (state, x, y, files) => {
|
|
|
2984
2998
|
}
|
|
2985
2999
|
};
|
|
2986
3000
|
|
|
3001
|
+
const setFocus = key => {
|
|
3002
|
+
return invoke('Focus.setFocus', key);
|
|
3003
|
+
};
|
|
3004
|
+
|
|
3005
|
+
const handleFocus = async state => {
|
|
3006
|
+
await setFocus(FocusExplorer);
|
|
3007
|
+
return state;
|
|
3008
|
+
};
|
|
3009
|
+
|
|
2987
3010
|
const updateIcon = dirent => {
|
|
2988
3011
|
return {
|
|
2989
3012
|
...dirent,
|
|
@@ -3322,10 +3345,6 @@ const handleWorkspaceChange = async state => {
|
|
|
3322
3345
|
return newState;
|
|
3323
3346
|
};
|
|
3324
3347
|
|
|
3325
|
-
const setFocus = key => {
|
|
3326
|
-
return invoke('Focus.setFocus', key);
|
|
3327
|
-
};
|
|
3328
|
-
|
|
3329
3348
|
const ExplorerEditBox = FocusExplorerEditBox;
|
|
3330
3349
|
|
|
3331
3350
|
const newDirent = async (state, editingType) => {
|
|
@@ -3463,21 +3482,22 @@ const renameDirent = state => {
|
|
|
3463
3482
|
|
|
3464
3483
|
const renderItems = {
|
|
3465
3484
|
isEqual(oldState, newState) {
|
|
3466
|
-
return JSON.stringify(oldState.items) === JSON.stringify(newState.items) && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.width === newState.width;
|
|
3485
|
+
return JSON.stringify(oldState.items) === JSON.stringify(newState.items) && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.width === newState.width && oldState.focused === newState.focused;
|
|
3467
3486
|
},
|
|
3468
3487
|
apply(oldState, newState) {
|
|
3469
3488
|
const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.icons, newState.useChevrons);
|
|
3470
3489
|
const isWide = newState.width > 450;
|
|
3471
|
-
const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide);
|
|
3490
|
+
const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide, newState.focused);
|
|
3472
3491
|
return ['Viewlet.setDom2', dom];
|
|
3473
3492
|
}
|
|
3474
3493
|
};
|
|
3475
3494
|
|
|
3476
|
-
//
|
|
3477
|
-
//
|
|
3495
|
+
// TODO add virtual dom diffing so that focus is not lost when updating dom
|
|
3496
|
+
// const renderFocus = {
|
|
3497
|
+
// isEqual(oldState: any, newState: any) {
|
|
3478
3498
|
// return oldState.focusedIndex === newState.focusedIndex && oldState.focused === newState.focused && oldState.minLineY === newState.minLineY
|
|
3479
3499
|
// },
|
|
3480
|
-
// apply(oldState:any, newState:any) {
|
|
3500
|
+
// apply(oldState: any, newState: any) {
|
|
3481
3501
|
// const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY
|
|
3482
3502
|
// const newFocusedIndex = newState.focusedIndex - newState.minLineY
|
|
3483
3503
|
// return [/* method */ 'setFocusedIndex', /* oldindex */ oldFocusedIndex, /* newIndex */ newFocusedIndex, /* focused */ newState.focused]
|
|
@@ -3860,6 +3880,10 @@ const setDeltaY = (state, deltaY) => {
|
|
|
3860
3880
|
};
|
|
3861
3881
|
};
|
|
3862
3882
|
|
|
3883
|
+
const terminate = () => {
|
|
3884
|
+
globalThis.close();
|
|
3885
|
+
};
|
|
3886
|
+
|
|
3863
3887
|
const updateEditingValue = (state, value) => {
|
|
3864
3888
|
const editingIcon = getFileIcon({
|
|
3865
3889
|
name: value
|
|
@@ -3900,6 +3924,7 @@ const commandMap = {
|
|
|
3900
3924
|
'Explorer.handleCopy': handleCopy,
|
|
3901
3925
|
'Explorer.handleDragOver': handleDragOver,
|
|
3902
3926
|
'Explorer.handleDrop': handleDrop,
|
|
3927
|
+
'Explorer.handleFocus': handleFocus,
|
|
3903
3928
|
'Explorer.handleIconThemeChange': handleIconThemeChange,
|
|
3904
3929
|
'Explorer.handlePaste': handlePaste,
|
|
3905
3930
|
'Explorer.handlePointerDown': handlePointerDown,
|
|
@@ -3918,6 +3943,7 @@ const commandMap = {
|
|
|
3918
3943
|
'Explorer.revealItem': revealItem,
|
|
3919
3944
|
'Explorer.saveState': saveState,
|
|
3920
3945
|
'Explorer.setDeltaY': setDeltaY,
|
|
3946
|
+
'Explorer.terminate': terminate,
|
|
3921
3947
|
'Explorer.updateEditingValue': updateEditingValue,
|
|
3922
3948
|
'Explorer.updateIcons': updateIcons
|
|
3923
3949
|
};
|