@lvce-editor/explorer-view 3.27.0 → 4.1.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 +57 -31
- package/package.json +1 -1
|
@@ -2730,9 +2730,9 @@ const text = data => {
|
|
|
2730
2730
|
};
|
|
2731
2731
|
};
|
|
2732
2732
|
|
|
2733
|
-
const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons,
|
|
2733
|
+
const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, indent) => {
|
|
2734
2734
|
let className = TreeItem$1;
|
|
2735
|
-
className = mergeClassNames(className, `Indent-${
|
|
2735
|
+
className = mergeClassNames(className, `Indent-${indent}`);
|
|
2736
2736
|
if (isSelected || isFocused) {
|
|
2737
2737
|
className = mergeClassNames(className, TreeItemActive);
|
|
2738
2738
|
}
|
|
@@ -2742,9 +2742,9 @@ const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, de
|
|
|
2742
2742
|
return className;
|
|
2743
2743
|
};
|
|
2744
2744
|
|
|
2745
|
-
const defaultIndent$1 =
|
|
2745
|
+
const defaultIndent$1 = 12;
|
|
2746
2746
|
const getTreeItemIndent = depth => {
|
|
2747
|
-
return
|
|
2747
|
+
return depth * defaultIndent$1;
|
|
2748
2748
|
};
|
|
2749
2749
|
|
|
2750
2750
|
// TODO make all of these variable configurable
|
|
@@ -2756,7 +2756,7 @@ const chevronSize = 22;
|
|
|
2756
2756
|
const getTreeItemIndentWithChevron = (depth, chevron) => {
|
|
2757
2757
|
// TODO use numeric value here, convert to string value in renderer process
|
|
2758
2758
|
const extraSpace = chevron ? 0 : chevronSize;
|
|
2759
|
-
return
|
|
2759
|
+
return depth * defaultIndent + extraSpace + defaultPaddingLeft;
|
|
2760
2760
|
};
|
|
2761
2761
|
|
|
2762
2762
|
const ariaExpandedValues = [undefined, 'true', 'false'];
|
|
@@ -2783,7 +2783,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2783
2783
|
const isCut = cutItems.includes(item.path);
|
|
2784
2784
|
const isDropping = dropTargets.includes(i);
|
|
2785
2785
|
const isIgnored = sourceControlIgnoredUris.includes(item.path);
|
|
2786
|
-
const
|
|
2786
|
+
const indent = indentFn(item.depth, chevron);
|
|
2787
|
+
const className = getTreeItemClassName(isSelected, isFocused, isDropping, useChevrons, indent);
|
|
2787
2788
|
const expanded = getExpandedType(item.type);
|
|
2788
2789
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
2789
2790
|
const isEditing = i === editingIndex;
|
|
@@ -2792,7 +2793,6 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2792
2793
|
icon = editingIcon;
|
|
2793
2794
|
chevron = getEditingChevron(item.type);
|
|
2794
2795
|
}
|
|
2795
|
-
const indent = indentFn(item.depth, chevron);
|
|
2796
2796
|
visible.push({
|
|
2797
2797
|
...item,
|
|
2798
2798
|
posInSet: item.posInSet ?? i + 1,
|
|
@@ -2986,7 +2986,10 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
2986
2986
|
};
|
|
2987
2987
|
|
|
2988
2988
|
const isEqual$6 = (oldState, newState) => {
|
|
2989
|
-
|
|
2989
|
+
// TODO compute css more optimized
|
|
2990
|
+
// maybe only when items change, and even then not
|
|
2991
|
+
// always, but only when it affects the css
|
|
2992
|
+
return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarActive === newState.scrollBarActive && oldState.maxIndent === newState.maxIndent && oldState.visibleExplorerItems === newState.visibleExplorerItems;
|
|
2990
2993
|
};
|
|
2991
2994
|
|
|
2992
2995
|
const isEqual$5 = (oldState, newState) => {
|
|
@@ -3972,6 +3975,22 @@ const show = async (x, y, id, ...args) => {
|
|
|
3972
3975
|
|
|
3973
3976
|
const Explorer = 4;
|
|
3974
3977
|
|
|
3978
|
+
const handleContextMenuAtIndex = async (state, index, x, y) => {
|
|
3979
|
+
number(x);
|
|
3980
|
+
number(y);
|
|
3981
|
+
const {
|
|
3982
|
+
uid
|
|
3983
|
+
} = state;
|
|
3984
|
+
const newState = {
|
|
3985
|
+
...state,
|
|
3986
|
+
focusedIndex: index,
|
|
3987
|
+
focused: false
|
|
3988
|
+
};
|
|
3989
|
+
set$1(uid, state, newState);
|
|
3990
|
+
await show(x, y, Explorer);
|
|
3991
|
+
return newState;
|
|
3992
|
+
};
|
|
3993
|
+
|
|
3975
3994
|
const handleContextMenuKeyboard = async state => {
|
|
3976
3995
|
const {
|
|
3977
3996
|
focusedIndex,
|
|
@@ -3982,22 +4001,14 @@ const handleContextMenuKeyboard = async state => {
|
|
|
3982
4001
|
} = state;
|
|
3983
4002
|
const menuX = x;
|
|
3984
4003
|
const menuY = y + (focusedIndex - minLineY + 1) * itemHeight;
|
|
3985
|
-
|
|
3986
|
-
return state;
|
|
4004
|
+
return handleContextMenuAtIndex(state, focusedIndex, menuX, menuY);
|
|
3987
4005
|
};
|
|
3988
4006
|
|
|
3989
4007
|
const handleContextMenuMouseAt = async (state, x, y) => {
|
|
3990
4008
|
number(x);
|
|
3991
4009
|
number(y);
|
|
3992
4010
|
const focusedIndex = getIndexFromPosition(state, x, y);
|
|
3993
|
-
|
|
3994
|
-
...state,
|
|
3995
|
-
focusedIndex,
|
|
3996
|
-
focused: false
|
|
3997
|
-
};
|
|
3998
|
-
set$1(state.uid, state, newState);
|
|
3999
|
-
await show(x, y, Explorer);
|
|
4000
|
-
return state;
|
|
4011
|
+
return handleContextMenuAtIndex(state, focusedIndex, x, y);
|
|
4001
4012
|
};
|
|
4002
4013
|
|
|
4003
4014
|
const getContextMenuHandler = button => {
|
|
@@ -5417,22 +5428,39 @@ const renameDirent = async state => {
|
|
|
5417
5428
|
};
|
|
5418
5429
|
};
|
|
5419
5430
|
|
|
5420
|
-
const
|
|
5421
|
-
|
|
5422
|
-
scrollBarHeight,
|
|
5423
|
-
uid,
|
|
5424
|
-
maxIndent
|
|
5425
|
-
} = newState;
|
|
5431
|
+
const getCss = (scrollBarHeight, uniqueIndents) => {
|
|
5432
|
+
// TODO each visible item should have an indent property
|
|
5426
5433
|
const rules = [`.Explorer {
|
|
5427
5434
|
--ScrollBarThumbHeight: ${scrollBarHeight}px;
|
|
5428
|
-
`];
|
|
5429
|
-
for (
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
padding-left: ${indent};
|
|
5435
|
+
}`];
|
|
5436
|
+
for (const item of uniqueIndents) {
|
|
5437
|
+
rules.push(`.Indent-${item} {
|
|
5438
|
+
padding-left: ${item}px;
|
|
5433
5439
|
}`);
|
|
5434
5440
|
}
|
|
5435
5441
|
const css = rules.join('\n');
|
|
5442
|
+
return css;
|
|
5443
|
+
};
|
|
5444
|
+
|
|
5445
|
+
const getUnique = items => {
|
|
5446
|
+
const seens = [];
|
|
5447
|
+
for (const item of items) {
|
|
5448
|
+
if (!seens.includes(item)) {
|
|
5449
|
+
seens.push(item);
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
return seens;
|
|
5453
|
+
};
|
|
5454
|
+
|
|
5455
|
+
const renderCss = (oldState, newState) => {
|
|
5456
|
+
const {
|
|
5457
|
+
scrollBarHeight,
|
|
5458
|
+
uid,
|
|
5459
|
+
visibleExplorerItems
|
|
5460
|
+
} = newState;
|
|
5461
|
+
const indents = visibleExplorerItems.map(item => item.indent);
|
|
5462
|
+
const uniqueIndents = getUnique(indents);
|
|
5463
|
+
const css = getCss(scrollBarHeight, uniqueIndents);
|
|
5436
5464
|
return [SetCss, uid, css];
|
|
5437
5465
|
};
|
|
5438
5466
|
|
|
@@ -5666,7 +5694,6 @@ const getExplorerItemVirtualDom = item => {
|
|
|
5666
5694
|
hasEditingError,
|
|
5667
5695
|
icon,
|
|
5668
5696
|
id,
|
|
5669
|
-
indent,
|
|
5670
5697
|
isEditing,
|
|
5671
5698
|
name,
|
|
5672
5699
|
path,
|
|
@@ -5687,7 +5714,6 @@ const getExplorerItemVirtualDom = item => {
|
|
|
5687
5714
|
ariaSetSize: setSize,
|
|
5688
5715
|
ariaLevel: depth,
|
|
5689
5716
|
childCount: 2 + chevronDom.length,
|
|
5690
|
-
paddingLeft: indent,
|
|
5691
5717
|
ariaLabel: name,
|
|
5692
5718
|
ariaExpanded,
|
|
5693
5719
|
ariaDescription: '',
|