@univerjs/find-replace 1.0.0-alpha.7 → 1.0.0-alpha.8

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