@lvce-editor/find-widget-worker 1.15.0 → 1.16.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 +151 -26
- package/package.json +1 -1
|
@@ -946,6 +946,7 @@ const {
|
|
|
946
946
|
registerCommands
|
|
947
947
|
} = create$2();
|
|
948
948
|
|
|
949
|
+
const User$1 = 1;
|
|
949
950
|
const Script$1 = 2;
|
|
950
951
|
const Unknown = 0;
|
|
951
952
|
|
|
@@ -978,16 +979,21 @@ const create$1 = (uid, x, y, width, height, parentUid) => {
|
|
|
978
979
|
editorWidth: width,
|
|
979
980
|
editorHeight: height,
|
|
980
981
|
inputSource: 0,
|
|
981
|
-
preserveCase: false
|
|
982
|
+
preserveCase: false,
|
|
983
|
+
resizerPointerDown: false
|
|
982
984
|
};
|
|
983
985
|
set$3(uid, state, state);
|
|
984
986
|
return state;
|
|
985
987
|
};
|
|
986
988
|
|
|
987
|
-
const isEqual$
|
|
989
|
+
const isEqual$6 = (oldState, newState) => {
|
|
988
990
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
989
991
|
};
|
|
990
992
|
|
|
993
|
+
const isEqual$5 = (oldState, newState) => {
|
|
994
|
+
return newState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x;
|
|
995
|
+
};
|
|
996
|
+
|
|
991
997
|
const isEqual$4 = (oldState, newState) => {
|
|
992
998
|
return oldState.version === newState.version;
|
|
993
999
|
};
|
|
@@ -1005,6 +1011,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1005
1011
|
};
|
|
1006
1012
|
|
|
1007
1013
|
const RenderBounds = 8;
|
|
1014
|
+
const RenderCss = 10;
|
|
1008
1015
|
const RenderEventListeners = 11;
|
|
1009
1016
|
const RenderUid = 12;
|
|
1010
1017
|
const RenderContent = 13;
|
|
@@ -1022,12 +1029,16 @@ const Div = 4;
|
|
|
1022
1029
|
const Text = 12;
|
|
1023
1030
|
const TextArea = 62;
|
|
1024
1031
|
|
|
1032
|
+
const ClientX = 'event.clientX';
|
|
1033
|
+
const ClientY = 'event.clientY';
|
|
1034
|
+
|
|
1025
1035
|
const User = 1;
|
|
1026
1036
|
const Script = 1;
|
|
1027
1037
|
|
|
1028
1038
|
const EditorWorker$1 = 99;
|
|
1029
1039
|
|
|
1030
1040
|
const FocusSelector = 'Viewlet.focusSelector';
|
|
1041
|
+
const SetCss = 'Viewlet.setCss';
|
|
1031
1042
|
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1032
1043
|
const SetValueByName = 'Viewlet.setValueByName';
|
|
1033
1044
|
|
|
@@ -1035,8 +1046,8 @@ const isEqual = (oldState, newState) => {
|
|
|
1035
1046
|
return newState.inputSource === User || oldState.value === newState.value;
|
|
1036
1047
|
};
|
|
1037
1048
|
|
|
1038
|
-
const modules = [isEqual$4, isEqual$2, isEqual$
|
|
1039
|
-
const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus, RenderValue];
|
|
1049
|
+
const modules = [isEqual$4, isEqual$2, isEqual$6, isEqual$1, isEqual$3, isEqual$3, isEqual, isEqual$5];
|
|
1050
|
+
const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus, RenderValue, RenderCss];
|
|
1040
1051
|
|
|
1041
1052
|
const diff = (oldState, newState) => {
|
|
1042
1053
|
const diffResult = [];
|
|
@@ -1425,7 +1436,7 @@ const Replace$2 = 'Replace';
|
|
|
1425
1436
|
const ReplaceAll$2 = 'ReplaceAll';
|
|
1426
1437
|
const ReplaceValue = 'replace-value';
|
|
1427
1438
|
const SearchValue = 'search-value';
|
|
1428
|
-
const ToggleReplace = 'ToggleReplace';
|
|
1439
|
+
const ToggleReplace$1 = 'ToggleReplace';
|
|
1429
1440
|
const UseRegularExpression$1 = 'UseRegularExpression';
|
|
1430
1441
|
|
|
1431
1442
|
const applyEdits = async (editorId, edits) => {
|
|
@@ -1534,6 +1545,49 @@ const handleInput = (state, value, inputSource = User) => {
|
|
|
1534
1545
|
return refresh(state, value, inputSource);
|
|
1535
1546
|
};
|
|
1536
1547
|
|
|
1548
|
+
const handleFindWidgetFocus = (state, focusKey) => {
|
|
1549
|
+
if (state.focus === focusKey) {
|
|
1550
|
+
return state;
|
|
1551
|
+
}
|
|
1552
|
+
return {
|
|
1553
|
+
...state,
|
|
1554
|
+
focus: focusKey,
|
|
1555
|
+
focusSource: User$1
|
|
1556
|
+
};
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
const handleReplaceFocus = state => {
|
|
1560
|
+
return handleFindWidgetFocus(state, FocusFindWidgetReplace);
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1563
|
+
const handleResizerPointerDown = async (state, eventX, eventY) => {
|
|
1564
|
+
return {
|
|
1565
|
+
...state,
|
|
1566
|
+
resizerPointerDown: true
|
|
1567
|
+
};
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
const handleResizerPointerMove = async (state, eventX, eventY) => {
|
|
1571
|
+
const {
|
|
1572
|
+
width,
|
|
1573
|
+
x
|
|
1574
|
+
} = state;
|
|
1575
|
+
const oldXEnd = x + width;
|
|
1576
|
+
const newWidth = oldXEnd - eventX;
|
|
1577
|
+
return {
|
|
1578
|
+
...state,
|
|
1579
|
+
x: eventX,
|
|
1580
|
+
width: newWidth
|
|
1581
|
+
};
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1584
|
+
const handleResizerPointerUp = async (state, eventX, eventY) => {
|
|
1585
|
+
return {
|
|
1586
|
+
...state,
|
|
1587
|
+
resizerPointerDown: false
|
|
1588
|
+
};
|
|
1589
|
+
};
|
|
1590
|
+
|
|
1537
1591
|
const getFindWidgetHeight = replaceExpanded => {
|
|
1538
1592
|
const collapsedHeight = 30;
|
|
1539
1593
|
const expandedHeight = 60;
|
|
@@ -1541,7 +1595,7 @@ const getFindWidgetHeight = replaceExpanded => {
|
|
|
1541
1595
|
return newHeight;
|
|
1542
1596
|
};
|
|
1543
1597
|
|
|
1544
|
-
const toggleReplace = state => {
|
|
1598
|
+
const toggleReplace$1 = state => {
|
|
1545
1599
|
const {
|
|
1546
1600
|
replaceExpanded
|
|
1547
1601
|
} = state;
|
|
@@ -1674,19 +1728,24 @@ const renderBounds = (oldState, newState) => {
|
|
|
1674
1728
|
};
|
|
1675
1729
|
|
|
1676
1730
|
const HandleBlur = 'handleBlur';
|
|
1731
|
+
const HandleClickButton = 'handleClickButton';
|
|
1677
1732
|
const HandleClickClose = 'handleClickClose';
|
|
1678
1733
|
const HandleClickNextMatch = 'handleClickNextMatch';
|
|
1679
1734
|
const HandleClickPreviousMatch = 'handleClickPreviousMatch';
|
|
1680
1735
|
const HandleClickReplace = 'handleClickReplace';
|
|
1681
|
-
const HandleClickToggleReplace = 'handleClickToggleReplace';
|
|
1682
1736
|
const HandleClickReplaceAll = 'handleClickReplaceAll';
|
|
1683
|
-
const
|
|
1737
|
+
const HandleClickToggleReplace = 'handleClickToggleReplace';
|
|
1684
1738
|
const HandleFocus = 'handleFocus';
|
|
1739
|
+
const HandleFocusNext = 'handleFocusNext';
|
|
1740
|
+
const HandleFocusPrevious = 'handleFocusPrevious';
|
|
1685
1741
|
const HandleInput = 'handleInput';
|
|
1686
1742
|
const HandleReplaceFocus = 'handleReplaceFocus';
|
|
1687
|
-
const HandleFocusPrevious = 'handleFocusPrevious';
|
|
1688
|
-
const HandleFocusNext = 'handleFocusNext';
|
|
1689
1743
|
const HandleReplaceInput = 'handleReplaceInput';
|
|
1744
|
+
const HandleResizerPointerDown = 'handleResizerPointerDown';
|
|
1745
|
+
const HandleResizerPointerMove = 'handleResizerPointerMove';
|
|
1746
|
+
const HandleResizerPointerUp = 'handleResizerPointerUp';
|
|
1747
|
+
const HandleSliderPointerMove = 'handleSliderPointerMove';
|
|
1748
|
+
const HandleToggleReplaceFocus = 'handleToggleReplaceFocus';
|
|
1690
1749
|
|
|
1691
1750
|
const emptyObject = {};
|
|
1692
1751
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
@@ -1708,6 +1767,7 @@ const NextMatch = 'Next Match';
|
|
|
1708
1767
|
const Find$1 = 'Find';
|
|
1709
1768
|
const Replace$1 = 'Replace';
|
|
1710
1769
|
const ReplaceAll$1 = 'Replace All';
|
|
1770
|
+
const ToggleReplace = 'Toggle Replace';
|
|
1711
1771
|
|
|
1712
1772
|
const noResults = () => {
|
|
1713
1773
|
return i18nString(NoResults);
|
|
@@ -1736,6 +1796,9 @@ const replace = () => {
|
|
|
1736
1796
|
const replaceAll = () => {
|
|
1737
1797
|
return i18nString(ReplaceAll$1);
|
|
1738
1798
|
};
|
|
1799
|
+
const toggleReplace = () => {
|
|
1800
|
+
return i18nString(ToggleReplace);
|
|
1801
|
+
};
|
|
1739
1802
|
|
|
1740
1803
|
const MatchCase = 'CaseSensitive';
|
|
1741
1804
|
const UseRegularExpression = 'Regex';
|
|
@@ -1829,17 +1892,20 @@ const getFindButtons = () => {
|
|
|
1829
1892
|
checked: false,
|
|
1830
1893
|
icon: MatchCase,
|
|
1831
1894
|
title: 'Match Case',
|
|
1832
|
-
name: MatchCase$1
|
|
1895
|
+
name: MatchCase$1,
|
|
1896
|
+
onClick: HandleClickButton
|
|
1833
1897
|
}, {
|
|
1834
1898
|
checked: false,
|
|
1835
1899
|
icon: MatchWholeWord,
|
|
1836
1900
|
title: 'Match Whole Word',
|
|
1837
|
-
name: MatchWholeWord$1
|
|
1901
|
+
name: MatchWholeWord$1,
|
|
1902
|
+
onClick: HandleClickButton
|
|
1838
1903
|
}, {
|
|
1839
1904
|
checked: false,
|
|
1840
1905
|
icon: UseRegularExpression,
|
|
1841
1906
|
title: 'Use Regular Expression',
|
|
1842
|
-
name: UseRegularExpression$1
|
|
1907
|
+
name: UseRegularExpression$1,
|
|
1908
|
+
onClick: HandleClickButton
|
|
1843
1909
|
}];
|
|
1844
1910
|
};
|
|
1845
1911
|
|
|
@@ -1887,16 +1953,20 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
1887
1953
|
const {
|
|
1888
1954
|
icon,
|
|
1889
1955
|
checked,
|
|
1890
|
-
title
|
|
1956
|
+
title,
|
|
1957
|
+
name,
|
|
1958
|
+
onClick
|
|
1891
1959
|
} = button;
|
|
1892
1960
|
return [{
|
|
1893
1961
|
type: Div,
|
|
1962
|
+
ariaChecked: checked,
|
|
1894
1963
|
className: mergeClassNames(SearchFieldButton, checked ? SearchFieldButtonChecked : ''),
|
|
1895
|
-
|
|
1964
|
+
name,
|
|
1896
1965
|
role: CheckBox,
|
|
1897
|
-
ariaChecked: checked,
|
|
1898
1966
|
tabIndex: 0,
|
|
1899
|
-
|
|
1967
|
+
title,
|
|
1968
|
+
childCount: 1,
|
|
1969
|
+
onClick
|
|
1900
1970
|
}, {
|
|
1901
1971
|
type: Div,
|
|
1902
1972
|
className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
|
|
@@ -1961,18 +2031,34 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons) => {
|
|
|
1961
2031
|
return dom;
|
|
1962
2032
|
};
|
|
1963
2033
|
|
|
2034
|
+
const getResizerVirtualDom = () => {
|
|
2035
|
+
return [{
|
|
2036
|
+
type: Div,
|
|
2037
|
+
className: 'Resizer',
|
|
2038
|
+
childCount: 1,
|
|
2039
|
+
onPointerDown: HandleResizerPointerDown,
|
|
2040
|
+
onPointerMove: HandleResizerPointerUp,
|
|
2041
|
+
onPointerUp: HandleResizerPointerMove
|
|
2042
|
+
}, {
|
|
2043
|
+
type: Div,
|
|
2044
|
+
className: 'ResizerHighlight',
|
|
2045
|
+
childCount: 0
|
|
2046
|
+
}];
|
|
2047
|
+
};
|
|
2048
|
+
|
|
1964
2049
|
const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
|
|
2050
|
+
const title = toggleReplace();
|
|
1965
2051
|
return [{
|
|
1966
2052
|
type: Button,
|
|
1967
2053
|
className: `IconButton SearchToggleButton ${replaceExpanded ? 'SearchToggleButtonExpanded' : ''}`,
|
|
1968
|
-
title
|
|
1969
|
-
ariaLabel:
|
|
2054
|
+
title,
|
|
2055
|
+
ariaLabel: title,
|
|
1970
2056
|
ariaExpanded: replaceExpanded,
|
|
1971
|
-
name: ToggleReplace,
|
|
2057
|
+
name: ToggleReplace$1,
|
|
1972
2058
|
childCount: 1,
|
|
1973
2059
|
'data-command': 'toggleReplace',
|
|
1974
2060
|
onClick,
|
|
1975
|
-
onFocus:
|
|
2061
|
+
onFocus: HandleToggleReplaceFocus
|
|
1976
2062
|
}, {
|
|
1977
2063
|
type: Div,
|
|
1978
2064
|
className: `MaskIcon ${replaceExpanded ? 'MaskIconChevronDown' : 'MaskIconChevronRight'}`,
|
|
@@ -1985,9 +2071,10 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, r
|
|
|
1985
2071
|
dom.push({
|
|
1986
2072
|
type: Div,
|
|
1987
2073
|
className: mergeClassNames(Viewlet, ViewletFind, ViewletFindWidget, FindWidget),
|
|
1988
|
-
childCount:
|
|
2074
|
+
childCount: 3,
|
|
1989
2075
|
role: Group
|
|
1990
2076
|
});
|
|
2077
|
+
dom.push(...getResizerVirtualDom());
|
|
1991
2078
|
dom.push(...getSearchToggleButtonVirtualDom(replaceExpanded, 'handleClickToggleReplace'));
|
|
1992
2079
|
dom.push({
|
|
1993
2080
|
type: Div,
|
|
@@ -2025,6 +2112,23 @@ const renderContent = (oldState, newState) => {
|
|
|
2025
2112
|
return [SetDom2, uid, dom];
|
|
2026
2113
|
};
|
|
2027
2114
|
|
|
2115
|
+
const renderCss = (oldState, newState) => {
|
|
2116
|
+
const {
|
|
2117
|
+
uid,
|
|
2118
|
+
width,
|
|
2119
|
+
height,
|
|
2120
|
+
x,
|
|
2121
|
+
y
|
|
2122
|
+
} = newState;
|
|
2123
|
+
const css = `:root {
|
|
2124
|
+
--FindWidgetWidth: ${width}px;
|
|
2125
|
+
--FindWidgetHeight: ${height}px;
|
|
2126
|
+
--FindWidgetX: ${x}px;
|
|
2127
|
+
--FindWidgetY: ${y}px;
|
|
2128
|
+
}`;
|
|
2129
|
+
return [SetCss, uid, css];
|
|
2130
|
+
};
|
|
2131
|
+
|
|
2028
2132
|
const getEventListeners = (uid, widgetId) => {
|
|
2029
2133
|
return [{
|
|
2030
2134
|
name: HandleInput,
|
|
@@ -2068,6 +2172,16 @@ const getEventListeners = (uid, widgetId) => {
|
|
|
2068
2172
|
}, {
|
|
2069
2173
|
name: HandleClickButton,
|
|
2070
2174
|
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleClickButton', 0, widgetId, `event.target.name`]
|
|
2175
|
+
}, {
|
|
2176
|
+
name: HandleResizerPointerDown,
|
|
2177
|
+
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleResizerPointerDown', 0, widgetId, ClientX, ClientY],
|
|
2178
|
+
trackPointerEvents: [HandleResizerPointerMove, HandleResizerPointerUp]
|
|
2179
|
+
}, {
|
|
2180
|
+
name: HandleSliderPointerMove,
|
|
2181
|
+
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleResizerPointerMove', 0, widgetId, ClientX, ClientY]
|
|
2182
|
+
}, {
|
|
2183
|
+
name: HandleResizerPointerUp,
|
|
2184
|
+
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleResizerPointerUp', 0, widgetId, ClientX, ClientY]
|
|
2071
2185
|
}];
|
|
2072
2186
|
};
|
|
2073
2187
|
|
|
@@ -2136,6 +2250,8 @@ const getRenderer = diffType => {
|
|
|
2136
2250
|
return renderValue;
|
|
2137
2251
|
case RenderReplaceValue:
|
|
2138
2252
|
return renderReplaceValue;
|
|
2253
|
+
case RenderCss:
|
|
2254
|
+
return renderCss;
|
|
2139
2255
|
default:
|
|
2140
2256
|
throw new Error('unknown renderer');
|
|
2141
2257
|
}
|
|
@@ -2160,6 +2276,10 @@ const render2 = (uid, diffResult) => {
|
|
|
2160
2276
|
return commands;
|
|
2161
2277
|
};
|
|
2162
2278
|
|
|
2279
|
+
const resize = async (state, dimensions) => {
|
|
2280
|
+
return state;
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2163
2283
|
const commandMap = {
|
|
2164
2284
|
'FindWidget.create': create$1,
|
|
2165
2285
|
'FindWidget.diff2': diff2,
|
|
@@ -2168,24 +2288,29 @@ const commandMap = {
|
|
|
2168
2288
|
'FindWidget.focusFirst': wrapCommand(focusFirst),
|
|
2169
2289
|
'FindWidget.focusIndex': wrapCommand(focusIndex),
|
|
2170
2290
|
'FindWidget.focusLast': wrapCommand(focusLast),
|
|
2171
|
-
'FindWidget.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
2172
2291
|
'FindWidget.focusNext': wrapCommand(focusNext),
|
|
2173
2292
|
'FindWidget.focusPrevious': wrapCommand(focusPrevious),
|
|
2174
2293
|
'FindWidget.focusReplace': wrapCommand(focusReplace),
|
|
2175
2294
|
'FindWidget.focusReplaceAllButton': wrapCommand(focusReplaceAllButton),
|
|
2176
2295
|
'FindWidget.getCommandIds': getCommandIds,
|
|
2177
2296
|
'FindWidget.handleBlur': wrapCommand(handleBlur),
|
|
2297
|
+
'FindWidget.handleClickButton': wrapCommand(handleClickButton),
|
|
2178
2298
|
'FindWidget.handleClickClose': wrapCommand(handleClickClose),
|
|
2179
2299
|
'FindWidget.handleInput': wrapCommand(handleInput),
|
|
2300
|
+
'FindWidget.handleReplaceFocus': wrapCommand(handleReplaceFocus),
|
|
2180
2301
|
'FindWidget.handleReplaceInput': wrapCommand(handleReplaceInput),
|
|
2302
|
+
'FindWidget.handleResizerPointerDown': wrapCommand(handleResizerPointerDown),
|
|
2303
|
+
'FindWidget.handleResizerPointerMove': wrapCommand(handleResizerPointerMove),
|
|
2304
|
+
'FindWidget.handleResizerPointerUp': wrapCommand(handleResizerPointerUp),
|
|
2181
2305
|
'FindWidget.loadContent': wrapCommand(loadContent),
|
|
2182
2306
|
'FindWidget.preventDefaultBrowserFind': wrapCommand(preventDefaultBrowserFind),
|
|
2183
2307
|
'FindWidget.render2': render2,
|
|
2184
|
-
'FindWidget.terminate': terminate,
|
|
2185
|
-
'FindWidget.toggleReplace': wrapCommand(toggleReplace),
|
|
2186
2308
|
'FindWidget.replace': wrapCommand(replace$1),
|
|
2187
2309
|
'FindWidget.replaceAll': wrapCommand(replaceAll$1),
|
|
2188
|
-
'FindWidget.
|
|
2310
|
+
'FindWidget.resize': wrapCommand(resize),
|
|
2311
|
+
'FindWidget.terminate': terminate,
|
|
2312
|
+
'FindWidget.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
2313
|
+
'FindWidget.toggleReplace': wrapCommand(toggleReplace$1),
|
|
2189
2314
|
'FindWidget.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression)
|
|
2190
2315
|
};
|
|
2191
2316
|
|