@univerjs/sheets-hyper-link-ui 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +32 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +1 -12
- package/lib/es/index.js +32 -2006
- package/lib/es/locale/ca-ES.js +1 -38
- package/lib/es/locale/en-US.js +1 -38
- package/lib/es/locale/es-ES.js +1 -38
- package/lib/es/locale/fa-IR.js +1 -38
- package/lib/es/locale/fr-FR.js +1 -38
- package/lib/es/locale/ja-JP.js +1 -38
- package/lib/es/locale/ko-KR.js +1 -38
- package/lib/es/locale/ru-RU.js +1 -38
- package/lib/es/locale/sk-SK.js +1 -38
- package/lib/es/locale/vi-VN.js +1 -38
- package/lib/es/locale/zh-CN.js +1 -38
- package/lib/es/locale/zh-TW.js +1 -38
- package/lib/facade.js +1 -12
- package/lib/index.css +168 -1
- package/lib/index.js +32 -2006
- package/lib/locale/ca-ES.js +1 -38
- package/lib/locale/en-US.js +1 -38
- package/lib/locale/es-ES.js +1 -38
- package/lib/locale/fa-IR.js +1 -38
- package/lib/locale/fr-FR.js +1 -38
- package/lib/locale/ja-JP.js +1 -38
- package/lib/locale/ko-KR.js +1 -38
- package/lib/locale/ru-RU.js +1 -38
- package/lib/locale/sk-SK.js +1 -38
- package/lib/locale/vi-VN.js +1 -38
- package/lib/locale/zh-CN.js +1 -38
- package/lib/locale/zh-TW.js +1 -38
- package/lib/types/commands/operations/popup.operations.d.ts +17 -2
- package/lib/types/config/config.d.ts +16 -1
- package/lib/types/controllers/auto-fill.controller.d.ts +15 -0
- package/lib/types/controllers/copy-paste.controller.d.ts +15 -0
- package/lib/types/controllers/hyper-link-permission.controller.d.ts +15 -0
- package/lib/types/controllers/popup.controller.d.ts +15 -0
- package/lib/types/controllers/render-controllers/render.controller.d.ts +18 -2
- package/lib/types/controllers/ui.controller.d.ts +15 -0
- package/lib/types/controllers/url.controller.d.ts +15 -0
- package/lib/types/facade/f-workbook.d.ts +15 -0
- package/lib/types/locale/ca-ES.d.ts +16 -1
- package/lib/types/locale/es-ES.d.ts +16 -1
- package/lib/types/locale/fa-IR.d.ts +16 -1
- package/lib/types/locale/fr-FR.d.ts +16 -1
- package/lib/types/locale/ja-JP.d.ts +16 -1
- package/lib/types/locale/ko-KR.d.ts +16 -1
- package/lib/types/locale/ru-RU.d.ts +16 -1
- package/lib/types/locale/sk-SK.d.ts +16 -1
- package/lib/types/locale/vi-VN.d.ts +16 -1
- package/lib/types/locale/zh-CN.d.ts +16 -1
- package/lib/types/locale/zh-TW.d.ts +16 -1
- package/lib/types/menu/menu.d.ts +22 -6
- package/lib/types/menu/schema.d.ts +16 -1
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/popup.service.d.ts +21 -5
- package/lib/types/services/resolver.service.d.ts +18 -2
- package/lib/types/services/side-panel.service.d.ts +18 -2
- package/lib/types/utils/index.d.ts +16 -1
- package/lib/types/views/CellLinkPopup/index.d.ts +16 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +32 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +18 -17
package/lib/index.js
CHANGED
|
@@ -1,2006 +1,32 @@
|
|
|
1
|
-
var Jn = Object.defineProperty;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let n;
|
|
33
|
-
try {
|
|
34
|
-
n = new URL(e);
|
|
35
|
-
} catch {
|
|
36
|
-
return t;
|
|
37
|
-
}
|
|
38
|
-
return n.hostname === location.hostname && n.port === location.port && n.protocol === location.protocol && n.pathname === location.pathname && n.hash && !n.search ? n.hash : e;
|
|
39
|
-
}
|
|
40
|
-
return t;
|
|
41
|
-
}
|
|
42
|
-
const Un = "sheets-hyper-link-ui.config", mn = {};
|
|
43
|
-
var mi = Object.getOwnPropertyDescriptor, vi = (t, e, n, i) => {
|
|
44
|
-
for (var r = i > 1 ? void 0 : i ? mi(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
45
|
-
(o = t[s]) && (r = o(r) || r);
|
|
46
|
-
return r;
|
|
47
|
-
}, me = (t, e) => (n, i) => e(n, i, t);
|
|
48
|
-
function fi(t, e) {
|
|
49
|
-
const n = e.getMergeData(), i = e.getMaxColumns() - 1, r = e.getMaxRows() - 1;
|
|
50
|
-
if (i < t.endColumn && (t.endColumn = i), r < t.endRow && (t.endRow = r), t.rangeType === cn.COLUMN || cn.ROW)
|
|
51
|
-
return t;
|
|
52
|
-
const s = [];
|
|
53
|
-
return n.forEach((o) => {
|
|
54
|
-
Ie.intersects(t, o) && s.push(o);
|
|
55
|
-
}), Ie.realUnion(t, ...s);
|
|
56
|
-
}
|
|
57
|
-
let ce = class {
|
|
58
|
-
constructor(t, e, n, i, r, s) {
|
|
59
|
-
this._univerInstanceService = t, this._commandService = e, this._definedNamesService = n, this._messageService = i, this._localeService = r, this._configService = s;
|
|
60
|
-
}
|
|
61
|
-
navigate(t) {
|
|
62
|
-
t.type === C.URL ? this.navigateToOtherWebsite(t.url) : this._navigateToUniver(t.searchObj);
|
|
63
|
-
}
|
|
64
|
-
_navigateToUniver(t) {
|
|
65
|
-
const { gid: e, range: n, rangeid: i } = t, r = this._univerInstanceService.getCurrentUnitForType(k.UNIVER_SHEET);
|
|
66
|
-
if (!r)
|
|
67
|
-
return;
|
|
68
|
-
const s = r.getUnitId();
|
|
69
|
-
if (i) {
|
|
70
|
-
const o = this._definedNamesService.getValueById(s, i);
|
|
71
|
-
if (!o)
|
|
72
|
-
return;
|
|
73
|
-
const { formulaOrRefString: c } = o, u = this._definedNamesService.getWorksheetByRef(s, c);
|
|
74
|
-
if (!u) {
|
|
75
|
-
this._messageService.show({
|
|
76
|
-
content: this._localeService.t("hyperLink.message.refError"),
|
|
77
|
-
type: ke.Error
|
|
78
|
-
});
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (u.isSheetHidden()) {
|
|
82
|
-
this._messageService.show({
|
|
83
|
-
content: this._localeService.t("hyperLink.message.hiddenSheet"),
|
|
84
|
-
type: ke.Error
|
|
85
|
-
});
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
this.navigateToDefineName(s, i);
|
|
89
|
-
}
|
|
90
|
-
if (e) {
|
|
91
|
-
if (n) {
|
|
92
|
-
const o = Ge(n);
|
|
93
|
-
yn(o.range) && n !== ri && this.navigateToRange(s, e, o.range);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
this.navigateToSheetById(s, e);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async navigateToRange(t, e, n, i) {
|
|
100
|
-
const r = await this.navigateToSheetById(t, e);
|
|
101
|
-
if (r) {
|
|
102
|
-
const s = fi(n, r);
|
|
103
|
-
await this._commandService.executeCommand(
|
|
104
|
-
Rn.id,
|
|
105
|
-
{
|
|
106
|
-
unitId: t,
|
|
107
|
-
subUnitId: e,
|
|
108
|
-
selections: [{
|
|
109
|
-
range: s,
|
|
110
|
-
primary: null
|
|
111
|
-
}]
|
|
112
|
-
}
|
|
113
|
-
), await this._commandService.executeCommand(bn.id, {
|
|
114
|
-
range: s,
|
|
115
|
-
forceTop: i
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async navigateToSheetById(t, e) {
|
|
120
|
-
const n = this._univerInstanceService.getUnit(t, k.UNIVER_SHEET);
|
|
121
|
-
if (!n)
|
|
122
|
-
return !1;
|
|
123
|
-
const i = n.getActiveSheet();
|
|
124
|
-
if (!i)
|
|
125
|
-
return !1;
|
|
126
|
-
if (i.getSheetId() === e)
|
|
127
|
-
return i;
|
|
128
|
-
const r = n.getSheetBySheetId(e);
|
|
129
|
-
return r ? n.getHiddenWorksheets().indexOf(e) > -1 ? (this._messageService.show({
|
|
130
|
-
content: this._localeService.t("hyperLink.message.hiddenSheet"),
|
|
131
|
-
type: ke.Error
|
|
132
|
-
}), !1) : await this._commandService.executeCommand(Pn.id, { unitId: t, subUnitId: e }) ? r : !1 : (this._messageService.show({
|
|
133
|
-
content: this._localeService.t("hyperLink.message.noSheet"),
|
|
134
|
-
type: ke.Error
|
|
135
|
-
}), !1);
|
|
136
|
-
}
|
|
137
|
-
async navigateToDefineName(t, e) {
|
|
138
|
-
return this._definedNamesService.focusRange(t, e), !0;
|
|
139
|
-
}
|
|
140
|
-
async navigateToOtherWebsite(t) {
|
|
141
|
-
var n;
|
|
142
|
-
const e = this._configService.getConfig(Un);
|
|
143
|
-
if ((n = e == null ? void 0 : e.urlHandler) != null && n.navigateToOtherWebsite)
|
|
144
|
-
return e.urlHandler.navigateToOtherWebsite(t);
|
|
145
|
-
window.open(t, "_blank", "noopener noreferrer");
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
ce = vi([
|
|
149
|
-
me(0, G),
|
|
150
|
-
me(1, te),
|
|
151
|
-
me(2, On),
|
|
152
|
-
me(3, Tn),
|
|
153
|
-
me(4, y(ct)),
|
|
154
|
-
me(5, Sn)
|
|
155
|
-
], ce);
|
|
156
|
-
class Hn extends K {
|
|
157
|
-
constructor() {
|
|
158
|
-
super(...arguments);
|
|
159
|
-
A(this, "_customHyperLinks", /* @__PURE__ */ new Map());
|
|
160
|
-
}
|
|
161
|
-
isBuiltInLinkType(n) {
|
|
162
|
-
return n !== C.URL;
|
|
163
|
-
}
|
|
164
|
-
getOptions() {
|
|
165
|
-
return Array.from(this._customHyperLinks.values()).map(({ option: n }) => n);
|
|
166
|
-
}
|
|
167
|
-
findCustomHyperLink(n) {
|
|
168
|
-
return Array.from(this._customHyperLinks.values()).find((r) => r.match(n));
|
|
169
|
-
}
|
|
170
|
-
registerCustomHyperLink(n) {
|
|
171
|
-
this._customHyperLinks.set(n.type, n);
|
|
172
|
-
}
|
|
173
|
-
getCustomHyperLink(n) {
|
|
174
|
-
return this._customHyperLinks.get(n);
|
|
175
|
-
}
|
|
176
|
-
removeCustomHyperLink(n) {
|
|
177
|
-
const { _customHyperLinks: i } = this;
|
|
178
|
-
i.delete(n);
|
|
179
|
-
}
|
|
180
|
-
dispose() {
|
|
181
|
-
super.dispose(), this._customHyperLinks.clear();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const ze = () => {
|
|
185
|
-
var Gt;
|
|
186
|
-
const [t, e] = j(""), [n, i] = j(!1), [r, s] = j(""), [o, c] = j(!0), [u, p] = j(C.URL), [l, g] = j(""), d = S(ct), _ = S(On), I = S(ee), f = S(G), w = S(Z), a = Ar(w.currentEditing$), b = S(Dt), M = S(ce), T = S(te), P = S(Hn), D = Et(() => P.getOptions(), [P]), $ = S(dt), Y = S(He), ne = S(Rr), De = S(Ue), re = S(er), ye = S(tr), Ee = S(Ue), [Re, $e] = j(!1), de = S(Tt), Gn = Et(() => de.getCurrentSelections(), []), Ae = Et(() => {
|
|
187
|
-
if (!P.isBuiltInLinkType(u))
|
|
188
|
-
return P.getCustomHyperLink(u);
|
|
189
|
-
}, [P, u]), [pe, Kn] = j(!1), [Pe, jt] = j(!1), H = Mn(!1), V = f.getCurrentUnitForType(k.UNIVER_SHEET), Yn = (V == null ? void 0 : V.getActiveSheet().getSheetId()) || "", X = di((h) => {
|
|
190
|
-
s(h.replaceAll(un.CUSTOM_RANGE_START, "").replaceAll(un.CUSTOM_RANGE_END, ""));
|
|
191
|
-
}, [s]);
|
|
192
|
-
Q(() => {
|
|
193
|
-
var h, E, R, L, O, B, Kt, Yt, zt, Xt, qt, Jt, Qt, en, tn, nn, rn;
|
|
194
|
-
if ((a == null ? void 0 : a.row) !== void 0 && a.col !== void 0) {
|
|
195
|
-
const { customRange: ie, row: _t, col: It } = a;
|
|
196
|
-
let { label: z } = a;
|
|
197
|
-
typeof z == "number" && (z = `${z}`);
|
|
198
|
-
let F;
|
|
199
|
-
if (ie)
|
|
200
|
-
F = {
|
|
201
|
-
id: (h = ie == null ? void 0 : ie.rangeId) != null ? h : "",
|
|
202
|
-
display: z != null ? z : "",
|
|
203
|
-
payload: (R = (E = ie == null ? void 0 : ie.properties) == null ? void 0 : E.url) != null ? R : "",
|
|
204
|
-
row: _t,
|
|
205
|
-
column: It
|
|
206
|
-
};
|
|
207
|
-
else if (a.type === m.VIEWING) {
|
|
208
|
-
const N = f.getUnit(a.unitId), J = N == null ? void 0 : N.getSheetBySheetId(a.subUnitId), U = J == null ? void 0 : J.getCellRaw(a.row, a.col), he = (B = (O = (L = U == null ? void 0 : U.p) == null ? void 0 : L.body) == null ? void 0 : O.customRanges) == null ? void 0 : B.find((on) => {
|
|
209
|
-
var an;
|
|
210
|
-
return on.rangeType === Ne.HYPERLINK && ((an = on.properties) == null ? void 0 : an.url);
|
|
211
|
-
}), Le = U == null ? void 0 : U.v;
|
|
212
|
-
U && (!ve.transform.isEmptyDocument((Yt = (Kt = U.p) == null ? void 0 : Kt.body) == null ? void 0 : Yt.dataStream) || We.isDefine(Le)) && c(!1), F = {
|
|
213
|
-
id: "",
|
|
214
|
-
display: "",
|
|
215
|
-
payload: (Xt = (zt = he == null ? void 0 : he.properties) == null ? void 0 : zt.url) != null ? Xt : "",
|
|
216
|
-
row: _t,
|
|
217
|
-
column: It
|
|
218
|
-
};
|
|
219
|
-
} else {
|
|
220
|
-
const N = f.getCurrentUnitForType(k.UNIVER_DOC), J = De.getActiveTextRange(), U = N == null ? void 0 : N.getBody(), he = J && U ? J : null, Le = he && ((Jt = ve.customRange.getCustomRangesInterestsWithSelection(he, (qt = U == null ? void 0 : U.customRanges) != null ? qt : [])) == null ? void 0 : Jt[0]);
|
|
221
|
-
c(!1), F = {
|
|
222
|
-
id: "",
|
|
223
|
-
display: z != null ? z : "",
|
|
224
|
-
payload: (en = (Qt = Le == null ? void 0 : Le.properties) == null ? void 0 : Qt.url) != null ? en : "",
|
|
225
|
-
row: _t,
|
|
226
|
-
column: It
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
e(F.id);
|
|
230
|
-
const sn = P.findCustomHyperLink(F);
|
|
231
|
-
if (sn) {
|
|
232
|
-
const N = sn.convert(F);
|
|
233
|
-
p(N.type), g(N.payload), X(N.display);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
X(F.display);
|
|
237
|
-
const q = b.parseHyperLink(F.payload);
|
|
238
|
-
switch (p(q.type === C.INVALID ? C.RANGE : q.type), q.type) {
|
|
239
|
-
case C.URL: {
|
|
240
|
-
g(q.url), q.url === F.display && (H.current = !0);
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
case C.RANGE: {
|
|
244
|
-
const N = q.searchObj, J = N.gid && (rn = (nn = (tn = f.getUnit(a.unitId)) == null ? void 0 : tn.getSheetBySheetId(N.gid)) == null ? void 0 : nn.getName()) != null ? rn : "", U = Qr(J, Ge(N.range).range);
|
|
245
|
-
g(U), U === F.display && (H.current = !0);
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
case C.SHEET: {
|
|
249
|
-
const N = q.searchObj;
|
|
250
|
-
g(N.gid);
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
case C.DEFINE_NAME: {
|
|
254
|
-
const N = q.searchObj;
|
|
255
|
-
g(N.rangeid);
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
default:
|
|
259
|
-
g("");
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}, [a, M, P, De, f]), Q(() => {
|
|
264
|
-
let h = null;
|
|
265
|
-
if (a && !a.customRangeId && a.type === m.VIEWING && We.isDefine(a.row) && We.isDefine(a.col)) {
|
|
266
|
-
const E = f.getUnit(a.unitId, k.UNIVER_SHEET), R = E == null ? void 0 : E.getSheetBySheetId(a.subUnitId), L = R == null ? void 0 : R.getMergedCell(a.row, a.col), O = new nr(ye.getColorFromTheme("primary.600")).toRgb();
|
|
267
|
-
h = ne.addShape(
|
|
268
|
-
{
|
|
269
|
-
range: L != null ? L : {
|
|
270
|
-
startColumn: a.col,
|
|
271
|
-
endColumn: a.col,
|
|
272
|
-
startRow: a.row,
|
|
273
|
-
endRow: a.row
|
|
274
|
-
},
|
|
275
|
-
style: {
|
|
276
|
-
// hasAutoFill: false,
|
|
277
|
-
fill: `rgb(${O.r}, ${O.g}, ${O.b}, 0.12)`,
|
|
278
|
-
strokeWidth: 1,
|
|
279
|
-
stroke: "#FFBD37",
|
|
280
|
-
widgets: {}
|
|
281
|
-
},
|
|
282
|
-
primary: null
|
|
283
|
-
},
|
|
284
|
-
[],
|
|
285
|
-
-1
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
return () => {
|
|
289
|
-
h && ne.removeShape(h);
|
|
290
|
-
};
|
|
291
|
-
}, [a, ne, ye, f]), Q(() => {
|
|
292
|
-
jt(u === C.RANGE);
|
|
293
|
-
}, [u]), Q(() => {
|
|
294
|
-
const h = (a == null ? void 0 : a.type) === m.ZEN_EDITOR ? Y.getRenderById(x) : Y.getRenderById(I.getCurrentEditorId()), E = new rr();
|
|
295
|
-
if (h) {
|
|
296
|
-
const R = h.with(kn);
|
|
297
|
-
R.setReserveRangesStatus(!0), E.add(() => {
|
|
298
|
-
R.setReserveRangesStatus(!1);
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
return () => {
|
|
302
|
-
I.disableForceKeepVisible(), E.dispose();
|
|
303
|
-
};
|
|
304
|
-
}, [a == null ? void 0 : a.type, I, Y]), Q(() => (Pe && w.setIsKeepVisible(Pe), w.setIsKeepVisible(Re), () => {
|
|
305
|
-
w.setIsKeepVisible(!1);
|
|
306
|
-
}), [Pe, Re, w]), Q(() => () => {
|
|
307
|
-
$.temporaryHidden && ($.show(), re.setContextValue(Ct, !1));
|
|
308
|
-
}, [re, $]), Q(() => {
|
|
309
|
-
if (Pe)
|
|
310
|
-
return I.enableForceKeepVisible(), () => {
|
|
311
|
-
I.disableForceKeepVisible();
|
|
312
|
-
};
|
|
313
|
-
}, [Pe, I]);
|
|
314
|
-
const zn = [
|
|
315
|
-
{
|
|
316
|
-
label: d.t("hyperLink.form.link"),
|
|
317
|
-
value: C.URL
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
label: d.t("hyperLink.form.range"),
|
|
321
|
-
value: C.RANGE
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
label: d.t("hyperLink.form.worksheet"),
|
|
325
|
-
value: C.SHEET
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
label: d.t("hyperLink.form.definedName"),
|
|
329
|
-
value: C.DEFINE_NAME
|
|
330
|
-
},
|
|
331
|
-
...D
|
|
332
|
-
];
|
|
333
|
-
if (!V)
|
|
334
|
-
return;
|
|
335
|
-
const Xn = V.getHiddenWorksheets(), mt = V.getSheets().map((h) => ({ label: h.getName(), value: h.getSheetId() })).filter((h) => Xn.indexOf(h.value) === -1), vt = Object.values((Gt = _.getDefinedNameMap(V.getUnitId())) != null ? Gt : {}).map((h) => ({
|
|
336
|
-
label: h.name,
|
|
337
|
-
value: h.id
|
|
338
|
-
})), Zt = (h, E) => {
|
|
339
|
-
if (h === C.URL)
|
|
340
|
-
return gi(E);
|
|
341
|
-
if (h === C.RANGE) {
|
|
342
|
-
const R = Ge(E), L = V.getSheetBySheetName(R.sheetName);
|
|
343
|
-
if (L)
|
|
344
|
-
return `#gid=${L.getSheetId()}&range=${ti(R.range)}`;
|
|
345
|
-
}
|
|
346
|
-
return `#${h}=${E}`;
|
|
347
|
-
}, qn = Vr((h) => {
|
|
348
|
-
var O;
|
|
349
|
-
const R = h.split(",").map(Ge)[0];
|
|
350
|
-
if (!R || !yn(R.range))
|
|
351
|
-
return;
|
|
352
|
-
R.sheetName || (R.sheetName = ((O = V.getActiveSheet()) == null ? void 0 : O.getName()) || "");
|
|
353
|
-
const L = ei(R);
|
|
354
|
-
g(L), L && (H.current || !r) && (X(L), H.current = !0);
|
|
355
|
-
}), ft = async () => {
|
|
356
|
-
if (o && !r || !l || u === C.URL && !Ye(l)) {
|
|
357
|
-
Kn(!0);
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
if (a)
|
|
361
|
-
if (t) {
|
|
362
|
-
const h = a.type === m.ZEN_EDITOR || a.type === m.EDITING ? ii.id : si.id;
|
|
363
|
-
await T.executeCommand(h, {
|
|
364
|
-
id: t,
|
|
365
|
-
unitId: a.unitId,
|
|
366
|
-
subUnitId: a.subUnitId,
|
|
367
|
-
payload: {
|
|
368
|
-
display: o ? r : "",
|
|
369
|
-
payload: Zt(u, l)
|
|
370
|
-
},
|
|
371
|
-
row: a.row,
|
|
372
|
-
column: a.col,
|
|
373
|
-
documentId: a.type === m.ZEN_EDITOR ? x : I.getCurrentEditorId()
|
|
374
|
-
});
|
|
375
|
-
} else {
|
|
376
|
-
const h = a.type === m.ZEN_EDITOR || a.type === m.EDITING ? oi.id : ai.id;
|
|
377
|
-
await T.executeCommand(h, {
|
|
378
|
-
unitId: a.unitId,
|
|
379
|
-
subUnitId: a.subUnitId,
|
|
380
|
-
link: {
|
|
381
|
-
id: kt(),
|
|
382
|
-
row: a.row,
|
|
383
|
-
column: a.col,
|
|
384
|
-
payload: Zt(u, l),
|
|
385
|
-
display: o ? r : ""
|
|
386
|
-
},
|
|
387
|
-
documentId: a.type === m.ZEN_EDITOR ? x : I.getCurrentEditorId()
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
if ((a == null ? void 0 : a.type) === m.VIEWING) {
|
|
391
|
-
await T.executeCommand(Pn.id, {
|
|
392
|
-
unitId: a.unitId,
|
|
393
|
-
subUnitId: a.subUnitId
|
|
394
|
-
});
|
|
395
|
-
const h = 1;
|
|
396
|
-
await T.executeCommand(bn.id, {
|
|
397
|
-
range: {
|
|
398
|
-
startRow: Math.max(a.row - h, 0),
|
|
399
|
-
endRow: a.row + h,
|
|
400
|
-
startColumn: Math.max(a.col - h, 0),
|
|
401
|
-
endColumn: a.col + h
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
T.executeCommand(qe.id);
|
|
406
|
-
};
|
|
407
|
-
return a ? /* @__PURE__ */ fe(
|
|
408
|
-
"div",
|
|
409
|
-
{
|
|
410
|
-
className: Ze("univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900", xn),
|
|
411
|
-
children: [
|
|
412
|
-
o ? /* @__PURE__ */ v(
|
|
413
|
-
ge,
|
|
414
|
-
{
|
|
415
|
-
label: d.t("hyperLink.form.label"),
|
|
416
|
-
error: pe && !r ? d.t("hyperLink.form.inputError") : "",
|
|
417
|
-
children: /* @__PURE__ */ v(
|
|
418
|
-
pn,
|
|
419
|
-
{
|
|
420
|
-
value: r,
|
|
421
|
-
onChange: (h) => {
|
|
422
|
-
X(h), H.current = !1;
|
|
423
|
-
},
|
|
424
|
-
placeholder: d.t("hyperLink.form.labelPlaceholder"),
|
|
425
|
-
autoFocus: !0,
|
|
426
|
-
onKeyDown: (h) => {
|
|
427
|
-
h.keyCode === Lt.ENTER && ft();
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
)
|
|
431
|
-
}
|
|
432
|
-
) : null,
|
|
433
|
-
/* @__PURE__ */ v(ge, { label: d.t("hyperLink.form.type"), children: /* @__PURE__ */ v(
|
|
434
|
-
yt,
|
|
435
|
-
{
|
|
436
|
-
className: "univer-w-full",
|
|
437
|
-
options: zn,
|
|
438
|
-
value: u,
|
|
439
|
-
onChange: (h) => {
|
|
440
|
-
p(h), g("");
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
) }),
|
|
444
|
-
u === C.URL && /* @__PURE__ */ v(
|
|
445
|
-
ge,
|
|
446
|
-
{
|
|
447
|
-
error: pe ? l ? Ye(l) ? "" : d.t("hyperLink.form.linkError") : d.t("hyperLink.form.inputError") : "",
|
|
448
|
-
children: /* @__PURE__ */ v(
|
|
449
|
-
pn,
|
|
450
|
-
{
|
|
451
|
-
value: l,
|
|
452
|
-
onChange: (h) => {
|
|
453
|
-
g(h), h && (H.current || !r || r === h) && (X(h), H.current = !0);
|
|
454
|
-
},
|
|
455
|
-
placeholder: d.t("hyperLink.form.linkPlaceholder"),
|
|
456
|
-
autoFocus: !0,
|
|
457
|
-
onKeyDown: (h) => {
|
|
458
|
-
h.keyCode === Lt.ENTER && ft();
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
)
|
|
462
|
-
}
|
|
463
|
-
),
|
|
464
|
-
u === C.RANGE && /* @__PURE__ */ v(ge, { error: pe && !l ? d.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ v(
|
|
465
|
-
ni,
|
|
466
|
-
{
|
|
467
|
-
unitId: V.getUnitId(),
|
|
468
|
-
subUnitId: Yn,
|
|
469
|
-
maxRangeCount: 1,
|
|
470
|
-
supportAcrossSheet: !0,
|
|
471
|
-
initialValue: l,
|
|
472
|
-
resetRange: Gn,
|
|
473
|
-
onChange: (h, E) => qn(E),
|
|
474
|
-
onRangeSelectorDialogVisibleChange: async (h) => {
|
|
475
|
-
var E, R;
|
|
476
|
-
if ($e(h), h)
|
|
477
|
-
a.type === m.ZEN_EDITOR && ($.hide(), re.setContextValue(Ct, !0)), a.type !== m.VIEWING && I.enableForceKeepVisible(), i(!0);
|
|
478
|
-
else {
|
|
479
|
-
if (await M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, !0), a.type === m.ZEN_EDITOR) {
|
|
480
|
-
await T.executeCommand(Rn.id, {
|
|
481
|
-
unitId: a.unitId,
|
|
482
|
-
subUnitId: a.subUnitId,
|
|
483
|
-
selections: [{ range: { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col } }]
|
|
484
|
-
}), $.show(), re.setContextValue(Ct, !1);
|
|
485
|
-
const L = (E = Y.getRenderById(x)) == null ? void 0 : E.with(Ur), O = (R = Ee.getTextRanges({ unitId: x, subUnitId: x })) == null ? void 0 : R[0];
|
|
486
|
-
L && O && (L.scrollToRange(O), Ee.refreshSelection({ unitId: x, subUnitId: x }));
|
|
487
|
-
}
|
|
488
|
-
I.disableForceKeepVisible(), i(!1);
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
onFocusChange: (h) => jt(h)
|
|
492
|
-
}
|
|
493
|
-
) }),
|
|
494
|
-
u === C.SHEET && /* @__PURE__ */ v(ge, { error: pe && !l ? d.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ v(
|
|
495
|
-
yt,
|
|
496
|
-
{
|
|
497
|
-
className: "univer-w-full",
|
|
498
|
-
options: mt,
|
|
499
|
-
value: l,
|
|
500
|
-
onChange: (h) => {
|
|
501
|
-
var L, O;
|
|
502
|
-
g(h);
|
|
503
|
-
const E = (L = mt.find((B) => B.value === h)) == null ? void 0 : L.label, R = (O = mt.find((B) => B.value === l)) == null ? void 0 : O.label;
|
|
504
|
-
E && (H.current || !r || r === R) && (X(E), H.current = !0);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
) }),
|
|
508
|
-
u === C.DEFINE_NAME && /* @__PURE__ */ v(ge, { error: pe && !l ? d.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ v(
|
|
509
|
-
yt,
|
|
510
|
-
{
|
|
511
|
-
className: "univer-w-full",
|
|
512
|
-
options: vt,
|
|
513
|
-
value: l,
|
|
514
|
-
onChange: (h) => {
|
|
515
|
-
var L, O;
|
|
516
|
-
g(h);
|
|
517
|
-
const E = (L = vt.find((B) => B.value === h)) == null ? void 0 : L.label, R = (O = vt.find((B) => B.value === l)) == null ? void 0 : O.label;
|
|
518
|
-
E && (H.current || !r || r === R) && (X(E), H.current = !0);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
) }),
|
|
522
|
-
(Ae == null ? void 0 : Ae.Form) && /* @__PURE__ */ v(
|
|
523
|
-
Ae.Form,
|
|
524
|
-
{
|
|
525
|
-
linkId: t,
|
|
526
|
-
payload: l,
|
|
527
|
-
display: r,
|
|
528
|
-
showError: pe,
|
|
529
|
-
setByPayload: H,
|
|
530
|
-
setDisplay: (h) => {
|
|
531
|
-
X(h), H.current = !0;
|
|
532
|
-
},
|
|
533
|
-
setPayload: g
|
|
534
|
-
}
|
|
535
|
-
),
|
|
536
|
-
/* @__PURE__ */ fe("div", { className: "univer-flex univer-flex-row univer-justify-end univer-gap-2", children: [
|
|
537
|
-
/* @__PURE__ */ v(
|
|
538
|
-
hn,
|
|
539
|
-
{
|
|
540
|
-
onClick: () => {
|
|
541
|
-
a && M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, !0), T.executeCommand(qe.id);
|
|
542
|
-
},
|
|
543
|
-
children: d.t("hyperLink.form.cancel")
|
|
544
|
-
}
|
|
545
|
-
),
|
|
546
|
-
/* @__PURE__ */ v(
|
|
547
|
-
hn,
|
|
548
|
-
{
|
|
549
|
-
variant: "primary",
|
|
550
|
-
onClick: async () => {
|
|
551
|
-
ft();
|
|
552
|
-
},
|
|
553
|
-
children: d.t("hyperLink.form.ok")
|
|
554
|
-
}
|
|
555
|
-
)
|
|
556
|
-
] })
|
|
557
|
-
]
|
|
558
|
-
}
|
|
559
|
-
) : null;
|
|
560
|
-
};
|
|
561
|
-
ze.componentKey = "univer.sheet.cell-link-edit";
|
|
562
|
-
function le({ ref: t, ...e }) {
|
|
563
|
-
const { icon: n, id: i, className: r, extend: s, ...o } = e, c = `univerjs-icon univerjs-icon-${i} ${r || ""}`.trim(), u = Mn(`_${Ci()}`);
|
|
564
|
-
return Dn(n, `${i}`, {
|
|
565
|
-
defIds: n.defIds,
|
|
566
|
-
idSuffix: u.current
|
|
567
|
-
}, {
|
|
568
|
-
ref: t,
|
|
569
|
-
className: c,
|
|
570
|
-
...o
|
|
571
|
-
}, s);
|
|
572
|
-
}
|
|
573
|
-
function Dn(t, e, n, i, r) {
|
|
574
|
-
return ue(t.tag, {
|
|
575
|
-
key: e,
|
|
576
|
-
..._i(t, n, r),
|
|
577
|
-
...i
|
|
578
|
-
}, (Ii(t, n).children || []).map((s, o) => Dn(s, `${e}-${t.tag}-${o}`, n, void 0, r)));
|
|
579
|
-
}
|
|
580
|
-
function _i(t, e, n) {
|
|
581
|
-
const i = { ...t.attrs };
|
|
582
|
-
n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1), t.tag === "mask" && i.id && (i.id = i.id + e.idSuffix), Object.entries(i).forEach(([s, o]) => {
|
|
583
|
-
s === "mask" && typeof o == "string" && (i[s] = o.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
|
|
584
|
-
});
|
|
585
|
-
const { defIds: r } = e;
|
|
586
|
-
return !r || r.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(([s, o]) => {
|
|
587
|
-
typeof o == "string" && (i[s] = o.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
|
|
588
|
-
})), i;
|
|
589
|
-
}
|
|
590
|
-
function Ii(t, e) {
|
|
591
|
-
var i;
|
|
592
|
-
const { defIds: n } = e;
|
|
593
|
-
return !n || n.length === 0 ? t : t.tag === "defs" && ((i = t.children) != null && i.length) ? {
|
|
594
|
-
...t,
|
|
595
|
-
children: t.children.map((r) => typeof r.attrs.id == "string" && n && n.includes(r.attrs.id) ? {
|
|
596
|
-
...r,
|
|
597
|
-
attrs: {
|
|
598
|
-
...r.attrs,
|
|
599
|
-
id: r.attrs.id + e.idSuffix
|
|
600
|
-
}
|
|
601
|
-
} : r)
|
|
602
|
-
} : t;
|
|
603
|
-
}
|
|
604
|
-
function Ci() {
|
|
605
|
-
return Math.random().toString(36).substring(2, 8);
|
|
606
|
-
}
|
|
607
|
-
le.displayName = "UniverIcon";
|
|
608
|
-
const Si = {
|
|
609
|
-
tag: "svg",
|
|
610
|
-
attrs: {
|
|
611
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
612
|
-
fill: "none",
|
|
613
|
-
viewBox: "0 0 16 16",
|
|
614
|
-
width: "1em",
|
|
615
|
-
height: "1em"
|
|
616
|
-
},
|
|
617
|
-
children: [{
|
|
618
|
-
tag: "path",
|
|
619
|
-
attrs: {
|
|
620
|
-
fill: "currentColor",
|
|
621
|
-
d: "M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",
|
|
622
|
-
fillRule: "evenodd",
|
|
623
|
-
clipRule: "evenodd"
|
|
624
|
-
}
|
|
625
|
-
}]
|
|
626
|
-
}, Ke = Se(function(e, n) {
|
|
627
|
-
return ue(le, Object.assign({}, e, {
|
|
628
|
-
id: "all-border-icon",
|
|
629
|
-
ref: n,
|
|
630
|
-
icon: Si
|
|
631
|
-
}));
|
|
632
|
-
});
|
|
633
|
-
Ke.displayName = "AllBorderIcon";
|
|
634
|
-
const yi = {
|
|
635
|
-
tag: "svg",
|
|
636
|
-
attrs: {
|
|
637
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
638
|
-
fill: "none",
|
|
639
|
-
viewBox: "0 0 16 16",
|
|
640
|
-
width: "1em",
|
|
641
|
-
height: "1em"
|
|
642
|
-
},
|
|
643
|
-
children: [{
|
|
644
|
-
tag: "path",
|
|
645
|
-
attrs: {
|
|
646
|
-
fill: "currentColor",
|
|
647
|
-
d: "M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",
|
|
648
|
-
fillRule: "evenodd",
|
|
649
|
-
clipRule: "evenodd"
|
|
650
|
-
}
|
|
651
|
-
}]
|
|
652
|
-
}, $n = Se(function(e, n) {
|
|
653
|
-
return ue(le, Object.assign({}, e, {
|
|
654
|
-
id: "copy-icon",
|
|
655
|
-
ref: n,
|
|
656
|
-
icon: yi
|
|
657
|
-
}));
|
|
658
|
-
});
|
|
659
|
-
$n.displayName = "CopyIcon";
|
|
660
|
-
const Ei = {
|
|
661
|
-
tag: "svg",
|
|
662
|
-
attrs: {
|
|
663
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
664
|
-
fill: "none",
|
|
665
|
-
viewBox: "0 0 16 16",
|
|
666
|
-
width: "1em",
|
|
667
|
-
height: "1em"
|
|
668
|
-
},
|
|
669
|
-
children: [{
|
|
670
|
-
tag: "path",
|
|
671
|
-
attrs: {
|
|
672
|
-
fill: "currentColor",
|
|
673
|
-
d: "M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"
|
|
674
|
-
}
|
|
675
|
-
}, {
|
|
676
|
-
tag: "path",
|
|
677
|
-
attrs: {
|
|
678
|
-
fill: "currentColor",
|
|
679
|
-
d: "M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"
|
|
680
|
-
}
|
|
681
|
-
}]
|
|
682
|
-
}, $t = Se(function(e, n) {
|
|
683
|
-
return ue(le, Object.assign({}, e, {
|
|
684
|
-
id: "link-icon",
|
|
685
|
-
ref: n,
|
|
686
|
-
icon: Ei
|
|
687
|
-
}));
|
|
688
|
-
});
|
|
689
|
-
$t.displayName = "LinkIcon";
|
|
690
|
-
const Ri = {
|
|
691
|
-
tag: "svg",
|
|
692
|
-
attrs: {
|
|
693
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
694
|
-
fill: "none",
|
|
695
|
-
viewBox: "0 0 16 17",
|
|
696
|
-
width: "1em",
|
|
697
|
-
height: "1em"
|
|
698
|
-
},
|
|
699
|
-
children: [
|
|
700
|
-
{
|
|
701
|
-
tag: "path",
|
|
702
|
-
attrs: {
|
|
703
|
-
fill: "currentColor",
|
|
704
|
-
d: "M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z"
|
|
705
|
-
}
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
tag: "path",
|
|
709
|
-
attrs: {
|
|
710
|
-
fill: "currentColor",
|
|
711
|
-
d: "M3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z"
|
|
712
|
-
}
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
tag: "path",
|
|
716
|
-
attrs: {
|
|
717
|
-
fill: "currentColor",
|
|
718
|
-
d: "M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z"
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
]
|
|
722
|
-
}, An = Se(function(e, n) {
|
|
723
|
-
return ue(le, Object.assign({}, e, {
|
|
724
|
-
id: "unlink-icon",
|
|
725
|
-
ref: n,
|
|
726
|
-
icon: Ri
|
|
727
|
-
}));
|
|
728
|
-
});
|
|
729
|
-
An.displayName = "UnlinkIcon";
|
|
730
|
-
const Pi = {
|
|
731
|
-
tag: "svg",
|
|
732
|
-
attrs: {
|
|
733
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
734
|
-
fill: "none",
|
|
735
|
-
viewBox: "0 0 17 16",
|
|
736
|
-
width: "1em",
|
|
737
|
-
height: "1em"
|
|
738
|
-
},
|
|
739
|
-
children: [{
|
|
740
|
-
tag: "path",
|
|
741
|
-
attrs: {
|
|
742
|
-
fill: "currentColor",
|
|
743
|
-
d: "M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",
|
|
744
|
-
fillRule: "evenodd",
|
|
745
|
-
clipRule: "evenodd"
|
|
746
|
-
}
|
|
747
|
-
}, {
|
|
748
|
-
tag: "path",
|
|
749
|
-
attrs: {
|
|
750
|
-
fill: "currentColor",
|
|
751
|
-
d: "M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"
|
|
752
|
-
}
|
|
753
|
-
}]
|
|
754
|
-
}, Vn = Se(function(e, n) {
|
|
755
|
-
return ue(le, Object.assign({}, e, {
|
|
756
|
-
id: "write-icon",
|
|
757
|
-
ref: n,
|
|
758
|
-
icon: Pi
|
|
759
|
-
}));
|
|
760
|
-
});
|
|
761
|
-
Vn.displayName = "WriteIcon";
|
|
762
|
-
const Li = {
|
|
763
|
-
tag: "svg",
|
|
764
|
-
attrs: {
|
|
765
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
766
|
-
fill: "none",
|
|
767
|
-
viewBox: "0 0 16 16",
|
|
768
|
-
width: "1em",
|
|
769
|
-
height: "1em"
|
|
770
|
-
},
|
|
771
|
-
children: [
|
|
772
|
-
{
|
|
773
|
-
tag: "path",
|
|
774
|
-
attrs: {
|
|
775
|
-
fill: "#35BD4B",
|
|
776
|
-
d: "M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"
|
|
777
|
-
}
|
|
778
|
-
},
|
|
779
|
-
{
|
|
780
|
-
tag: "path",
|
|
781
|
-
attrs: {
|
|
782
|
-
fill: "#32A846",
|
|
783
|
-
d: "M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"
|
|
784
|
-
}
|
|
785
|
-
},
|
|
786
|
-
{
|
|
787
|
-
tag: "path",
|
|
788
|
-
attrs: {
|
|
789
|
-
fill: "white",
|
|
790
|
-
d: "M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",
|
|
791
|
-
fillRule: "evenodd",
|
|
792
|
-
clipRule: "evenodd"
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
]
|
|
796
|
-
}, Bn = Se(function(e, n) {
|
|
797
|
-
return ue(le, Object.assign({}, e, {
|
|
798
|
-
id: "xlsx-multi-icon",
|
|
799
|
-
ref: n,
|
|
800
|
-
icon: Li
|
|
801
|
-
}));
|
|
802
|
-
});
|
|
803
|
-
Bn.displayName = "XlsxMultiIcon";
|
|
804
|
-
const wi = {
|
|
805
|
-
[C.URL]: /* @__PURE__ */ v($t, {}),
|
|
806
|
-
[C.SHEET]: /* @__PURE__ */ v(Bn, { className: "univer-text-green-500" }),
|
|
807
|
-
[C.RANGE]: /* @__PURE__ */ v(Ke, {}),
|
|
808
|
-
[C.DEFINE_NAME]: /* @__PURE__ */ v(Ke, {}),
|
|
809
|
-
[C.INVALID]: /* @__PURE__ */ v(Ke, {})
|
|
810
|
-
}, vn = (t) => {
|
|
811
|
-
var M, T;
|
|
812
|
-
const e = S(Z), n = S(te), i = S(Tn), r = S(ct), s = S(ce), o = S(ee), c = S(Dt), u = S(dt), { customRange: p, row: l, col: g, unitId: d, subUnitId: _, editPermission: I, copyPermission: f, type: w } = t;
|
|
813
|
-
if (!((M = p == null ? void 0 : p.properties) != null && M.url))
|
|
814
|
-
return null;
|
|
815
|
-
const a = c.parseHyperLink((T = p.properties.url) != null ? T : ""), b = a.type === C.INVALID;
|
|
816
|
-
return /* @__PURE__ */ fe(
|
|
817
|
-
"div",
|
|
818
|
-
{
|
|
819
|
-
className: Ze("univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow-md dark:!univer-bg-gray-900", xn),
|
|
820
|
-
onClick: () => e.hideCurrentPopup(),
|
|
821
|
-
children: [
|
|
822
|
-
/* @__PURE__ */ fe(
|
|
823
|
-
"div",
|
|
824
|
-
{
|
|
825
|
-
className: Ze("univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600", { "univer-text-red-500": b }),
|
|
826
|
-
onClick: () => {
|
|
827
|
-
u.visible || b || s.navigate(a);
|
|
828
|
-
},
|
|
829
|
-
children: [
|
|
830
|
-
/* @__PURE__ */ v(
|
|
831
|
-
"div",
|
|
832
|
-
{
|
|
833
|
-
className: "univer-mr-2 univer-flex univer-size-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",
|
|
834
|
-
children: wi[a.type]
|
|
835
|
-
}
|
|
836
|
-
),
|
|
837
|
-
/* @__PURE__ */ v(Be, { showIfEllipsis: !0, title: a.name, asChild: !0, children: /* @__PURE__ */ v("span", { className: "univer-flex-1 univer-truncate", children: a.name }) })
|
|
838
|
-
]
|
|
839
|
-
}
|
|
840
|
-
),
|
|
841
|
-
/* @__PURE__ */ fe(
|
|
842
|
-
"div",
|
|
843
|
-
{
|
|
844
|
-
className: "univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center",
|
|
845
|
-
children: [
|
|
846
|
-
f && /* @__PURE__ */ v(
|
|
847
|
-
"div",
|
|
848
|
-
{
|
|
849
|
-
className: Ze("univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", { "univer-text-red-500": b }),
|
|
850
|
-
onClick: () => {
|
|
851
|
-
if (!b) {
|
|
852
|
-
if (a.type !== C.URL) {
|
|
853
|
-
const P = new URL(window.location.href);
|
|
854
|
-
P.hash = a.url.slice(1), navigator.clipboard.writeText(P.href);
|
|
855
|
-
} else
|
|
856
|
-
navigator.clipboard.writeText(a.url);
|
|
857
|
-
i.show({
|
|
858
|
-
content: r.t("hyperLink.message.coped"),
|
|
859
|
-
type: ke.Info
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
},
|
|
863
|
-
children: /* @__PURE__ */ v(Be, { placement: "bottom", title: r.t("hyperLink.popup.copy"), children: /* @__PURE__ */ v($n, { className: "dark:!univer-text-white" }) })
|
|
864
|
-
}
|
|
865
|
-
),
|
|
866
|
-
I && /* @__PURE__ */ fe(Jr, { children: [
|
|
867
|
-
/* @__PURE__ */ v(
|
|
868
|
-
"div",
|
|
869
|
-
{
|
|
870
|
-
className: "univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
871
|
-
onClick: () => {
|
|
872
|
-
n.executeCommand(Vt.id, {
|
|
873
|
-
unitId: d,
|
|
874
|
-
subUnitId: _,
|
|
875
|
-
row: l,
|
|
876
|
-
col: g,
|
|
877
|
-
customRangeId: p.rangeId,
|
|
878
|
-
type: w
|
|
879
|
-
});
|
|
880
|
-
},
|
|
881
|
-
children: /* @__PURE__ */ v(Be, { placement: "bottom", title: r.t("hyperLink.popup.edit"), children: /* @__PURE__ */ v(Vn, { className: "dark:!univer-text-white" }) })
|
|
882
|
-
}
|
|
883
|
-
),
|
|
884
|
-
/* @__PURE__ */ v(
|
|
885
|
-
"div",
|
|
886
|
-
{
|
|
887
|
-
className: "univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
888
|
-
onClick: () => {
|
|
889
|
-
const P = w === m.EDITING || w === m.ZEN_EDITOR ? ci.id : ui.id;
|
|
890
|
-
n.syncExecuteCommand(P, {
|
|
891
|
-
unitId: d,
|
|
892
|
-
subUnitId: _,
|
|
893
|
-
id: p.rangeId,
|
|
894
|
-
row: l,
|
|
895
|
-
column: g,
|
|
896
|
-
documentId: w === m.ZEN_EDITOR ? x : o.getCurrentEditorId()
|
|
897
|
-
}) && e.hideCurrentPopup(void 0, !0);
|
|
898
|
-
},
|
|
899
|
-
children: /* @__PURE__ */ v(Be, { placement: "bottom", title: r.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ v(An, { className: "dark:!univer-text-white" }) })
|
|
900
|
-
}
|
|
901
|
-
)
|
|
902
|
-
] })
|
|
903
|
-
]
|
|
904
|
-
}
|
|
905
|
-
)
|
|
906
|
-
]
|
|
907
|
-
}
|
|
908
|
-
);
|
|
909
|
-
}, Xe = () => {
|
|
910
|
-
var r, s;
|
|
911
|
-
const t = S(Z), [e, n] = j(null), i = S(G);
|
|
912
|
-
if (Q(() => {
|
|
913
|
-
n(t.currentPopup);
|
|
914
|
-
const o = t.currentPopup$.subscribe((c) => {
|
|
915
|
-
n(c);
|
|
916
|
-
});
|
|
917
|
-
return () => {
|
|
918
|
-
o.unsubscribe();
|
|
919
|
-
};
|
|
920
|
-
}, [t.currentPopup, t.currentPopup$]), !e)
|
|
921
|
-
return null;
|
|
922
|
-
if (e.showAll) {
|
|
923
|
-
const o = i.getUnit(e.unitId, k.UNIVER_SHEET), c = o == null ? void 0 : o.getSheetBySheetId(e.subUnitId), u = c == null ? void 0 : c.getCell(e.row, e.col), p = (s = (r = u == null ? void 0 : u.p) == null ? void 0 : r.body) == null ? void 0 : s.customRanges;
|
|
924
|
-
return p != null && p.length ? /* @__PURE__ */ v("div", { children: p.map((l) => /* @__PURE__ */ v(vn, { ...e, customRange: l }, l.rangeId)) }) : null;
|
|
925
|
-
}
|
|
926
|
-
return /* @__PURE__ */ v(vn, { ...e });
|
|
927
|
-
};
|
|
928
|
-
Xe.componentKey = "univer.sheet.cell-link-popup";
|
|
929
|
-
var bi = Object.getOwnPropertyDescriptor, ki = (t, e, n, i) => {
|
|
930
|
-
for (var r = i > 1 ? void 0 : i ? bi(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
931
|
-
(o = t[s]) && (r = o(r) || r);
|
|
932
|
-
return r;
|
|
933
|
-
}, se = (t, e) => (n, i) => e(n, i, t);
|
|
934
|
-
const fn = (t, e) => {
|
|
935
|
-
var n, i;
|
|
936
|
-
return t.unitId === e.unitId && t.subUnitId === e.subUnitId && t.row === e.row && t.col === e.col && ((n = t.customRange) == null ? void 0 : n.rangeId) === ((i = e.customRange) == null ? void 0 : i.rangeId) && t.type === e.type;
|
|
937
|
-
};
|
|
938
|
-
let Z = class extends K {
|
|
939
|
-
constructor(e, n, i, r, s, o, c) {
|
|
940
|
-
super();
|
|
941
|
-
A(this, "_currentPopup", null);
|
|
942
|
-
A(this, "_currentPopup$", new Yr());
|
|
943
|
-
A(this, "currentPopup$", this._currentPopup$.asObservable());
|
|
944
|
-
A(this, "_currentEditingPopup", null);
|
|
945
|
-
A(this, "_currentEditing$", new zr(null));
|
|
946
|
-
A(this, "currentEditing$", this._currentEditing$.asObservable());
|
|
947
|
-
A(this, "_isKeepVisible", !1);
|
|
948
|
-
this._sheetCanvasPopManagerService = e, this._injector = n, this._univerInstanceService = i, this._editorBridgeService = r, this._textSelectionManagerService = s, this._docCanvasPopManagerService = o, this._zenZoneService = c, this.disposeWithMe(() => {
|
|
949
|
-
this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete();
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
get currentPopup() {
|
|
953
|
-
return this._currentPopup;
|
|
954
|
-
}
|
|
955
|
-
get currentEditing() {
|
|
956
|
-
return this._currentEditing$.getValue();
|
|
957
|
-
}
|
|
958
|
-
setIsKeepVisible(e) {
|
|
959
|
-
this._isKeepVisible = e;
|
|
960
|
-
}
|
|
961
|
-
getIsKeepVisible() {
|
|
962
|
-
return this._isKeepVisible;
|
|
963
|
-
}
|
|
964
|
-
// eslint-disable-next-line max-lines-per-function
|
|
965
|
-
showPopup(e) {
|
|
966
|
-
var g;
|
|
967
|
-
if (this._currentPopup && fn(e, this._currentPopup) || (this.hideCurrentPopup(void 0, !0), e.type !== m.ZEN_EDITOR && this._zenZoneService.visible))
|
|
968
|
-
return;
|
|
969
|
-
const n = this._currentEditing$.getValue();
|
|
970
|
-
if (n && fn(e, n))
|
|
971
|
-
return;
|
|
972
|
-
const { unitId: i, subUnitId: r, row: s, col: o, customRangeRect: c, customRange: u } = e;
|
|
973
|
-
let p;
|
|
974
|
-
const l = {
|
|
975
|
-
componentKey: Xe.componentKey,
|
|
976
|
-
direction: "bottom",
|
|
977
|
-
onClickOutside: () => {
|
|
978
|
-
this.hideCurrentPopup();
|
|
979
|
-
},
|
|
980
|
-
onClick: () => {
|
|
981
|
-
this.hideCurrentPopup(e.type, !0);
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
if (e.type === m.EDITING) {
|
|
985
|
-
if (!u)
|
|
986
|
-
return;
|
|
987
|
-
p = c && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
|
|
988
|
-
c,
|
|
989
|
-
l
|
|
990
|
-
);
|
|
991
|
-
} else if (e.type === m.ZEN_EDITOR) {
|
|
992
|
-
if (!u)
|
|
993
|
-
return;
|
|
994
|
-
p = this._docCanvasPopManagerService.attachPopupToRange(
|
|
995
|
-
{
|
|
996
|
-
startOffset: u.startIndex,
|
|
997
|
-
endOffset: u.endIndex + 1,
|
|
998
|
-
collapsed: !1
|
|
999
|
-
},
|
|
1000
|
-
l,
|
|
1001
|
-
x
|
|
1002
|
-
);
|
|
1003
|
-
} else if (e.showAll)
|
|
1004
|
-
p = this._sheetCanvasPopManagerService.attachPopupToCell(e.row, e.col, l, i, r);
|
|
1005
|
-
else {
|
|
1006
|
-
if (!u)
|
|
1007
|
-
return;
|
|
1008
|
-
p = c && this._sheetCanvasPopManagerService.attachPopupByPosition(
|
|
1009
|
-
c,
|
|
1010
|
-
l,
|
|
1011
|
-
e
|
|
1012
|
-
);
|
|
1013
|
-
}
|
|
1014
|
-
p && (this._currentPopup && ((g = this._currentPopup.disposable) == null || g.dispose()), this._currentPopup = {
|
|
1015
|
-
unitId: i,
|
|
1016
|
-
subUnitId: r,
|
|
1017
|
-
disposable: p,
|
|
1018
|
-
row: s,
|
|
1019
|
-
col: o,
|
|
1020
|
-
editPermission: !!e.editPermission,
|
|
1021
|
-
copyPermission: !!e.copyPermission,
|
|
1022
|
-
customRange: u,
|
|
1023
|
-
type: e.type,
|
|
1024
|
-
showAll: e.showAll
|
|
1025
|
-
}, this._currentPopup$.next(this._currentPopup));
|
|
1026
|
-
}
|
|
1027
|
-
hideCurrentPopup(e, n) {
|
|
1028
|
-
var i, r;
|
|
1029
|
-
this._currentPopup && ((!e || e === this._currentPopup.type) && this._currentPopup.disposable.canDispose() || n) && ((r = (i = this._currentPopup) == null ? void 0 : i.disposable) == null || r.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
|
|
1030
|
-
}
|
|
1031
|
-
dispose() {
|
|
1032
|
-
super.dispose(), this.hideCurrentPopup(), this.endEditing(), this._currentPopup$.complete(), this._currentEditing$.complete();
|
|
1033
|
-
}
|
|
1034
|
-
_getEditingRange() {
|
|
1035
|
-
var i, r, s;
|
|
1036
|
-
const e = this._editorBridgeService.isVisible().visible, n = this._editorBridgeService.getEditCellState();
|
|
1037
|
-
if (e && n) {
|
|
1038
|
-
const o = this._textSelectionManagerService.getActiveTextRange(), c = (i = n.documentLayoutObject.documentModel) == null ? void 0 : i.getBody();
|
|
1039
|
-
if (!c)
|
|
1040
|
-
return null;
|
|
1041
|
-
if (!o || o.collapsed)
|
|
1042
|
-
return {
|
|
1043
|
-
startOffset: 0,
|
|
1044
|
-
endOffset: c.dataStream.length - 2,
|
|
1045
|
-
collapsed: c.dataStream.length - 2 === 0,
|
|
1046
|
-
label: ve.transform.getPlainText(c.dataStream)
|
|
1047
|
-
};
|
|
1048
|
-
const u = ve.customRange.getCustomRangesInterestsWithSelection(o, (s = (r = c.customRanges) == null ? void 0 : r.filter((g) => g.rangeType === Ne.HYPERLINK)) != null ? s : []);
|
|
1049
|
-
let p = o.startOffset, l = o.endOffset;
|
|
1050
|
-
return u.forEach((g) => {
|
|
1051
|
-
p = Math.min(p, g.startIndex), l = Math.max(l, g.endIndex + 1);
|
|
1052
|
-
}), {
|
|
1053
|
-
startOffset: p,
|
|
1054
|
-
endOffset: l,
|
|
1055
|
-
collapsed: p === l,
|
|
1056
|
-
label: ve.transform.getPlainText(c.dataStream.slice(p, l))
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
return null;
|
|
1060
|
-
}
|
|
1061
|
-
get _editPopup() {
|
|
1062
|
-
return {
|
|
1063
|
-
componentKey: ze.componentKey,
|
|
1064
|
-
direction: "vertical",
|
|
1065
|
-
onClickOutside: () => {
|
|
1066
|
-
this.endEditing();
|
|
1067
|
-
},
|
|
1068
|
-
onContextMenu: () => {
|
|
1069
|
-
this.endEditing();
|
|
1070
|
-
},
|
|
1071
|
-
hiddenType: "hide"
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
startAddEditing(e) {
|
|
1075
|
-
var s, o, c, u, p;
|
|
1076
|
-
const { unitId: n, subUnitId: i, type: r } = e;
|
|
1077
|
-
if (r === m.ZEN_EDITOR) {
|
|
1078
|
-
const l = this._univerInstanceService.getUnit(x, k.UNIVER_DOC);
|
|
1079
|
-
if (!l)
|
|
1080
|
-
return;
|
|
1081
|
-
const g = this._textSelectionManagerService.getActiveTextRange();
|
|
1082
|
-
if (!g)
|
|
1083
|
-
return;
|
|
1084
|
-
this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
|
|
1085
|
-
g,
|
|
1086
|
-
this._editPopup,
|
|
1087
|
-
x
|
|
1088
|
-
);
|
|
1089
|
-
const d = (s = l.getBody()) == null ? void 0 : s.dataStream.slice(g.startOffset, g.endOffset);
|
|
1090
|
-
this._currentEditing$.next({
|
|
1091
|
-
...e,
|
|
1092
|
-
label: d
|
|
1093
|
-
});
|
|
1094
|
-
} else if (r === m.EDITING) {
|
|
1095
|
-
const l = this._getEditingRange();
|
|
1096
|
-
if (!l)
|
|
1097
|
-
return;
|
|
1098
|
-
this._textSelectionManagerService.replaceDocRanges([{ ...l }], { unitId: _e, subUnitId: _e });
|
|
1099
|
-
const g = this._injector.get(He).getRenderById(_e);
|
|
1100
|
-
if (!g)
|
|
1101
|
-
return;
|
|
1102
|
-
const d = Dr(l, g);
|
|
1103
|
-
if (!(d != null && d.length))
|
|
1104
|
-
return;
|
|
1105
|
-
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
|
|
1106
|
-
d.pop(),
|
|
1107
|
-
this._editPopup,
|
|
1108
|
-
n,
|
|
1109
|
-
i
|
|
1110
|
-
), this._currentEditing$.next({
|
|
1111
|
-
...e,
|
|
1112
|
-
label: (o = l == null ? void 0 : l.label) != null ? o : ""
|
|
1113
|
-
});
|
|
1114
|
-
} else {
|
|
1115
|
-
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
|
|
1116
|
-
e.row,
|
|
1117
|
-
e.col,
|
|
1118
|
-
this._editPopup,
|
|
1119
|
-
n,
|
|
1120
|
-
i
|
|
1121
|
-
);
|
|
1122
|
-
const l = this._univerInstanceService.getUnit(n, k.UNIVER_SHEET), g = l == null ? void 0 : l.getSheetBySheetId(i), d = g == null ? void 0 : g.getCellRaw(e.row, e.col);
|
|
1123
|
-
this._currentEditing$.next({
|
|
1124
|
-
...e,
|
|
1125
|
-
label: d != null && d.p ? ve.transform.getPlainText((u = (c = d.p.body) == null ? void 0 : c.dataStream) != null ? u : "") : ((p = d == null ? void 0 : d.v) != null ? p : "").toString()
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
// eslint-disable-next-line complexity, max-lines-per-function
|
|
1130
|
-
startEditing(e) {
|
|
1131
|
-
var o, c, u, p, l, g;
|
|
1132
|
-
(o = this._currentEditingPopup) == null || o.dispose(), this.hideCurrentPopup(void 0, !0);
|
|
1133
|
-
const { unitId: n, subUnitId: i } = e;
|
|
1134
|
-
let r, s;
|
|
1135
|
-
if (e.type === m.ZEN_EDITOR) {
|
|
1136
|
-
const d = this._univerInstanceService.getUnit(x, k.UNIVER_DOC);
|
|
1137
|
-
if (r = (u = (c = d == null ? void 0 : d.getBody()) == null ? void 0 : c.customRanges) == null ? void 0 : u.find((_) => _.rangeId === e.customRangeId), s = r ? (p = d == null ? void 0 : d.getBody()) == null ? void 0 : p.dataStream.slice(r.startIndex, r.endIndex + 1) : "", !r || !s)
|
|
1138
|
-
return;
|
|
1139
|
-
this._textSelectionManagerService.replaceTextRanges([
|
|
1140
|
-
{
|
|
1141
|
-
startOffset: r.startIndex,
|
|
1142
|
-
endOffset: r.endIndex + 1
|
|
1143
|
-
}
|
|
1144
|
-
]), this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
|
|
1145
|
-
{
|
|
1146
|
-
startOffset: r.startIndex,
|
|
1147
|
-
endOffset: r.endIndex,
|
|
1148
|
-
collapsed: !1
|
|
1149
|
-
},
|
|
1150
|
-
this._editPopup,
|
|
1151
|
-
x
|
|
1152
|
-
);
|
|
1153
|
-
} else if (e.type === m.EDITING) {
|
|
1154
|
-
const d = Lr(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
|
|
1155
|
-
if (!d || !((l = d.rects) != null && l.length))
|
|
1156
|
-
return;
|
|
1157
|
-
r = d.customRange, s = d.label, this._textSelectionManagerService.replaceTextRanges([
|
|
1158
|
-
{
|
|
1159
|
-
startOffset: r.startIndex,
|
|
1160
|
-
endOffset: r.endIndex + 1
|
|
1161
|
-
}
|
|
1162
|
-
]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
|
|
1163
|
-
d.rects.pop(),
|
|
1164
|
-
this._editPopup,
|
|
1165
|
-
n,
|
|
1166
|
-
i
|
|
1167
|
-
);
|
|
1168
|
-
} else {
|
|
1169
|
-
const d = this._univerInstanceService.getUnit(n, k.UNIVER_SHEET), _ = d == null ? void 0 : d.getSheetBySheetId(i), I = _ == null ? void 0 : _.getCellRaw(e.row, e.col), f = d == null ? void 0 : d.getStyles().getStyleByCell(I), w = f == null ? void 0 : f.tr, a = wr(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
|
|
1170
|
-
if (!a || !((g = a.rects) != null && g.length))
|
|
1171
|
-
return;
|
|
1172
|
-
r = a.customRange, s = a.label, w ? this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
|
|
1173
|
-
e.row,
|
|
1174
|
-
e.col,
|
|
1175
|
-
this._editPopup,
|
|
1176
|
-
n,
|
|
1177
|
-
i
|
|
1178
|
-
) : this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupByPosition(
|
|
1179
|
-
a.rects.pop(),
|
|
1180
|
-
this._editPopup,
|
|
1181
|
-
{
|
|
1182
|
-
unitId: n,
|
|
1183
|
-
subUnitId: i,
|
|
1184
|
-
row: e.row,
|
|
1185
|
-
col: e.col
|
|
1186
|
-
}
|
|
1187
|
-
);
|
|
1188
|
-
}
|
|
1189
|
-
this._currentEditing$.next({
|
|
1190
|
-
...e,
|
|
1191
|
-
customRange: r,
|
|
1192
|
-
label: s
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
endEditing(e) {
|
|
1196
|
-
var i;
|
|
1197
|
-
if (this.getIsKeepVisible())
|
|
1198
|
-
return;
|
|
1199
|
-
const n = this._currentEditing$.getValue();
|
|
1200
|
-
n && (!e || e === n.type) && ((i = this._currentEditingPopup) == null || i.dispose(), this._currentEditing$.next(null));
|
|
1201
|
-
}
|
|
1202
|
-
};
|
|
1203
|
-
Z = ki([
|
|
1204
|
-
se(0, y(Pr)),
|
|
1205
|
-
se(1, y(ut)),
|
|
1206
|
-
se(2, G),
|
|
1207
|
-
se(3, ee),
|
|
1208
|
-
se(4, y(Ue)),
|
|
1209
|
-
se(5, y(Hr)),
|
|
1210
|
-
se(6, dt)
|
|
1211
|
-
], Z);
|
|
1212
|
-
var Te = /* @__PURE__ */ ((t) => (t[t.ALLOWED = 0] = "ALLOWED", t[t.DISABLED_BY_CELL = 1] = "DISABLED_BY_CELL", t[t.ALLOW_ON_EDITING = 2] = "ALLOW_ON_EDITING", t))(Te || {});
|
|
1213
|
-
const Ti = /* @__PURE__ */ new Set([
|
|
1214
|
-
St.CHECKBOX,
|
|
1215
|
-
St.LIST,
|
|
1216
|
-
St.LIST_MULTIPLE
|
|
1217
|
-
]), At = (t, e, n, i) => {
|
|
1218
|
-
var c, u, p, l, g;
|
|
1219
|
-
const r = e.getCell(n, i);
|
|
1220
|
-
if (r != null && r.f || r != null && r.si || (p = (u = (c = r == null ? void 0 : r.p) == null ? void 0 : c.body) == null ? void 0 : u.customBlocks) != null && p.length)
|
|
1221
|
-
return 1;
|
|
1222
|
-
const s = t.has(gn) ? t.get(gn) : null, o = s == null ? void 0 : s.getRuleByLocation(e.getUnitId(), e.getSheetId(), n, i);
|
|
1223
|
-
return o && Ti.has(o.type) ? !0 : (g = (l = r == null ? void 0 : r.p) == null ? void 0 : l.drawingsOrder) != null && g.length ? 2 : 0;
|
|
1224
|
-
}, Ni = (t) => {
|
|
1225
|
-
const e = t.get(G).getCurrentUnitForType(k.UNIVER_SHEET);
|
|
1226
|
-
if (!e)
|
|
1227
|
-
return !0;
|
|
1228
|
-
const n = e.getActiveSheet(), i = t.get(Tt).getCurrentSelections();
|
|
1229
|
-
if (!i.length)
|
|
1230
|
-
return !0;
|
|
1231
|
-
const r = i[0].range.startRow, s = i[0].range.startColumn;
|
|
1232
|
-
return At(t, n, r, s) === 1;
|
|
1233
|
-
}, xi = (t) => {
|
|
1234
|
-
const e = t.get(Ue), n = t.get(G), i = e.getTextRanges();
|
|
1235
|
-
if (!(i != null && i.length))
|
|
1236
|
-
return !0;
|
|
1237
|
-
const r = n.getCurrentUnitForType(k.UNIVER_DOC);
|
|
1238
|
-
return !!(!r || i.every((o) => o.collapsed) || !r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody());
|
|
1239
|
-
}, Vt = {
|
|
1240
|
-
type: lt.OPERATION,
|
|
1241
|
-
id: "sheet.operation.open-hyper-link-edit-panel",
|
|
1242
|
-
handler(t, e) {
|
|
1243
|
-
if (!e)
|
|
1244
|
-
return !1;
|
|
1245
|
-
const n = t.get(Z);
|
|
1246
|
-
return e.customRangeId ? n.startEditing(e) : n.startAddEditing(e), !0;
|
|
1247
|
-
}
|
|
1248
|
-
}, qe = {
|
|
1249
|
-
type: lt.OPERATION,
|
|
1250
|
-
id: "sheet.operation.close-hyper-link-popup",
|
|
1251
|
-
handler(t) {
|
|
1252
|
-
return t.get(Z).endEditing(), !0;
|
|
1253
|
-
}
|
|
1254
|
-
}, Bt = {
|
|
1255
|
-
type: lt.OPERATION,
|
|
1256
|
-
id: "sheet.operation.insert-hyper-link",
|
|
1257
|
-
handler(t) {
|
|
1258
|
-
var g;
|
|
1259
|
-
const e = t.get(G), n = Nt(e), i = t.get(ee);
|
|
1260
|
-
if (!n)
|
|
1261
|
-
return !1;
|
|
1262
|
-
const r = t.get(te), o = t.get(Tt).getCurrentLastSelection();
|
|
1263
|
-
if (!o)
|
|
1264
|
-
return !1;
|
|
1265
|
-
const c = o.range.startRow, u = o.range.startColumn, p = i.isVisible(), l = ((g = e.getFocusedUnit()) == null ? void 0 : g.getUnitId()) === x;
|
|
1266
|
-
return r.executeCommand(Vt.id, {
|
|
1267
|
-
unitId: n.unitId,
|
|
1268
|
-
subUnitId: n.subUnitId,
|
|
1269
|
-
row: c,
|
|
1270
|
-
col: u,
|
|
1271
|
-
type: l ? m.ZEN_EDITOR : p.visible ? m.EDITING : m.VIEWING
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
}, ae = {
|
|
1275
|
-
type: lt.OPERATION,
|
|
1276
|
-
id: "sheet.operation.insert-hyper-link-toolbar",
|
|
1277
|
-
handler(t) {
|
|
1278
|
-
if (Ni(t))
|
|
1279
|
-
return !1;
|
|
1280
|
-
const e = t.get(te);
|
|
1281
|
-
return t.get(Z).currentEditing ? e.executeCommand(qe.id) : e.executeCommand(Bt.id);
|
|
1282
|
-
}
|
|
1283
|
-
}, Ft = "SHEET_HYPER_LINK_UI_PLUGIN";
|
|
1284
|
-
var Oi = Object.getOwnPropertyDescriptor, Mi = (t, e, n, i) => {
|
|
1285
|
-
for (var r = i > 1 ? void 0 : i ? Oi(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
1286
|
-
(o = t[s]) && (r = o(r) || r);
|
|
1287
|
-
return r;
|
|
1288
|
-
}, Fe = (t, e) => (n, i) => e(n, i, t);
|
|
1289
|
-
let Je = class extends K {
|
|
1290
|
-
constructor(e, n, i, r) {
|
|
1291
|
-
super();
|
|
1292
|
-
A(this, "_plainTextFilter", /* @__PURE__ */ new Set());
|
|
1293
|
-
A(this, "_copyInfo");
|
|
1294
|
-
this._sheetClipboardService = e, this._hyperLinkModel = n, this._injector = i, this._resolverService = r, this._initCopyPaste(), this.disposeWithMe(() => {
|
|
1295
|
-
this._plainTextFilter.clear();
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
|
-
registerPlainTextFilter(e) {
|
|
1299
|
-
this._plainTextFilter.add(e);
|
|
1300
|
-
}
|
|
1301
|
-
removePlainTextFilter(e) {
|
|
1302
|
-
this._plainTextFilter.delete(e);
|
|
1303
|
-
}
|
|
1304
|
-
/* If return false the process of paste text will be stop */
|
|
1305
|
-
_filterPlainText(e) {
|
|
1306
|
-
return Array.from(this._plainTextFilter).every((n) => n(e));
|
|
1307
|
-
}
|
|
1308
|
-
_initCopyPaste() {
|
|
1309
|
-
this._sheetClipboardService.addClipboardHook({
|
|
1310
|
-
id: Ft,
|
|
1311
|
-
onBeforeCopy: (e, n, i) => this._collect(e, n, i),
|
|
1312
|
-
onPasteCells: (e, n, i, r) => {
|
|
1313
|
-
const { copyType: s = kr.COPY, pasteType: o } = r, { range: c } = e || {}, { range: u, unitId: p, subUnitId: l } = n;
|
|
1314
|
-
return this._generateMutations(u, { copyType: s, pasteType: o, copyRange: c, unitId: p, subUnitId: l });
|
|
1315
|
-
},
|
|
1316
|
-
onPastePlainText: (e, n) => {
|
|
1317
|
-
const i = this._filterPlainText(n);
|
|
1318
|
-
if (Ye(n) && i) {
|
|
1319
|
-
const { range: r, unitId: s, subUnitId: o } = e, { ranges: [c], mapFunc: u } = Pt([r]), p = [], l = [];
|
|
1320
|
-
return En.foreach(c, (g, d) => {
|
|
1321
|
-
const { row: _, col: I } = u(g, d), f = this._hyperLinkModel.getHyperLinkByLocation(s, o, _, I);
|
|
1322
|
-
f && p.push({
|
|
1323
|
-
id: Oe.id,
|
|
1324
|
-
params: {
|
|
1325
|
-
unitId: s,
|
|
1326
|
-
subUnitId: o,
|
|
1327
|
-
id: f.id
|
|
1328
|
-
}
|
|
1329
|
-
}), f && l.push({
|
|
1330
|
-
id: Me.id,
|
|
1331
|
-
params: {
|
|
1332
|
-
unitId: s,
|
|
1333
|
-
subUnitId: o,
|
|
1334
|
-
link: f
|
|
1335
|
-
}
|
|
1336
|
-
});
|
|
1337
|
-
}), { redos: p, undos: l };
|
|
1338
|
-
}
|
|
1339
|
-
return { undos: [], redos: [] };
|
|
1340
|
-
},
|
|
1341
|
-
priority: 99
|
|
1342
|
-
});
|
|
1343
|
-
}
|
|
1344
|
-
_collect(e, n, i) {
|
|
1345
|
-
const r = new ir();
|
|
1346
|
-
this._copyInfo = {
|
|
1347
|
-
unitId: e,
|
|
1348
|
-
subUnitId: n,
|
|
1349
|
-
matrix: r
|
|
1350
|
-
};
|
|
1351
|
-
const s = this._injector.invoke((u) => dr(i, u, e, n));
|
|
1352
|
-
if (!s)
|
|
1353
|
-
return;
|
|
1354
|
-
const { rows: o, cols: c } = s;
|
|
1355
|
-
o.forEach((u, p) => {
|
|
1356
|
-
c.forEach((l, g) => {
|
|
1357
|
-
var _;
|
|
1358
|
-
const d = this._hyperLinkModel.getHyperLinkByLocation(e, n, u, l);
|
|
1359
|
-
r.setValue(p, g, (_ = d == null ? void 0 : d.id) != null ? _ : "");
|
|
1360
|
-
});
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1364
|
-
_generateMutations(e, n) {
|
|
1365
|
-
if (!this._copyInfo)
|
|
1366
|
-
return { redos: [], undos: [] };
|
|
1367
|
-
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !n.copyRange)
|
|
1368
|
-
return { redos: [], undos: [] };
|
|
1369
|
-
if ([
|
|
1370
|
-
Ve.SPECIAL_PASTE_COL_WIDTH,
|
|
1371
|
-
Ve.SPECIAL_PASTE_VALUE,
|
|
1372
|
-
Ve.SPECIAL_PASTE_FORMAT,
|
|
1373
|
-
Ve.SPECIAL_PASTE_FORMULA
|
|
1374
|
-
].includes(n.pasteType))
|
|
1375
|
-
return { redos: [], undos: [] };
|
|
1376
|
-
const { unitId: r, subUnitId: s } = this._copyInfo, o = [], c = [], { ranges: [u, p], mapFunc: l } = Pt([n.copyRange, e]);
|
|
1377
|
-
return Tr(u, p, !0).forEach(({ startRange: d }) => {
|
|
1378
|
-
var _;
|
|
1379
|
-
(_ = this._copyInfo) == null || _.matrix.forValue((I, f, w) => {
|
|
1380
|
-
const a = Ie.getPositionRange(
|
|
1381
|
-
{
|
|
1382
|
-
startRow: I,
|
|
1383
|
-
endRow: I,
|
|
1384
|
-
startColumn: f,
|
|
1385
|
-
endColumn: f
|
|
1386
|
-
},
|
|
1387
|
-
d
|
|
1388
|
-
), b = this._hyperLinkModel.getHyperLink(r, s, w), { row: M, col: T } = l(a.startRow, a.startColumn), P = this._hyperLinkModel.getHyperLinkByLocation(n.unitId, n.subUnitId, M, T), D = kt();
|
|
1389
|
-
P && o.push({
|
|
1390
|
-
id: Oe.id,
|
|
1391
|
-
params: {
|
|
1392
|
-
unitId: n.unitId,
|
|
1393
|
-
subUnitId: n.subUnitId,
|
|
1394
|
-
id: P.id
|
|
1395
|
-
}
|
|
1396
|
-
}), b && (o.push({
|
|
1397
|
-
id: Me.id,
|
|
1398
|
-
params: {
|
|
1399
|
-
unitId: n.unitId,
|
|
1400
|
-
subUnitId: n.subUnitId,
|
|
1401
|
-
link: {
|
|
1402
|
-
...b,
|
|
1403
|
-
id: D,
|
|
1404
|
-
row: M,
|
|
1405
|
-
column: T
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
}), c.push({
|
|
1409
|
-
id: Oe.id,
|
|
1410
|
-
params: {
|
|
1411
|
-
unitId: n.unitId,
|
|
1412
|
-
subUnitId: n.subUnitId,
|
|
1413
|
-
id: D
|
|
1414
|
-
}
|
|
1415
|
-
})), P && c.push({
|
|
1416
|
-
id: Me.id,
|
|
1417
|
-
params: {
|
|
1418
|
-
unitId: n.unitId,
|
|
1419
|
-
subUnitId: n.subUnitId,
|
|
1420
|
-
link: P
|
|
1421
|
-
}
|
|
1422
|
-
});
|
|
1423
|
-
});
|
|
1424
|
-
}), { redos: o, undos: c };
|
|
1425
|
-
}
|
|
1426
|
-
};
|
|
1427
|
-
Je = Mi([
|
|
1428
|
-
Fe(0, br),
|
|
1429
|
-
Fe(1, y(ht)),
|
|
1430
|
-
Fe(2, y(ut)),
|
|
1431
|
-
Fe(3, y(ce))
|
|
1432
|
-
], Je);
|
|
1433
|
-
const Wt = (t, e = x) => {
|
|
1434
|
-
var r;
|
|
1435
|
-
const n = t.get(G), i = (r = t.get(He).getRenderById(e)) == null ? void 0 : r.with(kn);
|
|
1436
|
-
return i ? i.textSelectionInner$.pipe(Ht(() => {
|
|
1437
|
-
const o = t.get(ee).getEditCellState();
|
|
1438
|
-
if (!o)
|
|
1439
|
-
return !0;
|
|
1440
|
-
const c = Nt(n, { unitId: o.unitId, subUnitId: o.sheetId });
|
|
1441
|
-
return !(c != null && c.worksheet) || At(t, c.worksheet, o.row, o.column) === 1 ? !0 : xi(t);
|
|
1442
|
-
})) : oe(!0);
|
|
1443
|
-
}, Fn = (t) => {
|
|
1444
|
-
var r;
|
|
1445
|
-
const e = t.get(G), n = t.has(ee) ? t.get(ee) : null;
|
|
1446
|
-
return ((r = n == null ? void 0 : n.currentEditCellState$.pipe(
|
|
1447
|
-
Ht((s) => {
|
|
1448
|
-
if (!s)
|
|
1449
|
-
return Te.DISABLED_BY_CELL;
|
|
1450
|
-
const o = Nt(e, { unitId: s.unitId, subUnitId: s.sheetId });
|
|
1451
|
-
return o ? At(t, o.worksheet, s.row, s.column) : Te.DISABLED_BY_CELL;
|
|
1452
|
-
}),
|
|
1453
|
-
xe((s) => {
|
|
1454
|
-
if (s === Te.DISABLED_BY_CELL)
|
|
1455
|
-
return oe(!0);
|
|
1456
|
-
const o = n ? n.visible$ : oe(null);
|
|
1457
|
-
return Xr([o, e.getCurrentTypeOfUnit$(k.UNIVER_DOC)]).pipe(
|
|
1458
|
-
xe(
|
|
1459
|
-
([c, u]) => c != null && c.visible ? (u == null ? void 0 : u.getUnitId()) === sr ? oe(!0) : Wt(t, _e) : oe(s !== Te.ALLOWED)
|
|
1460
|
-
)
|
|
1461
|
-
);
|
|
1462
|
-
})
|
|
1463
|
-
)) != null ? r : oe(!0)).pipe(
|
|
1464
|
-
xe((s) => s ? oe(!0) : xr(t, { workbookTypes: [Ut], worksheetTypes: [Ot, Ln, Mt], rangeTypes: [xt] }, !0))
|
|
1465
|
-
);
|
|
1466
|
-
}, Qe = {
|
|
1467
|
-
commandId: Bt.id,
|
|
1468
|
-
type: Nn.BUTTON,
|
|
1469
|
-
title: "hyperLink.menu.add",
|
|
1470
|
-
icon: "LinkIcon"
|
|
1471
|
-
}, et = (t) => `${t}-zen-editor`, Ui = (t) => ({
|
|
1472
|
-
...Qe,
|
|
1473
|
-
id: Qe.commandId,
|
|
1474
|
-
hidden$: pt(t, k.UNIVER_SHEET),
|
|
1475
|
-
disabled$: Fn(t)
|
|
1476
|
-
// disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
|
|
1477
|
-
}), Hi = (t) => ({
|
|
1478
|
-
...Qe,
|
|
1479
|
-
id: et(Qe.commandId),
|
|
1480
|
-
hidden$: pt(t, k.UNIVER_DOC, x),
|
|
1481
|
-
disabled$: Wt(t)
|
|
1482
|
-
}), tt = {
|
|
1483
|
-
tooltip: "hyperLink.form.addTitle",
|
|
1484
|
-
commandId: ae.id,
|
|
1485
|
-
type: Nn.BUTTON,
|
|
1486
|
-
icon: "LinkIcon"
|
|
1487
|
-
}, Di = (t) => ({
|
|
1488
|
-
...tt,
|
|
1489
|
-
id: tt.commandId,
|
|
1490
|
-
hidden$: pt(t, k.UNIVER_SHEET),
|
|
1491
|
-
disabled$: Fn(t)
|
|
1492
|
-
}), $i = (t) => ({
|
|
1493
|
-
...tt,
|
|
1494
|
-
id: et(tt.commandId),
|
|
1495
|
-
hidden$: pt(t, k.UNIVER_DOC, x),
|
|
1496
|
-
disabled$: Wt(t)
|
|
1497
|
-
}), Wn = {
|
|
1498
|
-
id: ae.id,
|
|
1499
|
-
binding: Lt.K | Br.CTRL_COMMAND,
|
|
1500
|
-
preconditions: Nr
|
|
1501
|
-
}, Ai = "@univerjs/sheets-hyper-link-ui", Vi = "0.17.0", jn = {
|
|
1502
|
-
name: Ai,
|
|
1503
|
-
version: Vi
|
|
1504
|
-
};
|
|
1505
|
-
var Bi = Object.getOwnPropertyDescriptor, Fi = (t, e, n, i) => {
|
|
1506
|
-
for (var r = i > 1 ? void 0 : i ? Bi(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
1507
|
-
(o = t[s]) && (r = o(r) || r);
|
|
1508
|
-
return r;
|
|
1509
|
-
}, _n = (t, e) => (n, i) => e(n, i, t);
|
|
1510
|
-
let nt = class extends K {
|
|
1511
|
-
constructor(t, e) {
|
|
1512
|
-
super(), this._autoFillService = t, this._hyperLinkModel = e, this._initAutoFill();
|
|
1513
|
-
}
|
|
1514
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1515
|
-
_initAutoFill() {
|
|
1516
|
-
const t = () => ({ redos: [], undos: [] }), e = (i, r) => {
|
|
1517
|
-
const { source: s, target: o, unitId: c, subUnitId: u } = i, p = Pt([s, o]), [l, g] = p.ranges, { mapFunc: d } = p, _ = {
|
|
1518
|
-
row: l.startRow,
|
|
1519
|
-
col: l.startColumn
|
|
1520
|
-
}, I = hr.getAutoFillRepeatRange(l, g), f = [], w = [];
|
|
1521
|
-
return I.forEach((a) => {
|
|
1522
|
-
const b = a.repeatStartCell, M = a.relativeRange, T = {
|
|
1523
|
-
startRow: _.row,
|
|
1524
|
-
startColumn: _.col,
|
|
1525
|
-
endColumn: _.col,
|
|
1526
|
-
endRow: _.row
|
|
1527
|
-
}, P = {
|
|
1528
|
-
startRow: b.row,
|
|
1529
|
-
startColumn: b.col,
|
|
1530
|
-
endColumn: b.col,
|
|
1531
|
-
endRow: b.row
|
|
1532
|
-
};
|
|
1533
|
-
En.foreach(M, (D, $) => {
|
|
1534
|
-
const Y = Ie.getPositionRange(
|
|
1535
|
-
{
|
|
1536
|
-
startRow: D,
|
|
1537
|
-
startColumn: $,
|
|
1538
|
-
endColumn: $,
|
|
1539
|
-
endRow: D
|
|
1540
|
-
},
|
|
1541
|
-
T
|
|
1542
|
-
), { row: ne, col: De } = d(Y.startRow, Y.startColumn), re = this._hyperLinkModel.getHyperLinkByLocation(c, u, ne, De), ye = Ie.getPositionRange(
|
|
1543
|
-
{
|
|
1544
|
-
startRow: D,
|
|
1545
|
-
startColumn: $,
|
|
1546
|
-
endColumn: $,
|
|
1547
|
-
endRow: D
|
|
1548
|
-
},
|
|
1549
|
-
P
|
|
1550
|
-
), { row: Ee, col: Re } = d(ye.startRow, ye.startColumn), $e = kt(), de = this._hyperLinkModel.getHyperLinkByLocation(c, u, Ee, Re);
|
|
1551
|
-
de && f.push({
|
|
1552
|
-
id: Oe.id,
|
|
1553
|
-
params: {
|
|
1554
|
-
unitId: c,
|
|
1555
|
-
subUnitId: u,
|
|
1556
|
-
id: de.id
|
|
1557
|
-
}
|
|
1558
|
-
}), (we.COPY === r || we.SERIES === r) && re && (f.push({
|
|
1559
|
-
id: Me.id,
|
|
1560
|
-
params: {
|
|
1561
|
-
unitId: c,
|
|
1562
|
-
subUnitId: u,
|
|
1563
|
-
link: {
|
|
1564
|
-
...re,
|
|
1565
|
-
id: $e,
|
|
1566
|
-
row: Ee,
|
|
1567
|
-
column: Re
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
}), w.push({
|
|
1571
|
-
id: Oe.id,
|
|
1572
|
-
params: {
|
|
1573
|
-
unitId: c,
|
|
1574
|
-
subUnitId: u,
|
|
1575
|
-
id: $e
|
|
1576
|
-
}
|
|
1577
|
-
})), de && w.push({
|
|
1578
|
-
id: Me.id,
|
|
1579
|
-
params: {
|
|
1580
|
-
unitId: c,
|
|
1581
|
-
subUnitId: u,
|
|
1582
|
-
link: de
|
|
1583
|
-
}
|
|
1584
|
-
});
|
|
1585
|
-
});
|
|
1586
|
-
}), {
|
|
1587
|
-
undos: w,
|
|
1588
|
-
redos: f
|
|
1589
|
-
};
|
|
1590
|
-
}, n = {
|
|
1591
|
-
id: Ft,
|
|
1592
|
-
onFillData: (i, r, s) => s === we.COPY || s === we.ONLY_FORMAT || s === we.SERIES ? e(i, s) : t()
|
|
1593
|
-
};
|
|
1594
|
-
this.disposeWithMe(this._autoFillService.addHook(n));
|
|
1595
|
-
}
|
|
1596
|
-
};
|
|
1597
|
-
nt = Fi([
|
|
1598
|
-
_n(0, pr),
|
|
1599
|
-
_n(1, y(ht))
|
|
1600
|
-
], nt);
|
|
1601
|
-
var Wi = Object.getOwnPropertyDescriptor, ji = (t, e, n, i) => {
|
|
1602
|
-
for (var r = i > 1 ? void 0 : i ? Wi(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
1603
|
-
(o = t[s]) && (r = o(r) || r);
|
|
1604
|
-
return r;
|
|
1605
|
-
}, Rt = (t, e) => (n, i) => e(n, i, t);
|
|
1606
|
-
let rt = class extends K {
|
|
1607
|
-
constructor(t, e, n) {
|
|
1608
|
-
super(), this._localeService = t, this._commandService = e, this._sheetPermissionCheckController = n, this._commandExecutedListener();
|
|
1609
|
-
}
|
|
1610
|
-
_commandExecutedListener() {
|
|
1611
|
-
this.disposeWithMe(
|
|
1612
|
-
this._commandService.beforeCommandExecuted((t) => {
|
|
1613
|
-
t.id === Wn.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
1614
|
-
workbookTypes: [Ut],
|
|
1615
|
-
rangeTypes: [xt],
|
|
1616
|
-
worksheetTypes: [Ot, Ln, Mt]
|
|
1617
|
-
}) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")));
|
|
1618
|
-
})
|
|
1619
|
-
);
|
|
1620
|
-
}
|
|
1621
|
-
};
|
|
1622
|
-
rt = ji([
|
|
1623
|
-
Rt(0, y(ct)),
|
|
1624
|
-
Rt(1, te),
|
|
1625
|
-
Rt(2, y(wn))
|
|
1626
|
-
], rt);
|
|
1627
|
-
var Zi = Object.getOwnPropertyDescriptor, Gi = (t, e, n, i) => {
|
|
1628
|
-
for (var r = i > 1 ? void 0 : i ? Zi(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
1629
|
-
(o = t[s]) && (r = o(r) || r);
|
|
1630
|
-
return r;
|
|
1631
|
-
}, W = (t, e) => (n, i) => e(n, i, t);
|
|
1632
|
-
let it = class extends K {
|
|
1633
|
-
constructor(t, e, n, i, r, s, o, c, u, p) {
|
|
1634
|
-
super(), this._hoverManagerService = t, this._sheetsHyperLinkPopupService = e, this._renderManagerService = n, this._permissionService = i, this._sheetPermissionCheckController = r, this._commandService = s, this._editorBridgeService = o, this._textSelectionManagerService = c, this._univerInstanceService = u, this._zenZoneService = p, this._initHoverListener(), this._initCommandListener(), this._initHoverEditingListener(), this._initTextSelectionListener(), this._initZenEditor();
|
|
1635
|
-
}
|
|
1636
|
-
_getLinkPermission(t) {
|
|
1637
|
-
const { unitId: e, subUnitId: n, row: i, col: r } = t, s = this._univerInstanceService.getUnit(e, k.UNIVER_SHEET), o = s == null ? void 0 : s.getSheetBySheetId(n);
|
|
1638
|
-
if (!o)
|
|
1639
|
-
return {
|
|
1640
|
-
viewPermission: !1,
|
|
1641
|
-
editPermission: !1,
|
|
1642
|
-
copyPermission: !1
|
|
1643
|
-
};
|
|
1644
|
-
const c = this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
1645
|
-
workbookTypes: [vr],
|
|
1646
|
-
worksheetTypes: [mr],
|
|
1647
|
-
rangeTypes: [gr]
|
|
1648
|
-
}, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }], e, n);
|
|
1649
|
-
let u = this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
1650
|
-
workbookTypes: [Ut],
|
|
1651
|
-
worksheetTypes: [Ot, Mt],
|
|
1652
|
-
rangeTypes: [xt]
|
|
1653
|
-
}, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }], e, n);
|
|
1654
|
-
const p = o.getCellRaw(i, r);
|
|
1655
|
-
p != null && p.f && p.f.startsWith("=HYPERLINK(") && (u = !1);
|
|
1656
|
-
const l = this._permissionService.composePermission([new fr(e).id, new _r(e, n).id]).every((g) => g.value);
|
|
1657
|
-
return {
|
|
1658
|
-
viewPermission: c,
|
|
1659
|
-
editPermission: u,
|
|
1660
|
-
copyPermission: l
|
|
1661
|
-
};
|
|
1662
|
-
}
|
|
1663
|
-
_initHoverListener() {
|
|
1664
|
-
this.disposeWithMe(
|
|
1665
|
-
// hover over not editing cell
|
|
1666
|
-
this._hoverManagerService.currentRichText$.pipe(je(200)).subscribe((t) => {
|
|
1667
|
-
var T, P, D;
|
|
1668
|
-
if (!t || ((T = t.customRange) == null ? void 0 : T.rangeType) !== Ne.HYPERLINK) {
|
|
1669
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1670
|
-
return;
|
|
1671
|
-
}
|
|
1672
|
-
const { unitId: e, subUnitId: n, row: i, col: r } = t, s = this._renderManagerService.getRenderById(e);
|
|
1673
|
-
if (!s)
|
|
1674
|
-
return;
|
|
1675
|
-
const o = this._univerInstanceService.getUnit(e, k.UNIVER_SHEET), c = o == null ? void 0 : o.getSheetBySheetId(n);
|
|
1676
|
-
if (!c)
|
|
1677
|
-
return;
|
|
1678
|
-
if (!s.with(Mr).active) {
|
|
1679
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING);
|
|
1680
|
-
return;
|
|
1681
|
-
}
|
|
1682
|
-
const p = (P = s == null ? void 0 : s.with(ln).getSkeletonParam(n)) == null ? void 0 : P.skeleton, l = r, g = i;
|
|
1683
|
-
let d = g, _ = l;
|
|
1684
|
-
p && p.overflowCache.forValue(($, Y, ne) => {
|
|
1685
|
-
Ie.contains(ne, { startColumn: l, endColumn: l, startRow: g, endRow: g }) && (d = $, _ = Y);
|
|
1686
|
-
});
|
|
1687
|
-
const { viewPermission: I, editPermission: f, copyPermission: w } = this._getLinkPermission(t);
|
|
1688
|
-
if (!I) {
|
|
1689
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1690
|
-
return;
|
|
1691
|
-
}
|
|
1692
|
-
const a = c.getCellStyleOnly(d, _), b = o.getStyles().getStyleByCell(a), M = (D = b == null ? void 0 : b.tr) == null ? void 0 : D.a;
|
|
1693
|
-
if (!M && !t.customRange) {
|
|
1694
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1695
|
-
return;
|
|
1696
|
-
}
|
|
1697
|
-
this._sheetsHyperLinkPopupService.showPopup({
|
|
1698
|
-
row: d,
|
|
1699
|
-
col: _,
|
|
1700
|
-
editPermission: f,
|
|
1701
|
-
copyPermission: w,
|
|
1702
|
-
customRange: t.customRange,
|
|
1703
|
-
customRangeRect: t.rect,
|
|
1704
|
-
type: m.VIEWING,
|
|
1705
|
-
unitId: e,
|
|
1706
|
-
subUnitId: n,
|
|
1707
|
-
showAll: !!M
|
|
1708
|
-
});
|
|
1709
|
-
})
|
|
1710
|
-
);
|
|
1711
|
-
}
|
|
1712
|
-
_initHoverEditingListener() {
|
|
1713
|
-
let t = null;
|
|
1714
|
-
this.disposeWithMe(
|
|
1715
|
-
this._editorBridgeService.currentEditCellState$.pipe(xe((e) => this._editorBridgeService.visible$.pipe(Ht((n) => ({ visible: n, state: e }))))).subscribe(({ visible: e, state: n }) => {
|
|
1716
|
-
if (!n || n.editorUnitId !== _e)
|
|
1717
|
-
return;
|
|
1718
|
-
if (!e.visible) {
|
|
1719
|
-
t == null || t.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.EDITING), this._sheetsHyperLinkPopupService.endEditing(m.EDITING);
|
|
1720
|
-
return;
|
|
1721
|
-
}
|
|
1722
|
-
const { editorUnitId: i, unitId: r, sheetId: s, row: o, column: c } = n, u = this._renderManagerService.getRenderById(i);
|
|
1723
|
-
if (!u)
|
|
1724
|
-
return;
|
|
1725
|
-
const { editPermission: p, viewPermission: l, copyPermission: g } = this._getLinkPermission({ unitId: r, subUnitId: s, row: o, col: c }), d = u.with(dn);
|
|
1726
|
-
l && (t == null || t.unsubscribe(), t = d.hoverCustomRanges$.pipe(je(200)).subscribe((_) => {
|
|
1727
|
-
var b, M;
|
|
1728
|
-
const I = _.find((T) => T.range.rangeType === Ne.HYPERLINK);
|
|
1729
|
-
if (!I) {
|
|
1730
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1731
|
-
return;
|
|
1732
|
-
}
|
|
1733
|
-
const f = I.rects[I.rects.length - 1];
|
|
1734
|
-
if (!((M = (b = this._renderManagerService.getRenderById(r)) == null ? void 0 : b.with(ln).getSkeletonParam(s)) == null ? void 0 : M.skeleton) || !f)
|
|
1735
|
-
return;
|
|
1736
|
-
const a = u.engine.getCanvasElement().getBoundingClientRect();
|
|
1737
|
-
this._sheetsHyperLinkPopupService.showPopup({
|
|
1738
|
-
unitId: r,
|
|
1739
|
-
subUnitId: s,
|
|
1740
|
-
row: o,
|
|
1741
|
-
col: c,
|
|
1742
|
-
customRange: I.range,
|
|
1743
|
-
customRangeRect: {
|
|
1744
|
-
left: f.left + a.left,
|
|
1745
|
-
top: f.top + a.top,
|
|
1746
|
-
bottom: f.bottom + a.top,
|
|
1747
|
-
right: f.right + a.left
|
|
1748
|
-
},
|
|
1749
|
-
editPermission: p,
|
|
1750
|
-
copyPermission: g,
|
|
1751
|
-
type: m.EDITING
|
|
1752
|
-
});
|
|
1753
|
-
}));
|
|
1754
|
-
})
|
|
1755
|
-
), this.disposeWithMe(() => {
|
|
1756
|
-
t == null || t.unsubscribe();
|
|
1757
|
-
});
|
|
1758
|
-
}
|
|
1759
|
-
_initZenEditor() {
|
|
1760
|
-
this.disposeWithMe(
|
|
1761
|
-
this._zenZoneService.visible$.subscribe((t) => {
|
|
1762
|
-
t ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.EDITING), this._sheetsHyperLinkPopupService.endEditing(m.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(m.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(m.ZEN_EDITOR));
|
|
1763
|
-
})
|
|
1764
|
-
), this.disposeWithMe(
|
|
1765
|
-
this._univerInstanceService.focused$.pipe(
|
|
1766
|
-
xe((t) => {
|
|
1767
|
-
const e = t === x ? this._renderManagerService.getRenderById(t) : null;
|
|
1768
|
-
return e ? e.with(dn).hoverCustomRanges$.pipe(je(200)) : new qr((n) => {
|
|
1769
|
-
n.next(null);
|
|
1770
|
-
});
|
|
1771
|
-
})
|
|
1772
|
-
).subscribe((t) => {
|
|
1773
|
-
const e = t == null ? void 0 : t.find((i) => i.range.rangeType === Ne.HYPERLINK), n = this._editorBridgeService.getEditCellState();
|
|
1774
|
-
if (e && n) {
|
|
1775
|
-
const { unitId: i, sheetId: r, row: s, column: o } = n, { editPermission: c, viewPermission: u, copyPermission: p } = this._getLinkPermission({ unitId: i, subUnitId: r, row: s, col: o });
|
|
1776
|
-
u && this._sheetsHyperLinkPopupService.showPopup({
|
|
1777
|
-
type: m.ZEN_EDITOR,
|
|
1778
|
-
unitId: i,
|
|
1779
|
-
subUnitId: r,
|
|
1780
|
-
row: s,
|
|
1781
|
-
col: o,
|
|
1782
|
-
customRange: e.range,
|
|
1783
|
-
editPermission: c,
|
|
1784
|
-
copyPermission: p
|
|
1785
|
-
});
|
|
1786
|
-
} else
|
|
1787
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup(m.ZEN_EDITOR);
|
|
1788
|
-
})
|
|
1789
|
-
);
|
|
1790
|
-
}
|
|
1791
|
-
_initTextSelectionListener() {
|
|
1792
|
-
this.disposeWithMe(
|
|
1793
|
-
this._textSelectionManagerService.textSelection$.subscribe((t) => {
|
|
1794
|
-
t && t.unitId === _e && this._sheetsHyperLinkPopupService.endEditing(m.EDITING);
|
|
1795
|
-
})
|
|
1796
|
-
);
|
|
1797
|
-
}
|
|
1798
|
-
_initCommandListener() {
|
|
1799
|
-
const t = [Ir.id, Cr.id, Sr.id];
|
|
1800
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
|
|
1801
|
-
t.includes(e.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1802
|
-
}));
|
|
1803
|
-
}
|
|
1804
|
-
};
|
|
1805
|
-
it = Gi([
|
|
1806
|
-
W(0, y(Or)),
|
|
1807
|
-
W(1, y(Z)),
|
|
1808
|
-
W(2, y(He)),
|
|
1809
|
-
W(3, y(or)),
|
|
1810
|
-
W(4, y(wn)),
|
|
1811
|
-
W(5, te),
|
|
1812
|
-
W(6, ee),
|
|
1813
|
-
W(7, y(Ue)),
|
|
1814
|
-
W(8, G),
|
|
1815
|
-
W(9, dt)
|
|
1816
|
-
], it);
|
|
1817
|
-
var Ki = Object.getOwnPropertyDescriptor, Zn = (t, e, n, i) => {
|
|
1818
|
-
for (var r = i > 1 ? void 0 : i ? Ki(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
1819
|
-
(o = t[s]) && (r = o(r) || r);
|
|
1820
|
-
return r;
|
|
1821
|
-
}, wt = (t, e) => (n, i) => e(n, i, t);
|
|
1822
|
-
let bt = class extends K {
|
|
1823
|
-
constructor(t, e) {
|
|
1824
|
-
super(), this._context = t, this._hyperLinkModel = e, this._initSkeletonChange();
|
|
1825
|
-
}
|
|
1826
|
-
_initSkeletonChange() {
|
|
1827
|
-
const t = () => {
|
|
1828
|
-
var e;
|
|
1829
|
-
(e = this._context.mainComponent) == null || e.makeForceDirty();
|
|
1830
|
-
};
|
|
1831
|
-
this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(je(16)).subscribe(() => {
|
|
1832
|
-
t();
|
|
1833
|
-
}));
|
|
1834
|
-
}
|
|
1835
|
-
};
|
|
1836
|
-
bt = Zn([
|
|
1837
|
-
wt(1, y(ht))
|
|
1838
|
-
], bt);
|
|
1839
|
-
let st = class extends K {
|
|
1840
|
-
constructor(t, e) {
|
|
1841
|
-
super(), this._sheetInterceptorService = t, this._hyperLinkModel = e, this._initViewModelIntercept();
|
|
1842
|
-
}
|
|
1843
|
-
_initViewModelIntercept() {
|
|
1844
|
-
this.disposeWithMe(
|
|
1845
|
-
this._sheetInterceptorService.intercept(
|
|
1846
|
-
Er.CELL_CONTENT,
|
|
1847
|
-
{
|
|
1848
|
-
effect: ar.Value,
|
|
1849
|
-
priority: 100,
|
|
1850
|
-
handler: (t, e, n) => {
|
|
1851
|
-
const { row: i, col: r, unitId: s, subUnitId: o } = e, c = this._hyperLinkModel.getHyperLinkByLocation(s, o, i, r);
|
|
1852
|
-
return c && t && (t === e.rawData && (t = { ...e.rawData }), t.linkUrl = c.payload, t.linkId = c.id), n(t);
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
)
|
|
1856
|
-
);
|
|
1857
|
-
}
|
|
1858
|
-
};
|
|
1859
|
-
st = Zn([
|
|
1860
|
-
wt(0, y(yr)),
|
|
1861
|
-
wt(1, y(ht))
|
|
1862
|
-
], st);
|
|
1863
|
-
const Yi = {
|
|
1864
|
-
[jr.MEDIA]: {
|
|
1865
|
-
[ae.id]: {
|
|
1866
|
-
order: 1,
|
|
1867
|
-
menuItemFactory: Di
|
|
1868
|
-
},
|
|
1869
|
-
[et(ae.id)]: {
|
|
1870
|
-
order: 1,
|
|
1871
|
-
menuItemFactory: $i
|
|
1872
|
-
}
|
|
1873
|
-
},
|
|
1874
|
-
[Fr.MAIN_AREA]: {
|
|
1875
|
-
[Wr.OTHERS]: {
|
|
1876
|
-
order: 1,
|
|
1877
|
-
[ae.id]: {
|
|
1878
|
-
order: 0,
|
|
1879
|
-
menuItemFactory: Ui
|
|
1880
|
-
},
|
|
1881
|
-
[et(ae.id)]: {
|
|
1882
|
-
order: 0,
|
|
1883
|
-
menuItemFactory: Hi
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
};
|
|
1888
|
-
var zi = Object.getOwnPropertyDescriptor, Xi = (t, e, n, i) => {
|
|
1889
|
-
for (var r = i > 1 ? void 0 : i ? zi(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
1890
|
-
(o = t[s]) && (r = o(r) || r);
|
|
1891
|
-
return r;
|
|
1892
|
-
}, be = (t, e) => (n, i) => e(n, i, t);
|
|
1893
|
-
let ot = class extends K {
|
|
1894
|
-
constructor(t, e, n, i, r) {
|
|
1895
|
-
super(), this._componentManager = t, this._commandService = e, this._menuManagerService = n, this._injector = i, this._shortcutService = r, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
|
|
1896
|
-
}
|
|
1897
|
-
_initComponents() {
|
|
1898
|
-
[
|
|
1899
|
-
[Xe.componentKey, Xe],
|
|
1900
|
-
[ze.componentKey, ze],
|
|
1901
|
-
["LinkIcon", $t]
|
|
1902
|
-
].forEach(([t, e]) => {
|
|
1903
|
-
this._componentManager.register(t, e);
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
_initCommands() {
|
|
1907
|
-
[
|
|
1908
|
-
Vt,
|
|
1909
|
-
qe,
|
|
1910
|
-
Bt,
|
|
1911
|
-
ae
|
|
1912
|
-
].forEach((t) => {
|
|
1913
|
-
this._commandService.registerCommand(t);
|
|
1914
|
-
});
|
|
1915
|
-
}
|
|
1916
|
-
_initMenus() {
|
|
1917
|
-
this._menuManagerService.mergeMenu(Yi);
|
|
1918
|
-
}
|
|
1919
|
-
_initShortCut() {
|
|
1920
|
-
this._shortcutService.registerShortcut(Wn);
|
|
1921
|
-
}
|
|
1922
|
-
};
|
|
1923
|
-
ot = Xi([
|
|
1924
|
-
be(0, y(Zr)),
|
|
1925
|
-
be(1, te),
|
|
1926
|
-
be(2, Gr),
|
|
1927
|
-
be(3, y(ut)),
|
|
1928
|
-
be(4, y(Kr))
|
|
1929
|
-
], ot);
|
|
1930
|
-
var qi = Object.getOwnPropertyDescriptor, Ji = (t, e, n, i) => {
|
|
1931
|
-
for (var r = i > 1 ? void 0 : i ? qi(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
1932
|
-
(o = t[s]) && (r = o(r) || r);
|
|
1933
|
-
return r;
|
|
1934
|
-
}, In = (t, e) => (n, i) => e(n, i, t);
|
|
1935
|
-
let at = class extends K {
|
|
1936
|
-
constructor(t, e) {
|
|
1937
|
-
super(), this._parserService = t, this._resolverService = e, this._handleInitUrl();
|
|
1938
|
-
}
|
|
1939
|
-
_handleInitUrl() {
|
|
1940
|
-
const t = location.hash;
|
|
1941
|
-
if (t) {
|
|
1942
|
-
const e = this._parserService.parseHyperLink(t);
|
|
1943
|
-
this._resolverService.navigate(e);
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
};
|
|
1947
|
-
at = Ji([
|
|
1948
|
-
In(0, y(Dt)),
|
|
1949
|
-
In(1, y(ce))
|
|
1950
|
-
], at);
|
|
1951
|
-
var Qi = Object.defineProperty, es = Object.getOwnPropertyDescriptor, ts = (t, e, n) => e in t ? Qi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, ns = (t, e, n, i) => {
|
|
1952
|
-
for (var r = i > 1 ? void 0 : i ? es(e, n) : e, s = t.length - 1, o; s >= 0; s--)
|
|
1953
|
-
(o = t[s]) && (r = o(r) || r);
|
|
1954
|
-
return r;
|
|
1955
|
-
}, Cn = (t, e) => (n, i) => e(n, i, t), gt = (t, e, n) => ts(t, typeof e != "symbol" ? e + "" : e, n);
|
|
1956
|
-
let Ce = class extends ur {
|
|
1957
|
-
constructor(t = mn, e, n) {
|
|
1958
|
-
super(), this._config = t, this._injector = e, this._configService = n;
|
|
1959
|
-
const { menu: i, ...r } = lr(
|
|
1960
|
-
{},
|
|
1961
|
-
mn,
|
|
1962
|
-
this._config
|
|
1963
|
-
);
|
|
1964
|
-
i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(Un, r);
|
|
1965
|
-
}
|
|
1966
|
-
onStarting() {
|
|
1967
|
-
[
|
|
1968
|
-
[ce],
|
|
1969
|
-
[Z],
|
|
1970
|
-
[Hn],
|
|
1971
|
-
[st],
|
|
1972
|
-
[it],
|
|
1973
|
-
[ot],
|
|
1974
|
-
[nt],
|
|
1975
|
-
[Je],
|
|
1976
|
-
[rt],
|
|
1977
|
-
[at]
|
|
1978
|
-
].forEach((e) => this._injector.add(e)), this._injector.get(st);
|
|
1979
|
-
}
|
|
1980
|
-
onReady() {
|
|
1981
|
-
this._injector.get(He).registerRenderModule(k.UNIVER_SHEET, [bt]), this._injector.get(nt), this._injector.get(Je), this._injector.get(ot);
|
|
1982
|
-
}
|
|
1983
|
-
onRendered() {
|
|
1984
|
-
this._injector.get(rt), this._injector.get(at), this._injector.get(it);
|
|
1985
|
-
}
|
|
1986
|
-
};
|
|
1987
|
-
gt(Ce, "pluginName", Ft);
|
|
1988
|
-
gt(Ce, "packageName", jn.name);
|
|
1989
|
-
gt(Ce, "version", jn.version);
|
|
1990
|
-
gt(Ce, "type", k.UNIVER_SHEET);
|
|
1991
|
-
Ce = ns([
|
|
1992
|
-
cr(li, $r),
|
|
1993
|
-
Cn(1, y(ut)),
|
|
1994
|
-
Cn(2, Sn)
|
|
1995
|
-
], Ce);
|
|
1996
|
-
export {
|
|
1997
|
-
qe as CloseHyperLinkPopupOperation,
|
|
1998
|
-
Bt as InsertHyperLinkOperation,
|
|
1999
|
-
Wn as InsertLinkShortcut,
|
|
2000
|
-
Vt as OpenHyperLinkEditPanelOperation,
|
|
2001
|
-
Je as SheetsHyperLinkCopyPasteController,
|
|
2002
|
-
Z as SheetsHyperLinkPopupService,
|
|
2003
|
-
ce as SheetsHyperLinkResolverService,
|
|
2004
|
-
Hn as SheetsHyperLinkSidePanelService,
|
|
2005
|
-
Ce as UniverSheetsHyperLinkUIPlugin
|
|
2006
|
-
};
|
|
1
|
+
import{BuildTextUtils as e,ColorKit as t,CommandType as n,CustomRangeType as r,DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as i,DOCS_NORMAL_EDITOR_UNIT_ID_KEY as a,DOCS_ZEN_EDITOR_UNIT_ID_KEY as o,DataStreamTreeTokenType as s,DataValidationType as c,DependentOn as l,Disposable as u,DisposableCollection as d,FOCUSING_SHEET as f,ICommandService as p,IConfigService as m,IContextService as h,IPermissionService as g,IUniverInstanceService as _,Inject as v,Injector as y,InterceptorEffectEnum as b,LocaleService as x,ObjectMatrix as S,Plugin as C,RANGE_TYPE as w,Range as T,Rectangle as E,ThemeService as D,Tools as ee,UniverInstanceType as O,generateRandomId as te,isValidRange as ne,merge as k}from"@univerjs/core";import{AUTO_FILL_APPLY_TYPE as A,AutoFillTools as j,ClearSelectionAllCommand as re,ClearSelectionContentCommand as ie,ClearSelectionFormatCommand as M,IAutoFillService as N,INTERCEPTOR_POINT as ae,RangeProtectionPermissionEditPoint as P,RangeProtectionPermissionViewPoint as oe,SetSelectionsOperation as se,SetWorksheetActiveOperation as ce,SheetInterceptorService as le,SheetPermissionCheckController as ue,SheetsSelectionsService as de,WorkbookCopyPermission as fe,WorkbookEditablePermission as pe,WorkbookViewPermission as me,WorksheetCopyPermission as he,WorksheetEditPermission as ge,WorksheetInsertHyperlinkPermission as _e,WorksheetSetCellValuePermission as ve,WorksheetViewPermission as ye,getSheetCommandTarget as F,rangeToDiscreteRange as be}from"@univerjs/sheets";import{COPY_TYPE as xe,HoverManagerService as Se,HoverRenderController as I,IEditorBridgeService as L,IMarkSelectionService as Ce,ISheetClipboardService as R,PREDEFINED_HOOK_NAME_PASTE as we,ScrollToRangeOperation as Te,SheetCanvasPopManagerService as z,SheetSkeletonManagerService as Ee,getCurrentRangeDisable$ as De,getCustomRangePosition as Oe,getEditingCustomRangePosition as ke,getRepeatRange as Ae,virtualizeDiscreteRanges as je,whenSheetEditorFocused as Me}from"@univerjs/sheets-ui";import{DocSelectionManagerService as Ne}from"@univerjs/docs";import{DocBackScrollRenderController as Pe,DocCanvasPopManagerService as Fe,DocEventManagerService as Ie,DocSelectionRenderService as Le,UniverDocsUIPlugin as Re,calcDocRangePositions as ze}from"@univerjs/docs-ui";import{IRenderManagerService as Be}from"@univerjs/engine-render";import{ComponentManager as Ve,ContextMenuGroup as He,ContextMenuPosition as Ue,IMenuManagerService as We,IMessageService as Ge,IShortcutService as Ke,IZenZoneService as qe,KeyCode as Je,MenuItemType as Ye,MetaKeys as Xe,RibbonInsertGroup as Ze,getMenuHiddenObservable as Qe,useDependency as B,useEvent as $e,useObservable as et}from"@univerjs/ui";import{BehaviorSubject as tt,Observable as nt,Subject as rt,combineLatest as it,debounceTime as at,map as ot,of as V,switchMap as st}from"rxjs";import{Button as ct,FormLayout as lt,Input as ut,MessageType as dt,Select as ft,Tooltip as pt,borderClassName as mt,clsx as ht}from"@univerjs/design";import{IDefinedNamesService as gt,deserializeRangeWithSheet as _t,serializeRange as vt,serializeRangeToRefString as yt,serializeRangeWithSheet as bt}from"@univerjs/engine-formula";import{RangeSelector as xt}from"@univerjs/sheets-formula-ui";import{AddHyperLinkCommand as St,AddHyperLinkMutation as Ct,AddRichHyperLinkCommand as wt,CancelHyperLinkCommand as Tt,CancelRichHyperLinkCommand as Et,ERROR_RANGE as Dt,HyperLinkModel as Ot,RemoveHyperLinkMutation as kt,SheetHyperLinkType as H,SheetsHyperLinkParserService as At,UniverSheetsHyperLinkPlugin as jt,UpdateHyperLinkCommand as Mt,UpdateRichHyperLinkCommand as Nt}from"@univerjs/sheets-hyper-link";import{useCallback as Pt,useEffect as U,useMemo as Ft,useRef as It,useState as W}from"react";import{Fragment as Lt,jsx as G,jsxs as Rt}from"react/jsx-runtime";import{AllBorderIcon as zt,CopyIcon as Bt,LinkIcon as Vt,UnlinkIcon as Ht,WriteIcon as Ut,XlsxMultiIcon as Wt}from"@univerjs/icons";import{SheetDataValidationModel as Gt}from"@univerjs/sheets-data-validation";let K=function(e){return e.EDITING=`editing`,e.VIEWING=`viewing`,e.ZEN_EDITOR=`zen_mode`,e}({});function Kt(e){return ee.isLegalUrl(e)}function qt(e){return/^[a-zA-Z]+:\/\//.test(e)}function Jt(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Yt(e){if(Kt(e)){let t=qt(e)?e:Jt(e)?`mailto://${e}`:`http://${e}`,n;try{n=new URL(t)}catch{return e}return n.hostname===location.hostname&&n.port===location.port&&n.protocol===location.protocol&&n.pathname===location.pathname&&n.hash&&!n.search?n.hash:t}return e}const Xt=`sheets-hyper-link-ui.config`;Symbol(Xt);const Zt={};function q(e,t){return function(n,r){t(n,r,e)}}function J(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Qt(e,t){let n=t.getMergeData(),r=t.getMaxColumns()-1,i=t.getMaxRows()-1;if(r<e.endColumn&&(e.endColumn=r),i<e.endRow&&(e.endRow=i),e.rangeType===w.COLUMN||w.ROW)return e;let a=[];return n.forEach(t=>{E.intersects(e,t)&&a.push(t)}),E.realUnion(e,...a)}let Y=class{constructor(e,t,n,r,i,a){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=i,this._configService=a}navigate(e){switch(e.type){case H.URL:this.navigateToOtherWebsite(e.url);break;default:this._navigateToUniver(e.searchObj)}}_navigateToUniver(e){let{gid:t,range:n,rangeid:r}=e,i=this._univerInstanceService.getCurrentUnitForType(O.UNIVER_SHEET);if(!i)return;let a=i.getUnitId();if(r){let e=this._definedNamesService.getValueById(a,r);if(!e)return;let{formulaOrRefString:t}=e,n=this._definedNamesService.getWorksheetByRef(a,t);if(!n){this._messageService.show({content:this._localeService.t(`hyperLink.message.refError`),type:dt.Error});return}if(n.isSheetHidden()){this._messageService.show({content:this._localeService.t(`hyperLink.message.hiddenSheet`),type:dt.Error});return}this.navigateToDefineName(a,r)}if(t){if(n){let e=_t(n);ne(e.range)&&n!==Dt&&this.navigateToRange(a,t,e.range);return}this.navigateToSheetById(a,t)}}async navigateToRange(e,t,n,r){let i=await this.navigateToSheetById(e,t);if(i){let a=Qt(n,i);await this._commandService.executeCommand(se.id,{unitId:e,subUnitId:t,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(Te.id,{range:a,forceTop:r})}}async navigateToSheetById(e,t){let n=this._univerInstanceService.getUnit(e,O.UNIVER_SHEET);if(!n)return!1;let r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;let i=n.getSheetBySheetId(t);return i?n.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t(`hyperLink.message.hiddenSheet`),type:dt.Error}),!1):await this._commandService.executeCommand(ce.id,{unitId:e,subUnitId:t})?i:!1:(this._messageService.show({content:this._localeService.t(`hyperLink.message.noSheet`),type:dt.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){var t;let n=this._configService.getConfig(Xt);if(!(n==null||(t=n.urlHandler)==null)&&t.navigateToOtherWebsite)return n.urlHandler.navigateToOtherWebsite(e);window.open(e,`_blank`,`noopener noreferrer`)}};Y=J([q(0,_),q(1,p),q(2,gt),q(3,Ge),q(4,v(x)),q(5,m)],Y);function $t(e){"@babel/helpers - typeof";return $t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},$t(e)}function en(e,t){if($t(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if($t(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function tn(e){var t=en(e,`string`);return $t(t)==`symbol`?t:t+``}function X(e,t,n){return(t=tn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var nn=class extends u{constructor(...e){super(...e),X(this,`_customHyperLinks`,new Map)}isBuiltInLinkType(e){return e!==H.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(t=>t.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){let{_customHyperLinks:t}=this;t.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}};const rn=()=>{var n;let[i,a]=W(``),[c,l]=W(!1),[u,m]=W(``),[g,v]=W(!0),[y,b]=W(H.URL),[S,C]=W(``),w=B(x),T=B(gt),E=B(L),k=B(_),A=B(Z),j=et(A.currentEditing$),re=B(At),ie=B(Y),M=B(p),N=B(nn),ae=Ft(()=>N.getOptions(),[N]),P=B(qe),oe=B(Be),le=B(Ce),ue=B(Ne),fe=B(h),pe=B(D),me=B(Ne),[he,ge]=W(!1),_e=B(de),ve=Ft(()=>_e.getCurrentSelections(),[]),ye=Ft(()=>{if(!N.isBuiltInLinkType(y))return N.getCustomHyperLink(y)},[N,y]),[F,be]=W(!1),[xe,Se]=W(!1),I=It(!1),R=k.getCurrentUnitForType(O.UNIVER_SHEET),we=(R==null?void 0:R.getActiveSheet().getSheetId())||``,z=Pt(e=>{m(e.replaceAll(s.CUSTOM_RANGE_START,``).replaceAll(s.CUSTOM_RANGE_END,``))},[m]);U(()=>{if((j==null?void 0:j.row)!==void 0&&j.col!==void 0){let{customRange:y,row:x,col:S}=j,{label:w}=j;typeof w==`number`&&(w=`${w}`);let T;if(y){var t,n,i,o;T={id:(t=y==null?void 0:y.rangeId)==null?``:t,display:(n=w)==null?``:n,payload:(i=y==null||(o=y.properties)==null?void 0:o.url)==null?``:i,row:x,column:S}}else if(j.type===K.VIEWING){var s,c,l,u;let t=k.getUnit(j.unitId),n=t==null?void 0:t.getSheetBySheetId(j.subUnitId),i=n==null?void 0:n.getCellRaw(j.row,j.col),a=i==null||(s=i.p)==null||(s=s.body)==null||(s=s.customRanges)==null?void 0:s.find(e=>{var t;return e.rangeType===r.HYPERLINK&&((t=e.properties)==null?void 0:t.url)}),o=i==null?void 0:i.v;i&&(!e.transform.isEmptyDocument((c=i.p)==null||(c=c.body)==null?void 0:c.dataStream)||ee.isDefine(o))&&v(!1),T={id:``,display:``,payload:(l=a==null||(u=a.properties)==null?void 0:u.url)==null?``:l,row:x,column:S}}else{var d,f,p,m,h;let t=k.getCurrentUnitForType(O.UNIVER_DOC),n=ue.getActiveTextRange(),r=t==null?void 0:t.getBody(),i=n&&r?n:null,a=i&&((d=e.customRange.getCustomRangesInterestsWithSelection(i,(f=r==null?void 0:r.customRanges)==null?[]:f))==null?void 0:d[0]);v(!1),T={id:``,display:(p=w)==null?``:p,payload:(m=a==null||(h=a.properties)==null?void 0:h.url)==null?``:m,row:x,column:S}}a(T.id);let E=N.findCustomHyperLink(T);if(E){let e=E.convert(T);b(e.type),C(e.payload),z(e.display);return}z(T.display);let D=re.parseHyperLink(T.payload);switch(b(D.type===H.INVALID?H.RANGE:D.type),D.type){case H.URL:C(D.url),D.url===T.display&&(I.current=!0);break;case H.RANGE:{var g,_;let e=D.searchObj,t=bt(e.gid?(g=(_=k.getUnit(j.unitId))==null||(_=_.getSheetBySheetId(e.gid))==null?void 0:_.getName())==null?``:g:``,_t(e.range).range);C(t),t===T.display&&(I.current=!0);break}case H.SHEET:{let e=D.searchObj;C(e.gid);break}case H.DEFINE_NAME:{let e=D.searchObj;C(e.rangeid);break}default:C(``);break}}},[j,ie,N,ue,k]),U(()=>{let e=null;if(j&&!j.customRangeId&&j.type===K.VIEWING&&ee.isDefine(j.row)&&ee.isDefine(j.col)){let n=k.getUnit(j.unitId,O.UNIVER_SHEET),r=n==null?void 0:n.getSheetBySheetId(j.subUnitId),i=r==null?void 0:r.getMergedCell(j.row,j.col),a=new t(pe.getColorFromTheme(`primary.600`)).toRgb();e=le.addShape({range:i==null?{startColumn:j.col,endColumn:j.col,startRow:j.row,endRow:j.row}:i,style:{fill:`rgb(${a.r}, ${a.g}, ${a.b}, 0.12)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null},[],-1)}return()=>{e&&le.removeShape(e)}},[j,le,pe,k]),U(()=>{Se(y===H.RANGE)},[y]),U(()=>{let e=(j==null?void 0:j.type)===K.ZEN_EDITOR?oe.getRenderById(o):oe.getRenderById(E.getCurrentEditorId()),t=new d;if(e){let n=e.with(Le);n.setReserveRangesStatus(!0),t.add(()=>{n.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),t.dispose()}},[j==null?void 0:j.type,E,oe]),U(()=>(xe&&A.setIsKeepVisible(xe),A.setIsKeepVisible(he),()=>{A.setIsKeepVisible(!1)}),[xe,he,A]),U(()=>()=>{P.temporaryHidden&&(P.show(),fe.setContextValue(f,!1))},[fe,P]),U(()=>{if(xe)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[xe,E]);let Ee=[{label:w.t(`hyperLink.form.link`),value:H.URL},{label:w.t(`hyperLink.form.range`),value:H.RANGE},{label:w.t(`hyperLink.form.worksheet`),value:H.SHEET},{label:w.t(`hyperLink.form.definedName`),value:H.DEFINE_NAME},...ae];if(!R)return;let De=R.getHiddenWorksheets(),Oe=R.getSheets().map(e=>({label:e.getName(),value:e.getSheetId()})).filter(e=>De.indexOf(e.value)===-1),ke=Object.values((n=T.getDefinedNameMap(R.getUnitId()))==null?{}:n).map(e=>({label:e.name,value:e.id})),Ae=(e,t)=>{if(e===H.URL)return Yt(t);if(e===H.RANGE){let e=_t(t),n=R.getSheetBySheetName(e.sheetName);if(n)return`#gid=${n.getSheetId()}&range=${vt(e.range)}`}return`#${e}=${t}`},je=$e(e=>{let t=e.split(`,`).map(_t)[0];if(!t||!ne(t.range))return;if(!t.sheetName){var n;t.sheetName=((n=R.getActiveSheet())==null?void 0:n.getName())||``}let r=yt(t);C(r),r&&(I.current||!u)&&(z(r),I.current=!0)}),Me=async()=>{if(g&&!u||!S||y===H.URL&&!Kt(S)){be(!0);return}if(j)if(i){let e=j.type===K.ZEN_EDITOR||j.type===K.EDITING?Nt.id:Mt.id;await M.executeCommand(e,{id:i,unitId:j.unitId,subUnitId:j.subUnitId,payload:{display:g?u:``,payload:Ae(y,S)},row:j.row,column:j.col,documentId:j.type===K.ZEN_EDITOR?o:E.getCurrentEditorId()})}else{let e=j.type===K.ZEN_EDITOR||j.type===K.EDITING?wt.id:St.id;await M.executeCommand(e,{unitId:j.unitId,subUnitId:j.subUnitId,link:{id:te(),row:j.row,column:j.col,payload:Ae(y,S),display:g?u:``},documentId:j.type===K.ZEN_EDITOR?o:E.getCurrentEditorId()})}(j==null?void 0:j.type)===K.VIEWING&&(await M.executeCommand(ce.id,{unitId:j.unitId,subUnitId:j.subUnitId}),await M.executeCommand(Te.id,{range:{startRow:Math.max(j.row-1,0),endRow:j.row+1,startColumn:Math.max(j.col-1,0),endColumn:j.col+1}})),M.executeCommand(mn.id)};return j?Rt(`div`,{className:ht(`
|
|
2
|
+
univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md
|
|
3
|
+
dark:!univer-bg-gray-900
|
|
4
|
+
`,mt),children:[g?G(lt,{label:w.t(`hyperLink.form.label`),error:F&&!u?w.t(`hyperLink.form.inputError`):``,children:G(ut,{value:u,onChange:e=>{z(e),I.current=!1},placeholder:w.t(`hyperLink.form.labelPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===Je.ENTER&&Me()}})}):null,G(lt,{label:w.t(`hyperLink.form.type`),children:G(ft,{className:`univer-w-full`,options:Ee,value:y,onChange:e=>{b(e),C(``)}})}),y===H.URL&&G(lt,{error:F?S?Kt(S)?``:w.t(`hyperLink.form.linkError`):w.t(`hyperLink.form.inputError`):``,children:G(ut,{value:S,onChange:e=>{C(e),e&&(I.current||!u||u===e)&&(z(e),I.current=!0)},placeholder:w.t(`hyperLink.form.linkPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===Je.ENTER&&Me()}})}),y===H.RANGE&&G(lt,{error:F&&!S?w.t(`hyperLink.form.inputError`):``,children:G(xt,{unitId:R.getUnitId(),subUnitId:we,maxRangeCount:1,supportAcrossSheet:!0,initialValue:S,resetRange:ve,onChange:(e,t)=>je(t),onRangeSelectorDialogVisibleChange:async e=>{if(ge(e),e)j.type===K.ZEN_EDITOR&&(P.hide(),fe.setContextValue(f,!0)),j.type!==K.VIEWING&&E.enableForceKeepVisible(),l(!0);else{if(await ie.navigateToRange(j.unitId,j.subUnitId,{startRow:j.row,endRow:j.row,startColumn:j.col,endColumn:j.col},!0),j.type===K.ZEN_EDITOR){var t,n;await M.executeCommand(se.id,{unitId:j.unitId,subUnitId:j.subUnitId,selections:[{range:{startRow:j.row,endRow:j.row,startColumn:j.col,endColumn:j.col}}]}),P.show(),fe.setContextValue(f,!1);let e=(t=oe.getRenderById(o))==null?void 0:t.with(Pe),r=(n=me.getTextRanges({unitId:o,subUnitId:o}))==null?void 0:n[0];e&&r&&(e.scrollToRange(r),me.refreshSelection({unitId:o,subUnitId:o}))}E.disableForceKeepVisible(),l(!1)}},onFocusChange:e=>Se(e)})}),y===H.SHEET&&G(lt,{error:F&&!S?w.t(`hyperLink.form.selectError`):``,children:G(ft,{className:`univer-w-full`,options:Oe,value:S,onChange:e=>{var t,n;C(e);let r=(t=Oe.find(t=>t.value===e))==null?void 0:t.label,i=(n=Oe.find(e=>e.value===S))==null?void 0:n.label;r&&(I.current||!u||u===i)&&(z(r),I.current=!0)}})}),y===H.DEFINE_NAME&&G(lt,{error:F&&!S?w.t(`hyperLink.form.selectError`):``,children:G(ft,{className:`univer-w-full`,options:ke,value:S,onChange:e=>{var t,n;C(e);let r=(t=ke.find(t=>t.value===e))==null?void 0:t.label,i=(n=ke.find(e=>e.value===S))==null?void 0:n.label;r&&(I.current||!u||u===i)&&(z(r),I.current=!0)}})}),(ye==null?void 0:ye.Form)&&G(ye.Form,{linkId:i,payload:S,display:u,showError:F,setByPayload:I,setDisplay:e=>{z(e),I.current=!0},setPayload:C}),Rt(`div`,{className:`univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[G(ct,{onClick:()=>{j&&ie.navigateToRange(j.unitId,j.subUnitId,{startRow:j.row,endRow:j.row,startColumn:j.col,endColumn:j.col},!0),M.executeCommand(mn.id)},children:w.t(`hyperLink.form.cancel`)}),G(ct,{variant:`primary`,onClick:async()=>{Me()},children:w.t(`hyperLink.form.ok`)})]})]}):null};rn.componentKey=`univer.sheet.cell-link-edit`;const an={[H.URL]:G(Vt,{}),[H.SHEET]:G(Wt,{className:`univer-text-green-500`}),[H.RANGE]:G(zt,{}),[H.DEFINE_NAME]:G(zt,{}),[H.INVALID]:G(zt,{})},on=e=>{var t,n;let r=B(Z),i=B(p),a=B(Ge),s=B(x),c=B(Y),l=B(L),u=B(At),d=B(qe),{customRange:f,row:m,col:h,unitId:g,subUnitId:_,editPermission:v,copyPermission:y,type:b}=e;if(!(!(f==null||(t=f.properties)==null)&&t.url))return null;let S=u.parseHyperLink((n=f.properties.url)==null?``:n),C=S.type===H.INVALID;return Rt(`div`,{className:ht(`
|
|
5
|
+
univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between
|
|
6
|
+
univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow-md
|
|
7
|
+
dark:!univer-bg-gray-900
|
|
8
|
+
`,mt),onClick:()=>r.hideCurrentPopup(),children:[Rt(`div`,{className:ht(`
|
|
9
|
+
univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center
|
|
10
|
+
univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600
|
|
11
|
+
`,{"univer-text-red-500":C}),onClick:()=>{d.visible||C||c.navigate(S)},children:[G(`div`,{className:`
|
|
12
|
+
univer-mr-2 univer-flex univer-size-5 univer-flex-none univer-items-center univer-justify-center
|
|
13
|
+
univer-text-base univer-text-gray-900
|
|
14
|
+
dark:!univer-text-white
|
|
15
|
+
`,children:an[S.type]}),G(pt,{showIfEllipsis:!0,title:S.name,asChild:!0,children:G(`span`,{className:`univer-flex-1 univer-truncate`,children:S.name})})]}),Rt(`div`,{className:`
|
|
16
|
+
univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center
|
|
17
|
+
`,children:[y&&G(`div`,{className:ht(`
|
|
18
|
+
univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row
|
|
19
|
+
univer-items-center univer-justify-center univer-rounded univer-text-base
|
|
20
|
+
hover:univer-bg-gray-100
|
|
21
|
+
dark:hover:!univer-bg-gray-700
|
|
22
|
+
`,{"univer-text-red-500":C}),onClick:()=>{if(!C){if(S.type!==H.URL){let e=new URL(window.location.href);e.hash=S.url.slice(1),navigator.clipboard.writeText(e.href)}else navigator.clipboard.writeText(S.url);a.show({content:s.t(`hyperLink.message.coped`),type:dt.Info})}},children:G(pt,{placement:`bottom`,title:s.t(`hyperLink.popup.copy`),children:G(Bt,{className:`dark:!univer-text-white`})})}),v&&Rt(Lt,{children:[G(`div`,{className:`
|
|
23
|
+
univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row
|
|
24
|
+
univer-items-center univer-justify-center univer-rounded univer-text-base
|
|
25
|
+
hover:univer-bg-gray-100
|
|
26
|
+
dark:hover:!univer-bg-gray-700
|
|
27
|
+
`,onClick:()=>{i.executeCommand(pn.id,{unitId:g,subUnitId:_,row:m,col:h,customRangeId:f.rangeId,type:b})},children:G(pt,{placement:`bottom`,title:s.t(`hyperLink.popup.edit`),children:G(Ut,{className:`dark:!univer-text-white`})})}),G(`div`,{className:`
|
|
28
|
+
univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row
|
|
29
|
+
univer-items-center univer-justify-center univer-rounded univer-text-base
|
|
30
|
+
hover:univer-bg-gray-100
|
|
31
|
+
dark:hover:!univer-bg-gray-700
|
|
32
|
+
`,onClick:()=>{let e=b===K.EDITING||b===K.ZEN_EDITOR?Et.id:Tt.id;i.syncExecuteCommand(e,{unitId:g,subUnitId:_,id:f.rangeId,row:m,column:h,documentId:b===K.ZEN_EDITOR?o:l.getCurrentEditorId()})&&r.hideCurrentPopup(void 0,!0)},children:G(pt,{placement:`bottom`,title:s.t(`hyperLink.popup.cancel`),children:G(Ht,{className:`dark:!univer-text-white`})})})]})]})]})},sn=()=>{let e=B(Z),[t,n]=W(null),r=B(_);if(U(()=>{n(e.currentPopup);let t=e.currentPopup$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!t)return null;if(t.showAll){var i;let e=r.getUnit(t.unitId,O.UNIVER_SHEET),n=e==null?void 0:e.getSheetBySheetId(t.subUnitId),a=n==null?void 0:n.getCell(t.row,t.col),o=a==null||(i=a.p)==null||(i=i.body)==null?void 0:i.customRanges;return o!=null&&o.length?G(`div`,{children:o.map(e=>G(on,{...t,customRange:e},e.rangeId))}):null}return G(on,{...t})};sn.componentKey=`univer.sheet.cell-link-popup`;const cn=(e,t)=>{var n,r;return e.unitId===t.unitId&&e.subUnitId===t.subUnitId&&e.row===t.row&&e.col===t.col&&((n=e.customRange)==null?void 0:n.rangeId)===((r=t.customRange)==null?void 0:r.rangeId)&&e.type===t.type};let Z=class extends u{get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}constructor(e,t,n,r,i,a,o){super(),this._sheetCanvasPopManagerService=e,this._injector=t,this._univerInstanceService=n,this._editorBridgeService=r,this._textSelectionManagerService=i,this._docCanvasPopManagerService=a,this._zenZoneService=o,X(this,`_currentPopup`,null),X(this,`_currentPopup$`,new rt),X(this,`currentPopup$`,this._currentPopup$.asObservable()),X(this,`_currentEditingPopup`,null),X(this,`_currentEditing$`,new tt(null)),X(this,`currentEditing$`,this._currentEditing$.asObservable()),X(this,`_isKeepVisible`,!1),this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&cn(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==K.ZEN_EDITOR&&this._zenZoneService.visible))return;let t=this._currentEditing$.getValue();if(t&&cn(e,t))return;let{unitId:n,subUnitId:r,row:i,col:a,customRangeRect:s,customRange:c}=e,l,u={componentKey:sn.componentKey,direction:`bottom`,onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===K.EDITING){if(!c)return;l=s&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(s,u)}else if(e.type===K.ZEN_EDITOR){if(!c)return;l=this._docCanvasPopManagerService.attachPopupToRange({startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},u,o)}else if(e.showAll)l=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,u,n,r);else{if(!c)return;l=s&&this._sheetCanvasPopManagerService.attachPopupByPosition(s,u,e)}if(l){if(this._currentPopup){var d;(d=this._currentPopup.disposable)==null||d.dispose()}this._currentPopup={unitId:n,subUnitId:r,disposable:l,row:i,col:a,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:c,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup)}}hideCurrentPopup(e,t){if(this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||t)){var n;(n=this._currentPopup)==null||(n=n.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null)}}dispose(){super.dispose(),this.hideCurrentPopup(),this.endEditing(),this._currentPopup$.complete(),this._currentEditing$.complete()}_getEditingRange(){let t=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(t&&n){var i,a,o;let t=this._textSelectionManagerService.getActiveTextRange(),s=(i=n.documentLayoutObject.documentModel)==null?void 0:i.getBody();if(!s)return null;if(!t||t.collapsed)return{startOffset:0,endOffset:s.dataStream.length-2,collapsed:s.dataStream.length-2==0,label:e.transform.getPlainText(s.dataStream)};let c=e.customRange.getCustomRangesInterestsWithSelection(t,(a=(o=s.customRanges)==null?void 0:o.filter(e=>e.rangeType===r.HYPERLINK))==null?[]:a),l=t.startOffset,u=t.endOffset;return c.forEach(e=>{l=Math.min(l,e.startIndex),u=Math.max(u,e.endIndex+1)}),{startOffset:l,endOffset:u,collapsed:l===u,label:e.transform.getPlainText(s.dataStream.slice(l,u))}}return null}get _editPopup(){return{componentKey:rn.componentKey,direction:`vertical`,onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:`hide`}}startAddEditing(t){let{unitId:n,subUnitId:r,type:i}=t;if(i===K.ZEN_EDITOR){var s;let e=this._univerInstanceService.getUnit(o,O.UNIVER_DOC);if(!e)return;let n=this._textSelectionManagerService.getActiveTextRange();if(!n)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(n,this._editPopup,o);let r=(s=e.getBody())==null?void 0:s.dataStream.slice(n.startOffset,n.endOffset);this._currentEditing$.next({...t,label:r})}else if(i===K.EDITING){var c;let e=this._getEditingRange();if(!e)return;this._textSelectionManagerService.replaceDocRanges([{...e}],{unitId:a,subUnitId:a});let i=this._injector.get(Be).getRenderById(a);if(!i)return;let o=ze(e,i);if(!(o!=null&&o.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(o.pop(),this._editPopup,n,r),this._currentEditing$.next({...t,label:(c=e==null?void 0:e.label)==null?``:c})}else{var l,u,d;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,n,r);let i=this._univerInstanceService.getUnit(n,O.UNIVER_SHEET),a=i==null?void 0:i.getSheetBySheetId(r),o=a==null?void 0:a.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:o!=null&&o.p?e.transform.getPlainText((l=(u=o.p.body)==null?void 0:u.dataStream)==null?``:l):((d=o==null?void 0:o.v)==null?``:d).toString()})}}startEditing(e){var t;(t=this._currentEditingPopup)==null||t.dispose(),this.hideCurrentPopup(void 0,!0);let{unitId:n,subUnitId:r}=e,i,a;if(e.type===K.ZEN_EDITOR){var s,c;let t=this._univerInstanceService.getUnit(o,O.UNIVER_DOC);if(i=t==null||(s=t.getBody())==null||(s=s.customRanges)==null?void 0:s.find(t=>t.rangeId===e.customRangeId),a=i?t==null||(c=t.getBody())==null?void 0:c.dataStream.slice(i.startIndex,i.endIndex+1):``,!i||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:i.startIndex,endOffset:i.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:i.startIndex,endOffset:i.endIndex,collapsed:!1},this._editPopup,o)}else if(e.type===K.EDITING){var l;let t=ke(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!t||!((l=t.rects)!=null&&l.length))return;i=t.customRange,a=t.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:i.startIndex,endOffset:i.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(t.rects.pop(),this._editPopup,n,r)}else{var u;let t=this._univerInstanceService.getUnit(n,O.UNIVER_SHEET),o=t==null?void 0:t.getSheetBySheetId(r),s=o==null?void 0:o.getCellRaw(e.row,e.col),c=t==null?void 0:t.getStyles().getStyleByCell(s),l=c==null?void 0:c.tr,d=Oe(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!d||!((u=d.rects)!=null&&u.length))return;i=d.customRange,a=d.label,l?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(d.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:i,label:a})}endEditing(e){if(this.getIsKeepVisible())return;let t=this._currentEditing$.getValue();if(t&&(!e||e===t.type)){var n;(n=this._currentEditingPopup)==null||n.dispose(),this._currentEditing$.next(null)}}};Z=J([q(0,v(z)),q(1,v(y)),q(2,_),q(3,L),q(4,v(Ne)),q(5,v(Fe)),q(6,qe)],Z);let Q=function(e){return e[e.ALLOWED=0]=`ALLOWED`,e[e.DISABLED_BY_CELL=1]=`DISABLED_BY_CELL`,e[e.ALLOW_ON_EDITING=2]=`ALLOW_ON_EDITING`,e}({});const ln=new Set([c.CHECKBOX,c.LIST,c.LIST_MULTIPLE]),un=(e,t,n,r)=>{var i,a;let o=t.getCell(n,r);if(o!=null&&o.f||o!=null&&o.si||!(o==null||(i=o.p)==null||(i=i.body)==null||(i=i.customBlocks)==null)&&i.length)return Q.DISABLED_BY_CELL;let s=e.has(Gt)?e.get(Gt):null,c=s==null?void 0:s.getRuleByLocation(t.getUnitId(),t.getSheetId(),n,r);return c&&ln.has(c.type)?!0:!(o==null||(a=o.p)==null||(a=a.drawingsOrder)==null)&&a.length?Q.ALLOW_ON_EDITING:Q.ALLOWED},dn=e=>{let t=e.get(_).getCurrentUnitForType(O.UNIVER_SHEET);if(!t)return!0;let n=t.getActiveSheet(),r=e.get(de).getCurrentSelections();if(!r.length)return!0;let i=r[0].range.startRow,a=r[0].range.startColumn;return un(e,n,i,a)===Q.DISABLED_BY_CELL},fn=e=>{let t=e.get(Ne),n=e.get(_),r=t.getTextRanges();if(!(r!=null&&r.length))return!0;let i=n.getCurrentUnitForType(O.UNIVER_DOC);return!!(!i||r.every(e=>e.collapsed)||!i.getSelfOrHeaderFooterModel(r[0].segmentId).getBody())},pn={type:n.OPERATION,id:`sheet.operation.open-hyper-link-edit-panel`,handler(e,t){if(!t)return!1;let n=e.get(Z);return t.customRangeId?n.startEditing(t):n.startAddEditing(t),!0}},mn={type:n.OPERATION,id:`sheet.operation.close-hyper-link-popup`,handler(e){return e.get(Z).endEditing(),!0}},hn={type:n.OPERATION,id:`sheet.operation.insert-hyper-link`,handler(e){var t;let n=e.get(_),r=F(n),i=e.get(L);if(!r)return!1;let a=e.get(p),s=e.get(de).getCurrentLastSelection();if(!s)return!1;let c=s.range.startRow,l=s.range.startColumn,u=i.isVisible(),d=((t=n.getFocusedUnit())==null?void 0:t.getUnitId())===o;return a.executeCommand(pn.id,{unitId:r.unitId,subUnitId:r.subUnitId,row:c,col:l,type:d?K.ZEN_EDITOR:u.visible?K.EDITING:K.VIEWING})}},$={type:n.OPERATION,id:`sheet.operation.insert-hyper-link-toolbar`,handler(e){if(dn(e))return!1;let t=e.get(p);return e.get(Z).currentEditing?t.executeCommand(mn.id):t.executeCommand(hn.id)}},gn=`SHEET_HYPER_LINK_UI_PLUGIN`;let _n=class extends u{registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(t=>t(e))}constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._hyperLinkModel=t,this._injector=n,this._resolverService=r,X(this,`_plainTextFilter`,new Set),X(this,`_copyInfo`,void 0),this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:gn,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,r)=>{let{copyType:i=xe.COPY,pasteType:a}=r,{range:o}=e||{},{range:s,unitId:c,subUnitId:l}=t;return this._generateMutations(s,{copyType:i,pasteType:a,copyRange:o,unitId:c,subUnitId:l})},onPastePlainText:(e,t)=>{let n=this._filterPlainText(t);if(Kt(t)&&n){let{range:t,unitId:n,subUnitId:r}=e,{ranges:[i],mapFunc:a}=je([t]),o=[],s=[];return T.foreach(i,(e,t)=>{let{row:i,col:c}=a(e,t),l=this._hyperLinkModel.getHyperLinkByLocation(n,r,i,c);l&&o.push({id:kt.id,params:{unitId:n,subUnitId:r,id:l.id}}),l&&s.push({id:Ct.id,params:{unitId:n,subUnitId:r,link:l}})}),{redos:o,undos:s}}return{undos:[],redos:[]}},priority:99})}_collect(e,t,n){let r=new S;this._copyInfo={unitId:e,subUnitId:t,matrix:r};let i=this._injector.invoke(r=>be(n,r,e,t));if(!i)return;let{rows:a,cols:o}=i;a.forEach((n,i)=>{o.forEach((a,o)=>{var s;let c=this._hyperLinkModel.getHyperLinkByLocation(e,t,n,a);r.setValue(i,o,(s=c==null?void 0:c.id)==null?``:s)})})}_generateMutations(e,t){if(!this._copyInfo||!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!t.copyRange||[we.SPECIAL_PASTE_COL_WIDTH,we.SPECIAL_PASTE_VALUE,we.SPECIAL_PASTE_FORMAT,we.SPECIAL_PASTE_FORMULA].includes(t.pasteType))return{redos:[],undos:[]};let{unitId:n,subUnitId:r}=this._copyInfo,i=[],a=[],{ranges:[o,s],mapFunc:c}=je([t.copyRange,e]);return Ae(o,s,!0).forEach(({startRange:e})=>{var o;(o=this._copyInfo)==null||o.matrix.forValue((o,s,l)=>{let u=E.getPositionRange({startRow:o,endRow:o,startColumn:s,endColumn:s},e),d=this._hyperLinkModel.getHyperLink(n,r,l),{row:f,col:p}=c(u.startRow,u.startColumn),m=this._hyperLinkModel.getHyperLinkByLocation(t.unitId,t.subUnitId,f,p),h=te();m&&i.push({id:kt.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:m.id}}),d&&(i.push({id:Ct.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:{...d,id:h,row:f,column:p}}}),a.push({id:kt.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,id:h}})),m&&a.push({id:Ct.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,link:m}})})}),{redos:i,undos:a}}};_n=J([q(0,R),q(1,v(Ot)),q(2,v(y)),q(3,v(Y))],_n);const vn=(e,t=o)=>{var n;let r=e.get(_),i=(n=e.get(Be).getRenderById(t))==null?void 0:n.with(Le);return i?i.textSelectionInner$.pipe(ot(()=>{let t=e.get(L).getEditCellState();if(!t)return!0;let n=F(r,{unitId:t.unitId,subUnitId:t.sheetId});return!(n!=null&&n.worksheet)||un(e,n.worksheet,t.row,t.column)===1?!0:fn(e)})):V(!0)},yn=e=>{var t;let n=e.get(_),r=e.has(L)?e.get(L):null;return((t=r==null?void 0:r.currentEditCellState$.pipe(ot(t=>{if(!t)return Q.DISABLED_BY_CELL;let r=F(n,{unitId:t.unitId,subUnitId:t.sheetId});return r?un(e,r.worksheet,t.row,t.column):Q.DISABLED_BY_CELL}),st(t=>t===Q.DISABLED_BY_CELL?V(!0):it([r?r.visible$:V(null),n.getCurrentTypeOfUnit$(O.UNIVER_DOC)]).pipe(st(([n,r])=>n!=null&&n.visible?(r==null?void 0:r.getUnitId())===i?V(!0):vn(e,a):V(t!==Q.ALLOWED))))))==null?V(!0):t).pipe(st(t=>t?V(!0):De(e,{workbookTypes:[pe],worksheetTypes:[ge,ve,_e],rangeTypes:[P]},!0)))},bn={commandId:hn.id,type:Ye.BUTTON,title:`hyperLink.menu.add`,icon:`LinkIcon`},xn=e=>`${e}-zen-editor`,Sn=e=>({...bn,id:bn.commandId,hidden$:Qe(e,O.UNIVER_SHEET),disabled$:yn(e)}),Cn=e=>({...bn,id:xn(bn.commandId),hidden$:Qe(e,O.UNIVER_DOC,o),disabled$:vn(e)}),wn={tooltip:`hyperLink.form.addTitle`,commandId:$.id,type:Ye.BUTTON,icon:`LinkIcon`},Tn=e=>({...wn,id:wn.commandId,hidden$:Qe(e,O.UNIVER_SHEET),disabled$:yn(e)}),En=e=>({...wn,id:xn(wn.commandId),hidden$:Qe(e,O.UNIVER_DOC,o),disabled$:vn(e)}),Dn={id:$.id,binding:Je.K|Xe.CTRL_COMMAND,preconditions:Me};var On=`@univerjs/sheets-hyper-link-ui`,kn=`0.18.0`;let An=class extends u{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),t=(e,t)=>{let{source:n,target:r,unitId:i,subUnitId:a}=e,o=je([n,r]),[s,c]=o.ranges,{mapFunc:l}=o,u={row:s.startRow,col:s.startColumn},d=j.getAutoFillRepeatRange(s,c),f=[],p=[];return d.forEach(e=>{let n=e.repeatStartCell,r=e.relativeRange,o={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},s={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};T.foreach(r,(e,n)=>{let r=E.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},o),{row:c,col:u}=l(r.startRow,r.startColumn),d=this._hyperLinkModel.getHyperLinkByLocation(i,a,c,u),m=E.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},s),{row:h,col:g}=l(m.startRow,m.startColumn),_=te(),v=this._hyperLinkModel.getHyperLinkByLocation(i,a,h,g);v&&f.push({id:kt.id,params:{unitId:i,subUnitId:a,id:v.id}}),(A.COPY===t||A.SERIES===t)&&d&&(f.push({id:Ct.id,params:{unitId:i,subUnitId:a,link:{...d,id:_,row:h,column:g}}}),p.push({id:kt.id,params:{unitId:i,subUnitId:a,id:_}})),v&&p.push({id:Ct.id,params:{unitId:i,subUnitId:a,link:v}})})}),{undos:p,redos:f}},n={id:gn,onFillData:(n,r,i)=>i===A.COPY||i===A.ONLY_FORMAT||i===A.SERIES?t(n,i):e()};this.disposeWithMe(this._autoFillService.addHook(n))}};An=J([q(0,N),q(1,v(Ot))],An);let jn=class extends u{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===Dn.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[pe],rangeTypes:[P],worksheetTypes:[ge,ve,_e]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.hyperLinkErr`)))}))}};jn=J([q(0,v(x)),q(1,p),q(2,v(ue))],jn);let Mn=class extends u{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionCheckController=i,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=s,this._univerInstanceService=c,this._zenZoneService=l,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){let{unitId:t,subUnitId:n,row:r,col:i}=e,a=this._univerInstanceService.getUnit(t,O.UNIVER_SHEET),o=a==null?void 0:a.getSheetBySheetId(n);if(!o)return{viewPermission:!1,editPermission:!1,copyPermission:!1};let s=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[me],worksheetTypes:[ye],rangeTypes:[oe]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}],t,n),c=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[pe],worksheetTypes:[ge,_e],rangeTypes:[P]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}],t,n),l=o.getCellRaw(r,i);l!=null&&l.f&&l.f.startsWith(`=HYPERLINK(`)&&(c=!1);let u=this._permissionService.composePermission([new fe(t).id,new he(t,n).id]).every(e=>e.value);return{viewPermission:s,editPermission:c,copyPermission:u}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(at(200)).subscribe(e=>{var t,n,i;if(!e||((t=e.customRange)==null?void 0:t.rangeType)!==r.HYPERLINK){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let{unitId:a,subUnitId:o,row:s,col:c}=e,l=this._renderManagerService.getRenderById(a);if(!l)return;let u=this._univerInstanceService.getUnit(a,O.UNIVER_SHEET),d=u==null?void 0:u.getSheetBySheetId(o);if(!d)return;if(!l.with(I).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(K.VIEWING);return}let f=l==null||(n=l.with(Ee).getSkeletonParam(o))==null?void 0:n.skeleton,p=c,m=s,h=m,g=p;f&&f.overflowCache.forValue((e,t,n)=>{E.contains(n,{startColumn:p,endColumn:p,startRow:m,endRow:m})&&(h=e,g=t)});let{viewPermission:_,editPermission:v,copyPermission:y}=this._getLinkPermission(e);if(!_){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let b=d.getCellStyleOnly(h,g),x=u.getStyles().getStyleByCell(b),S=x==null||(i=x.tr)==null?void 0:i.a;if(!S&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:h,col:g,editPermission:v,copyPermission:y,customRange:e.customRange,customRangeRect:e.rect,type:K.VIEWING,unitId:a,subUnitId:o,showAll:!!S})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(st(e=>this._editorBridgeService.visible$.pipe(ot(t=>({visible:t,state:e}))))).subscribe(({visible:t,state:n})=>{if(!n||n.editorUnitId!==a)return;if(!t.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(K.EDITING),this._sheetsHyperLinkPopupService.endEditing(K.EDITING);return}let{editorUnitId:i,unitId:o,sheetId:s,row:c,column:l}=n,u=this._renderManagerService.getRenderById(i);if(!u)return;let{editPermission:d,viewPermission:f,copyPermission:p}=this._getLinkPermission({unitId:o,subUnitId:s,row:c,col:l}),m=u.with(Ie);f&&(e==null||e.unsubscribe(),e=m.hoverCustomRanges$.pipe(at(200)).subscribe(e=>{var t;let n=e.find(e=>e.range.rangeType===r.HYPERLINK);if(!n){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let i=n.rects[n.rects.length-1];if(!(!((t=this._renderManagerService.getRenderById(o))==null||(t=t.with(Ee).getSkeletonParam(s))==null)&&t.skeleton)||!i)return;let a=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:o,subUnitId:s,row:c,col:l,customRange:n.range,customRangeRect:{left:i.left+a.left,top:i.top+a.top,bottom:i.bottom+a.top,right:i.right+a.left},editPermission:d,copyPermission:p,type:K.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(K.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(K.EDITING),this._sheetsHyperLinkPopupService.endEditing(K.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(K.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(K.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(K.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(st(e=>{let t=e===o?this._renderManagerService.getRenderById(e):null;return t?t.with(Ie).hoverCustomRanges$.pipe(at(200)):new nt(e=>{e.next(null)})})).subscribe(e=>{let t=e==null?void 0:e.find(e=>e.range.rangeType===r.HYPERLINK),n=this._editorBridgeService.getEditCellState();if(t&&n){let{unitId:e,sheetId:r,row:i,column:a}=n,{editPermission:o,viewPermission:s,copyPermission:c}=this._getLinkPermission({unitId:e,subUnitId:r,row:i,col:a});s&&this._sheetsHyperLinkPopupService.showPopup({type:K.ZEN_EDITOR,unitId:e,subUnitId:r,row:i,col:a,customRange:t.range,editPermission:o,copyPermission:c})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(K.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===a&&this._sheetsHyperLinkPopupService.endEditing(K.EDITING)}))}_initCommandListener(){let e=[ie.id,re.id,M.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Mn=J([q(0,v(Se)),q(1,v(Z)),q(2,v(Be)),q(3,v(g)),q(4,v(ue)),q(5,p),q(6,L),q(7,v(Ne)),q(8,_),q(9,qe)],Mn);let Nn=class extends u{constructor(e,t){super(),this._context=e,this._hyperLinkModel=t,this._initSkeletonChange()}_initSkeletonChange(){let e=()=>{var e;(e=this._context.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(at(16)).subscribe(()=>{e()}))}};Nn=J([q(1,v(Ot))],Nn);let Pn=class extends u{constructor(e,t){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(ae.CELL_CONTENT,{effect:b.Value,priority:100,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t,s=this._hyperLinkModel.getHyperLinkByLocation(a,o,r,i);return s&&e?(e===t.rawData&&(e={...t.rawData}),e.linkUrl=s.payload,e.linkId=s.id,n(e)):n(e)}}))}};Pn=J([q(0,v(le)),q(1,v(Ot))],Pn);const Fn={[Ze.MEDIA]:{[$.id]:{order:1,menuItemFactory:Tn},[xn($.id)]:{order:1,menuItemFactory:En}},[Ue.MAIN_AREA]:{[He.OTHERS]:{order:1,[$.id]:{order:0,menuItemFactory:Sn},[xn($.id)]:{order:0,menuItemFactory:Cn}}}};let In=class extends u{constructor(e,t,n,r,i){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[sn.componentKey,sn],[rn.componentKey,rn],[`LinkIcon`,Vt]].forEach(([e,t])=>{this._componentManager.register(e,t)})}_initCommands(){[pn,mn,hn,$].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(Fn)}_initShortCut(){this._shortcutService.registerShortcut(Dn)}};In=J([q(0,v(Ve)),q(1,p),q(2,We),q(3,v(y)),q(4,v(Ke))],In);let Ln=class extends u{constructor(e,t){super(),this._parserService=e,this._resolverService=t,this._handleInitUrl()}_handleInitUrl(){let e=location.hash;if(e){let t=this._parserService.parseHyperLink(e);this._resolverService.navigate(t)}}};Ln=J([q(0,v(At)),q(1,v(Y))],Ln);let Rn=class extends C{constructor(e=Zt,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{menu:r,...i}=k({},Zt,this._config);r&&this._configService.setConfig(`menu`,r,{merge:!0}),this._configService.setConfig(Xt,i)}onStarting(){[[Y],[Z],[nn],[Pn],[Mn],[In],[An],[_n],[jn],[Ln]].forEach(e=>this._injector.add(e)),this._injector.get(Pn)}onReady(){this._injector.get(Be).registerRenderModule(O.UNIVER_SHEET,[Nn]),this._injector.get(An),this._injector.get(_n),this._injector.get(In)}onRendered(){this._injector.get(jn),this._injector.get(Ln),this._injector.get(Mn)}};X(Rn,`pluginName`,gn),X(Rn,`packageName`,On),X(Rn,`version`,kn),X(Rn,`type`,O.UNIVER_SHEET),Rn=J([l(jt,Re),q(1,v(y)),q(2,m)],Rn);export{mn as CloseHyperLinkPopupOperation,hn as InsertHyperLinkOperation,Dn as InsertLinkShortcut,pn as OpenHyperLinkEditPanelOperation,_n as SheetsHyperLinkCopyPasteController,Z as SheetsHyperLinkPopupService,Y as SheetsHyperLinkResolverService,nn as SheetsHyperLinkSidePanelService,Rn as UniverSheetsHyperLinkUIPlugin};
|