@univerjs/docs-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/index.js +24 -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/index.js +24 -850
- package/lib/es/locale/ca-ES.js +1 -26
- package/lib/es/locale/en-US.js +1 -26
- package/lib/es/locale/es-ES.js +1 -26
- package/lib/es/locale/fa-IR.js +1 -26
- package/lib/es/locale/fr-FR.js +1 -26
- package/lib/es/locale/ja-JP.js +1 -26
- package/lib/es/locale/ko-KR.js +1 -26
- package/lib/es/locale/ru-RU.js +1 -26
- package/lib/es/locale/sk-SK.js +1 -26
- package/lib/es/locale/vi-VN.js +1 -26
- package/lib/es/locale/zh-CN.js +1 -26
- package/lib/es/locale/zh-TW.js +1 -26
- package/lib/index.css +146 -1
- package/lib/index.js +24 -850
- package/lib/locale/ca-ES.js +1 -26
- package/lib/locale/en-US.js +1 -26
- package/lib/locale/es-ES.js +1 -26
- package/lib/locale/fa-IR.js +1 -26
- package/lib/locale/fr-FR.js +1 -26
- package/lib/locale/ja-JP.js +1 -26
- package/lib/locale/ko-KR.js +1 -26
- package/lib/locale/ru-RU.js +1 -26
- package/lib/locale/sk-SK.js +1 -26
- package/lib/locale/vi-VN.js +1 -26
- package/lib/locale/zh-CN.js +1 -26
- package/lib/locale/zh-TW.js +1 -26
- package/lib/types/commands/commands/add-link.command.d.ts +16 -1
- package/lib/types/commands/commands/delete-link.command.d.ts +16 -1
- package/lib/types/commands/commands/update-link.command.d.ts +16 -1
- package/lib/types/commands/operations/popup.operation.d.ts +16 -1
- package/lib/types/config/config.d.ts +16 -1
- package/lib/types/controllers/doc-hyper-link-selection.controller.d.ts +15 -0
- package/lib/types/controllers/render-controllers/hyper-link-event.render-controller.d.ts +19 -3
- package/lib/types/controllers/render-controllers/render.controller.d.ts +18 -2
- package/lib/types/controllers/ui.controller.d.ts +17 -1
- 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 +17 -2
- package/lib/types/menu/schema.d.ts +16 -1
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/hyper-link-popup.service.d.ts +19 -3
- package/lib/umd/index.js +24 -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 +13 -12
package/lib/index.js
CHANGED
|
@@ -1,850 +1,24 @@
|
|
|
1
|
-
|
|
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
|
-
rangeId: s,
|
|
27
|
-
rangeType: D.HYPERLINK,
|
|
28
|
-
properties: {
|
|
29
|
-
url: t
|
|
30
|
-
},
|
|
31
|
-
unitId: i,
|
|
32
|
-
selections: r
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
return c ? o.syncExecuteCommand(c.id, c.params) : !1;
|
|
36
|
-
}
|
|
37
|
-
}, Pe = {
|
|
38
|
-
id: "docs.command.update-hyper-link",
|
|
39
|
-
type: R.COMMAND,
|
|
40
|
-
handler(n, e) {
|
|
41
|
-
var p;
|
|
42
|
-
if (!e)
|
|
43
|
-
return !1;
|
|
44
|
-
const { unitId: t, payload: i, segmentId: r, linkId: o } = e, s = n.get(x), c = n.get(k), u = n.get(M).getActiveTextRange(), v = c.getUnit(t, I.UNIVER_DOC);
|
|
45
|
-
if (!u || !v)
|
|
46
|
-
return !1;
|
|
47
|
-
const g = (p = Se(v.getSelfOrHeaderFooterModel(r).getBody(), u.startOffset, u.endOffset).textRuns) == null ? void 0 : p[0];
|
|
48
|
-
g && (g.ed = e.label.length + 1);
|
|
49
|
-
const d = Je(n, {
|
|
50
|
-
unitId: t,
|
|
51
|
-
body: {
|
|
52
|
-
dataStream: `${e.label}`,
|
|
53
|
-
customRanges: [{
|
|
54
|
-
rangeId: o,
|
|
55
|
-
rangeType: D.HYPERLINK,
|
|
56
|
-
startIndex: 0,
|
|
57
|
-
endIndex: e.label.length + 1,
|
|
58
|
-
properties: {
|
|
59
|
-
url: i
|
|
60
|
-
}
|
|
61
|
-
}],
|
|
62
|
-
textRuns: g ? [g] : void 0
|
|
63
|
-
},
|
|
64
|
-
selection: {
|
|
65
|
-
startOffset: u.startOffset,
|
|
66
|
-
endOffset: u.endOffset,
|
|
67
|
-
collapsed: !1,
|
|
68
|
-
segmentId: r
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return d ? s.syncExecuteCommand(d.id, d.params) : !1;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
function Pn(n) {
|
|
75
|
-
return /^[a-zA-Z]+:\/\//.test(n);
|
|
76
|
-
}
|
|
77
|
-
function Rn(n) {
|
|
78
|
-
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n);
|
|
79
|
-
}
|
|
80
|
-
function Mn(n) {
|
|
81
|
-
return Pn(n) ? n : Rn(n) ? `mailto://${n}` : `https://${n}`;
|
|
82
|
-
}
|
|
83
|
-
const K = () => {
|
|
84
|
-
const n = C(S), e = C(ye), t = Le(n.editingLink$), i = C(x), r = C(k), o = C(M), [s, c] = G(""), [l, u] = G(""), [v, f] = G(!1), g = Ae.isLegalUrl(s), d = t ? r.getUnit(t.unitId, I.UNIVER_DOC) : r.getCurrentUnitForType(I.UNIVER_DOC);
|
|
85
|
-
xn(() => {
|
|
86
|
-
var oe, se, ce, de, ae, le, ue, pe, ge;
|
|
87
|
-
const a = o.getActiveTextRange();
|
|
88
|
-
if (!a)
|
|
89
|
-
return;
|
|
90
|
-
if (t) {
|
|
91
|
-
const T = (oe = d == null ? void 0 : d.getSelfOrHeaderFooterModel(t.segmentId)) == null ? void 0 : oe.getBody(), H = (se = T == null ? void 0 : T.customRanges) == null ? void 0 : se.find((W) => (t == null ? void 0 : t.linkId) === W.rangeId && W.startIndex === t.startIndex && W.endIndex === t.endIndex);
|
|
92
|
-
d && H && (c((de = (ce = H.properties) == null ? void 0 : ce.url) != null ? de : ""), u(he.transform.getPlainText(Se(T, H.startIndex, H.endIndex + 1).dataStream)));
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const y = (ae = d == null ? void 0 : d.getSelfOrHeaderFooterModel(a.segmentId)) == null ? void 0 : ae.getBody(), re = y ? a : null, U = re && ((ue = he.customRange.getCustomRangesInterestsWithSelection(re, (le = y == null ? void 0 : y.customRanges) != null ? le : [])) == null ? void 0 : ue[0]);
|
|
96
|
-
d && U && c((ge = (pe = U == null ? void 0 : U.properties) == null ? void 0 : pe.url) != null ? ge : "");
|
|
97
|
-
}, [d, t, o, r]);
|
|
98
|
-
const p = () => {
|
|
99
|
-
n.hideEditPopup();
|
|
100
|
-
}, _ = () => {
|
|
101
|
-
if (f(!0), !g || !d)
|
|
102
|
-
return;
|
|
103
|
-
const a = Mn(s);
|
|
104
|
-
if (!t)
|
|
105
|
-
i.executeCommand(we.id, {
|
|
106
|
-
unitId: d.getUnitId(),
|
|
107
|
-
payload: a
|
|
108
|
-
});
|
|
109
|
-
else {
|
|
110
|
-
if (!l)
|
|
111
|
-
return;
|
|
112
|
-
i.executeCommand(Pe.id, {
|
|
113
|
-
unitId: d.getUnitId(),
|
|
114
|
-
payload: a,
|
|
115
|
-
linkId: t.linkId,
|
|
116
|
-
label: l,
|
|
117
|
-
segmentId: t.segmentId
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
n.hideEditPopup();
|
|
121
|
-
};
|
|
122
|
-
if (d)
|
|
123
|
-
return /* @__PURE__ */ O(
|
|
124
|
-
"div",
|
|
125
|
-
{
|
|
126
|
-
className: xe("univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-white univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900", ke),
|
|
127
|
-
children: [
|
|
128
|
-
/* @__PURE__ */ O("div", { children: [
|
|
129
|
-
t ? /* @__PURE__ */ h(
|
|
130
|
-
fe,
|
|
131
|
-
{
|
|
132
|
-
label: e.t("docLink.edit.label"),
|
|
133
|
-
error: v && !l ? e.t("docLink.edit.labelError") : "",
|
|
134
|
-
children: /* @__PURE__ */ h(
|
|
135
|
-
me,
|
|
136
|
-
{
|
|
137
|
-
value: l,
|
|
138
|
-
onChange: u,
|
|
139
|
-
autoFocus: !0,
|
|
140
|
-
onKeyDown: (a) => {
|
|
141
|
-
a.keyCode === X.ENTER && _();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
) : null,
|
|
147
|
-
/* @__PURE__ */ h(
|
|
148
|
-
fe,
|
|
149
|
-
{
|
|
150
|
-
label: e.t("docLink.edit.address"),
|
|
151
|
-
error: v && !g ? e.t("docLink.edit.addressError") : "",
|
|
152
|
-
children: /* @__PURE__ */ h(
|
|
153
|
-
me,
|
|
154
|
-
{
|
|
155
|
-
value: s,
|
|
156
|
-
onChange: c,
|
|
157
|
-
autoFocus: !0,
|
|
158
|
-
onKeyDown: (a) => {
|
|
159
|
-
a.keyCode === X.ENTER && _();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
)
|
|
165
|
-
] }),
|
|
166
|
-
/* @__PURE__ */ O("div", { className: "univer-flex univer-justify-end univer-gap-3", children: [
|
|
167
|
-
/* @__PURE__ */ h(Ie, { onClick: p, children: e.t("docLink.edit.cancel") }),
|
|
168
|
-
/* @__PURE__ */ h(
|
|
169
|
-
Ie,
|
|
170
|
-
{
|
|
171
|
-
variant: "primary",
|
|
172
|
-
disabled: !s,
|
|
173
|
-
onClick: _,
|
|
174
|
-
children: e.t("docLink.edit.confirm")
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
] })
|
|
178
|
-
]
|
|
179
|
-
}
|
|
180
|
-
);
|
|
181
|
-
};
|
|
182
|
-
K.componentKey = "docs-hyper-link-edit";
|
|
183
|
-
function $({ ref: n, ...e }) {
|
|
184
|
-
const { icon: t, id: i, className: r, extend: o, ...s } = e, c = `univerjs-icon univerjs-icon-${i} ${r || ""}`.trim(), l = kn(`_${En()}`);
|
|
185
|
-
return Re(t, `${i}`, {
|
|
186
|
-
defIds: t.defIds,
|
|
187
|
-
idSuffix: l.current
|
|
188
|
-
}, {
|
|
189
|
-
ref: n,
|
|
190
|
-
className: c,
|
|
191
|
-
...s
|
|
192
|
-
}, o);
|
|
193
|
-
}
|
|
194
|
-
function Re(n, e, t, i, r) {
|
|
195
|
-
return N(n.tag, {
|
|
196
|
-
key: e,
|
|
197
|
-
...bn(n, t, r),
|
|
198
|
-
...i
|
|
199
|
-
}, (Dn(n, t).children || []).map((o, s) => Re(o, `${e}-${n.tag}-${s}`, t, void 0, r)));
|
|
200
|
-
}
|
|
201
|
-
function bn(n, e, t) {
|
|
202
|
-
const i = { ...n.attrs };
|
|
203
|
-
t != null && t.colorChannel1 && i.fill === "colorChannel1" && (i.fill = t.colorChannel1), n.tag === "mask" && i.id && (i.id = i.id + e.idSuffix), Object.entries(i).forEach(([o, s]) => {
|
|
204
|
-
o === "mask" && typeof s == "string" && (i[o] = s.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
|
|
205
|
-
});
|
|
206
|
-
const { defIds: r } = e;
|
|
207
|
-
return !r || r.length === 0 || (n.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(([o, s]) => {
|
|
208
|
-
typeof s == "string" && (i[o] = s.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
|
|
209
|
-
})), i;
|
|
210
|
-
}
|
|
211
|
-
function Dn(n, e) {
|
|
212
|
-
var i;
|
|
213
|
-
const { defIds: t } = e;
|
|
214
|
-
return !t || t.length === 0 ? n : n.tag === "defs" && ((i = n.children) != null && i.length) ? {
|
|
215
|
-
...n,
|
|
216
|
-
children: n.children.map((r) => typeof r.attrs.id == "string" && t && t.includes(r.attrs.id) ? {
|
|
217
|
-
...r,
|
|
218
|
-
attrs: {
|
|
219
|
-
...r.attrs,
|
|
220
|
-
id: r.attrs.id + e.idSuffix
|
|
221
|
-
}
|
|
222
|
-
} : r)
|
|
223
|
-
} : n;
|
|
224
|
-
}
|
|
225
|
-
function En() {
|
|
226
|
-
return Math.random().toString(36).substring(2, 8);
|
|
227
|
-
}
|
|
228
|
-
$.displayName = "UniverIcon";
|
|
229
|
-
const Nn = {
|
|
230
|
-
tag: "svg",
|
|
231
|
-
attrs: {
|
|
232
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
233
|
-
fill: "none",
|
|
234
|
-
viewBox: "0 0 16 16",
|
|
235
|
-
width: "1em",
|
|
236
|
-
height: "1em"
|
|
237
|
-
},
|
|
238
|
-
children: [{
|
|
239
|
-
tag: "path",
|
|
240
|
-
attrs: {
|
|
241
|
-
fill: "currentColor",
|
|
242
|
-
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",
|
|
243
|
-
fillRule: "evenodd",
|
|
244
|
-
clipRule: "evenodd"
|
|
245
|
-
}
|
|
246
|
-
}]
|
|
247
|
-
}, Me = Z(function(e, t) {
|
|
248
|
-
return N($, Object.assign({}, e, {
|
|
249
|
-
id: "copy-icon",
|
|
250
|
-
ref: t,
|
|
251
|
-
icon: Nn
|
|
252
|
-
}));
|
|
253
|
-
});
|
|
254
|
-
Me.displayName = "CopyIcon";
|
|
255
|
-
const $n = {
|
|
256
|
-
tag: "svg",
|
|
257
|
-
attrs: {
|
|
258
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
259
|
-
fill: "none",
|
|
260
|
-
viewBox: "0 0 16 16",
|
|
261
|
-
width: "1em",
|
|
262
|
-
height: "1em"
|
|
263
|
-
},
|
|
264
|
-
children: [{
|
|
265
|
-
tag: "path",
|
|
266
|
-
attrs: {
|
|
267
|
-
fill: "currentColor",
|
|
268
|
-
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"
|
|
269
|
-
}
|
|
270
|
-
}, {
|
|
271
|
-
tag: "path",
|
|
272
|
-
attrs: {
|
|
273
|
-
fill: "currentColor",
|
|
274
|
-
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"
|
|
275
|
-
}
|
|
276
|
-
}]
|
|
277
|
-
}, ie = Z(function(e, t) {
|
|
278
|
-
return N($, Object.assign({}, e, {
|
|
279
|
-
id: "link-icon",
|
|
280
|
-
ref: t,
|
|
281
|
-
icon: $n
|
|
282
|
-
}));
|
|
283
|
-
});
|
|
284
|
-
ie.displayName = "LinkIcon";
|
|
285
|
-
const Un = {
|
|
286
|
-
tag: "svg",
|
|
287
|
-
attrs: {
|
|
288
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
289
|
-
fill: "none",
|
|
290
|
-
viewBox: "0 0 16 17",
|
|
291
|
-
width: "1em",
|
|
292
|
-
height: "1em"
|
|
293
|
-
},
|
|
294
|
-
children: [
|
|
295
|
-
{
|
|
296
|
-
tag: "path",
|
|
297
|
-
attrs: {
|
|
298
|
-
fill: "currentColor",
|
|
299
|
-
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"
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
tag: "path",
|
|
304
|
-
attrs: {
|
|
305
|
-
fill: "currentColor",
|
|
306
|
-
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"
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
tag: "path",
|
|
311
|
-
attrs: {
|
|
312
|
-
fill: "currentColor",
|
|
313
|
-
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"
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
]
|
|
317
|
-
}, be = Z(function(e, t) {
|
|
318
|
-
return N($, Object.assign({}, e, {
|
|
319
|
-
id: "unlink-icon",
|
|
320
|
-
ref: t,
|
|
321
|
-
icon: Un
|
|
322
|
-
}));
|
|
323
|
-
});
|
|
324
|
-
be.displayName = "UnlinkIcon";
|
|
325
|
-
const Tn = {
|
|
326
|
-
tag: "svg",
|
|
327
|
-
attrs: {
|
|
328
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
329
|
-
fill: "none",
|
|
330
|
-
viewBox: "0 0 17 16",
|
|
331
|
-
width: "1em",
|
|
332
|
-
height: "1em"
|
|
333
|
-
},
|
|
334
|
-
children: [{
|
|
335
|
-
tag: "path",
|
|
336
|
-
attrs: {
|
|
337
|
-
fill: "currentColor",
|
|
338
|
-
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",
|
|
339
|
-
fillRule: "evenodd",
|
|
340
|
-
clipRule: "evenodd"
|
|
341
|
-
}
|
|
342
|
-
}, {
|
|
343
|
-
tag: "path",
|
|
344
|
-
attrs: {
|
|
345
|
-
fill: "currentColor",
|
|
346
|
-
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"
|
|
347
|
-
}
|
|
348
|
-
}]
|
|
349
|
-
}, De = Z(function(e, t) {
|
|
350
|
-
return N($, Object.assign({}, e, {
|
|
351
|
-
id: "write-icon",
|
|
352
|
-
ref: t,
|
|
353
|
-
icon: Tn
|
|
354
|
-
}));
|
|
355
|
-
});
|
|
356
|
-
De.displayName = "WriteIcon";
|
|
357
|
-
const Ee = {
|
|
358
|
-
type: R.COMMAND,
|
|
359
|
-
id: "docs.command.delete-hyper-link",
|
|
360
|
-
async handler(n, e) {
|
|
361
|
-
if (!e)
|
|
362
|
-
return !1;
|
|
363
|
-
const { unitId: t, linkId: i, segmentId: r } = e, o = n.get(x), s = Qe(n, { unitId: t, rangeId: i, segmentId: r });
|
|
364
|
-
return s ? await o.syncExecuteCommand(s.id, s.params) : !1;
|
|
365
|
-
}
|
|
366
|
-
}, Ne = (n) => {
|
|
367
|
-
const e = n.get(M), t = n.get(k), i = e.getTextRanges();
|
|
368
|
-
if (!(i != null && i.length))
|
|
369
|
-
return !0;
|
|
370
|
-
const r = i[0];
|
|
371
|
-
return !!(!t.getCurrentUnitForType(I.UNIVER_DOC) || !r || r.collapsed);
|
|
372
|
-
}, w = {
|
|
373
|
-
type: R.OPERATION,
|
|
374
|
-
id: "doc.operation.show-hyper-link-edit-popup",
|
|
375
|
-
handler(n, e) {
|
|
376
|
-
var s;
|
|
377
|
-
const t = e == null ? void 0 : e.link, i = n.get(k);
|
|
378
|
-
if (Ne(n) && !t)
|
|
379
|
-
return !1;
|
|
380
|
-
const r = n.get(S), o = (t == null ? void 0 : t.unitId) || ((s = i.getCurrentUnitForType(I.UNIVER_DOC)) == null ? void 0 : s.getUnitId());
|
|
381
|
-
return o ? (r.showEditPopup(o, t), !0) : !1;
|
|
382
|
-
}
|
|
383
|
-
}, ee = {
|
|
384
|
-
type: R.OPERATION,
|
|
385
|
-
id: "doc.operation.toggle-hyper-link-info-popup",
|
|
386
|
-
handler(n, e) {
|
|
387
|
-
const t = n.get(S);
|
|
388
|
-
return e ? (t.showInfoPopup(e), !0) : (t.hideInfoPopup(), !0);
|
|
389
|
-
}
|
|
390
|
-
}, $e = {
|
|
391
|
-
type: R.OPERATION,
|
|
392
|
-
id: "doc.operation.click-hyper-link",
|
|
393
|
-
handler(n, e) {
|
|
394
|
-
var u, v, f;
|
|
395
|
-
if (!e)
|
|
396
|
-
return !1;
|
|
397
|
-
const { unitId: t, linkId: i, segmentId: r } = e, s = n.get(k).getUnit(t, I.UNIVER_DOC), c = s == null ? void 0 : s.getSelfOrHeaderFooterModel(r).getBody(), l = (f = (v = (u = c == null ? void 0 : c.customRanges) == null ? void 0 : u.find((g) => g.rangeId === i && g.rangeType === D.HYPERLINK)) == null ? void 0 : v.properties) == null ? void 0 : f.url;
|
|
398
|
-
return l && window.open(l, "_blank", "noopener noreferrer"), !0;
|
|
399
|
-
}
|
|
400
|
-
}, F = () => {
|
|
401
|
-
var _, a;
|
|
402
|
-
const n = C(S), e = C(x), t = C(gn), i = C(ye), r = Le(n.showingLink$), o = C(k);
|
|
403
|
-
if (!r)
|
|
404
|
-
return null;
|
|
405
|
-
const { unitId: s, linkId: c, segmentId: l, startIndex: u, endIndex: v } = r, f = o.getUnit(s, I.UNIVER_DOC), g = f == null ? void 0 : f.getSelfOrHeaderFooterModel(l).getBody(), d = (_ = g == null ? void 0 : g.customRanges) == null ? void 0 : _.find((y) => y.rangeId === c && y.rangeType === D.HYPERLINK && y.startIndex === u && y.endIndex === v);
|
|
406
|
-
if (!d)
|
|
407
|
-
return null;
|
|
408
|
-
const p = (a = d.properties) == null ? void 0 : a.url;
|
|
409
|
-
return /* @__PURE__ */ O(
|
|
410
|
-
"div",
|
|
411
|
-
{
|
|
412
|
-
className: xe("univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow dark:!univer-bg-gray-900", ke),
|
|
413
|
-
onClick: () => {
|
|
414
|
-
n.hideInfoPopup();
|
|
415
|
-
},
|
|
416
|
-
children: [
|
|
417
|
-
/* @__PURE__ */ O(
|
|
418
|
-
"div",
|
|
419
|
-
{
|
|
420
|
-
className: "univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-500",
|
|
421
|
-
onClick: () => window.open(p, void 0, "noopener noreferrer"),
|
|
422
|
-
children: [
|
|
423
|
-
/* @__PURE__ */ h(
|
|
424
|
-
"div",
|
|
425
|
-
{
|
|
426
|
-
className: "univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",
|
|
427
|
-
children: /* @__PURE__ */ h(ie, {})
|
|
428
|
-
}
|
|
429
|
-
),
|
|
430
|
-
/* @__PURE__ */ h(j, { showIfEllipsis: !0, title: p, children: /* @__PURE__ */ h("span", { className: "univer-flex-1 univer-truncate", children: p }) })
|
|
431
|
-
]
|
|
432
|
-
}
|
|
433
|
-
),
|
|
434
|
-
/* @__PURE__ */ O("div", { className: "univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center", children: [
|
|
435
|
-
/* @__PURE__ */ h(
|
|
436
|
-
"div",
|
|
437
|
-
{
|
|
438
|
-
className: "univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base",
|
|
439
|
-
onClick: () => {
|
|
440
|
-
navigator.clipboard.writeText(p), t.show({
|
|
441
|
-
content: i.t("docLink.info.coped"),
|
|
442
|
-
type: pn.Info
|
|
443
|
-
});
|
|
444
|
-
},
|
|
445
|
-
children: /* @__PURE__ */ h(j, { placement: "bottom", title: i.t("docLink.info.copy"), children: /* @__PURE__ */ h(Me, {}) })
|
|
446
|
-
}
|
|
447
|
-
),
|
|
448
|
-
/* @__PURE__ */ h(
|
|
449
|
-
"div",
|
|
450
|
-
{
|
|
451
|
-
className: "univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base",
|
|
452
|
-
onClick: () => {
|
|
453
|
-
e.executeCommand(w.id, {
|
|
454
|
-
link: r
|
|
455
|
-
});
|
|
456
|
-
},
|
|
457
|
-
children: /* @__PURE__ */ h(j, { placement: "bottom", title: i.t("docLink.info.edit"), children: /* @__PURE__ */ h(De, {}) })
|
|
458
|
-
}
|
|
459
|
-
),
|
|
460
|
-
/* @__PURE__ */ h(
|
|
461
|
-
"div",
|
|
462
|
-
{
|
|
463
|
-
className: "univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base",
|
|
464
|
-
onClick: () => {
|
|
465
|
-
e.executeCommand(Ee.id, {
|
|
466
|
-
unitId: s,
|
|
467
|
-
linkId: d.rangeId,
|
|
468
|
-
segmentId: l
|
|
469
|
-
});
|
|
470
|
-
},
|
|
471
|
-
children: /* @__PURE__ */ h(j, { placement: "bottom", title: i.t("docLink.info.cancel"), children: /* @__PURE__ */ h(be, {}) })
|
|
472
|
-
}
|
|
473
|
-
)
|
|
474
|
-
] })
|
|
475
|
-
]
|
|
476
|
-
}
|
|
477
|
-
);
|
|
478
|
-
};
|
|
479
|
-
F.componentKey = "univer.doc.link-info-popup";
|
|
480
|
-
var Hn = Object.getOwnPropertyDescriptor, jn = (n, e, t, i) => {
|
|
481
|
-
for (var r = i > 1 ? void 0 : i ? Hn(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
482
|
-
(s = n[o]) && (r = s(r) || r);
|
|
483
|
-
return r;
|
|
484
|
-
}, z = (n, e) => (t, i) => e(t, i, n);
|
|
485
|
-
let S = class extends E {
|
|
486
|
-
constructor(e, t, i) {
|
|
487
|
-
super();
|
|
488
|
-
L(this, "_editingLink$", new ve(null));
|
|
489
|
-
L(this, "_showingLink$", new ve(null));
|
|
490
|
-
L(this, "editingLink$", this._editingLink$.asObservable());
|
|
491
|
-
L(this, "showingLink$", this._showingLink$.asObservable());
|
|
492
|
-
L(this, "_editPopup", null);
|
|
493
|
-
L(this, "_infoPopup", null);
|
|
494
|
-
this._docCanvasPopupManagerService = e, this._textSelectionManagerService = t, this._univerInstanceService = i, this.disposeWithMe(() => {
|
|
495
|
-
this._editingLink$.complete(), this._showingLink$.complete();
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
get editing() {
|
|
499
|
-
return this._editingLink$.value;
|
|
500
|
-
}
|
|
501
|
-
get showing() {
|
|
502
|
-
return this._showingLink$.value;
|
|
503
|
-
}
|
|
504
|
-
showEditPopup(e, t) {
|
|
505
|
-
this._editPopup && this._editPopup.dispose(), this._editingLink$.next(t);
|
|
506
|
-
const i = this._textSelectionManagerService.getTextRanges({ unitId: e, subUnitId: e });
|
|
507
|
-
let r = i == null ? void 0 : i[i.length - 1];
|
|
508
|
-
if (t) {
|
|
509
|
-
const { segmentId: o, segmentPage: s, startIndex: c, endIndex: l } = t;
|
|
510
|
-
r = {
|
|
511
|
-
collapsed: !1,
|
|
512
|
-
startOffset: c,
|
|
513
|
-
endOffset: l + 1,
|
|
514
|
-
segmentId: o,
|
|
515
|
-
segmentPage: s
|
|
516
|
-
}, this._textSelectionManagerService.replaceDocRanges([{
|
|
517
|
-
startOffset: c,
|
|
518
|
-
endOffset: l + 1
|
|
519
|
-
}]);
|
|
520
|
-
}
|
|
521
|
-
return r ? (this._editPopup = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
522
|
-
r,
|
|
523
|
-
{
|
|
524
|
-
componentKey: K.componentKey,
|
|
525
|
-
direction: "bottom"
|
|
526
|
-
},
|
|
527
|
-
e
|
|
528
|
-
), this._editPopup) : null;
|
|
529
|
-
}
|
|
530
|
-
hideEditPopup() {
|
|
531
|
-
var e;
|
|
532
|
-
this._editingLink$.next(null), (e = this._editPopup) == null || e.dispose();
|
|
533
|
-
}
|
|
534
|
-
showInfoPopup(e) {
|
|
535
|
-
var u, v, f, g, d, p;
|
|
536
|
-
const { linkId: t, unitId: i, segmentId: r, segmentPage: o, startIndex: s, endIndex: c } = e;
|
|
537
|
-
if (!(((u = this.showing) == null ? void 0 : u.linkId) === t && ((v = this.showing) == null ? void 0 : v.unitId) === i && ((f = this.showing) == null ? void 0 : f.segmentId) === r && ((g = this.showing) == null ? void 0 : g.segmentPage) === o && ((d = this.showing) == null ? void 0 : d.startIndex) === s && ((p = this.showing) == null ? void 0 : p.endIndex) === c || (this._infoPopup && this._infoPopup.dispose(), !this._univerInstanceService.getUnit(i, I.UNIVER_DOC))))
|
|
538
|
-
return this._showingLink$.next({ unitId: i, linkId: t, segmentId: r, segmentPage: o, startIndex: s, endIndex: c }), this._infoPopup = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
539
|
-
{
|
|
540
|
-
collapsed: !1,
|
|
541
|
-
startOffset: s,
|
|
542
|
-
endOffset: c + 1,
|
|
543
|
-
segmentId: r,
|
|
544
|
-
segmentPage: o
|
|
545
|
-
},
|
|
546
|
-
{
|
|
547
|
-
componentKey: F.componentKey,
|
|
548
|
-
direction: "top-center",
|
|
549
|
-
multipleDirection: "top",
|
|
550
|
-
onClickOutside: () => {
|
|
551
|
-
this.hideInfoPopup();
|
|
552
|
-
}
|
|
553
|
-
},
|
|
554
|
-
i
|
|
555
|
-
), this._infoPopup;
|
|
556
|
-
}
|
|
557
|
-
hideInfoPopup() {
|
|
558
|
-
var e;
|
|
559
|
-
this._showingLink$.next(null), (e = this._infoPopup) == null || e.dispose();
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
S = jn([
|
|
563
|
-
z(0, m(rn)),
|
|
564
|
-
z(1, m(M)),
|
|
565
|
-
z(2, k)
|
|
566
|
-
], S);
|
|
567
|
-
var An = Object.getOwnPropertyDescriptor, Kn = (n, e, t, i) => {
|
|
568
|
-
for (var r = i > 1 ? void 0 : i ? An(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
569
|
-
(s = n[o]) && (r = s(r) || r);
|
|
570
|
-
return r;
|
|
571
|
-
}, q = (n, e) => (t, i) => e(t, i, n);
|
|
572
|
-
let B = class extends E {
|
|
573
|
-
constructor(n, e, t) {
|
|
574
|
-
super(), this._commandService = n, this._univerInstanceService = e, this._docHyperLinkService = t, this._initSelectionChange();
|
|
575
|
-
}
|
|
576
|
-
_initSelectionChange() {
|
|
577
|
-
this.disposeWithMe(
|
|
578
|
-
this._commandService.onCommandExecuted((n) => {
|
|
579
|
-
var e, t, i;
|
|
580
|
-
if (n.id === Xe.id) {
|
|
581
|
-
const r = n.params, { unitId: o, ranges: s, segmentId: c } = r, l = this._univerInstanceService.getUnit(o, I.UNIVER_DOC), u = s[0];
|
|
582
|
-
if (u && l) {
|
|
583
|
-
const { startOffset: v, endOffset: f, collapsed: g, segmentPage: d } = u, p = (t = (e = l.getSelfOrHeaderFooterModel(c)) == null ? void 0 : e.getBody()) == null ? void 0 : t.customRanges;
|
|
584
|
-
if (g) {
|
|
585
|
-
const _ = (i = p == null ? void 0 : p.findIndex((a) => a.startIndex < v && a.endIndex > f - 1)) != null ? i : -1;
|
|
586
|
-
if (_ > -1) {
|
|
587
|
-
const a = p[_];
|
|
588
|
-
this._docHyperLinkService.showInfoPopup({ unitId: o, linkId: a.rangeId, segmentId: c, segmentPage: d, startIndex: a.startIndex, endIndex: a.endIndex });
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
} else if (p == null ? void 0 : p.find((a) => a.startIndex <= v && a.endIndex >= f - 1))
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
this._docHyperLinkService.hideInfoPopup(), this._docHyperLinkService.hideEditPopup();
|
|
595
|
-
}
|
|
596
|
-
})
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
B = Kn([
|
|
601
|
-
q(0, x),
|
|
602
|
-
q(1, k),
|
|
603
|
-
q(2, m(S))
|
|
604
|
-
], B);
|
|
605
|
-
var Fn = Object.getOwnPropertyDescriptor, Bn = (n, e, t, i) => {
|
|
606
|
-
for (var r = i > 1 ? void 0 : i ? Fn(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
607
|
-
(s = n[o]) && (r = s(r) || r);
|
|
608
|
-
return r;
|
|
609
|
-
}, b = (n, e) => (t, i) => e(t, i, n);
|
|
610
|
-
let ne = class extends E {
|
|
611
|
-
constructor(n, e, t, i, r, o) {
|
|
612
|
-
super(), this._context = n, this._docEventManagerService = e, this._commandService = t, this._hyperLinkPopupService = i, this._docSkeletonManagerService = r, this._docSelectionManagerService = o, !(this._context.unitId === Ke || this._context.unitId === Fe) && (this._initHover(), this._initClick());
|
|
613
|
-
}
|
|
614
|
-
get _skeleton() {
|
|
615
|
-
return this._docSkeletonManagerService.getSkeleton();
|
|
616
|
-
}
|
|
617
|
-
_hideInfoPopup() {
|
|
618
|
-
this._hyperLinkPopupService.showing && this._commandService.executeCommand(
|
|
619
|
-
ee.id
|
|
620
|
-
);
|
|
621
|
-
}
|
|
622
|
-
_initHover() {
|
|
623
|
-
this.disposeWithMe(
|
|
624
|
-
this._docEventManagerService.hoverCustomRanges$.subscribe((n) => {
|
|
625
|
-
var r;
|
|
626
|
-
const e = n.find((o) => o.range.rangeType === D.HYPERLINK), t = this._docSelectionManagerService.getTextRanges(), i = t == null ? void 0 : t[0].segmentId;
|
|
627
|
-
if (((r = e == null ? void 0 : e.segmentId) != null ? r : "") !== i) {
|
|
628
|
-
this._hideInfoPopup();
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
e ? this._commandService.executeCommand(
|
|
632
|
-
ee.id,
|
|
633
|
-
{
|
|
634
|
-
unitId: this._context.unitId,
|
|
635
|
-
linkId: e.range.rangeId,
|
|
636
|
-
segmentId: e.segmentId,
|
|
637
|
-
segmentPage: e.segmentPageIndex,
|
|
638
|
-
rangeId: e.range.rangeId,
|
|
639
|
-
startIndex: e.range.startIndex,
|
|
640
|
-
endIndex: e.range.endIndex
|
|
641
|
-
}
|
|
642
|
-
) : this._hideInfoPopup();
|
|
643
|
-
})
|
|
644
|
-
);
|
|
645
|
-
}
|
|
646
|
-
_initClick() {
|
|
647
|
-
this.disposeWithMe(
|
|
648
|
-
this._docEventManagerService.clickCustomRanges$.subscribe((n) => {
|
|
649
|
-
const e = n.range;
|
|
650
|
-
e && this._commandService.executeCommand(
|
|
651
|
-
$e.id,
|
|
652
|
-
{
|
|
653
|
-
unitId: this._context.unitId,
|
|
654
|
-
linkId: e.rangeId,
|
|
655
|
-
segmentId: n.segmentId
|
|
656
|
-
}
|
|
657
|
-
);
|
|
658
|
-
})
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
ne = Bn([
|
|
663
|
-
b(1, m(on)),
|
|
664
|
-
b(2, x),
|
|
665
|
-
b(3, m(S)),
|
|
666
|
-
b(4, m(en)),
|
|
667
|
-
b(5, m(M))
|
|
668
|
-
], ne);
|
|
669
|
-
var Vn = Object.getOwnPropertyDescriptor, Zn = (n, e, t, i) => {
|
|
670
|
-
for (var r = i > 1 ? void 0 : i ? Vn(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
671
|
-
(s = n[o]) && (r = s(r) || r);
|
|
672
|
-
return r;
|
|
673
|
-
}, J = (n, e) => (t, i) => e(t, i, n);
|
|
674
|
-
let te = class extends E {
|
|
675
|
-
constructor(n, e, t, i) {
|
|
676
|
-
super(), this._context = n, this._docInterceptorService = e, this._hyperLinkService = t, this._docRenderController = i, this._init(), this._initReRender();
|
|
677
|
-
}
|
|
678
|
-
_init() {
|
|
679
|
-
this._docInterceptorService.intercept(tn.CUSTOM_RANGE, {
|
|
680
|
-
handler: (n, e, t) => {
|
|
681
|
-
if (!n)
|
|
682
|
-
return t(n);
|
|
683
|
-
const { unitId: i, index: r } = e, o = this._hyperLinkService.showing;
|
|
684
|
-
if (!o)
|
|
685
|
-
return t({
|
|
686
|
-
...n,
|
|
687
|
-
active: !1
|
|
688
|
-
});
|
|
689
|
-
const { linkId: s, unitId: c, startIndex: l, endIndex: u } = o, v = c === i && n.rangeId === s && r >= l && r <= u;
|
|
690
|
-
return t({
|
|
691
|
-
...n,
|
|
692
|
-
active: v
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
_initReRender() {
|
|
698
|
-
this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(
|
|
699
|
-
dn((n, e) => (n == null ? void 0 : n.linkId) === (e == null ? void 0 : e.linkId) && (n == null ? void 0 : n.unitId) === (e == null ? void 0 : e.unitId) && (n == null ? void 0 : n.startIndex) === (e == null ? void 0 : e.startIndex)),
|
|
700
|
-
an()
|
|
701
|
-
).subscribe(([n, e]) => {
|
|
702
|
-
e ? e.unitId === this._context.unitId && this._docRenderController.reRender(e.unitId) : n && n.unitId === this._context.unitId && this._docRenderController.reRender(n.unitId);
|
|
703
|
-
}));
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
te = Zn([
|
|
707
|
-
J(1, m(nn)),
|
|
708
|
-
J(2, m(S)),
|
|
709
|
-
J(3, m(sn))
|
|
710
|
-
], te);
|
|
711
|
-
const Ue = "doc-hyper-link-icon";
|
|
712
|
-
function Ce(n) {
|
|
713
|
-
return {
|
|
714
|
-
id: w.id,
|
|
715
|
-
type: fn.BUTTON,
|
|
716
|
-
icon: Ue,
|
|
717
|
-
title: "docLink.menu.tooltip",
|
|
718
|
-
tooltip: "docLink.menu.tooltip",
|
|
719
|
-
hidden$: vn(n, I.UNIVER_DOC),
|
|
720
|
-
disabled$: new ln(function(e) {
|
|
721
|
-
const i = n.get(M).textSelection$.pipe(un(16)).subscribe(() => {
|
|
722
|
-
e.next(Ne(n));
|
|
723
|
-
});
|
|
724
|
-
return () => {
|
|
725
|
-
i.unsubscribe();
|
|
726
|
-
};
|
|
727
|
-
})
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
const Yn = {
|
|
731
|
-
id: w.id,
|
|
732
|
-
binding: hn.CTRL_COMMAND | X.K,
|
|
733
|
-
description: "docLink.menu.tooltip",
|
|
734
|
-
preconditions: cn
|
|
735
|
-
}, Wn = {
|
|
736
|
-
[_n.MEDIA]: {
|
|
737
|
-
[w.id]: {
|
|
738
|
-
order: 1,
|
|
739
|
-
menuItemFactory: Ce
|
|
740
|
-
}
|
|
741
|
-
},
|
|
742
|
-
[mn.MAIN_AREA]: {
|
|
743
|
-
[In.DATA]: {
|
|
744
|
-
[w.id]: {
|
|
745
|
-
order: 0,
|
|
746
|
-
menuItemFactory: Ce
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
var Gn = Object.getOwnPropertyDescriptor, zn = (n, e, t, i) => {
|
|
752
|
-
for (var r = i > 1 ? void 0 : i ? Gn(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
753
|
-
(s = n[o]) && (r = s(r) || r);
|
|
754
|
-
return r;
|
|
755
|
-
}, A = (n, e) => (t, i) => e(t, i, n);
|
|
756
|
-
let V = class extends E {
|
|
757
|
-
constructor(n, e, t, i) {
|
|
758
|
-
super(), this._componentManager = n, this._commandService = e, this._menuManagerService = t, this._shortcutService = i, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortcut();
|
|
759
|
-
}
|
|
760
|
-
_initComponents() {
|
|
761
|
-
[
|
|
762
|
-
[K.componentKey, K],
|
|
763
|
-
[F.componentKey, F],
|
|
764
|
-
[Ue, ie]
|
|
765
|
-
].forEach(([n, e]) => {
|
|
766
|
-
this.disposeWithMe(
|
|
767
|
-
this._componentManager.register(n, e)
|
|
768
|
-
);
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
_initCommands() {
|
|
772
|
-
[
|
|
773
|
-
we,
|
|
774
|
-
Pe,
|
|
775
|
-
Ee,
|
|
776
|
-
w,
|
|
777
|
-
ee,
|
|
778
|
-
$e
|
|
779
|
-
].forEach((n) => {
|
|
780
|
-
this._commandService.registerCommand(n);
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
_initShortcut() {
|
|
784
|
-
[Yn].forEach((n) => {
|
|
785
|
-
this._shortcutService.registerShortcut(n);
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
_initMenus() {
|
|
789
|
-
this._menuManagerService.mergeMenu(Wn);
|
|
790
|
-
}
|
|
791
|
-
};
|
|
792
|
-
V = zn([
|
|
793
|
-
A(0, m(Cn)),
|
|
794
|
-
A(1, x),
|
|
795
|
-
A(2, Sn),
|
|
796
|
-
A(3, yn)
|
|
797
|
-
], V);
|
|
798
|
-
const qn = "DOC_HYPER_LINK_UI_PLUGIN";
|
|
799
|
-
var Jn = Object.defineProperty, Qn = Object.getOwnPropertyDescriptor, Xn = (n, e, t) => e in n ? Jn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, et = (n, e, t, i) => {
|
|
800
|
-
for (var r = i > 1 ? void 0 : i ? Qn(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
801
|
-
(s = n[o]) && (r = s(r) || r);
|
|
802
|
-
return r;
|
|
803
|
-
}, Q = (n, e) => (t, i) => e(t, i, n), Y = (n, e, t) => Xn(n, typeof e != "symbol" ? e + "" : e, t);
|
|
804
|
-
let P = class extends Ye {
|
|
805
|
-
constructor(n = _e, e, t, i) {
|
|
806
|
-
super(), this._config = n, this._injector = e, this._renderManagerSrv = t, this._configService = i;
|
|
807
|
-
const { menu: r, ...o } = We(
|
|
808
|
-
{},
|
|
809
|
-
_e,
|
|
810
|
-
this._config
|
|
811
|
-
);
|
|
812
|
-
r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(wn, o);
|
|
813
|
-
}
|
|
814
|
-
onStarting() {
|
|
815
|
-
[
|
|
816
|
-
[S],
|
|
817
|
-
[V],
|
|
818
|
-
[B]
|
|
819
|
-
].forEach((e) => {
|
|
820
|
-
this._injector.add(e);
|
|
821
|
-
}), this._injector.get(V);
|
|
822
|
-
}
|
|
823
|
-
onReady() {
|
|
824
|
-
this._injector.get(B);
|
|
825
|
-
}
|
|
826
|
-
onRendered() {
|
|
827
|
-
this._initRenderModule();
|
|
828
|
-
}
|
|
829
|
-
_initRenderModule() {
|
|
830
|
-
[
|
|
831
|
-
[te],
|
|
832
|
-
[ne]
|
|
833
|
-
].forEach((n) => {
|
|
834
|
-
this._renderManagerSrv.registerRenderModule(I.UNIVER_DOC, n);
|
|
835
|
-
});
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
Y(P, "pluginName", qn);
|
|
839
|
-
Y(P, "packageName", Oe.name);
|
|
840
|
-
Y(P, "version", Oe.version);
|
|
841
|
-
Y(P, "type", I.UNIVER_DOC);
|
|
842
|
-
P = et([
|
|
843
|
-
Be(Ge),
|
|
844
|
-
Q(1, m(Ve)),
|
|
845
|
-
Q(2, ze),
|
|
846
|
-
Q(3, Ze)
|
|
847
|
-
], P);
|
|
848
|
-
export {
|
|
849
|
-
P as UniverDocsHyperLinkUIPlugin
|
|
850
|
-
};
|
|
1
|
+
import{BuildTextUtils as e,CommandType as t,CustomRangeType as n,DOCS_NORMAL_EDITOR_UNIT_ID_KEY as r,DOCS_ZEN_EDITOR_UNIT_ID_KEY as i,DependentOn as a,Disposable as o,ICommandService as s,IConfigService as c,IUniverInstanceService as l,Inject as u,Injector as d,LocaleService as f,Plugin as p,Tools as m,UniverInstanceType as h,generateRandomId as g,getBodySlice as _,merge as v}from"@univerjs/core";import{UniverDocsHyperLinkPlugin as y}from"@univerjs/docs-hyper-link";import{IRenderManagerService as b}from"@univerjs/engine-render";import{DOC_INTERCEPTOR_POINT as x,DocInterceptorService as S,DocSelectionManagerService as C,DocSkeletonManagerService as ee,SetTextSelectionsOperation as te,addCustomRangeBySelectionFactory as ne,deleteCustomRangeFactory as re,replaceSelectionFactory as ie}from"@univerjs/docs";import{DocCanvasPopManagerService as ae,DocEventManagerService as oe,DocRenderController as se,whenDocAndEditorFocused as ce}from"@univerjs/docs-ui";import{BehaviorSubject as le,Observable as ue,debounceTime as de,distinctUntilChanged as fe,pairwise as pe}from"rxjs";import{Button as me,FormLayout as he,Input as w,MessageType as ge,Tooltip as T,borderClassName as E,clsx as D}from"@univerjs/design";import{ComponentManager as _e,ContextMenuGroup as ve,ContextMenuPosition as ye,IMenuManagerService as be,IMessageService as xe,IShortcutService as Se,KeyCode as O,MenuItemType as Ce,MetaKeys as we,RibbonInsertGroup as Te,getMenuHiddenObservable as Ee,useDependency as k,useObservable as A}from"@univerjs/ui";import{useEffect as De,useState as j}from"react";import{jsx as M,jsxs as N}from"react/jsx-runtime";import{CopyIcon as Oe,LinkIcon as P,UnlinkIcon as ke,WriteIcon as Ae}from"@univerjs/icons";var je=`@univerjs/docs-hyper-link-ui`,Me=`0.18.0`;const F=`docs-hyper-link-ui.config`;Symbol(F);const I={},L={type:t.COMMAND,id:`docs.command.add-hyper-link`,async handler(e,t){if(!t)return!1;let{payload:r,unitId:i,selections:a}=t,o=e.get(s),c=ne(e,{rangeId:g(),rangeType:n.HYPERLINK,properties:{url:r},unitId:i,selections:a});return c?o.syncExecuteCommand(c.id,c.params):!1}},R={id:`docs.command.update-hyper-link`,type:t.COMMAND,handler(e,t){var r;if(!t)return!1;let{unitId:i,payload:a,segmentId:o,linkId:c}=t,u=e.get(s),d=e.get(l),f=e.get(C).getActiveTextRange(),p=d.getUnit(i,h.UNIVER_DOC);if(!f||!p)return!1;let m=(r=_(p.getSelfOrHeaderFooterModel(o).getBody(),f.startOffset,f.endOffset).textRuns)==null?void 0:r[0];m&&(m.ed=t.label.length+1);let g=ie(e,{unitId:i,body:{dataStream:`${t.label}`,customRanges:[{rangeId:c,rangeType:n.HYPERLINK,startIndex:0,endIndex:t.label.length+1,properties:{url:a}}],textRuns:m?[m]:void 0},selection:{startOffset:f.startOffset,endOffset:f.endOffset,collapsed:!1,segmentId:o}});return g?u.syncExecuteCommand(g.id,g.params):!1}};function Ne(e){return/^[a-zA-Z]+:\/\//.test(e)}function Pe(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Fe(e){return Ne(e)?e:Pe(e)?`mailto://${e}`:`https://${e}`}const z=()=>{let t=k(J),n=k(f),r=A(t.editingLink$),i=k(s),a=k(l),o=k(C),[c,u]=j(``),[d,p]=j(``),[g,v]=j(!1),y=m.isLegalUrl(c),b=r?a.getUnit(r.unitId,h.UNIVER_DOC):a.getCurrentUnitForType(h.UNIVER_DOC);De(()=>{var t,n,i;let a=o.getActiveTextRange();if(!a)return;if(r){var s,c;let t=b==null||(s=b.getSelfOrHeaderFooterModel(r.segmentId))==null?void 0:s.getBody(),n=t==null||(c=t.customRanges)==null?void 0:c.find(e=>(r==null?void 0:r.linkId)===e.rangeId&&e.startIndex===r.startIndex&&e.endIndex===r.endIndex);if(b&&n){var l,d;u((l=(d=n.properties)==null?void 0:d.url)==null?``:l),p(e.transform.getPlainText(_(t,n.startIndex,n.endIndex+1).dataStream))}return}let f=b==null||(t=b.getSelfOrHeaderFooterModel(a.segmentId))==null?void 0:t.getBody(),m=f?a:null,h=m&&((n=e.customRange.getCustomRangesInterestsWithSelection(m,(i=f==null?void 0:f.customRanges)==null?[]:i))==null?void 0:n[0]);if(b&&h){var g,v;u((g=h==null||(v=h.properties)==null?void 0:v.url)==null?``:g)}},[b,r,o,a]);let x=()=>{t.hideEditPopup()},S=()=>{if(v(!0),!y||!b)return;let e=Fe(c);if(!r)i.executeCommand(L.id,{unitId:b.getUnitId(),payload:e});else{if(!d)return;i.executeCommand(R.id,{unitId:b.getUnitId(),payload:e,linkId:r.linkId,label:d,segmentId:r.segmentId})}t.hideEditPopup()};if(b)return N(`div`,{className:D(`
|
|
2
|
+
univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-white univer-px-6 univer-py-5 univer-shadow
|
|
3
|
+
dark:!univer-bg-gray-900
|
|
4
|
+
`,E),children:[N(`div`,{children:[r?M(he,{label:n.t(`docLink.edit.label`),error:g&&!d?n.t(`docLink.edit.labelError`):``,children:M(w,{value:d,onChange:p,autoFocus:!0,onKeyDown:e=>{e.keyCode===O.ENTER&&S()}})}):null,M(he,{label:n.t(`docLink.edit.address`),error:g&&!y?n.t(`docLink.edit.addressError`):``,children:M(w,{value:c,onChange:u,autoFocus:!0,onKeyDown:e=>{e.keyCode===O.ENTER&&S()}})})]}),N(`div`,{className:`univer-flex univer-justify-end univer-gap-3`,children:[M(me,{onClick:x,children:n.t(`docLink.edit.cancel`)}),M(me,{variant:`primary`,disabled:!c,onClick:S,children:n.t(`docLink.edit.confirm`)})]})]})};z.componentKey=`docs-hyper-link-edit`;const B={type:t.COMMAND,id:`docs.command.delete-hyper-link`,async handler(e,t){if(!t)return!1;let{unitId:n,linkId:r,segmentId:i}=t,a=e.get(s),o=re(e,{unitId:n,rangeId:r,segmentId:i});return o?await a.syncExecuteCommand(o.id,o.params):!1}},Ie=e=>{let t=e.get(C),n=e.get(l),r=t.getTextRanges();if(!(r!=null&&r.length))return!0;let i=r[0];return!!(!n.getCurrentUnitForType(h.UNIVER_DOC)||!i||i.collapsed)},V={type:t.OPERATION,id:`doc.operation.show-hyper-link-edit-popup`,handler(e,t){var n;let r=t==null?void 0:t.link,i=e.get(l);if(Ie(e)&&!r)return!1;let a=e.get(J),o=(r==null?void 0:r.unitId)||((n=i.getCurrentUnitForType(h.UNIVER_DOC))==null?void 0:n.getUnitId());return o?(a.showEditPopup(o,r),!0):!1}},H={type:t.OPERATION,id:`doc.operation.toggle-hyper-link-info-popup`,handler(e,t){let n=e.get(J);return t?(n.showInfoPopup(t),!0):(n.hideInfoPopup(),!0)}},Le={type:t.OPERATION,id:`doc.operation.click-hyper-link`,handler(e,t){var r;if(!t)return!1;let{unitId:i,linkId:a,segmentId:o}=t,s=e.get(l).getUnit(i,h.UNIVER_DOC),c=s==null?void 0:s.getSelfOrHeaderFooterModel(o).getBody(),u=c==null||(r=c.customRanges)==null||(r=r.find(e=>e.rangeId===a&&e.rangeType===n.HYPERLINK))==null||(r=r.properties)==null?void 0:r.url;return u&&window.open(u,`_blank`,`noopener noreferrer`),!0}},U=()=>{var e,t;let r=k(J),i=k(s),a=k(xe),o=k(f),c=A(r.showingLink$),u=k(l);if(!c)return null;let{unitId:d,linkId:p,segmentId:m,startIndex:g,endIndex:_}=c,v=u.getUnit(d,h.UNIVER_DOC),y=v==null?void 0:v.getSelfOrHeaderFooterModel(m).getBody(),b=y==null||(e=y.customRanges)==null?void 0:e.find(e=>e.rangeId===p&&e.rangeType===n.HYPERLINK&&e.startIndex===g&&e.endIndex===_);if(!b)return null;let x=(t=b.properties)==null?void 0:t.url;return N(`div`,{className:D(`
|
|
5
|
+
univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between
|
|
6
|
+
univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow
|
|
7
|
+
dark:!univer-bg-gray-900
|
|
8
|
+
`,E),onClick:()=>{r.hideInfoPopup()},children:[N(`div`,{className:`
|
|
9
|
+
univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate
|
|
10
|
+
univer-text-sm univer-leading-5 univer-text-primary-500
|
|
11
|
+
`,onClick:()=>window.open(x,void 0,`noopener noreferrer`),children:[M(`div`,{className:`
|
|
12
|
+
univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center
|
|
13
|
+
univer-justify-center univer-text-base univer-text-gray-900
|
|
14
|
+
dark:!univer-text-white
|
|
15
|
+
`,children:M(P,{})}),M(T,{showIfEllipsis:!0,title:x,children:M(`span`,{className:`univer-flex-1 univer-truncate`,children:x})})]}),N(`div`,{className:`univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center`,children:[M(`div`,{className:`
|
|
16
|
+
univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center
|
|
17
|
+
univer-justify-center univer-rounded univer-text-base
|
|
18
|
+
`,onClick:()=>{navigator.clipboard.writeText(x),a.show({content:o.t(`docLink.info.coped`),type:ge.Info})},children:M(T,{placement:`bottom`,title:o.t(`docLink.info.copy`),children:M(Oe,{})})}),M(`div`,{className:`
|
|
19
|
+
univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center
|
|
20
|
+
univer-justify-center univer-rounded univer-text-base
|
|
21
|
+
`,onClick:()=>{i.executeCommand(V.id,{link:c})},children:M(T,{placement:`bottom`,title:o.t(`docLink.info.edit`),children:M(Ae,{})})}),M(`div`,{className:`
|
|
22
|
+
univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center
|
|
23
|
+
univer-justify-center univer-rounded univer-text-base
|
|
24
|
+
`,onClick:()=>{i.executeCommand(B.id,{unitId:d,linkId:b.rangeId,segmentId:m})},children:M(T,{placement:`bottom`,title:o.t(`docLink.info.cancel`),children:M(ke,{})})})]})]})};U.componentKey=`univer.doc.link-info-popup`;function W(e){"@babel/helpers - typeof";return W=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},W(e)}function Re(e,t){if(W(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(W(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ze(e){var t=Re(e,`string`);return W(t)==`symbol`?t:t+``}function G(e,t,n){return(t=ze(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function K(e,t){return function(n,r){t(n,r,e)}}function q(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}let J=class extends o{constructor(e,t,n){super(),this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,G(this,`_editingLink$`,new le(null)),G(this,`_showingLink$`,new le(null)),G(this,`editingLink$`,this._editingLink$.asObservable()),G(this,`showingLink$`,this._showingLink$.asObservable()),G(this,`_editPopup`,null),G(this,`_infoPopup`,null),this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);let n=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e}),r=n==null?void 0:n[n.length-1];if(t){let{segmentId:e,segmentPage:n,startIndex:i,endIndex:a}=t;r={collapsed:!1,startOffset:i,endOffset:a+1,segmentId:e,segmentPage:n},this._textSelectionManagerService.replaceDocRanges([{startOffset:i,endOffset:a+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:z.componentKey,direction:`bottom`},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){var t,n,r,i,a,o;let{linkId:s,unitId:c,segmentId:l,segmentPage:u,startIndex:d,endIndex:f}=e;if(!(((t=this.showing)==null?void 0:t.linkId)===s&&((n=this.showing)==null?void 0:n.unitId)===c&&((r=this.showing)==null?void 0:r.segmentId)===l&&((i=this.showing)==null?void 0:i.segmentPage)===u&&((a=this.showing)==null?void 0:a.startIndex)===d&&((o=this.showing)==null?void 0:o.endIndex)===f)&&(this._infoPopup&&this._infoPopup.dispose(),this._univerInstanceService.getUnit(c,h.UNIVER_DOC)))return this._showingLink$.next({unitId:c,linkId:s,segmentId:l,segmentPage:u,startIndex:d,endIndex:f}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:d,endOffset:f+1,segmentId:l,segmentPage:u},{componentKey:U.componentKey,direction:`top-center`,multipleDirection:`top`,onClickOutside:()=>{this.hideInfoPopup()}},c),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),(e=this._infoPopup)==null||e.dispose()}};J=q([K(0,u(ae)),K(1,u(C)),K(2,l)],J);let Y=class extends o{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._docHyperLinkService=n,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===te.id){let{unitId:r,ranges:i,segmentId:a}=e.params,o=this._univerInstanceService.getUnit(r,h.UNIVER_DOC),s=i[0];if(s&&o){var t;let{startOffset:e,endOffset:i,collapsed:c,segmentPage:l}=s,u=(t=o.getSelfOrHeaderFooterModel(a))==null||(t=t.getBody())==null?void 0:t.customRanges;if(c){var n;let t=(n=u==null?void 0:u.findIndex(t=>t.startIndex<e&&t.endIndex>i-1))==null?-1:n;if(t>-1){let e=u[t];this._docHyperLinkService.showInfoPopup({unitId:r,linkId:e.rangeId,segmentId:a,segmentPage:l,startIndex:e.startIndex,endIndex:e.endIndex});return}}else if(u!=null&&u.find(t=>t.startIndex<=e&&t.endIndex>=i-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};Y=q([K(0,s),K(1,l),K(2,u(J))],Y);let X=class extends o{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,t,n,a,o,s){super(),this._context=e,this._docEventManagerService=t,this._commandService=n,this._hyperLinkPopupService=a,this._docSkeletonManagerService=o,this._docSelectionManagerService=s,!(this._context.unitId===i||this._context.unitId===r)&&(this._initHover(),this._initClick())}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(H.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var t;let r=e.find(e=>e.range.rangeType===n.HYPERLINK),i=this._docSelectionManagerService.getTextRanges(),a=i==null?void 0:i[0].segmentId;if(((t=r==null?void 0:r.segmentId)==null?``:t)!==a){this._hideInfoPopup();return}r?this._commandService.executeCommand(H.id,{unitId:this._context.unitId,linkId:r.range.rangeId,segmentId:r.segmentId,segmentPage:r.segmentPageIndex,rangeId:r.range.rangeId,startIndex:r.range.startIndex,endIndex:r.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;t&&this._commandService.executeCommand(Le.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId})}))}};X=q([K(1,u(oe)),K(2,s),K(3,u(J)),K(4,u(ee)),K(5,u(C))],X);let Z=class extends o{constructor(e,t,n,r){super(),this._context=e,this._docInterceptorService=t,this._hyperLinkService=n,this._docRenderController=r,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(x.CUSTOM_RANGE,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i}=t,a=this._hyperLinkService.showing;if(!a)return n({...e,active:!1});let{linkId:o,unitId:s,startIndex:c,endIndex:l}=a,u=s===r&&e.rangeId===o&&i>=c&&i<=l;return n({...e,active:u})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(fe((e,t)=>(e==null?void 0:e.linkId)===(t==null?void 0:t.linkId)&&(e==null?void 0:e.unitId)===(t==null?void 0:t.unitId)&&(e==null?void 0:e.startIndex)===(t==null?void 0:t.startIndex)),pe()).subscribe(([e,t])=>{t?t.unitId===this._context.unitId&&this._docRenderController.reRender(t.unitId):e&&e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId)}))}};Z=q([K(1,u(S)),K(2,u(J)),K(3,u(se))],Z);const Be=`doc-hyper-link-icon`;function Ve(e){return{id:V.id,type:Ce.BUTTON,icon:Be,title:`docLink.menu.tooltip`,tooltip:`docLink.menu.tooltip`,hidden$:Ee(e,h.UNIVER_DOC),disabled$:new ue(function(t){let n=e.get(C).textSelection$.pipe(de(16)).subscribe(()=>{t.next(Ie(e))});return()=>{n.unsubscribe()}})}}const He={id:V.id,binding:we.CTRL_COMMAND|O.K,description:`docLink.menu.tooltip`,preconditions:ce},Ue={[Te.MEDIA]:{[V.id]:{order:1,menuItemFactory:Ve}},[ye.MAIN_AREA]:{[ve.DATA]:{[V.id]:{order:0,menuItemFactory:Ve}}}};let Q=class extends o{constructor(e,t,n,r){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[z.componentKey,z],[U.componentKey,U],[Be,P]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initCommands(){[L,R,B,V,H,Le].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[He].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.mergeMenu(Ue)}};Q=q([K(0,u(_e)),K(1,s),K(2,be),K(3,Se)],Q);let $=class extends p{constructor(e=I,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=r;let{menu:i,...a}=v({},I,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(F,a)}onStarting(){[[J],[Q],[Y]].forEach(e=>{this._injector.add(e)}),this._injector.get(Q)}onReady(){this._injector.get(Y)}onRendered(){this._initRenderModule()}_initRenderModule(){[[Z],[X]].forEach(e=>{this._renderManagerSrv.registerRenderModule(h.UNIVER_DOC,e)})}};G($,`pluginName`,`DOC_HYPER_LINK_UI_PLUGIN`),G($,`packageName`,je),G($,`version`,Me),G($,`type`,h.UNIVER_DOC),$=q([a(y),K(1,u(d)),K(2,b),K(3,c)],$);export{$ as UniverDocsHyperLinkUIPlugin};
|