@lvce-editor/find-widget-worker 1.15.0 → 1.17.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 +170 -27
- package/package.json +1 -1
|
@@ -943,9 +943,11 @@ const {
|
|
|
943
943
|
wrapCommand,
|
|
944
944
|
dispose: dispose$2,
|
|
945
945
|
getCommandIds,
|
|
946
|
-
registerCommands
|
|
946
|
+
registerCommands,
|
|
947
|
+
wrapGetter
|
|
947
948
|
} = create$2();
|
|
948
949
|
|
|
950
|
+
const User$1 = 1;
|
|
949
951
|
const Script$1 = 2;
|
|
950
952
|
const Unknown = 0;
|
|
951
953
|
|
|
@@ -978,16 +980,22 @@ const create$1 = (uid, x, y, width, height, parentUid) => {
|
|
|
978
980
|
editorWidth: width,
|
|
979
981
|
editorHeight: height,
|
|
980
982
|
inputSource: 0,
|
|
981
|
-
preserveCase: false
|
|
983
|
+
preserveCase: false,
|
|
984
|
+
resizerPointerDown: false,
|
|
985
|
+
minWidth: 300
|
|
982
986
|
};
|
|
983
987
|
set$3(uid, state, state);
|
|
984
988
|
return state;
|
|
985
989
|
};
|
|
986
990
|
|
|
987
|
-
const isEqual$
|
|
991
|
+
const isEqual$6 = (oldState, newState) => {
|
|
988
992
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
989
993
|
};
|
|
990
994
|
|
|
995
|
+
const isEqual$5 = (oldState, newState) => {
|
|
996
|
+
return newState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x;
|
|
997
|
+
};
|
|
998
|
+
|
|
991
999
|
const isEqual$4 = (oldState, newState) => {
|
|
992
1000
|
return oldState.version === newState.version;
|
|
993
1001
|
};
|
|
@@ -1005,6 +1013,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1005
1013
|
};
|
|
1006
1014
|
|
|
1007
1015
|
const RenderBounds = 8;
|
|
1016
|
+
const RenderCss = 10;
|
|
1008
1017
|
const RenderEventListeners = 11;
|
|
1009
1018
|
const RenderUid = 12;
|
|
1010
1019
|
const RenderContent = 13;
|
|
@@ -1022,12 +1031,16 @@ const Div = 4;
|
|
|
1022
1031
|
const Text = 12;
|
|
1023
1032
|
const TextArea = 62;
|
|
1024
1033
|
|
|
1034
|
+
const ClientX = 'event.clientX';
|
|
1035
|
+
const ClientY = 'event.clientY';
|
|
1036
|
+
|
|
1025
1037
|
const User = 1;
|
|
1026
1038
|
const Script = 1;
|
|
1027
1039
|
|
|
1028
1040
|
const EditorWorker$1 = 99;
|
|
1029
1041
|
|
|
1030
1042
|
const FocusSelector = 'Viewlet.focusSelector';
|
|
1043
|
+
const SetCss = 'Viewlet.setCss';
|
|
1031
1044
|
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1032
1045
|
const SetValueByName = 'Viewlet.setValueByName';
|
|
1033
1046
|
|
|
@@ -1035,8 +1048,8 @@ const isEqual = (oldState, newState) => {
|
|
|
1035
1048
|
return newState.inputSource === User || oldState.value === newState.value;
|
|
1036
1049
|
};
|
|
1037
1050
|
|
|
1038
|
-
const modules = [isEqual$4, isEqual$2, isEqual$
|
|
1039
|
-
const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus, RenderValue];
|
|
1051
|
+
const modules = [isEqual$4, isEqual$2, isEqual$6, isEqual$1, isEqual$3, isEqual$3, isEqual, isEqual$5];
|
|
1052
|
+
const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus, RenderValue, RenderCss];
|
|
1040
1053
|
|
|
1041
1054
|
const diff = (oldState, newState) => {
|
|
1042
1055
|
const diffResult = [];
|
|
@@ -1425,7 +1438,7 @@ const Replace$2 = 'Replace';
|
|
|
1425
1438
|
const ReplaceAll$2 = 'ReplaceAll';
|
|
1426
1439
|
const ReplaceValue = 'replace-value';
|
|
1427
1440
|
const SearchValue = 'search-value';
|
|
1428
|
-
const ToggleReplace = 'ToggleReplace';
|
|
1441
|
+
const ToggleReplace$1 = 'ToggleReplace';
|
|
1429
1442
|
const UseRegularExpression$1 = 'UseRegularExpression';
|
|
1430
1443
|
|
|
1431
1444
|
const applyEdits = async (editorId, edits) => {
|
|
@@ -1534,6 +1547,58 @@ const handleInput = (state, value, inputSource = User) => {
|
|
|
1534
1547
|
return refresh(state, value, inputSource);
|
|
1535
1548
|
};
|
|
1536
1549
|
|
|
1550
|
+
const handleFindWidgetFocus = (state, focusKey) => {
|
|
1551
|
+
if (state.focus === focusKey) {
|
|
1552
|
+
return state;
|
|
1553
|
+
}
|
|
1554
|
+
return {
|
|
1555
|
+
...state,
|
|
1556
|
+
focus: focusKey,
|
|
1557
|
+
focusSource: User$1
|
|
1558
|
+
};
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
const handleReplaceFocus = state => {
|
|
1562
|
+
return handleFindWidgetFocus(state, FocusFindWidgetReplace);
|
|
1563
|
+
};
|
|
1564
|
+
|
|
1565
|
+
const handleResizerPointerDown = async (state, eventX, eventY) => {
|
|
1566
|
+
return {
|
|
1567
|
+
...state,
|
|
1568
|
+
resizerPointerDown: true
|
|
1569
|
+
};
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1572
|
+
const getNewWidth = (oldWidth, oldX, eventX, minWidth) => {
|
|
1573
|
+
const oldXEnd = oldX + oldWidth;
|
|
1574
|
+
const newWidth = Math.max(oldXEnd - eventX, minWidth);
|
|
1575
|
+
return newWidth;
|
|
1576
|
+
};
|
|
1577
|
+
const handleResizerPointerMove = async (state, eventX, eventY) => {
|
|
1578
|
+
const {
|
|
1579
|
+
width,
|
|
1580
|
+
x,
|
|
1581
|
+
resizerPointerDown,
|
|
1582
|
+
minWidth
|
|
1583
|
+
} = state;
|
|
1584
|
+
if (!resizerPointerDown) {
|
|
1585
|
+
return state;
|
|
1586
|
+
}
|
|
1587
|
+
const newWidth = getNewWidth(width, x, eventX, minWidth);
|
|
1588
|
+
return {
|
|
1589
|
+
...state,
|
|
1590
|
+
x: eventX,
|
|
1591
|
+
width: newWidth
|
|
1592
|
+
};
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
const handleResizerPointerUp = async (state, eventX, eventY) => {
|
|
1596
|
+
return {
|
|
1597
|
+
...state,
|
|
1598
|
+
resizerPointerDown: false
|
|
1599
|
+
};
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1537
1602
|
const getFindWidgetHeight = replaceExpanded => {
|
|
1538
1603
|
const collapsedHeight = 30;
|
|
1539
1604
|
const expandedHeight = 60;
|
|
@@ -1541,7 +1606,7 @@ const getFindWidgetHeight = replaceExpanded => {
|
|
|
1541
1606
|
return newHeight;
|
|
1542
1607
|
};
|
|
1543
1608
|
|
|
1544
|
-
const toggleReplace = state => {
|
|
1609
|
+
const toggleReplace$1 = state => {
|
|
1545
1610
|
const {
|
|
1546
1611
|
replaceExpanded
|
|
1547
1612
|
} = state;
|
|
@@ -1674,19 +1739,23 @@ const renderBounds = (oldState, newState) => {
|
|
|
1674
1739
|
};
|
|
1675
1740
|
|
|
1676
1741
|
const HandleBlur = 'handleBlur';
|
|
1742
|
+
const HandleClickButton = 'handleClickButton';
|
|
1677
1743
|
const HandleClickClose = 'handleClickClose';
|
|
1678
1744
|
const HandleClickNextMatch = 'handleClickNextMatch';
|
|
1679
1745
|
const HandleClickPreviousMatch = 'handleClickPreviousMatch';
|
|
1680
1746
|
const HandleClickReplace = 'handleClickReplace';
|
|
1681
|
-
const HandleClickToggleReplace = 'handleClickToggleReplace';
|
|
1682
1747
|
const HandleClickReplaceAll = 'handleClickReplaceAll';
|
|
1683
|
-
const
|
|
1748
|
+
const HandleClickToggleReplace = 'handleClickToggleReplace';
|
|
1684
1749
|
const HandleFocus = 'handleFocus';
|
|
1750
|
+
const HandleFocusNext = 'handleFocusNext';
|
|
1751
|
+
const HandleFocusPrevious = 'handleFocusPrevious';
|
|
1685
1752
|
const HandleInput = 'handleInput';
|
|
1686
1753
|
const HandleReplaceFocus = 'handleReplaceFocus';
|
|
1687
|
-
const HandleFocusPrevious = 'handleFocusPrevious';
|
|
1688
|
-
const HandleFocusNext = 'handleFocusNext';
|
|
1689
1754
|
const HandleReplaceInput = 'handleReplaceInput';
|
|
1755
|
+
const HandleResizerPointerDown = 'handleResizerPointerDown';
|
|
1756
|
+
const HandleResizerPointerMove = 'handleResizerPointerMove';
|
|
1757
|
+
const HandleResizerPointerUp = 'handleResizerPointerUp';
|
|
1758
|
+
const HandleToggleReplaceFocus = 'handleToggleReplaceFocus';
|
|
1690
1759
|
|
|
1691
1760
|
const emptyObject = {};
|
|
1692
1761
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
@@ -1708,6 +1777,7 @@ const NextMatch = 'Next Match';
|
|
|
1708
1777
|
const Find$1 = 'Find';
|
|
1709
1778
|
const Replace$1 = 'Replace';
|
|
1710
1779
|
const ReplaceAll$1 = 'Replace All';
|
|
1780
|
+
const ToggleReplace = 'Toggle Replace';
|
|
1711
1781
|
|
|
1712
1782
|
const noResults = () => {
|
|
1713
1783
|
return i18nString(NoResults);
|
|
@@ -1736,6 +1806,9 @@ const replace = () => {
|
|
|
1736
1806
|
const replaceAll = () => {
|
|
1737
1807
|
return i18nString(ReplaceAll$1);
|
|
1738
1808
|
};
|
|
1809
|
+
const toggleReplace = () => {
|
|
1810
|
+
return i18nString(ToggleReplace);
|
|
1811
|
+
};
|
|
1739
1812
|
|
|
1740
1813
|
const MatchCase = 'CaseSensitive';
|
|
1741
1814
|
const UseRegularExpression = 'Regex';
|
|
@@ -1829,17 +1902,20 @@ const getFindButtons = () => {
|
|
|
1829
1902
|
checked: false,
|
|
1830
1903
|
icon: MatchCase,
|
|
1831
1904
|
title: 'Match Case',
|
|
1832
|
-
name: MatchCase$1
|
|
1905
|
+
name: MatchCase$1,
|
|
1906
|
+
onClick: HandleClickButton
|
|
1833
1907
|
}, {
|
|
1834
1908
|
checked: false,
|
|
1835
1909
|
icon: MatchWholeWord,
|
|
1836
1910
|
title: 'Match Whole Word',
|
|
1837
|
-
name: MatchWholeWord$1
|
|
1911
|
+
name: MatchWholeWord$1,
|
|
1912
|
+
onClick: HandleClickButton
|
|
1838
1913
|
}, {
|
|
1839
1914
|
checked: false,
|
|
1840
1915
|
icon: UseRegularExpression,
|
|
1841
1916
|
title: 'Use Regular Expression',
|
|
1842
|
-
name: UseRegularExpression$1
|
|
1917
|
+
name: UseRegularExpression$1,
|
|
1918
|
+
onClick: HandleClickButton
|
|
1843
1919
|
}];
|
|
1844
1920
|
};
|
|
1845
1921
|
|
|
@@ -1887,16 +1963,20 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
1887
1963
|
const {
|
|
1888
1964
|
icon,
|
|
1889
1965
|
checked,
|
|
1890
|
-
title
|
|
1966
|
+
title,
|
|
1967
|
+
name,
|
|
1968
|
+
onClick
|
|
1891
1969
|
} = button;
|
|
1892
1970
|
return [{
|
|
1893
1971
|
type: Div,
|
|
1972
|
+
ariaChecked: checked,
|
|
1894
1973
|
className: mergeClassNames(SearchFieldButton, checked ? SearchFieldButtonChecked : ''),
|
|
1895
|
-
|
|
1974
|
+
name,
|
|
1896
1975
|
role: CheckBox,
|
|
1897
|
-
ariaChecked: checked,
|
|
1898
1976
|
tabIndex: 0,
|
|
1899
|
-
|
|
1977
|
+
title,
|
|
1978
|
+
childCount: 1,
|
|
1979
|
+
onClick
|
|
1900
1980
|
}, {
|
|
1901
1981
|
type: Div,
|
|
1902
1982
|
className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
|
|
@@ -1961,18 +2041,32 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons) => {
|
|
|
1961
2041
|
return dom;
|
|
1962
2042
|
};
|
|
1963
2043
|
|
|
2044
|
+
const getResizerVirtualDom = () => {
|
|
2045
|
+
return [{
|
|
2046
|
+
type: Div,
|
|
2047
|
+
className: 'Resizer',
|
|
2048
|
+
childCount: 1,
|
|
2049
|
+
onPointerDown: HandleResizerPointerDown
|
|
2050
|
+
}, {
|
|
2051
|
+
type: Div,
|
|
2052
|
+
className: 'ResizerHighlight',
|
|
2053
|
+
childCount: 0
|
|
2054
|
+
}];
|
|
2055
|
+
};
|
|
2056
|
+
|
|
1964
2057
|
const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
|
|
2058
|
+
const title = toggleReplace();
|
|
1965
2059
|
return [{
|
|
1966
2060
|
type: Button,
|
|
1967
2061
|
className: `IconButton SearchToggleButton ${replaceExpanded ? 'SearchToggleButtonExpanded' : ''}`,
|
|
1968
|
-
title
|
|
1969
|
-
ariaLabel:
|
|
2062
|
+
title,
|
|
2063
|
+
ariaLabel: title,
|
|
1970
2064
|
ariaExpanded: replaceExpanded,
|
|
1971
|
-
name: ToggleReplace,
|
|
2065
|
+
name: ToggleReplace$1,
|
|
1972
2066
|
childCount: 1,
|
|
1973
2067
|
'data-command': 'toggleReplace',
|
|
1974
2068
|
onClick,
|
|
1975
|
-
onFocus:
|
|
2069
|
+
onFocus: HandleToggleReplaceFocus
|
|
1976
2070
|
}, {
|
|
1977
2071
|
type: Div,
|
|
1978
2072
|
className: `MaskIcon ${replaceExpanded ? 'MaskIconChevronDown' : 'MaskIconChevronRight'}`,
|
|
@@ -1985,9 +2079,10 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, r
|
|
|
1985
2079
|
dom.push({
|
|
1986
2080
|
type: Div,
|
|
1987
2081
|
className: mergeClassNames(Viewlet, ViewletFind, ViewletFindWidget, FindWidget),
|
|
1988
|
-
childCount:
|
|
2082
|
+
childCount: 3,
|
|
1989
2083
|
role: Group
|
|
1990
2084
|
});
|
|
2085
|
+
dom.push(...getResizerVirtualDom());
|
|
1991
2086
|
dom.push(...getSearchToggleButtonVirtualDom(replaceExpanded, 'handleClickToggleReplace'));
|
|
1992
2087
|
dom.push({
|
|
1993
2088
|
type: Div,
|
|
@@ -2025,6 +2120,23 @@ const renderContent = (oldState, newState) => {
|
|
|
2025
2120
|
return [SetDom2, uid, dom];
|
|
2026
2121
|
};
|
|
2027
2122
|
|
|
2123
|
+
const renderCss = (oldState, newState) => {
|
|
2124
|
+
const {
|
|
2125
|
+
uid,
|
|
2126
|
+
width,
|
|
2127
|
+
height,
|
|
2128
|
+
x,
|
|
2129
|
+
y
|
|
2130
|
+
} = newState;
|
|
2131
|
+
const css = `:root {
|
|
2132
|
+
--FindWidgetWidth: ${width}px;
|
|
2133
|
+
--FindWidgetHeight: ${height}px;
|
|
2134
|
+
--FindWidgetX: ${x}px;
|
|
2135
|
+
--FindWidgetY: ${y}px;
|
|
2136
|
+
}`;
|
|
2137
|
+
return [SetCss, uid, css];
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2028
2140
|
const getEventListeners = (uid, widgetId) => {
|
|
2029
2141
|
return [{
|
|
2030
2142
|
name: HandleInput,
|
|
@@ -2068,6 +2180,16 @@ const getEventListeners = (uid, widgetId) => {
|
|
|
2068
2180
|
}, {
|
|
2069
2181
|
name: HandleClickButton,
|
|
2070
2182
|
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleClickButton', 0, widgetId, `event.target.name`]
|
|
2183
|
+
}, {
|
|
2184
|
+
name: HandleResizerPointerDown,
|
|
2185
|
+
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleResizerPointerDown', 0, widgetId, ClientX, ClientY],
|
|
2186
|
+
trackPointerEvents: [HandleResizerPointerMove, HandleResizerPointerUp]
|
|
2187
|
+
}, {
|
|
2188
|
+
name: HandleResizerPointerMove,
|
|
2189
|
+
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleResizerPointerMove', 0, widgetId, ClientX, ClientY]
|
|
2190
|
+
}, {
|
|
2191
|
+
name: HandleResizerPointerUp,
|
|
2192
|
+
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleResizerPointerUp', 0, widgetId, ClientX, ClientY]
|
|
2071
2193
|
}];
|
|
2072
2194
|
};
|
|
2073
2195
|
|
|
@@ -2136,6 +2258,8 @@ const getRenderer = diffType => {
|
|
|
2136
2258
|
return renderValue;
|
|
2137
2259
|
case RenderReplaceValue:
|
|
2138
2260
|
return renderReplaceValue;
|
|
2261
|
+
case RenderCss:
|
|
2262
|
+
return renderCss;
|
|
2139
2263
|
default:
|
|
2140
2264
|
throw new Error('unknown renderer');
|
|
2141
2265
|
}
|
|
@@ -2160,6 +2284,19 @@ const render2 = (uid, diffResult) => {
|
|
|
2160
2284
|
return commands;
|
|
2161
2285
|
};
|
|
2162
2286
|
|
|
2287
|
+
const resize = async (state, dimensions) => {
|
|
2288
|
+
return state;
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
const saveState = state => {
|
|
2292
|
+
const {
|
|
2293
|
+
width
|
|
2294
|
+
} = state;
|
|
2295
|
+
return {
|
|
2296
|
+
width
|
|
2297
|
+
};
|
|
2298
|
+
};
|
|
2299
|
+
|
|
2163
2300
|
const commandMap = {
|
|
2164
2301
|
'FindWidget.create': create$1,
|
|
2165
2302
|
'FindWidget.diff2': diff2,
|
|
@@ -2168,24 +2305,30 @@ const commandMap = {
|
|
|
2168
2305
|
'FindWidget.focusFirst': wrapCommand(focusFirst),
|
|
2169
2306
|
'FindWidget.focusIndex': wrapCommand(focusIndex),
|
|
2170
2307
|
'FindWidget.focusLast': wrapCommand(focusLast),
|
|
2171
|
-
'FindWidget.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
2172
2308
|
'FindWidget.focusNext': wrapCommand(focusNext),
|
|
2173
2309
|
'FindWidget.focusPrevious': wrapCommand(focusPrevious),
|
|
2174
2310
|
'FindWidget.focusReplace': wrapCommand(focusReplace),
|
|
2175
2311
|
'FindWidget.focusReplaceAllButton': wrapCommand(focusReplaceAllButton),
|
|
2176
2312
|
'FindWidget.getCommandIds': getCommandIds,
|
|
2177
2313
|
'FindWidget.handleBlur': wrapCommand(handleBlur),
|
|
2314
|
+
'FindWidget.handleClickButton': wrapCommand(handleClickButton),
|
|
2178
2315
|
'FindWidget.handleClickClose': wrapCommand(handleClickClose),
|
|
2179
2316
|
'FindWidget.handleInput': wrapCommand(handleInput),
|
|
2317
|
+
'FindWidget.handleReplaceFocus': wrapCommand(handleReplaceFocus),
|
|
2180
2318
|
'FindWidget.handleReplaceInput': wrapCommand(handleReplaceInput),
|
|
2319
|
+
'FindWidget.handleResizerPointerDown': wrapCommand(handleResizerPointerDown),
|
|
2320
|
+
'FindWidget.handleResizerPointerMove': wrapCommand(handleResizerPointerMove),
|
|
2321
|
+
'FindWidget.handleResizerPointerUp': wrapCommand(handleResizerPointerUp),
|
|
2181
2322
|
'FindWidget.loadContent': wrapCommand(loadContent),
|
|
2182
2323
|
'FindWidget.preventDefaultBrowserFind': wrapCommand(preventDefaultBrowserFind),
|
|
2183
2324
|
'FindWidget.render2': render2,
|
|
2184
|
-
'FindWidget.terminate': terminate,
|
|
2185
|
-
'FindWidget.toggleReplace': wrapCommand(toggleReplace),
|
|
2186
2325
|
'FindWidget.replace': wrapCommand(replace$1),
|
|
2187
2326
|
'FindWidget.replaceAll': wrapCommand(replaceAll$1),
|
|
2188
|
-
'FindWidget.
|
|
2327
|
+
'FindWidget.resize': wrapCommand(resize),
|
|
2328
|
+
'FindWidget.terminate': terminate,
|
|
2329
|
+
'FindWidget.saveState': wrapGetter(saveState),
|
|
2330
|
+
'FindWidget.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
2331
|
+
'FindWidget.toggleReplace': wrapCommand(toggleReplace$1),
|
|
2189
2332
|
'FindWidget.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression)
|
|
2190
2333
|
};
|
|
2191
2334
|
|