@univerjs/find-replace 1.0.0-alpha.7 → 1.0.0-beta.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.
Files changed (84) hide show
  1. package/lib/cjs/index.js +95 -41
  2. package/lib/cjs/locale/ar-SA.js +2 -1
  3. package/lib/cjs/locale/ca-ES.js +2 -1
  4. package/lib/cjs/locale/de-DE.js +2 -1
  5. package/lib/cjs/locale/en-US.js +2 -1
  6. package/lib/cjs/locale/es-ES.js +2 -1
  7. package/lib/cjs/locale/fa-IR.js +2 -1
  8. package/lib/cjs/locale/fr-FR.js +2 -1
  9. package/lib/cjs/locale/id-ID.js +2 -1
  10. package/lib/cjs/locale/it-IT.js +2 -1
  11. package/lib/cjs/locale/ja-JP.js +2 -1
  12. package/lib/cjs/locale/ko-KR.js +2 -1
  13. package/lib/cjs/locale/pl-PL.js +2 -1
  14. package/lib/cjs/locale/pt-BR.js +2 -1
  15. package/lib/cjs/locale/ru-RU.js +2 -1
  16. package/lib/cjs/locale/sk-SK.js +2 -1
  17. package/lib/cjs/locale/vi-VN.js +2 -1
  18. package/lib/cjs/locale/zh-CN.js +1 -0
  19. package/lib/cjs/locale/zh-HK.js +2 -1
  20. package/lib/cjs/locale/zh-TW.js +2 -1
  21. package/lib/es/index.js +95 -41
  22. package/lib/es/locale/ar-SA.js +2 -1
  23. package/lib/es/locale/ca-ES.js +2 -1
  24. package/lib/es/locale/de-DE.js +2 -1
  25. package/lib/es/locale/en-US.js +2 -1
  26. package/lib/es/locale/es-ES.js +2 -1
  27. package/lib/es/locale/fa-IR.js +2 -1
  28. package/lib/es/locale/fr-FR.js +2 -1
  29. package/lib/es/locale/id-ID.js +2 -1
  30. package/lib/es/locale/it-IT.js +2 -1
  31. package/lib/es/locale/ja-JP.js +2 -1
  32. package/lib/es/locale/ko-KR.js +2 -1
  33. package/lib/es/locale/pl-PL.js +2 -1
  34. package/lib/es/locale/pt-BR.js +2 -1
  35. package/lib/es/locale/ru-RU.js +2 -1
  36. package/lib/es/locale/sk-SK.js +2 -1
  37. package/lib/es/locale/vi-VN.js +2 -1
  38. package/lib/es/locale/zh-CN.js +1 -0
  39. package/lib/es/locale/zh-HK.js +2 -1
  40. package/lib/es/locale/zh-TW.js +2 -1
  41. package/lib/index.js +95 -41
  42. package/lib/locale/ar-SA.js +2 -1
  43. package/lib/locale/ca-ES.js +2 -1
  44. package/lib/locale/de-DE.js +2 -1
  45. package/lib/locale/en-US.js +2 -1
  46. package/lib/locale/es-ES.js +2 -1
  47. package/lib/locale/fa-IR.js +2 -1
  48. package/lib/locale/fr-FR.js +2 -1
  49. package/lib/locale/id-ID.js +2 -1
  50. package/lib/locale/it-IT.js +2 -1
  51. package/lib/locale/ja-JP.js +2 -1
  52. package/lib/locale/ko-KR.js +2 -1
  53. package/lib/locale/pl-PL.js +2 -1
  54. package/lib/locale/pt-BR.js +2 -1
  55. package/lib/locale/ru-RU.js +2 -1
  56. package/lib/locale/sk-SK.js +2 -1
  57. package/lib/locale/vi-VN.js +2 -1
  58. package/lib/locale/zh-CN.js +1 -0
  59. package/lib/locale/zh-HK.js +2 -1
  60. package/lib/locale/zh-TW.js +2 -1
  61. package/lib/types/locale/en-US.d.ts +1 -0
  62. package/lib/types/services/context-keys.d.ts +2 -0
  63. package/lib/types/services/find-replace.service.d.ts +24 -3
  64. package/lib/umd/index.js +1 -1
  65. package/lib/umd/locale/ar-SA.js +1 -1
  66. package/lib/umd/locale/ca-ES.js +1 -1
  67. package/lib/umd/locale/de-DE.js +1 -1
  68. package/lib/umd/locale/en-US.js +1 -1
  69. package/lib/umd/locale/es-ES.js +1 -1
  70. package/lib/umd/locale/fa-IR.js +1 -1
  71. package/lib/umd/locale/fr-FR.js +1 -1
  72. package/lib/umd/locale/id-ID.js +1 -1
  73. package/lib/umd/locale/it-IT.js +1 -1
  74. package/lib/umd/locale/ja-JP.js +1 -1
  75. package/lib/umd/locale/ko-KR.js +1 -1
  76. package/lib/umd/locale/pl-PL.js +1 -1
  77. package/lib/umd/locale/pt-BR.js +1 -1
  78. package/lib/umd/locale/ru-RU.js +1 -1
  79. package/lib/umd/locale/sk-SK.js +1 -1
  80. package/lib/umd/locale/vi-VN.js +1 -1
  81. package/lib/umd/locale/zh-CN.js +1 -1
  82. package/lib/umd/locale/zh-HK.js +1 -1
  83. package/lib/umd/locale/zh-TW.js +1 -1
  84. package/package.json +8 -8
