@univerjs/docs-find-replace 1.0.0-insiders.20260727-46ed76c

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/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @univerjs/docs-find-replace
2
+
3
+ ```bash
4
+ pnpm add @univerjs/docs-find-replace
5
+ ```
6
+
7
+ ```ts
8
+ import { UniverDocsFindReplacePlugin } from '@univerjs/docs-find-replace';
9
+
10
+ univer.registerPlugin(UniverDocsFindReplacePlugin);
11
+ ```
12
+
13
+ Phase one searches and replaces literal text in the current document body, including tables. It excludes headers, footers, comments, drawings, regular expressions, formatting search, special characters, result sidebars, presets, and Facade APIs.
@@ -0,0 +1,519 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _univerjs_core = require("@univerjs/core");
3
+ let _univerjs_docs = require("@univerjs/docs");
4
+ let _univerjs_docs_ui = require("@univerjs/docs-ui");
5
+ let _univerjs_engine_render = require("@univerjs/engine-render");
6
+ let _univerjs_find_replace = require("@univerjs/find-replace");
7
+ let _univerjs_ui = require("@univerjs/ui");
8
+ let rxjs = require("rxjs");
9
+
10
+ //#region package.json
11
+ var name = "@univerjs/docs-find-replace";
12
+ var version = "1.0.0-insiders.20260727-46ed76c";
13
+
14
+ //#endregion
15
+ //#region src/config/config.ts
16
+ /**
17
+ * Copyright 2023-present DreamNum Co., Ltd.
18
+ *
19
+ * Licensed under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License.
21
+ * You may obtain a copy of the License at
22
+ *
23
+ * http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ const DOCS_FIND_REPLACE_PLUGIN_CONFIG_KEY = "docs-find-replace.config";
32
+ const configSymbol = Symbol(DOCS_FIND_REPLACE_PLUGIN_CONFIG_KEY);
33
+ const defaultPluginConfig = {};
34
+
35
+ //#endregion
36
+ //#region src/controllers/utils.ts
37
+ function findDocRanges(body, query, disabled) {
38
+ if (!query.findString) return [];
39
+ const expression = _univerjs_core.regexp.createLiteralRegExp(query.findString, query.caseSensitive ? "gu" : "giu");
40
+ const wordRanges = query.matchesTheWholeWord ? new Set(Array.from(new Intl.Segmenter(void 0, { granularity: "word" }).segment(body.dataStream)).filter((item) => item.isWordLike).map((item) => `${item.index}:${item.index + item.segment.length}`)) : null;
41
+ return Array.from(body.dataStream.matchAll(expression)).filter((match) => {
42
+ var _wordRanges$has;
43
+ return (_wordRanges$has = wordRanges === null || wordRanges === void 0 ? void 0 : wordRanges.has(`${match.index}:${match.index + match[0].length}`)) !== null && _wordRanges$has !== void 0 ? _wordRanges$has : true;
44
+ }).map((match) => {
45
+ var _body$customRanges$so, _body$customRanges;
46
+ const startOffset = match.index;
47
+ const endOffset = startOffset + match[0].length;
48
+ const overlapsWholeEntity = (_body$customRanges$so = (_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.some((range) => range.wholeEntity && range.startIndex < endOffset && range.endIndex + 1 > startOffset)) !== null && _body$customRanges$so !== void 0 ? _body$customRanges$so : false;
49
+ return {
50
+ startOffset,
51
+ endOffset,
52
+ replaceable: !disabled && !overlapsWholeEntity
53
+ };
54
+ });
55
+ }
56
+
57
+ //#endregion
58
+ //#region src/commands/commands/docs-replace.command.ts
59
+ const DocsReplaceCommand = {
60
+ id: "docs.command.replace",
61
+ type: _univerjs_core.CommandType.COMMAND,
62
+ handler: (accessor, params) => {
63
+ if (!params) return {
64
+ success: 0,
65
+ failure: 0
66
+ };
67
+ const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
68
+ const commandService = accessor.get(_univerjs_core.ICommandService);
69
+ const doc = instanceService.getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
70
+ const body = doc === null || doc === void 0 ? void 0 : doc.getBody();
71
+ if (!doc || !body) return {
72
+ success: 0,
73
+ failure: params.range ? 1 : 0
74
+ };
75
+ const matches = findDocRanges(body, params.query, !!doc.getSnapshot().disabled);
76
+ const candidates = params.range ? matches.filter((match) => match.startOffset === params.range.startOffset && match.endOffset === params.range.endOffset) : matches;
77
+ const replaceable = candidates.filter((match) => match.replaceable);
78
+ const failure = (params.range && candidates.length === 0 ? 1 : candidates.length) - replaceable.length;
79
+ if (!replaceable.length) return {
80
+ success: 0,
81
+ failure
82
+ };
83
+ const textX = new _univerjs_core.TextX();
84
+ const memoryCursor = new _univerjs_core.MemoryCursor();
85
+ for (const match of replaceable) {
86
+ var _slice$textRuns, _slice$customRanges;
87
+ const slice = doc.sliceBody(match.startOffset, match.endOffset);
88
+ const insertBody = params.replaceString ? {
89
+ dataStream: params.replaceString,
90
+ textRuns: (slice === null || slice === void 0 || (_slice$textRuns = slice.textRuns) === null || _slice$textRuns === void 0 ? void 0 : _slice$textRuns.length) ? [{
91
+ ...slice.textRuns[0],
92
+ st: 0,
93
+ ed: params.replaceString.length
94
+ }] : void 0,
95
+ customRanges: (slice === null || slice === void 0 || (_slice$customRanges = slice.customRanges) === null || _slice$customRanges === void 0 ? void 0 : _slice$customRanges.length) ? [{
96
+ ...slice.customRanges[0],
97
+ startIndex: 0,
98
+ endIndex: params.replaceString.length - 1
99
+ }] : void 0
100
+ } : null;
101
+ textX.push(..._univerjs_core.BuildTextUtils.selection.delete([{
102
+ startOffset: match.startOffset,
103
+ endOffset: match.endOffset,
104
+ collapsed: false
105
+ }], body, memoryCursor.cursor, insertBody, false));
106
+ memoryCursor.moveCursorTo(match.endOffset);
107
+ }
108
+ const actions = _univerjs_core.JSONX.getInstance().editOp(textX.serialize(), (0, _univerjs_core.getRichTextEditPath)(doc));
109
+ return commandService.syncExecuteCommand(_univerjs_docs.RichTextEditingMutation.id, {
110
+ unitId: params.unitId,
111
+ actions,
112
+ textRanges: []
113
+ }) ? {
114
+ success: replaceable.length,
115
+ failure
116
+ } : {
117
+ success: 0,
118
+ failure: failure + replaceable.length
119
+ };
120
+ }
121
+ };
122
+
123
+ //#endregion
124
+ //#region src/menu/find-replace.menu.ts
125
+ function DocsFindReplaceMenuItemFactory(accessor) {
126
+ const contextService = accessor.get(_univerjs_core.IContextService);
127
+ return {
128
+ id: _univerjs_find_replace.OpenFindDialogOperation.id,
129
+ icon: "SearchIcon",
130
+ tooltip: "find-replace.toolbar",
131
+ type: _univerjs_ui.MenuItemType.BUTTON,
132
+ disabled$: contextService.subscribeContextValue$(_univerjs_core.FOCUSING_DOC).pipe((0, rxjs.map)((focused) => !focused))
133
+ };
134
+ }
135
+
136
+ //#endregion
137
+ //#region src/menu/schema.ts
138
+ const menuSchema = { [_univerjs_ui.RibbonStartGroup.OTHERS]: { [_univerjs_find_replace.OpenFindDialogOperation.id]: {
139
+ order: 3,
140
+ menuItemFactory: DocsFindReplaceMenuItemFactory
141
+ } } };
142
+
143
+ //#endregion
144
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
145
+ function _typeof(o) {
146
+ "@babel/helpers - typeof";
147
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
148
+ return typeof o;
149
+ } : function(o) {
150
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
151
+ }, _typeof(o);
152
+ }
153
+
154
+ //#endregion
155
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
156
+ function toPrimitive(t, r) {
157
+ if ("object" != _typeof(t) || !t) return t;
158
+ var e = t[Symbol.toPrimitive];
159
+ if (void 0 !== e) {
160
+ var i = e.call(t, r || "default");
161
+ if ("object" != _typeof(i)) return i;
162
+ throw new TypeError("@@toPrimitive must return a primitive value.");
163
+ }
164
+ return ("string" === r ? String : Number)(t);
165
+ }
166
+
167
+ //#endregion
168
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
169
+ function toPropertyKey(t) {
170
+ var i = toPrimitive(t, "string");
171
+ return "symbol" == _typeof(i) ? i : i + "";
172
+ }
173
+
174
+ //#endregion
175
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
176
+ function _defineProperty(e, r, t) {
177
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
178
+ value: t,
179
+ enumerable: !0,
180
+ configurable: !0,
181
+ writable: !0
182
+ }) : e[r] = t, e;
183
+ }
184
+
185
+ //#endregion
186
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
187
+ function __decorateParam(paramIndex, decorator) {
188
+ return function(target, key) {
189
+ decorator(target, key, paramIndex);
190
+ };
191
+ }
192
+
193
+ //#endregion
194
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
195
+ function __decorate(decorators, target, key, desc) {
196
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
197
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
198
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
199
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
200
+ }
201
+
202
+ //#endregion
203
+ //#region src/models/docs-find.model.ts
204
+ const DOCS_FIND_REPLACE_PROVIDER = "docs-find-replace-provider";
205
+ let DocsFindModel = class DocsFindModel extends _univerjs_find_replace.FindModel {
206
+ constructor(_doc, _skeletonManager, _selectionManager, _renderManagerService, _commandService, _themeService) {
207
+ super();
208
+ this._doc = _doc;
209
+ this._skeletonManager = _skeletonManager;
210
+ this._selectionManager = _selectionManager;
211
+ this._renderManagerService = _renderManagerService;
212
+ this._commandService = _commandService;
213
+ this._themeService = _themeService;
214
+ _defineProperty(this, "_matchesUpdate$", new rxjs.Subject());
215
+ _defineProperty(this, "matchesUpdate$", this._matchesUpdate$.asObservable());
216
+ _defineProperty(this, "_activelyChangingMatch$", new rxjs.Subject());
217
+ _defineProperty(this, "activelyChangingMatch$", this._activelyChangingMatch$.asObservable());
218
+ _defineProperty(this, "_matches", []);
219
+ _defineProperty(this, "_position", -1);
220
+ _defineProperty(this, "_query", null);
221
+ _defineProperty(this, "_highlights", []);
222
+ _defineProperty(this, "unitId", void 0);
223
+ this.unitId = _doc.getUnitId();
224
+ this.disposeWithMe((0, _univerjs_core.toDisposable)((0, _univerjs_core.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0, rxjs.filter)(([command]) => {
225
+ var _command$params;
226
+ return command.id === _univerjs_docs.RichTextEditingMutation.id && ((_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId) === this.unitId;
227
+ }), (0, rxjs.debounceTime)(220)).subscribe(() => this._scan(true))));
228
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(this._skeletonManager.currentSkeleton$.subscribe(() => this._refreshHighlights())));
229
+ }
230
+ get currentMatch() {
231
+ var _this$_matches$this$_;
232
+ return this._position < 0 ? null : (_this$_matches$this$_ = this._matches[this._position]) !== null && _this$_matches$this$_ !== void 0 ? _this$_matches$this$_ : null;
233
+ }
234
+ dispose() {
235
+ super.dispose();
236
+ this._disposeHighlights();
237
+ this._matchesUpdate$.complete();
238
+ this._activelyChangingMatch$.complete();
239
+ }
240
+ getMatches() {
241
+ return this._matches;
242
+ }
243
+ start(query) {
244
+ this._query = query;
245
+ this._position = -1;
246
+ this._scan(false);
247
+ }
248
+ moveToNextMatch(params) {
249
+ if (!this._matches.length) return null;
250
+ if ((params === null || params === void 0 ? void 0 : params.stayIfOnMatch) && this.currentMatch) return this._activate(this._position, params.noFocus);
251
+ let index;
252
+ if (params === null || params === void 0 ? void 0 : params.ignoreSelection) index = 0;
253
+ else if (this._position >= 0) index = this._position + 1;
254
+ else {
255
+ const selection = this._selectionManager.getActiveTextRange();
256
+ const selectedMatch = (params === null || params === void 0 ? void 0 : params.stayIfOnMatch) ? this._selectionMatchIndex() : -1;
257
+ index = selectedMatch >= 0 ? selectedMatch : this._matches.findIndex((match) => {
258
+ var _selection$endOffset;
259
+ return match.range.startOffset >= ((_selection$endOffset = selection === null || selection === void 0 ? void 0 : selection.endOffset) !== null && _selection$endOffset !== void 0 ? _selection$endOffset : 0);
260
+ });
261
+ }
262
+ if (index < 0 || index >= this._matches.length) index = (params === null || params === void 0 ? void 0 : params.loop) ? 0 : -1;
263
+ if (index < 0) {
264
+ this._position = -1;
265
+ this._refreshHighlights();
266
+ return null;
267
+ }
268
+ return this._activate(index, params === null || params === void 0 ? void 0 : params.noFocus);
269
+ }
270
+ moveToPreviousMatch(params) {
271
+ if (!this._matches.length) return null;
272
+ if ((params === null || params === void 0 ? void 0 : params.stayIfOnMatch) && this.currentMatch) return this._activate(this._position, params.noFocus);
273
+ let index;
274
+ if (params === null || params === void 0 ? void 0 : params.ignoreSelection) index = this._matches.length - 1;
275
+ else if (this._position >= 0) index = this._position - 1;
276
+ else {
277
+ const selection = this._selectionManager.getActiveTextRange();
278
+ const selectedMatch = (params === null || params === void 0 ? void 0 : params.stayIfOnMatch) ? this._selectionMatchIndex() : -1;
279
+ index = selectedMatch >= 0 ? selectedMatch : this._matches.findLastIndex((match) => {
280
+ var _selection$startOffse;
281
+ return match.range.endOffset <= ((_selection$startOffse = selection === null || selection === void 0 ? void 0 : selection.startOffset) !== null && _selection$startOffse !== void 0 ? _selection$startOffse : 0);
282
+ });
283
+ }
284
+ if (index < 0) index = (params === null || params === void 0 ? void 0 : params.loop) ? this._matches.length - 1 : -1;
285
+ if (index < 0) {
286
+ this._position = -1;
287
+ this._refreshHighlights();
288
+ return null;
289
+ }
290
+ return this._activate(index, params === null || params === void 0 ? void 0 : params.noFocus);
291
+ }
292
+ async replace(replaceString) {
293
+ const current = this.currentMatch;
294
+ if (!(current === null || current === void 0 ? void 0 : current.replaceable) || !this._query) return false;
295
+ const result = await this._commandService.executeCommand(DocsReplaceCommand.id, {
296
+ unitId: this.unitId,
297
+ query: this._query,
298
+ replaceString,
299
+ range: current.range
300
+ });
301
+ return (result === null || result === void 0 ? void 0 : result.success) === 1;
302
+ }
303
+ async replaceAll(replaceString) {
304
+ var _await$this$_commandS;
305
+ if (!this._query) return {
306
+ success: 0,
307
+ failure: 0
308
+ };
309
+ return (_await$this$_commandS = await this._commandService.executeCommand(DocsReplaceCommand.id, {
310
+ unitId: this.unitId,
311
+ query: this._query,
312
+ replaceString
313
+ })) !== null && _await$this$_commandS !== void 0 ? _await$this$_commandS : {
314
+ success: 0,
315
+ failure: this._matches.length
316
+ };
317
+ }
318
+ focusSelection() {
319
+ if (this.currentMatch) this._focusMatch(this.currentMatch);
320
+ }
321
+ _scan(emit) {
322
+ var _this$currentMatch;
323
+ if (!this._query) return;
324
+ const body = this._doc.getBody();
325
+ if (!body) {
326
+ this._matches = [];
327
+ this._position = -1;
328
+ this._disposeHighlights();
329
+ if (emit) this._matchesUpdate$.next([]);
330
+ return;
331
+ }
332
+ const previousStart = (_this$currentMatch = this.currentMatch) === null || _this$currentMatch === void 0 ? void 0 : _this$currentMatch.range.startOffset;
333
+ this._matches = findDocRanges(body, this._query, !!this._doc.getSnapshot().disabled).map((range) => ({
334
+ provider: DOCS_FIND_REPLACE_PROVIDER,
335
+ unitId: this.unitId,
336
+ range: {
337
+ ...range,
338
+ collapsed: false
339
+ },
340
+ replaceable: range.replaceable
341
+ }));
342
+ this._position = previousStart == null ? -1 : this._matches.findIndex((match) => match.range.startOffset >= previousStart);
343
+ this._refreshHighlights();
344
+ if (emit) this._matchesUpdate$.next(this._matches);
345
+ }
346
+ _selectionMatchIndex() {
347
+ const selection = this._selectionManager.getActiveTextRange();
348
+ if (!selection) return -1;
349
+ return this._matches.findIndex((match) => match.range.startOffset <= selection.startOffset && match.range.endOffset >= selection.endOffset);
350
+ }
351
+ _activate(index, noFocus = false) {
352
+ const match = this._matches[index];
353
+ if (!match) return null;
354
+ this._position = index;
355
+ if (!noFocus) this._focusMatch(match);
356
+ else this._refreshHighlights();
357
+ return match;
358
+ }
359
+ _focusMatch(match) {
360
+ var _this$_renderManagerS;
361
+ this._selectionManager.replaceDocRanges([match.range], {
362
+ unitId: this.unitId,
363
+ subUnitId: this.unitId
364
+ }, true, { shouldFocus: false });
365
+ (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(this.unitId)) === null || _this$_renderManagerS === void 0 || _this$_renderManagerS.with(_univerjs_docs_ui.DocBackScrollRenderController).scrollToRange(match.range);
366
+ this._activelyChangingMatch$.next(match);
367
+ this._refreshHighlights();
368
+ }
369
+ _refreshHighlights() {
370
+ this._disposeHighlights();
371
+ const render = this._renderManagerService.getRenderUnitById(this.unitId);
372
+ const skeleton = this._skeletonManager.getSkeleton();
373
+ const document = render === null || render === void 0 ? void 0 : render.mainComponent;
374
+ if (!render || !skeleton || !document) return;
375
+ const color = this._themeService.getColorFromTheme("yellow.400");
376
+ const passiveStyle = {
377
+ strokeWidth: 0,
378
+ stroke: "rgba(0,0,0,0)",
379
+ strokeActive: "rgba(0,0,0,0)",
380
+ fill: new _univerjs_core.ColorKit(color).setAlpha(.3).toRgbString()
381
+ };
382
+ const activeStyle = {
383
+ ...passiveStyle,
384
+ fill: new _univerjs_core.ColorKit(color).setAlpha(.65).toRgbString()
385
+ };
386
+ this._matches.forEach((match, index) => {
387
+ const range = (0, _univerjs_docs_ui.getTextRangeFromCharIndex)(match.range.startOffset, match.range.endOffset, render.scene, document, skeleton, index === this._position ? activeStyle : passiveStyle, "", -1);
388
+ if (range) this._highlights.push(range);
389
+ });
390
+ }
391
+ _disposeHighlights() {
392
+ this._highlights.forEach((highlight) => highlight.dispose());
393
+ this._highlights = [];
394
+ }
395
+ };
396
+ DocsFindModel = __decorate([
397
+ __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
398
+ __decorateParam(3, _univerjs_engine_render.IRenderManagerService),
399
+ __decorateParam(4, _univerjs_core.ICommandService),
400
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
401
+ ], DocsFindModel);
402
+
403
+ //#endregion
404
+ //#region src/services/docs-find-replace.provider.ts
405
+ let DocsFindReplaceProvider = class DocsFindReplaceProvider extends _univerjs_core.Disposable {
406
+ constructor(_instanceService, _renderManagerService, _injector) {
407
+ super();
408
+ this._instanceService = _instanceService;
409
+ this._renderManagerService = _renderManagerService;
410
+ this._injector = _injector;
411
+ _defineProperty(this, "capabilities", {
412
+ caseSensitive: true,
413
+ matchesTheWholeWord: true,
414
+ matchesTheWholeCell: false,
415
+ findDirection: false,
416
+ findScope: false,
417
+ findBy: false
418
+ });
419
+ _defineProperty(this, "_model", null);
420
+ }
421
+ isSupported(unit) {
422
+ return unit.type === _univerjs_core.UniverInstanceType.UNIVER_DOC;
423
+ }
424
+ async find(query) {
425
+ var _this$_renderManagerS;
426
+ this.terminate();
427
+ const doc = this._instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
428
+ if (!doc) return [];
429
+ const skeleton = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(doc.getUnitId())) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs.DocSkeletonManagerService);
430
+ if (!skeleton) return [];
431
+ this._model = this._injector.createInstance(DocsFindModel, doc, skeleton);
432
+ this._model.start(query);
433
+ return [this._model];
434
+ }
435
+ terminate() {
436
+ var _this$_model;
437
+ (_this$_model = this._model) === null || _this$_model === void 0 || _this$_model.dispose();
438
+ this._model = null;
439
+ }
440
+ dispose() {
441
+ this.terminate();
442
+ super.dispose();
443
+ }
444
+ };
445
+ DocsFindReplaceProvider = __decorate([
446
+ __decorateParam(0, _univerjs_core.IUniverInstanceService),
447
+ __decorateParam(1, _univerjs_engine_render.IRenderManagerService),
448
+ __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
449
+ ], DocsFindReplaceProvider);
450
+
451
+ //#endregion
452
+ //#region src/controllers/docs-find-replace.controller.ts
453
+ /**
454
+ * Copyright 2023-present DreamNum Co., Ltd.
455
+ *
456
+ * Licensed under the Apache License, Version 2.0 (the "License");
457
+ * you may not use this file except in compliance with the License.
458
+ * You may obtain a copy of the License at
459
+ *
460
+ * http://www.apache.org/licenses/LICENSE-2.0
461
+ *
462
+ * Unless required by applicable law or agreed to in writing, software
463
+ * distributed under the License is distributed on an "AS IS" BASIS,
464
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
465
+ * See the License for the specific language governing permissions and
466
+ * limitations under the License.
467
+ */
468
+ let DocsFindReplaceController = class DocsFindReplaceController extends _univerjs_core.Disposable {
469
+ constructor(provider, findReplaceService, commandService, menuManagerService) {
470
+ super();
471
+ this.disposeWithMe(provider);
472
+ this.disposeWithMe(findReplaceService.registerFindReplaceProvider(provider));
473
+ this.disposeWithMe(commandService.registerCommand(DocsReplaceCommand));
474
+ menuManagerService.mergeMenu(menuSchema);
475
+ }
476
+ };
477
+ DocsFindReplaceController = __decorate([
478
+ __decorateParam(0, (0, _univerjs_core.Inject)(DocsFindReplaceProvider)),
479
+ __decorateParam(1, _univerjs_find_replace.IFindReplaceService),
480
+ __decorateParam(2, _univerjs_core.ICommandService),
481
+ __decorateParam(3, _univerjs_ui.IMenuManagerService)
482
+ ], DocsFindReplaceController);
483
+
484
+ //#endregion
485
+ //#region src/index.ts
486
+ let UniverDocsFindReplacePlugin = class UniverDocsFindReplacePlugin extends _univerjs_core.Plugin {
487
+ constructor(_config = defaultPluginConfig, _injector, _configService) {
488
+ super();
489
+ this._config = _config;
490
+ this._injector = _injector;
491
+ this._configService = _configService;
492
+ const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
493
+ this._configService.setConfig(DOCS_FIND_REPLACE_PLUGIN_CONFIG_KEY, rest);
494
+ }
495
+ onStarting() {
496
+ this._injector.add([DocsFindReplaceProvider]);
497
+ this._injector.add([DocsFindReplaceController]);
498
+ }
499
+ onSteady() {
500
+ this._injector.get(DocsFindReplaceController);
501
+ }
502
+ };
503
+ _defineProperty(UniverDocsFindReplacePlugin, "pluginName", "DOCS_FIND_REPLACE_PLUGIN");
504
+ _defineProperty(UniverDocsFindReplacePlugin, "packageName", name);
505
+ _defineProperty(UniverDocsFindReplacePlugin, "version", version);
506
+ _defineProperty(UniverDocsFindReplacePlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_DOC);
507
+ UniverDocsFindReplacePlugin = __decorate([
508
+ (0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_docs_ui.UniverDocsUIPlugin, _univerjs_find_replace.UniverFindReplacePlugin),
509
+ __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
510
+ __decorateParam(2, _univerjs_core.IConfigService)
511
+ ], UniverDocsFindReplacePlugin);
512
+
513
+ //#endregion
514
+ Object.defineProperty(exports, 'UniverDocsFindReplacePlugin', {
515
+ enumerable: true,
516
+ get: function () {
517
+ return UniverDocsFindReplacePlugin;
518
+ }
519
+ });