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