@lvce-editor/text-search-worker 3.30.0 → 3.31.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/textSearchWorkerMain.js +56 -31
- package/package.json +1 -1
|
@@ -1652,14 +1652,15 @@ const focusSearchValueNext = state => {
|
|
|
1652
1652
|
return focusMatchCase$1(state);
|
|
1653
1653
|
};
|
|
1654
1654
|
|
|
1655
|
+
const Alert = 'alert';
|
|
1656
|
+
const Button$2 = 'button';
|
|
1655
1657
|
const CheckBox = 'checkbox';
|
|
1656
1658
|
const None$1 = 'none';
|
|
1659
|
+
const ScrollBar$1 = 'scrollbar';
|
|
1657
1660
|
const Status = 'status';
|
|
1658
|
-
const Tree = 'tree';
|
|
1659
|
-
const TreeItem$1 = 'treeitem';
|
|
1660
1661
|
const ToolBar = 'toolbar';
|
|
1661
|
-
const
|
|
1662
|
-
const
|
|
1662
|
+
const Tree$1 = 'tree';
|
|
1663
|
+
const TreeItem$1 = 'treeitem';
|
|
1663
1664
|
|
|
1664
1665
|
const Actions = 'Actions';
|
|
1665
1666
|
const Badge = 'Badge';
|
|
@@ -1670,16 +1671,13 @@ const FileIcon = 'FileIcon';
|
|
|
1670
1671
|
const FocusOutline = 'FocusOutline';
|
|
1671
1672
|
const Grow = 'Grow';
|
|
1672
1673
|
const Highlight = 'Highlight';
|
|
1673
|
-
const ScrollBarThumb = 'ScrollBarThumb';
|
|
1674
1674
|
const HighlightDeleted = 'HighlightDeleted';
|
|
1675
|
-
const ScrollBar = 'ScrollBar';
|
|
1676
1675
|
const HighlightInserted = 'HighlightInserted';
|
|
1677
1676
|
const IconButton = 'IconButton';
|
|
1678
1677
|
const Label = 'Label';
|
|
1679
1678
|
const List = 'List';
|
|
1680
1679
|
const MaskIcon = 'MaskIcon';
|
|
1681
1680
|
const MaskIconBook = 'MaskIconBook';
|
|
1682
|
-
const ScrollBarVertical = 'ScrollBarVertical';
|
|
1683
1681
|
const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
|
|
1684
1682
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
1685
1683
|
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
@@ -1690,6 +1688,9 @@ const MaskIconRegex = 'MaskIconRegex';
|
|
|
1690
1688
|
const MaskIconReplaceAll = 'MaskIconReplaceAll';
|
|
1691
1689
|
const MaskIconWholeWord = 'MaskIconWholeWord';
|
|
1692
1690
|
const MultilineInputBox = 'MultilineInputBox';
|
|
1691
|
+
const ScrollBar = 'ScrollBar';
|
|
1692
|
+
const ScrollBarThumb = 'ScrollBarThumb';
|
|
1693
|
+
const ScrollBarVertical = 'ScrollBarVertical';
|
|
1693
1694
|
const Search$1 = 'Search';
|
|
1694
1695
|
const SearchField = 'SearchField';
|
|
1695
1696
|
const SearchFieldButton = 'SearchFieldButton';
|
|
@@ -1710,8 +1711,10 @@ const SearchToggleButton = 'SearchToggleButton';
|
|
|
1710
1711
|
const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
1711
1712
|
const SourceControlBadge = 'SourceControlBadge';
|
|
1712
1713
|
const ToggleDetails = 'ToggleDetails';
|
|
1714
|
+
const Tree = 'Tree';
|
|
1713
1715
|
const TreeItem = 'TreeItem';
|
|
1714
1716
|
const TreeItemActive = 'TreeItemActive';
|
|
1717
|
+
const TreeItems$1 = 'TreeItems';
|
|
1715
1718
|
const Viewlet = 'Viewlet';
|
|
1716
1719
|
const ViewletSearchMessage = 'ViewletSearchMessage';
|
|
1717
1720
|
|
|
@@ -1908,7 +1911,7 @@ const getAbsolutePath = relativePath => {
|
|
|
1908
1911
|
return `/${relativePath}`; // TODO support windows paths
|
|
1909
1912
|
};
|
|
1910
1913
|
|
|
1911
|
-
const getDisplayResult = (results, fileIcons,
|
|
1914
|
+
const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY) => {
|
|
1912
1915
|
const result = results[i];
|
|
1913
1916
|
const {
|
|
1914
1917
|
type,
|
|
@@ -1917,7 +1920,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
|
|
|
1917
1920
|
start
|
|
1918
1921
|
} = result;
|
|
1919
1922
|
const posInSet = i + 1;
|
|
1920
|
-
const top = i * itemHeight;
|
|
1921
1923
|
const focused = i === focusedIndex;
|
|
1922
1924
|
const relativeIndex = i - minLineY;
|
|
1923
1925
|
switch (type) {
|
|
@@ -1932,7 +1934,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
|
|
|
1932
1934
|
icon: fileIcons[relativeIndex],
|
|
1933
1935
|
posInSet,
|
|
1934
1936
|
setSize,
|
|
1935
|
-
top,
|
|
1936
1937
|
lineNumber,
|
|
1937
1938
|
matchStart: 0,
|
|
1938
1939
|
matchLength: 0,
|
|
@@ -1949,7 +1950,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
|
|
|
1949
1950
|
icon: '',
|
|
1950
1951
|
posInSet,
|
|
1951
1952
|
setSize,
|
|
1952
|
-
top,
|
|
1953
1953
|
lineNumber,
|
|
1954
1954
|
matchStart: start,
|
|
1955
1955
|
matchLength: searchTermLength,
|
|
@@ -1969,7 +1969,7 @@ const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLine
|
|
|
1969
1969
|
const setSize = resultCount;
|
|
1970
1970
|
const searchTermLength = searchTerm.length;
|
|
1971
1971
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
1972
|
-
const displayResult = getDisplayResult(results, fileIcons,
|
|
1972
|
+
const displayResult = getDisplayResult(results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY);
|
|
1973
1973
|
displayResults.push(displayResult);
|
|
1974
1974
|
}
|
|
1975
1975
|
return displayResults;
|
|
@@ -1977,12 +1977,13 @@ const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLine
|
|
|
1977
1977
|
|
|
1978
1978
|
const HandleClick = 'handleClick';
|
|
1979
1979
|
const HandleExcludeInput = 'handleExcludeInput';
|
|
1980
|
-
const
|
|
1980
|
+
const HandleHeaderClick2 = 'handleHeaderClick2';
|
|
1981
1981
|
const HandleHeaderFocusIn = 'handleHeaderFocusIn';
|
|
1982
1982
|
const HandleIncludeInput = 'handleIncludeInput';
|
|
1983
1983
|
const HandleInput = 'handleInput';
|
|
1984
1984
|
const HandleListBlur = 'handleListBlur';
|
|
1985
1985
|
const HandleReplaceInput = 'handleReplaceInput';
|
|
1986
|
+
const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
|
|
1986
1987
|
const HandleWheel = 'handleWheel';
|
|
1987
1988
|
|
|
1988
1989
|
const FilesToExclude = 'FilesToExclude';
|
|
@@ -2258,7 +2259,7 @@ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage) => {
|
|
|
2258
2259
|
className: SearchHeader,
|
|
2259
2260
|
role: None$1,
|
|
2260
2261
|
childCount: 2,
|
|
2261
|
-
onClick:
|
|
2262
|
+
onClick: HandleHeaderClick2,
|
|
2262
2263
|
onFocusIn: HandleHeaderFocusIn
|
|
2263
2264
|
}, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage), ...getSearchHeaderDetailsVirtualDom(flags, message)];
|
|
2264
2265
|
return dom;
|
|
@@ -2276,14 +2277,20 @@ const getSearchInputErrorVirtualDom = errorMessage => {
|
|
|
2276
2277
|
}, text(errorMessage)];
|
|
2277
2278
|
};
|
|
2278
2279
|
|
|
2279
|
-
const
|
|
2280
|
+
const TreeItems = 'TreeItems';
|
|
2281
|
+
|
|
2282
|
+
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) => {
|
|
2280
2283
|
if (scrollBarHeight === 0) {
|
|
2281
2284
|
return [];
|
|
2282
2285
|
}
|
|
2283
2286
|
return [{
|
|
2284
2287
|
type: Div,
|
|
2285
2288
|
className: mergeClassNames(ScrollBar, ScrollBarVertical),
|
|
2286
|
-
childCount: 1
|
|
2289
|
+
childCount: 1,
|
|
2290
|
+
onPointerDown: HandleScrollBarPointerDown,
|
|
2291
|
+
role: ScrollBar$1,
|
|
2292
|
+
ariaControls: TreeItems,
|
|
2293
|
+
ariaValueNow: scrollBarValue
|
|
2287
2294
|
}, {
|
|
2288
2295
|
type: Div,
|
|
2289
2296
|
className: ScrollBarThumb,
|
|
@@ -2448,28 +2455,39 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
2448
2455
|
return dom;
|
|
2449
2456
|
};
|
|
2450
2457
|
|
|
2451
|
-
const
|
|
2452
|
-
const
|
|
2458
|
+
const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
|
|
2459
|
+
const pixelOffset = deltaY % itemHeight;
|
|
2453
2460
|
return [{
|
|
2454
2461
|
type: Div,
|
|
2455
|
-
className:
|
|
2456
|
-
|
|
2457
|
-
tabIndex: 0,
|
|
2458
|
-
childCount: visibleItems.length + scrollBarDomNodes,
|
|
2462
|
+
className: TreeItems$1,
|
|
2463
|
+
childCount: visibleItems.length,
|
|
2459
2464
|
onClick: HandleClick,
|
|
2460
2465
|
onBlur: HandleListBlur,
|
|
2461
|
-
onWheel: HandleWheel
|
|
2462
|
-
|
|
2466
|
+
onWheel: HandleWheel,
|
|
2467
|
+
id: TreeItems,
|
|
2468
|
+
top: `${-pixelOffset}px`
|
|
2469
|
+
}, ...visibleItems.flatMap(getSearchResultVirtualDom)];
|
|
2463
2470
|
};
|
|
2464
2471
|
|
|
2465
|
-
const
|
|
2472
|
+
const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
|
|
2473
|
+
const scrollBarDomNodes = scrollbarHeight === 0 ? 0 : 1;
|
|
2474
|
+
return [{
|
|
2475
|
+
type: Div,
|
|
2476
|
+
className: mergeClassNames(Viewlet, List, Tree, focusOutline ? FocusOutline : Empty),
|
|
2477
|
+
role: Tree$1,
|
|
2478
|
+
tabIndex: 0,
|
|
2479
|
+
childCount: 1 + scrollBarDomNodes
|
|
2480
|
+
}, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
|
|
2481
|
+
};
|
|
2482
|
+
|
|
2483
|
+
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
|
|
2466
2484
|
const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
|
|
2467
2485
|
const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
|
|
2468
2486
|
return [{
|
|
2469
2487
|
type: Div,
|
|
2470
2488
|
className: mergeClassNames(Viewlet, Search$1),
|
|
2471
2489
|
childCount
|
|
2472
|
-
}, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY)];
|
|
2490
|
+
}, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
|
|
2473
2491
|
};
|
|
2474
2492
|
|
|
2475
2493
|
const handleError = error => {
|
|
@@ -3275,9 +3293,12 @@ const focusPreviousPage = state => {
|
|
|
3275
3293
|
return focusIndex(state, indexPreviousPage);
|
|
3276
3294
|
};
|
|
3277
3295
|
|
|
3278
|
-
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight) => {
|
|
3296
|
+
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemCount) => {
|
|
3279
3297
|
const relativeY = eventY - y - topHeight + deltaY;
|
|
3280
3298
|
const index = Math.floor(relativeY / itemHeight);
|
|
3299
|
+
if (index >= itemCount) {
|
|
3300
|
+
return -1;
|
|
3301
|
+
}
|
|
3281
3302
|
return index;
|
|
3282
3303
|
};
|
|
3283
3304
|
|
|
@@ -3419,10 +3440,11 @@ const handleClickAt = (state, eventX, eventY) => {
|
|
|
3419
3440
|
y,
|
|
3420
3441
|
itemHeight,
|
|
3421
3442
|
deltaY,
|
|
3422
|
-
flags
|
|
3443
|
+
flags,
|
|
3444
|
+
listItems
|
|
3423
3445
|
} = state;
|
|
3424
3446
|
const topHeight = getTopHeight(flags);
|
|
3425
|
-
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight);
|
|
3447
|
+
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
|
|
3426
3448
|
return selectIndex(state, index);
|
|
3427
3449
|
};
|
|
3428
3450
|
|
|
@@ -3455,6 +3477,8 @@ const setDeltaY = (state, value) => {
|
|
|
3455
3477
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
3456
3478
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
3457
3479
|
const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
|
|
3480
|
+
|
|
3481
|
+
// TODO update icons
|
|
3458
3482
|
return {
|
|
3459
3483
|
...state,
|
|
3460
3484
|
deltaY: newDeltaY,
|
|
@@ -3636,13 +3660,14 @@ const getFocusSelector = focusKey => {
|
|
|
3636
3660
|
|
|
3637
3661
|
const renderItems = {
|
|
3638
3662
|
isEqual(oldState, newState) {
|
|
3639
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons && oldState.searchInputErrorMessage === newState.searchInputErrorMessage;
|
|
3663
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons && oldState.searchInputErrorMessage === newState.searchInputErrorMessage && oldState.deltaY === newState.deltaY;
|
|
3640
3664
|
},
|
|
3641
3665
|
apply(oldState, newState) {
|
|
3642
3666
|
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex, newState.collapsedPaths);
|
|
3643
3667
|
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3668
|
+
const scrollBarValue = newState.deltaY / newState.finalDeltaY * 100;
|
|
3644
3669
|
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, newState.scrollBarHeight);
|
|
3645
|
-
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY);
|
|
3670
|
+
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight);
|
|
3646
3671
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3647
3672
|
}
|
|
3648
3673
|
};
|