package/lib/cjs/index.js CHANGED
@@ -33,9 +33,11 @@ const FIND_REPLACE_DIALOG_FOCUS = "FIND_REPLACE_DIALOG_FOCUS";
33
33
  * If the find replace feature is activated and the replace is revealed.
34
34
  */
35
35
  const FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
36
+ /** If the focused unit has a find-replace provider. */
37
+ const FIND_REPLACE_AVAILABLE = "FIND_REPLACE_AVAILABLE";
36
38
 
37
39
  //#endregion
38
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
40
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
39
41
  function _typeof(o) {
40
42
  "@babel/helpers - typeof";
41
43
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -46,7 +48,7 @@ function _typeof(o) {
46
48
  }
47
49
 
48
50
  //#endregion
49
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
51
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
50
52
  function toPrimitive(t, r) {
51
53
  if ("object" != _typeof(t) || !t) return t;
52
54
  var e = t[Symbol.toPrimitive];
@@ -59,14 +61,14 @@ function toPrimitive(t, r) {
59
61
  }
60
62
 
61
63
  //#endregion
62
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
64
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
63
65
  function toPropertyKey(t) {
64
66
  var i = toPrimitive(t, "string");
65
67
  return "symbol" == _typeof(i) ? i : i + "";
66
68
  }
67
69
 
68
70
  //#endregion
69
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
71
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
70
72
  function _defineProperty(e, r, t) {
71
73
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
72
74
  value: t,
@@ -77,7 +79,7 @@ function _defineProperty(e, r, t) {
77
79
  }
78
80
 
79
81
  //#endregion
80
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
82
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
81
83
  function __decorateParam(paramIndex, decorator) {
82
84
  return function(target, key) {
83
85
  decorator(target, key, paramIndex);
@@ -85,7 +87,7 @@ function __decorateParam(paramIndex, decorator) {
85
87
  }
86
88
 
87
89
  //#endregion
88
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
90
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
89
91
  function __decorate(decorators, target, key, desc) {
90
92
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
91
93
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -106,6 +108,7 @@ function shouldStateUpdateTriggerResearch(statusUpdate) {
106
108
  if (typeof statusUpdate.inputtingFindString !== "undefined") return true;
107
109
  if (typeof statusUpdate.findDirection !== "undefined") return true;
108
110
  if (typeof statusUpdate.matchesTheWholeCell !== "undefined") return true;
111
+ if (typeof statusUpdate.matchesTheWholeWord !== "undefined") return true;
109
112
  if (typeof statusUpdate.caseSensitive !== "undefined") return true;
110
113
  if (typeof statusUpdate.findScope !== "undefined") return true;
111
114
  if (typeof statusUpdate.findBy !== "undefined") return true;
@@ -171,7 +174,8 @@ let FindReplaceModel = class FindReplaceModel extends _univerjs_core.Disposable
171
174
  findBy: this._state.findBy,
172
175
  replaceRevealed: this._state.replaceRevealed,
173
176
  caseSensitive: this._state.caseSensitive,
174
- matchesTheWholeCell: this._state.matchesTheWholeCell
177
+ matchesTheWholeCell: this._state.matchesTheWholeCell,
178
+ matchesTheWholeWord: this._state.matchesTheWholeWord
175
179
  })))).flat();
176
180
  this._subscribeToModelsChanges(findModels);
177
181
  const newMatches = this._matches = findModels.map((c) => c.getMatches()).flat();
@@ -358,6 +362,7 @@ function createInitFindReplaceState() {
358
362
  matchesCount: 0,
359
363
  matchesPosition: 0,
360
364
  matchesTheWholeCell: false,
365
+ matchesTheWholeWord: false,
361
366
  replaceRevealed: false,
362
367
  replaceString: "",
363
368
  revealed: true
@@ -383,6 +388,7 @@ var FindReplaceState = class {
383
388
  _defineProperty(this, "_matchesCount", 0);
384
389
  _defineProperty(this, "_caseSensitive", true);
385
390
  _defineProperty(this, "_matchesTheWholeCell", false);
391
+ _defineProperty(this, "_matchesTheWholeWord", false);
386
392
  _defineProperty(this, "_findDirection", "row");
387
393
  _defineProperty(this, "_findScope", "subunit");
388
394
  _defineProperty(this, "_findBy", "value");
@@ -418,6 +424,9 @@ var FindReplaceState = class {
418
424
  get matchesTheWholeCell() {
419
425
  return this._matchesTheWholeCell;
420
426
  }
427
+ get matchesTheWholeWord() {
428
+ return this._matchesTheWholeWord;
429
+ }
421
430
  get findDirection() {
422
431
  return this._findDirection;
423
432
  }
@@ -488,6 +497,11 @@ var FindReplaceState = class {
488
497
  changedState.matchesTheWholeCell = changes.matchesTheWholeCell;
489
498
  changed = true;
490
499
  }
500
+ if (typeof changes.matchesTheWholeWord !== "undefined" && changes.matchesTheWholeWord !== this._matchesTheWholeWord) {
501
+ this._matchesTheWholeWord = changes.matchesTheWholeWord;
502
+ changedState.matchesTheWholeWord = changes.matchesTheWholeWord;
503
+ changed = true;
504
+ }
491
505
  if (typeof changes.inputtingFindString !== "undefined" && changes.inputtingFindString !== this._inputtingFindString) {
492
506
  this._inputtingFindString = changes.inputtingFindString;
493
507
  changedState.inputtingFindString = changes.inputtingFindString;
@@ -510,6 +524,7 @@ var FindReplaceState = class {
510
524
  matchesCount: this._matchesCount,
511
525
  matchesPosition: this._matchesPosition,
512
526
  matchesTheWholeCell: this._matchesTheWholeCell,
527
+ matchesTheWholeWord: this._matchesTheWholeWord,
513
528
  replaceRevealed: this._replaceRevealed,
514
529
  revealed: this._revealed
515
530
  });
@@ -530,10 +545,11 @@ let FindReplaceService = class FindReplaceService extends _univerjs_core.Disposa
530
545
  get replaceRevealed() {
531
546
  return this._state.replaceRevealed;
532
547
  }
533
- constructor(_injector, _contextService) {
548
+ constructor(_injector, _contextService, _univerInstanceService) {
534
549
  super();
535
550
  this._injector = _injector;
536
551
  this._contextService = _contextService;
552
+ this._univerInstanceService = _univerInstanceService;
537
553
  _defineProperty(this, "_providers", /* @__PURE__ */ new Set());
538
554
  _defineProperty(this, "_state", new FindReplaceState());
539
555
  _defineProperty(this, "_model", void 0);
@@ -544,6 +560,10 @@ let FindReplaceService = class FindReplaceService extends _univerjs_core.Disposa
544
560
  _defineProperty(this, "replaceables$", this._replaceables$.asObservable());
545
561
  _defineProperty(this, "_focusSignal$", new rxjs.Subject());
546
562
  _defineProperty(this, "focusSignal$", this._focusSignal$.asObservable());
563
+ _defineProperty(this, "_providerCapabilities$", new rxjs.BehaviorSubject(null));
564
+ _defineProperty(this, "providerCapabilities$", this._providerCapabilities$.asObservable());
565
+ _defineProperty(this, "_activeProvider", null);
566
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(this._univerInstanceService.focused$.subscribe(() => this._syncActiveProvider())));
547
567
  }
548
568
  dispose() {
549
569
  super.dispose();
@@ -552,6 +572,7 @@ let FindReplaceService = class FindReplaceService extends _univerjs_core.Disposa
552
572
  this._replaceables$.next([]);
553
573
  this._replaceables$.complete();
554
574
  this._focusSignal$.complete();
575
+ this._providerCapabilities$.complete();
555
576
  }
556
577
  getProviders() {
557
578
  return this._providers;
@@ -582,6 +603,9 @@ let FindReplaceService = class FindReplaceService extends _univerjs_core.Disposa
582
603
  changeMatchesTheWholeCell(matchesTheWholeCell) {
583
604
  this._state.changeState({ matchesTheWholeCell });
584
605
  }
606
+ changeMatchesTheWholeWord(matchesTheWholeWord) {
607
+ this._state.changeState({ matchesTheWholeWord });
608
+ }
585
609
  changeCaseSensitive(caseSensitive) {
586
610
  this._state.changeState({ caseSensitive });
587
611
  }
@@ -631,8 +655,8 @@ let FindReplaceService = class FindReplaceService extends _univerjs_core.Disposa
631
655
  (_this$_model2 = this._model) === null || _this$_model2 === void 0 || _this$_model2.focusSelection();
632
656
  }
633
657
  start(revealReplace = false) {
634
- if (this._providers.size === 0) return false;
635
- this._model = this._injector.createInstance(FindReplaceModel, this._state, this._providers);
658
+ if (!this._activeProvider) return false;
659
+ this._model = this._injector.createInstance(FindReplaceModel, this._state, /* @__PURE__ */ new Set([this._activeProvider]));
636
660
  this._modelDisposables = new _univerjs_core.DisposableCollection();
637
661
  this._modelDisposables.add((0, _univerjs_core.toDisposable)(this._model.currentMatch$.subscribe((match) => this._currentMatch$.next(match))));
638
662
  this._modelDisposables.add((0, _univerjs_core.toDisposable)(this._model.replaceables$.subscribe((replaceables) => this._replaceables$.next(replaceables))));
@@ -657,7 +681,20 @@ let FindReplaceService = class FindReplaceService extends _univerjs_core.Disposa
657
681
  }
658
682
  registerFindReplaceProvider(provider) {
659
683
  this._providers.add(provider);
660
- return (0, _univerjs_core.toDisposable)(() => this._providers.delete(provider));
684
+ this._syncActiveProvider();
685
+ return (0, _univerjs_core.toDisposable)(() => {
686
+ this._providers.delete(provider);
687
+ this._syncActiveProvider();
688
+ });
689
+ }
690
+ _syncActiveProvider() {
691
+ const unit = this._univerInstanceService.getFocusedUnit();
692
+ const provider = unit == null ? null : Array.from(this._providers).find((candidate) => candidate.isSupported(unit)) ?? null;
693
+ if (provider === this._activeProvider) return;
694
+ if (this.revealed) this.terminate();
695
+ this._activeProvider = provider;
696
+ this._providerCapabilities$.next((provider === null || provider === void 0 ? void 0 : provider.capabilities) ?? null);
697
+ this._contextService.setContextValue(FIND_REPLACE_AVAILABLE, provider != null);
661
698
  }
662
699
  _toggleRevealReplace(revealReplace) {
663
700
  this._contextService.setContextValue(FIND_REPLACE_REPLACE_REVEALED, revealReplace);
@@ -666,7 +703,11 @@ let FindReplaceService = class FindReplaceService extends _univerjs_core.Disposa
666
703
  this._contextService.setContextValue(_univerjs_engine_render.RENDER_RAW_FORMULA_KEY, force);
667
704
  }
668
705
  };
669
- FindReplaceService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, _univerjs_core.IContextService)], FindReplaceService);
706
+ FindReplaceService = __decorate([
707
+ __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
708
+ __decorateParam(1, _univerjs_core.IContextService),
709
+ __decorateParam(2, _univerjs_core.IUniverInstanceService)
710
+ ], FindReplaceService);
670
711
 
671
712
  //#endregion
672
713
  //#region src/commands/commands/replace.command.ts
@@ -796,8 +837,8 @@ function whenFindReplaceInputFocused(contextService) {
796
837
  return contextService.getContextValue(FIND_REPLACE_INPUT_FOCUS);
797
838
  }
798
839
  const FIND_REPLACE_SHORTCUT_GROUP = "7_find-replace-shortcuts";
799
- function whenSheetFocused(contextService) {
800
- return contextService.getContextValue(_univerjs_core.FOCUSING_SHEET);
840
+ function whenFindReplaceAvailable(contextService) {
841
+ return contextService.getContextValue(FIND_REPLACE_AVAILABLE);
801
842
  }
802
843
  function whenEditorNotActivated(contextService) {
803
844
  return !contextService.getContextValue(_univerjs_core.EDITOR_ACTIVATED);
@@ -809,7 +850,7 @@ const OpenFindDialogShortcutItem = {
809
850
  group: FIND_REPLACE_SHORTCUT_GROUP,
810
851
  groupTitle: "find-replace.shortcut.panel",
811
852
  preconditions(contextService) {
812
- return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
853
+ return !whenFindReplaceDialogFocused(contextService) && whenFindReplaceAvailable(contextService) && whenEditorNotActivated(contextService);
813
854
  }
814
855
  };
815
856
  const MacOpenFindDialogShortcutItem = {
@@ -818,7 +859,7 @@ const MacOpenFindDialogShortcutItem = {
818
859
  binding: _univerjs_ui.KeyCode.F | _univerjs_ui.MetaKeys.CTRL_COMMAND,
819
860
  mac: _univerjs_ui.KeyCode.F | _univerjs_ui.MetaKeys.MAC_CTRL,
820
861
  preconditions(contextService) {
821
- return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
862
+ return !whenFindReplaceDialogFocused(contextService) && whenFindReplaceAvailable(contextService) && whenEditorNotActivated(contextService);
822
863
  }
823
864
  };
824
865
  const OpenReplaceDialogShortcutItem = {
@@ -829,7 +870,7 @@ const OpenReplaceDialogShortcutItem = {
829
870
  group: FIND_REPLACE_SHORTCUT_GROUP,
830
871
  groupTitle: "find-replace.shortcut.panel",
831
872
  preconditions(contextService) {
832
- return whenSheetFocused(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
873
+ return whenFindReplaceAvailable(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
833
874
  }
834
875
  };
835
876
  const GoToNextFindMatchShortcutItem = {
@@ -924,13 +965,14 @@ let FindReplaceController = class FindReplaceController extends _univerjs_core.R
924
965
  });
925
966
  }
926
967
  _openPanel() {
968
+ var _this$_univerInstance;
969
+ const sessionUnitId = (_this$_univerInstance = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
927
970
  this._dialogService.open({
928
971
  id: FIND_REPLACE_DIALOG_ID,
929
972
  draggable: true,
930
973
  width: FIND_REPLACE_PANEL_WIDTH,
931
974
  title: { title: this._localeService.t("find-replace.dialog.title") },
932
975
  children: { label: "FindReplaceDialog" },
933
- destroyOnClose: true,
934
976
  mask: false,
935
977
  maskClosable: false,
936
978
  defaultPosition: getFindReplaceDialogDefaultPosition(),
@@ -938,7 +980,7 @@ let FindReplaceController = class FindReplaceController extends _univerjs_core.R
938
980
  onClose: () => this.closePanel()
939
981
  });
940
982
  this._closingListenerDisposable = (0, _univerjs_core.toDisposable)(this._univerInstanceService.focused$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((focused) => {
941
- if (!focused || !this._univerInstanceService.getUniverSheetInstance(focused)) this.closePanel();
983
+ if (!focused || focused !== sessionUnitId) this.closePanel();
942
984
  }));
943
985
  }
944
986
  closePanel() {
@@ -971,7 +1013,7 @@ function getFindReplaceDialogDefaultPosition() {
971
1013
  //#endregion
972
1014
  //#region package.json
973
1015
  var name = "@univerjs/find-replace";
974
- var version = "1.0.0-alpha.7";
1016
+ var version = "1.0.0-beta.0";
975
1017
 
976
1018
  //#endregion
977
1019
  //#region src/config/config.ts
@@ -1096,7 +1138,8 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
1096
1138
  const messageService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMessageService);
1097
1139
  const currentMatch = (0, _univerjs_ui.useObservable)(findReplaceService.currentMatch$, void 0, true);
1098
1140
  const replaceables = (0, _univerjs_ui.useObservable)(findReplaceService.replaceables$, void 0, true);
1099
- const { matchesCount, matchesPosition, findString, inputtingFindString, replaceString, caseSensitive, matchesTheWholeCell, findDirection, findScope, findBy, findCompleted } = (0, _univerjs_ui.useObservable)(findReplaceService.state$, void 0, true);
1141
+ const capabilities = (0, _univerjs_ui.useObservable)(findReplaceService.providerCapabilities$, null, true);
1142
+ const { matchesCount, matchesPosition, findString, inputtingFindString, replaceString, caseSensitive, matchesTheWholeCell, matchesTheWholeWord, findDirection, findScope, findBy, findCompleted } = (0, _univerjs_ui.useObservable)(findReplaceService.state$, void 0, true);
1100
1143
  const findDisabled = inputtingFindString.length === 0;
1101
1144
  const replaceDisabled = matchesCount === 0 || !(currentMatch === null || currentMatch === void 0 ? void 0 : currentMatch.replaceable);
1102
1145
  const replaceAllDisabled = replaceables.length === 0;
@@ -1118,7 +1161,7 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
1118
1161
  const onClickReplaceAllButton = (0, react.useCallback)(async () => {
1119
1162
  await commandService.executeCommand(ReplaceAllMatchesCommand.id);
1120
1163
  focus();
1121
- }, [commandService]);
1164
+ }, [commandService, focus]);
1122
1165
  const onChangeFindDirection = (0, react.useCallback)((findDirection) => {
1123
1166
  findReplaceService.changeFindDirection(findDirection);
1124
1167
  }, [findReplaceService]);
@@ -1173,7 +1216,7 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
1173
1216
  onChange: (value) => onReplaceStringChange(value)
1174
1217
  })
1175
1218
  }),
1176
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1219
+ (capabilities === null || capabilities === void 0 ? void 0 : capabilities.findDirection) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1177
1220
  label: localeService.t("find-replace.dialog.find-direction.title"),
1178
1221
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
1179
1222
  value: findDirection,
@@ -1181,14 +1224,14 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
1181
1224
  onChange: onChangeFindDirection
1182
1225
  })
