@univerjs/find-replace 0.1.2 → 0.1.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/README.md +9 -1
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +786 -431
- package/lib/index.css +1 -1
- package/lib/types/{views/dialog/Dialog.d.ts → commands/command/replace.command.d.ts} +3 -2
- package/lib/types/commands/operations/find-replace.operation.d.ts +0 -2
- package/lib/types/controllers/find-replace.controller.d.ts +7 -5
- package/lib/types/controllers/find-replace.shortcut.d.ts +1 -1
- package/lib/types/index.d.ts +3 -2
- package/lib/types/locale/en-US.d.ts +48 -2
- package/lib/types/locale/zh-CN.d.ts +2 -16
- package/lib/types/services/context-keys.d.ts +7 -2
- package/lib/types/services/find-replace.service.d.ts +184 -49
- package/lib/types/views/dialog/FindReplaceDialog.d.ts +19 -0
- package/lib/types/views/dialog/SearchInput.d.ts +28 -0
- package/lib/umd/index.js +2 -2
- package/package.json +25 -17
- /package/lib/types/views/dialog/{Dialog.stories.d.ts → FindReplaceDialog.stories.d.ts} +0 -0
package/lib/es/index.js
CHANGED
|
@@ -1,245 +1,331 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Disposable as
|
|
5
|
-
import { createIdentifier as
|
|
6
|
-
import { ILayoutService as
|
|
7
|
-
import { Subject as
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var rt = Object.defineProperty;
|
|
2
|
+
var at = (t, e, n) => e in t ? rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var c = (t, e, n) => (at(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
+
import { Disposable as X, IUniverInstanceService as he, ILogService as ue, toDisposable as q, IContextService as U, DisposableCollection as ot, CommandType as b, LocaleService as P, ICommandService as ee, FOCUSING_SHEET as fe, EDITOR_ACTIVATED as pe, UniverInstanceType as ct, RxDisposable as lt, OnLifecycle as dt, LifecycleStages as ht, Plugin as ut } from "@univerjs/core";
|
|
5
|
+
import { createIdentifier as ft, Inject as y, Injector as _e } from "@wendellhu/redi";
|
|
6
|
+
import { IConfirmService as pt, IMessageService as ge, useObservable as I, ILayoutService as me, KeyCode as x, MetaKeys as M, MenuGroup as _t, MenuItemType as gt, MenuPosition as mt, getMenuHiddenObservable as vt, ComponentManager as St, IMenuService as Ct, IShortcutService as Rt, IDialogService as xt } from "@univerjs/ui";
|
|
7
|
+
import { BehaviorSubject as F, Subject as ve, throttleTime as Mt, combineLatest as Se, debounceTime as bt, fromEvent as yt, map as It, takeUntil as ae } from "rxjs";
|
|
8
|
+
import { RENDER_RAW_FORMULA_KEY as Ft } from "@univerjs/engine-render";
|
|
9
|
+
import Pt, { forwardRef as B, useRef as z, createElement as Ce, useCallback as _, Fragment as E, useEffect as j, useMemo as te, useImperativeHandle as Dt } from "react";
|
|
10
|
+
import { MessageType as $, InputWithSlot as Ot, Pager as Tt, Button as N, FormLayout as R, Input as Et, Select as H, FormDualColumnLayout as oe, Checkbox as ce } from "@univerjs/design";
|
|
11
|
+
import { useDependency as S } from "@wendellhu/redi/react-bindings";
|
|
12
|
+
var m = function() {
|
|
13
|
+
return m = Object.assign || function(t) {
|
|
13
14
|
for (var e, n = 1, i = arguments.length; n < i; n++) {
|
|
14
15
|
e = arguments[n];
|
|
15
|
-
for (var
|
|
16
|
-
Object.prototype.hasOwnProperty.call(e,
|
|
16
|
+
for (var s in e)
|
|
17
|
+
Object.prototype.hasOwnProperty.call(e, s) && (t[s] = e[s]);
|
|
17
18
|
}
|
|
18
19
|
return t;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
20
|
+
}, m.apply(this, arguments);
|
|
21
|
+
}, $t = function(t, e) {
|
|
21
22
|
var n = {};
|
|
22
23
|
for (var i in t)
|
|
23
24
|
Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
|
|
24
25
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
25
|
-
for (var
|
|
26
|
-
e.indexOf(i[
|
|
26
|
+
for (var s = 0, i = Object.getOwnPropertySymbols(t); s < i.length; s++)
|
|
27
|
+
e.indexOf(i[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[s]) && (n[i[s]] = t[i[s]]);
|
|
27
28
|
return n;
|
|
28
|
-
},
|
|
29
|
-
var n = t.icon, i = t.id,
|
|
30
|
-
return
|
|
29
|
+
}, Re = B(function(t, e) {
|
|
30
|
+
var n = t.icon, i = t.id, s = t.className, r = t.extend, a = $t(t, ["icon", "id", "className", "extend"]), o = "univerjs-icon univerjs-icon-".concat(i, " ").concat(s || "").trim(), d = z("_".concat(jt()));
|
|
31
|
+
return xe(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, m({ ref: e, className: o }, a), r);
|
|
31
32
|
});
|
|
32
|
-
function
|
|
33
|
-
return
|
|
34
|
-
return
|
|
33
|
+
function xe(t, e, n, i, s) {
|
|
34
|
+
return Ce(t.tag, m(m({ key: e }, Nt(t, n, s)), i), (At(t, n).children || []).map(function(r, a) {
|
|
35
|
+
return xe(r, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, s);
|
|
35
36
|
}));
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
var i =
|
|
38
|
+
function Nt(t, e, n) {
|
|
39
|
+
var i = m({}, t.attrs);
|
|
39
40
|
n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
|
|
40
|
-
var
|
|
41
|
-
return !
|
|
42
|
-
var a =
|
|
43
|
-
typeof
|
|
41
|
+
var s = e.defIds;
|
|
42
|
+
return !s || s.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(r) {
|
|
43
|
+
var a = r[0], o = r[1];
|
|
44
|
+
typeof o == "string" && (i[a] = o.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
44
45
|
})), i;
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
+
function At(t, e) {
|
|
47
48
|
var n, i = e.defIds;
|
|
48
|
-
return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ?
|
|
49
|
-
return typeof
|
|
49
|
+
return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? m(m({}, t), { children: t.children.map(function(s) {
|
|
50
|
+
return typeof s.attrs.id == "string" && i && i.indexOf(s.attrs.id) > -1 ? m(m({}, s), { attrs: m(m({}, s.attrs), { id: s.attrs.id + e.idSuffix }) }) : s;
|
|
50
51
|
}) }) : t;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function jt() {
|
|
53
54
|
return Math.random().toString(36).substring(2, 8);
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" },
|
|
59
|
-
children: [
|
|
60
|
-
{
|
|
61
|
-
tag: "mask",
|
|
62
|
-
attrs: {
|
|
63
|
-
id: "mask0_217_40",
|
|
64
|
-
style: { maskType: "alpha" },
|
|
65
|
-
width: 17,
|
|
66
|
-
height: 17,
|
|
67
|
-
x: 0,
|
|
68
|
-
y: 0,
|
|
69
|
-
maskUnits: "userSpaceOnUse"
|
|
70
|
-
},
|
|
71
|
-
children: [
|
|
72
|
-
{
|
|
73
|
-
tag: "path",
|
|
74
|
-
attrs: { fill: "#D9D9D9", d: "M0.9 0.09H16.9V16.09H0.9z" }
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
tag: "g",
|
|
80
|
-
attrs: { mask: "url(#mask0_217_40)" },
|
|
81
|
-
children: [
|
|
82
|
-
{
|
|
83
|
-
tag: "path",
|
|
84
|
-
attrs: {
|
|
85
|
-
fill: "currentColor",
|
|
86
|
-
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",
|
|
87
|
-
fillRule: "evenodd",
|
|
88
|
-
clipRule: "evenodd"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}, J = k(function(t, e) {
|
|
95
|
-
return K(q, Object.assign({}, t, {
|
|
56
|
+
Re.displayName = "UniverIcon";
|
|
57
|
+
var wt = { 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" } }] }] }, Me = B(function(t, e) {
|
|
58
|
+
return Ce(Re, Object.assign({}, t, {
|
|
96
59
|
id: "search-single-16",
|
|
97
60
|
ref: e,
|
|
98
|
-
icon:
|
|
61
|
+
icon: wt
|
|
99
62
|
}));
|
|
100
63
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
64
|
+
Me.displayName = "SearchSingle16";
|
|
65
|
+
const be = "FIND_REPLACE_INPUT_FOCUS", ye = "FIND_REPLACE_DIALOG_FOCUS", Ie = "FIND_REPLACE_REPLACE_REVEALED";
|
|
66
|
+
var Lt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, Fe = (t, e, n, i) => {
|
|
67
|
+
for (var s = i > 1 ? void 0 : i ? Ut(e, n) : e, r = t.length - 1, a; r >= 0; r--)
|
|
68
|
+
(a = t[r]) && (s = (i ? a(e, n, s) : a(s)) || s);
|
|
69
|
+
return i && s && Lt(e, n, s), s;
|
|
70
|
+
}, w = (t, e) => (n, i) => e(n, i, t);
|
|
71
|
+
class Ni extends X {
|
|
108
72
|
}
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
l(this, "_stateUpdates$", new be());
|
|
113
|
-
l(this, "stateUpdates$", this._stateUpdates$.asObservable());
|
|
114
|
-
l(this, "_state$", new Ee(Q()));
|
|
115
|
-
l(this, "state$", this._state$.asObservable());
|
|
116
|
-
// TODO@wzhudev: put all state properties here
|
|
117
|
-
l(this, "_findString", "");
|
|
118
|
-
l(this, "_revealed", !1);
|
|
119
|
-
l(this, "_replaceRevealed", !1);
|
|
120
|
-
l(this, "_matchesPosition", 0);
|
|
121
|
-
l(this, "_matchesCount", 0);
|
|
122
|
-
}
|
|
123
|
-
get state() {
|
|
124
|
-
return this._state$.getValue();
|
|
125
|
-
}
|
|
126
|
-
get findString() {
|
|
127
|
-
return this._findString;
|
|
128
|
-
}
|
|
129
|
-
changeState(e) {
|
|
130
|
-
let n = !1;
|
|
131
|
-
const i = {};
|
|
132
|
-
typeof e.findString < "u" && e.findString !== this._findString && (this._findString = e.findString, i.findString = this._findString, n = !0), typeof e.revealed < "u" && e.revealed !== this._revealed && (this._revealed = e.revealed, i.revealed = e.revealed, n = !0), typeof e.replaceRevealed < "u" && e.replaceRevealed !== this._replaceRevealed && (this._replaceRevealed = e.replaceRevealed, i.replaceRevealed = e.replaceRevealed, n = !0), typeof e.matchesCount < "u" && e.matchesCount !== this._matchesCount && (this._matchesCount = e.matchesCount, i.matchesCount = e.matchesCount, n = !0), typeof e.matchesPosition < "u" && e.matchesPosition !== this._matchesPosition && (this._matchesPosition = e.matchesPosition, i.matchesPosition = e.matchesPosition, n = !0), n && (this._stateUpdates$.next(i), this._state$.next({
|
|
133
|
-
findString: this._findString,
|
|
134
|
-
revealed: this._revealed,
|
|
135
|
-
replaceRevealed: this._replaceRevealed,
|
|
136
|
-
matchesCount: this._matchesCount,
|
|
137
|
-
matchesPosition: this._matchesPosition
|
|
138
|
-
}));
|
|
139
|
-
}
|
|
73
|
+
const v = ft("find-replace.service");
|
|
74
|
+
function Bt(t) {
|
|
75
|
+
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";
|
|
140
76
|
}
|
|
141
|
-
let
|
|
142
|
-
constructor(e, n, i,
|
|
77
|
+
let K = class extends X {
|
|
78
|
+
constructor(e, n, i, s) {
|
|
143
79
|
super();
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
80
|
+
c(this, "currentMatch$", new F(null));
|
|
81
|
+
c(this, "replaceables$", new F([]));
|
|
82
|
+
/** All find models returned by providers. */
|
|
83
|
+
c(this, "_findModels", []);
|
|
84
|
+
/** The find model that the current match is from. */
|
|
85
|
+
c(this, "_matchingModel", null);
|
|
86
|
+
c(this, "_matches", []);
|
|
87
|
+
c(this, "_currentSearchingDisposables", null);
|
|
88
|
+
this._state = e, this._providers = n, this._univerInstanceService = i, this._logService = s, this.disposeWithMe(
|
|
89
|
+
this._state.stateUpdates$.pipe(Mt(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (r) => {
|
|
90
|
+
const a = this._state.state;
|
|
91
|
+
Bt(r) && (a.findString !== "" && !a.replaceRevealed ? (await this._startSearching(), this._state.changeState({ findCompleted: !0 })) : r.replaceRevealed !== !0 && this._stopSearching());
|
|
92
|
+
})
|
|
93
|
+
);
|
|
151
94
|
}
|
|
152
|
-
|
|
153
|
-
this.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
95
|
+
get searched() {
|
|
96
|
+
return this._findModels.length > 0;
|
|
97
|
+
}
|
|
98
|
+
dispose() {
|
|
99
|
+
super.dispose(), this._stopSearching(), this.currentMatch$.complete(), this.replaceables$.complete(), this._state.changeState({ ...ie(), revealed: !1 });
|
|
100
|
+
}
|
|
101
|
+
async start() {
|
|
102
|
+
if (!this._state.findString)
|
|
103
|
+
return { results: [] };
|
|
104
|
+
const e = await this._startSearching();
|
|
105
|
+
return this._state.changeState({ findCompleted: !0 }), e;
|
|
106
|
+
}
|
|
107
|
+
/** Call this method to start a `searching`. */
|
|
108
|
+
async _startSearching() {
|
|
109
|
+
if (!this._state.findString)
|
|
110
|
+
return { results: [] };
|
|
111
|
+
const e = Array.from(this._providers), n = this._findModels = (await Promise.all(e.map((r) => r.find({
|
|
112
|
+
findString: this._state.findString,
|
|
113
|
+
findDirection: this._state.findDirection,
|
|
114
|
+
findScope: this._state.findScope,
|
|
115
|
+
findBy: this._state.findBy,
|
|
116
|
+
replaceRevealed: this._state.replaceRevealed,
|
|
117
|
+
caseSensitive: this._state.caseSensitive,
|
|
118
|
+
matchesTheWholeCell: this._state.matchesTheWholeCell
|
|
119
|
+
})))).flat();
|
|
120
|
+
this._subscribeToModelsChanges(n);
|
|
121
|
+
const i = this._matches = n.map((r) => r.getMatches()).flat();
|
|
122
|
+
if (this.replaceables$.next(i.filter((r) => r.replaceable)), !i.length)
|
|
123
|
+
return this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), { results: [] };
|
|
124
|
+
const s = this._moveToInitialMatch(n, i);
|
|
160
125
|
return this._state.changeState({
|
|
161
126
|
matchesCount: i.length,
|
|
162
|
-
matchesPosition:
|
|
127
|
+
matchesPosition: s + 1
|
|
163
128
|
// the matches position start from 1
|
|
164
|
-
}), {
|
|
165
|
-
|
|
166
|
-
|
|
129
|
+
}), { results: i };
|
|
130
|
+
}
|
|
131
|
+
/** Terminate the current searching session, when searching string is empty. */
|
|
132
|
+
_stopSearching() {
|
|
133
|
+
var e;
|
|
134
|
+
this._providers.forEach((n) => n.terminate()), this._findModels = [], this._matches = [], this._matchingModel = null, (e = this._currentSearchingDisposables) == null || e.dispose(), this._currentSearchingDisposables = null, this.currentMatch$.next(null), this.replaceables$.next([]), this._state.changeState({
|
|
135
|
+
findCompleted: !1,
|
|
136
|
+
matchesCount: 0,
|
|
137
|
+
matchesPosition: 0
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// When a document's content changes, we should reset all matches and try to move to the next match.
|
|
141
|
+
_subscribeToModelsChanges(e) {
|
|
142
|
+
const n = this._currentSearchingDisposables = new ot(), i = Se(e.map((s) => s.matchesUpdate$)).pipe(bt(220)).subscribe(([...s]) => {
|
|
143
|
+
const r = this._matches = s.flat();
|
|
144
|
+
if (r.length) {
|
|
145
|
+
const a = this._moveToInitialMatch(this._findModels, r, !0);
|
|
146
|
+
this._state.changeState({ matchesCount: r.length, matchesPosition: a + 1 }), this.replaceables$.next(r.filter((o) => o.replaceable));
|
|
147
|
+
} else
|
|
148
|
+
this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), this.replaceables$.next([]);
|
|
149
|
+
});
|
|
150
|
+
e.forEach((s) => n.add(q(s.activelyChangingMatch$.subscribe((r) => {
|
|
151
|
+
const a = this._matches.findIndex((o) => o === r);
|
|
152
|
+
this._state.changeState({ matchesPosition: a + 1 });
|
|
153
|
+
})))), n.add(q(i));
|
|
154
|
+
}
|
|
155
|
+
async replace() {
|
|
156
|
+
return this._matchingModel ? this._matchingModel.replace(this._state.replaceString) : !1;
|
|
157
|
+
}
|
|
158
|
+
async replaceAll() {
|
|
159
|
+
const e = await Promise.all(this._findModels.map((n) => n.replaceAll(this._state.replaceString))).then((n) => n.reduce((i, s) => (i.success += s.success, i.failure += s.failure, i), { success: 0, failure: 0 }));
|
|
160
|
+
return e.failure === 0 && this._stopSearching(), e;
|
|
161
|
+
}
|
|
162
|
+
getCurrentMatch() {
|
|
163
|
+
return this._state.matchesPosition > 0 ? this._matches[this._state.matchesPosition - 1] : null;
|
|
167
164
|
}
|
|
168
165
|
moveToNextMatch() {
|
|
169
|
-
if (!this.
|
|
166
|
+
if (!this._matchingModel)
|
|
170
167
|
return;
|
|
171
|
-
const e = this._findModels.length === 1, n = this.
|
|
168
|
+
const e = this._findModels.length === 1, n = this._matchingModel.moveToNextMatch({ loop: e });
|
|
172
169
|
if (n) {
|
|
173
|
-
const i = this._matches.findIndex((
|
|
174
|
-
this._state.changeState({
|
|
170
|
+
const i = this._matches.findIndex((s) => s === n);
|
|
171
|
+
this.currentMatch$.next(n), this._state.changeState({
|
|
175
172
|
matchesPosition: i + 1
|
|
176
173
|
});
|
|
177
174
|
} else {
|
|
178
|
-
const i = this._findModels.findIndex((
|
|
179
|
-
this.
|
|
175
|
+
const i = this._findModels.findIndex((o) => o === this._matchingModel), s = this._findModels[(i + 1) % this._findModels.length], r = s.moveToNextMatch(), a = this._matches.findIndex((o) => o === r);
|
|
176
|
+
this.currentMatch$.next(r), this._matchingModel = s, this._state.changeState({
|
|
180
177
|
matchesPosition: a + 1
|
|
181
178
|
});
|
|
182
179
|
}
|
|
183
180
|
}
|
|
184
181
|
moveToPreviousMatch() {
|
|
185
|
-
if (!this.
|
|
182
|
+
if (!this._matchingModel)
|
|
186
183
|
return;
|
|
187
|
-
const e = this._findModels.length === 1, n = this.
|
|
184
|
+
const e = this._findModels.length === 1, n = this._matchingModel.moveToPreviousMatch({ loop: e });
|
|
188
185
|
if (n) {
|
|
189
|
-
const i = this._matches.findIndex((
|
|
190
|
-
this._state.changeState({
|
|
186
|
+
const i = this._matches.findIndex((s) => s === n);
|
|
187
|
+
this.currentMatch$.next(n), this._state.changeState({
|
|
191
188
|
matchesPosition: i + 1
|
|
192
189
|
});
|
|
193
190
|
} else {
|
|
194
|
-
const i = this._findModels.findIndex((
|
|
195
|
-
this.
|
|
191
|
+
const i = this._findModels.findIndex((o) => o === this._matchingModel), s = this._findModels[(i - 1 + this._findModels.length) % this._findModels.length], r = s.moveToPreviousMatch(), a = this._matches.findIndex((o) => o === r);
|
|
192
|
+
this.currentMatch$.next(r), this._matchingModel = s, this._state.changeState({
|
|
196
193
|
matchesPosition: a + 1
|
|
197
194
|
});
|
|
198
195
|
}
|
|
199
196
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (!i)
|
|
197
|
+
_moveToInitialMatch(e, n, i = !1) {
|
|
198
|
+
var d;
|
|
199
|
+
const s = (d = this._univerInstanceService.getFocusedUniverInstance()) == null ? void 0 : d.getUnitId();
|
|
200
|
+
if (!s)
|
|
205
201
|
return -1;
|
|
206
|
-
const r = e.find((
|
|
202
|
+
const r = e.find((u) => u.unitId === s);
|
|
207
203
|
if (r) {
|
|
208
|
-
this.
|
|
209
|
-
const
|
|
210
|
-
return
|
|
204
|
+
this._matchingModel = r;
|
|
205
|
+
const u = r.moveToNextMatch({ stayIfOnMatch: !0, noFocus: i }), p = n.findIndex((f) => f === u);
|
|
206
|
+
return this.currentMatch$.next(u), p;
|
|
211
207
|
}
|
|
212
|
-
this.
|
|
213
|
-
const
|
|
214
|
-
return this.
|
|
215
|
-
}
|
|
216
|
-
_cancelFinding() {
|
|
217
|
-
this._providers.forEach((e) => e.cancel()), this._state.changeState({
|
|
218
|
-
matchesCount: 0,
|
|
219
|
-
matchesPosition: 0
|
|
220
|
-
});
|
|
208
|
+
this._matchingModel = e[0];
|
|
209
|
+
const a = this._matchingModel.moveToNextMatch({ noFocus: i }), o = this._matches.findIndex((u) => u === a);
|
|
210
|
+
return this.currentMatch$.next(a), o;
|
|
221
211
|
}
|
|
222
212
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
],
|
|
227
|
-
|
|
213
|
+
K = Fe([
|
|
214
|
+
w(2, he),
|
|
215
|
+
w(3, ue)
|
|
216
|
+
], K);
|
|
217
|
+
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 || {});
|
|
218
|
+
function ie() {
|
|
228
219
|
return {
|
|
229
|
-
|
|
220
|
+
caseSensitive: !1,
|
|
221
|
+
findBy: "value",
|
|
222
|
+
findCompleted: !1,
|
|
223
|
+
findDirection: "row",
|
|
224
|
+
findScope: "subunit",
|
|
230
225
|
findString: "",
|
|
231
|
-
|
|
226
|
+
inputtingFindString: "",
|
|
227
|
+
matchesCount: 0,
|
|
232
228
|
matchesPosition: 0,
|
|
233
|
-
|
|
229
|
+
matchesTheWholeCell: !1,
|
|
230
|
+
replaceRevealed: !1,
|
|
231
|
+
replaceString: "",
|
|
232
|
+
revealed: !0
|
|
234
233
|
};
|
|
235
234
|
}
|
|
236
|
-
|
|
237
|
-
constructor(
|
|
235
|
+
class Wt {
|
|
236
|
+
constructor() {
|
|
237
|
+
c(this, "_stateUpdates$", new ve());
|
|
238
|
+
c(this, "stateUpdates$", this._stateUpdates$.asObservable());
|
|
239
|
+
c(this, "_state$", new F(ie()));
|
|
240
|
+
c(this, "state$", this._state$.asObservable());
|
|
241
|
+
c(this, "_findString", "");
|
|
242
|
+
c(this, "_inputtingFindString", "");
|
|
243
|
+
c(this, "_replaceString", "");
|
|
244
|
+
c(this, "_revealed", !1);
|
|
245
|
+
c(this, "_replaceRevealed", !1);
|
|
246
|
+
c(this, "_matchesPosition", 0);
|
|
247
|
+
c(this, "_matchesCount", 0);
|
|
248
|
+
c(this, "_caseSensitive", !0);
|
|
249
|
+
c(this, "_matchesTheWholeCell", !1);
|
|
250
|
+
c(this, "_findDirection", "row");
|
|
251
|
+
c(this, "_findScope", "subunit");
|
|
252
|
+
c(this, "_findBy", "value");
|
|
253
|
+
c(this, "_findCompleted", !1);
|
|
254
|
+
}
|
|
255
|
+
get state() {
|
|
256
|
+
return this._state$.getValue();
|
|
257
|
+
}
|
|
258
|
+
get inputtingFindString() {
|
|
259
|
+
return this._inputtingFindString;
|
|
260
|
+
}
|
|
261
|
+
get findString() {
|
|
262
|
+
return this._findString;
|
|
263
|
+
}
|
|
264
|
+
get revealed() {
|
|
265
|
+
return this._revealed;
|
|
266
|
+
}
|
|
267
|
+
get replaceRevealed() {
|
|
268
|
+
return this._replaceRevealed;
|
|
269
|
+
}
|
|
270
|
+
get matchesPosition() {
|
|
271
|
+
return this._matchesPosition;
|
|
272
|
+
}
|
|
273
|
+
get matchesCount() {
|
|
274
|
+
return this._matchesCount;
|
|
275
|
+
}
|
|
276
|
+
get replaceString() {
|
|
277
|
+
return this._replaceString;
|
|
278
|
+
}
|
|
279
|
+
get caseSensitive() {
|
|
280
|
+
return this._caseSensitive;
|
|
281
|
+
}
|
|
282
|
+
get matchesTheWholeCell() {
|
|
283
|
+
return this._matchesTheWholeCell;
|
|
284
|
+
}
|
|
285
|
+
get findDirection() {
|
|
286
|
+
return this._findDirection;
|
|
287
|
+
}
|
|
288
|
+
get findScope() {
|
|
289
|
+
return this._findScope;
|
|
290
|
+
}
|
|
291
|
+
get findBy() {
|
|
292
|
+
return this._findBy;
|
|
293
|
+
}
|
|
294
|
+
get findCompleted() {
|
|
295
|
+
return this._findCompleted;
|
|
296
|
+
}
|
|
297
|
+
changeState(e) {
|
|
298
|
+
let n = !1;
|
|
299
|
+
const i = {};
|
|
300
|
+
typeof e.findString < "u" && e.findString !== this._findString && (this._findString = e.findString, i.findString = this._findString, n = !0), typeof e.revealed < "u" && e.revealed !== this._revealed && (this._revealed = e.revealed, i.revealed = e.revealed, n = !0), typeof e.replaceRevealed < "u" && e.replaceRevealed !== this._replaceRevealed && (this._replaceRevealed = e.replaceRevealed, i.replaceRevealed = e.replaceRevealed, n = !0), typeof e.replaceString < "u" && e.replaceString !== this._replaceString && (this._replaceString = e.replaceString, i.replaceString = e.replaceString, n = !0), typeof e.matchesCount < "u" && e.matchesCount !== this._matchesCount && (this._matchesCount = e.matchesCount, i.matchesCount = e.matchesCount, n = !0), typeof e.matchesPosition < "u" && e.matchesPosition !== this._matchesPosition && (this._matchesPosition = e.matchesPosition, i.matchesPosition = e.matchesPosition, n = !0), typeof e.findBy < "u" && e.findBy !== this._findBy && (this._findBy = e.findBy, i.findBy = e.findBy, n = !0), typeof e.findScope < "u" && e.findScope !== this._findScope && (this._findScope = e.findScope, i.findScope = e.findScope, n = !0), typeof e.findDirection < "u" && e.findDirection !== this._findDirection && (this._findDirection = e.findDirection, i.findDirection = e.findDirection, n = !0), typeof e.caseSensitive < "u" && e.caseSensitive !== this._caseSensitive && (this._caseSensitive = e.caseSensitive, i.caseSensitive = e.caseSensitive, n = !0), typeof e.matchesTheWholeCell < "u" && e.matchesTheWholeCell !== this._matchesTheWholeCell && (this._matchesTheWholeCell = e.matchesTheWholeCell, i.matchesTheWholeCell = e.matchesTheWholeCell, n = !0), typeof e.inputtingFindString < "u" && e.inputtingFindString !== this._inputtingFindString && (this._inputtingFindString = e.inputtingFindString, i.inputtingFindString = e.inputtingFindString, n = !0), typeof e.findCompleted < "u" && e.findCompleted !== this._findCompleted && (this._findCompleted = e.findCompleted, i.findCompleted = e.findCompleted, n = !0), n && (this._state$.next({
|
|
301
|
+
caseSensitive: this._caseSensitive,
|
|
302
|
+
findBy: this._findBy,
|
|
303
|
+
findCompleted: this._findCompleted,
|
|
304
|
+
findDirection: this._findDirection,
|
|
305
|
+
findScope: this._findScope,
|
|
306
|
+
findString: this._findString,
|
|
307
|
+
inputtingFindString: this._inputtingFindString,
|
|
308
|
+
matchesCount: this._matchesCount,
|
|
309
|
+
matchesPosition: this._matchesPosition,
|
|
310
|
+
matchesTheWholeCell: this._matchesTheWholeCell,
|
|
311
|
+
replaceRevealed: this._replaceRevealed,
|
|
312
|
+
revealed: this._revealed
|
|
313
|
+
}), this._stateUpdates$.next(i));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
let Q = class extends X {
|
|
317
|
+
constructor(e, n) {
|
|
238
318
|
super();
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this
|
|
319
|
+
c(this, "_providers", /* @__PURE__ */ new Set());
|
|
320
|
+
c(this, "_state", new Wt());
|
|
321
|
+
c(this, "_model");
|
|
322
|
+
c(this, "_currentMatch$", new F(null));
|
|
323
|
+
c(this, "currentMatch$", this._currentMatch$.asObservable());
|
|
324
|
+
c(this, "_replaceables$", new F([]));
|
|
325
|
+
c(this, "replaceables$", this._replaceables$.asObservable());
|
|
326
|
+
c(this, "_focusSignal$", new ve());
|
|
327
|
+
c(this, "focusSignal$", this._focusSignal$.asObservable());
|
|
328
|
+
this._injector = e, this._contextService = n;
|
|
243
329
|
}
|
|
244
330
|
get stateUpdates$() {
|
|
245
331
|
return this._state.stateUpdates$;
|
|
@@ -247,77 +333,122 @@ let b = class extends E {
|
|
|
247
333
|
get state$() {
|
|
248
334
|
return this._state.state$;
|
|
249
335
|
}
|
|
336
|
+
get revealed() {
|
|
337
|
+
return this._state.revealed;
|
|
338
|
+
}
|
|
339
|
+
get replaceRevealed() {
|
|
340
|
+
return this._state.replaceRevealed;
|
|
341
|
+
}
|
|
342
|
+
dispose() {
|
|
343
|
+
super.dispose(), this._currentMatch$.next(null), this._currentMatch$.complete(), this._replaceables$.next([]), this._replaceables$.complete(), this._focusSignal$.complete();
|
|
344
|
+
}
|
|
345
|
+
getCurrentMatch() {
|
|
346
|
+
var e;
|
|
347
|
+
return (e = this._model) == null ? void 0 : e.getCurrentMatch();
|
|
348
|
+
}
|
|
349
|
+
getFindString() {
|
|
350
|
+
return this._state.findString;
|
|
351
|
+
}
|
|
250
352
|
changeFindString(e) {
|
|
251
|
-
this._state.changeState({
|
|
252
|
-
|
|
253
|
-
|
|
353
|
+
this._state.changeState({ findString: e });
|
|
354
|
+
}
|
|
355
|
+
focusFindInput() {
|
|
356
|
+
this._focusSignal$.next();
|
|
357
|
+
}
|
|
358
|
+
changeInputtingFindString(e) {
|
|
359
|
+
e ? this._state.changeState({ inputtingFindString: e }) : this._state.changeState({ inputtingFindString: "", findString: "" });
|
|
360
|
+
}
|
|
361
|
+
changeReplaceString(e) {
|
|
362
|
+
this._state.changeState({ replaceString: e });
|
|
363
|
+
}
|
|
364
|
+
changeMatchesTheWholeCell(e) {
|
|
365
|
+
this._state.changeState({ matchesTheWholeCell: e });
|
|
366
|
+
}
|
|
367
|
+
changeCaseSensitive(e) {
|
|
368
|
+
this._state.changeState({ caseSensitive: e });
|
|
369
|
+
}
|
|
370
|
+
changeFindBy(e) {
|
|
371
|
+
this._state.changeState({ findBy: e }), this._toggleDisplayRawFormula(
|
|
372
|
+
e === "formula"
|
|
373
|
+
/* FORMULA */
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
changeFindScope(e) {
|
|
377
|
+
this._state.changeState({ findScope: e });
|
|
378
|
+
}
|
|
379
|
+
changeFindDirection(e) {
|
|
380
|
+
this._state.changeState({ findDirection: e });
|
|
254
381
|
}
|
|
255
382
|
moveToNextMatch() {
|
|
256
|
-
|
|
257
|
-
this._model && ((e = this._model) == null || e.moveToNextMatch());
|
|
383
|
+
this._model && (this._state.replaceRevealed && !this._model.searched ? (this._state.changeState({ findString: this._state.inputtingFindString }), this._model.start()) : this._model.moveToNextMatch(), this._focusSignal$.next());
|
|
258
384
|
}
|
|
259
385
|
moveToPreviousMatch() {
|
|
260
|
-
|
|
261
|
-
this._model && ((e = this._model) == null || e.moveToPreviousMatch());
|
|
386
|
+
this._model && (this._state.replaceRevealed && !this._model.searched ? (this._state.changeState({ findString: this._state.inputtingFindString }), this._model.start()) : this._model.moveToPreviousMatch(), this._focusSignal$.next());
|
|
262
387
|
}
|
|
263
|
-
replace() {
|
|
264
|
-
return !
|
|
388
|
+
async replace() {
|
|
389
|
+
return this._model ? this._model.replace() : !1;
|
|
265
390
|
}
|
|
266
|
-
replaceAll() {
|
|
267
|
-
|
|
391
|
+
async replaceAll() {
|
|
392
|
+
if (!this._model)
|
|
393
|
+
throw new Error("[FindReplaceService] replaceAll: model is not initialized!");
|
|
394
|
+
return this._model.replaceAll();
|
|
268
395
|
}
|
|
269
396
|
revealReplace() {
|
|
270
|
-
this._state.changeState({ replaceRevealed: !0 });
|
|
271
|
-
}
|
|
272
|
-
disposeModel() {
|
|
273
|
-
var e;
|
|
274
|
-
(e = this._model) == null || e.dispose(), this._model = null;
|
|
397
|
+
this._state.changeState({ replaceRevealed: !0, inputtingFindString: this._state.findString }), this._toggleRevealReplace(!0);
|
|
275
398
|
}
|
|
276
|
-
start() {
|
|
399
|
+
start(e = !1) {
|
|
277
400
|
if (this._providers.size === 0)
|
|
278
401
|
return !1;
|
|
279
|
-
this._model = this._injector.createInstance(
|
|
280
|
-
const
|
|
281
|
-
return e.
|
|
402
|
+
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));
|
|
403
|
+
const n = ie();
|
|
404
|
+
return e && (n.replaceRevealed = !0), this._state.changeState(n), this._toggleRevealReplace(e), !0;
|
|
282
405
|
}
|
|
283
|
-
|
|
284
|
-
|
|
406
|
+
find() {
|
|
407
|
+
var e;
|
|
408
|
+
(e = this._model) == null || e.start();
|
|
409
|
+
}
|
|
410
|
+
terminate() {
|
|
411
|
+
var e;
|
|
412
|
+
(e = this._model) == null || e.dispose(), this._model = null, this._toggleDisplayRawFormula(!1), this._toggleRevealReplace(!1);
|
|
285
413
|
}
|
|
286
414
|
registerFindReplaceProvider(e) {
|
|
287
|
-
return this._providers.add(e),
|
|
415
|
+
return this._providers.add(e), q(() => this._providers.delete(e));
|
|
416
|
+
}
|
|
417
|
+
_toggleRevealReplace(e) {
|
|
418
|
+
this._contextService.setContextValue(Ie, e);
|
|
419
|
+
}
|
|
420
|
+
_toggleDisplayRawFormula(e) {
|
|
421
|
+
this._contextService.setContextValue(Ft, e);
|
|
288
422
|
}
|
|
289
423
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const D = {
|
|
424
|
+
Q = Fe([
|
|
425
|
+
w(0, y(_e)),
|
|
426
|
+
w(1, U)
|
|
427
|
+
], Q);
|
|
428
|
+
const W = {
|
|
296
429
|
id: "ui.operation.open-find-dialog",
|
|
297
|
-
type:
|
|
298
|
-
handler: (t) =>
|
|
299
|
-
|
|
430
|
+
type: b.OPERATION,
|
|
431
|
+
handler: (t) => {
|
|
432
|
+
const e = t.get(v);
|
|
433
|
+
return e.revealed ? e.focusFindInput() : e.start(), !0;
|
|
434
|
+
}
|
|
435
|
+
}, ne = {
|
|
300
436
|
id: "ui.operation.open-replace-dialog",
|
|
301
|
-
type:
|
|
302
|
-
handler: (t) =>
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
id: "ui.operation.close-find-replace-dialog",
|
|
309
|
-
type: m.OPERATION,
|
|
310
|
-
handler: (t) => !0
|
|
311
|
-
}, te = {
|
|
312
|
-
type: m.OPERATION,
|
|
437
|
+
type: b.OPERATION,
|
|
438
|
+
handler: (t) => {
|
|
439
|
+
const e = t.get(v);
|
|
440
|
+
return e.revealed ? e.replaceRevealed ? e.focusFindInput() : e.revealReplace() : e.start(!0), !0;
|
|
441
|
+
}
|
|
442
|
+
}, Pe = {
|
|
443
|
+
type: b.OPERATION,
|
|
313
444
|
id: "ui.operation.go-to-next-match",
|
|
314
|
-
handler: (t) => (t.get(
|
|
315
|
-
},
|
|
316
|
-
type:
|
|
445
|
+
handler: (t) => (t.get(v).moveToNextMatch(), !0)
|
|
446
|
+
}, De = {
|
|
447
|
+
type: b.OPERATION,
|
|
317
448
|
id: "ui.operation.go-to-previous-match",
|
|
318
|
-
handler: (t) => (t.get(
|
|
319
|
-
}
|
|
320
|
-
var
|
|
449
|
+
handler: (t) => (t.get(v).moveToPreviousMatch(), !0)
|
|
450
|
+
};
|
|
451
|
+
var Oe = { exports: {} }, G = {};
|
|
321
452
|
/**
|
|
322
453
|
* @license React
|
|
323
454
|
* react-jsx-runtime.production.min.js
|
|
@@ -327,262 +458,486 @@ var ne = { exports: {} }, O = {};
|
|
|
327
458
|
* This source code is licensed under the MIT license found in the
|
|
328
459
|
* LICENSE file in the root directory of this source tree.
|
|
329
460
|
*/
|
|
330
|
-
var
|
|
331
|
-
function
|
|
332
|
-
var i,
|
|
333
|
-
n !== void 0 && (
|
|
461
|
+
var Gt = Pt, kt = Symbol.for("react.element"), Vt = Symbol.for("react.fragment"), Ht = Object.prototype.hasOwnProperty, qt = Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, zt = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
462
|
+
function Te(t, e, n) {
|
|
463
|
+
var i, s = {}, r = null, a = null;
|
|
464
|
+
n !== void 0 && (r = "" + n), e.key !== void 0 && (r = "" + e.key), e.ref !== void 0 && (a = e.ref);
|
|
334
465
|
for (i in e)
|
|
335
|
-
|
|
466
|
+
Ht.call(e, i) && !zt.hasOwnProperty(i) && (s[i] = e[i]);
|
|
336
467
|
if (t && t.defaultProps)
|
|
337
468
|
for (i in e = t.defaultProps, e)
|
|
338
|
-
|
|
339
|
-
return { $$typeof:
|
|
469
|
+
s[i] === void 0 && (s[i] = e[i]);
|
|
470
|
+
return { $$typeof: kt, type: t, key: r, ref: a, props: s, _owner: qt.current };
|
|
340
471
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
var
|
|
346
|
-
const
|
|
347
|
-
|
|
472
|
+
G.Fragment = Vt;
|
|
473
|
+
G.jsx = Te;
|
|
474
|
+
G.jsxs = Te;
|
|
475
|
+
Oe.exports = G;
|
|
476
|
+
var l = Oe.exports;
|
|
477
|
+
const Ee = {
|
|
478
|
+
id: "ui.command.replace-current-match",
|
|
479
|
+
type: b.COMMAND,
|
|
480
|
+
handler: (t) => t.get(v).replace()
|
|
481
|
+
}, Kt = "CONFIRM_REPLACE_ALL", $e = {
|
|
482
|
+
id: "ui.command.replace-all-matches",
|
|
483
|
+
type: b.COMMAND,
|
|
484
|
+
handler: async (t) => {
|
|
485
|
+
const e = t.get(pt), n = t.get(P), i = t.get(ge);
|
|
486
|
+
if (!await e.confirm({
|
|
487
|
+
id: Kt,
|
|
488
|
+
title: { title: n.t("find-replace.replace.confirm.title") },
|
|
489
|
+
cancelText: n.t("button.cancel"),
|
|
490
|
+
confirmText: n.t("button.confirm")
|
|
491
|
+
}))
|
|
492
|
+
return !1;
|
|
493
|
+
const r = await t.get(v).replaceAll(), { success: a, failure: o } = r;
|
|
494
|
+
return o > 0 ? (a === 0 ? i.show({
|
|
495
|
+
type: $.Error,
|
|
496
|
+
content: n.t("find-replace.replace.all-failure")
|
|
497
|
+
}) : i.show({
|
|
498
|
+
type: $.Warning,
|
|
499
|
+
content: n.t("find-replace.replace.partial-success", `${a}`, `${o}`)
|
|
500
|
+
}), !1) : (i.show({
|
|
501
|
+
type: $.Success,
|
|
502
|
+
content: n.t("find-replace.replace.all-success", `${a}`)
|
|
503
|
+
}), !0);
|
|
504
|
+
}
|
|
348
505
|
};
|
|
349
|
-
function
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
},
|
|
359
|
-
[t]
|
|
360
|
-
), N = M(
|
|
361
|
-
(c) => {
|
|
362
|
-
a(c);
|
|
363
|
-
},
|
|
364
|
-
[t]
|
|
365
|
-
);
|
|
366
|
-
De(() => {
|
|
367
|
-
let c;
|
|
368
|
-
return s.current && (c = n.registerContainerElement(s.current)), () => c == null ? void 0 : c.dispose();
|
|
369
|
-
}, [s.current]);
|
|
370
|
-
function ce() {
|
|
371
|
-
return /* @__PURE__ */ d.jsxs(A, { children: [
|
|
372
|
-
/* @__PURE__ */ d.jsx(
|
|
373
|
-
$e,
|
|
506
|
+
function Ne(t) {
|
|
507
|
+
const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition: s, findString: r, findReplaceService: a, onChange: o, ...d } = t, p = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
|
|
508
|
+
return /* @__PURE__ */ l.jsx(
|
|
509
|
+
Ot,
|
|
510
|
+
{
|
|
511
|
+
autoFocus: !0,
|
|
512
|
+
placeholder: n.t("find-replace.dialog.find-placeholder"),
|
|
513
|
+
slot: /* @__PURE__ */ l.jsx(
|
|
514
|
+
Tt,
|
|
374
515
|
{
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
total: v,
|
|
383
|
-
onChange: (c) => {
|
|
384
|
-
g === v && c === 1 ? t.moveToNextMatch() : g === 1 && c === v || c < g ? t.moveToPreviousMatch() : t.moveToNextMatch();
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
),
|
|
388
|
-
value: i,
|
|
389
|
-
onChange: (c) => se(c)
|
|
516
|
+
loop: !0,
|
|
517
|
+
text: p,
|
|
518
|
+
value: s,
|
|
519
|
+
total: i,
|
|
520
|
+
onChange: (f) => {
|
|
521
|
+
s === i && f === 1 ? a.moveToNextMatch() : s === 1 && f === i || f < s ? a.moveToPreviousMatch() : a.moveToNextMatch();
|
|
522
|
+
}
|
|
390
523
|
}
|
|
391
524
|
),
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
525
|
+
value: r,
|
|
526
|
+
onChange: (f) => o == null ? void 0 : o(f),
|
|
527
|
+
...d
|
|
528
|
+
}
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
const Yt = "univer-find-replace-dialog-container", Zt = "univer-find-replace-expand-container", Jt = "univer-button-text", Qt = "univer-find-replace-buttons-group", Xt = "univer-find-replace-buttons-group-right", L = {
|
|
532
|
+
findReplaceDialogContainer: Yt,
|
|
533
|
+
findReplaceExpandContainer: Zt,
|
|
534
|
+
buttonText: Jt,
|
|
535
|
+
findReplaceButtonsGroup: Qt,
|
|
536
|
+
findReplaceButtonsGroupRight: Xt
|
|
537
|
+
};
|
|
538
|
+
function Ae(t, e) {
|
|
539
|
+
const n = _(() => {
|
|
540
|
+
var s;
|
|
541
|
+
(s = document.querySelector(".univer-find-input input")) == null || s.focus();
|
|
542
|
+
}, []), i = _(() => {
|
|
543
|
+
const s = document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");
|
|
544
|
+
return Array.from(s).some((r) => r === document.activeElement);
|
|
545
|
+
}, []);
|
|
546
|
+
return Dt(e, () => ({ focus: n, selectHasFocus: i })), j(() => {
|
|
547
|
+
const s = t.focusSignal$.subscribe(() => n());
|
|
548
|
+
return () => s.unsubscribe();
|
|
549
|
+
}, [t, n]), { focus: n, selectHasFocus: i };
|
|
550
|
+
}
|
|
551
|
+
const ei = B(function(e, n) {
|
|
552
|
+
const i = S(P), s = S(v), r = S(ee), a = I(s.state$, void 0, !0), { findCompleted: o, findString: d, matchesCount: u, matchesPosition: p } = a, f = _(() => {
|
|
553
|
+
r.executeCommand(ne.id);
|
|
554
|
+
}, [r]), O = _((C) => s.changeFindString(C), [s]);
|
|
555
|
+
return Ae(s, n), /* @__PURE__ */ l.jsxs(E, { children: [
|
|
556
|
+
/* @__PURE__ */ l.jsx(
|
|
557
|
+
Ne,
|
|
558
|
+
{
|
|
559
|
+
findCompleted: o,
|
|
560
|
+
className: "univer-find-input",
|
|
561
|
+
matchesCount: u,
|
|
562
|
+
matchesPosition: p,
|
|
563
|
+
findReplaceService: s,
|
|
564
|
+
localeService: i,
|
|
565
|
+
findString: d,
|
|
566
|
+
onChange: O
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
/* @__PURE__ */ l.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ l.jsx(N, { type: "text", size: "small", onClick: f, children: i.t("find-replace.dialog.advanced-finding") }) })
|
|
570
|
+
] });
|
|
571
|
+
}), ti = B(function(e, n) {
|
|
572
|
+
const i = S(v), s = S(P), r = S(ee), a = S(ge), o = I(i.currentMatch$, void 0, !0), d = I(i.replaceables$, void 0, !0), u = I(i.state$, void 0, !0), {
|
|
573
|
+
matchesCount: p,
|
|
574
|
+
matchesPosition: f,
|
|
575
|
+
findString: O,
|
|
576
|
+
inputtingFindString: C,
|
|
577
|
+
replaceString: Le,
|
|
578
|
+
caseSensitive: Ue,
|
|
579
|
+
matchesTheWholeCell: Be,
|
|
580
|
+
findDirection: We,
|
|
581
|
+
findScope: Ge,
|
|
582
|
+
findBy: ke,
|
|
583
|
+
findCompleted: V
|
|
584
|
+
} = u, Ve = C.length === 0, He = p === 0 || !(o != null && o.replaceable), qe = d.length === 0, ze = _(
|
|
585
|
+
(h) => i.changeInputtingFindString(h),
|
|
586
|
+
[i]
|
|
587
|
+
), Ke = _(
|
|
588
|
+
(h) => i.changeReplaceString(h),
|
|
589
|
+
[i]
|
|
590
|
+
), { focus: Ye } = Ae(i, n), Ze = _(() => {
|
|
591
|
+
O === C ? i.moveToNextMatch() : (i.changeFindString(C), i.find());
|
|
592
|
+
}, [O, C, i]), Je = _(() => r.executeCommand(Ee.id), [r]), Qe = _(async () => {
|
|
593
|
+
await r.executeCommand($e.id), Ye();
|
|
594
|
+
}, [r]), Xe = _((h) => {
|
|
595
|
+
i.changeFindDirection(h);
|
|
596
|
+
}, [i]), et = _((h) => {
|
|
597
|
+
i.changeFindScope(h);
|
|
598
|
+
}, [i]), tt = _((h) => {
|
|
599
|
+
i.changeFindBy(h);
|
|
600
|
+
}, [i]), it = ni(s), nt = si(s), st = ri(s);
|
|
601
|
+
return j(() => {
|
|
602
|
+
const h = V && p === 0;
|
|
603
|
+
let T = null;
|
|
604
|
+
return h && (T = a.show({
|
|
605
|
+
content: s.t("find-replace.dialog.no-match"),
|
|
606
|
+
type: $.Warning,
|
|
607
|
+
delay: 5e3
|
|
608
|
+
})), () => T == null ? void 0 : T.dispose();
|
|
609
|
+
}, [V, p, a, s]), /* @__PURE__ */ l.jsxs(E, { children: [
|
|
610
|
+
/* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.find"), children: /* @__PURE__ */ l.jsx(
|
|
611
|
+
Ne,
|
|
612
|
+
{
|
|
613
|
+
findCompleted: V,
|
|
614
|
+
className: "univer-find-input",
|
|
615
|
+
matchesCount: p,
|
|
616
|
+
matchesPosition: f,
|
|
617
|
+
findReplaceService: i,
|
|
618
|
+
localeService: s,
|
|
619
|
+
findString: C,
|
|
620
|
+
onChange: ze
|
|
621
|
+
}
|
|
622
|
+
) }),
|
|
623
|
+
/* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.replace"), children: /* @__PURE__ */ l.jsx(
|
|
624
|
+
Et,
|
|
625
|
+
{
|
|
626
|
+
placeholder: s.t("find-replace.dialog.replace-placeholder"),
|
|
627
|
+
value: Le,
|
|
628
|
+
onChange: (h) => Ke(h)
|
|
629
|
+
}
|
|
630
|
+
) }),
|
|
631
|
+
/* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ l.jsx(H, { value: We, options: nt, onChange: Xe }) }),
|
|
632
|
+
/* @__PURE__ */ l.jsx(oe, { children: /* @__PURE__ */ l.jsxs(E, { children: [
|
|
633
|
+
/* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ l.jsx(H, { value: Ge, options: it, onChange: et }) }),
|
|
634
|
+
/* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ l.jsx(H, { value: ke, options: st, onChange: tt }) })
|
|
635
|
+
] }) }),
|
|
636
|
+
/* @__PURE__ */ l.jsx(oe, { children: /* @__PURE__ */ l.jsxs(E, { children: [
|
|
637
|
+
/* @__PURE__ */ l.jsx(R, { children: /* @__PURE__ */ l.jsx(
|
|
638
|
+
ce,
|
|
399
639
|
{
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
640
|
+
checked: Ue,
|
|
641
|
+
onChange: (h) => {
|
|
642
|
+
i.changeCaseSensitive(h);
|
|
643
|
+
},
|
|
644
|
+
children: s.t("find-replace.dialog.case-sensitive")
|
|
404
645
|
}
|
|
405
646
|
) }),
|
|
406
|
-
/* @__PURE__ */
|
|
407
|
-
|
|
647
|
+
/* @__PURE__ */ l.jsx(R, { children: /* @__PURE__ */ l.jsx(
|
|
648
|
+
ce,
|
|
408
649
|
{
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
650
|
+
checked: Be,
|
|
651
|
+
onChange: (h) => {
|
|
652
|
+
i.changeMatchesTheWholeCell(h);
|
|
653
|
+
},
|
|
654
|
+
children: s.t("find-replace.dialog.match-the-whole-cell")
|
|
412
655
|
}
|
|
413
|
-
) })
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
/* @__PURE__ */
|
|
417
|
-
/* @__PURE__ */
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
656
|
+
) })
|
|
657
|
+
] }) }),
|
|
658
|
+
/* @__PURE__ */ l.jsxs("div", { className: L.findReplaceButtonsGroup, children: [
|
|
659
|
+
/* @__PURE__ */ l.jsx(N, { type: "primary", onClick: Ze, disabled: Ve, children: s.t("find-replace.dialog.find") }),
|
|
660
|
+
/* @__PURE__ */ l.jsxs("span", { className: L.findReplaceButtonsGroupRight, children: [
|
|
661
|
+
/* @__PURE__ */ l.jsx(N, { disabled: He, onClick: Je, children: s.t("find-replace.dialog.replace") }),
|
|
662
|
+
/* @__PURE__ */ l.jsx(N, { disabled: qe, onClick: Qe, children: s.t("find-replace.dialog.replace-all") })
|
|
663
|
+
] })
|
|
664
|
+
] })
|
|
665
|
+
] });
|
|
666
|
+
});
|
|
667
|
+
function ii() {
|
|
668
|
+
const t = S(v), e = S(me), n = S(U), i = I(t.state$, void 0, !0), s = z(null);
|
|
669
|
+
j(() => {
|
|
670
|
+
let d;
|
|
671
|
+
return s.current && (d = e.registerContainerElement(s.current)), () => d == null ? void 0 : d.dispose();
|
|
672
|
+
}, [e]);
|
|
673
|
+
const r = z(null), a = _(
|
|
674
|
+
(d) => n.setContextValue(ye, d),
|
|
675
|
+
[n]
|
|
676
|
+
), o = _(
|
|
677
|
+
(d) => n.setContextValue(be, d),
|
|
678
|
+
[n]
|
|
679
|
+
);
|
|
680
|
+
return j(() => {
|
|
681
|
+
var u;
|
|
682
|
+
const d = yt(document, "focusin").subscribe((p) => {
|
|
683
|
+
var f;
|
|
684
|
+
p.target && ((f = s.current) != null && f.contains(p.target)) ? a(!0) : a(!1), !r.current || !r.current.selectHasFocus() ? o(!0) : o(!1);
|
|
685
|
+
});
|
|
686
|
+
return (u = r.current) == null || u.focus(), a(!0), o(!0), () => {
|
|
687
|
+
d.unsubscribe(), a(!1);
|
|
688
|
+
};
|
|
689
|
+
}, [a, o]), /* @__PURE__ */ l.jsx("div", { className: L.findReplaceDialogContainer, ref: s, children: i.replaceRevealed ? /* @__PURE__ */ l.jsx(ti, { ref: r }) : /* @__PURE__ */ l.jsx(ei, { ref: r }) });
|
|
422
690
|
}
|
|
423
|
-
function
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
691
|
+
function ni(t) {
|
|
692
|
+
const e = t.getCurrentLocale();
|
|
693
|
+
return te(() => [
|
|
694
|
+
{ label: t.t("find-replace.dialog.find-scope.current-sheet"), value: J.SUBUNIT },
|
|
695
|
+
{ label: t.t("find-replace.dialog.find-scope.workbook"), value: J.UNIT }
|
|
696
|
+
], [e]);
|
|
697
|
+
}
|
|
698
|
+
function si(t) {
|
|
699
|
+
const e = t.getCurrentLocale();
|
|
700
|
+
return te(() => [
|
|
701
|
+
{ label: t.t("find-replace.dialog.find-direction.row"), value: Y.ROW },
|
|
702
|
+
{ label: t.t("find-replace.dialog.find-direction.column"), value: Y.COLUMN }
|
|
703
|
+
], [e]);
|
|
433
704
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
705
|
+
function ri(t) {
|
|
706
|
+
const e = t.getCurrentLocale();
|
|
707
|
+
return te(() => [
|
|
708
|
+
{ label: t.t("find-replace.dialog.find-by.value"), value: Z.VALUE },
|
|
709
|
+
{ label: t.t("find-replace.dialog.find-by.formula"), value: Z.FORMULA }
|
|
710
|
+
], [e]);
|
|
711
|
+
}
|
|
712
|
+
function D(t) {
|
|
713
|
+
return t.getContextValue(ye);
|
|
714
|
+
}
|
|
715
|
+
function ai(t) {
|
|
716
|
+
return t.getContextValue(Ie);
|
|
717
|
+
}
|
|
718
|
+
function je(t) {
|
|
719
|
+
return t.getContextValue(be);
|
|
720
|
+
}
|
|
721
|
+
const k = "7_find-replace-shortcuts";
|
|
722
|
+
function se(t) {
|
|
723
|
+
return t.getContextValue(fe);
|
|
724
|
+
}
|
|
725
|
+
function re(t) {
|
|
726
|
+
return !t.getContextValue(pe);
|
|
727
|
+
}
|
|
728
|
+
const oi = {
|
|
729
|
+
id: W.id,
|
|
730
|
+
description: "find-replace.shortcut.open-find-dialog",
|
|
731
|
+
binding: x.F | M.CTRL_COMMAND,
|
|
732
|
+
group: k,
|
|
439
733
|
preconditions(t) {
|
|
440
|
-
return !t
|
|
734
|
+
return !D(t) && se(t) && re(t);
|
|
441
735
|
}
|
|
442
|
-
},
|
|
443
|
-
id:
|
|
444
|
-
description: "
|
|
445
|
-
binding:
|
|
446
|
-
|
|
736
|
+
}, ci = {
|
|
737
|
+
id: W.id,
|
|
738
|
+
description: "find-replace.shortcut.open-find-dialog",
|
|
739
|
+
binding: x.F | M.CTRL_COMMAND,
|
|
740
|
+
mac: x.F | M.MAC_CTRL,
|
|
447
741
|
preconditions(t) {
|
|
448
|
-
return !t
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
id:
|
|
452
|
-
description: "
|
|
453
|
-
binding:
|
|
454
|
-
|
|
455
|
-
|
|
742
|
+
return !D(t) && se(t) && re(t);
|
|
743
|
+
}
|
|
744
|
+
}, li = {
|
|
745
|
+
id: ne.id,
|
|
746
|
+
description: "find-replace.shortcut.open-replace-dialog",
|
|
747
|
+
binding: x.H | M.CTRL_COMMAND,
|
|
748
|
+
mac: x.H | M.MAC_CTRL,
|
|
749
|
+
group: k,
|
|
456
750
|
preconditions(t) {
|
|
457
|
-
return
|
|
751
|
+
return se(t) && re(t) && (!D(t) || !ai(t));
|
|
458
752
|
}
|
|
459
|
-
},
|
|
460
|
-
id:
|
|
461
|
-
description: "
|
|
462
|
-
binding:
|
|
463
|
-
group:
|
|
753
|
+
}, di = {
|
|
754
|
+
id: Pe.id,
|
|
755
|
+
description: "find-replace.shortcut.go-to-next-match",
|
|
756
|
+
binding: x.ENTER,
|
|
757
|
+
group: k,
|
|
464
758
|
priority: 1e3,
|
|
465
759
|
preconditions(t) {
|
|
466
|
-
return
|
|
760
|
+
return je(t) && D(t);
|
|
467
761
|
}
|
|
468
|
-
},
|
|
469
|
-
id:
|
|
470
|
-
description: "
|
|
471
|
-
binding:
|
|
472
|
-
group:
|
|
762
|
+
}, hi = {
|
|
763
|
+
id: De.id,
|
|
764
|
+
description: "find-replace.shortcut.go-to-previous-match",
|
|
765
|
+
binding: x.ENTER | M.SHIFT,
|
|
766
|
+
group: k,
|
|
473
767
|
priority: 1e3,
|
|
474
768
|
preconditions(t) {
|
|
475
|
-
return
|
|
769
|
+
return je(t) && D(t);
|
|
476
770
|
}
|
|
477
771
|
};
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
772
|
+
function ui(t) {
|
|
773
|
+
const e = t.get(U);
|
|
774
|
+
return {
|
|
775
|
+
id: W.id,
|
|
776
|
+
icon: "SearchIcon",
|
|
777
|
+
tooltip: "find-replace.toolbar",
|
|
778
|
+
group: _t.TOOLBAR_OTHERS,
|
|
779
|
+
type: gt.BUTTON,
|
|
780
|
+
positions: [mt.TOOLBAR_START],
|
|
781
|
+
hidden$: vt(t, ct.SHEET),
|
|
782
|
+
disabled$: Se([
|
|
783
|
+
e.subscribeContextValue$(pe),
|
|
784
|
+
e.subscribeContextValue$(fe)
|
|
785
|
+
]).pipe(It(([n, i]) => n || !i))
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
var fi = Object.defineProperty, pi = Object.getOwnPropertyDescriptor, _i = (t, e, n, i) => {
|
|
789
|
+
for (var s = i > 1 ? void 0 : i ? pi(e, n) : e, r = t.length - 1, a; r >= 0; r--)
|
|
790
|
+
(a = t[r]) && (s = (i ? a(e, n, s) : a(s)) || s);
|
|
791
|
+
return i && s && fi(e, n, s), s;
|
|
792
|
+
}, g = (t, e) => (n, i) => e(n, i, t);
|
|
793
|
+
const le = "DESKTOP_FIND_REPLACE_DIALOG", we = 350, gi = 20, mi = -90;
|
|
794
|
+
let A = class extends lt {
|
|
795
|
+
constructor(t, e, n, i, s, r, a, o, d, u, p, f) {
|
|
796
|
+
super(), this._univerInstanceService = t, this._menuService = e, this._shortcutService = n, this._commandService = i, this._findReplaceService = s, this._logService = r, this._dialogService = a, this._contextService = o, this._layoutService = d, this._localeService = u, this._componentManager = p, this._injector = f, this._initCommands(), this._initUI(), this._initShortcuts();
|
|
797
|
+
}
|
|
798
|
+
_initCommands() {
|
|
489
799
|
[
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
800
|
+
W,
|
|
801
|
+
ne,
|
|
802
|
+
Pe,
|
|
803
|
+
De,
|
|
804
|
+
$e,
|
|
805
|
+
Ee
|
|
496
806
|
].forEach((t) => {
|
|
497
807
|
this.disposeWithMe(this._commandService.registerCommand(t));
|
|
498
808
|
});
|
|
499
809
|
}
|
|
500
|
-
_initUI() {
|
|
501
|
-
[tt].forEach((t) => {
|
|
502
|
-
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)));
|
|
503
|
-
}), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", et)), this.disposeWithMe(this._componentManager.register("SearchIcon", J)), this._findReplaceService.stateUpdates$.pipe(je(this.dispose$)).subscribe((t) => {
|
|
504
|
-
t.revealed === !0 ? this._openPanel() : t.revealed === !1 && this._closePanel();
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
810
|
_initShortcuts() {
|
|
508
811
|
[
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
].forEach((t) =>
|
|
515
|
-
|
|
516
|
-
|
|
812
|
+
li,
|
|
813
|
+
oi,
|
|
814
|
+
ci,
|
|
815
|
+
hi,
|
|
816
|
+
di
|
|
817
|
+
].forEach((t) => this.disposeWithMe(this._shortcutService.registerShortcut(t)));
|
|
818
|
+
}
|
|
819
|
+
_initUI() {
|
|
820
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(ui))), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", ii)), this.disposeWithMe(this._componentManager.register("SearchIcon", Me)), this._findReplaceService.stateUpdates$.pipe(ae(this.dispose$)).subscribe((t) => {
|
|
821
|
+
t.revealed === !0 && this._openPanel();
|
|
822
|
+
}), this.disposeWithMe(
|
|
823
|
+
this._univerInstanceService.focused$.pipe(ae(this.dispose$)).subscribe((t) => {
|
|
824
|
+
(!t || !this._univerInstanceService.getUniverSheetInstance(t)) && this.closePanel();
|
|
825
|
+
})
|
|
826
|
+
);
|
|
517
827
|
}
|
|
518
828
|
_openPanel() {
|
|
519
829
|
this._dialogService.open({
|
|
520
|
-
id:
|
|
830
|
+
id: le,
|
|
521
831
|
draggable: !0,
|
|
522
|
-
width:
|
|
523
|
-
title: { title: this._localeService.t("
|
|
832
|
+
width: we,
|
|
833
|
+
title: { title: this._localeService.t("find-replace.dialog.title") },
|
|
524
834
|
children: { label: "FindReplaceDialog" },
|
|
525
|
-
|
|
526
|
-
|
|
835
|
+
destroyOnClose: !0,
|
|
836
|
+
defaultPosition: vi(),
|
|
837
|
+
preservePositionOnDestroy: !0,
|
|
838
|
+
onClose: () => this.closePanel()
|
|
839
|
+
});
|
|
527
840
|
}
|
|
528
|
-
|
|
529
|
-
this._dialogService.close(
|
|
841
|
+
closePanel() {
|
|
842
|
+
this._dialogService.close(le), this._findReplaceService.terminate(), queueMicrotask(() => this._layoutService.focus());
|
|
530
843
|
}
|
|
531
844
|
};
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
845
|
+
A = _i([
|
|
846
|
+
dt(ht.Rendered, A),
|
|
847
|
+
g(0, he),
|
|
848
|
+
g(1, Ct),
|
|
849
|
+
g(2, Rt),
|
|
850
|
+
g(3, ee),
|
|
851
|
+
g(4, v),
|
|
852
|
+
g(5, ue),
|
|
853
|
+
g(6, xt),
|
|
854
|
+
g(7, U),
|
|
855
|
+
g(8, me),
|
|
856
|
+
g(9, y(P)),
|
|
857
|
+
g(10, y(St)),
|
|
858
|
+
g(11, y(_e))
|
|
859
|
+
], A);
|
|
860
|
+
function vi() {
|
|
861
|
+
const { innerWidth: t } = window;
|
|
862
|
+
return { x: (t - we) / 2 - gi, y: mi };
|
|
863
|
+
}
|
|
864
|
+
const Si = {
|
|
865
|
+
"find-replace": {
|
|
866
|
+
toolbar: "查找替换",
|
|
867
|
+
shortcut: {
|
|
868
|
+
"open-find-dialog": "打开查找对话框",
|
|
869
|
+
"open-replace-dialog": "打开替换对话框",
|
|
870
|
+
"close-dialog": "关闭查找替换对话框",
|
|
871
|
+
"go-to-next-match": "下一个匹配项",
|
|
872
|
+
"go-to-previous-match": "下一个匹配项"
|
|
873
|
+
},
|
|
874
|
+
dialog: {
|
|
875
|
+
title: "查找",
|
|
876
|
+
find: "查找",
|
|
877
|
+
replace: "替换",
|
|
878
|
+
"replace-all": "替换全部",
|
|
879
|
+
"find-placeholder": "输入查找内容",
|
|
880
|
+
"advanced-finding": "替换 / 高级查找",
|
|
881
|
+
"replace-placeholder": "输入替换内容",
|
|
882
|
+
"case-sensitive": "匹配大小写",
|
|
883
|
+
"match-the-whole-cell": "匹配整个单元格",
|
|
884
|
+
"find-scope": {
|
|
885
|
+
title: "查找范围",
|
|
886
|
+
"current-sheet": "当前子表",
|
|
887
|
+
workbook: "整个工作簿"
|
|
888
|
+
},
|
|
889
|
+
"find-direction": {
|
|
890
|
+
title: "查找顺序",
|
|
891
|
+
column: "按列查找",
|
|
892
|
+
row: "按行查找"
|
|
893
|
+
},
|
|
894
|
+
"find-by": {
|
|
895
|
+
title: "查找方式",
|
|
896
|
+
formula: "查找公式",
|
|
897
|
+
value: "查找值"
|
|
898
|
+
},
|
|
899
|
+
"no-match": "已完成搜索,但是未找到任何匹配项",
|
|
900
|
+
"no-result": "无结果"
|
|
901
|
+
},
|
|
902
|
+
replace: {
|
|
903
|
+
"all-success": "已全部替换 {0} 个匹配项",
|
|
904
|
+
"all-failure": "替换失败",
|
|
905
|
+
confirm: {
|
|
906
|
+
title: "确定要替换所有的匹配项吗?"
|
|
557
907
|
}
|
|
558
908
|
}
|
|
559
|
-
}
|
|
909
|
+
},
|
|
910
|
+
"find-replace-shortcuts": "查找替换"
|
|
560
911
|
};
|
|
561
|
-
var
|
|
562
|
-
for (var
|
|
563
|
-
(a = t[
|
|
564
|
-
return i &&
|
|
565
|
-
},
|
|
566
|
-
const
|
|
567
|
-
let
|
|
912
|
+
var Ci = Object.defineProperty, Ri = Object.getOwnPropertyDescriptor, xi = (t, e, n, i) => {
|
|
913
|
+
for (var s = i > 1 ? void 0 : i ? Ri(e, n) : e, r = t.length - 1, a; r >= 0; r--)
|
|
914
|
+
(a = t[r]) && (s = (i ? a(e, n, s) : a(s)) || s);
|
|
915
|
+
return i && s && Ci(e, n, s), s;
|
|
916
|
+
}, Mi = (t, e) => (n, i) => e(n, i, t);
|
|
917
|
+
const bi = "FIND_REPLACE";
|
|
918
|
+
let de = class extends ut {
|
|
568
919
|
constructor(t, e) {
|
|
569
|
-
super(
|
|
570
|
-
zhCN:
|
|
920
|
+
super(bi), this._injector = t, this._localeService = e, this._localeService.load({
|
|
921
|
+
zhCN: Si
|
|
571
922
|
});
|
|
572
923
|
}
|
|
573
924
|
onStarting(t) {
|
|
574
|
-
[[
|
|
925
|
+
[[A], [v, { useClass: Q }]].forEach(
|
|
575
926
|
(e) => {
|
|
576
927
|
t.add(e);
|
|
577
928
|
}
|
|
578
929
|
);
|
|
579
930
|
}
|
|
580
931
|
};
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
],
|
|
932
|
+
de = xi([
|
|
933
|
+
Mi(1, y(P))
|
|
934
|
+
], de);
|
|
584
935
|
export {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
936
|
+
Z as FindBy,
|
|
937
|
+
Y as FindDirection,
|
|
938
|
+
Ni as FindModel,
|
|
939
|
+
A as FindReplaceController,
|
|
940
|
+
J as FindScope,
|
|
941
|
+
v as IFindReplaceService,
|
|
942
|
+
de as UniverFindReplacePlugin
|
|
588
943
|
};
|