@univerjs/sheets-find-replace 0.16.1 → 0.17.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,32 +1,32 @@
1
- var ge = Object.defineProperty;
2
- var fe = (h, e, t) => e in h ? ge(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
3
- var f = (h, e, t) => fe(h, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommandType as H, IUndoRedoService as _e, ICommandService as O, Rectangle as Se, Inject as k, Injector as A, IContextService as Z, IUniverInstanceService as q, ThemeService as me, Disposable as ee, EDITOR_ACTIVATED as pe, UniverInstanceType as te, fromCallback as F, ColorKit as ve, rotate as L, groupBy as Ie, ObjectMatrix as Ce, Tools as Re, replaceInDocumentBody as ke, DependentOn as we, IConfigService as be, Plugin as Me, merge as xe } from "@univerjs/core";
5
- import { SetRangeValuesCommand as ie, SheetsSelectionsService as ye, SelectRangeCommand as Ue, SetWorksheetActiveOperation as Pe, SetSelectionsOperation as Be, SetWorksheetActivateCommand as Fe, UniverSheetsPlugin as j } from "@univerjs/sheets";
6
- import { Shape as We, Rect as He, IRenderManagerService as ne, RENDER_RAW_FORMULA_KEY as Te } from "@univerjs/engine-render";
7
- import { FindReplaceController as Ee, IFindReplaceService as Oe, FindModel as Ae, FindBy as b, FindScope as R, FindDirection as w, UniverFindReplacePlugin as Ne } from "@univerjs/find-replace";
8
- import { SheetSkeletonManagerService as De, getCoordByCell as V, getSheetObject as $e, ScrollToCellCommand as Le } from "@univerjs/sheets-ui";
9
- import { filter as M, Subject as G, throttleTime as je, merge as Ve, skip as Ge, debounceTime as Ye } from "rxjs";
10
- const se = {
1
+ var fe = Object.defineProperty;
2
+ var _e = (h, e, t) => e in h ? fe(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
3
+ var f = (h, e, t) => _e(h, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CommandType as T, IUndoRedoService as me, ICommandService as A, Rectangle as Se, Inject as k, Injector as N, IContextService as q, IUniverInstanceService as ee, ThemeService as pe, Disposable as te, EDITOR_ACTIVATED as ve, UniverInstanceType as ie, fromCallback as W, ColorKit as Ie, rotate as j, groupBy as Ce, ObjectMatrix as Re, Tools as ke, replaceInDocumentBody as we, DependentOn as be, IConfigService as Me, Plugin as xe, merge as ye } from "@univerjs/core";
5
+ import { SetRangeValuesCommand as ne, SheetsSelectionsService as Ue, SelectRangeCommand as Pe, SetWorksheetActiveOperation as Be, SetSelectionsOperation as Fe, SetWorksheetActivateCommand as We, UniverSheetsPlugin as V } from "@univerjs/sheets";
6
+ import { Shape as He, Rect as Te, IRenderManagerService as se, RENDER_RAW_FORMULA_KEY as Ee } from "@univerjs/engine-render";
7
+ import { FindReplaceController as Oe, IFindReplaceService as Ae, FindModel as Ne, FindBy as M, FindScope as R, FindDirection as b, UniverFindReplacePlugin as De } from "@univerjs/find-replace";
8
+ import { SheetSkeletonManagerService as $e, getCoordByCell as G, getSheetObject as Le, ScrollToCellCommand as je } from "@univerjs/sheets-ui";
9
+ import { filter as x, Subject as Y, throttleTime as Ve, merge as Ge, skip as Ye, debounceTime as Ke } from "rxjs";
10
+ const re = {
11
11
  id: "sheet.command.replace",
12
- type: H.COMMAND,
12
+ type: T.COMMAND,
13
13
  handler: async (h, e) => {
14
- const t = h.get(_e), i = h.get(O), { unitId: n, replacements: r } = e, s = t.__tempBatchingUndoRedo(n), o = await Promise.all(r.map((c) => i.executeCommand(ie.id, {
14
+ const t = h.get(me), i = h.get(A), { unitId: n, replacements: r } = e, s = t.__tempBatchingUndoRedo(n), o = await Promise.all(r.map((c) => i.executeCommand(ne.id, {
15
15
  unitId: n,
16
16
  subUnitId: c.subUnitId,
17
17
  value: c.value
18
18
  })));
19
- return s.dispose(), Ke(o, r);
19
+ return s.dispose(), Qe(o, r);
20
20
  }
21
21
  };
22
- function Ke(h, e) {
22
+ function Qe(h, e) {
23
23
  let t = 0, i = 0;
24
24
  return h.forEach((n, r) => {
25
25
  const s = e[r].count;
26
26
  n ? t += s : i += s;
27
27
  }), { success: t, failure: i };
28
28
  }
29
- class Qe extends We {
29
+ class Xe extends He {
30
30
  constructor(t, i) {
31
31
  super(t, i);
32
32
  f(this, "_activated", !1);
@@ -42,7 +42,7 @@ class Qe extends We {
42
42
  }
43
43
  _draw(t) {
44
44
  const i = this._activated, n = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`, r = `rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;
45
- He.drawWith(t, {
45
+ Te.drawWith(t, {
46
46
  width: this.width,
47
47
  height: this.height,
48
48
  fill: n,
@@ -52,31 +52,31 @@ class Qe extends We {
52
52
  });
53
53
  }
54
54
  }
55
- function Y(h, e) {
55
+ function K(h, e) {
56
56
  return h.startRow === e.startRow && h.startColumn === e.startColumn;
57
57
  }
58
- function K(h, e) {
58
+ function Q(h, e) {
59
59
  return h.startRow < e.startRow || h.startRow === e.startRow && h.startColumn <= e.startColumn;
60
60
  }
61
- function Q(h, e) {
61
+ function X(h, e) {
62
62
  return h.startColumn < e.startColumn || h.startColumn === e.startColumn && h.startRow <= e.startRow;
63
63
  }
64
- function Xe(h, e) {
64
+ function ze(h, e) {
65
65
  return h.startRow > e.startRow || h.startRow === e.startRow && h.startColumn >= e.startColumn;
66
66
  }
67
- function ze(h, e) {
67
+ function Je(h, e) {
68
68
  return h.startColumn > e.startColumn || h.startColumn === e.startColumn && h.startRow >= e.startRow;
69
69
  }
70
- function Je(h, e) {
70
+ function Ze(h, e) {
71
71
  const { range: t } = h, { startRow: i, startColumn: n } = t, r = e.getMergedCell(i, n);
72
72
  return r ? Se.equals(t, r) : t.endRow === t.startRow && t.endColumn === t.startColumn;
73
73
  }
74
- var Ze = Object.getOwnPropertyDescriptor, N = (h, e, t, i) => {
75
- for (var n = i > 1 ? void 0 : i ? Ze(e, t) : e, r = h.length - 1, s; r >= 0; r--)
74
+ var qe = Object.getOwnPropertyDescriptor, D = (h, e, t, i) => {
75
+ for (var n = i > 1 ? void 0 : i ? qe(e, t) : e, r = h.length - 1, s; r >= 0; r--)
76
76
  (s = h[r]) && (n = s(n) || n);
77
77
  return n;
78
- }, m = (h, e) => (t, i) => e(t, i, h);
79
- let x = class extends ee {
78
+ }, S = (h, e) => (t, i) => e(t, i, h);
79
+ let y = class extends te {
80
80
  constructor(e, t, i, n, r) {
81
81
  super();
82
82
  f(this, "_provider");
@@ -86,28 +86,28 @@ let x = class extends ee {
86
86
  super.dispose(), this._findReplaceController.closePanel(), this._provider.dispose();
87
87
  }
88
88
  _init() {
89
- const e = this._injector.createInstance(E);
90
- this._provider = e, this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)), this.disposeWithMe(this._contextService.subscribeContextValue$(pe).pipe(M((t) => !!t)).subscribe(() => this._findReplaceController.closePanel()));
89
+ const e = this._injector.createInstance(O);
90
+ this._provider = e, this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)), this.disposeWithMe(this._contextService.subscribeContextValue$(ve).pipe(x((t) => !!t)).subscribe(() => this._findReplaceController.closePanel()));
91
91
  }
92
92
  _initCommands() {
93
- [se].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
93
+ [re].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
94
94
  }
95
95
  };
96
- x = N([
97
- m(0, k(A)),
98
- m(1, k(Ee)),
99
- m(2, Z),
100
- m(3, Oe),
101
- m(4, O)
102
- ], x);
103
- const qe = "sheets-find-replace-provider", et = 1e4;
104
- let T = class extends Ae {
96
+ y = D([
97
+ S(0, k(N)),
98
+ S(1, k(Oe)),
99
+ S(2, q),
100
+ S(3, Ae),
101
+ S(4, A)
102
+ ], y);
103
+ const et = "sheets-find-replace-provider", tt = 1e4;
104
+ let E = class extends Ne {
105
105
  constructor(e, t, i, n, r, s, o, c) {
106
106
  super();
107
107
  // We can directly inject the `FindReplaceService` here, and call its methods instead of using the observables.
108
- f(this, "_matchesUpdate$", new G());
108
+ f(this, "_matchesUpdate$", new Y());
109
109
  f(this, "matchesUpdate$", this._matchesUpdate$.asObservable());
110
- f(this, "_activelyChangingMatch$", new G());
110
+ f(this, "_activelyChangingMatch$", new Y());
111
111
  f(this, "activelyChangingMatch$", this._activelyChangingMatch$.asObservable());
112
112
  /** Hold matches by the worksheet they are in. Make it easier to track the next (or previous) match when searching in the whole workbook. */
113
113
  f(this, "_matchesByWorksheet", /* @__PURE__ */ new Map());
@@ -145,7 +145,7 @@ let T = class extends Ae {
145
145
  return this._matches;
146
146
  }
147
147
  start(e) {
148
- switch (this._query = e, e.findBy === b.FORMULA ? this._toggleDisplayRawFormula(!0) : this._toggleDisplayRawFormula(!1), e.findScope) {
148
+ switch (this._query = e, e.findBy === M.FORMULA ? this._toggleDisplayRawFormula(!0) : this._toggleDisplayRawFormula(!1), e.findScope) {
149
149
  case R.UNIT:
150
150
  this.findInWorkbook(e);
151
151
  break;
@@ -157,14 +157,14 @@ let T = class extends Ae {
157
157
  }
158
158
  focusSelection() {
159
159
  const e = this.currentMatch;
160
- e && this._commandService.executeCommand(Ue.id, {
160
+ e && this._commandService.executeCommand(Pe.id, {
161
161
  unitId: e.unitId,
162
162
  subUnit: e.range.subUnitId,
163
163
  range: e.range.range
164
164
  });
165
165
  }
166
166
  _toggleDisplayRawFormula(e) {
167
- this._contextService.setContextValue(Te, e);
167
+ this._contextService.setContextValue(Ee, e);
168
168
  }
169
169
  /**
170
170
  * Find all matches in the current workbook no matter which worksheet is activated.
@@ -184,7 +184,7 @@ let T = class extends Ae {
184
184
  return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(() => {
185
185
  this._updateFindHighlight(), this._updateCurrentHighlightShape(this._activeHighlightIndex);
186
186
  })), this.disposeWithMe(
187
- F(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(M(([s, o]) => s.id === Pe.id && !(o != null && o.fromFindReplace))).subscribe(() => {
187
+ W(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(x(([s, o]) => s.id === Be.id && !(o != null && o.fromFindReplace))).subscribe(() => {
188
188
  const s = this._workbook.getActiveSheet();
189
189
  if (!s)
190
190
  return;
@@ -192,11 +192,11 @@ let T = class extends Ae {
192
192
  this._matchesByWorksheet.has(o) && this._findNextMatchOnActiveSheetChange(s);
193
193
  })
194
194
  ), this.disposeWithMe(
195
- F(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(
196
- M(
197
- ([s]) => s.type === H.MUTATION && s.params.unitId === this._workbook.getUnitId()
195
+ W(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(
196
+ x(
197
+ ([s]) => s.type === T.MUTATION && s.params.unitId === this._workbook.getUnitId()
198
198
  ),
199
- je(600, void 0, { leading: !1, trailing: !0 })
199
+ Ve(600, void 0, { leading: !1, trailing: !0 })
200
200
  ).subscribe(() => r())
201
201
  ), r(), i;
202
202
  }
@@ -220,7 +220,7 @@ let T = class extends Ae {
220
220
  const c = this._workbook.getActiveSheet();
221
221
  if (!c) return !1;
222
222
  const l = this._workbookSelections.getCurrentSelections();
223
- return (d = l == null ? void 0 : l.some((u) => !Je(u, c))) != null ? d : !1;
223
+ return (d = l == null ? void 0 : l.some((u) => !Ze(u, c))) != null ? d : !1;
224
224
  };
225
225
  let n, r = !0, s = !1;
226
226
  const o = () => {
@@ -232,12 +232,12 @@ let T = class extends Ae {
232
232
  return this._matches = d.results, this._matchesPosition = this._tryRestoreLastMatchesPosition(l, this._matches), r ? (n = d, r = !1) : this._matchesUpdate$.next(this._matches), this._updateFindHighlight(), d;
233
233
  };
234
234
  return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(() => this._updateFindHighlight())), this.disposeWithMe(
235
- Ve(
236
- F(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(
237
- M(([c]) => {
238
- if (c.type === H.MUTATION && c.params.unitId === this._workbook.getUnitId())
235
+ Ge(
236
+ W(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(
237
+ x(([c]) => {
238
+ if (c.type === T.MUTATION && c.params.unitId === this._workbook.getUnitId())
239
239
  return !0;
240
- if (c.id === Be.id && c.params.unitId === t) {
240
+ if (c.id === Fe.id && c.params.unitId === t) {
241
241
  const l = i();
242
242
  return l === !1 && s === !1 ? !1 : (s = l, !0);
243
243
  }
@@ -245,20 +245,20 @@ let T = class extends Ae {
245
245
  })
246
246
  ),
247
247
  // activeSheet$ is a BehaviorSubject, so we need to skip the first
248
- this._workbook.activeSheet$.pipe(Ge(1))
249
- ).pipe(Ye(200)).subscribe(() => o())
248
+ this._workbook.activeSheet$.pipe(Ye(1))
249
+ ).pipe(Ke(200)).subscribe(() => o())
250
250
  ), o(), n;
251
251
  }
252
252
  _findInRange(e, t, i, n, r) {
253
- const s = [], o = e.getSheetId(), c = (t.findDirection === w.COLUMN ? e.iterateByColumn : e.iterateByRow).bind(e)(i);
253
+ const s = [], o = e.getSheetId(), c = (t.findDirection === b.COLUMN ? e.iterateByColumn : e.iterateByRow).bind(e)(i);
254
254
  for (const l of c) {
255
- const { row: a, col: d, colSpan: u, rowSpan: _, value: S } = l;
256
- if (r != null && r(a, d) || !S || e.getRowFiltered(a))
255
+ const { row: a, col: d, colSpan: u, rowSpan: _, value: m } = l;
256
+ if (r != null && r(a, d) || !m || e.getRowFiltered(a))
257
257
  continue;
258
- const { hit: I, replaceable: C, isFormula: p } = tt(e, a, d, t, S);
258
+ const { hit: I, replaceable: C, isFormula: p } = it(e, a, d, t, m);
259
259
  if (I) {
260
- const U = {
261
- provider: qe,
260
+ const P = {
261
+ provider: et,
262
262
  unitId: n,
263
263
  replaceable: C,
264
264
  isFormula: p,
@@ -272,13 +272,13 @@ let T = class extends Ae {
272
272
  }
273
273
  }
274
274
  };
275
- s.push(U);
275
+ s.push(P);
276
276
  }
277
277
  }
278
278
  return { results: s };
279
279
  }
280
280
  _findInSelections(e, t, i, n) {
281
- const { findDirection: r } = i, s = r === w.ROW ? K : Q, o = /* @__PURE__ */ new Set();
281
+ const { findDirection: r } = i, s = r === b.ROW ? Q : X, o = /* @__PURE__ */ new Set();
282
282
  return { results: t.map((l) => this._findInRange(e, i, l.range, n, (a, d) => {
283
283
  const u = `${a}-${d}`;
284
284
  return o.has(u) ? !0 : (o.add(u), !1);
@@ -305,34 +305,34 @@ let T = class extends Ae {
305
305
  const t = this._workbook.getUnitId(), i = this._renderManagerService.getRenderById(t);
306
306
  if (i == null)
307
307
  return;
308
- const { scene: n } = i, r = this._matches, s = this._themeService.getColorFromTheme("yellow.400"), o = new ve(s).toRgb(), c = this._workbook.getActiveSheet();
308
+ const { scene: n } = i, r = this._matches, s = this._themeService.getColorFromTheme("yellow.400"), o = new Ie(s).toRgb(), c = this._workbook.getActiveSheet();
309
309
  if (!c)
310
310
  return;
311
311
  const l = c.getSheetId(), a = r.filter((u) => u.range.subUnitId === l).map((u, _) => {
312
- const { startColumn: S, startRow: I, endColumn: C, endRow: p } = u.range.range, U = V(I, S, n, e), oe = V(p, C, n, e), { startX: D, startY: $ } = U, { endX: he, endY: ce } = oe;
313
- let P = !0;
312
+ const { startColumn: m, startRow: I, endColumn: C, endRow: p } = u.range.range, P = G(I, m, n, e), he = G(p, C, n, e), { startX: $, startY: L } = P, { endX: ce, endY: ae } = he;
313
+ let B = !0;
314
314
  for (let v = I; v <= p; v++)
315
315
  if (c.getRowRawVisible(v)) {
316
- P = !1;
316
+ B = !1;
317
317
  break;
318
318
  }
319
- let B = !0;
320
- for (let v = S; v <= C; v++)
319
+ let F = !0;
320
+ for (let v = m; v <= C; v++)
321
321
  if (c.getColVisible(v)) {
322
- B = !1;
322
+ F = !1;
323
323
  break;
324
324
  }
325
- const ae = P || B, le = B ? 2 : he - D, de = P ? 2 : ce - $, ue = {
326
- left: D,
327
- top: $,
325
+ const le = B || F, de = F ? 2 : ce - $, ue = B ? 2 : ae - L, ge = {
326
+ left: $,
327
+ top: L,
328
328
  color: o,
329
- width: le,
330
- height: de,
329
+ width: de,
330
+ height: ue,
331
331
  evented: !1,
332
- inHiddenRange: ae,
333
- zIndex: et
332
+ inHiddenRange: le,
333
+ zIndex: tt
334
334
  };
335
- return new Qe(`find-highlight-${_}`, ue);
335
+ return new Xe(`find-highlight-${_}`, ge);
336
336
  });
337
337
  n.addObjects(a), this._highlightShapes = a, n.makeDirty();
338
338
  }
@@ -346,13 +346,13 @@ let T = class extends Ae {
346
346
  }
347
347
  }
348
348
  _getSheetObject() {
349
- return $e(this._univerInstanceService, this._renderManagerService);
349
+ return Le(this._univerInstanceService, this._renderManagerService);
350
350
  }
351
351
  _focusMatch(e) {
352
352
  var i;
353
353
  const t = e.range.subUnitId;
354
- t !== ((i = this._workbook.getActiveSheet()) == null ? void 0 : i.getSheetId()) && this._commandService.executeCommand(Fe.id, { unitId: this._workbook.getUnitId(), subUnitId: t }, { fromFindReplace: !0 }), this._commandService.executeCommand(
355
- Le.id,
354
+ t !== ((i = this._workbook.getActiveSheet()) == null ? void 0 : i.getSheetId()) && this._commandService.executeCommand(We.id, { unitId: this._workbook.getUnitId(), subUnitId: t }, { fromFindReplace: !0 }), this._commandService.executeCommand(
355
+ je.id,
356
356
  { range: e.range.range },
357
357
  { fromFindReplace: !0 }
358
358
  );
@@ -374,7 +374,7 @@ let T = class extends Ae {
374
374
  const t = (o = e == null ? void 0 : e.loop) != null ? o : !1, i = (c = e == null ? void 0 : e.stayIfOnMatch) != null ? c : !1, n = (l = e == null ? void 0 : e.noFocus) != null ? l : !1, r = (a = e == null ? void 0 : e.ignoreSelection) != null ? a : !1, s = this._findNextMatch(t, i, r);
375
375
  if (s) {
376
376
  const [u, _] = s;
377
- return this._matchesPosition = _ + 1, this._query.findScope === R.UNIT ? this._activeHighlightIndex = this._matchesByWorksheet.get(u.range.subUnitId).findIndex((S) => S === u) : this._activeHighlightIndex = _, n || this._focusMatch(u), ((d = this._workbook.getActiveSheet()) == null ? void 0 : d.getSheetId()) === u.range.subUnitId && this._updateCurrentHighlightShape(this._activeHighlightIndex), u;
377
+ return this._matchesPosition = _ + 1, this._query.findScope === R.UNIT ? this._activeHighlightIndex = this._matchesByWorksheet.get(u.range.subUnitId).findIndex((m) => m === u) : this._activeHighlightIndex = _, n || this._focusMatch(u), ((d = this._workbook.getActiveSheet()) == null ? void 0 : d.getSheetId()) === u.range.subUnitId && this._updateCurrentHighlightShape(this._activeHighlightIndex), u;
378
378
  }
379
379
  return this._matchesPosition = 0, this._updateCurrentHighlightShape(), null;
380
380
  }
@@ -385,7 +385,7 @@ let T = class extends Ae {
385
385
  const t = (o = e == null ? void 0 : e.loop) != null ? o : !1, i = (c = e == null ? void 0 : e.stayIfOnMatch) != null ? c : !1, n = (l = e == null ? void 0 : e.noFocus) != null ? l : !1, r = (a = e == null ? void 0 : e.ignoreSelection) != null ? a : !1, s = this._findPreviousMatch(t, i, r);
386
386
  if (s) {
387
387
  const [u, _] = s;
388
- return this._matchesPosition = _ + 1, this._query.findScope === R.UNIT ? this._activeHighlightIndex = this._matchesByWorksheet.get(u.range.subUnitId).findIndex((S) => S === u) : this._activeHighlightIndex = _, n || this._focusMatch(u), ((d = this._workbook.getActiveSheet()) == null ? void 0 : d.getSheetId()) === u.range.subUnitId && this._updateCurrentHighlightShape(this._activeHighlightIndex), u;
388
+ return this._matchesPosition = _ + 1, this._query.findScope === R.UNIT ? this._activeHighlightIndex = this._matchesByWorksheet.get(u.range.subUnitId).findIndex((m) => m === u) : this._activeHighlightIndex = _, n || this._focusMatch(u), ((d = this._workbook.getActiveSheet()) == null ? void 0 : d.getSheetId()) === u.range.subUnitId && this._updateCurrentHighlightShape(this._activeHighlightIndex), u;
389
389
  }
390
390
  return this._matchesPosition = 0, this._updateCurrentHighlightShape(), null;
391
391
  }
@@ -438,20 +438,20 @@ let T = class extends Ae {
438
438
  return s ? this._findNextMatchByRange(this._matchesByWorksheet.get(s), n.range) : null;
439
439
  }
440
440
  _findPreviousWorksheetThatHasAMatch(e, t = !1) {
441
- const i = this._workbook.getSheetOrders(), n = i.findIndex((o) => o === e), s = (t ? L(i, n + 1) : i.slice(0, n + 1)).findLast((o) => this._matchesByWorksheet.has(o));
441
+ const i = this._workbook.getSheetOrders(), n = i.findIndex((o) => o === e), s = (t ? j(i, n + 1) : i.slice(0, n + 1)).findLast((o) => this._matchesByWorksheet.has(o));
442
442
  return s != null ? s : null;
443
443
  }
444
444
  _findNextWorksheetThatHasAMatch(e, t = !1) {
445
- const i = this._workbook.getSheetOrders(), n = i.findIndex((o) => o === e), s = (t ? L(i, n) : i.slice(n)).find((o) => this._matchesByWorksheet.has(o));
445
+ const i = this._workbook.getSheetOrders(), n = i.findIndex((o) => o === e), s = (t ? j(i, n) : i.slice(n)).find((o) => this._matchesByWorksheet.has(o));
446
446
  return s != null ? s : null;
447
447
  }
448
448
  _findNextMatchByRange(e, t, i = !1) {
449
- const n = this._query.findDirection === w.ROW;
449
+ const n = this._query.findDirection === b.ROW;
450
450
  let r = e.findIndex((o) => {
451
451
  const c = o.range.range;
452
- if (!(n ? K(t, c) : Q(t, c)))
452
+ if (!(n ? Q(t, c) : X(t, c)))
453
453
  return !1;
454
- const a = Y(t, c);
454
+ const a = K(t, c);
455
455
  return i ? a : !a;
456
456
  });
457
457
  r === -1 && (r = e.length - 1);
@@ -459,12 +459,12 @@ let T = class extends Ae {
459
459
  return [s, this._matches.findIndex((o) => o === s)];
460
460
  }
461
461
  _findPreviousMatchByRange(e, t, i = !1) {
462
- const n = this._query.findDirection === w.ROW;
462
+ const n = this._query.findDirection === b.ROW;
463
463
  let r = this._matches.findLastIndex((o) => {
464
464
  const c = o.range.range;
465
- if (!(n ? Xe(t, c) : ze(t, c)))
465
+ if (!(n ? ze(t, c) : Je(t, c)))
466
466
  return !1;
467
- const a = Y(t, c);
467
+ const a = K(t, c);
468
468
  return i ? a : !a;
469
469
  });
470
470
  r === -1 && (r = 0);
@@ -477,7 +477,7 @@ let T = class extends Ae {
477
477
  const t = this.currentMatch.range, i = this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId), n = this._getReplacedCellData(
478
478
  this.currentMatch,
479
479
  i,
480
- this._query.findBy === b.FORMULA,
480
+ this._query.findBy === M.FORMULA,
481
481
  this._query.findString,
482
482
  e,
483
483
  this._query.caseSensitive ? "g" : "ig"
@@ -490,23 +490,23 @@ let T = class extends Ae {
490
490
  }
491
491
  }
492
492
  };
493
- return this._commandService.executeCommand(ie.id, r);
493
+ return this._commandService.executeCommand(ne.id, r);
494
494
  }
495
495
  async replaceAll(e) {
496
496
  if (this._matchesCount === 0 || !this._query)
497
497
  return { success: 0, failure: 0 };
498
- const t = this._workbook.getUnitId(), { findString: i, caseSensitive: n, findBy: r } = this._query, s = r === b.FORMULA, o = n ? "g" : "ig", c = [];
499
- return Ie(this._matches.filter((a) => a.replaceable), (a) => a.range.subUnitId).forEach((a, d) => {
500
- const u = new Ce(), _ = this._workbook.getSheetBySheetId(d);
501
- a.forEach((S) => {
502
- const { startColumn: I, startRow: C } = S.range.range, p = this._getReplacedCellData(S, _, s, i, e, o);
498
+ const t = this._workbook.getUnitId(), { findString: i, caseSensitive: n, findBy: r } = this._query, s = r === M.FORMULA, o = n ? "g" : "ig", c = [];
499
+ return Ce(this._matches.filter((a) => a.replaceable), (a) => a.range.subUnitId).forEach((a, d) => {
500
+ const u = new Re(), _ = this._workbook.getSheetBySheetId(d);
501
+ a.forEach((m) => {
502
+ const { startColumn: I, startRow: C } = m.range.range, p = this._getReplacedCellData(m, _, s, i, e, o);
503
503
  p && u.setValue(C, I, p);
504
504
  }), c.push({
505
505
  count: a.length,
506
506
  subUnitId: d,
507
507
  value: u.getMatrix()
508
508
  });
509
- }), c ? this._commandService.executeCommand(se.id, {
509
+ }), c ? this._commandService.executeCommand(re.id, {
510
510
  unitId: t,
511
511
  replacements: c
512
512
  }) : { success: 0, failure: 0 };
@@ -515,26 +515,26 @@ let T = class extends Ae {
515
515
  var _;
516
516
  const o = e.range.range, { startRow: c, startColumn: l } = o, a = t.getCellRaw(c, l);
517
517
  if (e.isFormula)
518
- return i ? { f: a.f.replace(new RegExp(X(n), s), r), v: null } : null;
518
+ return i ? { f: a.f.replace(new RegExp(z(n), s), r), v: null } : null;
519
519
  if (!!((_ = a.p) != null && _.body)) {
520
- const S = Re.deepClone(a.p);
521
- return ke(S.body, n, r, this._query.caseSensitive), { p: S };
520
+ const m = ke.deepClone(a.p);
521
+ return we(m.body, n, r, this._query.caseSensitive), { p: m };
522
522
  }
523
- return { v: a.v.toString().replace(new RegExp(X(n), s), r) };
523
+ return { v: a.v.toString().replace(new RegExp(z(n), s), r) };
524
524
  }
525
525
  };
526
- T = N([
527
- m(2, q),
528
- m(3, ne),
529
- m(4, O),
530
- m(5, Z),
531
- m(6, k(me)),
532
- m(7, k(ye))
533
- ], T);
534
- function X(h) {
526
+ E = D([
527
+ S(2, ee),
528
+ S(3, se),
529
+ S(4, A),
530
+ S(5, q),
531
+ S(6, k(pe)),
532
+ S(7, k(Ue))
533
+ ], E);
534
+ function z(h) {
535
535
  return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
536
536
  }
537
- let E = class extends ee {
537
+ let O = class extends te {
538
538
  constructor(e, t, i) {
539
539
  super();
540
540
  /**
@@ -545,9 +545,9 @@ let E = class extends ee {
545
545
  }
546
546
  async find(e) {
547
547
  this._terminate();
548
- const t = this._univerInstanceService.getCurrentUnitOfType(te.UNIVER_SHEET);
548
+ const t = this._univerInstanceService.getCurrentUnitOfType(ie.UNIVER_SHEET);
549
549
  if (!t) return [];
550
- const i = this._preprocessQuery(e), n = this._renderManagerService.getRenderById(t.getUnitId()).with(De), r = this._injector.createInstance(T, t, n);
550
+ const i = this._preprocessQuery(e), n = this._renderManagerService.getRenderById(t.getUnitId()).with($e), r = this._injector.createInstance(E, t, n);
551
551
  return this._findModelsByUnitId.set(t.getUnitId(), r), r.start(i), [r];
552
552
  }
553
553
  terminate() {
@@ -569,61 +569,65 @@ let E = class extends ee {
569
569
  };
570
570
  }
571
571
  };
572
- E = N([
573
- m(0, q),
574
- m(1, ne),
575
- m(2, k(A))
576
- ], E);
572
+ O = D([
573
+ S(0, ee),
574
+ S(1, se),
575
+ S(2, k(N))
576
+ ], O);
577
577
  const g = { hit: !1, replaceable: !1, isFormula: !1, rawData: null };
578
- function tt(h, e, t, i, n) {
579
- const { findBy: r } = i, s = r === b.FORMULA, o = h.getCellRaw(e, t);
580
- return g.rawData = o, !(o != null && o.f) ? (g.isFormula = !1, W(n, i) ? o ? (g.hit = !0, g.replaceable = !0) : (g.hit = !0, g.replaceable = !1) : (g.hit = !1, g.replaceable = !1), g) : (g.isFormula = !0, s ? W({ v: o.f }, i) ? (g.hit = !0, g.replaceable = !0, g) : (g.hit = !1, g.replaceable = !1, g) : (g.replaceable = !1, W(n, i) ? g.hit = !0 : g.hit = !1, g));
578
+ function it(h, e, t, i, n) {
579
+ const { findBy: r } = i, s = r === M.FORMULA, o = h.getCellRaw(e, t);
580
+ return g.rawData = o, !(o != null && o.f) ? (g.isFormula = !1, H(n, i) ? o ? (g.hit = !0, g.replaceable = !0) : (g.hit = !0, g.replaceable = !1) : (g.hit = !1, g.replaceable = !1), g) : (g.isFormula = !0, s ? H({ v: o.f }, i) ? (g.hit = !0, g.replaceable = !0, g) : (g.hit = !1, g.replaceable = !1, g) : (g.replaceable = !1, H(n, i) ? g.hit = !0 : g.hit = !1, g));
581
581
  }
582
- function W(h, e) {
583
- let t = it(h);
584
- return t ? e.matchesTheWholeCell ? (t = nt(t), e.caseSensitive ? t === e.findString : t.toLowerCase() === e.findString) : e.caseSensitive ? t.indexOf(e.findString) > -1 : t.toLowerCase().indexOf(e.findString) > -1 : !1;
582
+ function H(h, e) {
583
+ let t = nt(h);
584
+ return t ? e.matchesTheWholeCell ? (t = st(t), e.caseSensitive ? t === e.findString : t.toLowerCase() === e.findString) : e.caseSensitive ? t.indexOf(e.findString) > -1 : t.toLowerCase().indexOf(e.findString) > -1 : !1;
585
585
  }
586
- function it(h) {
586
+ function nt(h) {
587
587
  var t, i, n;
588
588
  const e = (n = (i = (t = h == null ? void 0 : h.p) == null ? void 0 : t.body) == null ? void 0 : i.dataStream) != null ? n : h == null ? void 0 : h.v;
589
589
  return typeof e == "number" ? `${e}` : typeof e == "boolean" ? e ? "1" : "0" : e;
590
590
  }
591
- function nt(h) {
591
+ function st(h) {
592
592
  return h.replace(/^ +/g, "").replace(/ +$/g, "");
593
593
  }
594
- const st = "sheets-find-replace.config", z = {};
595
- var rt = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, ht = (h, e, t) => e in h ? rt(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t, ct = (h, e, t, i) => {
596
- for (var n = i > 1 ? void 0 : i ? ot(e, t) : e, r = h.length - 1, s; r >= 0; r--)
594
+ const rt = "@univerjs/sheets-find-replace", ot = "0.17.0", oe = {
595
+ name: rt,
596
+ version: ot
597
+ }, ht = "sheets-find-replace.config", J = {};
598
+ var ct = Object.defineProperty, at = Object.getOwnPropertyDescriptor, lt = (h, e, t) => e in h ? ct(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t, dt = (h, e, t, i) => {
599
+ for (var n = i > 1 ? void 0 : i ? at(e, t) : e, r = h.length - 1, s; r >= 0; r--)
597
600
  (s = h[r]) && (n = s(n) || n);
598
601
  return n;
599
- }, J = (h, e) => (t, i) => e(t, i, h), re = (h, e, t) => ht(h, typeof e != "symbol" ? e + "" : e, t);
600
- const at = "SHEET_FIND_REPLACE_PLUGIN";
601
- let y = class extends Me {
602
- constructor(h = z, e, t) {
602
+ }, Z = (h, e) => (t, i) => e(t, i, h), U = (h, e, t) => lt(h, typeof e != "symbol" ? e + "" : e, t);
603
+ let w = class extends xe {
604
+ constructor(h = J, e, t) {
603
605
  super(), this._config = h, this._injector = e, this._configService = t;
604
- const { ...i } = xe(
606
+ const { ...i } = ye(
605
607
  {},
606
- z,
608
+ J,
607
609
  this._config
608
610
  );
609
- this._configService.setConfig(st, i);
611
+ this._configService.setConfig(ht, i);
610
612
  }
611
613
  onStarting() {
612
- [[x]].forEach((h) => this._injector.add(h));
614
+ [[y]].forEach((h) => this._injector.add(h));
613
615
  }
614
616
  onSteady() {
615
- this._injector.get(x);
617
+ this._injector.get(y);
616
618
  }
617
619
  };
618
- re(y, "pluginName", at);
619
- re(y, "type", te.UNIVER_SHEET);
620
- y = ct([
621
- we(j, j, Ne),
622
- J(1, k(A)),
623
- J(2, be)
624
- ], y);
620
+ U(w, "pluginName", "SHEET_FIND_REPLACE_PLUGIN");
621
+ U(w, "packageName", oe.name);
622
+ U(w, "version", oe.version);
623
+ U(w, "type", ie.UNIVER_SHEET);
624
+ w = dt([
625
+ be(V, V, De),
626
+ Z(1, k(N)),
627
+ Z(2, Me)
628
+ ], w);
625
629
  export {
626
- se as SheetReplaceCommand,
627
- x as SheetsFindReplaceController,
628
- y as UniverSheetsFindReplacePlugin
630
+ re as SheetReplaceCommand,
631
+ y as SheetsFindReplaceController,
632
+ w as UniverSheetsFindReplacePlugin
629
633
  };
@@ -14,6 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { SheetReplaceCommand } from './commands/commands/sheet-replace.command';
17
- export type { IUniverSheetsFindReplaceConfig } from './controllers/config.schema';
17
+ export type { IUniverSheetsFindReplaceConfig } from './config/config';
18
18
  export { SheetsFindReplaceController } from './controllers/sheet-find-replace.controller';
19
19
  export { UniverSheetsFindReplacePlugin } from './plugin';
@@ -1,10 +1,12 @@
1
- import { IUniverSheetsFindReplaceConfig } from './controllers/config.schema';
1
+ import { IUniverSheetsFindReplaceConfig } from './config/config';
2
2
  import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
3
  export declare class UniverSheetsFindReplacePlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected readonly _injector: Injector;
6
6
  private readonly _configService;
7
7
  static pluginName: string;
8
+ static packageName: string;
9
+ static version: string;
8
10
  static type: UniverInstanceType;
9
11
  constructor(_config: Partial<IUniverSheetsFindReplaceConfig> | undefined, _injector: Injector, _configService: IConfigService);
10
12
  onStarting(): void;