@lvce-editor/editor-worker 4.7.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.
@@ -7881,6 +7881,7 @@ const Diagnostic = 'Diagnostic';
7881
7881
  const FindWidgetReplace = 'FindWidgetReplace';
7882
7882
  const FindWidgetFind = 'FindWidgetFind';
7883
7883
  const FindWidgetMatchCount = 'FindWidgetMatchCount';
7884
+ const FindWidgetMatchCountEmpty = 'FindWidgetMatchCountEmpty';
7884
7885
  const FindWidgetRight = 'FindWidgetRight';
7885
7886
  const EditorCompletionItem = 'EditorCompletionItem';
7886
7887
  const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
@@ -7949,6 +7950,15 @@ const HandleSashPointerDown = 'handleSashPointerDown';
7949
7950
  const HandleClose = 'handleClose';
7950
7951
  const HandleFocusIn = 'handleFocusIn';
7951
7952
  const HandleClick = 'handleClick';
7953
+ const HandleInput = 'handleInput';
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';
7952
7962
 
7953
7963
  const hoverProblemMessage = {
7954
7964
  type: Span,
@@ -10557,37 +10567,37 @@ const FocusNext = 'FocusNext';
10557
10567
  const FocusPrevious = 'FocusPrevious';
10558
10568
  const Replace = 'Replace';
10559
10569
 
10560
- const getFindWidgetButtons = buttonsEnabled => {
10570
+ const getFindWidgetButtons = (findButtonsEnabled, replaceButtonsEnabled) => {
10561
10571
  const findButtons = [{
10562
10572
  label: previousMatch(),
10563
10573
  icon: ArrowUp,
10564
- disabled: !buttonsEnabled,
10565
- onClick: 'handleClickPreviousMatch',
10574
+ disabled: !findButtonsEnabled,
10575
+ onClick: HandleClickPreviousMatch,
10566
10576
  name: FocusPrevious
10567
10577
  }, {
10568
10578
  label: nextMatch(),
10569
10579
  icon: ArrowDown,
10570
- disabled: !buttonsEnabled,
10571
- onClick: 'handleClickNextMatch',
10580
+ disabled: !findButtonsEnabled,
10581
+ onClick: HandleClickNextMatch,
10572
10582
  name: FocusNext
10573
10583
  }, {
10574
10584
  label: close(),
10575
10585
  icon: Close$1,
10576
10586
  disabled: false,
10577
- onClick: 'handleClickClose',
10587
+ onClick: HandleClickClose,
10578
10588
  name: Close
10579
10589
  }];
10580
10590
  const replaceButtons = [{
10581
10591
  label: replace(),
10582
10592
  icon: Replace$1,
10583
- disabled: !buttonsEnabled,
10584
- onClick: 'handleClickReplace',
10593
+ disabled: !replaceButtonsEnabled,
10594
+ onClick: HandleClickReplace,
10585
10595
  name: Replace
10586
10596
  }, {
10587
10597
  label: replaceAll(),
10588
10598
  icon: ReplaceAll$1,
10589
- disabled: !buttonsEnabled,
10590
- onClick: 'handleClickReplaceAll',
10599
+ disabled: !replaceButtonsEnabled,
10600
+ onClick: HandleClickReplaceAll,
10591
10601
  name: ReplaceAll
10592
10602
  }];
10593
10603
  return {
@@ -10596,6 +10606,15 @@ const getFindWidgetButtons = buttonsEnabled => {
10596
10606
  };
10597
10607
  };
10598
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
+
10599
10618
  // TODO always focus element by name
10600
10619
  const getFindWidgetFocusSelector = focus => {
10601
10620
  switch (focus) {
@@ -10620,6 +10639,13 @@ const getFindWidgetFocusSelector = focus => {
10620
10639
  }
10621
10640
  };
10622
10641
 
10642
+ const getFindMatchCountClassName = (matchCount, value) => {
10643
+ if (value && matchCount === 0) {
10644
+ return mergeClassNames(FindWidgetMatchCount, FindWidgetMatchCountEmpty);
10645
+ }
10646
+ return FindWidgetMatchCount;
10647
+ };
10648
+
10623
10649
  const getIconVirtualDom = (icon, type = Div) => {
10624
10650
  return {
10625
10651
  type,
@@ -10702,17 +10728,18 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
10702
10728
  return dom;
10703
10729
  };
10704
10730
 
10705
- const getFindWidgetFindVirtualDom = (matchCountText, buttons) => {
10731
+ const getFindWidgetFindVirtualDom = (matchCountText, buttons, matchCount, value) => {
10706
10732
  const dom = [];
10707
10733
  dom.push({
10708
10734
  type: Div,
10709
10735
  className: FindWidgetFind,
10710
10736
  childCount: 5
10711
10737
  });
10712
- dom.push(...getSearchFieldVirtualDom('search-value', find(), 'handleInput', [], [], 'handleFocus'));
10738
+ dom.push(...getSearchFieldVirtualDom('search-value', find(), HandleInput, [], [], HandleFocus));
10739
+ const findClassName = getFindMatchCountClassName(matchCount, value);
10713
10740
  dom.push({
10714
10741
  type: Div,
10715
- className: FindWidgetMatchCount,
10742
+ className: findClassName,
10716
10743
  childCount: 1
10717
10744
  }, text(matchCountText), ...buttons.flatMap(getIconButtonVirtualDom));
10718
10745
  return dom;
@@ -10725,7 +10752,7 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons) => {
10725
10752
  type: Div,
10726
10753
  className: FindWidgetReplace,
10727
10754
  childCount: 1 + replaceButtons.length
10728
- }, ...getSearchFieldVirtualDom('replace-value', replace(), 'handleReplaceInput', [], [], 'handleReplaceFocus'), ...replaceButtons.flatMap(getIconButtonVirtualDom));
10755
+ }, ...getSearchFieldVirtualDom('replace-value', replace(), HandleReplaceInput, [], [], HandleReplaceFocus), ...replaceButtons.flatMap(getIconButtonVirtualDom));
10729
10756
  }
10730
10757
  return dom;
10731
10758
  };
@@ -10749,7 +10776,7 @@ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
10749
10776
  }];
