@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/index.js CHANGED
@@ -1,6 +1,6 @@
1
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";
2
2
  import { Button, Checkbox, FormDualColumnLayout, FormLayout, Input, MessageType, Pager, Select } from "@univerjs/design";
3
- import { ComponentManager, IDialogService, ILayoutService, IMenuManagerService, IMessageService, IShortcutService, KeyCode, MenuItemType, MetaKeys, RibbonDataGroup, getMenuHiddenObservable, useDebounceFn, useDependency, useObservable } from "@univerjs/ui";
3
+ import { ComponentManager, IDialogService, ILayoutService, IMenuManagerService, IMessageService, IShortcutService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonDataGroup, 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";
@@ -34,7 +34,7 @@ const FIND_REPLACE_DIALOG_FOCUS = "FIND_REPLACE_DIALOG_FOCUS";
34
34
  const FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
37
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
38
38
  function _typeof(o) {
39
39
  "@babel/helpers - typeof";
40
40
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -45,7 +45,7 @@ function _typeof(o) {
45
45
  }
46
46
 
47
47
  //#endregion
48
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
48
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
49
49
  function toPrimitive(t, r) {
50
50
  if ("object" != _typeof(t) || !t) return t;
51
51
  var e = t[Symbol.toPrimitive];
@@ -58,14 +58,14 @@ function toPrimitive(t, r) {
58
58
  }
59
59
 
60
60
  //#endregion
61
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
61
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
62
62
  function toPropertyKey(t) {
63
63
  var i = toPrimitive(t, "string");
64
64
  return "symbol" == _typeof(i) ? i : i + "";
65
65
  }
66
66
 
67
67
  //#endregion
68
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
68
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
69
69
  function _defineProperty(e, r, t) {
70
70
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
71
71
  value: t,
@@ -76,7 +76,7 @@ function _defineProperty(e, r, t) {
76
76
  }
77
77
 
78
78
  //#endregion
79
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
79
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
80
80
  function __decorateParam(paramIndex, decorator) {
81
81
  return function(target, key) {
82
82
  decorator(target, key, paramIndex);
@@ -84,7 +84,7 @@ function __decorateParam(paramIndex, decorator) {
84
84
  }
85
85
 
86
86
  //#endregion
87
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
87
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
88
88
  function __decorate(decorators, target, key, desc) {
89
89
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
90
90
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -779,10 +779,206 @@ const menuSchema = { [RibbonDataGroup.ORGANIZATION]: { [OpenFindDialogOperation.
779
779
  menuItemFactory: FindReplaceMenuItemFactory
780
780
  } } };
781
781
 
782
+ //#endregion
783
+ //#region src/controllers/find-replace.shortcut.ts
784
+ function whenFindReplaceDialogFocused(contextService) {
785
+ return contextService.getContextValue(FIND_REPLACE_DIALOG_FOCUS);
786
+ }
787
+ function whenReplaceRevealed(contextService) {
788
+ return contextService.getContextValue(FIND_REPLACE_REPLACE_REVEALED);
789
+ }
790
+ function whenFindReplaceInputFocused(contextService) {
791
+ return contextService.getContextValue(FIND_REPLACE_INPUT_FOCUS);
792
+ }
793
+ const FIND_REPLACE_SHORTCUT_GROUP = "7_find-replace-shortcuts";
794
+ function whenSheetFocused(contextService) {
795
+ return contextService.getContextValue(FOCUSING_SHEET);
796
+ }
797
+ function whenEditorNotActivated(contextService) {
798
+ return !contextService.getContextValue(EDITOR_ACTIVATED);
799
+ }
800
+ const OpenFindDialogShortcutItem = {
801
+ id: OpenFindDialogOperation.id,
802
+ description: "find-replace.shortcut.open-find-dialog",
803
+ binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
804
+ group: FIND_REPLACE_SHORTCUT_GROUP,
805
+ groupTitle: "find-replace.shortcut.panel",
806
+ preconditions(contextService) {
807
+ return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
808
+ }
809
+ };
810
+ const MacOpenFindDialogShortcutItem = {
811
+ id: OpenFindDialogOperation.id,
812
+ description: "find-replace.shortcut.open-find-dialog",
813
+ binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
814
+ mac: KeyCode.F | MetaKeys.MAC_CTRL,
815
+ preconditions(contextService) {
816
+ return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
817
+ }
818
+ };
819
+ const OpenReplaceDialogShortcutItem = {
820
+ id: OpenReplaceDialogOperation.id,
821
+ description: "find-replace.shortcut.open-replace-dialog",
822
+ binding: KeyCode.H | MetaKeys.CTRL_COMMAND,
823
+ mac: KeyCode.H | MetaKeys.MAC_CTRL,
824
+ group: FIND_REPLACE_SHORTCUT_GROUP,
825
+ groupTitle: "find-replace.shortcut.panel",
826
+ preconditions(contextService) {
827
+ return whenSheetFocused(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
828
+ }
829
+ };
830
+ const GoToNextFindMatchShortcutItem = {
831
+ id: GoToNextMatchOperation.id,
832
+ description: "find-replace.shortcut.go-to-next-match",
833
+ binding: KeyCode.ENTER,
834
+ group: FIND_REPLACE_SHORTCUT_GROUP,
835
+ groupTitle: "find-replace.shortcut.panel",
836
+ priority: 1e3,
837
+ preconditions(contextService) {
838
+ return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
839
+ }
840
+ };
841
+ const GoToPreviousFindMatchShortcutItem = {
842
+ id: GoToPreviousMatchOperation.id,
843
+ description: "find-replace.shortcut.go-to-previous-match",
844
+ binding: KeyCode.ENTER | MetaKeys.SHIFT,
845
+ group: FIND_REPLACE_SHORTCUT_GROUP,
846
+ groupTitle: "find-replace.shortcut.panel",
847
+ priority: 1e3,
848
+ preconditions(contextService) {
849
+ return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
850
+ }
851
+ };
852
+ const FocusSelectionShortcutItem = {
853
+ id: FocusSelectionOperation.id,
854
+ description: "find-replace.shortcut.focus-selection",
855
+ binding: KeyCode.ESC,
856
+ group: FIND_REPLACE_SHORTCUT_GROUP,
857
+ groupTitle: "find-replace.shortcut.panel",
858
+ priority: 1e3,
859
+ preconditions(contextService) {
860
+ return whenFindReplaceDialogFocused(contextService);
861
+ }
862
+ };
863
+
864
+ //#endregion
865
+ //#region src/controllers/find-replace.controller.ts
866
+ const FIND_REPLACE_DIALOG_ID = "DESKTOP_FIND_REPLACE_DIALOG";
867
+ const FIND_REPLACE_PANEL_WIDTH = 350;
868
+ const FIND_REPLACE_PANEL_RIGHT_PADDING = 20;
869
+ const FIND_REPLACE_PANEL_TOP_PADDING = 64;
870
+ let FindReplaceController = class FindReplaceController extends RxDisposable {
871
+ constructor(_univerInstanceService, _menuManagerService, _shortcutService, _commandService, _findReplaceService, _dialogService, _layoutService, _localeService) {
872
+ super();
873
+ this._univerInstanceService = _univerInstanceService;
874
+ this._menuManagerService = _menuManagerService;
875
+ this._shortcutService = _shortcutService;
876
+ this._commandService = _commandService;
877
+ this._findReplaceService = _findReplaceService;
878
+ this._dialogService = _dialogService;
879
+ this._layoutService = _layoutService;
880
+ this._localeService = _localeService;
881
+ _defineProperty(this, "_closingListenerDisposable", void 0);
882
+ this._initCommands();
883
+ this._initUI();
884
+ this._initShortcuts();
885
+ }
886
+ dispose() {
887
+ var _this$_closingListene;
888
+ super.dispose();
889
+ (_this$_closingListene = this._closingListenerDisposable) === null || _this$_closingListene === void 0 || _this$_closingListene.dispose();
890
+ this._closingListenerDisposable = null;
891
+ }
892
+ _initCommands() {
893
+ [
894
+ OpenFindDialogOperation,
895
+ OpenReplaceDialogOperation,
896
+ GoToNextMatchOperation,
897
+ GoToPreviousMatchOperation,
898
+ ReplaceAllMatchesCommand,
899
+ ReplaceCurrentMatchCommand,
900
+ FocusSelectionOperation
901
+ ].forEach((c) => {
902
+ this.disposeWithMe(this._commandService.registerCommand(c));
903
+ });
904
+ }
905
+ _initShortcuts() {
906
+ [
907
+ OpenReplaceDialogShortcutItem,
908
+ OpenFindDialogShortcutItem,
909
+ MacOpenFindDialogShortcutItem,
910
+ GoToPreviousFindMatchShortcutItem,
911
+ GoToNextFindMatchShortcutItem,
912
+ FocusSelectionShortcutItem
913
+ ].forEach((s) => this.disposeWithMe(this._shortcutService.registerShortcut(s)));
914
+ }
915
+ _initUI() {
916
+ this._menuManagerService.mergeMenu(menuSchema);
917
+ this._findReplaceService.stateUpdates$.pipe(takeUntil(this.dispose$)).subscribe((newState) => {
918
+ if (newState.revealed === true) this._openPanel();
919
+ });
920
+ }
921
+ _openPanel() {
922
+ this._dialogService.open({
923
+ id: FIND_REPLACE_DIALOG_ID,
924
+ draggable: true,
925
+ width: FIND_REPLACE_PANEL_WIDTH,
926
+ title: { title: this._localeService.t("find-replace.dialog.title") },
927
+ children: { label: "FindReplaceDialog" },
928
+ destroyOnClose: true,
929
+ mask: false,
930
+ maskClosable: false,
931
+ defaultPosition: getFindReplaceDialogDefaultPosition(),
932
+ preservePositionOnDestroy: true,
933
+ onClose: () => this.closePanel()
934
+ });
935
+ this._closingListenerDisposable = toDisposable(this._univerInstanceService.focused$.pipe(takeUntil(this.dispose$)).subscribe((focused) => {
936
+ if (!focused || !this._univerInstanceService.getUniverSheetInstance(focused)) this.closePanel();
937
+ }));
938
+ }
939
+ closePanel() {
940
+ if (!this._closingListenerDisposable) return;
941
+ this._closingListenerDisposable.dispose();
942
+ this._closingListenerDisposable = null;
943
+ this._dialogService.close(FIND_REPLACE_DIALOG_ID);
944
+ this._findReplaceService.terminate();
945
+ queueMicrotask(() => this._layoutService.focus());
946
+ }
947
+ };
948
+ FindReplaceController = __decorate([
949
+ __decorateParam(0, IUniverInstanceService),
950
+ __decorateParam(1, IMenuManagerService),
951
+ __decorateParam(2, IShortcutService),
952
+ __decorateParam(3, ICommandService),
953
+ __decorateParam(4, IFindReplaceService),
954
+ __decorateParam(5, IDialogService),
955
+ __decorateParam(6, ILayoutService),
956
+ __decorateParam(7, Inject(LocaleService))
957
+ ], FindReplaceController);
958
+ function getFindReplaceDialogDefaultPosition() {
959
+ const { innerWidth } = window;
960
+ return {
961
+ x: innerWidth - FIND_REPLACE_PANEL_WIDTH - FIND_REPLACE_PANEL_RIGHT_PADDING,
962
+ y: FIND_REPLACE_PANEL_TOP_PADDING
963
+ };
964
+ }
965
+
966
+ //#endregion
967
+ //#region package.json
968
+ var name = "@univerjs/find-replace";
969
+ var version = "1.0.0-alpha.0";
970
+
971
+ //#endregion
972
+ //#region src/config/config.ts
973
+ const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
974
+ const configSymbol = Symbol(FIND_REPLACE_PLUGIN_CONFIG_KEY);
975
+ const defaultPluginConfig = {};
976
+
782
977
  //#endregion
783
978
  //#region src/views/dialog/SearchInput.tsx
784
979
  function SearchInput(props) {
785
- const { findCompleted: findComplete, localeService, matchesCount, matchesPosition, initialFindString, findReplaceService, onChange, ...rest } = props;
980
+ const { findCompleted: findComplete, matchesCount, matchesPosition, initialFindString, findReplaceService, onChange, ...rest } = props;
981
+ const localeService = useDependency(LocaleService);
786
982
  const [value, setValue] = useState(initialFindString);
787
983
  const text = findComplete && matchesCount === 0 ? localeService.t("find-replace.dialog.no-result") : matchesCount === 0 ? " " : void 0;
788
984
  function handleChangePosition(newIndex) {
@@ -856,7 +1052,6 @@ const FindDialog = forwardRef(function FindDialogImpl(_props, ref) {
856
1052
  matchesCount,
857
1053
  matchesPosition,
858
1054
  findReplaceService,
859
- localeService,
860
1055
  initialFindString: findString,
861
1056
  onChange: onFindStringChange
862
1057
  }), /* @__PURE__ */ jsx("div", {
@@ -931,7 +1126,6 @@ const ReplaceDialog = forwardRef(function ReplaceDialogImpl(_props, ref) {
931
1126
  matchesCount,
932
1127
  matchesPosition,
933
1128
  findReplaceService,
934
- localeService,
935
1129
  initialFindString: inputtingFindString,
936
1130
  onChange: onFindStringChange
937
1131
  })
@@ -1074,204 +1268,40 @@ function useFindByOptions(localeService) {
1074
1268
  }
1075
1269
 
1076
1270
  //#endregion
1077
- //#region src/controllers/find-replace.shortcut.ts
1078
- function whenFindReplaceDialogFocused(contextService) {
1079
- return contextService.getContextValue(FIND_REPLACE_DIALOG_FOCUS);
1080
- }
1081
- function whenReplaceRevealed(contextService) {
1082
- return contextService.getContextValue(FIND_REPLACE_REPLACE_REVEALED);
1083
- }
1084
- function whenFindReplaceInputFocused(contextService) {
1085
- return contextService.getContextValue(FIND_REPLACE_INPUT_FOCUS);
1086
- }
1087
- const FIND_REPLACE_SHORTCUT_GROUP = "7_find-replace-shortcuts";
1088
- function whenSheetFocused(contextService) {
1089
- return contextService.getContextValue(FOCUSING_SHEET);
1090
- }
1091
- function whenEditorNotActivated(contextService) {
1092
- return !contextService.getContextValue(EDITOR_ACTIVATED);
1093
- }
1094
- const OpenFindDialogShortcutItem = {
1095
- id: OpenFindDialogOperation.id,
1096
- description: "find-replace.shortcut.open-find-dialog",
1097
- binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
1098
- group: FIND_REPLACE_SHORTCUT_GROUP,
1099
- groupTitle: "find-replace.shortcut.panel",
1100
- preconditions(contextService) {
1101
- return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
1102
- }
1103
- };
1104
- const MacOpenFindDialogShortcutItem = {
1105
- id: OpenFindDialogOperation.id,
1106
- description: "find-replace.shortcut.open-find-dialog",
1107
- binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
1108
- mac: KeyCode.F | MetaKeys.MAC_CTRL,
1109
- preconditions(contextService) {
1110
- return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
1111
- }
1112
- };
1113
- const OpenReplaceDialogShortcutItem = {
1114
- id: OpenReplaceDialogOperation.id,
1115
- description: "find-replace.shortcut.open-replace-dialog",
1116
- binding: KeyCode.H | MetaKeys.CTRL_COMMAND,
1117
- mac: KeyCode.H | MetaKeys.MAC_CTRL,
1118
- group: FIND_REPLACE_SHORTCUT_GROUP,
1119
- groupTitle: "find-replace.shortcut.panel",
1120
- preconditions(contextService) {
1121
- return whenSheetFocused(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
1122
- }
1123
- };
1124
- const GoToNextFindMatchShortcutItem = {
1125
- id: GoToNextMatchOperation.id,
1126
- description: "find-replace.shortcut.go-to-next-match",
1127
- binding: KeyCode.ENTER,
1128
- group: FIND_REPLACE_SHORTCUT_GROUP,
1129
- groupTitle: "find-replace.shortcut.panel",
1130
- priority: 1e3,
1131
- preconditions(contextService) {
1132
- return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
1133
- }
1134
- };
1135
- const GoToPreviousFindMatchShortcutItem = {
1136
- id: GoToPreviousMatchOperation.id,
1137
- description: "find-replace.shortcut.go-to-previous-match",
1138
- binding: KeyCode.ENTER | MetaKeys.SHIFT,
1139
- group: FIND_REPLACE_SHORTCUT_GROUP,
1140
- groupTitle: "find-replace.shortcut.panel",
1141
- priority: 1e3,
1142
- preconditions(contextService) {
1143
- return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
1144
- }
1145
- };
1146
- const FocusSelectionShortcutItem = {
1147
- id: FocusSelectionOperation.id,
1148
- description: "find-replace.shortcut.focus-selection",
1149
- binding: KeyCode.ESC,
1150
- group: FIND_REPLACE_SHORTCUT_GROUP,
1151
- groupTitle: "find-replace.shortcut.panel",
1152
- priority: 1e3,
1153
- preconditions(contextService) {
1154
- return whenFindReplaceDialogFocused(contextService);
1155
- }
1156
- };
1157
-
1158
- //#endregion
1159
- //#region src/controllers/find-replace.controller.ts
1160
- const FIND_REPLACE_DIALOG_ID = "DESKTOP_FIND_REPLACE_DIALOG";
1161
- const FIND_REPLACE_PANEL_WIDTH = 350;
1162
- const FIND_REPLACE_PANEL_RIGHT_PADDING = 20;
1163
- const FIND_REPLACE_PANEL_TOP_PADDING = 64;
1164
- let FindReplaceController = class FindReplaceController extends RxDisposable {
1165
- constructor(_univerInstanceService, _menuManagerService, _shortcutService, _commandService, _findReplaceService, _dialogService, _layoutService, _localeService, _componentManager) {
1271
+ //#region src/controllers/components.controller.ts
1272
+ /**
1273
+ * Copyright 2023-present DreamNum Co., Ltd.
1274
+ *
1275
+ * Licensed under the Apache License, Version 2.0 (the "License");
1276
+ * you may not use this file except in compliance with the License.
1277
+ * You may obtain a copy of the License at
1278
+ *
1279
+ * http://www.apache.org/licenses/LICENSE-2.0
1280
+ *
1281
+ * Unless required by applicable law or agreed to in writing, software
1282
+ * distributed under the License is distributed on an "AS IS" BASIS,
1283
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1284
+ * See the License for the specific language governing permissions and
1285
+ * limitations under the License.
1286
+ */
1287
+ let ComponentsController = class ComponentsController extends Disposable {
1288
+ constructor(_componentManager, _iconManager) {
1166
1289
  super();
1167
- this._univerInstanceService = _univerInstanceService;
1168
- this._menuManagerService = _menuManagerService;
1169
- this._shortcutService = _shortcutService;
1170
- this._commandService = _commandService;
1171
- this._findReplaceService = _findReplaceService;
1172
- this._dialogService = _dialogService;
1173
- this._layoutService = _layoutService;
1174
- this._localeService = _localeService;
1175
1290
  this._componentManager = _componentManager;
1176
- _defineProperty(this, "_closingListenerDisposable", void 0);
1177
- this._initCommands();
1178
- this._initUI();
1179
- this._initShortcuts();
1291
+ this._iconManager = _iconManager;
1292
+ this._registerIcons();
1293
+ this._registerComponents();
1180
1294
  }
1181
- dispose() {
1182
- var _this$_closingListene;
1183
- super.dispose();
1184
- (_this$_closingListene = this._closingListenerDisposable) === null || _this$_closingListene === void 0 || _this$_closingListene.dispose();
1185
- this._closingListenerDisposable = null;
1295
+ _registerIcons() {
1296
+ this.disposeWithMe(this._iconManager.register({ SearchIcon }));
1186
1297
  }
1187
- _initCommands() {
1188
- [
1189
- OpenFindDialogOperation,
1190
- OpenReplaceDialogOperation,
1191
- GoToNextMatchOperation,
1192
- GoToPreviousMatchOperation,
1193
- ReplaceAllMatchesCommand,
1194
- ReplaceCurrentMatchCommand,
1195
- FocusSelectionOperation
1196
- ].forEach((c) => {
1197
- this.disposeWithMe(this._commandService.registerCommand(c));
1198
- });
1199
- }
1200
- _initShortcuts() {
1201
- [
1202
- OpenReplaceDialogShortcutItem,
1203
- OpenFindDialogShortcutItem,
1204
- MacOpenFindDialogShortcutItem,
1205
- GoToPreviousFindMatchShortcutItem,
1206
- GoToNextFindMatchShortcutItem,
1207
- FocusSelectionShortcutItem
1208
- ].forEach((s) => this.disposeWithMe(this._shortcutService.registerShortcut(s)));
1209
- }
1210
- _initUI() {
1211
- [["FindReplaceDialog", FindReplaceDialog], ["SearchIcon", SearchIcon]].forEach(([key, comp]) => {
1298
+ _registerComponents() {
1299
+ [["FindReplaceDialog", FindReplaceDialog]].forEach(([key, comp]) => {
1212
1300
  this.disposeWithMe(this._componentManager.register(key, comp));
1213
1301
  });
1214
- this._menuManagerService.mergeMenu(menuSchema);
1215
- this._findReplaceService.stateUpdates$.pipe(takeUntil(this.dispose$)).subscribe((newState) => {
1216
- if (newState.revealed === true) this._openPanel();
1217
- });
1218
- }
1219
- _openPanel() {
1220
- this._dialogService.open({
1221
- id: FIND_REPLACE_DIALOG_ID,
1222
- draggable: true,
1223
- width: FIND_REPLACE_PANEL_WIDTH,
1224
- title: { title: this._localeService.t("find-replace.dialog.title") },
1225
- children: { label: "FindReplaceDialog" },
1226
- destroyOnClose: true,
1227
- mask: false,
1228
- maskClosable: false,
1229
- defaultPosition: getFindReplaceDialogDefaultPosition(),
1230
- preservePositionOnDestroy: true,
1231
- onClose: () => this.closePanel()
1232
- });
1233
- this._closingListenerDisposable = toDisposable(this._univerInstanceService.focused$.pipe(takeUntil(this.dispose$)).subscribe((focused) => {
1234
- if (!focused || !this._univerInstanceService.getUniverSheetInstance(focused)) this.closePanel();
1235
- }));
1236
- }
1237
- closePanel() {
1238
- if (!this._closingListenerDisposable) return;
1239
- this._closingListenerDisposable.dispose();
1240
- this._closingListenerDisposable = null;
1241
- this._dialogService.close(FIND_REPLACE_DIALOG_ID);
1242
- this._findReplaceService.terminate();
1243
- queueMicrotask(() => this._layoutService.focus());
1244
1302
  }
1245
1303
  };
1246
- FindReplaceController = __decorate([
1247
- __decorateParam(0, IUniverInstanceService),
1248
- __decorateParam(1, IMenuManagerService),
1249
- __decorateParam(2, IShortcutService),
1250
- __decorateParam(3, ICommandService),
1251
- __decorateParam(4, IFindReplaceService),
1252
- __decorateParam(5, IDialogService),
1253
- __decorateParam(6, ILayoutService),
1254
- __decorateParam(7, Inject(LocaleService)),
1255
- __decorateParam(8, Inject(ComponentManager))
1256
- ], FindReplaceController);
1257
- function getFindReplaceDialogDefaultPosition() {
1258
- const { innerWidth } = window;
1259
- return {
1260
- x: innerWidth - FIND_REPLACE_PANEL_WIDTH - FIND_REPLACE_PANEL_RIGHT_PADDING,
1261
- y: FIND_REPLACE_PANEL_TOP_PADDING
1262
- };
1263
- }
1264
-
1265
- //#endregion
1266
- //#region package.json
1267
- var name = "@univerjs/find-replace";
1268
- var version = "0.25.0";
1269
-
1270
- //#endregion
1271
- //#region src/config/config.ts
1272
- const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
1273
- const configSymbol = Symbol(FIND_REPLACE_PLUGIN_CONFIG_KEY);
1274
- const defaultPluginConfig = {};
1304
+ ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
1275
1305
 
1276
1306
  //#endregion
1277
1307
  //#region src/plugin.ts
@@ -1285,6 +1315,8 @@ let UniverFindReplacePlugin = class UniverFindReplacePlugin extends Plugin {
1285
1315
  this._configService.setConfig(FIND_REPLACE_PLUGIN_CONFIG_KEY, rest);
1286
1316
  }
1287
1317
  onStarting() {
1318
+ this._injector.add([ComponentsController]);
1319
+ this._injector.get(ComponentsController);
1288
1320
  [[FindReplaceController], [IFindReplaceService, { useClass: FindReplaceService }]].forEach((d) => this._injector.add(d));
1289
1321
  }
1290
1322
  onRendered() {
@@ -1297,4 +1329,4 @@ _defineProperty(UniverFindReplacePlugin, "version", version);
1297
1329
  UniverFindReplacePlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverFindReplacePlugin);
1298
1330
 
1299
1331
  //#endregion
1300
- export { FindBy, FindDirection, FindModel, FindReplaceController, FindReplaceModel, FindReplaceState, FindScope, GoToNextMatchOperation, GoToPreviousMatchOperation, IFindReplaceService, OpenFindDialogOperation, OpenReplaceDialogOperation, ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand, UniverFindReplacePlugin, createInitFindReplaceState };
1332
+ export { FindBy, FindDirection, FindModel, FindReplaceController, FindReplaceModel, FindReplaceService, FindReplaceState, FindScope, GoToNextMatchOperation, GoToPreviousMatchOperation, IFindReplaceService, OpenFindDialogOperation, OpenReplaceDialogOperation, ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand, UniverFindReplacePlugin, createInitFindReplaceState };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Disposable } from '@univerjs/core';
17
+ import { ComponentManager, IconManager } from '@univerjs/ui';
18
+ export declare class ComponentsController extends Disposable {
19
+ private readonly _componentManager;
20
+ private readonly _iconManager;
21
+ constructor(_componentManager: ComponentManager, _iconManager: IconManager);
22
+ private _registerIcons;
23
+ private _registerComponents;
24
+ }
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ICommandService, IUniverInstanceService, LocaleService, RxDisposable } from '@univerjs/core';
17
- import { ComponentManager, IDialogService, ILayoutService, IMenuManagerService, IShortcutService } from '@univerjs/ui';
17
+ import { IDialogService, ILayoutService, IMenuManagerService, IShortcutService } from '@univerjs/ui';
18
18
  import { IFindReplaceService } from '../services/find-replace.service';
19
19
  export declare class FindReplaceController extends RxDisposable {
20
20
  private readonly _univerInstanceService;
@@ -25,8 +25,7 @@ export declare class FindReplaceController extends RxDisposable {
25
25
  private readonly _dialogService;
26
26
  private readonly _layoutService;
27
27
  private readonly _localeService;
28
- private readonly _componentManager;
29
- constructor(_univerInstanceService: IUniverInstanceService, _menuManagerService: IMenuManagerService, _shortcutService: IShortcutService, _commandService: ICommandService, _findReplaceService: IFindReplaceService, _dialogService: IDialogService, _layoutService: ILayoutService, _localeService: LocaleService, _componentManager: ComponentManager);
28
+ constructor(_univerInstanceService: IUniverInstanceService, _menuManagerService: IMenuManagerService, _shortcutService: IShortcutService, _commandService: ICommandService, _findReplaceService: IFindReplaceService, _dialogService: IDialogService, _layoutService: ILayoutService, _localeService: LocaleService);
30
29
  dispose(): void;
31
30
  private _initCommands;
32
31
  private _initShortcuts;
@@ -20,4 +20,4 @@ export type { IUniverFindReplaceConfig } from './config/config';
20
20
  export { FindReplaceController } from './controllers/find-replace.controller';
21
21
  export { UniverFindReplacePlugin } from './plugin';
22
22
  export type { IFindComplete, IFindMatch, IFindMoveParams, IFindQuery, IFindReplaceProvider, IFindReplaceState, IReplaceAllResult, } from './services/find-replace.service';
23
- export { createInitFindReplaceState, FindBy, FindDirection, FindModel, FindReplaceModel, FindReplaceState, FindScope, IFindReplaceService } from './services/find-replace.service';
23
+ export { createInitFindReplaceState, FindBy, FindDirection, FindModel, FindReplaceModel, FindReplaceService, FindReplaceState, FindScope, IFindReplaceService, } from './services/find-replace.service';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { LocaleLeafKeys } from '@univerjs/core';
17
+ import type enUS from './en-US';
18
+ export type LocaleKey = LocaleLeafKeys<typeof enUS>;
@@ -15,4 +15,5 @@
15
15
  */
16
16
  import type { IAccessor } from '@univerjs/core';
17
17
  import type { IMenuButtonItem } from '@univerjs/ui';
18
- export declare function FindReplaceMenuItemFactory(accessor: IAccessor): IMenuButtonItem;
18
+ import type { LocaleKey } from '../locale/types';
19
+ export declare function FindReplaceMenuItemFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey>;
@@ -15,4 +15,4 @@
15
15
  */
16
16
  export declare const FindDialog: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
17
17
  export declare const ReplaceDialog: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
18
- export declare function FindReplaceDialog(): import("react/jsx-runtime").JSX.Element;
18
+ export declare function FindReplaceDialog(): import("react").JSX.Element;
@@ -17,8 +17,8 @@ import type { Meta } from '@storybook/react';
17
17
  declare const meta: Meta;
18
18
  export default meta;
19
19
  export declare const FindDialog: {
20
- render(): import("react/jsx-runtime").JSX.Element;
20
+ render(): import("react").JSX.Element;
21
21
  };
22
22
  export declare const ReplaceDialog: {
23
- render(): import("react/jsx-runtime").JSX.Element;
23
+ render(): import("react").JSX.Element;
24
24
  };
@@ -13,15 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { LocaleService } from '@univerjs/core';
17
16
  import type { IInputProps } from '@univerjs/design';
18
17
  import type { IFindReplaceService } from '../../services/find-replace.service';
19
18
  export interface ISearchInputProps extends Pick<IInputProps, 'onFocus' | 'onBlur' | 'className' | 'onChange'> {
20
19
  findCompleted: boolean;
21
- localeService: LocaleService;
22
20
  findReplaceService: IFindReplaceService;
23
21
  matchesPosition: number;
24
22
  matchesCount: number;
25
23
  initialFindString: string;
26
24
  }
27
- export declare function SearchInput(props: ISearchInputProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function SearchInput(props: ISearchInputProps): import("react").JSX.Element;