1183
1226
  }),
1184
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormDualColumnLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1227
+ ((capabilities === null || capabilities === void 0 ? void 0 : capabilities.findScope) || (capabilities === null || capabilities === void 0 ? void 0 : capabilities.findBy)) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormDualColumnLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [capabilities.findScope && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1185
1228
  label: localeService.t("find-replace.dialog.find-scope.title"),
1186
1229
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
1187
1230
  value: findScope,
1188
1231
  options: findScopeOptions,
1189
1232
  onChange: onChangeFindScope
1190
1233
  })
1191
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1234
+ }), capabilities.findBy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1192
1235
  label: localeService.t("find-replace.dialog.find-by.title"),
1193
1236
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
1194
1237
  value: findBy,
@@ -1196,19 +1239,29 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
1196
1239
  onChange: onChangeFindBy
1197
1240
  })
1198
1241
  })] }) }),
1199
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormDualColumnLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
1200
- checked: caseSensitive,
1201
- onChange: (checked) => {
1202
- findReplaceService.changeCaseSensitive(checked);
1203
- },
1204
- children: localeService.t("find-replace.dialog.case-sensitive")
1205
- }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
1206
- checked: matchesTheWholeCell,
1207
- onChange: (checked) => {
1208
- findReplaceService.changeMatchesTheWholeCell(checked);
1209
- },
1210
- children: localeService.t("find-replace.dialog.match-the-whole-cell")
1211
- }) })] }) }),
1242
+ ((capabilities === null || capabilities === void 0 ? void 0 : capabilities.caseSensitive) || (capabilities === null || capabilities === void 0 ? void 0 : capabilities.matchesTheWholeCell) || (capabilities === null || capabilities === void 0 ? void 0 : capabilities.matchesTheWholeWord)) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormDualColumnLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1243
+ capabilities.caseSensitive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
1244
+ checked: caseSensitive,
1245
+ onChange: (checked) => {
1246
+ findReplaceService.changeCaseSensitive(checked);
1247
+ if (findCompleted) findReplaceService.find();
1248
+ },
1249
+ children: localeService.t("find-replace.dialog.case-sensitive")
1250
+ }) }),
1251
+ capabilities.matchesTheWholeCell && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
1252
+ checked: matchesTheWholeCell,
1253
+ onChange: (checked) => findReplaceService.changeMatchesTheWholeCell(checked),
1254
+ children: localeService.t("find-replace.dialog.match-the-whole-cell")
1255
+ }) }),
1256
+ capabilities.matchesTheWholeWord && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
1257
+ checked: matchesTheWholeWord,
1258
+ onChange: (checked) => {
1259
+ findReplaceService.changeMatchesTheWholeWord(checked);
1260
+ if (findCompleted) findReplaceService.find();
1261
+ },
1262
+ children: localeService.t("find-replace.dialog.match-the-whole-word")
1263
+ }) })
1264
+ ] }) }),
1212
1265
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1213
1266
  className: "univer-mt-6 univer-flex univer-justify-between",
