@lvce-editor/find-widget-worker 3.13.0 → 3.13.1

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.
@@ -889,6 +889,7 @@ const SetCss = 'Viewlet.setCss';
889
889
  const SetFocusContext = 'Viewlet.setFocusContext';
890
890
  const SetValueByName = 'Viewlet.setValueByName';
891
891
 
892
+ const Empty = 0;
892
893
  const FocusFindWidget$1 = 16;
893
894
  const FocusFindWidgetCloseButton$1 = 48;
894
895
  const FocusFindWidgetNextMatchButton$1 = 49;
@@ -1209,11 +1210,14 @@ const isEqual$6 = (oldState, newState) => {
1209
1210
  };
1210
1211
 
1211
1212
  const isEqual$5 = (oldState, newState) => {
1213
+ if (newState.focusSource === User) {
1214
+ return true;
1215
+ }
1212
1216
  return oldState.focused === newState.focused && oldState.focus === newState.focus && oldState.focusVersion === newState.focusVersion;
1213
1217
  };
1214
1218
 
1215
1219
  const isEqual$4 = (oldState, newState) => {
1216
- return oldState.focused === newState.focused;
1220
+ return oldState.focused === newState.focused && oldState.focus === newState.focus;
1217
1221
  };
1218
1222
 
1219
1223
  const isEqual$3 = (oldState, newState) => {
@@ -1279,9 +1283,9 @@ const disposeInstance = instanceId => {
1279
1283
  return disposeInstance$1(instanceId);
1280
1284
  };
1281
1285
 
1282
- const FindWidget$1 = 16;
1283
1286
  const FocusFindWidgetCloseButton = 48;
1284
1287
  const FocusFindWidgetNextMatchButton = 49;
1288
+ const FocusFindWidgetOptions = 44;
1285
1289
  const FocusFindWidgetPreviousMatchButton = 50;
1286
1290
  const FocusFindWidgetReplace = 43;
1287
1291
  const FocusFindWidgetReplaceAllButton = 47;
@@ -1755,6 +1759,9 @@ const getEdits = (matches, value, replacement, startIndex, replaceAll, lines, pr
1755
1759
  startOffset
1756
1760
  });
1757
1761
  }
1762
+ if (replaceAll) {
1763
+ edits.reverse();
1764
+ }
1758
1765
  return edits;
1759
1766
  };
1760
1767
 
