@univerjs/find-replace 0.25.1 → 1.0.0-alpha.1

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 (90) hide show
  1. package/lib/cjs/index.js +237 -199
  2. package/lib/cjs/locale/ar-SA.js +1 -0
  3. package/lib/cjs/locale/ca-ES.js +1 -0
  4. package/lib/cjs/locale/de-DE.js +1 -0
  5. package/lib/cjs/locale/en-US.js +1 -0
  6. package/lib/cjs/locale/es-ES.js +1 -0
  7. package/lib/cjs/locale/fa-IR.js +1 -0
  8. package/lib/cjs/locale/fr-FR.js +1 -0
  9. package/lib/cjs/locale/id-ID.js +1 -0
  10. package/lib/cjs/locale/it-IT.js +1 -0
  11. package/lib/cjs/locale/ja-JP.js +1 -0
  12. package/lib/cjs/locale/ko-KR.js +1 -0
  13. package/lib/cjs/locale/pl-PL.js +1 -0
  14. package/lib/cjs/locale/pt-BR.js +1 -0
  15. package/lib/cjs/locale/ru-RU.js +1 -0
  16. package/lib/cjs/locale/sk-SK.js +1 -0
  17. package/lib/cjs/locale/vi-VN.js +1 -0
  18. package/lib/cjs/locale/zh-CN.js +1 -0
  19. package/lib/cjs/locale/zh-HK.js +1 -0
  20. package/lib/cjs/locale/zh-TW.js +1 -0
  21. package/lib/es/index.js +233 -201
  22. package/lib/es/locale/ar-SA.js +1 -0
  23. package/lib/es/locale/ca-ES.js +1 -0
  24. package/lib/es/locale/de-DE.js +1 -0
  25. package/lib/es/locale/en-US.js +1 -0
  26. package/lib/es/locale/es-ES.js +1 -0
  27. package/lib/es/locale/fa-IR.js +1 -0
  28. package/lib/es/locale/fr-FR.js +1 -0
  29. package/lib/es/locale/id-ID.js +1 -0
  30. package/lib/es/locale/it-IT.js +1 -0
  31. package/lib/es/locale/ja-JP.js +1 -0
  32. package/lib/es/locale/ko-KR.js +1 -0
  33. package/lib/es/locale/pl-PL.js +1 -0
  34. package/lib/es/locale/pt-BR.js +1 -0
  35. package/lib/es/locale/ru-RU.js +1 -0
  36. package/lib/es/locale/sk-SK.js +1 -0
  37. package/lib/es/locale/vi-VN.js +1 -0
  38. package/lib/es/locale/zh-CN.js +1 -0
  39. package/lib/es/locale/zh-HK.js +1 -0
  40. package/lib/es/locale/zh-TW.js +1 -0
  41. package/lib/index.js +233 -201
  42. package/lib/locale/ar-SA.js +1 -0
  43. package/lib/locale/ca-ES.js +1 -0
  44. package/lib/locale/de-DE.js +1 -0
  45. package/lib/locale/en-US.js +1 -0
  46. package/lib/locale/es-ES.js +1 -0
  47. package/lib/locale/fa-IR.js +1 -0
  48. package/lib/locale/fr-FR.js +1 -0
  49. package/lib/locale/id-ID.js +1 -0
  50. package/lib/locale/it-IT.js +1 -0
  51. package/lib/locale/ja-JP.js +1 -0
  52. package/lib/locale/ko-KR.js +1 -0
  53. package/lib/locale/pl-PL.js +1 -0
  54. package/lib/locale/pt-BR.js +1 -0
  55. package/lib/locale/ru-RU.js +1 -0
  56. package/lib/locale/sk-SK.js +1 -0
  57. package/lib/locale/vi-VN.js +1 -0
  58. package/lib/locale/zh-CN.js +1 -0
  59. package/lib/locale/zh-HK.js +1 -0
  60. package/lib/locale/zh-TW.js +1 -0
  61. package/lib/types/controllers/components.controller.d.ts +24 -0
  62. package/lib/types/controllers/find-replace.controller.d.ts +2 -3
  63. package/lib/types/index.d.ts +1 -1
  64. package/lib/types/locale/en-US.d.ts +1 -0
  65. package/lib/types/locale/types.d.ts +18 -0
  66. package/lib/types/menu/find-replace.menu.d.ts +2 -1
  67. package/lib/types/views/dialog/FindReplaceDialog.d.ts +1 -1
  68. package/lib/types/views/dialog/FindReplaceDialog.stories.d.ts +2 -2
  69. package/lib/types/views/dialog/SearchInput.d.ts +1 -3
  70. package/lib/umd/index.js +1 -1
  71. package/lib/umd/locale/ar-SA.js +1 -1
  72. package/lib/umd/locale/ca-ES.js +1 -1
  73. package/lib/umd/locale/de-DE.js +1 -1
  74. package/lib/umd/locale/en-US.js +1 -1
  75. package/lib/umd/locale/es-ES.js +1 -1
  76. package/lib/umd/locale/fa-IR.js +1 -1
  77. package/lib/umd/locale/fr-FR.js +1 -1
  78. package/lib/umd/locale/id-ID.js +1 -1
  79. package/lib/umd/locale/it-IT.js +1 -1
  80. package/lib/umd/locale/ja-JP.js +1 -1
  81. package/lib/umd/locale/ko-KR.js +1 -1
  82. package/lib/umd/locale/pl-PL.js +1 -1
  83. package/lib/umd/locale/pt-BR.js +1 -1
  84. package/lib/umd/locale/ru-RU.js +1 -1
  85. package/lib/umd/locale/sk-SK.js +1 -1
  86. package/lib/umd/locale/vi-VN.js +1 -1
  87. package/lib/umd/locale/zh-CN.js +1 -1
  88. package/lib/umd/locale/zh-HK.js +1 -1
  89. package/lib/umd/locale/zh-TW.js +1 -1
  90. package/package.json +8 -8
