@lvce-editor/find-widget-worker 1.23.0 → 2.0.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/findWidgetWorkerMain.js +133 -21
- package/package.json +1 -1
|
@@ -988,8 +988,10 @@ const create$1 = (uid, x, y, width, height, parentUid) => {
|
|
|
988
988
|
minWidth: 400,
|
|
989
989
|
history: [],
|
|
990
990
|
inputErrorMessage: '',
|
|
991
|
-
inputHeight:
|
|
992
|
-
inputLineHeight:
|
|
991
|
+
inputHeight: 15,
|
|
992
|
+
inputLineHeight: 15,
|
|
993
|
+
inputPaddingTop: 2,
|
|
994
|
+
inputPaddingBottom: 2
|
|
993
995
|
};
|
|
994
996
|
set$3(uid, state, state);
|
|
995
997
|
return state;
|
|
@@ -1046,9 +1048,18 @@ const ClientX = 'event.clientX';
|
|
|
1046
1048
|
const ClientY = 'event.clientY';
|
|
1047
1049
|
const TargetName = 'event.target.name';
|
|
1048
1050
|
|
|
1051
|
+
const Tab = 2;
|
|
1052
|
+
const Enter = 3;
|
|
1053
|
+
const KeyF = 34;
|
|
1054
|
+
const F4 = 60;
|
|
1055
|
+
|
|
1049
1056
|
const User = 1;
|
|
1050
1057
|
const Script = 2;
|
|
1051
1058
|
|
|
1059
|
+
const CtrlCmd = 1 << 11 >>> 0;
|
|
1060
|
+
const Shift = 1 << 10 >>> 0;
|
|
1061
|
+
const Alt = 1 << 9 >>> 0;
|
|
1062
|
+
|
|
1052
1063
|
const EditorWorker$1 = 99;
|
|
1053
1064
|
|
|
1054
1065
|
const FocusSelector = 'Viewlet.focusSelector';
|
|
@@ -1056,7 +1067,13 @@ const SetCss = 'Viewlet.setCss';
|
|
|
1056
1067
|
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1057
1068
|
const SetValueByName = 'Viewlet.setValueByName';
|
|
1058
1069
|
|
|
1070
|
+
const FocusFindWidget$1 = 16;
|
|
1059
1071
|
const FocusFindWidgetCloseButton$1 = 48;
|
|
1072
|
+
const FocusFindWidgetNextMatchButton = 49;
|
|
1073
|
+
const FocusFindWidgetPreviousMatchButton = 50;
|
|
1074
|
+
const FocusFindWidgetReplace$1 = 43;
|
|
1075
|
+
const FocusFindWidgetReplaceAllButton$1 = 47;
|
|
1076
|
+
const FocusFindWidgetReplaceButton = 46;
|
|
1060
1077
|
const FocusIgnoreFiles = 1012;
|
|
1061
1078
|
const FocusSearchExcludeInput = 1008;
|
|
1062
1079
|
const FocusSearchIncludeInput = 1007;
|
|
@@ -1419,7 +1436,9 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1419
1436
|
matchCase,
|
|
1420
1437
|
useRegularExpression,
|
|
1421
1438
|
matchWholeWord,
|
|
1422
|
-
inputLineHeight
|
|
1439
|
+
inputLineHeight,
|
|
1440
|
+
inputPaddingTop,
|
|
1441
|
+
inputPaddingBottom
|
|
1423
1442
|
} = state;
|
|
1424
1443
|
const options = {
|
|
1425
1444
|
matchCase,
|
|
@@ -1430,12 +1449,15 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1430
1449
|
matches,
|
|
1431
1450
|
error
|
|
1432
1451
|
} = findMatches(lines, value, options);
|
|
1433
|
-
const
|
|
1452
|
+
const textHeight = measureTextHeight(value, inputLineHeight);
|
|
1453
|
+
const inputHeight = textHeight + inputPaddingBottom + inputPaddingTop;
|
|
1454
|
+
const height = inputHeight + 5;
|
|
1434
1455
|
if (error) {
|
|
1435
1456
|
return {
|
|
1436
1457
|
...state,
|
|
1437
1458
|
inputErrorMessage: error,
|
|
1438
|
-
inputHeight
|
|
1459
|
+
inputHeight,
|
|
1460
|
+
height
|
|
1439
1461
|
};
|
|
1440
1462
|
}
|
|
1441
1463
|
const matchCount = getMatchCount(matches);
|
|
@@ -1447,7 +1469,8 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1447
1469
|
matchCount,
|
|
1448
1470
|
matches,
|
|
1449
1471
|
matchIndex: 0,
|
|
1450
|
-
value
|
|
1472
|
+
value,
|
|
1473
|
+
height
|
|
1451
1474
|
};
|
|
1452
1475
|
};
|
|
1453
1476
|
|
|
@@ -1794,6 +1817,82 @@ const focusPreviousElement = state => {
|
|
|
1794
1817
|
return focusElement(state, previousFocus);
|
|
1795
1818
|
};
|
|
1796
1819
|
|
|
1820
|
+
const getKeyBindings = () => {
|
|
1821
|
+
return [{
|
|
1822
|
+
key: Enter,
|
|
1823
|
+
command: 'FindWidget.focusNext',
|
|
1824
|
+
when: FocusFindWidget$1
|
|
1825
|
+
}, {
|
|
1826
|
+
key: CtrlCmd | KeyF,
|
|
1827
|
+
command: 'FindWidget.preventDefaultBrowserFind',
|
|
1828
|
+
when: FocusFindWidget$1
|
|
1829
|
+
}, {
|
|
1830
|
+
key: Shift | F4,
|
|
1831
|
+
command: 'FindWidget.focusPrevious',
|
|
1832
|
+
when: FocusFindWidget$1
|
|
1833
|
+
}, {
|
|
1834
|
+
key: F4,
|
|
1835
|
+
command: 'FindWidget.focusNext',
|
|
1836
|
+
when: FocusFindWidget$1
|
|
1837
|
+
}, {
|
|
1838
|
+
key: Shift | Tab,
|
|
1839
|
+
command: 'FindWidget.focusToggleReplace',
|
|
1840
|
+
when: FocusFindWidget$1
|
|
1841
|
+
}, {
|
|
1842
|
+
key: Tab,
|
|
1843
|
+
command: 'FindWidget.focusReplace',
|
|
1844
|
+
when: FocusFindWidget$1
|
|
1845
|
+
}, {
|
|
1846
|
+
key: Tab,
|
|
1847
|
+
command: 'FindWidget.focusPreviousMatchButton',
|
|
1848
|
+
when: FocusFindWidgetReplace$1
|
|
1849
|
+
}, {
|
|
1850
|
+
key: Alt | CtrlCmd | Enter,
|
|
1851
|
+
command: 'FindWidget.replaceAll',
|
|
1852
|
+
when: FocusFindWidgetReplace$1
|
|
1853
|
+
}, {
|
|
1854
|
+
key: Tab,
|
|
1855
|
+
command: 'FindWidget.focusNextMatchButton',
|
|
1856
|
+
when: FocusFindWidgetPreviousMatchButton
|
|
1857
|
+
}, {
|
|
1858
|
+
key: Shift | Tab,
|
|
1859
|
+
command: 'FindWidget.focusReplace',
|
|
1860
|
+
when: FocusFindWidgetPreviousMatchButton
|
|
1861
|
+
}, {
|
|
1862
|
+
key: Shift | Tab,
|
|
1863
|
+
command: 'FindWidget.focusPreviousMatchButton',
|
|
1864
|
+
when: FocusFindWidgetNextMatchButton
|
|
1865
|
+
}, {
|
|
1866
|
+
key: Tab,
|
|
1867
|
+
command: 'FindWidget.focusCloseButton',
|
|
1868
|
+
when: FocusFindWidgetNextMatchButton
|
|
1869
|
+
}, {
|
|
1870
|
+
key: Shift | Tab,
|
|
1871
|
+
command: 'FindWidget.focusNextMatchButton',
|
|
1872
|
+
when: FocusFindWidgetCloseButton$1
|
|
1873
|
+
}, {
|
|
1874
|
+
key: Tab,
|
|
1875
|
+
command: 'FindWidget.focusReplaceButton',
|
|
1876
|
+
when: FocusFindWidgetCloseButton$1
|
|
1877
|
+
}, {
|
|
1878
|
+
key: Shift | Tab,
|
|
1879
|
+
command: 'FindWidget.focusFind',
|
|
1880
|
+
when: FocusFindWidgetReplace$1
|
|
1881
|
+
}, {
|
|
1882
|
+
key: Tab,
|
|
1883
|
+
command: 'FindWidget.focusReplaceAllButton',
|
|
1884
|
+
when: FocusFindWidgetReplaceButton
|
|
1885
|
+
}, {
|
|
1886
|
+
key: Shift | Tab,
|
|
1887
|
+
command: 'FindWidget.focusCloseButton',
|
|
1888
|
+
when: FocusFindWidgetReplaceButton
|
|
1889
|
+
}, {
|
|
1890
|
+
key: Shift | Tab,
|
|
1891
|
+
command: 'FindWidget.focusReplaceButton',
|
|
1892
|
+
when: FocusFindWidgetReplaceAllButton$1
|
|
1893
|
+
}];
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1797
1896
|
const handleInput = (state, value, inputSource = User) => {
|
|
1798
1897
|
return refresh(state, value, inputSource);
|
|
1799
1898
|
};
|
|
@@ -1884,7 +1983,8 @@ const loadContent = async (state, savedState) => {
|
|
|
1884
1983
|
editorUid,
|
|
1885
1984
|
editorWidth,
|
|
1886
1985
|
editorX,
|
|
1887
|
-
editorY
|
|
1986
|
+
editorY,
|
|
1987
|
+
inputLineHeight
|
|
1888
1988
|
} = state;
|
|
1889
1989
|
const {
|
|
1890
1990
|
replacement,
|
|
@@ -1904,11 +2004,13 @@ const loadContent = async (state, savedState) => {
|
|
|
1904
2004
|
const actualValue = value || getSelectedText(lines, selections);
|
|
1905
2005
|
const matches = findMatchesCaseInsensitive(lines, actualValue);
|
|
1906
2006
|
const matchCount = getMatchCount(matches);
|
|
2007
|
+
const inputHeight = measureTextHeight(value, inputLineHeight);
|
|
1907
2008
|
return {
|
|
1908
2009
|
...state,
|
|
1909
2010
|
focus: FocusSearchInput,
|
|
1910
2011
|
focused: true,
|
|
1911
2012
|
height,
|
|
2013
|
+
inputHeight,
|
|
1912
2014
|
inputSource: Script,
|
|
1913
2015
|
lines,
|
|
1914
2016
|
matchCount,
|
|
@@ -2153,13 +2255,6 @@ const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
|
2153
2255
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
2154
2256
|
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
2155
2257
|
|
|
2156
|
-
const getFindMatchCountClassName = (matchCount, hasValue) => {
|
|
2157
|
-
if (hasValue && matchCount === 0) {
|
|
2158
|
-
return mergeClassNames(FindWidgetMatchCount, FindWidgetMatchCountEmpty);
|
|
2159
|
-
}
|
|
2160
|
-
return FindWidgetMatchCount;
|
|
2161
|
-
};
|
|
2162
|
-
|
|
2163
2258
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
2164
2259
|
return {
|
|
2165
2260
|
type,
|
|
@@ -2193,6 +2288,22 @@ const getIconButtonVirtualDom = iconButton => {
|
|
|
2193
2288
|
}, getIconVirtualDom(icon)];
|
|
2194
2289
|
};
|
|
2195
2290
|
|
|
2291
|
+
const emptyMatches = mergeClassNames(FindWidgetMatchCount, FindWidgetMatchCountEmpty);
|
|
2292
|
+
const getFindMatchCountClassName = (matchCount, hasValue) => {
|
|
2293
|
+
if (hasValue && matchCount === 0) {
|
|
2294
|
+
return emptyMatches;
|
|
2295
|
+
}
|
|
2296
|
+
return FindWidgetMatchCount;
|
|
2297
|
+
};
|
|
2298
|
+
|
|
2299
|
+
const getMatchCountVirtualDom = (matchCountText, matchCount, hasValue) => {
|
|
2300
|
+
return [{
|
|
2301
|
+
type: Div,
|
|
2302
|
+
className: getFindMatchCountClassName(matchCount, hasValue),
|
|
2303
|
+
childCount: 1
|
|
2304
|
+
}, text(matchCountText)];
|
|
2305
|
+
};
|
|
2306
|
+
|
|
2196
2307
|
const checkedClassName = mergeClassNames(SearchFieldButton, SearchFieldButtonChecked);
|
|
2197
2308
|
const unCheckedClassName = SearchFieldButton;
|
|
2198
2309
|
const getSearchFieldButtonVirtualDom = button => {
|
|
@@ -2253,12 +2364,12 @@ const getFindWidgetFindVirtualDom = (matchCountText, buttons, fieldButtons, matc
|
|
|
2253
2364
|
return [{
|
|
2254
2365
|
type: Div,
|
|
2255
2366
|
className: FindWidgetFind,
|
|
2256
|
-
childCount:
|
|
2367
|
+
childCount: 2
|
|
2257
2368
|
}, ...getSearchFieldVirtualDom(SearchValue, find(), HandleInput, fieldButtons, [], HandleFocus, extraClassName), {
|
|
2258
2369
|
type: Div,
|
|
2259
|
-
className:
|
|
2260
|
-
childCount: 1
|
|
2261
|
-
},
|
|
2370
|
+
className: 'FindWidgetActions',
|
|
2371
|
+
childCount: 1 + buttons.length
|
|
2372
|
+
}, ...getMatchCountVirtualDom(matchCountText, matchCount, hasValue), ...buttons.flatMap(getIconButtonVirtualDom)];
|
|
2262
2373
|
};
|
|
2263
2374
|
|
|
2264
2375
|
const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons, replaceFieldButtons) => {
|
|
@@ -2578,17 +2689,18 @@ const commandMap = {
|
|
|
2578
2689
|
'FindWidget.diff2': diff2,
|
|
2579
2690
|
'FindWidget.dispose': dispose$1,
|
|
2580
2691
|
'FindWidget.focusCloseButton': wrapCommand(focusCloseButton),
|
|
2581
|
-
'FindWidget.focusFirst': wrapCommand(focusFirst),
|
|
2582
2692
|
'FindWidget.focusElement': wrapCommand(focusElement),
|
|
2693
|
+
'FindWidget.focusFirst': wrapCommand(focusFirst),
|
|
2583
2694
|
'FindWidget.focusIndex': wrapCommand(focusIndex),
|
|
2584
2695
|
'FindWidget.focusLast': wrapCommand(focusLast),
|
|
2585
2696
|
'FindWidget.focusNext': wrapCommand(focusNext),
|
|
2586
|
-
'FindWidget.focusPrevious': wrapCommand(focusPrevious),
|
|
2587
2697
|
'FindWidget.focusNextElement': wrapCommand(focusNextElement),
|
|
2698
|
+
'FindWidget.focusPrevious': wrapCommand(focusPrevious),
|
|
2588
2699
|
'FindWidget.focusPreviousElement': wrapCommand(focusPreviousElement),
|
|
2589
2700
|
'FindWidget.focusReplace': wrapCommand(focusReplace),
|
|
2590
2701
|
'FindWidget.focusReplaceAllButton': wrapCommand(focusReplaceAllButton),
|
|
2591
2702
|
'FindWidget.getCommandIds': getCommandIds,
|
|
2703
|
+
'FindWidget.getKeyBindings': getKeyBindings,
|
|
2592
2704
|
'FindWidget.handleBlur': wrapCommand(handleBlur),
|
|
2593
2705
|
'FindWidget.handleClickButton': wrapCommand(handleClickButton),
|
|
2594
2706
|
'FindWidget.handleClickClose': wrapCommand(handleClickClose),
|
|
@@ -2604,8 +2716,8 @@ const commandMap = {
|
|
|
2604
2716
|
'FindWidget.replace': wrapCommand(replace$1),
|
|
2605
2717
|
'FindWidget.replaceAll': wrapCommand(replaceAll$1),
|
|
2606
2718
|
'FindWidget.resize': wrapCommand(resize),
|
|
2607
|
-
'FindWidget.terminate': terminate,
|
|
2608
2719
|
'FindWidget.saveState': wrapGetter(saveState),
|
|
2720
|
+
'FindWidget.terminate': terminate,
|
|
2609
2721
|
'FindWidget.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
2610
2722
|
'FindWidget.toggleReplace': wrapCommand(toggleReplace$1),
|
|
2611
2723
|
'FindWidget.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression)
|