@lvce-editor/editor-worker 3.8.0 → 3.10.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.
@@ -134,7 +134,6 @@ const EditorRow = 'EditorRow';
134
134
  const EditorSelection = 'EditorSelection';
135
135
  const FileIcon = 'FileIcon';
136
136
  const HoverDisplayString = 'HoverDisplayString';
137
- const SearchFieldContainer = 'SearchFieldContainer';
138
137
  const HoverDocumentation = 'HoverDocumentation';
139
138
  const SearchFieldButtons = 'SearchFieldButtons';
140
139
  const HoverEditorRow = 'HoverEditorRow';
@@ -3420,9 +3419,6 @@ const noTypeDefinitionFound = () => {
3420
3419
  const noResults$1 = () => {
3421
3420
  return i18nString(UiStrings$1.NoResults);
3422
3421
  };
3423
- const replace = () => {
3424
- return i18nString(UiStrings$1.Replace);
3425
- };
3426
3422
 
3427
3423
  // @ts-ignore
3428
3424
  const goTo = async ({
@@ -5193,7 +5189,8 @@ const loadContent$1 = editorId => {
5193
5189
  value,
5194
5190
  matches,
5195
5191
  matchIndex: 0,
5196
- matchCount
5192
+ matchCount,
5193
+ editorUid: editor.uid
5197
5194
  };
5198
5195
  };
5199
5196
  const refresh = (state, value = state.value) => {
@@ -5230,9 +5227,14 @@ const handleBlur = async state => {
5230
5227
  return state;
5231
5228
  };
5232
5229
  const toggleReplace = state => {
5230
+ const newExpanded = !state.replaceExpanded;
5231
+ const collapsedHeight = 30;
5232
+ const expandedHeight = 60;
5233
+ const newHeight = newExpanded ? expandedHeight : collapsedHeight;
5233
5234
  return {
5234
5235
  ...state,
5235
- replaceExpanded: !state.replaceExpanded
5236
+ replaceExpanded: !state.replaceExpanded,
5237
+ height: newHeight
5236
5238
  };
5237
5239
  };
5238
5240
 
@@ -5320,7 +5322,8 @@ const openFind2 = async editor => {
5320
5322
  x,
5321
5323
  y,
5322
5324
  width,
5323
- height
5325
+ height,
5326
+ editorUid: editor.uid || editor.id
5324
5327
  };
5325
5328
  return latestState;
5326
5329
  };
@@ -8621,7 +8624,11 @@ const widgetCommands = {
8621
8624
  'FindWidget.focusLast': Find,
8622
8625
  'FindWidget.toggleReplace': Find,
8623
8626
  'FindWidget.handleFocus': Find,
8624
- 'FindWidget.handleBlur': Find
8627
+ 'FindWidget.handleBlur': Find,
8628
+ 'FindWidget.handleToggleReplaceFocus': Find,
8629
+ 'FindWidget.handleInput': Find,
8630
+ 'FindWidget.handleReplaceInput': Find,
8631
+ 'FindWidget.handleReplaceFocus': Find
8625
8632
  };
8626
8633
 
8627
8634
  // TODO wrap commands globally, not per editor
@@ -9842,7 +9849,9 @@ const UiStrings = {
9842
9849
  Close: 'Close',
9843
9850
  PreviousMatch: 'Previous Match',
9844
9851
  NextMatch: 'Next Match',
9845
- Find: 'Find'
9852
+ Find: 'Find',
9853
+ Replace: 'Replace',
9854
+ ReplaceAll: 'Replace All'
9846
9855
  };
9847
9856
  const noResults = () => {
9848
9857
  return i18nString(UiStrings.NoResults);
@@ -9862,6 +9871,15 @@ const nextMatch = () => {
9862
9871
  const close = () => {
9863
9872
  return i18nString(UiStrings.Close);
9864
9873
  };
9874
+ const find = () => {
9875
+ return i18nString(UiStrings.Find);
9876
+ };
9877
+ const replace = () => {
9878
+ return i18nString(UiStrings.Replace);
9879
+ };
9880
+ const replaceAll = () => {
9881
+ return i18nString(UiStrings.ReplaceAll);
9882
+ };
9865
9883
 
9866
9884
  const getIconVirtualDom = (icon, type = Div) => {
9867
9885
  return {
@@ -9872,6 +9890,27 @@ const getIconVirtualDom = (icon, type = Div) => {
9872
9890
  };
9873
9891
  };
9874
9892
 
9893
+ const getIconButtonVirtualDom = iconButton => {
9894
+ const {
9895
+ label,
9896
+ icon,
9897
+ disabled
9898
+ } = iconButton;
9899
+ let className = IconButton;
9900
+ if (disabled) {
9901
+ className += ' ' + IconButtonDisabled;
9902
+ }
9903
+ return [{
9904
+ type: Button,
9905
+ className,
9906
+ title: label,
9907
+ ariaLabel: label,
9908
+ childCount: 1,
9909
+ disabled: disabled ? true : undefined,
9910
+ onClick: iconButton.onClick
9911
+ }, getIconVirtualDom(icon)];
9912
+ };
9913
+
9875
9914
  const getSearchFieldButtonVirtualDom = button => {
9876
9915
  const {
9877
9916
  icon,
@@ -9916,36 +9955,11 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
9916
9955
  childCount: insideButtons.length
9917
9956
  }, ...insideButtons.flatMap(getSearchFieldButtonVirtualDom)];
9918
9957
  if (outsideButtons.length > 0) {
9919
- dom.unshift({
9920
- type: Div,
9921
- className: SearchFieldContainer,
9922
- role: None,
9923
- childCount: 1 + outsideButtons.length
9924
- });
9925
- dom.push(...outsideButtons.flatMap(getSearchFieldButtonVirtualDom));
9958
+ throw new Error('outsideButtons are deprecated');
9926
9959
  }
9927
9960
  return dom;
9928
9961
  };
9929
9962
 
9930
- const getIconButtonVirtualDom = iconButton => {
9931
- const {
9932
- label,
9933
- icon,
9934
- disabled
9935
- } = iconButton;
9936
- let className = IconButton;
9937
- if (disabled) {
9938
- className += ' ' + IconButtonDisabled;
9939
- }
9940
- return [{
9941
- type: Button,
9942
- className,
9943
- title: label,
9944
- ariaLabel: label,
9945
- childCount: 1,
9946
- disabled: disabled ? true : undefined
9947
- }, getIconVirtualDom(icon)];
9948
- };
9949
9963
  const getFindWidgetFindVirtualDom = (matchCountText, buttons) => {
9950
9964
  const dom = [];
9951
9965
  dom.push({
@@ -9953,7 +9967,7 @@ const getFindWidgetFindVirtualDom = (matchCountText, buttons) => {
9953
9967
  className: FindWidgetFind,
9954
9968
  childCount: 5
9955
9969
  });
9956
- dom.push(...getSearchFieldVirtualDom('search-value', 'Find', 'handleInput', [], [], 'handleFocus'));
9970
+ dom.push(...getSearchFieldVirtualDom('search-value', find(), 'handleInput', [], [], 'handleFocus'));
9957
9971
  dom.push({
9958
9972
  type: Div,
9959
9973
  className: FindWidgetMatchCount,
@@ -9962,14 +9976,14 @@ const getFindWidgetFindVirtualDom = (matchCountText, buttons) => {
9962
9976
  return dom;
9963
9977
  };
9964
9978
 
9965
- const getFindWidgetReplaceVirtualDom = replaceExpanded => {
9979
+ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons) => {
9966
9980
  const dom = [];
9967
9981
  if (replaceExpanded) {
9968
9982
  dom.push({
9969
9983
  type: Div,
9970
9984
  className: FindWidgetReplace,
9971
- childCount: 1
9972
- }, text(replace()));
9985
+ childCount: 1 + replaceButtons.length
9986
+ }, ...getSearchFieldVirtualDom('replace-value', replace(), 'handleReplaceInput', [], [], 'handleReplaceFocus'), ...replaceButtons.flatMap(getIconButtonVirtualDom));
9973
9987
  }
9974
9988
  return dom;
9975
9989
  };
@@ -9991,7 +10005,7 @@ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
9991
10005
  }];
9992
10006
  };
9993
10007
 
9994
- const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, buttons, matchCase, matchWholeWord, useRegularExpression) => {
10008
+ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, replaceButtons, matchCase, matchWholeWord, useRegularExpression) => {
9995
10009
  const dom = [];
9996
10010
  dom.push({
9997
10011
  type: Div,
@@ -9999,15 +10013,15 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, buttons, match
9999
10013
  childCount: 2,
10000
10014
  role: Group
10001
10015
  });
10002
- dom.push(...getSearchToggleButtonVirtualDom(replaceExpanded, 'handleClick'));
10016
+ dom.push(...getSearchToggleButtonVirtualDom(replaceExpanded, 'handleClickToggleReplace'));
10003
10017
  dom.push({
10004
10018
  type: Div,
10005
10019
  className: FindWidgetRight,
10006
10020
  childCount: replaceExpanded ? 2 : 1
10007
10021
  });
10008
- dom.push(...getFindWidgetFindVirtualDom(matchCountText, buttons));
10022
+ dom.push(...getFindWidgetFindVirtualDom(matchCountText, findButtons));
10009
10023
  if (replaceExpanded) {
10010
- dom.push(...getFindWidgetReplaceVirtualDom(replaceExpanded));
10024
+ dom.push(...getFindWidgetReplaceVirtualDom(replaceExpanded, replaceButtons));
10011
10025
  }
10012
10026
  return dom;
10013
10027
  };
@@ -10022,6 +10036,8 @@ const getMatchCountText = (matchIndex, matchCount) => {
10022
10036
  const ArrowDown = 'ArrowDown';
10023
10037
  const ArrowUp = 'ArrowUp';
10024
10038
  const Close = 'Close';
10039
+ const Replace = 'Replace';
10040
+ const ReplaceAll = 'ReplaceAll';
10025
10041
 
10026
10042
  const renderValue = {
10027
10043
  isEqual(oldState, newState) {
@@ -10038,20 +10054,34 @@ const renderDetails = {
10038
10054
  apply(oldState, newState) {
10039
10055
  const matchCountText = getMatchCountText(newState.matchIndex, newState.matchCount);
10040
10056
  const buttonsEnabled = newState.matchCount > 0;
10041
- const buttons = [{
10057
+ const findButtons = [{
10042
10058
  label: previousMatch(),
10043
10059
  icon: ArrowUp,
10044
- disabled: !buttonsEnabled
10060
+ disabled: !buttonsEnabled,
10061
+ onClick: 'handleClickPreviousMatch'
10045
10062
  }, {
10046
10063
  label: nextMatch(),
10047
10064
  icon: ArrowDown,
10048
- disabled: !buttonsEnabled
10065
+ disabled: !buttonsEnabled,
10066
+ onClick: 'handleClickNextMatch'
10049
10067
  }, {
10050
10068
  label: close(),
10051
10069
  icon: Close,
10052
- disabled: false
10070
+ disabled: false,
10071
+ onClick: 'handleClickClose'
10072
+ }];
10073
+ const replaceButtons = [{
10074
+ label: replace(),
10075
+ icon: Replace,
10076
+ disabled: !buttonsEnabled,
10077
+ onClick: 'handleClickReplace'
10078
+ }, {
10079
+ label: replaceAll(),
10080
+ icon: ReplaceAll,
10081
+ disabled: !buttonsEnabled,
10082
+ onClick: 'handleClickReplaceAll'
10053
10083
  }];
10054
- const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, buttons);
10084
+ const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons);
10055
10085
  return ['Viewlet.setDom2', dom];
10056
10086
  }
10057
10087
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",