@lvce-editor/text-search-worker 3.29.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 +75 -26
- 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';
|
|
@@ -1687,6 +1688,9 @@ const MaskIconRegex = 'MaskIconRegex';
|
|
|
1687
1688
|
const MaskIconReplaceAll = 'MaskIconReplaceAll';
|
|
1688
1689
|
const MaskIconWholeWord = 'MaskIconWholeWord';
|
|
1689
1690
|
const MultilineInputBox = 'MultilineInputBox';
|
|
1691
|
+
const ScrollBar = 'ScrollBar';
|
|
1692
|
+
const ScrollBarThumb = 'ScrollBarThumb';
|
|
1693
|
+
const ScrollBarVertical = 'ScrollBarVertical';
|
|
1690
1694
|
const Search$1 = 'Search';
|
|
1691
1695
|
const SearchField = 'SearchField';
|
|
1692
1696
|
const SearchFieldButton = 'SearchFieldButton';
|
|
@@ -1707,8 +1711,10 @@ const SearchToggleButton = 'SearchToggleButton';
|
|
|
1707
1711
|
const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
1708
1712
|
const SourceControlBadge = 'SourceControlBadge';
|
|
1709
1713
|
const ToggleDetails = 'ToggleDetails';
|
|
1714
|
+
const Tree = 'Tree';
|
|
1710
1715
|
const TreeItem = 'TreeItem';
|
|
1711
1716
|
const TreeItemActive = 'TreeItemActive';
|
|
1717
|
+
const TreeItems$1 = 'TreeItems';
|
|
1712
1718
|
const Viewlet = 'Viewlet';
|
|
1713
1719
|
const ViewletSearchMessage = 'ViewletSearchMessage';
|
|
1714
1720
|
|
|
@@ -1905,7 +1911,7 @@ const getAbsolutePath = relativePath => {
|
|
|
1905
1911
|
return `/${relativePath}`; // TODO support windows paths
|
|
1906
1912
|
};
|
|
1907
1913
|
|
|
1908
|
-
const getDisplayResult = (results, fileIcons,
|
|
1914
|
+
const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY) => {
|
|
1909
1915
|
const result = results[i];
|
|
1910
1916
|
const {
|
|
1911
1917
|
type,
|
|
@@ -1914,7 +1920,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
|
|
|
1914
1920
|
start
|
|
1915
1921
|
} = result;
|
|
1916
1922
|
const posInSet = i + 1;
|
|
1917
|
-
const top = i * itemHeight;
|
|
1918
1923
|
const focused = i === focusedIndex;
|
|
1919
1924
|
const relativeIndex = i - minLineY;
|
|
1920
1925
|
switch (type) {
|
|
@@ -1929,7 +1934,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
|
|
|
1929
1934
|
icon: fileIcons[relativeIndex],
|
|
1930
1935
|
posInSet,
|
|
1931
1936
|
setSize,
|
|
1932
|
-
top,
|
|
1933
1937
|
lineNumber,
|
|
1934
1938
|
matchStart: 0,
|
|
1935
1939
|
matchLength: 0,
|
|
@@ -1946,7 +1950,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
|
|
|
1946
1950
|
icon: '',
|
|
1947
1951
|
posInSet,
|
|
1948
1952
|
setSize,
|
|
1949
|
-
top,
|
|
1950
1953
|
lineNumber,
|
|
1951
1954
|
matchStart: start,
|
|
1952
1955
|
matchLength: searchTermLength,
|
|
@@ -1966,20 +1969,22 @@ const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLine
|
|
|
1966
1969
|
const setSize = resultCount;
|
|
1967
1970
|
const searchTermLength = searchTerm.length;
|
|
1968
1971
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
1969
|
-
const displayResult = getDisplayResult(results, fileIcons,
|
|
1972
|
+
const displayResult = getDisplayResult(results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY);
|
|
1970
1973
|
displayResults.push(displayResult);
|
|
1971
1974
|
}
|
|
1972
1975
|
return displayResults;
|
|
1973
1976
|
};
|
|
1974
1977
|
|
|
1975
1978
|
const HandleClick = 'handleClick';
|
|
1976
|
-
const
|
|
1979
|
+
const HandleExcludeInput = 'handleExcludeInput';
|
|
1980
|
+
const HandleHeaderClick2 = 'handleHeaderClick2';
|
|
1977
1981
|
const HandleHeaderFocusIn = 'handleHeaderFocusIn';
|
|
1978
|
-
const
|
|
1982
|
+
const HandleIncludeInput = 'handleIncludeInput';
|
|
1979
1983
|
const HandleInput = 'handleInput';
|
|
1984
|
+
const HandleListBlur = 'handleListBlur';
|
|
1980
1985
|
const HandleReplaceInput = 'handleReplaceInput';
|
|
1981
|
-
const
|
|
1982
|
-
const
|
|
1986
|
+
const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
|
|
1987
|
+
const HandleWheel = 'handleWheel';
|
|
1983
1988
|
|
|
1984
1989
|
const FilesToExclude = 'FilesToExclude';
|
|
1985
1990
|
const FilesToInclude = 'FilesToInclude';
|
|
@@ -2254,7 +2259,7 @@ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage) => {
|
|
|
2254
2259
|
className: SearchHeader,
|
|
2255
2260
|
role: None$1,
|
|
2256
2261
|
childCount: 2,
|
|
2257
|
-
onClick:
|
|
2262
|
+
onClick: HandleHeaderClick2,
|
|
2258
2263
|
onFocusIn: HandleHeaderFocusIn
|
|
2259
2264
|
}, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage), ...getSearchHeaderDetailsVirtualDom(flags, message)];
|
|
2260
2265
|
return dom;
|
|
@@ -2272,6 +2277,29 @@ const getSearchInputErrorVirtualDom = errorMessage => {
|
|
|
2272
2277
|
}, text(errorMessage)];
|
|
2273
2278
|
};
|
|
2274
2279
|
|
|
2280
|
+
const TreeItems = 'TreeItems';
|
|
2281
|
+
|
|
2282
|
+
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) => {
|
|
2283
|
+
if (scrollBarHeight === 0) {
|
|
2284
|
+
return [];
|
|
2285
|
+
}
|
|
2286
|
+
return [{
|
|
2287
|
+
type: Div,
|
|
2288
|
+
className: mergeClassNames(ScrollBar, ScrollBarVertical),
|
|
2289
|
+
childCount: 1,
|
|
2290
|
+
onPointerDown: HandleScrollBarPointerDown,
|
|
2291
|
+
role: ScrollBar$1,
|
|
2292
|
+
ariaControls: TreeItems,
|
|
2293
|
+
ariaValueNow: scrollBarValue
|
|
2294
|
+
}, {
|
|
2295
|
+
type: Div,
|
|
2296
|
+
className: ScrollBarThumb,
|
|
2297
|
+
height: scrollBarHeight,
|
|
2298
|
+
translate: `0 ${scrollBarY}px`,
|
|
2299
|
+
childCount: 0
|
|
2300
|
+
}];
|
|
2301
|
+
};
|
|
2302
|
+
|
|
2275
2303
|
// TODO instead of setting string, support enum in virtual dom and send enum to renderer process
|
|
2276
2304
|
// which converts it to a boolean
|
|
2277
2305
|
const getAriaExpanded = expanded => {
|
|
@@ -2427,26 +2455,39 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
2427
2455
|
return dom;
|
|
2428
2456
|
};
|
|
2429
2457
|
|
|
2430
|
-
const
|
|
2458
|
+
const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
|
|
2459
|
+
const pixelOffset = deltaY % itemHeight;
|
|
2431
2460
|
return [{
|
|
2432
2461
|
type: Div,
|
|
2433
|
-
className:
|
|
2434
|
-
role: Tree,
|
|
2435
|
-
tabIndex: 0,
|
|
2462
|
+
className: TreeItems$1,
|
|
2436
2463
|
childCount: visibleItems.length,
|
|
2437
2464
|
onClick: HandleClick,
|
|
2438
|
-
onBlur: HandleListBlur
|
|
2465
|
+
onBlur: HandleListBlur,
|
|
2466
|
+
onWheel: HandleWheel,
|
|
2467
|
+
id: TreeItems,
|
|
2468
|
+
top: `${-pixelOffset}px`
|
|
2439
2469
|
}, ...visibleItems.flatMap(getSearchResultVirtualDom)];
|
|
2440
2470
|
};
|
|
2441
2471
|
|
|
2442
|
-
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) => {
|
|
2443
2484
|
const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
|
|
2444
2485
|
const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
|
|
2445
2486
|
return [{
|
|
2446
2487
|
type: Div,
|
|
2447
2488
|
className: mergeClassNames(Viewlet, Search$1),
|
|
2448
2489
|
childCount
|
|
2449
|
-
}, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline)];
|
|
2490
|
+
}, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
|
|
2450
2491
|
};
|
|
2451
2492
|
|
|
2452
2493
|
const handleError = error => {
|
|
@@ -3252,9 +3293,12 @@ const focusPreviousPage = state => {
|
|
|
3252
3293
|
return focusIndex(state, indexPreviousPage);
|
|
3253
3294
|
};
|
|
3254
3295
|
|
|
3255
|
-
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight) => {
|
|
3296
|
+
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemCount) => {
|
|
3256
3297
|
const relativeY = eventY - y - topHeight + deltaY;
|
|
3257
3298
|
const index = Math.floor(relativeY / itemHeight);
|
|
3299
|
+
if (index >= itemCount) {
|
|
3300
|
+
return -1;
|
|
3301
|
+
}
|
|
3258
3302
|
return index;
|
|
3259
3303
|
};
|
|
3260
3304
|
|
|
@@ -3396,10 +3440,11 @@ const handleClickAt = (state, eventX, eventY) => {
|
|
|
3396
3440
|
y,
|
|
3397
3441
|
itemHeight,
|
|
3398
3442
|
deltaY,
|
|
3399
|
-
flags
|
|
3443
|
+
flags,
|
|
3444
|
+
listItems
|
|
3400
3445
|
} = state;
|
|
3401
3446
|
const topHeight = getTopHeight(flags);
|
|
3402
|
-
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight);
|
|
3447
|
+
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
|
|
3403
3448
|
return selectIndex(state, index);
|
|
3404
3449
|
};
|
|
3405
3450
|
|
|
@@ -3432,6 +3477,8 @@ const setDeltaY = (state, value) => {
|
|
|
3432
3477
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
3433
3478
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
3434
3479
|
const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
|
|
3480
|
+
|
|
3481
|
+
// TODO update icons
|
|
3435
3482
|
return {
|
|
3436
3483
|
...state,
|
|
3437
3484
|
deltaY: newDeltaY,
|
|
@@ -3613,12 +3660,14 @@ const getFocusSelector = focusKey => {
|
|
|
3613
3660
|
|
|
3614
3661
|
const renderItems = {
|
|
3615
3662
|
isEqual(oldState, newState) {
|
|
3616
|
-
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;
|
|
3617
3664
|
},
|
|
3618
3665
|
apply(oldState, newState) {
|
|
3619
3666
|
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex, newState.collapsedPaths);
|
|
3620
3667
|
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3621
|
-
const
|
|
3668
|
+
const scrollBarValue = newState.deltaY / newState.finalDeltaY * 100;
|
|
3669
|
+
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, newState.scrollBarHeight);
|
|
3670
|
+
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight);
|
|
3622
3671
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3623
3672
|
}
|
|
3624
3673
|
};
|