@univerjs/find-replace 0.2.3 → 0.2.4
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 +2 -2
- package/lib/es/index.js +285 -277
- package/lib/types/services/find-replace.service.d.ts +4 -0
- package/lib/umd/index.js +2 -2
- package/package.json +16 -16
package/lib/es/index.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
1
|
var at = Object.defineProperty;
|
|
2
2
|
var ot = (t, e, n) => e in t ? at(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
-
var
|
|
4
|
-
import { Disposable as X, IUniverInstanceService as pe, toDisposable as H, IContextService as ee, DisposableCollection as ct, CommandType as y, LocaleService as
|
|
5
|
-
import { createIdentifier as _t, Inject as
|
|
6
|
-
import { IConfirmService as gt, IMessageService as me, useObservable as I, ILayoutService as ve, KeyCode as M, MetaKeys as
|
|
7
|
-
import { BehaviorSubject as
|
|
8
|
-
import { RENDER_RAW_FORMULA_KEY as
|
|
9
|
-
import
|
|
10
|
-
import { MessageType as
|
|
11
|
-
import { useDependency as
|
|
12
|
-
var
|
|
13
|
-
return
|
|
3
|
+
var o = (t, e, n) => ot(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { Disposable as X, IUniverInstanceService as pe, toDisposable as H, IContextService as ee, DisposableCollection as ct, CommandType as y, LocaleService as O, ICommandService as te, FOCUSING_SHEET as _e, EDITOR_ACTIVATED as ge, UniverInstanceType as lt, RxDisposable as dt, OnLifecycle as ht, LifecycleStages as ut, Plugin as ft, Tools as pt } from "@univerjs/core";
|
|
5
|
+
import { createIdentifier as _t, Inject as b, Injector as ie } from "@wendellhu/redi";
|
|
6
|
+
import { IConfirmService as gt, IMessageService as me, useObservable as I, ILayoutService as ve, KeyCode as M, MetaKeys as x, MenuGroup as mt, MenuItemType as vt, MenuPosition as St, getMenuHiddenObservable as Ct, ComponentManager as Rt, IMenuService as Mt, IShortcutService as bt, IDialogService as xt } from "@univerjs/ui";
|
|
7
|
+
import { BehaviorSubject as D, Subject as Se, throttleTime as yt, combineLatest as Ce, debounceTime as It, fromEvent as Ft, map as Dt, takeUntil as ce } from "rxjs";
|
|
8
|
+
import { RENDER_RAW_FORMULA_KEY as Ot } from "@univerjs/engine-render";
|
|
9
|
+
import Pt, { forwardRef as w, useRef as q, createElement as Re, useCallback as u, Fragment as N, useEffect as j, useMemo as ne, useImperativeHandle as Tt } from "react";
|
|
10
|
+
import { MessageType as $, InputWithSlot as Et, Pager as Nt, Button as A, FormLayout as R, Input as $t, Select as G, FormDualColumnLayout as le, Checkbox as de } from "@univerjs/design";
|
|
11
|
+
import { useDependency as v } from "@wendellhu/redi/react-bindings";
|
|
12
|
+
var _ = function() {
|
|
13
|
+
return _ = Object.assign || function(t) {
|
|
14
14
|
for (var e, n = 1, i = arguments.length; n < i; n++) {
|
|
15
15
|
e = arguments[n];
|
|
16
|
-
for (var
|
|
16
|
+
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
|
|
17
17
|
}
|
|
18
18
|
return t;
|
|
19
|
-
},
|
|
19
|
+
}, _.apply(this, arguments);
|
|
20
20
|
}, At = function(t, e) {
|
|
21
21
|
var n = {};
|
|
22
22
|
for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
|
|
23
23
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
24
|
-
for (var
|
|
25
|
-
e.indexOf(i[
|
|
24
|
+
for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
|
|
25
|
+
e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
|
|
26
26
|
return n;
|
|
27
27
|
}, Me = w(function(t, e) {
|
|
28
|
-
var n = t.icon, i = t.id,
|
|
29
|
-
return
|
|
28
|
+
var n = t.icon, i = t.id, r = t.className, s = t.extend, a = At(t, ["icon", "id", "className", "extend"]), l = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), d = q("_".concat(wt()));
|
|
29
|
+
return be(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, _({ ref: e, className: l }, a), s);
|
|
30
30
|
});
|
|
31
|
-
function
|
|
32
|
-
return Re(t.tag,
|
|
33
|
-
return
|
|
31
|
+
function be(t, e, n, i, r) {
|
|
32
|
+
return Re(t.tag, _(_({ key: e }, jt(t, n, r)), i), (Lt(t, n).children || []).map(function(s, a) {
|
|
33
|
+
return be(s, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
36
|
function jt(t, e, n) {
|
|
37
|
-
var i =
|
|
37
|
+
var i = _({}, t.attrs);
|
|
38
38
|
n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
|
|
39
|
-
var
|
|
40
|
-
return !
|
|
41
|
-
var a =
|
|
42
|
-
typeof
|
|
39
|
+
var r = e.defIds;
|
|
40
|
+
return !r || r.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(s) {
|
|
41
|
+
var a = s[0], l = s[1];
|
|
42
|
+
typeof l == "string" && (i[a] = l.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
43
43
|
})), i;
|
|
44
44
|
}
|
|
45
45
|
function Lt(t, e) {
|
|
46
46
|
var n, i = e.defIds;
|
|
47
|
-
return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ?
|
|
48
|
-
return typeof
|
|
47
|
+
return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? _(_({}, t), { children: t.children.map(function(r) {
|
|
48
|
+
return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? _(_({}, r), { attrs: _(_({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
|
|
49
49
|
}) }) : t;
|
|
50
50
|
}
|
|
51
51
|
function wt() {
|
|
52
52
|
return Math.random().toString(36).substring(2, 8);
|
|
53
53
|
}
|
|
54
54
|
Me.displayName = "UniverIcon";
|
|
55
|
-
var Ut = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_217_40", style: { maskType: "alpha" }, width: 17, height: 17, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#D9D9D9", d: "M0.9 0.09H16.9V16.09H0.9z" } }] }, { tag: "g", attrs: { mask: "url(#mask0_217_40)" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z", fillRule: "evenodd", clipRule: "evenodd" } }] }] },
|
|
55
|
+
var Ut = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_217_40", style: { maskType: "alpha" }, width: 17, height: 17, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#D9D9D9", d: "M0.9 0.09H16.9V16.09H0.9z" } }] }, { tag: "g", attrs: { mask: "url(#mask0_217_40)" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z", fillRule: "evenodd", clipRule: "evenodd" } }] }] }, xe = w(function(t, e) {
|
|
56
56
|
return Re(Me, Object.assign({}, t, {
|
|
57
57
|
id: "search-single-16",
|
|
58
58
|
ref: e,
|
|
59
59
|
icon: Ut
|
|
60
60
|
}));
|
|
61
61
|
});
|
|
62
|
-
|
|
62
|
+
xe.displayName = "SearchSingle16";
|
|
63
63
|
const ye = "FIND_REPLACE_INPUT_FOCUS", Ie = "FIND_REPLACE_DIALOG_FOCUS", Fe = "FIND_REPLACE_REPLACE_REVEALED";
|
|
64
|
-
var Bt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor,
|
|
65
|
-
for (var
|
|
66
|
-
(a = t[
|
|
67
|
-
return i &&
|
|
64
|
+
var Bt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, De = (t, e, n, i) => {
|
|
65
|
+
for (var r = i > 1 ? void 0 : i ? Wt(e, n) : e, s = t.length - 1, a; s >= 0; s--)
|
|
66
|
+
(a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
|
|
67
|
+
return i && r && Bt(e, n, r), r;
|
|
68
68
|
}, z = (t, e) => (n, i) => e(n, i, t);
|
|
69
69
|
class Ai extends X {
|
|
70
70
|
}
|
|
71
|
-
const
|
|
72
|
-
function
|
|
71
|
+
const g = _t("find-replace.service");
|
|
72
|
+
function kt(t) {
|
|
73
73
|
return typeof t.findString < "u" || typeof t.inputtingFindString < "u" || typeof t.findDirection < "u" || typeof t.matchesTheWholeCell < "u" || typeof t.caseSensitive < "u" || typeof t.findScope < "u" || typeof t.findBy < "u";
|
|
74
74
|
}
|
|
75
75
|
let K = class extends X {
|
|
76
76
|
constructor(e, n, i) {
|
|
77
77
|
super();
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
o(this, "currentMatch$", new D(null));
|
|
79
|
+
o(this, "replaceables$", new D([]));
|
|
80
80
|
/** All find models returned by providers. */
|
|
81
|
-
|
|
81
|
+
o(this, "_findModels", []);
|
|
82
82
|
/** The find model that the current match is from. */
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
o(this, "_matchingModel", null);
|
|
84
|
+
o(this, "_matches", []);
|
|
85
|
+
o(this, "_currentSearchingDisposables", null);
|
|
86
86
|
this._state = e, this._providers = n, this._univerInstanceService = i, this.disposeWithMe(
|
|
87
|
-
this._state.stateUpdates$.pipe(yt(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (
|
|
88
|
-
const
|
|
89
|
-
|
|
87
|
+
this._state.stateUpdates$.pipe(yt(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (r) => {
|
|
88
|
+
const s = this._state.state;
|
|
89
|
+
kt(r) && (s.findString !== "" && !s.replaceRevealed ? (await this._startSearching(), this._state.changeState({ findCompleted: !0 })) : r.replaceRevealed !== !0 && this._stopSearching());
|
|
90
90
|
})
|
|
91
91
|
);
|
|
92
92
|
}
|
|
@@ -94,7 +94,7 @@ let K = class extends X {
|
|
|
94
94
|
return this._findModels.length > 0;
|
|
95
95
|
}
|
|
96
96
|
dispose() {
|
|
97
|
-
super.dispose(), this._stopSearching(), this.currentMatch$.complete(), this.replaceables$.complete(), this._state.changeState({ ...
|
|
97
|
+
super.dispose(), this._stopSearching(), this.currentMatch$.complete(), this.replaceables$.complete(), this._state.changeState({ ...re(), revealed: !1 });
|
|
98
98
|
}
|
|
99
99
|
async start() {
|
|
100
100
|
if (!this._state.findString)
|
|
@@ -117,14 +117,7 @@ let K = class extends X {
|
|
|
117
117
|
})))).flat();
|
|
118
118
|
this._subscribeToModelsChanges(n);
|
|
119
119
|
const i = this._matches = n.map((r) => r.getMatches()).flat();
|
|
120
|
-
|
|
121
|
-
return this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), { results: [] };
|
|
122
|
-
const s = this._moveToInitialMatch(n, i);
|
|
123
|
-
return this._state.changeState({
|
|
124
|
-
matchesCount: i.length,
|
|
125
|
-
matchesPosition: s + 1
|
|
126
|
-
// the matches position start from 1
|
|
127
|
-
}), { results: i };
|
|
120
|
+
return this.replaceables$.next(i.filter((r) => r.replaceable)), i.length ? (this._moveToInitialMatch(n), this._state.changeState({ matchesCount: i.length }), { results: i }) : (this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), { results: [] });
|
|
128
121
|
}
|
|
129
122
|
/** Terminate the current searching session, when searching string is empty. */
|
|
130
123
|
_stopSearching() {
|
|
@@ -137,16 +130,12 @@ let K = class extends X {
|
|
|
137
130
|
}
|
|
138
131
|
// When a document's content changes, we should reset all matches and try to move to the next match.
|
|
139
132
|
_subscribeToModelsChanges(e) {
|
|
140
|
-
const n = this._currentSearchingDisposables = new ct(), i = Ce(e.map((
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
const a = this._moveToInitialMatch(this._findModels, r, !0);
|
|
144
|
-
this._state.changeState({ matchesCount: r.length, matchesPosition: a + 1 }), this.replaceables$.next(r.filter((o) => o.replaceable));
|
|
145
|
-
} else
|
|
146
|
-
this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), this.replaceables$.next([]);
|
|
133
|
+
const n = this._currentSearchingDisposables = new ct(), i = Ce(e.map((r) => r.matchesUpdate$)).pipe(It(220)).subscribe(([...r]) => {
|
|
134
|
+
const s = this._matches = r.flat();
|
|
135
|
+
s.length ? (this._moveToInitialMatch(this._findModels, !0), this._state.changeState({ matchesCount: s.length }), this.replaceables$.next(s.filter((a) => a.replaceable))) : (this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), this.replaceables$.next([]));
|
|
147
136
|
});
|
|
148
|
-
e.forEach((
|
|
149
|
-
const a = this._matches.findIndex((
|
|
137
|
+
e.forEach((r) => n.add(H(r.activelyChangingMatch$.subscribe((s) => {
|
|
138
|
+
const a = this._matches.findIndex((l) => l === s);
|
|
150
139
|
this._state.changeState({ matchesPosition: a + 1 });
|
|
151
140
|
})))), n.add(H(i));
|
|
152
141
|
}
|
|
@@ -154,26 +143,40 @@ let K = class extends X {
|
|
|
154
143
|
return this._matchingModel ? this._matchingModel.replace(this._state.replaceString) : !1;
|
|
155
144
|
}
|
|
156
145
|
async replaceAll() {
|
|
157
|
-
const e = await Promise.all(this._findModels.map((n) => n.replaceAll(this._state.replaceString))).then((n) => n.reduce((i,
|
|
146
|
+
const e = await Promise.all(this._findModels.map((n) => n.replaceAll(this._state.replaceString))).then((n) => n.reduce((i, r) => (i.success += r.success, i.failure += r.failure, i), { success: 0, failure: 0 }));
|
|
158
147
|
return e.failure === 0 && this._stopSearching(), e;
|
|
159
148
|
}
|
|
160
149
|
getCurrentMatch() {
|
|
161
150
|
return this._state.matchesPosition > 0 ? this._matches[this._state.matchesPosition - 1] : null;
|
|
162
151
|
}
|
|
152
|
+
_markMatch(e) {
|
|
153
|
+
const n = this._matches.findIndex((i) => i === e);
|
|
154
|
+
this.currentMatch$.next(e), this._state.changeState({ matchesPosition: n + 1 });
|
|
155
|
+
}
|
|
163
156
|
moveToNextMatch() {
|
|
164
157
|
if (!this._matchingModel)
|
|
165
158
|
return;
|
|
166
159
|
const e = this._findModels.length === 1, n = this._matchingModel.moveToNextMatch({ loop: e });
|
|
167
|
-
if (n)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
160
|
+
if (n)
|
|
161
|
+
this._markMatch(n);
|
|
162
|
+
else {
|
|
163
|
+
const i = this._findModels.findIndex((r) => r === this._matchingModel);
|
|
164
|
+
this._moveToNextUnitMatch(i);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
_moveToNextUnitMatch(e) {
|
|
168
|
+
const n = this._findModels.length;
|
|
169
|
+
for (let i = (e + 1) % n; i !== e; ) {
|
|
170
|
+
const r = this._findModels[i], s = r.moveToNextMatch({ ignoreSelection: !0 });
|
|
171
|
+
if (s) {
|
|
172
|
+
this._matchingModel = r, this._markMatch(s);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
i = (i + 1) % n;
|
|
176
|
+
}
|
|
177
|
+
if (this._matchingModel) {
|
|
178
|
+
const i = this._matchingModel.moveToNextMatch({ ignoreSelection: !0 });
|
|
179
|
+
i && this._markMatch(i);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
moveToPreviousMatch() {
|
|
@@ -181,38 +184,42 @@ let K = class extends X {
|
|
|
181
184
|
return;
|
|
182
185
|
const e = this._findModels.length === 1, n = this._matchingModel.moveToPreviousMatch({ loop: e });
|
|
183
186
|
if (n) {
|
|
184
|
-
const i = this._matches.findIndex((
|
|
185
|
-
this.currentMatch$.next(n), this._state.changeState({
|
|
186
|
-
matchesPosition: i + 1
|
|
187
|
-
});
|
|
187
|
+
const i = this._matches.findIndex((r) => r === n);
|
|
188
|
+
this.currentMatch$.next(n), this._state.changeState({ matchesPosition: i + 1 });
|
|
188
189
|
} else {
|
|
189
|
-
const i = this._findModels.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
const i = this._findModels.length, r = this._findModels.findIndex((a) => a === this._matchingModel);
|
|
191
|
+
for (let a = (r - 1 + i) % i; a !== r; ) {
|
|
192
|
+
const l = this._findModels[a], d = l.moveToPreviousMatch({ ignoreSelection: !0 });
|
|
193
|
+
if (d) {
|
|
194
|
+
this._matchingModel = l, this._markMatch(d);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
a = (a - 1) % i;
|
|
198
|
+
}
|
|
199
|
+
const s = this._matchingModel.moveToPreviousMatch({ ignoreSelection: !0 });
|
|
200
|
+
s && this._markMatch(s);
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
|
-
_moveToInitialMatch(e, n
|
|
196
|
-
var
|
|
197
|
-
const
|
|
198
|
-
if (!
|
|
203
|
+
_moveToInitialMatch(e, n = !1) {
|
|
204
|
+
var s;
|
|
205
|
+
const i = (s = this._univerInstanceService.getFocusedUnit()) == null ? void 0 : s.getUnitId();
|
|
206
|
+
if (!i)
|
|
199
207
|
return -1;
|
|
200
|
-
const r = e.
|
|
201
|
-
if (r) {
|
|
202
|
-
this._matchingModel = r;
|
|
203
|
-
const
|
|
204
|
-
|
|
208
|
+
const r = e.findIndex((a) => a.unitId === i);
|
|
209
|
+
if (r !== -1) {
|
|
210
|
+
this._matchingModel = e[r];
|
|
211
|
+
const a = this._matchingModel.moveToNextMatch({ stayIfOnMatch: !0, noFocus: n });
|
|
212
|
+
if (a)
|
|
213
|
+
return this._markMatch(a), r;
|
|
205
214
|
}
|
|
206
|
-
this.
|
|
207
|
-
const a = this._matchingModel.moveToNextMatch({ noFocus: i }), o = this._matches.findIndex((u) => u === a);
|
|
208
|
-
return this.currentMatch$.next(a), o;
|
|
215
|
+
return this._moveToNextUnitMatch(r), 0;
|
|
209
216
|
}
|
|
210
217
|
};
|
|
211
|
-
K =
|
|
218
|
+
K = De([
|
|
212
219
|
z(2, pe)
|
|
213
220
|
], K);
|
|
214
221
|
var Y = /* @__PURE__ */ ((t) => (t.ROW = "row", t.COLUMN = "column", t))(Y || {}), Z = /* @__PURE__ */ ((t) => (t.VALUE = "value", t.FORMULA = "formula", t))(Z || {}), J = /* @__PURE__ */ ((t) => (t.SUBUNIT = "subunit", t.UNIT = "unit", t))(J || {});
|
|
215
|
-
function
|
|
222
|
+
function re() {
|
|
216
223
|
return {
|
|
217
224
|
caseSensitive: !1,
|
|
218
225
|
findBy: "value",
|
|
@@ -229,25 +236,25 @@ function se() {
|
|
|
229
236
|
revealed: !0
|
|
230
237
|
};
|
|
231
238
|
}
|
|
232
|
-
class
|
|
239
|
+
class Gt {
|
|
233
240
|
constructor() {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
241
|
+
o(this, "_stateUpdates$", new Se());
|
|
242
|
+
o(this, "stateUpdates$", this._stateUpdates$.asObservable());
|
|
243
|
+
o(this, "_state$", new D(re()));
|
|
244
|
+
o(this, "state$", this._state$.asObservable());
|
|
245
|
+
o(this, "_findString", "");
|
|
246
|
+
o(this, "_inputtingFindString", "");
|
|
247
|
+
o(this, "_replaceString", "");
|
|
248
|
+
o(this, "_revealed", !1);
|
|
249
|
+
o(this, "_replaceRevealed", !1);
|
|
250
|
+
o(this, "_matchesPosition", 0);
|
|
251
|
+
o(this, "_matchesCount", 0);
|
|
252
|
+
o(this, "_caseSensitive", !0);
|
|
253
|
+
o(this, "_matchesTheWholeCell", !1);
|
|
254
|
+
o(this, "_findDirection", "row");
|
|
255
|
+
o(this, "_findScope", "subunit");
|
|
256
|
+
o(this, "_findBy", "value");
|
|
257
|
+
o(this, "_findCompleted", !1);
|
|
251
258
|
}
|
|
252
259
|
get state() {
|
|
253
260
|
return this._state$.getValue();
|
|
@@ -291,6 +298,7 @@ class Vt {
|
|
|
291
298
|
get findCompleted() {
|
|
292
299
|
return this._findCompleted;
|
|
293
300
|
}
|
|
301
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
294
302
|
changeState(e) {
|
|
295
303
|
let n = !1;
|
|
296
304
|
const i = {};
|
|
@@ -313,15 +321,15 @@ class Vt {
|
|
|
313
321
|
let Q = class extends X {
|
|
314
322
|
constructor(e, n) {
|
|
315
323
|
super();
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
324
|
+
o(this, "_providers", /* @__PURE__ */ new Set());
|
|
325
|
+
o(this, "_state", new Gt());
|
|
326
|
+
o(this, "_model");
|
|
327
|
+
o(this, "_currentMatch$", new D(null));
|
|
328
|
+
o(this, "currentMatch$", this._currentMatch$.asObservable());
|
|
329
|
+
o(this, "_replaceables$", new D([]));
|
|
330
|
+
o(this, "replaceables$", this._replaceables$.asObservable());
|
|
331
|
+
o(this, "_focusSignal$", new Se());
|
|
332
|
+
o(this, "focusSignal$", this._focusSignal$.asObservable());
|
|
325
333
|
this._injector = e, this._contextService = n;
|
|
326
334
|
}
|
|
327
335
|
get stateUpdates$() {
|
|
@@ -397,7 +405,7 @@ let Q = class extends X {
|
|
|
397
405
|
if (this._providers.size === 0)
|
|
398
406
|
return !1;
|
|
399
407
|
this._model = this._injector.createInstance(K, this._state, this._providers), this._model.currentMatch$.subscribe((i) => this._currentMatch$.next(i)), this._model.replaceables$.subscribe((i) => this._replaceables$.next(i));
|
|
400
|
-
const n =
|
|
408
|
+
const n = re();
|
|
401
409
|
return e && (n.replaceRevealed = !0), this._state.changeState(n), this._toggleRevealReplace(e), !0;
|
|
402
410
|
}
|
|
403
411
|
find() {
|
|
@@ -415,35 +423,35 @@ let Q = class extends X {
|
|
|
415
423
|
this._contextService.setContextValue(Fe, e);
|
|
416
424
|
}
|
|
417
425
|
_toggleDisplayRawFormula(e) {
|
|
418
|
-
this._contextService.setContextValue(
|
|
426
|
+
this._contextService.setContextValue(Ot, e);
|
|
419
427
|
}
|
|
420
428
|
};
|
|
421
|
-
Q =
|
|
422
|
-
z(0,
|
|
429
|
+
Q = De([
|
|
430
|
+
z(0, b(ie)),
|
|
423
431
|
z(1, ee)
|
|
424
432
|
], Q);
|
|
425
433
|
const U = {
|
|
426
434
|
id: "ui.operation.open-find-dialog",
|
|
427
435
|
type: y.OPERATION,
|
|
428
436
|
handler: (t) => {
|
|
429
|
-
const e = t.get(
|
|
437
|
+
const e = t.get(g);
|
|
430
438
|
return e.revealed ? e.focusFindInput() : e.start(), !0;
|
|
431
439
|
}
|
|
432
|
-
},
|
|
440
|
+
}, se = {
|
|
433
441
|
id: "ui.operation.open-replace-dialog",
|
|
434
442
|
type: y.OPERATION,
|
|
435
443
|
handler: (t) => {
|
|
436
|
-
const e = t.get(
|
|
444
|
+
const e = t.get(g);
|
|
437
445
|
return e.revealed ? e.replaceRevealed ? e.focusFindInput() : e.revealReplace() : e.start(!0), !0;
|
|
438
446
|
}
|
|
439
|
-
},
|
|
447
|
+
}, Oe = {
|
|
440
448
|
type: y.OPERATION,
|
|
441
449
|
id: "ui.operation.go-to-next-match",
|
|
442
|
-
handler: (t) => (t.get(
|
|
443
|
-
},
|
|
450
|
+
handler: (t) => (t.get(g).moveToNextMatch(), !0)
|
|
451
|
+
}, Pe = {
|
|
444
452
|
type: y.OPERATION,
|
|
445
453
|
id: "ui.operation.go-to-previous-match",
|
|
446
|
-
handler: (t) => (t.get(
|
|
454
|
+
handler: (t) => (t.get(g).moveToPreviousMatch(), !0)
|
|
447
455
|
};
|
|
448
456
|
var Te = { exports: {} }, B = {};
|
|
449
457
|
/**
|
|
@@ -455,28 +463,28 @@ var Te = { exports: {} }, B = {};
|
|
|
455
463
|
* This source code is licensed under the MIT license found in the
|
|
456
464
|
* LICENSE file in the root directory of this source tree.
|
|
457
465
|
*/
|
|
458
|
-
var
|
|
466
|
+
var Vt = Pt, Ht = Symbol.for("react.element"), qt = Symbol.for("react.fragment"), zt = Object.prototype.hasOwnProperty, Kt = Vt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Yt = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
459
467
|
function Ee(t, e, n) {
|
|
460
|
-
var i,
|
|
461
|
-
n !== void 0 && (
|
|
462
|
-
for (i in e) zt.call(e, i) && !Yt.hasOwnProperty(i) && (
|
|
463
|
-
if (t && t.defaultProps) for (i in e = t.defaultProps, e)
|
|
464
|
-
return { $$typeof: Ht, type: t, key:
|
|
468
|
+
var i, r = {}, s = null, a = null;
|
|
469
|
+
n !== void 0 && (s = "" + n), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (a = e.ref);
|
|
470
|
+
for (i in e) zt.call(e, i) && !Yt.hasOwnProperty(i) && (r[i] = e[i]);
|
|
471
|
+
if (t && t.defaultProps) for (i in e = t.defaultProps, e) r[i] === void 0 && (r[i] = e[i]);
|
|
472
|
+
return { $$typeof: Ht, type: t, key: s, ref: a, props: r, _owner: Kt.current };
|
|
465
473
|
}
|
|
466
474
|
B.Fragment = qt;
|
|
467
475
|
B.jsx = Ee;
|
|
468
476
|
B.jsxs = Ee;
|
|
469
477
|
Te.exports = B;
|
|
470
|
-
var
|
|
471
|
-
const
|
|
478
|
+
var c = Te.exports;
|
|
479
|
+
const Ne = {
|
|
472
480
|
id: "ui.command.replace-current-match",
|
|
473
481
|
type: y.COMMAND,
|
|
474
|
-
handler: (t) => t.get(
|
|
475
|
-
}, Zt = "CONFIRM_REPLACE_ALL",
|
|
482
|
+
handler: (t) => t.get(g).replace()
|
|
483
|
+
}, Zt = "CONFIRM_REPLACE_ALL", $e = {
|
|
476
484
|
id: "ui.command.replace-all-matches",
|
|
477
485
|
type: y.COMMAND,
|
|
478
486
|
handler: async (t) => {
|
|
479
|
-
const e = t.get(gt), n = t.get(
|
|
487
|
+
const e = t.get(gt), n = t.get(O), i = t.get(me);
|
|
480
488
|
if (!await e.confirm({
|
|
481
489
|
id: Zt,
|
|
482
490
|
title: { title: n.t("find-replace.replace.confirm.title") },
|
|
@@ -484,40 +492,40 @@ const $e = {
|
|
|
484
492
|
confirmText: n.t("button.confirm")
|
|
485
493
|
}))
|
|
486
494
|
return !1;
|
|
487
|
-
const
|
|
488
|
-
return
|
|
489
|
-
type:
|
|
495
|
+
const s = await t.get(g).replaceAll(), { success: a, failure: l } = s;
|
|
496
|
+
return l > 0 ? (a === 0 ? i.show({
|
|
497
|
+
type: $.Error,
|
|
490
498
|
content: n.t("find-replace.replace.all-failure")
|
|
491
499
|
}) : i.show({
|
|
492
|
-
type:
|
|
493
|
-
content: n.t("find-replace.replace.partial-success", `${a}`, `${
|
|
500
|
+
type: $.Warning,
|
|
501
|
+
content: n.t("find-replace.replace.partial-success", `${a}`, `${l}`)
|
|
494
502
|
}), !1) : (i.show({
|
|
495
|
-
type:
|
|
503
|
+
type: $.Success,
|
|
496
504
|
content: n.t("find-replace.replace.all-success", `${a}`)
|
|
497
505
|
}), !0);
|
|
498
506
|
}
|
|
499
507
|
};
|
|
500
508
|
function Ae(t) {
|
|
501
|
-
const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition:
|
|
502
|
-
return /* @__PURE__ */
|
|
509
|
+
const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition: r, findString: s, findReplaceService: a, onChange: l, ...d } = t, f = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
|
|
510
|
+
return /* @__PURE__ */ c.jsx(
|
|
503
511
|
Et,
|
|
504
512
|
{
|
|
505
513
|
autoFocus: !0,
|
|
506
514
|
placeholder: n.t("find-replace.dialog.find-placeholder"),
|
|
507
|
-
slot: /* @__PURE__ */
|
|
508
|
-
|
|
515
|
+
slot: /* @__PURE__ */ c.jsx(
|
|
516
|
+
Nt,
|
|
509
517
|
{
|
|
510
518
|
loop: !0,
|
|
511
519
|
text: f,
|
|
512
|
-
value:
|
|
520
|
+
value: r,
|
|
513
521
|
total: i,
|
|
514
522
|
onChange: (p) => {
|
|
515
|
-
|
|
523
|
+
r === i && p === 1 ? a.moveToNextMatch() : r === 1 && p === i || p < r ? a.moveToPreviousMatch() : a.moveToNextMatch();
|
|
516
524
|
}
|
|
517
525
|
}
|
|
518
526
|
),
|
|
519
|
-
value:
|
|
520
|
-
onChange: (p) =>
|
|
527
|
+
value: s,
|
|
528
|
+
onChange: (p) => l == null ? void 0 : l(p),
|
|
521
529
|
...d
|
|
522
530
|
}
|
|
523
531
|
);
|
|
@@ -530,40 +538,40 @@ const Jt = "univer-find-replace-dialog-container", Qt = "univer-find-replace-exp
|
|
|
530
538
|
findReplaceButtonsGroupRight: ti
|
|
531
539
|
};
|
|
532
540
|
function je(t, e) {
|
|
533
|
-
const n =
|
|
534
|
-
var
|
|
535
|
-
(
|
|
536
|
-
}, []), i =
|
|
537
|
-
const
|
|
538
|
-
return Array.from(
|
|
541
|
+
const n = u(() => {
|
|
542
|
+
var r;
|
|
543
|
+
(r = document.querySelector(".univer-find-input input")) == null || r.focus();
|
|
544
|
+
}, []), i = u(() => {
|
|
545
|
+
const r = document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");
|
|
546
|
+
return Array.from(r).some((s) => s === document.activeElement);
|
|
539
547
|
}, []);
|
|
540
548
|
return Tt(e, () => ({ focus: n, selectHasFocus: i })), j(() => {
|
|
541
|
-
const
|
|
542
|
-
return () =>
|
|
549
|
+
const r = t.focusSignal$.subscribe(() => n());
|
|
550
|
+
return () => r.unsubscribe();
|
|
543
551
|
}, [t, n]), { focus: n, selectHasFocus: i };
|
|
544
552
|
}
|
|
545
553
|
const ii = w(function(e, n) {
|
|
546
|
-
const i =
|
|
547
|
-
|
|
548
|
-
}, [
|
|
549
|
-
return je(
|
|
550
|
-
/* @__PURE__ */
|
|
554
|
+
const i = v(O), r = v(g), s = v(te), a = I(r.state$, void 0, !0), { findCompleted: l, findString: d, matchesCount: S, matchesPosition: f } = a, p = u(() => {
|
|
555
|
+
s.executeCommand(se.id);
|
|
556
|
+
}, [s]), T = u((C) => r.changeFindString(C), [r]);
|
|
557
|
+
return je(r, n), /* @__PURE__ */ c.jsxs(N, { children: [
|
|
558
|
+
/* @__PURE__ */ c.jsx(
|
|
551
559
|
Ae,
|
|
552
560
|
{
|
|
553
|
-
findCompleted:
|
|
561
|
+
findCompleted: l,
|
|
554
562
|
className: "univer-find-input",
|
|
555
|
-
matchesCount:
|
|
563
|
+
matchesCount: S,
|
|
556
564
|
matchesPosition: f,
|
|
557
|
-
findReplaceService:
|
|
565
|
+
findReplaceService: r,
|
|
558
566
|
localeService: i,
|
|
559
567
|
findString: d,
|
|
560
568
|
onChange: T
|
|
561
569
|
}
|
|
562
570
|
),
|
|
563
|
-
/* @__PURE__ */
|
|
571
|
+
/* @__PURE__ */ c.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ c.jsx(A, { type: "text", size: "small", onClick: p, children: i.t("find-replace.dialog.advanced-finding") }) })
|
|
564
572
|
] });
|
|
565
573
|
}), ni = w(function(e, n) {
|
|
566
|
-
const i =
|
|
574
|
+
const i = v(g), r = v(O), s = v(te), a = v(me), l = I(i.currentMatch$, void 0, !0), d = I(i.replaceables$, void 0, !0), S = I(i.state$, void 0, !0), {
|
|
567
575
|
matchesCount: f,
|
|
568
576
|
matchesPosition: p,
|
|
569
577
|
findString: T,
|
|
@@ -571,118 +579,118 @@ const ii = w(function(e, n) {
|
|
|
571
579
|
replaceString: Ue,
|
|
572
580
|
caseSensitive: Be,
|
|
573
581
|
matchesTheWholeCell: We,
|
|
574
|
-
findDirection:
|
|
575
|
-
findScope:
|
|
576
|
-
findBy:
|
|
577
|
-
findCompleted:
|
|
578
|
-
} =
|
|
582
|
+
findDirection: ke,
|
|
583
|
+
findScope: Ge,
|
|
584
|
+
findBy: Ve,
|
|
585
|
+
findCompleted: k
|
|
586
|
+
} = S, He = C.length === 0, qe = f === 0 || !(l != null && l.replaceable), ze = d.length === 0, Ke = u(
|
|
579
587
|
(h) => i.changeInputtingFindString(h),
|
|
580
588
|
[i]
|
|
581
|
-
), Ye =
|
|
589
|
+
), Ye = u(
|
|
582
590
|
(h) => i.changeReplaceString(h),
|
|
583
591
|
[i]
|
|
584
|
-
), { focus: Ze } = je(i, n), Je =
|
|
592
|
+
), { focus: Ze } = je(i, n), Je = u(() => {
|
|
585
593
|
T === C ? i.moveToNextMatch() : (i.changeFindString(C), i.find());
|
|
586
|
-
}, [T, C, i]), Qe =
|
|
587
|
-
await
|
|
588
|
-
}, [
|
|
594
|
+
}, [T, C, i]), Qe = u(() => s.executeCommand(Ne.id), [s]), Xe = u(async () => {
|
|
595
|
+
await s.executeCommand($e.id), Ze();
|
|
596
|
+
}, [s]), et = u((h) => {
|
|
589
597
|
i.changeFindDirection(h);
|
|
590
|
-
}, [i]), tt =
|
|
598
|
+
}, [i]), tt = u((h) => {
|
|
591
599
|
i.changeFindScope(h);
|
|
592
|
-
}, [i]), it =
|
|
600
|
+
}, [i]), it = u((h) => {
|
|
593
601
|
i.changeFindBy(h);
|
|
594
|
-
}, [i]), nt =
|
|
602
|
+
}, [i]), nt = si(r), rt = ai(r), st = oi(r);
|
|
595
603
|
return j(() => {
|
|
596
|
-
const h =
|
|
604
|
+
const h = k && f === 0;
|
|
597
605
|
let E = null;
|
|
598
606
|
return h && (E = a.show({
|
|
599
|
-
content:
|
|
600
|
-
type:
|
|
607
|
+
content: r.t("find-replace.dialog.no-match"),
|
|
608
|
+
type: $.Warning,
|
|
601
609
|
duration: 5e3
|
|
602
610
|
})), () => E == null ? void 0 : E.dispose();
|
|
603
|
-
}, [
|
|
604
|
-
/* @__PURE__ */
|
|
611
|
+
}, [k, f, a, r]), /* @__PURE__ */ c.jsxs(N, { children: [
|
|
612
|
+
/* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.find"), children: /* @__PURE__ */ c.jsx(
|
|
605
613
|
Ae,
|
|
606
614
|
{
|
|
607
|
-
findCompleted:
|
|
615
|
+
findCompleted: k,
|
|
608
616
|
className: "univer-find-input",
|
|
609
617
|
matchesCount: f,
|
|
610
618
|
matchesPosition: p,
|
|
611
619
|
findReplaceService: i,
|
|
612
|
-
localeService:
|
|
620
|
+
localeService: r,
|
|
613
621
|
findString: C,
|
|
614
622
|
onChange: Ke
|
|
615
623
|
}
|
|
616
624
|
) }),
|
|
617
|
-
/* @__PURE__ */
|
|
618
|
-
|
|
625
|
+
/* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.replace"), children: /* @__PURE__ */ c.jsx(
|
|
626
|
+
$t,
|
|
619
627
|
{
|
|
620
|
-
placeholder:
|
|
628
|
+
placeholder: r.t("find-replace.dialog.replace-placeholder"),
|
|
621
629
|
value: Ue,
|
|
622
630
|
onChange: (h) => Ye(h)
|
|
623
631
|
}
|
|
624
632
|
) }),
|
|
625
|
-
/* @__PURE__ */
|
|
626
|
-
/* @__PURE__ */
|
|
627
|
-
/* @__PURE__ */
|
|
628
|
-
/* @__PURE__ */
|
|
633
|
+
/* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ c.jsx(G, { value: ke, options: rt, onChange: et }) }),
|
|
634
|
+
/* @__PURE__ */ c.jsx(le, { children: /* @__PURE__ */ c.jsxs(N, { children: [
|
|
635
|
+
/* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ c.jsx(G, { value: Ge, options: nt, onChange: tt }) }),
|
|
636
|
+
/* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ c.jsx(G, { value: Ve, options: st, onChange: it }) })
|
|
629
637
|
] }) }),
|
|
630
|
-
/* @__PURE__ */
|
|
631
|
-
/* @__PURE__ */
|
|
638
|
+
/* @__PURE__ */ c.jsx(le, { children: /* @__PURE__ */ c.jsxs(N, { children: [
|
|
639
|
+
/* @__PURE__ */ c.jsx(R, { children: /* @__PURE__ */ c.jsx(
|
|
632
640
|
de,
|
|
633
641
|
{
|
|
634
642
|
checked: Be,
|
|
635
643
|
onChange: (h) => {
|
|
636
644
|
i.changeCaseSensitive(h);
|
|
637
645
|
},
|
|
638
|
-
children:
|
|
646
|
+
children: r.t("find-replace.dialog.case-sensitive")
|
|
639
647
|
}
|
|
640
648
|
) }),
|
|
641
|
-
/* @__PURE__ */
|
|
649
|
+
/* @__PURE__ */ c.jsx(R, { children: /* @__PURE__ */ c.jsx(
|
|
642
650
|
de,
|
|
643
651
|
{
|
|
644
652
|
checked: We,
|
|
645
653
|
onChange: (h) => {
|
|
646
654
|
i.changeMatchesTheWholeCell(h);
|
|
647
655
|
},
|
|
648
|
-
children:
|
|
656
|
+
children: r.t("find-replace.dialog.match-the-whole-cell")
|
|
649
657
|
}
|
|
650
658
|
) })
|
|
651
659
|
] }) }),
|
|
652
|
-
/* @__PURE__ */
|
|
653
|
-
/* @__PURE__ */
|
|
654
|
-
/* @__PURE__ */
|
|
655
|
-
/* @__PURE__ */
|
|
656
|
-
/* @__PURE__ */
|
|
660
|
+
/* @__PURE__ */ c.jsxs("div", { className: L.findReplaceButtonsGroup, children: [
|
|
661
|
+
/* @__PURE__ */ c.jsx(A, { type: "primary", onClick: Je, disabled: He, children: r.t("find-replace.dialog.find") }),
|
|
662
|
+
/* @__PURE__ */ c.jsxs("span", { className: L.findReplaceButtonsGroupRight, children: [
|
|
663
|
+
/* @__PURE__ */ c.jsx(A, { disabled: qe, onClick: Qe, children: r.t("find-replace.dialog.replace") }),
|
|
664
|
+
/* @__PURE__ */ c.jsx(A, { disabled: ze, onClick: Xe, children: r.t("find-replace.dialog.replace-all") })
|
|
657
665
|
] })
|
|
658
666
|
] })
|
|
659
667
|
] });
|
|
660
668
|
});
|
|
661
|
-
function
|
|
662
|
-
const t =
|
|
669
|
+
function ri() {
|
|
670
|
+
const t = v(g), e = v(ve), n = v(ee), i = I(t.state$, void 0, !0), r = q(null);
|
|
663
671
|
j(() => {
|
|
664
672
|
let d;
|
|
665
|
-
return
|
|
673
|
+
return r.current && (d = e.registerContainerElement(r.current)), () => d == null ? void 0 : d.dispose();
|
|
666
674
|
}, [e]);
|
|
667
|
-
const
|
|
675
|
+
const s = q(null), a = u(
|
|
668
676
|
(d) => n.setContextValue(Ie, d),
|
|
669
677
|
[n]
|
|
670
|
-
),
|
|
678
|
+
), l = u(
|
|
671
679
|
(d) => n.setContextValue(ye, d),
|
|
672
680
|
[n]
|
|
673
681
|
);
|
|
674
682
|
return j(() => {
|
|
675
|
-
var
|
|
683
|
+
var S;
|
|
676
684
|
const d = Ft(document, "focusin").subscribe((f) => {
|
|
677
685
|
var p;
|
|
678
|
-
f.target && ((p =
|
|
686
|
+
f.target && ((p = r.current) != null && p.contains(f.target)) ? a(!0) : a(!1), !s.current || !s.current.selectHasFocus() ? l(!0) : l(!1);
|
|
679
687
|
});
|
|
680
|
-
return (
|
|
688
|
+
return (S = s.current) == null || S.focus(), a(!0), l(!0), () => {
|
|
681
689
|
d.unsubscribe(), a(!1);
|
|
682
690
|
};
|
|
683
|
-
}, [a,
|
|
691
|
+
}, [a, l]), /* @__PURE__ */ c.jsx("div", { className: L.findReplaceDialogContainer, ref: r, children: i.replaceRevealed ? /* @__PURE__ */ c.jsx(ni, { ref: s }) : /* @__PURE__ */ c.jsx(ii, { ref: s }) });
|
|
684
692
|
}
|
|
685
|
-
function
|
|
693
|
+
function si(t) {
|
|
686
694
|
const e = t.getCurrentLocale();
|
|
687
695
|
return ne(() => [
|
|
688
696
|
{ label: t.t("find-replace.dialog.find-scope.current-sheet"), value: J.SUBUNIT },
|
|
@@ -703,7 +711,7 @@ function oi(t) {
|
|
|
703
711
|
{ label: t.t("find-replace.dialog.find-by.formula"), value: Z.FORMULA }
|
|
704
712
|
], [e]);
|
|
705
713
|
}
|
|
706
|
-
function
|
|
714
|
+
function P(t) {
|
|
707
715
|
return t.getContextValue(Ie);
|
|
708
716
|
}
|
|
709
717
|
function ci(t) {
|
|
@@ -722,45 +730,45 @@ function oe(t) {
|
|
|
722
730
|
const li = {
|
|
723
731
|
id: U.id,
|
|
724
732
|
description: "find-replace.shortcut.open-find-dialog",
|
|
725
|
-
binding: M.F |
|
|
733
|
+
binding: M.F | x.CTRL_COMMAND,
|
|
726
734
|
group: W,
|
|
727
735
|
preconditions(t) {
|
|
728
|
-
return !
|
|
736
|
+
return !P(t) && ae(t) && oe(t);
|
|
729
737
|
}
|
|
730
738
|
}, di = {
|
|
731
739
|
id: U.id,
|
|
732
740
|
description: "find-replace.shortcut.open-find-dialog",
|
|
733
|
-
binding: M.F |
|
|
734
|
-
mac: M.F |
|
|
741
|
+
binding: M.F | x.CTRL_COMMAND,
|
|
742
|
+
mac: M.F | x.MAC_CTRL,
|
|
735
743
|
preconditions(t) {
|
|
736
|
-
return !
|
|
744
|
+
return !P(t) && ae(t) && oe(t);
|
|
737
745
|
}
|
|
738
746
|
}, hi = {
|
|
739
|
-
id:
|
|
747
|
+
id: se.id,
|
|
740
748
|
description: "find-replace.shortcut.open-replace-dialog",
|
|
741
|
-
binding: M.H |
|
|
742
|
-
mac: M.H |
|
|
749
|
+
binding: M.H | x.CTRL_COMMAND,
|
|
750
|
+
mac: M.H | x.MAC_CTRL,
|
|
743
751
|
group: W,
|
|
744
752
|
preconditions(t) {
|
|
745
|
-
return ae(t) && oe(t) && (!
|
|
753
|
+
return ae(t) && oe(t) && (!P(t) || !ci(t));
|
|
746
754
|
}
|
|
747
755
|
}, ui = {
|
|
748
|
-
id:
|
|
756
|
+
id: Oe.id,
|
|
749
757
|
description: "find-replace.shortcut.go-to-next-match",
|
|
750
758
|
binding: M.ENTER,
|
|
751
759
|
group: W,
|
|
752
760
|
priority: 1e3,
|
|
753
761
|
preconditions(t) {
|
|
754
|
-
return Le(t) &&
|
|
762
|
+
return Le(t) && P(t);
|
|
755
763
|
}
|
|
756
764
|
}, fi = {
|
|
757
|
-
id:
|
|
765
|
+
id: Pe.id,
|
|
758
766
|
description: "find-replace.shortcut.go-to-previous-match",
|
|
759
|
-
binding: M.ENTER |
|
|
767
|
+
binding: M.ENTER | x.SHIFT,
|
|
760
768
|
group: W,
|
|
761
769
|
priority: 1e3,
|
|
762
770
|
preconditions(t) {
|
|
763
|
-
return Le(t) &&
|
|
771
|
+
return Le(t) && P(t);
|
|
764
772
|
}
|
|
765
773
|
};
|
|
766
774
|
function pi(t) {
|
|
@@ -776,27 +784,27 @@ function pi(t) {
|
|
|
776
784
|
disabled$: Ce([
|
|
777
785
|
e.subscribeContextValue$(ge),
|
|
778
786
|
e.subscribeContextValue$(_e)
|
|
779
|
-
]).pipe(
|
|
787
|
+
]).pipe(Dt(([n, i]) => n || !i))
|
|
780
788
|
};
|
|
781
789
|
}
|
|
782
790
|
var _i = Object.defineProperty, gi = Object.getOwnPropertyDescriptor, mi = (t, e, n, i) => {
|
|
783
|
-
for (var
|
|
784
|
-
(a = t[
|
|
785
|
-
return i &&
|
|
786
|
-
},
|
|
791
|
+
for (var r = i > 1 ? void 0 : i ? gi(e, n) : e, s = t.length - 1, a; s >= 0; s--)
|
|
792
|
+
(a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
|
|
793
|
+
return i && r && _i(e, n, r), r;
|
|
794
|
+
}, m = (t, e) => (n, i) => e(n, i, t);
|
|
787
795
|
const vi = {}, he = "DESKTOP_FIND_REPLACE_DIALOG", we = 350, Si = 20, Ci = -90;
|
|
788
796
|
let F = class extends dt {
|
|
789
|
-
constructor(t, e, n, i,
|
|
790
|
-
super(), this._config = t, this._univerInstanceService = e, this._menuService = n, this._shortcutService = i, this._commandService =
|
|
797
|
+
constructor(t, e, n, i, r, s, a, l, d, S, f) {
|
|
798
|
+
super(), this._config = t, this._univerInstanceService = e, this._menuService = n, this._shortcutService = i, this._commandService = r, this._findReplaceService = s, this._dialogService = a, this._layoutService = l, this._localeService = d, this._componentManager = S, this._injector = f, this._initCommands(), this._initUI(), this._initShortcuts();
|
|
791
799
|
}
|
|
792
800
|
_initCommands() {
|
|
793
801
|
[
|
|
794
802
|
U,
|
|
795
|
-
|
|
796
|
-
De,
|
|
803
|
+
se,
|
|
797
804
|
Oe,
|
|
798
|
-
|
|
799
|
-
$e
|
|
805
|
+
Pe,
|
|
806
|
+
$e,
|
|
807
|
+
Ne
|
|
800
808
|
].forEach((t) => {
|
|
801
809
|
this.disposeWithMe(this._commandService.registerCommand(t));
|
|
802
810
|
});
|
|
@@ -812,7 +820,7 @@ let F = class extends dt {
|
|
|
812
820
|
}
|
|
813
821
|
_initUI() {
|
|
814
822
|
const { menu: t = {} } = this._config;
|
|
815
|
-
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(pi), t)), this.disposeWithMe(this._componentManager.register("FindReplaceDialog",
|
|
823
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(pi), t)), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", ri)), this.disposeWithMe(this._componentManager.register("SearchIcon", xe)), this._findReplaceService.stateUpdates$.pipe(ce(this.dispose$)).subscribe((e) => {
|
|
816
824
|
e.revealed === !0 && this._openPanel();
|
|
817
825
|
}), this.disposeWithMe(
|
|
818
826
|
this._univerInstanceService.focused$.pipe(ce(this.dispose$)).subscribe((e) => {
|
|
@@ -839,29 +847,29 @@ let F = class extends dt {
|
|
|
839
847
|
};
|
|
840
848
|
F = mi([
|
|
841
849
|
ht(ut.Rendered, F),
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
850
|
+
m(1, pe),
|
|
851
|
+
m(2, Mt),
|
|
852
|
+
m(3, bt),
|
|
853
|
+
m(4, te),
|
|
854
|
+
m(5, g),
|
|
855
|
+
m(6, xt),
|
|
856
|
+
m(7, ve),
|
|
857
|
+
m(8, b(O)),
|
|
858
|
+
m(9, b(Rt)),
|
|
859
|
+
m(10, b(ie))
|
|
852
860
|
], F);
|
|
853
861
|
function Ri() {
|
|
854
862
|
const { innerWidth: t } = window;
|
|
855
863
|
return { x: (t - we) / 2 - Si, y: Ci };
|
|
856
864
|
}
|
|
857
|
-
var Mi = Object.defineProperty,
|
|
858
|
-
for (var
|
|
859
|
-
(a = t[
|
|
860
|
-
return i &&
|
|
865
|
+
var Mi = Object.defineProperty, bi = Object.getOwnPropertyDescriptor, xi = (t, e, n, i) => {
|
|
866
|
+
for (var r = i > 1 ? void 0 : i ? bi(e, n) : e, s = t.length - 1, a; s >= 0; s--)
|
|
867
|
+
(a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
|
|
868
|
+
return i && r && Mi(e, n, r), r;
|
|
861
869
|
}, ue = (t, e) => (n, i) => e(n, i, t);
|
|
862
870
|
const yi = "FIND_REPLACE_PLUGIN";
|
|
863
|
-
var
|
|
864
|
-
let fe = (
|
|
871
|
+
var V;
|
|
872
|
+
let fe = (V = class extends ft {
|
|
865
873
|
constructor(t = {}, e, n) {
|
|
866
874
|
super(), this._config = t, this._injector = e, this._localeService = n, this._config = pt.deepMerge({}, vi, this._config);
|
|
867
875
|
}
|
|
@@ -873,17 +881,17 @@ let fe = (k = class extends ft {
|
|
|
873
881
|
useFactory: () => this._injector.createInstance(F, this._config)
|
|
874
882
|
}
|
|
875
883
|
],
|
|
876
|
-
[
|
|
884
|
+
[g, { useClass: Q }]
|
|
877
885
|
].forEach(
|
|
878
886
|
(e) => {
|
|
879
887
|
t.add(e);
|
|
880
888
|
}
|
|
881
889
|
);
|
|
882
890
|
}
|
|
883
|
-
},
|
|
884
|
-
fe =
|
|
885
|
-
ue(1,
|
|
886
|
-
ue(2,
|
|
891
|
+
}, o(V, "pluginName", yi), V);
|
|
892
|
+
fe = xi([
|
|
893
|
+
ue(1, b(ie)),
|
|
894
|
+
ue(2, b(O))
|
|
887
895
|
], fe);
|
|
888
896
|
export {
|
|
889
897
|
Z as FindBy,
|
|
@@ -891,12 +899,12 @@ export {
|
|
|
891
899
|
Ai as FindModel,
|
|
892
900
|
F as FindReplaceController,
|
|
893
901
|
J as FindScope,
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
902
|
+
Oe as GoToNextMatchOperation,
|
|
903
|
+
Pe as GoToPreviousMatchOperation,
|
|
904
|
+
g as IFindReplaceService,
|
|
897
905
|
U as OpenFindDialogOperation,
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
906
|
+
se as OpenReplaceDialogOperation,
|
|
907
|
+
$e as ReplaceAllMatchesCommand,
|
|
908
|
+
Ne as ReplaceCurrentMatchCommand,
|
|
901
909
|
fe as UniverFindReplacePlugin
|
|
902
910
|
};
|