10750
10777
  };
10751
10778
 
10752
- const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, replaceButtons, matchCase, matchWholeWord, useRegularExpression) => {
10779
+ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, replaceButtons, matchCase, matchWholeWord, useRegularExpression, matchCount, value) => {
10753
10780
  const dom = [];
10754
10781
  dom.push({
10755
10782
  type: Div,
@@ -10763,7 +10790,7 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, r
10763
10790
  className: FindWidgetRight,
10764
10791
  childCount: replaceExpanded ? 2 : 1
10765
10792
  });
10766
- dom.push(...getFindWidgetFindVirtualDom(matchCountText, findButtons));
10793
+ dom.push(...getFindWidgetFindVirtualDom(matchCountText, findButtons, matchCount, value));
10767
10794
  if (replaceExpanded) {
10768
10795
  dom.push(...getFindWidgetReplaceVirtualDom(replaceExpanded, replaceButtons));
10769
10796
  }
@@ -10787,16 +10814,19 @@ const renderValue = {
10787
10814
  };
10788
10815
  const renderDetails = {
10789
10816
  isEqual(oldState, newState) {
10790
- 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;
10791
10818
  },
10792
10819
  apply(oldState, newState) {
10793
10820
  const matchCountText = getMatchCountText(newState.matchIndex, newState.matchCount);
10794
- const buttonsEnabled = newState.matchCount > 0;
10821
+ const {
10822
+ findButtonsEnabled,
10823
+ replaceButtonsEnabled
10824
+ } = getFindWidgetButtonsEnabled(newState.matchCount, newState.value);
10795
10825
  const {
10796
10826
  findButtons,
10797
10827
  replaceButtons
10798
- } = getFindWidgetButtons(buttonsEnabled);
10799
- const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons);
10828
+ } = getFindWidgetButtons(findButtonsEnabled, replaceButtonsEnabled);
10829
+ const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons, newState.matchCase, newState.matchWholeWord, newState.useRegularExpression, newState.matchCount, newState.value);
10800
10830
  return ['Viewlet.setDom2', dom];
10801
10831
  }
10802
10832
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "4.7.0",
3
+ "version": "4.9.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",