@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/cjs/index.js +1 -1
- package/lib/es/index.js +155 -151
- package/lib/index.js +155 -151
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +3 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
- /package/lib/types/{controllers/config.schema.d.ts → config/config.d.ts} +0 -0
package/lib/es/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var f = (h, e, t) =>
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import { SetRangeValuesCommand as
|
|
6
|
-
import { Shape as
|
|
7
|
-
import { FindReplaceController as
|
|
8
|
-
import { SheetSkeletonManagerService as
|
|
9
|
-
import { filter as
|
|
10
|
-
const
|
|
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:
|
|
12
|
+
type: T.COMMAND,
|
|
13
13
|
handler: async (h, e) => {
|
|
14
|
-
const t = h.get(
|
|
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(),
|
|
19
|
+
return s.dispose(), Qe(o, r);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
function
|
|
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
|
|
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
|
-
|
|
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
|
|
55
|
+
function K(h, e) {
|
|
56
56
|
return h.startRow === e.startRow && h.startColumn === e.startColumn;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function Q(h, e) {
|
|
59
59
|
return h.startRow < e.startRow || h.startRow === e.startRow && h.startColumn <= e.startColumn;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function X(h, e) {
|
|
62
62
|
return h.startColumn < e.startColumn || h.startColumn === e.startColumn && h.startRow <= e.startRow;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function ze(h, e) {
|
|
65
65
|
return h.startRow > e.startRow || h.startRow === e.startRow && h.startColumn >= e.startColumn;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function Je(h, e) {
|
|
68
68
|
return h.startColumn > e.startColumn || h.startColumn === e.startColumn && h.startRow >= e.startRow;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
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
|
|
75
|
-
for (var n = i > 1 ? void 0 : i ?
|
|
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
|
-
},
|
|
79
|
-
let
|
|
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(
|
|
90
|
-
this._provider = e, this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)), this.disposeWithMe(this._contextService.subscribeContextValue$(
|
|
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
|
-
[
|
|
93
|
+
[re].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
],
|
|
103
|
-
const
|
|
104
|
-
let
|
|
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
|
|
108
|
+
f(this, "_matchesUpdate$", new Y());
|
|
109
109
|
f(this, "matchesUpdate$", this._matchesUpdate$.asObservable());
|
|
110
|
-
f(this, "_activelyChangingMatch$", new
|
|
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 ===
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
([s]) => s.type ===
|
|
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
|
-
|
|
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) => !
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (c.type ===
|
|
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 ===
|
|
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(
|
|
249
|
-
).pipe(
|
|
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 ===
|
|
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:
|
|
256
|
-
if (r != null && r(a, d) || !
|
|
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 } =
|
|
258
|
+
const { hit: I, replaceable: C, isFormula: p } = it(e, a, d, t, m);
|
|
259
259
|
if (I) {
|
|
260
|
-
const
|
|
261
|
-
provider:
|
|
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(
|
|
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 ===
|
|
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
|
|
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:
|
|
313
|
-
let
|
|
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
|
-
|
|
316
|
+
B = !1;
|
|
317
317
|
break;
|
|
318
318
|
}
|
|
319
|
-
let
|
|
320
|
-
for (let v =
|
|
319
|
+
let F = !0;
|
|
320
|
+
for (let v = m; v <= C; v++)
|
|
321
321
|
if (c.getColVisible(v)) {
|
|
322
|
-
|
|
322
|
+
F = !1;
|
|
323
323
|
break;
|
|
324
324
|
}
|
|
325
|
-
const
|
|
326
|
-
left:
|
|
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:
|
|
330
|
-
height:
|
|
329
|
+
width: de,
|
|
330
|
+
height: ue,
|
|
331
331
|
evented: !1,
|
|
332
|
-
inHiddenRange:
|
|
333
|
-
zIndex:
|
|
332
|
+
inHiddenRange: le,
|
|
333
|
+
zIndex: tt
|
|
334
334
|
};
|
|
335
|
-
return new
|
|
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
|
|
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(
|
|
355
|
-
|
|
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((
|
|
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((
|
|
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 ?
|
|
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 ?
|
|
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 ===
|
|
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 ?
|
|
452
|
+
if (!(n ? Q(t, c) : X(t, c)))
|
|
453
453
|
return !1;
|
|
454
|
-
const a =
|
|
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 ===
|
|
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 ?
|
|
465
|
+
if (!(n ? ze(t, c) : Je(t, c)))
|
|
466
466
|
return !1;
|
|
467
|
-
const a =
|
|
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 ===
|
|
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(
|
|
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 ===
|
|
499
|
-
return
|
|
500
|
-
const u = new
|
|
501
|
-
a.forEach((
|
|
502
|
-
const { startColumn: I, startRow: C } =
|
|
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(
|
|
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(
|
|
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
|
|
521
|
-
return
|
|
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(
|
|
523
|
+
return { v: a.v.toString().replace(new RegExp(z(n), s), r) };
|
|
524
524
|
}
|
|
525
525
|
};
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
],
|
|
534
|
-
function
|
|
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
|
|
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(
|
|
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(
|
|
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
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
],
|
|
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
|
|
579
|
-
const { findBy: r } = i, s = r ===
|
|
580
|
-
return g.rawData = o, !(o != null && o.f) ? (g.isFormula = !1,
|
|
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
|
|
583
|
-
let t =
|
|
584
|
-
return t ? e.matchesTheWholeCell ? (t =
|
|
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
|
|
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
|
|
591
|
+
function st(h) {
|
|
592
592
|
return h.replace(/^ +/g, "").replace(/ +$/g, "");
|
|
593
593
|
}
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
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
|
-
},
|
|
600
|
-
|
|
601
|
-
|
|
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 } =
|
|
606
|
+
const { ...i } = ye(
|
|
605
607
|
{},
|
|
606
|
-
|
|
608
|
+
J,
|
|
607
609
|
this._config
|
|
608
610
|
);
|
|
609
|
-
this._configService.setConfig(
|
|
611
|
+
this._configService.setConfig(ht, i);
|
|
610
612
|
}
|
|
611
613
|
onStarting() {
|
|
612
|
-
[[
|
|
614
|
+
[[y]].forEach((h) => this._injector.add(h));
|
|
613
615
|
}
|
|
614
616
|
onSteady() {
|
|
615
|
-
this._injector.get(
|
|
617
|
+
this._injector.get(y);
|
|
616
618
|
}
|
|
617
619
|
};
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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
|
-
|
|
627
|
-
|
|
628
|
-
|
|
630
|
+
re as SheetReplaceCommand,
|
|
631
|
+
y as SheetsFindReplaceController,
|
|
632
|
+
w as UniverSheetsFindReplacePlugin
|
|
629
633
|
};
|