@@ -1842,6 +1849,10 @@ const replaceAll$1 = async state => {
1842
1849
 
1843
1850
  const getClickHandler = name => {
1844
1851
  switch (name) {
1852
+ case FocusNext:
1853
+ return focusNext;
1854
+ case FocusPrevious:
1855
+ return focusPrevious;
1845
1856
  case MatchCase$2:
1846
1857
  return toggleMatchCase;
1847
1858
  case MatchWholeWord$2:
@@ -1859,13 +1870,35 @@ const getClickHandler = name => {
1859
1870
  }
1860
1871
  };
1861
1872
 
1862
- const handleClickButton = async (state, name) => {
1863
- const fn = getClickHandler(name);
1864
- return fn(state);
1865
- };
1866
-
1867
- const handleClickClose = state => {
1868
- return close$1(state);
1873
+ const getFindWidgetFocusKey = name => {
1874
+ switch (name) {
1875
+ case Close$2:
1876
+ return FocusFindWidgetCloseButton$1;
1877
+ case FocusNext:
1878
+ return FocusFindWidgetNextMatchButton$1;
1879
+ case FocusPrevious:
1880
+ return FocusFindWidgetPreviousMatchButton$1;
1881
+ case MatchCase$2:
1882
+ return FocusSearchMatchCase;
1883
+ case MatchWholeWord$2:
1884
+ return FocusSearchWholeWord;
1885
+ case PreserveCase$1:
1886
+ return FocusSearchPreserveCase;
1887
+ case Replace$2:
1888
+ return FocusFindWidgetReplaceButton$1;
1889
+ case ReplaceAll$2:
1890
+ return FocusFindWidgetReplaceAllButton$1;
1891
+ case ReplaceValue:
1892
+ return FocusSearchReplaceInput;
1893
+ case SearchValue:
1894
+ return FocusSearchInput;
1895
+ case ToggleReplace$1:
1896
+ return FocusToggleReplace;
1897
+ case UseRegularExpression$2:
1898
+ return FocusSearchRegex;
1899
+ default:
1900
+ return Empty;
1901
+ }
1869
1902
  };
1870
1903
 
1871
1904
  const handleFindWidgetFocus = (state, focusKey) => {
@@ -1882,13 +1915,25 @@ const handleFindWidgetFocus = (state, focusKey) => {
1882
1915
  };
1883
1916
  };
1884
1917
 
1885
- const handleFindFocus = state => {
1886
- return handleFindWidgetFocus(state, FindWidget$1);
1918
+ const handleClickButton = async (state, name) => {
1919
+ const fn = getClickHandler(name);
1920
+ const newState = await fn(state);
1921
+ const focusKey = getFindWidgetFocusKey(name);
1922
+ return handleFindWidgetFocus(newState, focusKey);
1923
+ };
1924
+
1925
+ const handleClickClose = state => {
1926
+ return close$1(state);
1927
+ };
1928
+
1929
+ const handleFindFocus = (state, name) => {
1930
+ const focusKey = getFindWidgetFocusKey(name);
1931
+ return handleFindWidgetFocus(state, focusKey);
1887
1932
  };
1888
1933
 
1889
1934
  // TODO maybe use one handleFocus function with a name parameter
1890
1935
  const handleReplaceFocus = state => {
1891
- return handleFindWidgetFocus(state, FocusFindWidgetReplace);
1936
+ return handleFindWidgetFocus(state, FocusSearchReplaceInput);
1892
1937
  };
1893
1938
 
1894
1939
  const handleResizerPointerDown = async (state, eventX, eventY) => {
@@ -1935,7 +1980,7 @@ const handleResizerPointerUp = async (state, eventX, eventY) => {
1935
1980
  };
1936
1981
 
1937
1982
  const handleToggleReplaceFocus = state => {
1938
- return handleFindWidgetFocus(state, FocusFindWidgetToggleReplace);
1983
+ return handleFindWidgetFocus(state, FocusToggleReplace);
1939
1984
  };
1940
1985
 
1941
1986
  const toggleReplace$1 = state => {
@@ -1969,6 +2014,19 @@ const focusElement = (state, whenExpression) => {
1969
2014
 
1970
2015
  const getNextFocus = (focus, replaceExpanded) => {
1971
2016
  switch (focus) {
2017
+ case FocusFindWidgetCloseButton$1:
2018
+ if (replaceExpanded) {
2019
+ return FocusFindWidgetReplaceButton$1;
2020
+ }
2021
+ return FocusToggleReplace;
2022
+ case FocusFindWidgetNextMatchButton$1:
2023
+ return FocusFindWidgetCloseButton$1;
2024
+ case FocusFindWidgetPreviousMatchButton$1:
2025
+ return FocusFindWidgetNextMatchButton$1;
2026
+ case FocusFindWidgetReplaceAllButton$1:
2027
+ return FocusToggleReplace;
2028
+ case FocusFindWidgetReplaceButton$1:
2029
+ return FocusFindWidgetReplaceAllButton$1;
1972
2030
  case FocusSearchExcludeInput:
1973
2031
  return FocusIgnoreFiles;
1974
2032
  case FocusSearchIncludeInput:
@@ -1983,12 +2041,12 @@ const getNextFocus = (focus, replaceExpanded) => {
1983
2041
  case FocusSearchOpenEditors:
1984
2042
  return FocusSearchExcludeInput;
1985
2043
  case FocusSearchPreserveCase:
1986
- return FocusSearchReplaceAll;
2044
+ return FocusFindWidgetPreviousMatchButton$1;
1987
2045
  case FocusSearchRegex:
1988
2046
  if (replaceExpanded) {
1989
2047
  return FocusSearchPreserveCase;
1990
2048
  }
1991
- return FocusFindWidgetCloseButton$1;
2049
+ return FocusFindWidgetPreviousMatchButton$1;
1992
2050
  case FocusSearchReplaceAll:
1993
2051
  return FocusToggleDetails;
1994
2052
  case FocusSearchReplaceInput:
@@ -2016,7 +2074,18 @@ const focusNextElement = state => {
2016
2074
  const getPreviousFocus = (focus, replaceExpanded) => {
2017
2075
  switch (focus) {
2018
2076
  case FocusFindWidgetCloseButton$1:
2077
+ return FocusFindWidgetNextMatchButton$1;
2078
+ case FocusFindWidgetNextMatchButton$1:
2079
+ return FocusFindWidgetPreviousMatchButton$1;
2080
+ case FocusFindWidgetPreviousMatchButton$1:
2081
+ if (replaceExpanded) {
2082
+ return FocusSearchPreserveCase;
2083
+ }
2019
2084
  return FocusSearchRegex;
2085
+ case FocusFindWidgetReplaceAllButton$1:
2086
+ return FocusFindWidgetReplaceButton$1;
2087
+ case FocusFindWidgetReplaceButton$1:
2088
+ return FocusFindWidgetCloseButton$1;
2020
2089
  case FocusIgnoreFiles:
2021
2090
  return FocusSearchExcludeInput;
2022
2091
  case FocusSearchExcludeInput:
@@ -2047,6 +2116,11 @@ const getPreviousFocus = (focus, replaceExpanded) => {
2047
2116
  return FocusSearchReplaceAll;
2048
2117
  }
2049
2118
  return FocusSearchRegex;
2119
+ case FocusToggleReplace:
2120
+ if (replaceExpanded) {
2121
+ return FocusFindWidgetReplaceAllButton$1;
2122
+ }
2123
+ return FocusFindWidgetCloseButton$1;
2050
2124
  default:
2051
2125
  return focus;
2052
2126
  }
@@ -2061,6 +2135,18 @@ const focusPreviousElement = state => {
2061
2135
  return focusElement(state, previousFocus);
2062
2136
  };
2063
2137
 
2138
+ const focusContexts = [FocusFindWidget$1, FocusFindWidgetReplace$1, FocusFindWidgetOptions, FocusFindWidgetPreviousMatchButton$1, FocusFindWidgetNextMatchButton$1, FocusFindWidgetCloseButton$1, FocusFindWidgetReplaceButton$1, FocusFindWidgetReplaceAllButton$1, FocusFindWidgetToggleReplace];
2139
+ const getFocusNavigationKeyBindings = () => {
2140
+ return focusContexts.flatMap(when => [{
2141
+ command: 'FindWidget.focusNextElement',
2142
+ key: Tab,
2143
+ when
2144
+ }, {
2145
+ command: 'FindWidget.focusPreviousElement',
2146
+ key: Shift | Tab,
2147
+ when
2148
+ }]);
2149
+ };
2064
2150
  const getKeyBindings = () => {
2065
2151
  return [{
2066
2152
  command: 'FindWidget.close',
@@ -2086,18 +2172,6 @@ const getKeyBindings = () => {
2086
2172
  command: 'FindWidget.focusNext',
2087
2173
  key: F4,
2088
2174
  when: FocusFindWidget$1
2089
- }, {
2090
- command: 'FindWidget.focusToggleReplace',
2091
- key: Shift | Tab,
2092
- when: FocusFindWidget$1
2093
- }, {
2094
- command: 'FindWidget.focusReplace',
2095
- key: Tab,
2096
- when: FocusFindWidget$1
2097
- }, {
2098
- command: 'FindWidget.focusPreviousMatchButton',
2099
- key: Tab,
2100
- when: FocusFindWidgetReplace$1
2101
2175
  }, {
2102
2176
  command: 'FindWidget.replace',
2103
2177
  key: Enter,
@@ -2106,51 +2180,19 @@ const getKeyBindings = () => {
2106
2180
  command: 'FindWidget.replaceAll',
2107
2181
  key: Alt | CtrlCmd | Enter,
2108
2182
  when: FocusFindWidgetReplace$1
2109
- }, {
2110
- command: 'FindWidget.focusNextMatchButton',
2111
- key: Tab,
2112
- when: FocusFindWidgetPreviousMatchButton$1
2113
- }, {
2114
- command: 'FindWidget.focusReplace',
2115
- key: Shift | Tab,
2116
- when: FocusFindWidgetPreviousMatchButton$1
2117
- }, {
2118
- command: 'FindWidget.focusPreviousMatchButton',
2119
- key: Shift | Tab,
2120
- when: FocusFindWidgetNextMatchButton$1
2121
- }, {
2122
- command: 'FindWidget.focusCloseButton',
2123
- key: Tab,
2124
- when: FocusFindWidgetNextMatchButton$1
2125
- }, {
2126
- command: 'FindWidget.focusNextMatchButton',
2127
- key: Shift | Tab,
2128
- when: FocusFindWidgetCloseButton$1
2129
- }, {
2130
- command: 'FindWidget.focusReplaceButton',
2131
- key: Tab,
2132
- when: FocusFindWidgetCloseButton$1
2133
- }, {
2134
- command: 'FindWidget.focusFind',
2135
- key: Shift | Tab,
2136
- when: FocusFindWidgetReplace$1
2137
- }, {
2138
- command: 'FindWidget.focusReplaceAllButton',
2139
- key: Tab,
2140
- when: FocusFindWidgetReplaceButton$1
2141
- }, {
2142
- command: 'FindWidget.focusCloseButton',
2143
- key: Shift | Tab,
2144
- when: FocusFindWidgetReplaceButton$1
2145
- }, {
2146
- command: 'FindWidget.focusReplaceButton',
2147
- key: Shift | Tab,
2148
- when: FocusFindWidgetReplaceAllButton$1
2149
- }];
2183
+ }, ...getFocusNavigationKeyBindings()];
2150
2184
  };
2151
2185
 
2152
2186
  const handleInput = (state, value, inputSource = User$1) => {
2153
- return refresh(state, value, inputSource);
2187
+ const newState = refresh(state, value, inputSource);
2188
+ if (inputSource !== User$1) {
2189
+ return newState;
2190
+ }
2191
+ return {
2192
+ ...newState,
2193
+ focus: FocusSearchInput,
2194
+ focusSource: User
2195
+ };
2154
2196
  };
2155
2197
 
2156
2198
  const handleReplaceInput = (state, value, inputSource = User$1) => {
@@ -2432,13 +2474,13 @@ const getFindWidgetButtons = (findButtonsEnabled, replaceButtonsEnabled, matchCa
2432
2474
  icon: ArrowUp,
2433
2475
  label: previousMatch(),
2434
2476
  name: FocusPrevious,
2435
- onClick: HandleClickPreviousMatch
2477
+ onClick: HandleClickButton
2436
2478
  }, {
2437
2479
  disabled: !findButtonsEnabled,
2438
2480
  icon: ArrowDown,
2439
2481
  label: nextMatch(),
2440
2482
  name: FocusNext,
2441
- onClick: HandleClickNextMatch
2483
+ onClick: HandleClickButton
2442
2484
  }, {
2443
2485
  disabled: false,
2444
2486
  icon: Close,
@@ -2662,7 +2704,7 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons, replace
2662
2704
  childCount: 1 + replaceButtons.length,
2663
2705
  className: FindWidgetReplace,
2664
2706
  type: Div
2665
- }, ...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleReplaceInput, [], [], HandleReplaceFocus, extraClassName, replaceInputFocused), ...replaceButtons.flatMap(getIconButtonVirtualDom)];
2707
+ }, ...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleReplaceInput, replaceFieldButtons, [], HandleReplaceFocus, extraClassName, replaceInputFocused), ...replaceButtons.flatMap(getIconButtonVirtualDom)];
2666
2708
  };
2667
2709
 
2668
2710
  const resizerNode = {
@@ -2844,6 +2886,14 @@ const getFocusSelector = focusKey => {
2844
2886
  switch (focusKey) {
2845
2887
  case FocusFindWidgetCloseButton$1:
2846
2888
  return Close$2;
2889
+ case FocusFindWidgetNextMatchButton$1:
2890
+ return FocusNext;
2891
+ case FocusFindWidgetPreviousMatchButton$1:
2892
+ return FocusPrevious;
2893
+ case FocusFindWidgetReplaceAllButton$1:
2894
+ return ReplaceAll$2;
2895
+ case FocusFindWidgetReplaceButton$1:
2896
+ return Replace$2;
2847
2897
  case FocusSearchInput:
2848
2898
  return SearchValue;
2849
2899
  case FocusSearchMatchCase:
@@ -2877,8 +2927,24 @@ const renderFocus = (oldState, newState) => {
2877
2927
 
2878
2928
  const FocusFindWidget = 16;
2879
2929
 
2930
+ const optionFocusContexts = [FocusSearchMatchCase, FocusSearchPreserveCase, FocusSearchRegex, FocusSearchWholeWord];
2880
2931
  const renderFocusContext = (oldState, newState) => {
2881
- return [/* method */SetFocusContext, FocusFindWidget];
2932
+ const {
2933
+ focus
2934
+ } = newState;
2935
+ if (focus === FocusSearchReplaceInput) {
2936
+ return [/* method */SetFocusContext, FocusFindWidgetReplace];
2937
+ }
2938
+ if (focus === FocusSearchInput || !focus) {
2939
+ return [/* method */SetFocusContext, FocusFindWidget];
2940
+ }
2941
+ if (focus === FocusToggleReplace) {
2942
+ return [/* method */SetFocusContext, FocusFindWidgetToggleReplace];
2943
+ }
2944
+ if (optionFocusContexts.includes(focus)) {
2945
+ return [/* method */SetFocusContext, FocusFindWidgetOptions];
2946
+ }
2947
+ return [/* method */SetFocusContext, focus];
2882
2948
  };
2883
2949
 
2884
2950
  const renderReplaceValue = (oldState, newState) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/find-widget-worker",
3
- "version": "3.13.0",
3
+ "version": "3.13.1",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",