1214
1267
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
@@ -1238,9 +1291,10 @@ function FindReplaceDialog() {
1238
1291
  const state = (0, _univerjs_ui.useObservable)(findReplaceService.state$, void 0, true);
1239
1292
  const dialogContainerRef = (0, react.useRef)(null);
1240
1293
  (0, react.useEffect)(() => {
1241
- let disposable;
1242
- if (dialogContainerRef.current) disposable = layoutService.registerContainerElement(dialogContainerRef.current);
1243
- return () => disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
1294
+ const container = dialogContainerRef.current;
1295
+ if (!container) return;
1296
+ const disposable = layoutService.registerContainerElement(container);
1297
+ return () => disposable.dispose();
1244
1298
  }, [layoutService]);
1245
1299
  const focusRef = (0, react.useRef)(null);
1246
1300
  const setDialogContainerFocus = (0, react.useCallback)((focused) => contextService.setContextValue(FIND_REPLACE_DIALOG_FOCUS, focused), [contextService]);
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "استبدال",
18
18
  "replace-all": "استبدال الكل",
19
19
  "case-sensitive": "حساس لحالة الأحرف",
20
- "find-placeholder": "البحث في هذه الورقة",
20
+ "find-placeholder": "البحث",
21
21
  "advanced-finding": "بحث واستبدال متقدم",
22
22
  "replace-placeholder": "أدخل نص الاستبدال",
23
23
  "match-the-whole-cell": "تطابق الخلية بأكملها",
24
+ "match-the-whole-word": "مطابقة الكلمة بالكامل",
24
25
  "find-direction": {
25
26
  title: "اتجاه البحث",
26
27
  row: "البحث حسب الصف",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Reemplaça",
18
18
  "replace-all": "Reemplaça-ho tot",
19
19
  "case-sensitive": "Distingeix majúscules de minúscules",
20
- "find-placeholder": "Cerca en aquest full",
20
+ "find-placeholder": "Cerca",
21
21
  "advanced-finding": "Cerca i reemplaçament avançats",
22
22
  "replace-placeholder": "Introduïu la cadena de reemplaçament",
23
23
  "match-the-whole-cell": "Coincidir amb la cel·la sencera",
24
+ "match-the-whole-word": "Coincideix amb la paraula sencera",
24
25
  "find-direction": {
25
26
  title: "Direcció de la cerca",
26
27
  row: "Cerca per fila",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Ersetzen",
18
18
  "replace-all": "Alle ersetzen",
19
19
  "case-sensitive": "Groß-/Kleinschreibung beachten",
20
- "find-placeholder": "In diesem Blatt suchen",
20
+ "find-placeholder": "Suchen",
21
21
  "advanced-finding": "Erweitertes Suchen & Ersetzen",
22
22
  "replace-placeholder": "Ersetzungstext eingeben",
23
23
  "match-the-whole-cell": "Ganze Zelle vergleichen",
24
+ "match-the-whole-word": "Nur ganzes Wort",
24
25
  "find-direction": {
25
26
  title: "Suchrichtung",
26
27
  row: "Nach Zeile suchen",
@@ -32,10 +32,11 @@ const locale = { "find-replace": {
32
32
  replace: "Replace",
33
33
  "replace-all": "Replace All",
34
34
  "case-sensitive": "Case Sensitive",
35
- "find-placeholder": "Find in this Sheet",
35
+ "find-placeholder": "Find",
36
36
  "advanced-finding": "Advanced Searching & Replace",
37
37
  "replace-placeholder": "Input Replace String",
38
38
  "match-the-whole-cell": "Match the Whole Cell",
39
+ "match-the-whole-word": "Match Whole Word",
39
40
  "find-direction": {
40
41
  title: "Find Direction",
41
42
  row: "Search by Row",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Reemplazar",
18
18
  "replace-all": "Reemplazar todo",
19
19
  "case-sensitive": "Distinguir mayúsculas y minúsculas",
20
- "find-placeholder": "Buscar en esta hoja",
20
+ "find-placeholder": "Buscar",
21
21
  "advanced-finding": "Búsqueda y reemplazo avanzados",
22
22
  "replace-placeholder": "Introducir cadena de reemplazo",
23
23
  "match-the-whole-cell": "Coincidir con toda la celda",
24
+ "match-the-whole-word": "Coincidir con la palabra completa",
24
25
  "find-direction": {
25
26
  title: "Dirección de búsqueda",
26
27
  row: "Buscar por fila",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "جایگزینی",
18
18
  "replace-all": "جایگزینی همه",
19
19
  "case-sensitive": "حساس به حروف بزرگ و کوچک",
20
- "find-placeholder": "جستجو در این شیت",
20
+ "find-placeholder": "جستجو",
21
21
  "advanced-finding": "جستجو و جایگزینی پیشرفته",
22
22
  "replace-placeholder": "رشته جایگزینی را وارد کنید",
23
23
  "match-the-whole-cell": "تطابق کل سلول",
24
+ "match-the-whole-word": "تطبیق کل کلمه",
24
25
  "find-direction": {
25
26
  title: "جهت جستجو",
26
27
  row: "جستجو بر اساس ردیف",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Remplacer",
18
18
  "replace-all": "Remplacer tout",
19
19
  "case-sensitive": "Sensible à la casse",
20
- "find-placeholder": "Rechercher dans cette feuille",
20
+ "find-placeholder": "Rechercher",
21
21
  "advanced-finding": "Recherche et remplacement avancés",
22
22
  "replace-placeholder": "Saisir la chaîne de remplacement",
23
23
  "match-the-whole-cell": "Correspondance de la cellule entière",
24
+ "match-the-whole-word": "Mot entier",
24
25
  "find-direction": {
25
26
  title: "Direction de la recherche",
26
27
  row: "Rechercher par ligne",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Ganti",
18
18
  "replace-all": "Ganti Semua",
19
19
  "case-sensitive": "Sensitif Huruf",
20
- "find-placeholder": "Cari di Lembar ini",
20
+ "find-placeholder": "Cari",
21
21
  "advanced-finding": "Pencarian & Penggantian Lanjutan",
22
22
  "replace-placeholder": "Masukkan String Pengganti",
23
23
  "match-the-whole-cell": "Cocokkan Seluruh Sel",
24
+ "match-the-whole-word": "Cocokkan seluruh kata",
24
25
  "find-direction": {
25
26
  title: "Arah Cari",
26
27
  row: "Cari per Baris",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Sostituisci",
18
18
  "replace-all": "Sostituisci tutto",
19
19
  "case-sensitive": "Maiuscole/minuscole",
20
- "find-placeholder": "Trova in questo foglio",
20
+ "find-placeholder": "Trova",
21
21
  "advanced-finding": "Ricerca e sostituzione avanzate",
22
22
  "replace-placeholder": "Inserisci stringa di sostituzione",
23
23
  "match-the-whole-cell": "Corrispondenza con l'intera cella",
24
+ "match-the-whole-word": "Trova parola intera",
24
25
  "find-direction": {
25
26
  title: "Direzione ricerca",
26
27
  row: "Cerca per riga",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "置換",
18
18
  "replace-all": "すべて置換",
19
19
  "case-sensitive": "大文字と小文字を区別",
20
- "find-placeholder": "このシート内を検索",
20
+ "find-placeholder": "検索",
21
21
  "advanced-finding": "詳細検索と置換",
22
22
  "replace-placeholder": "置換文字列を入力",
23
23
  "match-the-whole-cell": "セル全体に一致",
24
+ "match-the-whole-word": "単語単位で検索",
24
25
  "find-direction": {
25
26
  title: "検索方向",
26
27
  row: "行ごとに検索",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "바꾸기",
18
18
  "replace-all": "모두 바꾸기",
19
19
  "case-sensitive": "대/소문자 구분",
20
- "find-placeholder": "이 시트에서 찾기",
20
+ "find-placeholder": "찾기",
21
21
  "advanced-finding": "고급 검색 및 바꾸기",
22
22
  "replace-placeholder": "바꿀 문자열 입력",
23
23
  "match-the-whole-cell": "전체 셀 내용 일치",
24
+ "match-the-whole-word": "단어 단위로 일치",
24
25
  "find-direction": {
25
26
  title: "검색 방향",
26
27
  row: "행 기준 검색",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Zamień",
18
18
  "replace-all": "Zamień wszystko",
19
19
  "case-sensitive": "Rozróżniaj wielkość liter",
20
- "find-placeholder": "Znajdź w tym arkuszu",
20
+ "find-placeholder": "Znajdź",
21
21
  "advanced-finding": "Zaawansowane wyszukiwanie i zastępowanie",
22
22
  "replace-placeholder": "Wprowadź ciąg zastępujący",
23
23
  "match-the-whole-cell": "Dopasuj całą komórkę",
24
+ "match-the-whole-word": "Dopasuj całe słowo",
24
25
  "find-direction": {
25
26
  title: "Kierunek wyszukiwania",
26
27
  row: "Szukaj według wierszy",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Substituir",
18
18
  "replace-all": "Substituir Tudo",
19
19
  "case-sensitive": "Diferenciar Maiúsculas/Minúsculas",
20
- "find-placeholder": "Localizar nesta Planilha",
20
+ "find-placeholder": "Localizar",
21
21
  "advanced-finding": "Pesquisa e Substituição Avançadas",
22
22
  "replace-placeholder": "Digite o Texto de Substituição",
23
23
  "match-the-whole-cell": "Corresponder à Célula Inteira",
24
+ "match-the-whole-word": "Corresponder palavra inteira",
24
25
  "find-direction": {
25
26
  title: "Direção da Pesquisa",
26
27
  row: "Pesquisar por Linha",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Заменить",
18
18
  "replace-all": "Заменить все",
19
19
  "case-sensitive": "Учитывать регистр",
20
- "find-placeholder": "Найти на этом листе",
20
+ "find-placeholder": "Найти",
21
21
  "advanced-finding": "Расширенный поиск и замена",
22
22
  "replace-placeholder": "Введите строку для замены",
23
23
  "match-the-whole-cell": "Соответствие всей ячейке",
24
+ "match-the-whole-word": "Только слово целиком",
24
25
  "find-direction": {
25
26
  title: "Направление поиска",
26
27
  row: "Искать по строкам",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Nahradiť",
18
18
  "replace-all": "Nahradiť všetko",
19
19
  "case-sensitive": "Rozlišovať veľké a malé písmená",
20
- "find-placeholder": "Hľadať v tomto hárku",
20
+ "find-placeholder": "Hľadať",
21
21
  "advanced-finding": "Pokročilé hľadanie a nahradenie",
22
22
  "replace-placeholder": "Zadajte reťazec na nahradenie",
23
23
  "match-the-whole-cell": "Zhoda s celou bunkou",
24
+ "match-the-whole-word": "Hľadať iba celé slová",
24
25
  "find-direction": {
25
26
  title: "Smer hľadania",
26
27
  row: "Hľadať podľa riadkov",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "Thay thế",
18
18
  "replace-all": "Thay thế Tất cả",
19
19
  "case-sensitive": "Phân biệt chữ hoa chữ thường",
20
- "find-placeholder": "Tìm trong Trang tính này",
20
+ "find-placeholder": "Tìm",
21
21
  "advanced-finding": "Tìm kiếm & Thay thế Nâng cao",
22
22
  "replace-placeholder": "Nhập chuỗi thay thế",
23
23
  "match-the-whole-cell": "Khớp toàn bộ ô",
24
+ "match-the-whole-word": "Khớp toàn bộ từ",
24
25
  "find-direction": {
25
26
  title: "Hướng tìm kiếm",
26
27
  row: "Tìm theo hàng",
@@ -21,6 +21,7 @@ const locale = { "find-replace": {
21
21
  "replace-placeholder": "输入替换内容",
22
22
  "case-sensitive": "匹配大小写",
23
23
  "match-the-whole-cell": "匹配整个单元格",
24
+ "match-the-whole-word": "全词匹配",
24
25
  "find-scope": {
25
26
  title: "查找范围",
26
27
  "current-sheet": "当前子表",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "取代",
18
18
  "replace-all": "全部取代",
19
19
  "case-sensitive": "區分大小寫",
20
- "find-placeholder": "在此工作表中尋找",
20
+ "find-placeholder": "尋找",
21
21
  "advanced-finding": "進階搜尋與取代",
22
22
  "replace-placeholder": "輸入取代字串",
23
23
  "match-the-whole-cell": "完全符合儲存格內容",
24
+ "match-the-whole-word": "全詞匹配",
24
25
  "find-direction": {
25
26
  title: "尋找方向",
26
27
  row: "按列搜尋",
@@ -17,10 +17,11 @@ const locale = { "find-replace": {
17
17
  replace: "取代",
18
18
  "replace-all": "全部取代",
19
19
  "case-sensitive": "區分大小寫",
20
- "find-placeholder": "在此工作表中尋找",
20
+ "find-placeholder": "尋找",
21
21
  "advanced-finding": "進階搜尋與取代",
22
22
  "replace-placeholder": "輸入取代字串",
23
23
  "match-the-whole-cell": "完全符合儲存格內容",
24
+ "match-the-whole-word": "全詞匹配",
24
25
  "find-direction": {
25
26
  title: "尋找方向",
26
27
  row: "按列搜尋",