@lvce-editor/explorer-view 5.26.0 → 5.27.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/README.md +9 -0
- package/dist/explorerViewWorkerMain.js +78 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2457,13 +2457,6 @@ const mergeClassNames = (...classNames) => {
|
|
|
2457
2457
|
return classNames.filter(Boolean).join(' ');
|
|
2458
2458
|
};
|
|
2459
2459
|
|
|
2460
|
-
const px = value => {
|
|
2461
|
-
return `${value}px`;
|
|
2462
|
-
};
|
|
2463
|
-
const position = (x, y) => {
|
|
2464
|
-
return `${x}px ${y}px`;
|
|
2465
|
-
};
|
|
2466
|
-
|
|
2467
2460
|
const text = data => {
|
|
2468
2461
|
return {
|
|
2469
2462
|
childCount: 0,
|
|
@@ -2884,7 +2877,7 @@ const wrapListItemCommand = fn => {
|
|
|
2884
2877
|
const intermediate = get(id);
|
|
2885
2878
|
set(id, intermediate.oldState, updatedState);
|
|
2886
2879
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, items.length);
|
|
2887
|
-
if (items === intermediate.newState.items && minLineY === intermediate.newState.minLineY && editingIcon === intermediate.newState.editingIcon && cutItems === intermediate.newState.cutItems && editingErrorMessage === intermediate.newState.editingErrorMessage && dropTargets === intermediate.newState.dropTargets && fileIconCache === intermediate.newState.fileIconCache && decorations === intermediate.newState.decorations) {
|
|
2880
|
+
if (items === intermediate.newState.items && minLineY === intermediate.newState.minLineY && height === intermediate.newState.height && itemHeight === intermediate.newState.itemHeight && editingIcon === intermediate.newState.editingIcon && cutItems === intermediate.newState.cutItems && editingErrorMessage === intermediate.newState.editingErrorMessage && dropTargets === intermediate.newState.dropTargets && fileIconCache === intermediate.newState.fileIconCache && decorations === intermediate.newState.decorations) {
|
|
2888
2881
|
return;
|
|
2889
2882
|
}
|
|
2890
2883
|
const visible = items.slice(minLineY, maxLineY);
|
|
@@ -2981,7 +2974,7 @@ const isEqual$6 = (oldState, newState) => {
|
|
|
2981
2974
|
// TODO compute css more optimized
|
|
2982
2975
|
// maybe only when items change, and even then not
|
|
2983
2976
|
// always, but only when it affects the css
|
|
2984
|
-
return oldState.editingErrorMessage === newState.editingErrorMessage && oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems && oldState.width === newState.width;
|
|
2977
|
+
return oldState.deltaY === newState.deltaY && oldState.editingErrorMessage === newState.editingErrorMessage && oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems && oldState.width === newState.width;
|
|
2985
2978
|
};
|
|
2986
2979
|
|
|
2987
2980
|
const isEqual$5 = (oldState, newState) => {
|
|
@@ -5070,6 +5063,48 @@ const handlePointerDown = (state, button, x, y) => {
|
|
|
5070
5063
|
return state;
|
|
5071
5064
|
};
|
|
5072
5065
|
|
|
5066
|
+
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
5067
|
+
if (size >= contentSize) {
|
|
5068
|
+
return 0;
|
|
5069
|
+
}
|
|
5070
|
+
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
5071
|
+
};
|
|
5072
|
+
|
|
5073
|
+
const handleResize = (state, dimensions) => {
|
|
5074
|
+
const {
|
|
5075
|
+
height: rawHeight,
|
|
5076
|
+
width: rawWidth
|
|
5077
|
+
} = dimensions;
|
|
5078
|
+
if (!Number.isFinite(rawHeight) || !Number.isFinite(rawWidth)) {
|
|
5079
|
+
return state;
|
|
5080
|
+
}
|
|
5081
|
+
const height = Math.max(0, rawHeight);
|
|
5082
|
+
const width = Math.max(0, rawWidth);
|
|
5083
|
+
const {
|
|
5084
|
+
deltaY,
|
|
5085
|
+
itemHeight,
|
|
5086
|
+
items
|
|
5087
|
+
} = state;
|
|
5088
|
+
const contentHeight = items.length * itemHeight;
|
|
5089
|
+
const maxDeltaY = Math.max(contentHeight - height, 0);
|
|
5090
|
+
const newDeltaY = Math.min(Math.max(deltaY, 0), maxDeltaY);
|
|
5091
|
+
const minLineY = Math.round(newDeltaY / itemHeight);
|
|
5092
|
+
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, items.length);
|
|
5093
|
+
const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
|
|
5094
|
+
if (state.height === height && state.width === width && state.deltaY === newDeltaY && state.minLineY === minLineY && state.maxLineY === maxLineY && state.scrollBarHeight === scrollBarHeight) {
|
|
5095
|
+
return state;
|
|
5096
|
+
}
|
|
5097
|
+
return {
|
|
5098
|
+
...state,
|
|
5099
|
+
deltaY: newDeltaY,
|
|
5100
|
+
height,
|
|
5101
|
+
maxLineY,
|
|
5102
|
+
minLineY,
|
|
5103
|
+
scrollBarHeight,
|
|
5104
|
+
width
|
|
5105
|
+
};
|
|
5106
|
+
};
|
|
5107
|
+
|
|
5073
5108
|
const handleUpload = async (state, dirents) => {
|
|
5074
5109
|
const {
|
|
5075
5110
|
pathSeparator,
|
|
@@ -5494,12 +5529,18 @@ const getIndentRule = indent => {
|
|
|
5494
5529
|
padding-left: ${indent}px;
|
|
5495
5530
|
}`;
|
|
5496
5531
|
};
|
|
5497
|
-
|
|
5532
|
+
|
|
5533
|
+
const getCss = (scrollBarHeight, scrollBarTop, uniqueIndents, errorMessageLeft, errorMessageTop, errorMessageWidth) => {
|
|
5498
5534
|
const rules = [`.Explorer {
|
|
5499
5535
|
--ScrollBarThumbHeight: ${scrollBarHeight}px;
|
|
5536
|
+
--ScrollBarThumbTop: ${scrollBarTop}px;
|
|
5500
5537
|
--ErrorMessageTop: ${errorMessageTop}px;
|
|
5501
5538
|
--ErrorMessageLeft: ${errorMessageLeft}px;
|
|
5502
5539
|
--ErrorMessageWidth: ${errorMessageWidth}px;
|
|
5540
|
+
}
|
|
5541
|
+
.Explorer .ScrollBarThumb {
|
|
5542
|
+
height: var(--ScrollBarThumbHeight);
|
|
5543
|
+
translate: 0px var(--ScrollBarThumbTop);
|
|
5503
5544
|
}`, ...uniqueIndents.map(getIndentRule)];
|
|
5504
5545
|
const css = rules.join('\n');
|
|
5505
5546
|
return css;
|
|
@@ -5516,6 +5557,17 @@ const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, inde
|
|
|
5516
5557
|
};
|
|
5517
5558
|
};
|
|
5518
5559
|
|
|
5560
|
+
const getScrollBarTop = (height, contentHeight, scrollTop) => {
|
|
5561
|
+
if (contentHeight <= 0 || !Number.isFinite(contentHeight)) {
|
|
5562
|
+
return 0;
|
|
5563
|
+
}
|
|
5564
|
+
const scrollBarTop = Math.round(scrollTop / contentHeight * height);
|
|
5565
|
+
if (!Number.isFinite(scrollBarTop)) {
|
|
5566
|
+
return 0;
|
|
5567
|
+
}
|
|
5568
|
+
return scrollBarTop;
|
|
5569
|
+
};
|
|
5570
|
+
|
|
5519
5571
|
const getUnique = items => {
|
|
5520
5572
|
const seens = [];
|
|
5521
5573
|
for (const item of items) {
|
|
@@ -5535,7 +5587,9 @@ const getUniqueIndents = items => {
|
|
|
5535
5587
|
|
|
5536
5588
|
const renderCss = (oldState, newState) => {
|
|
5537
5589
|
const {
|
|
5590
|
+
deltaY,
|
|
5538
5591
|
focusedIndex,
|
|
5592
|
+
height,
|
|
5539
5593
|
itemHeight,
|
|
5540
5594
|
items,
|
|
5541
5595
|
minLineY,
|
|
@@ -5545,6 +5599,8 @@ const renderCss = (oldState, newState) => {
|
|
|
5545
5599
|
width
|
|
5546
5600
|
} = newState;
|
|
5547
5601
|
const uniqueIndents = getUniqueIndents(visibleExplorerItems);
|
|
5602
|
+
const contentHeight = items.length * itemHeight;
|
|
5603
|
+
const scrollBarTop = getScrollBarTop(height, contentHeight, deltaY);
|
|
5548
5604
|
const indent = 8;
|
|
5549
5605
|
const padding = 10;
|
|
5550
5606
|
const fileIconWidth = 16;
|
|
@@ -5556,7 +5612,7 @@ const renderCss = (oldState, newState) => {
|
|
|
5556
5612
|
left,
|
|
5557
5613
|
top
|
|
5558
5614
|
} = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace, width);
|
|
5559
|
-
const css = getCss(scrollBarHeight, uniqueIndents, left, top, errorMessageWidth);
|
|
5615
|
+
const css = getCss(scrollBarHeight, scrollBarTop, uniqueIndents, left, top, errorMessageWidth);
|
|
5560
5616
|
return [SetCss, uid, css];
|
|
5561
5617
|
};
|
|
5562
5618
|
|
|
@@ -5626,11 +5682,14 @@ const renderFocus = (oldState, newState) => {
|
|
|
5626
5682
|
};
|
|
5627
5683
|
|
|
5628
5684
|
const renderFocusContext = (oldState, newState) => {
|
|
5685
|
+
const {
|
|
5686
|
+
uid
|
|
5687
|
+
} = newState;
|
|
5629
5688
|
if (newState.focus === Input$1) {
|
|
5630
|
-
return [SetFocusContext,
|
|
5689
|
+
return [SetFocusContext, uid, FocusExplorerEditBox];
|
|
5631
5690
|
}
|
|
5632
5691
|
if (newState.focus === List) {
|
|
5633
|
-
return [SetFocusContext,
|
|
5692
|
+
return [SetFocusContext, uid, FocusExplorer];
|
|
5634
5693
|
}
|
|
5635
5694
|
return [];
|
|
5636
5695
|
};
|
|
@@ -5848,25 +5907,11 @@ const getListItemsVirtualDom = (visibleItems, focusedIndex, focused, dropTargets
|
|
|
5848
5907
|
return dom;
|
|
5849
5908
|
};
|
|
5850
5909
|
|
|
5851
|
-
const
|
|
5852
|
-
if (size >= contentSize) {
|
|
5853
|
-
return 0;
|
|
5854
|
-
}
|
|
5855
|
-
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
5856
|
-
};
|
|
5857
|
-
|
|
5858
|
-
const getScrollBarTop = (height, contentHeight, scrollTop) => {
|
|
5859
|
-
const scrollBarTop = Math.round(scrollTop / contentHeight * height);
|
|
5860
|
-
return scrollBarTop;
|
|
5861
|
-
};
|
|
5862
|
-
|
|
5863
|
-
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
5910
|
+
const getScrollBarVirtualDom = scrollBarHeight => {
|
|
5864
5911
|
const shouldShowScrollbar = scrollBarHeight > 0;
|
|
5865
5912
|
if (!shouldShowScrollbar) {
|
|
5866
5913
|
return [];
|
|
5867
5914
|
}
|
|
5868
|
-
const heightString = px(scrollBarHeight);
|
|
5869
|
-
const translateString = position(0, scrollBarTop);
|
|
5870
5915
|
return [{
|
|
5871
5916
|
childCount: 1,
|
|
5872
5917
|
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
@@ -5874,8 +5919,6 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
5874
5919
|
}, {
|
|
5875
5920
|
childCount: 0,
|
|
5876
5921
|
className: ScrollBarThumb,
|
|
5877
|
-
height: heightString,
|
|
5878
|
-
translate: translateString,
|
|
5879
5922
|
type: Div
|
|
5880
5923
|
}];
|
|
5881
5924
|
};
|
|
@@ -5890,13 +5933,12 @@ const getChildCount = (scrollBarDomLength, errorDomLength) => {
|
|
|
5890
5933
|
}
|
|
5891
5934
|
return childCount;
|
|
5892
5935
|
};
|
|
5893
|
-
const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight,
|
|
5936
|
+
const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, errorMessage) => {
|
|
5894
5937
|
if (!root) {
|
|
5895
5938
|
return getExplorerWelcomeVirtualDom(isWide);
|
|
5896
5939
|
}
|
|
5897
5940
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
|
|
5898
|
-
const
|
|
5899
|
-
const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarTop);
|
|
5941
|
+
const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight);
|
|
5900
5942
|
const errorDom = getErrorMessageDom(errorMessage);
|
|
5901
5943
|
const childCount = getChildCount(scrollBarDom.length, errorDom.length);
|
|
5902
5944
|
const parentNode = {
|
|
@@ -5911,7 +5953,6 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
|
|
|
5911
5953
|
|
|
5912
5954
|
const renderItems = (oldState, newState) => {
|
|
5913
5955
|
const {
|
|
5914
|
-
deltaY,
|
|
5915
5956
|
dropTargets,
|
|
5916
5957
|
editingErrorMessage,
|
|
5917
5958
|
focused,
|
|
@@ -5925,8 +5966,8 @@ const renderItems = (oldState, newState) => {
|
|
|
5925
5966
|
const visibleDirents = newState.visibleExplorerItems;
|
|
5926
5967
|
const isWide = width > 450;
|
|
5927
5968
|
const contentHeight = items.length * itemHeight;
|
|
5928
|
-
const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight,
|
|
5929
|
-
return [SetDom2, dom];
|
|
5969
|
+
const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, editingErrorMessage);
|
|
5970
|
+
return [SetDom2, newState.uid, dom];
|
|
5930
5971
|
};
|
|
5931
5972
|
|
|
5932
5973
|
const renderIncremental = (oldState, newState) => {
|
|
@@ -6484,6 +6525,7 @@ const commandMap = {
|
|
|
6484
6525
|
'Explorer.handleKeyDown': wrapListItemCommand(handleKeyDown),
|
|
6485
6526
|
'Explorer.handlePaste': wrapListItemCommand(handlePaste),
|
|
6486
6527
|
'Explorer.handlePointerDown': wrapListItemCommand(handlePointerDown),
|
|
6528
|
+
'Explorer.handleResize': wrapListItemCommand(handleResize),
|
|
6487
6529
|
'Explorer.handleUpload': wrapListItemCommand(handleUpload),
|
|
6488
6530
|
'Explorer.handleWheel': wrapListItemCommand(handleWheel),
|
|
6489
6531
|
'Explorer.handleWorkspaceChange': wrapListItemCommand(handleWorkspaceChange),
|