@univerjs/docs-find-replace 1.0.0-alpha.8

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