package/lib/cjs/index.js CHANGED
@@ -35,7 +35,7 @@ const FIND_REPLACE_DIALOG_FOCUS = "FIND_REPLACE_DIALOG_FOCUS";
35
35
  const FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
36
36
 
37
37
  //#endregion
38
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
38
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
39
39
  function _typeof(o) {
40
40
  "@babel/helpers - typeof";
41
41
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -46,7 +46,7 @@ function _typeof(o) {
46
46
  }
47
47
 
48
48
  //#endregion
49
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
49
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
50
50
  function toPrimitive(t, r) {
51
51
  if ("object" != _typeof(t) || !t) return t;
52
52
  var e = t[Symbol.toPrimitive];
@@ -59,14 +59,14 @@ function toPrimitive(t, r) {
59
59
  }
60
60
 
61
61
  //#endregion
62
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
62
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
63
63
  function toPropertyKey(t) {
64
64
  var i = toPrimitive(t, "string");
65
65
  return "symbol" == _typeof(i) ? i : i + "";
66
66
  }
67
67
 
68
68
  //#endregion
69
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
69
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
70
70
  function _defineProperty(e, r, t) {
71
71
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
72
72
  value: t,
@@ -77,7 +77,7 @@ function _defineProperty(e, r, t) {
77
77
  }
78
78
 
79
79
  //#endregion
80
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
80
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
81
81
  function __decorateParam(paramIndex, decorator) {
82
82
  return function(target, key) {
83
83
  decorator(target, key, paramIndex);
@@ -85,7 +85,7 @@ function __decorateParam(paramIndex, decorator) {
85
85
  }
86
86
 
87
87
  //#endregion
88
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
88
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
89
89
  function __decorate(decorators, target, key, desc) {
90
90
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
91
91
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -780,10 +780,206 @@ const menuSchema = { [_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [OpenFindDia
780
780
  menuItemFactory: FindReplaceMenuItemFactory
781
781
  } } };
782
782
 
783
+ //#endregion
784
+ //#region src/controllers/find-replace.shortcut.ts
785
+ function whenFindReplaceDialogFocused(contextService) {
786
+ return contextService.getContextValue(FIND_REPLACE_DIALOG_FOCUS);
787
+ }
788
+ function whenReplaceRevealed(contextService) {
789
+ return contextService.getContextValue(FIND_REPLACE_REPLACE_REVEALED);
790
+ }
791
+ function whenFindReplaceInputFocused(contextService) {
792
+ return contextService.getContextValue(FIND_REPLACE_INPUT_FOCUS);
793
+ }
794
+ const FIND_REPLACE_SHORTCUT_GROUP = "7_find-replace-shortcuts";
795
+ function whenSheetFocused(contextService) {
796
+ return contextService.getContextValue(_univerjs_core.FOCUSING_SHEET);
797
+ }
798
+ function whenEditorNotActivated(contextService) {
799
+ return !contextService.getContextValue(_univerjs_core.EDITOR_ACTIVATED);
800
+ }
801
+ const OpenFindDialogShortcutItem = {
802
+ id: OpenFindDialogOperation.id,
803
+ description: "find-replace.shortcut.open-find-dialog",
804
+ binding: _univerjs_ui.KeyCode.F | _univerjs_ui.MetaKeys.CTRL_COMMAND,
805
+ group: FIND_REPLACE_SHORTCUT_GROUP,
806
+ groupTitle: "find-replace.shortcut.panel",
807
+ preconditions(contextService) {
808
+ return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
809
+ }
810
+ };
811
+ const MacOpenFindDialogShortcutItem = {
812
+ id: OpenFindDialogOperation.id,
813
+ description: "find-replace.shortcut.open-find-dialog",
814
+ binding: _univerjs_ui.KeyCode.F | _univerjs_ui.MetaKeys.CTRL_COMMAND,
815
+ mac: _univerjs_ui.KeyCode.F | _univerjs_ui.MetaKeys.MAC_CTRL,
816
+ preconditions(contextService) {
817
+ return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
818
+ }
819
+ };
820
+ const OpenReplaceDialogShortcutItem = {
821
+ id: OpenReplaceDialogOperation.id,
822
+ description: "find-replace.shortcut.open-replace-dialog",
823
+ binding: _univerjs_ui.KeyCode.H | _univerjs_ui.MetaKeys.CTRL_COMMAND,
824
+ mac: _univerjs_ui.KeyCode.H | _univerjs_ui.MetaKeys.MAC_CTRL,
825
+ group: FIND_REPLACE_SHORTCUT_GROUP,
826
+ groupTitle: "find-replace.shortcut.panel",
827
+ preconditions(contextService) {
828
+ return whenSheetFocused(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
829
+ }
830
+ };
831
+ const GoToNextFindMatchShortcutItem = {
832
+ id: GoToNextMatchOperation.id,
833
+ description: "find-replace.shortcut.go-to-next-match",
834
+ binding: _univerjs_ui.KeyCode.ENTER,
835
+ group: FIND_REPLACE_SHORTCUT_GROUP,
836
+ groupTitle: "find-replace.shortcut.panel",
837
+ priority: 1e3,
838
+ preconditions(contextService) {
839
+ return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
840
+ }
841
+ };
842
+ const GoToPreviousFindMatchShortcutItem = {
843
+ id: GoToPreviousMatchOperation.id,
844
+ description: "find-replace.shortcut.go-to-previous-match",
845
+ binding: _univerjs_ui.KeyCode.ENTER | _univerjs_ui.MetaKeys.SHIFT,
846
+ group: FIND_REPLACE_SHORTCUT_GROUP,
847
+ groupTitle: "find-replace.shortcut.panel",
848
+ priority: 1e3,
849
+ preconditions(contextService) {
850
+ return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
851
+ }
852
+ };
853
+ const FocusSelectionShortcutItem = {
854
+ id: FocusSelectionOperation.id,
855
+ description: "find-replace.shortcut.focus-selection",
856
+ binding: _univerjs_ui.KeyCode.ESC,
857
+ group: FIND_REPLACE_SHORTCUT_GROUP,
858
+ groupTitle: "find-replace.shortcut.panel",
859
+ priority: 1e3,
860
+ preconditions(contextService) {
861
+ return whenFindReplaceDialogFocused(contextService);
862
+ }
863
+ };
864
+
865
+ //#endregion
866
+ //#region src/controllers/find-replace.controller.ts
867
+ const FIND_REPLACE_DIALOG_ID = "DESKTOP_FIND_REPLACE_DIALOG";
868
+ const FIND_REPLACE_PANEL_WIDTH = 350;
869
+ const FIND_REPLACE_PANEL_RIGHT_PADDING = 20;
870
+ const FIND_REPLACE_PANEL_TOP_PADDING = 64;
871
+ let FindReplaceController = class FindReplaceController extends _univerjs_core.RxDisposable {
872
+ constructor(_univerInstanceService, _menuManagerService, _shortcutService, _commandService, _findReplaceService, _dialogService, _layoutService, _localeService) {
873
+ super();
874
+ this._univerInstanceService = _univerInstanceService;
875
+ this._menuManagerService = _menuManagerService;
876
+ this._shortcutService = _shortcutService;
877
+ this._commandService = _commandService;
878
+ this._findReplaceService = _findReplaceService;
879
+ this._dialogService = _dialogService;
880
+ this._layoutService = _layoutService;
881
+ this._localeService = _localeService;
882
+ _defineProperty(this, "_closingListenerDisposable", void 0);
883
+ this._initCommands();
884
+ this._initUI();
885
+ this._initShortcuts();
886
+ }
887
+ dispose() {
888
+ var _this$_closingListene;
889
+ super.dispose();
890
+ (_this$_closingListene = this._closingListenerDisposable) === null || _this$_closingListene === void 0 || _this$_closingListene.dispose();
891
+ this._closingListenerDisposable = null;
892
+ }
893
+ _initCommands() {
894
+ [
895
+ OpenFindDialogOperation,
896
+ OpenReplaceDialogOperation,
897
+ GoToNextMatchOperation,
898
+ GoToPreviousMatchOperation,
899
+ ReplaceAllMatchesCommand,
900
+ ReplaceCurrentMatchCommand,
901
+ FocusSelectionOperation
902
+ ].forEach((c) => {
903
+ this.disposeWithMe(this._commandService.registerCommand(c));
904
+ });
905
+ }
906
+ _initShortcuts() {
907
+ [
908
+ OpenReplaceDialogShortcutItem,
909
+ OpenFindDialogShortcutItem,
910
+ MacOpenFindDialogShortcutItem,
911
+ GoToPreviousFindMatchShortcutItem,
912
+ GoToNextFindMatchShortcutItem,
913
+ FocusSelectionShortcutItem
914
+ ].forEach((s) => this.disposeWithMe(this._shortcutService.registerShortcut(s)));
915
+ }
916
+ _initUI() {
917
+ this._menuManagerService.mergeMenu(menuSchema);
918
+ this._findReplaceService.stateUpdates$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((newState) => {
919
+ if (newState.revealed === true) this._openPanel();
920
+ });
921
+ }
922
+ _openPanel() {
923
+ this._dialogService.open({
924
+ id: FIND_REPLACE_DIALOG_ID,
925
+ draggable: true,
926
+ width: FIND_REPLACE_PANEL_WIDTH,
927
+ title: { title: this._localeService.t("find-replace.dialog.title") },
928
+ children: { label: "FindReplaceDialog" },
929
+ destroyOnClose: true,
930
+ mask: false,
931
+ maskClosable: false,
932
+ defaultPosition: getFindReplaceDialogDefaultPosition(),
933
+ preservePositionOnDestroy: true,
934
+ onClose: () => this.closePanel()
935
+ });
936
+ this._closingListenerDisposable = (0, _univerjs_core.toDisposable)(this._univerInstanceService.focused$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((focused) => {
937
+ if (!focused || !this._univerInstanceService.getUniverSheetInstance(focused)) this.closePanel();
938
+ }));
939
+ }
940
+ closePanel() {
941
+ if (!this._closingListenerDisposable) return;
942
+ this._closingListenerDisposable.dispose();
943
+ this._closingListenerDisposable = null;
944
+ this._dialogService.close(FIND_REPLACE_DIALOG_ID);
945
+ this._findReplaceService.terminate();
946
+ queueMicrotask(() => this._layoutService.focus());
947
+ }
948
+ };
949
+ FindReplaceController = __decorate([
950
+ __decorateParam(0, _univerjs_core.IUniverInstanceService),
951
+ __decorateParam(1, _univerjs_ui.IMenuManagerService),
952
+ __decorateParam(2, _univerjs_ui.IShortcutService),
953
+ __decorateParam(3, _univerjs_core.ICommandService),
954
+ __decorateParam(4, IFindReplaceService),
955
+ __decorateParam(5, _univerjs_ui.IDialogService),
956
+ __decorateParam(6, _univerjs_ui.ILayoutService),
957
+ __decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
958
+ ], FindReplaceController);
959
+ function getFindReplaceDialogDefaultPosition() {
960
+ const { innerWidth } = window;
961
+ return {
962
+ x: innerWidth - FIND_REPLACE_PANEL_WIDTH - FIND_REPLACE_PANEL_RIGHT_PADDING,
963
+ y: FIND_REPLACE_PANEL_TOP_PADDING
964
+ };
965
+ }
966
+
967
+ //#endregion
968
+ //#region package.json
969
+ var name = "@univerjs/find-replace";
970
+ var version = "1.0.0-alpha.1";
971
+
972
+ //#endregion
973
+ //#region src/config/config.ts
974
+ const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
975
+ const configSymbol = Symbol(FIND_REPLACE_PLUGIN_CONFIG_KEY);
976
+ const defaultPluginConfig = {};
977
+
783
978
  //#endregion
784
979
  //#region src/views/dialog/SearchInput.tsx
785
980
  function SearchInput(props) {
786
- const { findCompleted: findComplete, localeService, matchesCount, matchesPosition, initialFindString, findReplaceService, onChange, ...rest } = props;
981
+ const { findCompleted: findComplete, matchesCount, matchesPosition, initialFindString, findReplaceService, onChange, ...rest } = props;
982
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
787
983
  const [value, setValue] = (0, react.useState)(initialFindString);
788
984
  const text = findComplete && matchesCount === 0 ? localeService.t("find-replace.dialog.no-result") : matchesCount === 0 ? " " : void 0;
789
985
  function handleChangePosition(newIndex) {
@@ -857,7 +1053,6 @@ const FindDialog = (0, react.forwardRef)(function FindDialogImpl(_props, ref) {
857
1053
  matchesCount,
858
1054
  matchesPosition,
859
1055
  findReplaceService,
860
- localeService,
861
1056
  initialFindString: findString,
862
1057
  onChange: onFindStringChange
863
1058
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -932,7 +1127,6 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
932
1127
  matchesCount,
933
1128
  matchesPosition,
934
1129
  findReplaceService,
935
- localeService,
936
1130
  initialFindString: inputtingFindString,
937
1131
  onChange: onFindStringChange
938
1132
  })
@@ -1075,204 +1269,40 @@ function useFindByOptions(localeService) {
1075
1269
  }
1076
1270
 
1077
1271
  //#endregion
1078
- //#region src/controllers/find-replace.shortcut.ts
1079
- function whenFindReplaceDialogFocused(contextService) {
1080
- return contextService.getContextValue(FIND_REPLACE_DIALOG_FOCUS);
1081
- }
1082
- function whenReplaceRevealed(contextService) {
1083
- return contextService.getContextValue(FIND_REPLACE_REPLACE_REVEALED);
1084
- }
1085
- function whenFindReplaceInputFocused(contextService) {
1086
- return contextService.getContextValue(FIND_REPLACE_INPUT_FOCUS);
1087
- }
1088
- const FIND_REPLACE_SHORTCUT_GROUP = "7_find-replace-shortcuts";
1089
- function whenSheetFocused(contextService) {
1090
- return contextService.getContextValue(_univerjs_core.FOCUSING_SHEET);
1091
- }
1092
- function whenEditorNotActivated(contextService) {
1093
- return !contextService.getContextValue(_univerjs_core.EDITOR_ACTIVATED);
1094
- }
1095
- const OpenFindDialogShortcutItem = {
1096
- id: OpenFindDialogOperation.id,
1097
- description: "find-replace.shortcut.open-find-dialog",
1098
- binding: _univerjs_ui.KeyCode.F | _univerjs_ui.MetaKeys.CTRL_COMMAND,
1099
- group: FIND_REPLACE_SHORTCUT_GROUP,
1100
- groupTitle: "find-replace.shortcut.panel",
1101
- preconditions(contextService) {
1102
- return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
1103
- }
1104
- };
1105
- const MacOpenFindDialogShortcutItem = {
1106
- id: OpenFindDialogOperation.id,
1107
- description: "find-replace.shortcut.open-find-dialog",
1108
- binding: _univerjs_ui.KeyCode.F | _univerjs_ui.MetaKeys.CTRL_COMMAND,
1109
- mac: _univerjs_ui.KeyCode.F | _univerjs_ui.MetaKeys.MAC_CTRL,
1110
- preconditions(contextService) {
1111
- return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
1112
- }
1113
- };
1114
- const OpenReplaceDialogShortcutItem = {
1115
- id: OpenReplaceDialogOperation.id,
1116
- description: "find-replace.shortcut.open-replace-dialog",
1117
- binding: _univerjs_ui.KeyCode.H | _univerjs_ui.MetaKeys.CTRL_COMMAND,
1118
- mac: _univerjs_ui.KeyCode.H | _univerjs_ui.MetaKeys.MAC_CTRL,
1119
- group: FIND_REPLACE_SHORTCUT_GROUP,
1120
- groupTitle: "find-replace.shortcut.panel",
1121
- preconditions(contextService) {
1122
- return whenSheetFocused(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
1123
- }
1124
- };
1125
- const GoToNextFindMatchShortcutItem = {
1126
- id: GoToNextMatchOperation.id,
1127
- description: "find-replace.shortcut.go-to-next-match",
1128
- binding: _univerjs_ui.KeyCode.ENTER,
1129
- group: FIND_REPLACE_SHORTCUT_GROUP,
1130
- groupTitle: "find-replace.shortcut.panel",
1131
- priority: 1e3,
1132
- preconditions(contextService) {
1133
- return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
1134
- }
1135
- };
1136
- const GoToPreviousFindMatchShortcutItem = {
1137
- id: GoToPreviousMatchOperation.id,
1138
- description: "find-replace.shortcut.go-to-previous-match",
1139
- binding: _univerjs_ui.KeyCode.ENTER | _univerjs_ui.MetaKeys.SHIFT,
1140
- group: FIND_REPLACE_SHORTCUT_GROUP,
1141
- groupTitle: "find-replace.shortcut.panel",
1142
- priority: 1e3,
1143
- preconditions(contextService) {
1144
- return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
1145
- }
1146
- };
1147
- const FocusSelectionShortcutItem = {
1148
- id: FocusSelectionOperation.id,
1149
- description: "find-replace.shortcut.focus-selection",
1150
- binding: _univerjs_ui.KeyCode.ESC,
1151
- group: FIND_REPLACE_SHORTCUT_GROUP,
1152
- groupTitle: "find-replace.shortcut.panel",
1153
- priority: 1e3,
1154
- preconditions(contextService) {
1155
- return whenFindReplaceDialogFocused(contextService);
1156
- }
1157
- };
1158
-
1159
- //#endregion
1160
- //#region src/controllers/find-replace.controller.ts
1161
- const FIND_REPLACE_DIALOG_ID = "DESKTOP_FIND_REPLACE_DIALOG";
1162
- const FIND_REPLACE_PANEL_WIDTH = 350;
1163
- const FIND_REPLACE_PANEL_RIGHT_PADDING = 20;
1164
- const FIND_REPLACE_PANEL_TOP_PADDING = 64;
1165
- let FindReplaceController = class FindReplaceController extends _univerjs_core.RxDisposable {
1166
- constructor(_univerInstanceService, _menuManagerService, _shortcutService, _commandService, _findReplaceService, _dialogService, _layoutService, _localeService, _componentManager) {
1272
+ //#region src/controllers/components.controller.ts
1273
+ /**
1274
+ * Copyright 2023-present DreamNum Co., Ltd.
1275
+ *
1276
+ * Licensed under the Apache License, Version 2.0 (the "License");
1277
+ * you may not use this file except in compliance with the License.
1278
+ * You may obtain a copy of the License at
1279
+ *
1280
+ * http://www.apache.org/licenses/LICENSE-2.0
1281
+ *
1282
+ * Unless required by applicable law or agreed to in writing, software
1283
+ * distributed under the License is distributed on an "AS IS" BASIS,
1284
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1285
+ * See the License for the specific language governing permissions and
1286
+ * limitations under the License.
1287
+ */
1288
+ let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
1289
+ constructor(_componentManager, _iconManager) {
1167
1290
  super();
1168
- this._univerInstanceService = _univerInstanceService;
1169
- this._menuManagerService = _menuManagerService;
1170
- this._shortcutService = _shortcutService;
1171
- this._commandService = _commandService;
1172
- this._findReplaceService = _findReplaceService;
1173
- this._dialogService = _dialogService;
1174
- this._layoutService = _layoutService;
1175
- this._localeService = _localeService;
1176
1291
  this._componentManager = _componentManager;
1177
- _defineProperty(this, "_closingListenerDisposable", void 0);
1178
- this._initCommands();
1179
- this._initUI();
1180
- this._initShortcuts();
1181
- }
1182
- dispose() {
1183
- var _this$_closingListene;
1184
- super.dispose();
1185
- (_this$_closingListene = this._closingListenerDisposable) === null || _this$_closingListene === void 0 || _this$_closingListene.dispose();
1186
- this._closingListenerDisposable = null;
1187
- }
1188
- _initCommands() {
1189
- [
1190
- OpenFindDialogOperation,
1191
- OpenReplaceDialogOperation,
1192
- GoToNextMatchOperation,
1193
- GoToPreviousMatchOperation,
1194
- ReplaceAllMatchesCommand,
1195
- ReplaceCurrentMatchCommand,
1196
- FocusSelectionOperation
1197
- ].forEach((c) => {
1198
- this.disposeWithMe(this._commandService.registerCommand(c));
1199
- });
1292
+ this._iconManager = _iconManager;
1293
+ this._registerIcons();
1294
+ this._registerComponents();
1200
1295
  }
1201
- _initShortcuts() {
1202
- [
1203
- OpenReplaceDialogShortcutItem,
1204
- OpenFindDialogShortcutItem,
1205
- MacOpenFindDialogShortcutItem,
1206
- GoToPreviousFindMatchShortcutItem,
1207
- GoToNextFindMatchShortcutItem,
1208
- FocusSelectionShortcutItem
1209
- ].forEach((s) => this.disposeWithMe(this._shortcutService.registerShortcut(s)));
1296
+ _registerIcons() {
1297
+ this.disposeWithMe(this._iconManager.register({ SearchIcon: _univerjs_icons.SearchIcon }));
1210
1298
  }
1211
- _initUI() {
1212
- [["FindReplaceDialog", FindReplaceDialog], ["SearchIcon", _univerjs_icons.SearchIcon]].forEach(([key, comp]) => {
1299
+ _registerComponents() {
1300
+ [["FindReplaceDialog", FindReplaceDialog]].forEach(([key, comp]) => {
1213
1301
  this.disposeWithMe(this._componentManager.register(key, comp));
1214
1302
  });
1215
- this._menuManagerService.mergeMenu(menuSchema);
1216
- this._findReplaceService.stateUpdates$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((newState) => {
1217
- if (newState.revealed === true) this._openPanel();
1218
- });
1219
- }
1220
- _openPanel() {
1221
- this._dialogService.open({
1222
- id: FIND_REPLACE_DIALOG_ID,
1223
- draggable: true,
1224
- width: FIND_REPLACE_PANEL_WIDTH,
1225
- title: { title: this._localeService.t("find-replace.dialog.title") },
1226
- children: { label: "FindReplaceDialog" },
1227
- destroyOnClose: true,
1228
- mask: false,
1229
- maskClosable: false,
1230
- defaultPosition: getFindReplaceDialogDefaultPosition(),
1231
- preservePositionOnDestroy: true,
1232
- onClose: () => this.closePanel()
1233
- });
1234
- this._closingListenerDisposable = (0, _univerjs_core.toDisposable)(this._univerInstanceService.focused$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((focused) => {
1235
- if (!focused || !this._univerInstanceService.getUniverSheetInstance(focused)) this.closePanel();
1236
- }));
1237
- }
1238
- closePanel() {
1239
- if (!this._closingListenerDisposable) return;
1240
- this._closingListenerDisposable.dispose();
1241
- this._closingListenerDisposable = null;
1242
- this._dialogService.close(FIND_REPLACE_DIALOG_ID);
1243
- this._findReplaceService.terminate();
1244
- queueMicrotask(() => this._layoutService.focus());
1245
1303
  }
1246
1304
  };
1247
- FindReplaceController = __decorate([
1248
- __decorateParam(0, _univerjs_core.IUniverInstanceService),
1249
- __decorateParam(1, _univerjs_ui.IMenuManagerService),
1250
- __decorateParam(2, _univerjs_ui.IShortcutService),
1251
- __decorateParam(3, _univerjs_core.ICommandService),
1252
- __decorateParam(4, IFindReplaceService),
1253
- __decorateParam(5, _univerjs_ui.IDialogService),
1254
- __decorateParam(6, _univerjs_ui.ILayoutService),
1255
- __decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
1256
- __decorateParam(8, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))
1257
- ], FindReplaceController);
1258
- function getFindReplaceDialogDefaultPosition() {
1259
- const { innerWidth } = window;
1260
- return {
1261
- x: innerWidth - FIND_REPLACE_PANEL_WIDTH - FIND_REPLACE_PANEL_RIGHT_PADDING,
1262
- y: FIND_REPLACE_PANEL_TOP_PADDING
1263
- };
1264
- }
1265
-
1266
- //#endregion
1267
- //#region package.json
1268
- var name = "@univerjs/find-replace";
1269
- var version = "0.25.1";
1270
-
1271
- //#endregion
1272
- //#region src/config/config.ts
1273
- const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
1274
- const configSymbol = Symbol(FIND_REPLACE_PLUGIN_CONFIG_KEY);
1275
- const defaultPluginConfig = {};
1305
+ ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
1276
1306
 
1277
1307
  //#endregion
1278
1308
  //#region src/plugin.ts
@@ -1286,6 +1316,8 @@ let UniverFindReplacePlugin = class UniverFindReplacePlugin extends _univerjs_co
1286
1316
  this._configService.setConfig(FIND_REPLACE_PLUGIN_CONFIG_KEY, rest);
1287
1317
  }
1288
1318
  onStarting() {
1319
+ this._injector.add([ComponentsController]);
1320
+ this._injector.get(ComponentsController);
1289
1321
  [[FindReplaceController], [IFindReplaceService, { useClass: FindReplaceService }]].forEach((d) => this._injector.add(d));
1290
1322
  }
1291
1323
  onRendered() {
@@ -1313,6 +1345,12 @@ Object.defineProperty(exports, 'FindReplaceModel', {
1313
1345
  return FindReplaceModel;
1314
1346
  }
1315
1347
  });
1348
+ Object.defineProperty(exports, 'FindReplaceService', {
1349
+ enumerable: true,
1350
+ get: function () {
1351
+ return FindReplaceService;
1352
+ }
1353
+ });
1316
1354
  exports.FindReplaceState = FindReplaceState;
1317
1355
  exports.FindScope = FindScope;
1318
1356
  exports.GoToNextMatchOperation = GoToNextMatchOperation;
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "تم استبدال {0} تطابقات",
44
+ "partial-success": "تم استبدال {0} تطابقات، وتعذر استبدال {1}",
44
45
  "all-failure": "فشل الاستبدال",
45
46
  confirm: { title: "هل أنت متأكد من استبدال جميع التطابقات؟" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "S'han reemplaçat totes les {0} coincidències",
44
+ "partial-success": "S'han reemplaçat {0} coincidències, no s'han pogut reemplaçar {1}",
44
45
  "all-failure": "Error en el reemplaçament",
45
46
  confirm: { title: "Esteu segur que voleu reemplaçar totes les coincidències?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Alle {0} Treffer ersetzt",
44
+ "partial-success": "{0} Treffer ersetzt, {1} konnten nicht ersetzt werden",
44
45
  "all-failure": "Ersetzen fehlgeschlagen",
45
46
  confirm: { title: "Sollen alle Treffer ersetzt werden?" }
46
47
  },
@@ -56,6 +56,7 @@ const locale = { "find-replace": {
56
56
  },
57
57
  replace: {
58
58
  "all-success": "Replaced all {0} matches",
59
+ "partial-success": "Replaced {0} matches, failed to replace {1}",
59
60
  "all-failure": "Replace failed",
60
61
  confirm: { title: "Are you sure to replace all matches?" }
61
62
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Se reemplazaron todas las {0} coincidencias",
44
+ "partial-success": "Se reemplazaron {0} coincidencias; no se pudieron reemplazar {1}",
44
45
  "all-failure": "Error al reemplazar",
45
46
  confirm: { title: "¿Está seguro de que desea reemplazar todas las coincidencias?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "همه {0} مورد تطابق جایگزین شدند",
44
+ "partial-success": "{0} مورد تطابق جایگزین شد، جایگزینی {1} مورد ناموفق بود",
44
45
  "all-failure": "جایگزینی ناموفق بود",
45
46
  confirm: { title: "آیا مطمئن هستید که می‌خواهید همه موارد تطابق را جایگزین کنید؟" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Toutes les {0} correspondances ont été remplacées",
44
+ "partial-success": "{0} correspondances ont été remplacées, {1} ont échoué",
44
45
  "all-failure": "Échec du remplacement",
45
46
  confirm: { title: "Êtes-vous sûr de vouloir remplacer toutes les correspondances ?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Berhasil mengganti {0} kecocokan",
44
+ "partial-success": "Berhasil mengganti {0} kecocokan, gagal mengganti {1}",
44
45
  "all-failure": "Penggantian gagal",
45
46
  confirm: { title: "Apakah Anda yakin ingin mengganti semua kecocokan?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Sostituite tutte le {0} corrispondenze",
44
+ "partial-success": "Sostituite {0} corrispondenze, {1} non sostituite",
44
45
  "all-failure": "Sostituzione non riuscita",
45
46
  confirm: { title: "Sei sicuro di voler sostituire tutte le corrispondenze?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "一致項目 {0} 件すべてを置換しました",
44
+ "partial-success": "{0} 件の一致項目を置換しました。{1} 件の置換に失敗しました",
44
45
  "all-failure": "置換に失敗しました",
45
46
  confirm: { title: "すべての一致項目を置換してもよろしいですか?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "일치 항목 {0}개를 모두 바꿨습니다.",
44
+ "partial-success": "일치 항목 {0}개를 바꾸고 {1}개는 바꾸지 못했습니다.",
44
45
  "all-failure": "바꾸기 실패",
45
46
  confirm: { title: "모든 일치 항목을 바꾸시겠습니까?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Zastąpiono wszystkie dopasowania: {0}",
44
+ "partial-success": "Zastąpiono dopasowania: {0}, nie udało się zastąpić: {1}",
44
45
  "all-failure": "Zastępowanie nie powiodło się",
45
46
  confirm: { title: "Czy na pewno chcesz zastąpić wszystkie dopasowania?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Substituídas todas as {0} correspondências",
44
+ "partial-success": "{0} correspondências substituídas, falha ao substituir {1}",
44
45
  "all-failure": "Falha na substituição",
45
46
  confirm: { title: "Tem certeza de que deseja substituir todas as correspondências?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Заменены все совпадения: {0}",
44
+ "partial-success": "Заменено совпадений: {0}, не удалось заменить: {1}",
44
45
  "all-failure": "Ошибка замены",
45
46
  confirm: { title: "Вы уверены, что хотите заменить все совпадения?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Všetkých {0} zhôd bolo nahradených",
44
+ "partial-success": "Nahradených {0} zhôd, {1} sa nepodarilo nahradiť",
44
45
  "all-failure": "Nahradenie zlyhalo",
45
46
  confirm: { title: "Ste si istí, že chcete nahradiť všetky zhody?" }
46
47
  },
@@ -41,6 +41,7 @@ const locale = { "find-replace": {
41
41
  },
42
42
  replace: {
43
43
  "all-success": "Đã thay thế tất cả {0} kết quả phù hợp",
44
+ "partial-success": "Đã thay thế {0} kết quả phù hợp, không thể thay thế {1}",
44
45
  "all-failure": "Thay thế thất bại",
45
46
  confirm: { title: "Bạn có chắc chắn muốn thay thế tất cả các kết quả phù hợp không?" }
46
47
  },