@lvce-editor/editor-worker 4.8.0 → 4.9.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.
@@ -7952,6 +7952,13 @@ const HandleFocusIn = 'handleFocusIn';
7952
7952
  const HandleClick = 'handleClick';
7953
7953
  const HandleInput = 'handleInput';
7954
7954
  const HandleFocus = 'handleFocus';
7955
+ const HandleClickPreviousMatch = 'handleClickPreviousMatch';
7956
+ const HandleClickNextMatch = 'handleClickNextMatch';
7957
+ const HandleClickClose = 'handleClickClose';
7958
+ const HandleClickReplace = 'handleClickReplace';
7959
+ const HandleClickReplaceAll = 'handleClickReplaceAll';
7960
+ const HandleReplaceInput = 'handleReplaceInput';
7961
+ const HandleReplaceFocus = 'handleReplaceFocus';
7955
7962
 
7956
7963
  const hoverProblemMessage = {
7957
7964
  type: Span,
@@ -10560,37 +10567,37 @@ const FocusNext = 'FocusNext';
10560
10567
  const FocusPrevious = 'FocusPrevious';
10561
10568
  const Replace = 'Replace';
10562
10569
 
10563
- const getFindWidgetButtons = buttonsEnabled => {
10570
+ const getFindWidgetButtons = (findButtonsEnabled, replaceButtonsEnabled) => {
10564
10571
  const findButtons = [{
10565
10572
  label: previousMatch(),
10566
10573
  icon: ArrowUp,
10567
- disabled: !buttonsEnabled,
10568
- onClick: 'handleClickPreviousMatch',
10574
+ disabled: !findButtonsEnabled,
10575
+ onClick: HandleClickPreviousMatch,
10569
10576
  name: FocusPrevious
10570
10577
  }, {
10571
10578
  label: nextMatch(),
10572
10579
  icon: ArrowDown,
10573
- disabled: !buttonsEnabled,
10574
- onClick: 'handleClickNextMatch',
10580
+ disabled: !findButtonsEnabled,
10581
+ onClick: HandleClickNextMatch,
10575
10582
  name: FocusNext
10576
10583
  }, {
10577
10584
  label: close(),
10578
10585
  icon: Close$1,
10579
10586
  disabled: false,
10580
- onClick: 'handleClickClose',
10587
+ onClick: HandleClickClose,
10581
10588
  name: Close
10582
10589
  }];
10583
10590
  const replaceButtons = [{
10584
10591
  label: replace(),
10585
10592
  icon: Replace$1,
10586
- disabled: !buttonsEnabled,
10587
- onClick: 'handleClickReplace',
10593
+ disabled: !replaceButtonsEnabled,
10594
+ onClick: HandleClickReplace,
10588
10595
  name: Replace
10589
10596
  }, {
10590
10597
  label: replaceAll(),
10591
10598
  icon: ReplaceAll$1,
10592
- disabled: !buttonsEnabled,
10593
- onClick: 'handleClickReplaceAll',
10599
+ disabled: !replaceButtonsEnabled,
10600
+ onClick: HandleClickReplaceAll,
10594
10601
  name: ReplaceAll
10595
10602
  }];
10596
10603
  return {
@@ -10599,6 +10606,15 @@ const getFindWidgetButtons = buttonsEnabled => {
10599
10606
  };
10600
10607
  };
10601
10608
 
10609
+ const getFindWidgetButtonsEnabled = (matchCount, value) => {
10610
+ const findButtonsEnabled = matchCount > 0;
10611
+ const replaceButtonsEnabled = value.length > 0;
10612
+ return {
10613
+ findButtonsEnabled,
10614
+ replaceButtonsEnabled
10615
+ };
10616
+ };
10617
+
10602
10618
  // TODO always focus element by name
10603
10619
  const getFindWidgetFocusSelector = focus => {
10604
10620
  switch (focus) {
@@ -10623,8 +10639,8 @@ const getFindWidgetFocusSelector = focus => {
10623
10639
  }
10624
10640
  };
10625
10641
 
10626
- const getFindMatchCountClassName = matchCount => {
10627
- if (matchCount === 0) {
10642
+ const getFindMatchCountClassName = (matchCount, value) => {
10643
+ if (value && matchCount === 0) {
10628
10644
  return mergeClassNames(FindWidgetMatchCount, FindWidgetMatchCountEmpty);
10629
10645
  }
10630
10646
  return FindWidgetMatchCount;
@@ -10712,7 +10728,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
10712
10728
  return dom;
10713
10729
  };
10714
10730
 
10715
- const getFindWidgetFindVirtualDom = (matchCountText, buttons, matchCount) => {
10731
+ const getFindWidgetFindVirtualDom = (matchCountText, buttons, matchCount, value) => {
10716
10732
  const dom = [];
10717
10733
  dom.push({
10718
10734
  type: Div,
@@ -10720,7 +10736,7 @@ const getFindWidgetFindVirtualDom = (matchCountText, buttons, matchCount) => {
10720
10736
  childCount: 5
10721
10737
  });
10722
10738
  dom.push(...getSearchFieldVirtualDom('search-value', find(), HandleInput, [], [], HandleFocus));
10723
- const findClassName = getFindMatchCountClassName(matchCount);
10739
+ const findClassName = getFindMatchCountClassName(matchCount, value);
10724
10740
  dom.push({
10725
10741
  type: Div,
10726
10742
  className: findClassName,
@@ -10736,7 +10752,7 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons) => {
10736
10752
  type: Div,
10737
10753
  className: FindWidgetReplace,
10738
10754
  childCount: 1 + replaceButtons.length
10739
- }, ...getSearchFieldVirtualDom('replace-value', replace(), 'handleReplaceInput', [], [], 'handleReplaceFocus'), ...replaceButtons.flatMap(getIconButtonVirtualDom));
10755
+ }, ...getSearchFieldVirtualDom('replace-value', replace(), HandleReplaceInput, [], [], HandleReplaceFocus), ...replaceButtons.flatMap(getIconButtonVirtualDom));
10740
10756
  }
10741
10757
  return dom;
10742
10758
  };
@@ -10760,7 +10776,7 @@ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
10760
10776
  }];
10761
10777
  };
10762
10778
 
10763
- const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, replaceButtons, matchCase, matchWholeWord, useRegularExpression, matchCount) => {
10779
+ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, replaceButtons, matchCase, matchWholeWord, useRegularExpression, matchCount, value) => {
10764
10780
  const dom = [];
10765
10781
  dom.push({
10766
10782
  type: Div,
@@ -10774,7 +10790,7 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, r
10774
10790
  className: FindWidgetRight,
10775
10791
  childCount: replaceExpanded ? 2 : 1
10776
10792
  });
10777
- dom.push(...getFindWidgetFindVirtualDom(matchCountText, findButtons, matchCount));
10793
+ dom.push(...getFindWidgetFindVirtualDom(matchCountText, findButtons, matchCount, value));
10778
10794
  if (replaceExpanded) {
10779
10795
  dom.push(...getFindWidgetReplaceVirtualDom(replaceExpanded, replaceButtons));
10780
10796
  }
@@ -10798,16 +10814,19 @@ const renderValue = {
10798
10814
  };
10799
10815
  const renderDetails = {
10800
10816
  isEqual(oldState, newState) {
10801
- return oldState.matchIndex === newState.matchIndex && oldState.matchCount === newState.matchCount && oldState.replaceExpanded === newState.replaceExpanded;
10817
+ return oldState.matchIndex === newState.matchIndex && oldState.matchCount === newState.matchCount && oldState.replaceExpanded === newState.replaceExpanded && oldState.value === newState.value;
10802
10818
  },
10803
10819
  apply(oldState, newState) {
10804
10820
  const matchCountText = getMatchCountText(newState.matchIndex, newState.matchCount);
10805
- const buttonsEnabled = newState.matchCount > 0;
10821
+ const {
10822
+ findButtonsEnabled,
10823
+ replaceButtonsEnabled
10824
+ } = getFindWidgetButtonsEnabled(newState.matchCount, newState.value);
10806
10825
  const {
10807
10826
  findButtons,
10808
10827
  replaceButtons
10809
- } = getFindWidgetButtons(buttonsEnabled);
10810
- const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons, newState.matchCase, newState.matchWholeWord, newState.useRegularExpression, newState.matchCount);
10828
+ } = getFindWidgetButtons(findButtonsEnabled, replaceButtonsEnabled);
10829
+ const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons, newState.matchCase, newState.matchWholeWord, newState.useRegularExpression, newState.matchCount, newState.value);
10811
10830
  return ['Viewlet.setDom2', dom];
10812
10831
  }
10813
10832
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "4.8.0",
3
+ "version": "4.9.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",