@univerjs/sheets-find-replace 0.10.8 → 0.10.9-nightly.202509260614
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 +185 -172
- package/lib/index.js +185 -172
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
- package/LICENSE +0 -176
package/lib/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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 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 = {
|
|
11
11
|
id: "sheet.command.replace",
|
|
12
|
-
type:
|
|
12
|
+
type: H.COMMAND,
|
|
13
13
|
handler: async (h, e) => {
|
|
14
|
-
const t = h.get(_e), i = h.get(
|
|
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, {
|
|
15
15
|
unitId: n,
|
|
16
16
|
subUnitId: c.subUnitId,
|
|
17
17
|
value: c.value
|
|
18
18
|
})));
|
|
19
|
-
return s.dispose(),
|
|
19
|
+
return s.dispose(), Ke(o, r);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
function
|
|
22
|
+
function Ke(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 Qe extends We {
|
|
30
30
|
constructor(t, i) {
|
|
31
31
|
super(t, i);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
f(this, "_activated", !1);
|
|
33
|
+
f(this, "_inHiddenRange", !1);
|
|
34
|
+
f(this, "_color");
|
|
35
35
|
i && this.setShapeProps(i);
|
|
36
36
|
}
|
|
37
37
|
setShapeProps(t) {
|
|
@@ -42,7 +42,7 @@ class Ke extends Fe {
|
|
|
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
|
+
He.drawWith(t, {
|
|
46
46
|
width: this.width,
|
|
47
47
|
height: this.height,
|
|
48
48
|
fill: n,
|
|
@@ -52,75 +52,75 @@ class Ke extends Fe {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function Y(h, e) {
|
|
56
56
|
return h.startRow === e.startRow && h.startColumn === e.startColumn;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function K(h, e) {
|
|
59
59
|
return h.startRow < e.startRow || h.startRow === e.startRow && h.startColumn <= e.startColumn;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function Q(h, e) {
|
|
62
62
|
return h.startColumn < e.startColumn || h.startColumn === e.startColumn && h.startRow <= e.startRow;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Xe(h, e) {
|
|
65
65
|
return h.startRow > e.startRow || h.startRow === e.startRow && h.startColumn >= e.startColumn;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function ze(h, e) {
|
|
68
68
|
return h.startColumn > e.startColumn || h.startColumn === e.startColumn && h.startRow >= e.startRow;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function Je(h, e) {
|
|
71
71
|
const { range: t } = h, { startRow: i, startColumn: n } = t, r = e.getMergedCell(i, n);
|
|
72
|
-
return r ?
|
|
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 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--)
|
|
76
76
|
(s = h[r]) && (n = s(n) || n);
|
|
77
77
|
return n;
|
|
78
78
|
}, m = (h, e) => (t, i) => e(t, i, h);
|
|
79
|
-
let
|
|
79
|
+
let x = class extends ee {
|
|
80
80
|
constructor(e, t, i, n, r) {
|
|
81
81
|
super();
|
|
82
|
-
|
|
82
|
+
f(this, "_provider");
|
|
83
83
|
this._injector = e, this._findReplaceController = t, this._contextService = i, this._findReplaceService = n, this._commandService = r, this._init(), this._initCommands();
|
|
84
84
|
}
|
|
85
85
|
dispose() {
|
|
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(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()));
|
|
91
91
|
}
|
|
92
92
|
_initCommands() {
|
|
93
|
-
[
|
|
93
|
+
[se].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
|
|
97
|
-
m(0,
|
|
98
|
-
m(1,
|
|
99
|
-
m(2,
|
|
100
|
-
m(3,
|
|
101
|
-
m(4,
|
|
102
|
-
],
|
|
103
|
-
const
|
|
104
|
-
let
|
|
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 {
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
f(this, "_matchesUpdate$", new G());
|
|
109
|
+
f(this, "matchesUpdate$", this._matchesUpdate$.asObservable());
|
|
110
|
+
f(this, "_activelyChangingMatch$", new G());
|
|
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());
|
|
114
114
|
/** Hold all matches in the currently searching scope. */
|
|
115
|
-
|
|
115
|
+
f(this, "_matches", []);
|
|
116
116
|
/** Position of the current focused ISheetCellMatch, starting from 1. */
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
f(this, "_matchesPosition", 0);
|
|
118
|
+
f(this, "_activeHighlightIndex", -1);
|
|
119
|
+
f(this, "_highlightShapes", []);
|
|
120
|
+
f(this, "_currentHighlightShape", null);
|
|
121
121
|
/** This properties holds the query params during this searching session. */
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
f(this, "_query", null);
|
|
123
|
+
f(this, "_workbookSelections");
|
|
124
124
|
this._workbook = e, this._sheetSkeletonManagerService = t, this._univerInstanceService = i, this._renderManagerService = n, this._commandService = r, this._contextService = s, this._themeService = o, this._workbookSelections = c.getWorkbookSelections(this.unitId);
|
|
125
125
|
}
|
|
126
126
|
get _matchesCount() {
|
|
@@ -145,11 +145,11 @@ let F = class extends Oe {
|
|
|
145
145
|
return this._matches;
|
|
146
146
|
}
|
|
147
147
|
start(e) {
|
|
148
|
-
switch (this._query = e, e.findBy ===
|
|
149
|
-
case
|
|
148
|
+
switch (this._query = e, e.findBy === b.FORMULA ? this._toggleDisplayRawFormula(!0) : this._toggleDisplayRawFormula(!1), e.findScope) {
|
|
149
|
+
case R.UNIT:
|
|
150
150
|
this.findInWorkbook(e);
|
|
151
151
|
break;
|
|
152
|
-
case
|
|
152
|
+
case R.SUBUNIT:
|
|
153
153
|
default:
|
|
154
154
|
this.findInActiveWorksheet(e);
|
|
155
155
|
break;
|
|
@@ -157,14 +157,14 @@ let F = class extends Oe {
|
|
|
157
157
|
}
|
|
158
158
|
focusSelection() {
|
|
159
159
|
const e = this.currentMatch;
|
|
160
|
-
e && this._commandService.executeCommand(
|
|
160
|
+
e && this._commandService.executeCommand(Ue.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(Te, 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 F = class extends Oe {
|
|
|
184
184
|
return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(() => {
|
|
185
185
|
this._updateFindHighlight(), this._updateCurrentHighlightShape(this._activeHighlightIndex);
|
|
186
186
|
})), this.disposeWithMe(
|
|
187
|
-
|
|
187
|
+
F(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(M(([s, o]) => s.id === Pe.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 F = class extends Oe {
|
|
|
192
192
|
this._matchesByWorksheet.has(o) && this._findNextMatchOnActiveSheetChange(s);
|
|
193
193
|
})
|
|
194
194
|
), this.disposeWithMe(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
([s]) => s.type ===
|
|
195
|
+
F(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(
|
|
196
|
+
M(
|
|
197
|
+
([s]) => s.type === H.MUTATION && s.params.unitId === this._workbook.getUnitId()
|
|
198
198
|
),
|
|
199
|
-
|
|
199
|
+
je(600, void 0, { leading: !1, trailing: !0 })
|
|
200
200
|
).subscribe(() => r())
|
|
201
201
|
), r(), i;
|
|
202
202
|
}
|
|
@@ -220,7 +220,7 @@ let F = class extends Oe {
|
|
|
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) => !Je(u, c))) != null ? d : !1;
|
|
224
224
|
};
|
|
225
225
|
let n, r = !0, s = !1;
|
|
226
226
|
const o = () => {
|
|
@@ -232,12 +232,12 @@ let F = class extends Oe {
|
|
|
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
|
+
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())
|
|
239
239
|
return !0;
|
|
240
|
-
if (c.id ===
|
|
240
|
+
if (c.id === Be.id && c.params.unitId === t) {
|
|
241
241
|
const l = i();
|
|
242
242
|
return l === !1 && s === !1 ? !1 : (s = l, !0);
|
|
243
243
|
}
|
|
@@ -245,40 +245,40 @@ let F = class extends Oe {
|
|
|
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(Ge(1))
|
|
249
|
+
).pipe(Ye(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 === w.COLUMN ? e.iterateByColumn : e.iterateByRow).bind(e)(i);
|
|
254
254
|
for (const l of c) {
|
|
255
|
-
const { row: a, col: d, colSpan: u, rowSpan:
|
|
255
|
+
const { row: a, col: d, colSpan: u, rowSpan: _, value: S } = l;
|
|
256
256
|
if (r != null && r(a, d) || !S || e.getRowFiltered(a))
|
|
257
257
|
continue;
|
|
258
|
-
const { hit:
|
|
259
|
-
if (
|
|
260
|
-
const
|
|
261
|
-
provider:
|
|
258
|
+
const { hit: I, replaceable: C, isFormula: p } = tt(e, a, d, t, S);
|
|
259
|
+
if (I) {
|
|
260
|
+
const U = {
|
|
261
|
+
provider: qe,
|
|
262
262
|
unitId: n,
|
|
263
|
-
replaceable:
|
|
264
|
-
isFormula:
|
|
263
|
+
replaceable: C,
|
|
264
|
+
isFormula: p,
|
|
265
265
|
range: {
|
|
266
266
|
subUnitId: o,
|
|
267
267
|
range: {
|
|
268
268
|
startRow: a,
|
|
269
269
|
startColumn: d,
|
|
270
270
|
endColumn: d + (u != null ? u : 1) - 1,
|
|
271
|
-
endRow: a + (
|
|
271
|
+
endRow: a + (_ != null ? _ : 1) - 1
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
};
|
|
275
|
-
s.push(
|
|
275
|
+
s.push(U);
|
|
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 === w.ROW ? K : Q, 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,21 +305,34 @@ let F = class extends Oe {
|
|
|
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 ve(s).toRgb(), c = this._workbook.getActiveSheet();
|
|
309
309
|
if (!c)
|
|
310
310
|
return;
|
|
311
|
-
const l = c.getSheetId(), a = r.filter((u) => u.range.subUnitId === l).map((u,
|
|
312
|
-
const { startColumn: S, startRow:
|
|
313
|
-
|
|
314
|
-
|
|
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;
|
|
314
|
+
for (let v = I; v <= p; v++)
|
|
315
|
+
if (c.getRowRawVisible(v)) {
|
|
316
|
+
P = !1;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
let B = !0;
|
|
320
|
+
for (let v = S; v <= C; v++)
|
|
321
|
+
if (c.getColVisible(v)) {
|
|
322
|
+
B = !1;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
const ae = P || B, le = B ? 2 : he - D, de = P ? 2 : ce - $, ue = {
|
|
326
|
+
left: D,
|
|
327
|
+
top: $,
|
|
315
328
|
color: o,
|
|
316
|
-
width:
|
|
317
|
-
height:
|
|
329
|
+
width: le,
|
|
330
|
+
height: de,
|
|
318
331
|
evented: !1,
|
|
319
|
-
inHiddenRange:
|
|
320
|
-
zIndex:
|
|
332
|
+
inHiddenRange: ae,
|
|
333
|
+
zIndex: et
|
|
321
334
|
};
|
|
322
|
-
return new
|
|
335
|
+
return new Qe(`find-highlight-${_}`, ue);
|
|
323
336
|
});
|
|
324
337
|
n.addObjects(a), this._highlightShapes = a, n.makeDirty();
|
|
325
338
|
}
|
|
@@ -333,13 +346,13 @@ let F = class extends Oe {
|
|
|
333
346
|
}
|
|
334
347
|
}
|
|
335
348
|
_getSheetObject() {
|
|
336
|
-
return
|
|
349
|
+
return $e(this._univerInstanceService, this._renderManagerService);
|
|
337
350
|
}
|
|
338
351
|
_focusMatch(e) {
|
|
339
352
|
var i;
|
|
340
353
|
const t = e.range.subUnitId;
|
|
341
|
-
t !== ((i = this._workbook.getActiveSheet()) == null ? void 0 : i.getSheetId()) && this._commandService.executeCommand(
|
|
342
|
-
|
|
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,
|
|
343
356
|
{ range: e.range.range },
|
|
344
357
|
{ fromFindReplace: !0 }
|
|
345
358
|
);
|
|
@@ -360,8 +373,8 @@ let F = class extends Oe {
|
|
|
360
373
|
return null;
|
|
361
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);
|
|
362
375
|
if (s) {
|
|
363
|
-
const [u,
|
|
364
|
-
return this._matchesPosition =
|
|
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;
|
|
365
378
|
}
|
|
366
379
|
return this._matchesPosition = 0, this._updateCurrentHighlightShape(), null;
|
|
367
380
|
}
|
|
@@ -371,8 +384,8 @@ let F = class extends Oe {
|
|
|
371
384
|
return null;
|
|
372
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);
|
|
373
386
|
if (s) {
|
|
374
|
-
const [u,
|
|
375
|
-
return this._matchesPosition =
|
|
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;
|
|
376
389
|
}
|
|
377
390
|
return this._matchesPosition = 0, this._updateCurrentHighlightShape(), null;
|
|
378
391
|
}
|
|
@@ -393,7 +406,7 @@ let F = class extends Oe {
|
|
|
393
406
|
const c = this._matches.length - 1;
|
|
394
407
|
return [this._matches[c], c];
|
|
395
408
|
}
|
|
396
|
-
if (this._query.findScope !==
|
|
409
|
+
if (this._query.findScope !== R.UNIT)
|
|
397
410
|
return this._findPreviousMatchByRange(this._matches, n.range);
|
|
398
411
|
const r = (o = this._workbook.getActiveSheet()) == null ? void 0 : o.getSheetId();
|
|
399
412
|
if (!r)
|
|
@@ -416,7 +429,7 @@ let F = class extends Oe {
|
|
|
416
429
|
const n = this._workbookSelections.getCurrentLastSelection();
|
|
417
430
|
if (i || !n)
|
|
418
431
|
return [this._matches[0], 0];
|
|
419
|
-
if (this._query.findScope !==
|
|
432
|
+
if (this._query.findScope !== R.UNIT)
|
|
420
433
|
return this._findNextMatchByRange(this._matches, n.range, t);
|
|
421
434
|
const r = (o = this._workbook.getActiveSheet()) == null ? void 0 : o.getSheetId();
|
|
422
435
|
if (!r)
|
|
@@ -425,20 +438,20 @@ let F = class extends Oe {
|
|
|
425
438
|
return s ? this._findNextMatchByRange(this._matchesByWorksheet.get(s), n.range) : null;
|
|
426
439
|
}
|
|
427
440
|
_findPreviousWorksheetThatHasAMatch(e, t = !1) {
|
|
428
|
-
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 ? L(i, n + 1) : i.slice(0, n + 1)).findLast((o) => this._matchesByWorksheet.has(o));
|
|
429
442
|
return s != null ? s : null;
|
|
430
443
|
}
|
|
431
444
|
_findNextWorksheetThatHasAMatch(e, t = !1) {
|
|
432
|
-
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 ? L(i, n) : i.slice(n)).find((o) => this._matchesByWorksheet.has(o));
|
|
433
446
|
return s != null ? s : null;
|
|
434
447
|
}
|
|
435
448
|
_findNextMatchByRange(e, t, i = !1) {
|
|
436
|
-
const n = this._query.findDirection ===
|
|
449
|
+
const n = this._query.findDirection === w.ROW;
|
|
437
450
|
let r = e.findIndex((o) => {
|
|
438
451
|
const c = o.range.range;
|
|
439
|
-
if (!(n ?
|
|
452
|
+
if (!(n ? K(t, c) : Q(t, c)))
|
|
440
453
|
return !1;
|
|
441
|
-
const a =
|
|
454
|
+
const a = Y(t, c);
|
|
442
455
|
return i ? a : !a;
|
|
443
456
|
});
|
|
444
457
|
r === -1 && (r = e.length - 1);
|
|
@@ -446,12 +459,12 @@ let F = class extends Oe {
|
|
|
446
459
|
return [s, this._matches.findIndex((o) => o === s)];
|
|
447
460
|
}
|
|
448
461
|
_findPreviousMatchByRange(e, t, i = !1) {
|
|
449
|
-
const n = this._query.findDirection ===
|
|
462
|
+
const n = this._query.findDirection === w.ROW;
|
|
450
463
|
let r = this._matches.findLastIndex((o) => {
|
|
451
464
|
const c = o.range.range;
|
|
452
|
-
if (!(n ?
|
|
465
|
+
if (!(n ? Xe(t, c) : ze(t, c)))
|
|
453
466
|
return !1;
|
|
454
|
-
const a =
|
|
467
|
+
const a = Y(t, c);
|
|
455
468
|
return i ? a : !a;
|
|
456
469
|
});
|
|
457
470
|
r === -1 && (r = 0);
|
|
@@ -464,7 +477,7 @@ let F = class extends Oe {
|
|
|
464
477
|
const t = this.currentMatch.range, i = this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId), n = this._getReplacedCellData(
|
|
465
478
|
this.currentMatch,
|
|
466
479
|
i,
|
|
467
|
-
this._query.findBy ===
|
|
480
|
+
this._query.findBy === b.FORMULA,
|
|
468
481
|
this._query.findString,
|
|
469
482
|
e,
|
|
470
483
|
this._query.caseSensitive ? "g" : "ig"
|
|
@@ -477,64 +490,64 @@ let F = class extends Oe {
|
|
|
477
490
|
}
|
|
478
491
|
}
|
|
479
492
|
};
|
|
480
|
-
return this._commandService.executeCommand(
|
|
493
|
+
return this._commandService.executeCommand(ie.id, r);
|
|
481
494
|
}
|
|
482
495
|
async replaceAll(e) {
|
|
483
496
|
if (this._matchesCount === 0 || !this._query)
|
|
484
497
|
return { success: 0, failure: 0 };
|
|
485
|
-
const t = this._workbook.getUnitId(), { findString: i, caseSensitive: n, findBy: r } = this._query, s = r ===
|
|
486
|
-
return
|
|
487
|
-
const u = new
|
|
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);
|
|
488
501
|
a.forEach((S) => {
|
|
489
|
-
const { startColumn:
|
|
490
|
-
|
|
502
|
+
const { startColumn: I, startRow: C } = S.range.range, p = this._getReplacedCellData(S, _, s, i, e, o);
|
|
503
|
+
p && u.setValue(C, I, p);
|
|
491
504
|
}), c.push({
|
|
492
505
|
count: a.length,
|
|
493
506
|
subUnitId: d,
|
|
494
507
|
value: u.getMatrix()
|
|
495
508
|
});
|
|
496
|
-
}), c ? this._commandService.executeCommand(
|
|
509
|
+
}), c ? this._commandService.executeCommand(se.id, {
|
|
497
510
|
unitId: t,
|
|
498
511
|
replacements: c
|
|
499
512
|
}) : { success: 0, failure: 0 };
|
|
500
513
|
}
|
|
501
514
|
_getReplacedCellData(e, t, i, n, r, s) {
|
|
502
|
-
var
|
|
515
|
+
var _;
|
|
503
516
|
const o = e.range.range, { startRow: c, startColumn: l } = o, a = t.getCellRaw(c, l);
|
|
504
517
|
if (e.isFormula)
|
|
505
|
-
return i ? { f: a.f.replace(new RegExp(
|
|
506
|
-
if (!!((
|
|
507
|
-
const S =
|
|
508
|
-
return
|
|
518
|
+
return i ? { f: a.f.replace(new RegExp(X(n), s), r), v: null } : null;
|
|
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 };
|
|
509
522
|
}
|
|
510
|
-
return { v: a.v.toString().replace(new RegExp(
|
|
523
|
+
return { v: a.v.toString().replace(new RegExp(X(n), s), r) };
|
|
511
524
|
}
|
|
512
525
|
};
|
|
513
|
-
|
|
514
|
-
m(2,
|
|
515
|
-
m(3,
|
|
516
|
-
m(4,
|
|
517
|
-
m(5,
|
|
518
|
-
m(6,
|
|
519
|
-
m(7,
|
|
520
|
-
],
|
|
521
|
-
function
|
|
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) {
|
|
522
535
|
return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
523
536
|
}
|
|
524
|
-
let
|
|
537
|
+
let E = class extends ee {
|
|
525
538
|
constructor(e, t, i) {
|
|
526
539
|
super();
|
|
527
540
|
/**
|
|
528
541
|
* Hold all find results in this kind of univer business instances (Workbooks).
|
|
529
542
|
*/
|
|
530
|
-
|
|
543
|
+
f(this, "_findModelsByUnitId", /* @__PURE__ */ new Map());
|
|
531
544
|
this._univerInstanceService = e, this._renderManagerService = t, this._injector = i;
|
|
532
545
|
}
|
|
533
546
|
async find(e) {
|
|
534
547
|
this._terminate();
|
|
535
|
-
const t = this._univerInstanceService.getCurrentUnitOfType(
|
|
548
|
+
const t = this._univerInstanceService.getCurrentUnitOfType(te.UNIVER_SHEET);
|
|
536
549
|
if (!t) return [];
|
|
537
|
-
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(De), r = this._injector.createInstance(T, t, n);
|
|
538
551
|
return this._findModelsByUnitId.set(t.getUnitId(), r), r.start(i), [r];
|
|
539
552
|
}
|
|
540
553
|
terminate() {
|
|
@@ -556,61 +569,61 @@ let W = class extends q {
|
|
|
556
569
|
};
|
|
557
570
|
}
|
|
558
571
|
};
|
|
559
|
-
|
|
560
|
-
m(0,
|
|
561
|
-
m(1,
|
|
562
|
-
m(2,
|
|
563
|
-
],
|
|
572
|
+
E = N([
|
|
573
|
+
m(0, q),
|
|
574
|
+
m(1, ne),
|
|
575
|
+
m(2, k(A))
|
|
576
|
+
], E);
|
|
564
577
|
const g = { hit: !1, replaceable: !1, isFormula: !1, rawData: null };
|
|
565
|
-
function
|
|
566
|
-
const { findBy: r } = i, s = r ===
|
|
567
|
-
return g.rawData = o, !(o != null && o.f) ? (g.isFormula = !1,
|
|
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));
|
|
568
581
|
}
|
|
569
|
-
function
|
|
570
|
-
let t =
|
|
571
|
-
return t ? e.matchesTheWholeCell ? (t =
|
|
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;
|
|
572
585
|
}
|
|
573
|
-
function
|
|
586
|
+
function it(h) {
|
|
574
587
|
var t, i, n;
|
|
575
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;
|
|
576
589
|
return typeof e == "number" ? `${e}` : typeof e == "boolean" ? e ? "1" : "0" : e;
|
|
577
590
|
}
|
|
578
|
-
function
|
|
591
|
+
function nt(h) {
|
|
579
592
|
return h.replace(/^ +/g, "").replace(/ +$/g, "");
|
|
580
593
|
}
|
|
581
|
-
const
|
|
582
|
-
var
|
|
583
|
-
for (var n = i > 1 ? void 0 : i ?
|
|
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--)
|
|
584
597
|
(s = h[r]) && (n = s(n) || n);
|
|
585
598
|
return n;
|
|
586
|
-
},
|
|
587
|
-
const
|
|
588
|
-
let
|
|
589
|
-
constructor(h =
|
|
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) {
|
|
590
603
|
super(), this._config = h, this._injector = e, this._configService = t;
|
|
591
|
-
const { ...i } =
|
|
604
|
+
const { ...i } = xe(
|
|
592
605
|
{},
|
|
593
|
-
|
|
606
|
+
z,
|
|
594
607
|
this._config
|
|
595
608
|
);
|
|
596
|
-
this._configService.setConfig(
|
|
609
|
+
this._configService.setConfig(st, i);
|
|
597
610
|
}
|
|
598
611
|
onStarting() {
|
|
599
|
-
[[
|
|
612
|
+
[[x]].forEach((h) => this._injector.add(h));
|
|
600
613
|
}
|
|
601
614
|
onSteady() {
|
|
602
|
-
this._injector.get(
|
|
615
|
+
this._injector.get(x);
|
|
603
616
|
}
|
|
604
617
|
};
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
],
|
|
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);
|
|
612
625
|
export {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
626
|
+
se as SheetReplaceCommand,
|
|
627
|
+
x as SheetsFindReplaceController,
|
|
628
|
+
y as UniverSheetsFindReplacePlugin
|
|
616
629
|
};
|