@univerjs/find-replace 0.25.0 → 1.0.0-alpha.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.
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.0";
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.0";
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;