@univerjs/sheets-find-replace 0.1.11 → 0.1.13-nightly.202406041140
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 +332 -344
- package/lib/locale/en-US.json +8 -0
- package/lib/locale/ru-RU.json +8 -0
- package/lib/locale/zh-CN.json +8 -0
- package/lib/types/controllers/sheet-find-replace.controller.d.ts +3 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +2 -3
- package/lib/umd/index.js +1 -1
- package/package.json +20 -16
- package/LICENSE +0 -176
- package/lib/types/locale/index.d.ts +0 -18
package/lib/es/index.js
CHANGED
|
@@ -1,139 +1,118 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var g = (
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import { Inject as p, Injector as
|
|
6
|
-
import { FindReplaceController as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { SheetSkeletonManagerService as
|
|
10
|
-
import { filter as y, Subject as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
failure: "Failed to replace all cells"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}, St = {
|
|
19
|
-
"sheet-find-replace": {
|
|
20
|
-
replace: {
|
|
21
|
-
"partial-failure": "部分单元格替换失败",
|
|
22
|
-
failure: "替换失败"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}, pt = {
|
|
26
|
-
"sheet-find-replace": {
|
|
27
|
-
replace: {
|
|
28
|
-
"partial-failure": "Не удалось заменить некоторые ячейки",
|
|
29
|
-
failure: "Не удалось заменить все ячейки"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
class Xe extends Be {
|
|
34
|
-
constructor(t, i) {
|
|
35
|
-
super(t, i);
|
|
1
|
+
var ge = Object.defineProperty;
|
|
2
|
+
var fe = (t, e, i) => e in t ? ge(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
3
|
+
var g = (t, e, i) => (fe(t, typeof e != "symbol" ? e + "" : e, i), i);
|
|
4
|
+
import { CommandType as H, IUndoRedoService as _e, ICommandService as T, Rectangle as Se, OnLifecycle as me, LifecycleStages as pe, ThemeService as Ce, Disposable as J, EDITOR_ACTIVATED as Ie, IContextService as q, IUniverInstanceService as E, UniverInstanceType as O, fromCallback as W, ColorKit as ve, rotate as j, groupBy as Re, ObjectMatrix as ke, Tools as we, replaceInDocumentBody as be, DependentOn as Me, Plugin as ye } from "@univerjs/core";
|
|
5
|
+
import { Inject as p, Injector as D } from "@wendellhu/redi";
|
|
6
|
+
import { FindReplaceController as xe, IFindReplaceService as Ue, FindModel as We, FindBy as M, FindScope as v, FindDirection as b, UniverFindReplacePlugin as Pe } from "@univerjs/find-replace";
|
|
7
|
+
import { SetRangeValuesCommand as ee, SelectionManagerService as He, SetWorksheetActiveOperation as Fe, SetSelectionsOperation as Be, SetWorksheetActivateCommand as Te, UniverSheetsPlugin as G } from "@univerjs/sheets";
|
|
8
|
+
import { Shape as Oe, Rect as De, IRenderManagerService as Ae, RENDER_RAW_FORMULA_KEY as Ne } from "@univerjs/engine-render";
|
|
9
|
+
import { SheetSkeletonManagerService as $e, getCoordByCell as Q, getSheetObject as Ve, ScrollToCellCommand as Le } from "@univerjs/sheets-ui";
|
|
10
|
+
import { filter as y, Subject as X, throttleTime as je, merge as Ge, skip as Qe, debounceTime as Xe } from "rxjs";
|
|
11
|
+
var te = /* @__PURE__ */ ((t) => (t[t.View = 0] = "View", t[t.Edit = 1] = "Edit", t[t.ManageCollaborator = 2] = "ManageCollaborator", t[t.Print = 3] = "Print", t[t.Duplicate = 4] = "Duplicate", t[t.Comment = 5] = "Comment", t[t.Copy = 6] = "Copy", t[t.Share = 7] = "Share", t[t.Export = 8] = "Export", t[t.MoveWorksheet = 9] = "MoveWorksheet", t[t.DeleteWorksheet = 10] = "DeleteWorksheet", t[t.HideWorksheet = 11] = "HideWorksheet", t[t.RenameWorksheet = 12] = "RenameWorksheet", t[t.CreateWorksheet = 13] = "CreateWorksheet", t[t.SetWorksheetStyle = 14] = "SetWorksheetStyle", t[t.EditWorksheetCell = 15] = "EditWorksheetCell", t[t.InsertHyperlink = 16] = "InsertHyperlink", t[t.Sort = 17] = "Sort", t[t.Filter = 18] = "Filter", t[t.PivotTable = 19] = "PivotTable", t[t.FloatImg = 20] = "FloatImg", t[t.History = 21] = "History", t[t.RwHgtClWdt = 22] = "RwHgtClWdt", t[t.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", t[t.ViewFilter = 24] = "ViewFilter", t[t.MoveSheet = 25] = "MoveSheet", t[t.DeleteSheet = 26] = "DeleteSheet", t[t.HideSheet = 27] = "HideSheet", t[t.CopySheet = 28] = "CopySheet", t[t.RenameSheet = 29] = "RenameSheet", t[t.CreateSheet = 30] = "CreateSheet", t[t.SelectProtectedCells = 31] = "SelectProtectedCells", t[t.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", t[t.SetCellStyle = 33] = "SetCellStyle", t[t.SetCellValue = 34] = "SetCellValue", t[t.SetRowStyle = 35] = "SetRowStyle", t[t.SetColumnStyle = 36] = "SetColumnStyle", t[t.InsertRow = 37] = "InsertRow", t[t.InsertColumn = 38] = "InsertColumn", t[t.DeleteRow = 39] = "DeleteRow", t[t.DeleteColumn = 40] = "DeleteColumn", t[t.EditExtraObject = 41] = "EditExtraObject", t[t.Delete = 42] = "Delete", t[t.UNRECOGNIZED = -1] = "UNRECOGNIZED", t))(te || {});
|
|
12
|
+
class Ye extends Oe {
|
|
13
|
+
constructor(i, n) {
|
|
14
|
+
super(i, n);
|
|
36
15
|
g(this, "_activated", !1);
|
|
37
16
|
g(this, "_inHiddenRange", !1);
|
|
38
17
|
g(this, "_color");
|
|
39
|
-
|
|
18
|
+
n && this.setShapeProps(n);
|
|
40
19
|
}
|
|
41
|
-
setShapeProps(
|
|
42
|
-
this._activated = !!
|
|
43
|
-
width:
|
|
44
|
-
height:
|
|
20
|
+
setShapeProps(i) {
|
|
21
|
+
this._activated = !!i.activated, typeof i.inHiddenRange < "u" && (this._inHiddenRange = i.inHiddenRange), typeof i.color < "u" && (this._color = i.color), this.transformByState({
|
|
22
|
+
width: i.width,
|
|
23
|
+
height: i.height
|
|
45
24
|
});
|
|
46
25
|
}
|
|
47
|
-
_draw(
|
|
48
|
-
const
|
|
49
|
-
|
|
26
|
+
_draw(i) {
|
|
27
|
+
const n = this._activated, r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`, o = `rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;
|
|
28
|
+
De.drawWith(i, {
|
|
50
29
|
width: this.width,
|
|
51
30
|
height: this.height,
|
|
52
|
-
fill:
|
|
53
|
-
stroke:
|
|
54
|
-
strokeWidth:
|
|
31
|
+
fill: r,
|
|
32
|
+
stroke: n ? o : void 0,
|
|
33
|
+
strokeWidth: n ? 2 : 0,
|
|
55
34
|
evented: !1
|
|
56
35
|
});
|
|
57
36
|
}
|
|
58
37
|
}
|
|
59
|
-
const
|
|
38
|
+
const ie = {
|
|
60
39
|
id: "sheet.command.replace",
|
|
61
|
-
type:
|
|
62
|
-
handler: async (
|
|
63
|
-
const
|
|
64
|
-
unitId:
|
|
40
|
+
type: H.COMMAND,
|
|
41
|
+
handler: async (t, e) => {
|
|
42
|
+
const i = t.get(_e), n = t.get(T), { unitId: r, replacements: o } = e, s = i.__tempBatchingUndoRedo(r), h = await Promise.all(o.map((c) => n.executeCommand(ee.id, {
|
|
43
|
+
unitId: r,
|
|
65
44
|
subUnitId: c.subUnitId,
|
|
66
45
|
value: c.value
|
|
67
46
|
})));
|
|
68
|
-
return s.dispose(),
|
|
47
|
+
return s.dispose(), Ze(h, o);
|
|
69
48
|
}
|
|
70
49
|
};
|
|
71
|
-
function
|
|
72
|
-
let
|
|
73
|
-
return
|
|
74
|
-
const s = e[
|
|
75
|
-
|
|
76
|
-
}), { success:
|
|
50
|
+
function Ze(t, e) {
|
|
51
|
+
let i = 0, n = 0;
|
|
52
|
+
return t.forEach((r, o) => {
|
|
53
|
+
const s = e[o].count;
|
|
54
|
+
r ? i += s : n += s;
|
|
55
|
+
}), { success: i, failure: n };
|
|
77
56
|
}
|
|
78
|
-
function
|
|
79
|
-
return
|
|
57
|
+
function Y(t, e) {
|
|
58
|
+
return t.startRow === e.startRow && t.startColumn === e.startColumn;
|
|
80
59
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
60
|
+
function Z(t, e) {
|
|
61
|
+
return t.startRow < e.startRow || t.startRow === e.startRow && t.startColumn <= e.startColumn;
|
|
83
62
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
63
|
+
function K(t, e) {
|
|
64
|
+
return t.startColumn < e.startColumn || t.startColumn === e.startColumn && t.startRow <= e.startRow;
|
|
86
65
|
}
|
|
87
|
-
function
|
|
88
|
-
return
|
|
66
|
+
function Ke(t, e) {
|
|
67
|
+
return t.startRow > e.startRow || t.startRow === e.startRow && t.startColumn >= e.startColumn;
|
|
89
68
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
69
|
+
function ze(t, e) {
|
|
70
|
+
return t.startColumn > e.startColumn || t.startColumn === e.startColumn && t.startRow >= e.startRow;
|
|
92
71
|
}
|
|
93
|
-
function
|
|
94
|
-
const { range:
|
|
95
|
-
return
|
|
72
|
+
function Je(t, e) {
|
|
73
|
+
const { range: i } = t, { startRow: n, startColumn: r } = i, o = e.getMergedCell(n, r);
|
|
74
|
+
return o ? Se.equals(i, o) : i.endRow === i.startRow && i.endColumn === i.startColumn;
|
|
96
75
|
}
|
|
97
|
-
var
|
|
98
|
-
for (var
|
|
99
|
-
(s =
|
|
100
|
-
return
|
|
101
|
-
}, _ = (
|
|
102
|
-
let
|
|
103
|
-
constructor(e,
|
|
76
|
+
var A = (t, e, i, n) => {
|
|
77
|
+
for (var r = e, o = t.length - 1, s; o >= 0; o--)
|
|
78
|
+
(s = t[o]) && (r = s(r) || r);
|
|
79
|
+
return r;
|
|
80
|
+
}, _ = (t, e) => (i, n) => e(i, n, t);
|
|
81
|
+
let k = class extends J {
|
|
82
|
+
constructor(e, i, n, r, o) {
|
|
104
83
|
super();
|
|
105
84
|
g(this, "_provider");
|
|
106
|
-
this._injector = e, this._findReplaceController =
|
|
85
|
+
this._injector = e, this._findReplaceController = i, this._contextService = n, this._findReplaceService = r, this._commandService = o, this._init(), this._initCommands();
|
|
107
86
|
}
|
|
108
87
|
dispose() {
|
|
109
88
|
super.dispose(), this._provider.dispose();
|
|
110
89
|
}
|
|
111
90
|
_init() {
|
|
112
|
-
const e = this._injector.createInstance(
|
|
91
|
+
const e = this._injector.createInstance(B);
|
|
113
92
|
this._provider = e, this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)), this.disposeWithMe(
|
|
114
|
-
this._contextService.subscribeContextValue$(
|
|
93
|
+
this._contextService.subscribeContextValue$(Ie).pipe(y((i) => !!i)).subscribe(() => this._findReplaceController.closePanel())
|
|
115
94
|
);
|
|
116
95
|
}
|
|
117
96
|
_initCommands() {
|
|
118
|
-
[
|
|
97
|
+
[ie].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
|
|
119
98
|
}
|
|
120
99
|
};
|
|
121
|
-
|
|
122
|
-
me(
|
|
123
|
-
_(0, p(
|
|
124
|
-
_(1, p(
|
|
125
|
-
_(2,
|
|
126
|
-
_(3,
|
|
127
|
-
_(4,
|
|
128
|
-
],
|
|
129
|
-
const qe = "sheets-find-replace-provider",
|
|
130
|
-
let F = class extends
|
|
131
|
-
constructor(e,
|
|
100
|
+
k = A([
|
|
101
|
+
me(pe.Steady, k),
|
|
102
|
+
_(0, p(D)),
|
|
103
|
+
_(1, p(xe)),
|
|
104
|
+
_(2, q),
|
|
105
|
+
_(3, Ue),
|
|
106
|
+
_(4, T)
|
|
107
|
+
], k);
|
|
108
|
+
const qe = "sheets-find-replace-provider", Ee = 1e4;
|
|
109
|
+
let F = class extends We {
|
|
110
|
+
constructor(e, i, n, r, o, s, h, c, a) {
|
|
132
111
|
super();
|
|
133
112
|
// We can directly inject the `FindReplaceService` here, and call its methods instead of using the observables.
|
|
134
|
-
g(this, "_matchesUpdate$", new
|
|
113
|
+
g(this, "_matchesUpdate$", new X());
|
|
135
114
|
g(this, "matchesUpdate$", this._matchesUpdate$.asObservable());
|
|
136
|
-
g(this, "_activelyChangingMatch$", new
|
|
115
|
+
g(this, "_activelyChangingMatch$", new X());
|
|
137
116
|
g(this, "activelyChangingMatch$", this._activelyChangingMatch$.asObservable());
|
|
138
117
|
/** Hold matches by the worksheet they are in. Make it easier to track the next (or previous) match when searching in the whole workbook. */
|
|
139
118
|
g(this, "_matchesByWorksheet", /* @__PURE__ */ new Map());
|
|
@@ -146,7 +125,7 @@ let F = class extends Ue {
|
|
|
146
125
|
g(this, "_currentHighlightShape", null);
|
|
147
126
|
/** This properties holds the query params during this searching session. */
|
|
148
127
|
g(this, "_query", null);
|
|
149
|
-
this._workbook = e, this._univerInstanceService =
|
|
128
|
+
this._workbook = e, this._univerInstanceService = i, this._renderManagerService = n, this._commandService = r, this._contextService = o, this._themeService = s, this._sheetSkeletonManagerService = h, this._selectionManagerService = c, this._findReplaceController = a;
|
|
150
129
|
}
|
|
151
130
|
get _matchesCount() {
|
|
152
131
|
return this._matches.length;
|
|
@@ -170,18 +149,18 @@ let F = class extends Ue {
|
|
|
170
149
|
return this._matches;
|
|
171
150
|
}
|
|
172
151
|
start(e) {
|
|
173
|
-
switch (this._query = e, e.findBy ===
|
|
174
|
-
case
|
|
152
|
+
switch (this._query = e, e.findBy === M.FORMULA ? this._toggleDisplayRawFormula(!0) : this._toggleDisplayRawFormula(!1), e.findScope) {
|
|
153
|
+
case v.UNIT:
|
|
175
154
|
this.findInWorkbook(e);
|
|
176
155
|
break;
|
|
177
|
-
case
|
|
156
|
+
case v.SUBUNIT:
|
|
178
157
|
default:
|
|
179
158
|
this.findInActiveWorksheet(e);
|
|
180
159
|
break;
|
|
181
160
|
}
|
|
182
161
|
}
|
|
183
162
|
_toggleDisplayRawFormula(e) {
|
|
184
|
-
this._contextService.setContextValue(
|
|
163
|
+
this._contextService.setContextValue(Ne, e);
|
|
185
164
|
}
|
|
186
165
|
/**
|
|
187
166
|
* Find all matches in the current workbook no matter which worksheet is activated.
|
|
@@ -189,41 +168,41 @@ let F = class extends Ue {
|
|
|
189
168
|
* @returns the query complete event
|
|
190
169
|
*/
|
|
191
170
|
findInWorkbook(e) {
|
|
192
|
-
const
|
|
193
|
-
let
|
|
194
|
-
const
|
|
195
|
-
const s = this._workbook.getSheets().filter((
|
|
196
|
-
const c = this._findInWorksheet(
|
|
197
|
-
return
|
|
171
|
+
const i = this._workbook.getUnitId();
|
|
172
|
+
let n, r = !0;
|
|
173
|
+
const o = () => {
|
|
174
|
+
const s = this._workbook.getSheets().filter((h) => !h.isSheetHidden()).map((h) => {
|
|
175
|
+
const c = this._findInWorksheet(h, e, i), a = h.getSheetId(), { results: l } = c;
|
|
176
|
+
return l.length ? this._matchesByWorksheet.set(a, c.results) : this._matchesByWorksheet.delete(a), c;
|
|
198
177
|
});
|
|
199
|
-
this._matches = s.map((
|
|
178
|
+
this._matches = s.map((h) => h.results).flat(), this._updateFindHighlight(), r ? (n = { results: this._matches }, r = !1) : this._matchesUpdate$.next(this._matches);
|
|
200
179
|
};
|
|
201
180
|
return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(() => {
|
|
202
181
|
this._updateFindHighlight(), this._updateCurrentHighlightShape(this._activeHighlightIndex);
|
|
203
182
|
})), this.disposeWithMe(
|
|
204
|
-
|
|
205
|
-
y(([s,
|
|
183
|
+
W(this._commandService.onCommandExecuted).pipe(
|
|
184
|
+
y(([s, h]) => s.id === Fe.id && !(h != null && h.fromFindReplace))
|
|
206
185
|
).subscribe(() => {
|
|
207
|
-
const s = this._workbook.getActiveSheet(),
|
|
208
|
-
this._matchesByWorksheet.has(
|
|
186
|
+
const s = this._workbook.getActiveSheet(), h = s.getSheetId();
|
|
187
|
+
this._matchesByWorksheet.has(h) && this._findNextMatchOnActiveSheetChange(s);
|
|
209
188
|
})
|
|
210
189
|
), this.disposeWithMe(
|
|
211
|
-
|
|
190
|
+
W(this._commandService.onCommandExecuted).pipe(
|
|
212
191
|
y(
|
|
213
|
-
([s]) => s.type ===
|
|
192
|
+
([s]) => s.type === H.MUTATION && s.params.unitId === this._workbook.getUnitId()
|
|
214
193
|
),
|
|
215
|
-
|
|
216
|
-
).subscribe(() =>
|
|
217
|
-
),
|
|
194
|
+
je(600, void 0, { leading: !1, trailing: !0 })
|
|
195
|
+
).subscribe(() => o())
|
|
196
|
+
), o(), n;
|
|
218
197
|
}
|
|
219
198
|
/**
|
|
220
199
|
* This method is used in `findInWorkbook`. When the active sheet changes, this method helps to find the next match
|
|
221
200
|
* in the new worksheet.
|
|
222
201
|
*/
|
|
223
202
|
_findNextMatchOnActiveSheetChange(e) {
|
|
224
|
-
let
|
|
225
|
-
const
|
|
226
|
-
s != null && s.length ? ([
|
|
203
|
+
let i, n, r = 0;
|
|
204
|
+
const o = this._matchesByWorksheet.get(e.getSheetId()), s = this._selectionManagerService.getSelections();
|
|
205
|
+
s != null && s.length ? ([i, r] = this._findNextMatchByRange(o, s[0].range), n = o.findIndex((h) => h === i)) : (i = o[0], n = 0, r = this._matches.findIndex((h) => h === i)), this._matchesPosition = r + 1, this._activelyChangingMatch$.next(i), this._activeHighlightIndex = n, this._updateFindHighlight(), this._updateCurrentHighlightShape(n);
|
|
227
206
|
}
|
|
228
207
|
/**
|
|
229
208
|
* Find all matches (only) in the currently activated worksheet.
|
|
@@ -231,321 +210,331 @@ let F = class extends Ue {
|
|
|
231
210
|
* @returns the query complete event
|
|
232
211
|
*/
|
|
233
212
|
findInActiveWorksheet(e) {
|
|
234
|
-
const
|
|
213
|
+
const i = this._workbook.getUnitId(), n = () => {
|
|
235
214
|
var d;
|
|
236
|
-
const c = this._workbook.getActiveSheet(),
|
|
237
|
-
return (d =
|
|
215
|
+
const c = this._workbook.getActiveSheet(), a = this._selectionManagerService.getSelections();
|
|
216
|
+
return (d = a == null ? void 0 : a.some((f) => !Je(f, c))) != null ? d : !1;
|
|
238
217
|
};
|
|
239
|
-
let
|
|
240
|
-
const
|
|
241
|
-
const c = this._workbook.getActiveSheet(),
|
|
242
|
-
s =
|
|
243
|
-
const
|
|
244
|
-
return this._matches = d.results, this._matchesPosition = this._tryRestoreLastMatchesPosition(
|
|
218
|
+
let r, o = !0, s = !1;
|
|
219
|
+
const h = () => {
|
|
220
|
+
const c = this._workbook.getActiveSheet(), a = this.currentMatch;
|
|
221
|
+
s = n();
|
|
222
|
+
const l = this._selectionManagerService.getSelections(), d = s ? this._findInSelections(c, l, e, i) : this._findInWorksheet(c, e, i);
|
|
223
|
+
return this._matches = d.results, this._matchesPosition = this._tryRestoreLastMatchesPosition(a, this._matches), o ? (r = d, o = !1) : this._matchesUpdate$.next(this._matches), this._updateFindHighlight(), d;
|
|
245
224
|
};
|
|
246
225
|
return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(() => this._updateFindHighlight())), this.disposeWithMe(
|
|
247
|
-
|
|
248
|
-
|
|
226
|
+
Ge(
|
|
227
|
+
W(this._commandService.onCommandExecuted).pipe(
|
|
249
228
|
y(([c]) => {
|
|
250
|
-
if (c.type ===
|
|
229
|
+
if (c.type === H.MUTATION && c.params.unitId === this._workbook.getUnitId())
|
|
251
230
|
return !0;
|
|
252
|
-
if (c.id ===
|
|
253
|
-
const
|
|
254
|
-
return
|
|
231
|
+
if (c.id === Be.id && c.params.unitId === i) {
|
|
232
|
+
const a = n();
|
|
233
|
+
return a === !1 && s === !1 ? !1 : (s = a, !0);
|
|
255
234
|
}
|
|
256
235
|
return !1;
|
|
257
236
|
})
|
|
258
237
|
),
|
|
259
238
|
// activeSheet$ is a BehaviorSubject, so we need to skip the first
|
|
260
|
-
this._workbook.activeSheet$.pipe(
|
|
261
|
-
).pipe(
|
|
262
|
-
),
|
|
263
|
-
}
|
|
264
|
-
_findInRange(e,
|
|
265
|
-
const s = [],
|
|
266
|
-
for (const
|
|
267
|
-
const { row:
|
|
268
|
-
if (r != null &&
|
|
239
|
+
this._workbook.activeSheet$.pipe(Qe(1))
|
|
240
|
+
).pipe(Xe(200)).subscribe(() => h())
|
|
241
|
+
), h(), r;
|
|
242
|
+
}
|
|
243
|
+
_findInRange(e, i, n, r, o) {
|
|
244
|
+
const s = [], h = e.getSheetId(), c = (i.findDirection === b.COLUMN ? e.iterateByColumn : e.iterateByRow).bind(e)(n);
|
|
245
|
+
for (const a of c) {
|
|
246
|
+
const { row: l, col: d, colSpan: f, rowSpan: m, value: S } = a;
|
|
247
|
+
if (!this._getFindReplacePermissionCheck({ row: l, col: d, unitId: r, subUnitId: h }) || o != null && o(l, d) || !S || e.getRowFiltered(l))
|
|
269
248
|
continue;
|
|
270
|
-
const { hit:
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
249
|
+
const { hit: R, replaceable: C, isFormula: w } = et(e, l, d, i, S);
|
|
250
|
+
if (R) {
|
|
251
|
+
const U = {
|
|
273
252
|
provider: qe,
|
|
274
|
-
unitId:
|
|
275
|
-
replaceable:
|
|
276
|
-
isFormula:
|
|
253
|
+
unitId: r,
|
|
254
|
+
replaceable: C,
|
|
255
|
+
isFormula: w,
|
|
277
256
|
range: {
|
|
278
|
-
subUnitId:
|
|
257
|
+
subUnitId: h,
|
|
279
258
|
range: {
|
|
280
|
-
startRow:
|
|
259
|
+
startRow: l,
|
|
281
260
|
startColumn: d,
|
|
282
261
|
endColumn: d + (f != null ? f : 1) - 1,
|
|
283
|
-
endRow:
|
|
262
|
+
endRow: l + (m != null ? m : 1) - 1
|
|
284
263
|
}
|
|
285
264
|
}
|
|
286
265
|
};
|
|
287
|
-
s.push(
|
|
266
|
+
s.push(U);
|
|
288
267
|
}
|
|
289
268
|
}
|
|
290
269
|
return { results: s };
|
|
291
270
|
}
|
|
292
|
-
_findInSelections(e,
|
|
293
|
-
const { findDirection:
|
|
294
|
-
return { results:
|
|
271
|
+
_findInSelections(e, i, n, r) {
|
|
272
|
+
const { findDirection: o } = n, s = o === b.ROW ? Z : K, h = /* @__PURE__ */ new Set();
|
|
273
|
+
return { results: i.map((a) => this._findInRange(
|
|
295
274
|
e,
|
|
296
|
-
i,
|
|
297
|
-
l.range,
|
|
298
275
|
n,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
276
|
+
a.range,
|
|
277
|
+
r,
|
|
278
|
+
(l, d) => {
|
|
279
|
+
const f = `${l}-${d}`;
|
|
280
|
+
return h.has(f) ? !0 : (h.add(f), !1);
|
|
302
281
|
}
|
|
303
|
-
).results).flat().sort((
|
|
282
|
+
).results).flat().sort((a, l) => s(a.range.range, l.range.range) ? -1 : 1) };
|
|
304
283
|
}
|
|
305
284
|
/** Find matches in a given worksheet. */
|
|
306
|
-
_findInWorksheet(e,
|
|
307
|
-
const
|
|
308
|
-
return this._findInRange(e,
|
|
285
|
+
_findInWorksheet(e, i, n) {
|
|
286
|
+
const r = e.getRowCount(), o = e.getColumnCount(), s = { startRow: 0, startColumn: 0, endRow: r - 1, endColumn: o - 1 };
|
|
287
|
+
return this._findInRange(e, i, s, n);
|
|
309
288
|
}
|
|
310
289
|
_disposeHighlights() {
|
|
311
290
|
var e;
|
|
312
|
-
this._highlightShapes.forEach((
|
|
313
|
-
|
|
291
|
+
this._highlightShapes.forEach((i) => {
|
|
292
|
+
i.getScene().makeDirty(), i.dispose();
|
|
314
293
|
}), this._highlightShapes = [], (e = this._currentHighlightShape) == null || e.dispose(), this._currentHighlightShape = null;
|
|
315
294
|
}
|
|
316
295
|
_updateFindHighlight() {
|
|
317
|
-
var
|
|
296
|
+
var m, S;
|
|
318
297
|
this._disposeHighlights();
|
|
319
|
-
const e = (
|
|
320
|
-
if (!e || !this._getSheetObject() || ((
|
|
298
|
+
const e = (m = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : m.skeleton;
|
|
299
|
+
if (!e || !this._getSheetObject() || ((S = this._univerInstanceService.getFocusedUnit()) == null ? void 0 : S.getUnitId()) !== this._workbook.getUnitId())
|
|
321
300
|
return;
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
301
|
+
const r = this._workbook.getUnitId(), o = this._renderManagerService.getRenderById(r);
|
|
302
|
+
if (o == null)
|
|
324
303
|
return;
|
|
325
|
-
const { scene: s } =
|
|
326
|
-
const { startColumn:
|
|
327
|
-
left:
|
|
328
|
-
top:
|
|
329
|
-
color:
|
|
330
|
-
width:
|
|
331
|
-
height:
|
|
304
|
+
const { scene: s } = o, h = this._matches, c = this._themeService.getCurrentTheme().gold400, a = new ve(c).toRgb(), l = this._workbook.getActiveSheet(), d = l.getSheetId(), f = h.filter((I) => I.range.subUnitId === d).map((I, R) => {
|
|
305
|
+
const { startColumn: C, startRow: w, endColumn: U, endRow: se } = I.range.range, re = Q(w, C, s, e), oe = Q(se, U, s, e), { startX: N, startY: $ } = re, { endX: he, endY: ce } = oe, V = !l.getRowRawVisible(w), L = !l.getColVisible(C), ae = V || L, le = L ? 2 : he - N, de = V ? 2 : ce - $, ue = {
|
|
306
|
+
left: N,
|
|
307
|
+
top: $,
|
|
308
|
+
color: a,
|
|
309
|
+
width: le,
|
|
310
|
+
height: de,
|
|
332
311
|
evented: !1,
|
|
333
|
-
inHiddenRange:
|
|
312
|
+
inHiddenRange: ae,
|
|
313
|
+
zIndex: Ee
|
|
334
314
|
};
|
|
335
|
-
return new
|
|
315
|
+
return new Ye(`find-highlight-${R}`, ue);
|
|
336
316
|
});
|
|
337
|
-
s.addObjects(f
|
|
317
|
+
s.addObjects(f), this._highlightShapes = f, s.makeDirty();
|
|
338
318
|
}
|
|
339
319
|
_updateCurrentHighlightShape(e) {
|
|
340
|
-
var
|
|
341
|
-
if ((
|
|
342
|
-
const
|
|
343
|
-
if (!
|
|
320
|
+
var i;
|
|
321
|
+
if ((i = this._currentHighlightShape) == null || i.setShapeProps({ activated: !1 }), this._currentHighlightShape = null, e !== void 0) {
|
|
322
|
+
const n = this._highlightShapes[e];
|
|
323
|
+
if (!n)
|
|
344
324
|
return;
|
|
345
|
-
this._currentHighlightShape =
|
|
325
|
+
this._currentHighlightShape = n, n.setShapeProps({ activated: !0 });
|
|
346
326
|
}
|
|
347
327
|
}
|
|
348
328
|
_getSheetObject() {
|
|
349
|
-
return
|
|
329
|
+
return Ve(this._univerInstanceService, this._renderManagerService);
|
|
350
330
|
}
|
|
351
331
|
_focusMatch(e) {
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
{ unitId: this._workbook.getUnitId(), subUnitId:
|
|
332
|
+
const i = e.range.subUnitId;
|
|
333
|
+
i !== this._workbook.getActiveSheet().getSheetId() && this._commandService.syncExecuteCommand(
|
|
334
|
+
Te.id,
|
|
335
|
+
{ unitId: this._workbook.getUnitId(), subUnitId: i },
|
|
356
336
|
{ fromFindReplace: !0 }
|
|
357
337
|
), this._commandService.syncExecuteCommand(
|
|
358
|
-
|
|
338
|
+
Le.id,
|
|
359
339
|
{ range: e.range.range },
|
|
360
340
|
{ fromFindReplace: !0 }
|
|
361
341
|
);
|
|
362
342
|
}
|
|
363
|
-
_tryRestoreLastMatchesPosition(e,
|
|
343
|
+
_tryRestoreLastMatchesPosition(e, i) {
|
|
364
344
|
if (!e)
|
|
365
345
|
return 0;
|
|
366
|
-
const { subUnitId:
|
|
367
|
-
if (
|
|
346
|
+
const { subUnitId: n } = e.range, { startColumn: r, startRow: o } = e.range.range, s = i.findIndex((h) => {
|
|
347
|
+
if (n !== h.range.subUnitId)
|
|
368
348
|
return !1;
|
|
369
|
-
const { startColumn: c, startRow:
|
|
370
|
-
return c ===
|
|
349
|
+
const { startColumn: c, startRow: a } = h.range.range;
|
|
350
|
+
return c === r && a === o;
|
|
371
351
|
});
|
|
372
352
|
return s > -1 ? s + 1 : 0;
|
|
373
353
|
}
|
|
374
354
|
moveToNextMatch(e) {
|
|
375
|
-
var s,
|
|
355
|
+
var s, h, c;
|
|
376
356
|
if (!this._matches.length)
|
|
377
357
|
return null;
|
|
378
|
-
const
|
|
379
|
-
if (
|
|
380
|
-
const [
|
|
381
|
-
return this._matchesPosition =
|
|
358
|
+
const i = (s = e == null ? void 0 : e.loop) != null ? s : !1, n = (h = e == null ? void 0 : e.stayIfOnMatch) != null ? h : !1, r = (c = e == null ? void 0 : e.noFocus) != null ? c : !1, o = this._findNextMatch(i, n);
|
|
359
|
+
if (o) {
|
|
360
|
+
const [a, l] = o;
|
|
361
|
+
return this._matchesPosition = l + 1, this._query.findScope === v.UNIT ? this._activeHighlightIndex = this._matchesByWorksheet.get(a.range.subUnitId).findIndex((d) => d === a) : this._activeHighlightIndex = l, r || this._focusMatch(a), this._workbook.getActiveSheet().getSheetId() === a.range.subUnitId && this._updateCurrentHighlightShape(this._activeHighlightIndex), a;
|
|
382
362
|
}
|
|
383
363
|
return this._matchesPosition = 0, this._updateCurrentHighlightShape(), null;
|
|
384
364
|
}
|
|
385
365
|
moveToPreviousMatch(e) {
|
|
386
|
-
var s,
|
|
366
|
+
var s, h, c;
|
|
387
367
|
if (!this._matches.length)
|
|
388
368
|
return null;
|
|
389
|
-
const
|
|
390
|
-
if (
|
|
391
|
-
const [
|
|
392
|
-
return this._matchesPosition =
|
|
369
|
+
const i = (s = e == null ? void 0 : e.loop) != null ? s : !1, n = (h = e == null ? void 0 : e.stayIfOnMatch) != null ? h : !1, r = (c = e == null ? void 0 : e.noFocus) != null ? c : !1, o = this._findPreviousMatch(i, n);
|
|
370
|
+
if (o) {
|
|
371
|
+
const [a, l] = o;
|
|
372
|
+
return this._matchesPosition = l + 1, this._query.findScope === v.UNIT ? this._activeHighlightIndex = this._matchesByWorksheet.get(a.range.subUnitId).findIndex((d) => d === a) : this._activeHighlightIndex = l, r || this._focusMatch(a), this._workbook.getActiveSheet().getSheetId() === a.range.subUnitId && this._updateCurrentHighlightShape(this._activeHighlightIndex), a;
|
|
393
373
|
}
|
|
394
374
|
return this._matchesPosition = 0, this._updateCurrentHighlightShape(), null;
|
|
395
375
|
}
|
|
396
|
-
_findPreviousMatch(e = !1,
|
|
376
|
+
_findPreviousMatch(e = !1, i = !1) {
|
|
397
377
|
if (this.currentMatch) {
|
|
398
|
-
const s = this._matches.findIndex((
|
|
399
|
-
if (
|
|
378
|
+
const s = this._matches.findIndex((l) => l === this.currentMatch);
|
|
379
|
+
if (i)
|
|
400
380
|
return [this.currentMatch, s];
|
|
401
|
-
const
|
|
402
|
-
if (!e &&
|
|
381
|
+
const h = s - 1;
|
|
382
|
+
if (!e && h < 0)
|
|
403
383
|
return null;
|
|
404
|
-
const c = this._matches.length,
|
|
405
|
-
return [this._matches[
|
|
384
|
+
const c = this._matches.length, a = (h + c) % c;
|
|
385
|
+
return [this._matches[a], a];
|
|
406
386
|
}
|
|
407
|
-
const
|
|
408
|
-
if (!(
|
|
387
|
+
const n = this._selectionManagerService.getSelections();
|
|
388
|
+
if (!(n != null && n.length))
|
|
409
389
|
return [this._matches[0], 0];
|
|
410
|
-
if (this._query.findScope !==
|
|
411
|
-
return this._findPreviousMatchByRange(this._matches,
|
|
412
|
-
const
|
|
413
|
-
return
|
|
390
|
+
if (this._query.findScope !== v.UNIT)
|
|
391
|
+
return this._findPreviousMatchByRange(this._matches, n[0].range);
|
|
392
|
+
const r = this._workbook.getActiveSheet().getSheetId(), o = this._findPreviousWorksheetThatHasAMatch(r, e);
|
|
393
|
+
return o ? this._findPreviousMatchByRange(this._matchesByWorksheet.get(o), n[0].range) : null;
|
|
414
394
|
}
|
|
415
|
-
_findNextMatch(e = !1,
|
|
395
|
+
_findNextMatch(e = !1, i = !1) {
|
|
416
396
|
if (this.currentMatch) {
|
|
417
|
-
const s = this._matches.findIndex((
|
|
418
|
-
if (
|
|
397
|
+
const s = this._matches.findIndex((l) => l === this.currentMatch);
|
|
398
|
+
if (i)
|
|
419
399
|
return [this.currentMatch, s];
|
|
420
|
-
const
|
|
421
|
-
if (!e &&
|
|
400
|
+
const h = s + 1, c = this._matches.length;
|
|
401
|
+
if (!e && h >= c)
|
|
422
402
|
return null;
|
|
423
|
-
const
|
|
424
|
-
return [this._matches[
|
|
403
|
+
const a = h % c;
|
|
404
|
+
return [this._matches[a], a];
|
|
425
405
|
}
|
|
426
|
-
const
|
|
427
|
-
if (!(
|
|
406
|
+
const n = this._selectionManagerService.getSelections();
|
|
407
|
+
if (!(n != null && n.length))
|
|
428
408
|
return [this._matches[0], 0];
|
|
429
|
-
if (this._query.findScope !==
|
|
430
|
-
return this._findNextMatchByRange(this._matches,
|
|
431
|
-
const
|
|
432
|
-
return
|
|
409
|
+
if (this._query.findScope !== v.UNIT)
|
|
410
|
+
return this._findNextMatchByRange(this._matches, n[0].range, i);
|
|
411
|
+
const r = this._workbook.getActiveSheet().getSheetId(), o = this._findNextWorksheetThatHasAMatch(r, e);
|
|
412
|
+
return o ? this._findNextMatchByRange(this._matchesByWorksheet.get(o), n[0].range) : null;
|
|
433
413
|
}
|
|
434
|
-
_findPreviousWorksheetThatHasAMatch(e,
|
|
435
|
-
const
|
|
414
|
+
_findPreviousWorksheetThatHasAMatch(e, i = !1) {
|
|
415
|
+
const n = this._workbook.getSheetOrders(), r = n.findIndex((h) => h === e), s = (i ? j(n, r + 1) : n.slice(0, r + 1)).findLast((h) => this._matchesByWorksheet.has(h));
|
|
436
416
|
return s != null ? s : null;
|
|
437
417
|
}
|
|
438
|
-
_findNextWorksheetThatHasAMatch(e,
|
|
439
|
-
const
|
|
418
|
+
_findNextWorksheetThatHasAMatch(e, i = !1) {
|
|
419
|
+
const n = this._workbook.getSheetOrders(), r = n.findIndex((h) => h === e), s = (i ? j(n, r) : n.slice(r)).find((h) => this._matchesByWorksheet.has(h));
|
|
440
420
|
return s != null ? s : null;
|
|
441
421
|
}
|
|
442
|
-
_findNextMatchByRange(e,
|
|
443
|
-
const
|
|
444
|
-
let
|
|
445
|
-
const c =
|
|
446
|
-
if (!(
|
|
422
|
+
_findNextMatchByRange(e, i, n = !1) {
|
|
423
|
+
const r = this._query.findDirection === b.ROW;
|
|
424
|
+
let o = e.findIndex((h) => {
|
|
425
|
+
const c = h.range.range;
|
|
426
|
+
if (!(r ? Z(i, c) : K(i, c)))
|
|
447
427
|
return !1;
|
|
448
|
-
const
|
|
449
|
-
return
|
|
428
|
+
const l = Y(i, c);
|
|
429
|
+
return n ? l : !l;
|
|
450
430
|
});
|
|
451
|
-
|
|
452
|
-
const s = e[
|
|
453
|
-
return [s, this._matches.findIndex((
|
|
454
|
-
}
|
|
455
|
-
_findPreviousMatchByRange(e,
|
|
456
|
-
const
|
|
457
|
-
let
|
|
458
|
-
const c =
|
|
459
|
-
if (!(
|
|
431
|
+
o === -1 && (o = e.length - 1);
|
|
432
|
+
const s = e[o];
|
|
433
|
+
return [s, this._matches.findIndex((h) => h === s)];
|
|
434
|
+
}
|
|
435
|
+
_findPreviousMatchByRange(e, i, n = !1) {
|
|
436
|
+
const r = this._query.findDirection === b.ROW;
|
|
437
|
+
let o = this._matches.findLastIndex((h) => {
|
|
438
|
+
const c = h.range.range;
|
|
439
|
+
if (!(r ? Ke(i, c) : ze(i, c)))
|
|
460
440
|
return !1;
|
|
461
|
-
const
|
|
462
|
-
return
|
|
441
|
+
const l = Y(i, c);
|
|
442
|
+
return n ? l : !l;
|
|
463
443
|
});
|
|
464
|
-
|
|
465
|
-
const s = e[
|
|
466
|
-
return [s, this._matches.findIndex((
|
|
444
|
+
o === -1 && (o = 0);
|
|
445
|
+
const s = e[o];
|
|
446
|
+
return [s, this._matches.findIndex((h) => h === s)];
|
|
467
447
|
}
|
|
468
448
|
async replace(e) {
|
|
469
449
|
if (this._matchesCount === 0 || !this.currentMatch || !this._query || !this.currentMatch.replaceable)
|
|
470
450
|
return !1;
|
|
471
|
-
const
|
|
451
|
+
const i = this.currentMatch.range, n = this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId), r = this._getReplacedCellData(
|
|
472
452
|
this.currentMatch,
|
|
473
|
-
|
|
474
|
-
this._query.findBy ===
|
|
453
|
+
n,
|
|
454
|
+
this._query.findBy === M.FORMULA,
|
|
475
455
|
this._query.findString,
|
|
476
456
|
e,
|
|
477
457
|
this._query.caseSensitive ? "g" : "ig"
|
|
478
|
-
),
|
|
458
|
+
), o = {
|
|
479
459
|
unitId: this.currentMatch.unitId,
|
|
480
|
-
subUnitId:
|
|
460
|
+
subUnitId: i.subUnitId,
|
|
481
461
|
value: {
|
|
482
|
-
[
|
|
483
|
-
[
|
|
462
|
+
[i.range.startRow]: {
|
|
463
|
+
[i.range.startColumn]: r
|
|
484
464
|
}
|
|
485
465
|
}
|
|
486
466
|
};
|
|
487
|
-
return this._commandService.executeCommand(ee.id,
|
|
467
|
+
return this._commandService.executeCommand(ee.id, o);
|
|
488
468
|
}
|
|
489
469
|
async replaceAll(e) {
|
|
490
470
|
if (this._matchesCount === 0 || !this._query)
|
|
491
471
|
return { success: 0, failure: 0 };
|
|
492
|
-
const
|
|
493
|
-
return
|
|
494
|
-
const f = new
|
|
495
|
-
|
|
496
|
-
const { startColumn:
|
|
497
|
-
|
|
472
|
+
const i = this._workbook.getUnitId(), { findString: n, caseSensitive: r, findBy: o } = this._query, s = o === M.FORMULA, h = r ? "g" : "ig", c = [];
|
|
473
|
+
return Re(this._matches.filter((l) => l.replaceable), (l) => l.range.subUnitId).forEach((l, d) => {
|
|
474
|
+
const f = new ke(), m = this._workbook.getSheetBySheetId(d);
|
|
475
|
+
l.forEach((S) => {
|
|
476
|
+
const { startColumn: I, startRow: R } = S.range.range, C = this._getReplacedCellData(S, m, s, n, e, h);
|
|
477
|
+
C && f.setValue(R, I, C);
|
|
498
478
|
}), c.push({
|
|
499
|
-
count:
|
|
479
|
+
count: l.length,
|
|
500
480
|
subUnitId: d,
|
|
501
481
|
value: f.getMatrix()
|
|
502
482
|
});
|
|
503
|
-
}), c ? this._commandService.executeCommand(
|
|
504
|
-
unitId:
|
|
483
|
+
}), c ? this._commandService.executeCommand(ie.id, {
|
|
484
|
+
unitId: i,
|
|
505
485
|
replacements: c
|
|
506
486
|
}) : { success: 0, failure: 0 };
|
|
507
487
|
}
|
|
508
|
-
_getReplacedCellData(e,
|
|
509
|
-
var
|
|
510
|
-
const
|
|
488
|
+
_getReplacedCellData(e, i, n, r, o, s) {
|
|
489
|
+
var m;
|
|
490
|
+
const h = e.range.range, { startRow: c, startColumn: a } = h, l = i.getCellRaw(c, a);
|
|
511
491
|
if (e.isFormula)
|
|
512
|
-
return
|
|
513
|
-
if (!!((
|
|
514
|
-
const
|
|
515
|
-
return be(
|
|
492
|
+
return n ? { f: l.f.replace(new RegExp(z(r), s), o), v: null } : null;
|
|
493
|
+
if (!!((m = l.p) != null && m.body)) {
|
|
494
|
+
const S = we.deepClone(l.p);
|
|
495
|
+
return be(S.body, r, o), { p: S };
|
|
516
496
|
}
|
|
517
|
-
return { v:
|
|
497
|
+
return { v: l.v.toString().replace(new RegExp(z(r), s), o) };
|
|
498
|
+
}
|
|
499
|
+
_getFindReplacePermissionCheck(e) {
|
|
500
|
+
var a, l;
|
|
501
|
+
const { row: i, col: n, subUnitId: r } = e, s = this._univerInstanceService.getCurrentUnitForType(O.UNIVER_SHEET).getSheetBySheetId(r);
|
|
502
|
+
if (!s)
|
|
503
|
+
return !1;
|
|
504
|
+
const h = (l = (a = s.getCell(i, n)) == null ? void 0 : a.selectionProtection) == null ? void 0 : l[0];
|
|
505
|
+
return (h == null ? void 0 : h[te.View]) !== !1;
|
|
518
506
|
}
|
|
519
507
|
};
|
|
520
|
-
F =
|
|
521
|
-
_(1,
|
|
522
|
-
_(2,
|
|
523
|
-
_(3,
|
|
524
|
-
_(4,
|
|
525
|
-
_(5, p(
|
|
526
|
-
_(6, p(
|
|
527
|
-
_(7, p(
|
|
508
|
+
F = A([
|
|
509
|
+
_(1, E),
|
|
510
|
+
_(2, Ae),
|
|
511
|
+
_(3, T),
|
|
512
|
+
_(4, q),
|
|
513
|
+
_(5, p(Ce)),
|
|
514
|
+
_(6, p($e)),
|
|
515
|
+
_(7, p(He)),
|
|
516
|
+
_(8, p(k))
|
|
528
517
|
], F);
|
|
529
|
-
function
|
|
530
|
-
return
|
|
518
|
+
function z(t) {
|
|
519
|
+
return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
531
520
|
}
|
|
532
|
-
let
|
|
533
|
-
constructor(e,
|
|
521
|
+
let B = class extends J {
|
|
522
|
+
constructor(e, i) {
|
|
534
523
|
super();
|
|
535
524
|
/**
|
|
536
525
|
* Hold all find results in this kind of univer business instances (Workbooks).
|
|
537
526
|
*/
|
|
538
527
|
g(this, "_findModelsByUnitId", /* @__PURE__ */ new Map());
|
|
539
|
-
this._univerInstanceService = e, this._injector =
|
|
528
|
+
this._univerInstanceService = e, this._injector = i;
|
|
540
529
|
}
|
|
541
530
|
async find(e) {
|
|
542
531
|
this._terminate();
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
546
|
-
this._findModelsByUnitId.set(
|
|
547
|
-
const
|
|
548
|
-
return
|
|
532
|
+
const i = this._univerInstanceService.getCurrentUnitForType(O.UNIVER_SHEET);
|
|
533
|
+
if (i) {
|
|
534
|
+
const n = this._injector.createInstance(F, i);
|
|
535
|
+
this._findModelsByUnitId.set(i.getUnitId(), n);
|
|
536
|
+
const r = this._preprocessQuery(e);
|
|
537
|
+
return n.start(r), [n];
|
|
549
538
|
}
|
|
550
539
|
return [];
|
|
551
540
|
}
|
|
@@ -561,56 +550,55 @@ let W = class extends z {
|
|
|
561
550
|
* @returns the parsed query object
|
|
562
551
|
*/
|
|
563
552
|
_preprocessQuery(e) {
|
|
564
|
-
let
|
|
565
|
-
return
|
|
553
|
+
let i = e.caseSensitive ? e.findString : e.findString.toLowerCase();
|
|
554
|
+
return i = i.trim(), {
|
|
566
555
|
...e,
|
|
567
|
-
findString:
|
|
556
|
+
findString: i
|
|
568
557
|
};
|
|
569
558
|
}
|
|
570
559
|
};
|
|
571
|
-
|
|
572
|
-
_(0,
|
|
573
|
-
_(1, p(
|
|
574
|
-
],
|
|
560
|
+
B = A([
|
|
561
|
+
_(0, E),
|
|
562
|
+
_(1, p(D))
|
|
563
|
+
], B);
|
|
575
564
|
const u = { hit: !1, replaceable: !1, isFormula: !1, rawData: null };
|
|
576
|
-
function
|
|
577
|
-
const { findBy:
|
|
578
|
-
return u.rawData =
|
|
565
|
+
function et(t, e, i, n, r) {
|
|
566
|
+
const { findBy: o } = n, s = o === M.FORMULA, h = t.getCellRaw(e, i);
|
|
567
|
+
return u.rawData = h, !(h != null && h.f) ? (u.isFormula = !1, P(r, n) ? h ? (u.hit = !0, u.replaceable = !0) : (u.hit = !0, u.replaceable = !1) : (u.hit = !1, u.replaceable = !1), u) : (u.isFormula = !0, s ? P({ v: h.f }, n) ? (u.hit = !0, u.replaceable = !0, u) : (u.hit = !1, u.replaceable = !1, u) : (u.replaceable = !1, P(r, n) ? u.hit = !0 : u.hit = !1, u));
|
|
579
568
|
}
|
|
580
|
-
function P(
|
|
581
|
-
let
|
|
582
|
-
return
|
|
569
|
+
function P(t, e) {
|
|
570
|
+
let i = tt(t);
|
|
571
|
+
return i ? e.matchesTheWholeCell ? (i = it(i), e.caseSensitive ? i === e.findString : i.toLowerCase() === e.findString) : e.caseSensitive ? i.indexOf(e.findString) > -1 : i.toLowerCase().indexOf(e.findString) > -1 : !1;
|
|
583
572
|
}
|
|
584
|
-
function
|
|
585
|
-
var
|
|
586
|
-
const e = (
|
|
573
|
+
function tt(t) {
|
|
574
|
+
var i, n, r;
|
|
575
|
+
const e = (r = (n = (i = t == null ? void 0 : t.p) == null ? void 0 : i.body) == null ? void 0 : n.dataStream) != null ? r : t == null ? void 0 : t.v;
|
|
587
576
|
return typeof e == "number" ? `${e}` : typeof e == "boolean" ? e ? "1" : "0" : e;
|
|
588
577
|
}
|
|
589
|
-
function
|
|
590
|
-
return
|
|
578
|
+
function it(t) {
|
|
579
|
+
return t.replace(/^ +/g, "").replace(/ +$/g, "");
|
|
591
580
|
}
|
|
592
|
-
var
|
|
593
|
-
for (var
|
|
594
|
-
(s =
|
|
595
|
-
return
|
|
596
|
-
},
|
|
597
|
-
const ht = "
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
G
|
|
610
|
-
|
|
581
|
+
var nt = Object.defineProperty, st = (t, e, i) => e in t ? nt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, rt = (t, e, i, n) => {
|
|
582
|
+
for (var r = e, o = t.length - 1, s; o >= 0; o--)
|
|
583
|
+
(s = t[o]) && (r = s(r) || r);
|
|
584
|
+
return r;
|
|
585
|
+
}, ot = (t, e) => (i, n) => e(i, n, t), ne = (t, e, i) => (st(t, typeof e != "symbol" ? e + "" : e, i), i);
|
|
586
|
+
const ht = "SHEET_FIND_REPLACE_PLUGIN";
|
|
587
|
+
let x = class extends ye {
|
|
588
|
+
constructor(t, e) {
|
|
589
|
+
super(), this._injector = e;
|
|
590
|
+
}
|
|
591
|
+
onStarting(t) {
|
|
592
|
+
[[k]].forEach((e) => t.add(e));
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
ne(x, "pluginName", ht);
|
|
596
|
+
ne(x, "type", O.UNIVER_SHEET);
|
|
597
|
+
x = rt([
|
|
598
|
+
Me(G, G, Pe),
|
|
599
|
+
ot(1, p(D))
|
|
600
|
+
], x);
|
|
611
601
|
export {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
pt as ruRU,
|
|
615
|
-
St as zhCN
|
|
602
|
+
k as SheetsFindReplaceController,
|
|
603
|
+
x as UniverSheetsFindReplacePlugin
|
|
616
604
|
};
|