@univerjs/docs-hyper-link-ui 0.4.2 → 0.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,418 +1,448 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { CommandType, ICommandService, generateRandomId, CustomRangeType, IUniverInstanceService, UniverInstanceType, getBodySlice, DataStreamTreeTokenType, useDependency, LocaleService, useObservable, Tools, BuildTextUtils, Disposable, Inject, DependentOn, Injector, Plugin, IConfigService } from "@univerjs/core";
6
- import { UniverDocsHyperLinkPlugin } from "@univerjs/docs-hyper-link";
7
- import { IRenderManagerService } from "@univerjs/engine-render";
8
- import { DocSelectionManagerService, SetTextSelectionsOperation, DocSkeletonManagerService, DocInterceptorService, DOC_INTERCEPTOR_POINT } from "@univerjs/docs";
9
- import { addCustomRangeBySelectionFactory, replaceSelectionFactory, deleteCustomRangeFactory, DocCanvasPopManagerService, DocEventManagerService, DocRenderController, whenDocAndEditorFocused } from "@univerjs/docs-ui";
10
- import { BehaviorSubject, distinctUntilChanged, pairwise, Observable, debounceTime } from "rxjs";
11
- import { FormLayout, Input, Button, Tooltip, MessageType } from "@univerjs/design";
12
- import { KeyCode, IMessageService, useObservable as useObservable$1, MetaKeys, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IMenuManagerService, IShortcutService } from "@univerjs/ui";
13
- import React, { useState, useEffect, forwardRef, useRef, createElement } from "react";
14
- const PLUGIN_CONFIG_KEY = "docs-hyper-link-ui.config", defaultPluginConfig = {}, AddDocHyperLinkCommand = {
15
- type: CommandType.COMMAND,
1
+ var Be = Object.defineProperty;
2
+ var Ae = (n, e, t) => e in n ? Be(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var P = (n, e, t) => Ae(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CommandType as E, ICommandService as x, generateRandomId as Fe, CustomRangeType as b, IUniverInstanceService as O, UniverInstanceType as I, getBodySlice as ye, useDependency as L, LocaleService as ke, useObservable as Ke, Tools as Ve, BuildTextUtils as ne, Disposable as D, Inject as _, DependentOn as We, Injector as Ye, Plugin as Ge, IConfigService as Ze } from "@univerjs/core";
5
+ import { UniverDocsHyperLinkPlugin as ze } from "@univerjs/docs-hyper-link";
6
+ import { IRenderManagerService as qe } from "@univerjs/engine-render";
7
+ import { addCustomRangeBySelectionFactory as Je, DocSelectionManagerService as M, replaceSelectionFactory as Qe, deleteCustomRangeFactory as Xe, SetTextSelectionsOperation as en, DocSkeletonManagerService as nn, DocInterceptorService as tn, DOC_INTERCEPTOR_POINT as rn } from "@univerjs/docs";
8
+ import { DocCanvasPopManagerService as on, DocEventManagerService as sn, DocRenderController as cn, whenDocAndEditorFocused as dn } from "@univerjs/docs-ui";
9
+ import { BehaviorSubject as me, distinctUntilChanged as an, pairwise as ln, Observable as un, debounceTime as pn } from "rxjs";
10
+ import fn, { useState as q, useEffect as gn, forwardRef as N, useRef as hn, createElement as j } from "react";
11
+ import { FormLayout as _e, Input as Ie, Button as Ce, Tooltip as B, MessageType as vn } from "@univerjs/design";
12
+ import { KeyCode as te, IMessageService as mn, useObservable as _n, MetaKeys as In, MenuItemType as Cn, getMenuHiddenObservable as Ln, RibbonStartGroup as Sn, ContextMenuPosition as yn, ContextMenuGroup as kn, ComponentManager as xn, IMenuManagerService as On, IShortcutService as Pn } from "@univerjs/ui";
13
+ const Rn = "docs-hyper-link-ui.config", En = {};
14
+ var xe = { exports: {} }, Z = {};
15
+ /**
16
+ * @license React
17
+ * react-jsx-runtime.production.min.js
18
+ *
19
+ * Copyright (c) Facebook, Inc. and its affiliates.
20
+ *
21
+ * This source code is licensed under the MIT license found in the
22
+ * LICENSE file in the root directory of this source tree.
23
+ */
24
+ var bn = fn, Mn = Symbol.for("react.element"), wn = Symbol.for("react.fragment"), Dn = Object.prototype.hasOwnProperty, Nn = bn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, jn = { key: !0, ref: !0, __self: !0, __source: !0 };
25
+ function Oe(n, e, t) {
26
+ var i, r = {}, s = null, o = null;
27
+ t !== void 0 && (s = "" + t), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (o = e.ref);
28
+ for (i in e) Dn.call(e, i) && !jn.hasOwnProperty(i) && (r[i] = e[i]);
29
+ if (n && n.defaultProps) for (i in e = n.defaultProps, e) r[i] === void 0 && (r[i] = e[i]);
30
+ return { $$typeof: Mn, type: n, key: s, ref: o, props: r, _owner: Nn.current };
31
+ }
32
+ Z.Fragment = wn;
33
+ Z.jsx = Oe;
34
+ Z.jsxs = Oe;
35
+ xe.exports = Z;
36
+ var a = xe.exports;
37
+ const Pe = {
38
+ type: E.COMMAND,
16
39
  id: "docs.command.add-hyper-link",
17
- async handler(accessor, params) {
18
- if (!params)
40
+ async handler(n, e) {
41
+ if (!e)
19
42
  return !1;
20
- const { payload, unitId, selection } = params, commandService = accessor.get(ICommandService), id = generateRandomId(), doMutation = addCustomRangeBySelectionFactory(
21
- accessor,
43
+ const { payload: t, unitId: i, selection: r } = e, s = n.get(x), o = Fe(), c = Je(
44
+ n,
22
45
  {
23
- rangeId: id,
24
- rangeType: CustomRangeType.HYPERLINK,
46
+ rangeId: o,
47
+ rangeType: b.HYPERLINK,
25
48
  properties: {
26
- url: payload
49
+ url: t
27
50
  },
28
- unitId,
29
- selection
51
+ unitId: i,
52
+ selection: r
30
53
  }
31
54
  );
32
- return doMutation ? commandService.syncExecuteCommand(doMutation.id, doMutation.params) : !1;
55
+ return c ? s.syncExecuteCommand(c.id, c.params) : !1;
33
56
  }
34
- }, UpdateDocHyperLinkCommand = {
57
+ }, Re = {
35
58
  id: "docs.command.update-hyper-link",
36
- type: CommandType.COMMAND,
37
- handler(accessor, params) {
38
- var _a7;
39
- if (!params)
59
+ type: E.COMMAND,
60
+ handler(n, e) {
61
+ var h;
62
+ if (!e)
40
63
  return !1;
41
- const { unitId, payload, segmentId } = params, commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), currentSelection = accessor.get(DocSelectionManagerService).getActiveTextRange(), doc = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
42
- if (!currentSelection || !doc)
64
+ const { unitId: t, payload: i, segmentId: r, linkId: s } = e, o = n.get(x), c = n.get(O), l = n.get(M).getActiveTextRange(), u = c.getUnit(t, I.UNIVER_DOC);
65
+ if (!l || !u)
43
66
  return !1;
44
- const newId = generateRandomId(), textRun = (_a7 = getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(), currentSelection.startOffset, currentSelection.endOffset).textRuns) == null ? void 0 : _a7[0];
45
- textRun && (textRun.ed = params.label.length + 1);
46
- const replaceSelection = replaceSelectionFactory(accessor, {
47
- unitId,
67
+ const p = (h = ye(u.getSelfOrHeaderFooterModel(r).getBody(), l.startOffset, l.endOffset).textRuns) == null ? void 0 : h[0];
68
+ p && (p.ed = e.label.length + 1);
69
+ const d = Qe(n, {
70
+ unitId: t,
48
71
  body: {
49
- dataStream: `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${params.label}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`,
72
+ dataStream: `${e.label}`,
50
73
  customRanges: [{
51
- rangeId: newId,
52
- rangeType: CustomRangeType.HYPERLINK,
74
+ rangeId: s,
75
+ rangeType: b.HYPERLINK,
53
76
  startIndex: 0,
54
- endIndex: params.label.length + 1,
77
+ endIndex: e.label.length + 1,
55
78
  properties: {
56
- url: payload
79
+ url: i
57
80
  }
58
81
  }],
59
- textRuns: textRun ? [textRun] : void 0
82
+ textRuns: p ? [p] : void 0
60
83
  },
61
84
  selection: {
62
- startOffset: currentSelection.startOffset,
63
- endOffset: currentSelection.endOffset,
85
+ startOffset: l.startOffset,
86
+ endOffset: l.endOffset,
64
87
  collapsed: !1,
65
- segmentId
88
+ segmentId: r
66
89
  }
67
90
  });
68
- return replaceSelection ? commandService.syncExecuteCommand(replaceSelection.id, replaceSelection.params) : !1;
69
- }
70
- }, docsLinkEdit = "univer-docs-link-edit", docsLinkEditTitle = "univer-docs-link-edit-title", docsLinkEditClose = "univer-docs-link-edit-close", docsLinkEditButtons = "univer-docs-link-edit-buttons", docsLinkEditButton = "univer-docs-link-edit-button", styles$1 = {
71
- docsLinkEdit,
72
- docsLinkEditTitle,
73
- docsLinkEditClose,
74
- docsLinkEditButtons,
75
- docsLinkEditButton
91
+ return d ? o.syncExecuteCommand(d.id, d.params) : !1;
92
+ }
93
+ }, $n = "univer-docs-link-edit", Un = "univer-docs-link-edit-title", Tn = "univer-docs-link-edit-close", Hn = "univer-docs-link-edit-buttons", Bn = "univer-docs-link-edit-button", A = {
94
+ docsLinkEdit: $n,
95
+ docsLinkEditTitle: Un,
96
+ docsLinkEditClose: Tn,
97
+ docsLinkEditButtons: Hn,
98
+ docsLinkEditButton: Bn
76
99
  };
77
- function hasProtocol(urlString) {
78
- return /^[a-zA-Z]+:\/\//.test(urlString);
100
+ function An(n) {
101
+ return /^[a-zA-Z]+:\/\//.test(n);
79
102
  }
80
- __name(hasProtocol, "hasProtocol");
81
- function isEmail(url) {
82
- return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
103
+ function Fn(n) {
104
+ return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n);
83
105
  }
84
- __name(isEmail, "isEmail");
85
- function transformUrl(urlStr) {
86
- return hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `https://${urlStr}`;
106
+ function Kn(n) {
107
+ return An(n) ? n : Fn(n) ? `mailto://${n}` : `https://${n}`;
87
108
  }
88
- __name(transformUrl, "transformUrl");
89
- const DocHyperLinkEdit = /* @__PURE__ */ __name(() => {
90
- const hyperLinkService = useDependency(DocHyperLinkPopupService), localeService = useDependency(LocaleService), editing = useObservable(hyperLinkService.editingLink$), commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), docSelectionManagerService = useDependency(DocSelectionManagerService), [link, setLink] = useState(""), [label, setLabel] = useState(""), [showError, setShowError] = useState(!1), isLegal = Tools.isLegalUrl(link), doc = editing ? univerInstanceService.getUnit(editing.unitId, UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
91
- useEffect(() => {
92
- var _a7, _b, _c, _d, _e, _f, _g, _h, _i;
93
- const activeRange = docSelectionManagerService.getActiveTextRange();
94
- if (!activeRange)
109
+ const K = () => {
110
+ const n = L(S), e = L(ke), t = Ke(n.editingLink$), i = L(x), r = L(O), s = L(M), [o, c] = q(""), [g, l] = q(""), [u, v] = q(!1), p = Ve.isLegalUrl(o), d = t ? r.getUnit(t.unitId, I.UNIVER_DOC) : r.getCurrentUnitForType(I.UNIVER_DOC);
111
+ gn(() => {
112
+ var de, ae, le, ue, pe, fe, ge, he, ve;
113
+ const f = s.getActiveTextRange();
114
+ if (!f)
95
115
  return;
96
- if (editing) {
97
- const body2 = (_a7 = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(editing.segmentId)) == null ? void 0 : _a7.getBody(), matchedRange2 = (_b = body2 == null ? void 0 : body2.customRanges) == null ? void 0 : _b.find((i) => (editing == null ? void 0 : editing.linkId) === i.rangeId);
98
- doc && matchedRange2 && (setLink((_d = (_c = matchedRange2.properties) == null ? void 0 : _c.url) != null ? _d : ""), setLabel(BuildTextUtils.transform.getPlainText(getBodySlice(body2, matchedRange2.startIndex, matchedRange2.endIndex).dataStream)));
116
+ if (t) {
117
+ const T = (de = d == null ? void 0 : d.getSelfOrHeaderFooterModel(t.segmentId)) == null ? void 0 : de.getBody(), H = (ae = T == null ? void 0 : T.customRanges) == null ? void 0 : ae.find((z) => (t == null ? void 0 : t.linkId) === z.rangeId && z.startIndex === t.startIndex && z.endIndex === t.endIndex);
118
+ d && H && (c((ue = (le = H.properties) == null ? void 0 : le.url) != null ? ue : ""), l(ne.transform.getPlainText(ye(T, H.startIndex, H.endIndex + 1).dataStream)));
99
119
  return;
100
120
  }
101
- const body = (_e = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(activeRange.segmentId)) == null ? void 0 : _e.getBody(), selection = body ? BuildTextUtils.selection.getInsertSelection(activeRange, body) : null, matchedRange = selection && ((_g = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_f = body == null ? void 0 : body.customRanges) != null ? _f : [])) == null ? void 0 : _g[0]);
102
- doc && matchedRange && setLink((_i = (_h = matchedRange == null ? void 0 : matchedRange.properties) == null ? void 0 : _h.url) != null ? _i : "");
103
- }, [doc, editing, docSelectionManagerService, univerInstanceService]);
104
- const handleCancel = /* @__PURE__ */ __name(() => {
105
- hyperLinkService.hideEditPopup();
106
- }, "handleCancel"), handleConfirm = /* @__PURE__ */ __name(() => {
107
- if (setShowError(!0), !isLegal || !doc)
121
+ const y = (pe = d == null ? void 0 : d.getSelfOrHeaderFooterModel(f.segmentId)) == null ? void 0 : pe.getBody(), ce = y ? f : null, U = ce && ((ge = ne.customRange.getCustomRangesInterestsWithSelection(ce, (fe = y == null ? void 0 : y.customRanges) != null ? fe : [])) == null ? void 0 : ge[0]);
122
+ d && U && c((ve = (he = U == null ? void 0 : U.properties) == null ? void 0 : he.url) != null ? ve : "");
123
+ }, [d, t, s, r]);
124
+ const h = () => {
125
+ n.hideEditPopup();
126
+ }, C = () => {
127
+ if (v(!0), !p || !d)
108
128
  return;
109
- const linkFinal = transformUrl(link);
110
- if (!editing)
111
- commandService.executeCommand(AddDocHyperLinkCommand.id, {
112
- unitId: doc.getUnitId(),
113
- payload: linkFinal
129
+ const f = Kn(o);
130
+ if (!t)
131
+ i.executeCommand(Pe.id, {
132
+ unitId: d.getUnitId(),
133
+ payload: f
114
134
  });
115
135
  else {
116
- if (!label)
136
+ if (!g)
117
137
  return;
118
- commandService.executeCommand(UpdateDocHyperLinkCommand.id, {
119
- unitId: doc.getUnitId(),
120
- payload: linkFinal,
121
- linkId: editing.linkId,
122
- label,
123
- segmentId: editing.segmentId
138
+ i.executeCommand(Re.id, {
139
+ unitId: d.getUnitId(),
140
+ payload: f,
141
+ linkId: t.linkId,
142
+ label: g,
143
+ segmentId: t.segmentId
124
144
  });
125
145
  }
126
- hyperLinkService.hideEditPopup();
127
- }, "handleConfirm");
128
- if (doc)
129
- return /* @__PURE__ */ React.createElement("div", { className: styles$1.docsLinkEdit }, /* @__PURE__ */ React.createElement("div", null, editing ? /* @__PURE__ */ React.createElement(
130
- FormLayout,
131
- {
132
- label: localeService.t("docLink.edit.label"),
133
- error: showError && !label ? localeService.t("docLink.edit.labelError") : ""
134
- },
135
- /* @__PURE__ */ React.createElement(
136
- Input,
137
- {
138
- value: label,
139
- onChange: setLabel,
140
- autoFocus: !0,
141
- onKeyDown: /* @__PURE__ */ __name((evt) => {
142
- evt.keyCode === KeyCode.ENTER && handleConfirm();
143
- }, "onKeyDown")
144
- }
145
- )
146
- ) : null, /* @__PURE__ */ React.createElement(
147
- FormLayout,
148
- {
149
- label: localeService.t("docLink.edit.address"),
150
- error: showError && !isLegal ? localeService.t("docLink.edit.addressError") : ""
151
- },
152
- /* @__PURE__ */ React.createElement(
153
- Input,
154
- {
155
- value: link,
156
- onChange: setLink,
157
- autoFocus: !0,
158
- onKeyDown: /* @__PURE__ */ __name((evt) => {
159
- evt.keyCode === KeyCode.ENTER && handleConfirm();
160
- }, "onKeyDown")
161
- }
162
- )
163
- )), /* @__PURE__ */ React.createElement("div", { className: styles$1.docsLinkEditButtons }, /* @__PURE__ */ React.createElement(
164
- Button,
165
- {
166
- className: styles$1.docsLinkEditButton,
167
- onClick: handleCancel
168
- },
169
- localeService.t("docLink.edit.cancel")
170
- ), /* @__PURE__ */ React.createElement(
171
- Button,
172
- {
173
- disabled: !link,
174
- className: styles$1.docsLinkEditButton,
175
- type: "primary",
176
- onClick: handleConfirm
177
- },
178
- localeService.t("docLink.edit.confirm")
179
- )));
180
- }, "DocHyperLinkEdit");
181
- DocHyperLinkEdit.componentKey = "docs-hyper-link-edit";
182
- var __assign = function() {
183
- return __assign = Object.assign || function(t) {
184
- for (var s, i = 1, n = arguments.length; i < n; i++) {
185
- s = arguments[i];
186
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
146
+ n.hideEditPopup();
147
+ };
148
+ if (d)
149
+ return /* @__PURE__ */ a.jsxs("div", { className: A.docsLinkEdit, children: [
150
+ /* @__PURE__ */ a.jsxs("div", { children: [
151
+ t ? /* @__PURE__ */ a.jsx(
152
+ _e,
153
+ {
154
+ label: e.t("docLink.edit.label"),
155
+ error: u && !g ? e.t("docLink.edit.labelError") : "",
156
+ children: /* @__PURE__ */ a.jsx(
157
+ Ie,
158
+ {
159
+ value: g,
160
+ onChange: l,
161
+ autoFocus: !0,
162
+ onKeyDown: (f) => {
163
+ f.keyCode === te.ENTER && C();
164
+ }
165
+ }
166
+ )
167
+ }
168
+ ) : null,
169
+ /* @__PURE__ */ a.jsx(
170
+ _e,
171
+ {
172
+ label: e.t("docLink.edit.address"),
173
+ error: u && !p ? e.t("docLink.edit.addressError") : "",
174
+ children: /* @__PURE__ */ a.jsx(
175
+ Ie,
176
+ {
177
+ value: o,
178
+ onChange: c,
179
+ autoFocus: !0,
180
+ onKeyDown: (f) => {
181
+ f.keyCode === te.ENTER && C();
182
+ }
183
+ }
184
+ )
185
+ }
186
+ )
187
+ ] }),
188
+ /* @__PURE__ */ a.jsxs("div", { className: A.docsLinkEditButtons, children: [
189
+ /* @__PURE__ */ a.jsx(
190
+ Ce,
191
+ {
192
+ className: A.docsLinkEditButton,
193
+ onClick: h,
194
+ children: e.t("docLink.edit.cancel")
195
+ }
196
+ ),
197
+ /* @__PURE__ */ a.jsx(
198
+ Ce,
199
+ {
200
+ disabled: !o,
201
+ className: A.docsLinkEditButton,
202
+ type: "primary",
203
+ onClick: C,
204
+ children: e.t("docLink.edit.confirm")
205
+ }
206
+ )
207
+ ] })
208
+ ] });
209
+ };
210
+ K.componentKey = "docs-hyper-link-edit";
211
+ var m = function() {
212
+ return m = Object.assign || function(n) {
213
+ for (var e, t = 1, i = arguments.length; t < i; t++) {
214
+ e = arguments[t];
215
+ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (n[r] = e[r]);
187
216
  }
188
- return t;
189
- }, __assign.apply(this, arguments);
190
- }, __rest = function(s, e) {
217
+ return n;
218
+ }, m.apply(this, arguments);
219
+ }, Vn = function(n, e) {
191
220
  var t = {};
192
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
193
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
194
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
195
- e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
221
+ for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
222
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
223
+ for (var r = 0, i = Object.getOwnPropertySymbols(n); r < i.length; r++)
224
+ e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, i[r]) && (t[i[r]] = n[i[r]]);
196
225
  return t;
197
- }, IconBase = forwardRef(function(props, ref) {
198
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
199
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
226
+ }, $ = N(function(n, e) {
227
+ var t = n.icon, i = n.id, r = n.className, s = n.extend, o = Vn(n, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), g = hn("_".concat(Gn()));
228
+ return Ee(t, "".concat(i), { defIds: t.defIds, idSuffix: g.current }, m({ ref: e, className: c }, o), s);
200
229
  });
201
- function render(node, id, runtimeProps, rootProps, extend) {
202
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
203
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
230
+ function Ee(n, e, t, i, r) {
231
+ return j(n.tag, m(m({ key: e }, Wn(n, t, r)), i), (Yn(n, t).children || []).map(function(s, o) {
232
+ return Ee(s, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, r);
204
233
  }));
205
234
  }
206
- __name(render, "render");
207
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
208
- var attrs = __assign({}, node.attrs);
209
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
210
- var defIds = runtimeProps.defIds;
211
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a7) {
212
- var key = _a7[0], value = _a7[1];
213
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
214
- })), attrs;
235
+ function Wn(n, e, t) {
236
+ var i = m({}, n.attrs);
237
+ t != null && t.colorChannel1 && i.fill === "colorChannel1" && (i.fill = t.colorChannel1);
238
+ var r = e.defIds;
239
+ return !r || r.length === 0 || (n.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(s) {
240
+ var o = s[0], c = s[1];
241
+ typeof c == "string" && (i[o] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
242
+ })), i;
215
243
  }
216
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
217
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
218
- var _a7, defIds = runtimeProps.defIds;
219
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a7 = node.children) === null || _a7 === void 0) && _a7.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
220
- return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
221
- }) }) : node;
244
+ function Yn(n, e) {
245
+ var t, i = e.defIds;
246
+ return !i || i.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? m(m({}, n), { children: n.children.map(function(r) {
247
+ return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? m(m({}, r), { attrs: m(m({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
248
+ }) }) : n;
222
249
  }
223
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
224
- function generateShortUuid() {
250
+ function Gn() {
225
251
  return Math.random().toString(36).substring(2, 8);
226
252
  }
227
- __name(generateShortUuid, "generateShortUuid");
228
- IconBase.displayName = "UniverIcon";
229
- var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", 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", fillRule: "evenodd", clipRule: "evenodd" } }] }, CopySingle = forwardRef(function(props, ref) {
230
- return createElement(IconBase, Object.assign({}, props, {
253
+ $.displayName = "UniverIcon";
254
+ var Zn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", 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", fillRule: "evenodd", clipRule: "evenodd" } }] }, be = N(function(n, e) {
255
+ return j($, Object.assign({}, n, {
231
256
  id: "copy-single",
232
- ref,
233
- icon: element$3
257
+ ref: e,
258
+ icon: Zn
234
259
  }));
235
260
  });
236
- CopySingle.displayName = "CopySingle";
237
- var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332", fillRule: "evenodd", clipRule: "evenodd" } }] }, LinkSingle = forwardRef(function(props, ref) {
238
- return createElement(IconBase, Object.assign({}, props, {
261
+ be.displayName = "CopySingle";
262
+ var zn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332", fillRule: "evenodd", clipRule: "evenodd" } }] }, se = N(function(n, e) {
263
+ return j($, Object.assign({}, n, {
239
264
  id: "link-single",
240
- ref,
241
- icon: element$2
265
+ ref: e,
266
+ icon: zn
242
267
  }));
243
268
  });
244
- LinkSingle.displayName = "LinkSingle";
245
- var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", 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.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.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.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z" } }] }, UnlinkSingle = forwardRef(function(props, ref) {
246
- return createElement(IconBase, Object.assign({}, props, {
269
+ se.displayName = "LinkSingle";
270
+ var qn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", 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.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.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.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z" } }] }, Me = N(function(n, e) {
271
+ return j($, Object.assign({}, n, {
247
272
  id: "unlink-single",
248
- ref,
249
- icon: element$1
273
+ ref: e,
274
+ icon: qn
250
275
  }));
251
276
  });
252
- UnlinkSingle.displayName = "UnlinkSingle";
253
- var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", 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", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", 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" } }] }, WriteSingle = forwardRef(function(props, ref) {
254
- return createElement(IconBase, Object.assign({}, props, {
277
+ Me.displayName = "UnlinkSingle";
278
+ var Jn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", 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", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", 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" } }] }, we = N(function(n, e) {
279
+ return j($, Object.assign({}, n, {
255
280
  id: "write-single",
256
- ref,
257
- icon: element
281
+ ref: e,
282
+ icon: Jn
258
283
  }));
259
284
  });
260
- WriteSingle.displayName = "WriteSingle";
261
- function r(e) {
262
- var t, f, n = "";
263
- if (typeof e == "string" || typeof e == "number") n += e;
264
- else if (typeof e == "object") if (Array.isArray(e)) {
265
- var o = e.length;
266
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
267
- } else for (f in e) e[f] && (n && (n += " "), n += f);
268
- return n;
285
+ we.displayName = "WriteSingle";
286
+ function De(n) {
287
+ var e, t, i = "";
288
+ if (typeof n == "string" || typeof n == "number") i += n;
289
+ else if (typeof n == "object") if (Array.isArray(n)) {
290
+ var r = n.length;
291
+ for (e = 0; e < r; e++) n[e] && (t = De(n[e])) && (i && (i += " "), i += t);
292
+ } else for (t in n) n[t] && (i && (i += " "), i += t);
293
+ return i;
269
294
  }
270
- __name(r, "r");
271
- function clsx() {
272
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
273
- return n;
295
+ function Le() {
296
+ for (var n, e, t = 0, i = "", r = arguments.length; t < r; t++) (n = arguments[t]) && (e = De(n)) && (i && (i += " "), i += e);
297
+ return i;
274
298
  }
275
- __name(clsx, "clsx");
276
- const DeleteDocHyperLinkCommand = {
277
- type: CommandType.COMMAND,
299
+ const Ne = {
300
+ type: E.COMMAND,
278
301
  id: "docs.command.delete-hyper-link",
279
- async handler(accessor, params) {
280
- if (!params)
302
+ async handler(n, e) {
303
+ if (!e)
281
304
  return !1;
282
- const { unitId, linkId, segmentId } = params, commandService = accessor.get(ICommandService), doMutation = deleteCustomRangeFactory(accessor, { unitId, rangeId: linkId, segmentId });
283
- return doMutation ? await commandService.syncExecuteCommand(doMutation.id, doMutation.params) : !1;
305
+ const { unitId: t, linkId: i, segmentId: r } = e, s = n.get(x), o = Xe(n, { unitId: t, rangeId: i, segmentId: r });
306
+ return o ? await s.syncExecuteCommand(o.id, o.params) : !1;
284
307
  }
285
- }, shouldDisableAddLink = /* @__PURE__ */ __name((accessor) => {
286
- var _a7;
287
- const textSelectionService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), textRanges = textSelectionService.getDocRanges();
288
- if (!textRanges.length || textRanges.length > 1)
308
+ }, je = (n) => {
309
+ var l;
310
+ const e = n.get(M), t = n.get(O), i = e.getDocRanges();
311
+ if (!i.length || i.length > 1)
289
312
  return !0;
290
- const activeRange = textRanges[0], doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
291
- if (!doc || !activeRange || activeRange.collapsed)
313
+ const r = i[0], s = t.getCurrentUnitForType(I.UNIVER_DOC);
314
+ if (!s || !r || r.collapsed)
292
315
  return !0;
293
- const body = doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody(), paragraphs = body == null ? void 0 : body.paragraphs;
294
- if (!paragraphs)
316
+ const o = s.getSelfOrHeaderFooterModel(r.segmentId).getBody(), c = o == null ? void 0 : o.paragraphs;
317
+ if (!c)
295
318
  return !0;
296
- for (let i = 0, len = paragraphs.length; i < len; i++) {
297
- const p = paragraphs[i];
298
- if (activeRange.startOffset <= p.startIndex && activeRange.endOffset > p.startIndex)
319
+ for (let u = 0, v = c.length; u < v; u++) {
320
+ const p = c[u];
321
+ if (r.startOffset <= p.startIndex && r.endOffset > p.startIndex)
299
322
  return !0;
300
- if (p.startIndex > activeRange.endOffset)
323
+ if (p.startIndex > r.endOffset)
301
324
  break;
302
325
  }
303
- return !BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(activeRange, (_a7 = body.customRanges) != null ? _a7 : []).every((range) => range.rangeType === CustomRangeType.HYPERLINK);
304
- }, "shouldDisableAddLink"), ShowDocHyperLinkEditPopupOperation = {
305
- type: CommandType.OPERATION,
326
+ return !ne.customRange.getCustomRangesInterestsWithSelection(r, (l = o.customRanges) != null ? l : []).every((u) => u.rangeType === b.HYPERLINK);
327
+ }, R = {
328
+ type: E.OPERATION,
306
329
  id: "doc.operation.show-hyper-link-edit-popup",
307
- handler(accessor, params) {
308
- var _a7;
309
- const linkInfo = params == null ? void 0 : params.link, univerInstanceService = accessor.get(IUniverInstanceService);
310
- if (shouldDisableAddLink(accessor) && !linkInfo)
330
+ handler(n, e) {
331
+ var o;
332
+ const t = e == null ? void 0 : e.link, i = n.get(O);
333
+ if (je(n) && !t)
311
334
  return !1;
312
- const hyperLinkService = accessor.get(DocHyperLinkPopupService), unitId = (linkInfo == null ? void 0 : linkInfo.unitId) || ((_a7 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a7.getUnitId());
313
- return unitId ? (hyperLinkService.showEditPopup(unitId, linkInfo), !0) : !1;
335
+ const r = n.get(S), s = (t == null ? void 0 : t.unitId) || ((o = i.getCurrentUnitForType(I.UNIVER_DOC)) == null ? void 0 : o.getUnitId());
336
+ return s ? (r.showEditPopup(s, t), !0) : !1;
314
337
  }
315
- }, ToggleDocHyperLinkInfoPopupOperation = {
316
- type: CommandType.OPERATION,
338
+ }, ie = {
339
+ type: E.OPERATION,
317
340
  id: "doc.operation.toggle-hyper-link-info-popup",
318
- handler(accessor, params) {
319
- const hyperLinkService = accessor.get(DocHyperLinkPopupService);
320
- return params ? (hyperLinkService.showInfoPopup(params), !0) : (hyperLinkService.hideInfoPopup(), !0);
341
+ handler(n, e) {
342
+ const t = n.get(S);
343
+ return e ? (t.showInfoPopup(e), !0) : (t.hideInfoPopup(), !0);
321
344
  }
322
- }, ClickDocHyperLinkOperation = {
323
- type: CommandType.OPERATION,
345
+ }, $e = {
346
+ type: E.OPERATION,
324
347
  id: "doc.operation.click-hyper-link",
325
- handler(accessor, params) {
326
- var _a7, _b, _c;
327
- if (!params)
348
+ handler(n, e) {
349
+ var l, u, v;
350
+ if (!e)
328
351
  return !1;
329
- const { unitId, linkId, segmentId } = params, doc = accessor.get(IUniverInstanceService).getUnit(unitId, UniverInstanceType.UNIVER_DOC), body = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(segmentId).getBody(), link = (_c = (_b = (_a7 = body == null ? void 0 : body.customRanges) == null ? void 0 : _a7.find((range) => range.rangeId === linkId && range.rangeType === CustomRangeType.HYPERLINK)) == null ? void 0 : _b.properties) == null ? void 0 : _c.url;
330
- return link && window.open(link, "_blank", "noopener noreferrer"), !0;
331
- }
332
- }, docLink = "univer-doc-link", docLinkType = "univer-doc-link-type", docLinkContent = "univer-doc-link-content", docLinkContentError = "univer-doc-link-content-error", docLinkUrl = "univer-doc-link-url", docLinkOperations = "univer-doc-link-operations", docLinkOperation = "univer-doc-link-operation", docLinkOperationError = "univer-doc-link-operation-error", styles = {
333
- docLink,
334
- docLinkType,
335
- docLinkContent,
336
- docLinkContentError,
337
- docLinkUrl,
338
- docLinkOperations,
339
- docLinkOperation,
340
- docLinkOperationError
341
- }, DocLinkPopup = /* @__PURE__ */ __name(() => {
342
- var _a7, _b;
343
- const hyperLinkService = useDependency(DocHyperLinkPopupService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), currentPopup = useObservable$1(hyperLinkService.showingLink$), univerInstanceService = useDependency(IUniverInstanceService);
344
- if (!currentPopup)
352
+ const { unitId: t, linkId: i, segmentId: r } = e, o = n.get(O).getUnit(t, I.UNIVER_DOC), c = o == null ? void 0 : o.getSelfOrHeaderFooterModel(r).getBody(), g = (v = (u = (l = c == null ? void 0 : c.customRanges) == null ? void 0 : l.find((p) => p.rangeId === i && p.rangeType === b.HYPERLINK)) == null ? void 0 : u.properties) == null ? void 0 : v.url;
353
+ return g && window.open(g, "_blank", "noopener noreferrer"), !0;
354
+ }
355
+ }, Qn = "univer-doc-link", Xn = "univer-doc-link-type", et = "univer-doc-link-content", nt = "univer-doc-link-content-error", tt = "univer-doc-link-url", it = "univer-doc-link-operations", rt = "univer-doc-link-operation", ot = "univer-doc-link-operation-error", k = {
356
+ docLink: Qn,
357
+ docLinkType: Xn,
358
+ docLinkContent: et,
359
+ docLinkContentError: nt,
360
+ docLinkUrl: tt,
361
+ docLinkOperations: it,
362
+ docLinkOperation: rt,
363
+ docLinkOperationError: ot
364
+ }, V = () => {
365
+ var C, f;
366
+ const n = L(S), e = L(x), t = L(mn), i = L(ke), r = _n(n.showingLink$), s = L(O);
367
+ if (!r)
345
368
  return null;
346
- const { unitId, linkId, segmentId } = currentPopup, doc = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), body = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(segmentId).getBody(), link = (_a7 = body == null ? void 0 : body.customRanges) == null ? void 0 : _a7.find((range) => range.rangeId === linkId && range.rangeType === CustomRangeType.HYPERLINK);
347
- if (!link)
369
+ const { unitId: o, linkId: c, segmentId: g, startIndex: l, endIndex: u } = r, v = s.getUnit(o, I.UNIVER_DOC), p = v == null ? void 0 : v.getSelfOrHeaderFooterModel(g).getBody(), d = (C = p == null ? void 0 : p.customRanges) == null ? void 0 : C.find((y) => y.rangeId === c && y.rangeType === b.HYPERLINK && y.startIndex === l && y.endIndex === u);
370
+ if (!d)
348
371
  return null;
349
- const url = (_b = link.properties) == null ? void 0 : _b.url;
350
- return /* @__PURE__ */ React.createElement(
372
+ const h = (f = d.properties) == null ? void 0 : f.url;
373
+ return /* @__PURE__ */ a.jsxs(
351
374
  "div",
352
375
  {
353
- className: styles.docLink,
354
- onClick: /* @__PURE__ */ __name(() => {
355
- hyperLinkService.hideInfoPopup();
356
- }, "onClick")
357
- },
358
- /* @__PURE__ */ React.createElement("div", { className: clsx(styles.docLinkContent), onClick: /* @__PURE__ */ __name(() => window.open(url), "onClick") }, /* @__PURE__ */ React.createElement("div", { className: styles.docLinkType }, /* @__PURE__ */ React.createElement(LinkSingle, null)), /* @__PURE__ */ React.createElement(Tooltip, { showIfEllipsis: !0, title: url }, /* @__PURE__ */ React.createElement("span", { className: styles.docLinkUrl }, url))),
359
- /* @__PURE__ */ React.createElement("div", { className: styles.docLinkOperations }, /* @__PURE__ */ React.createElement(
360
- "div",
361
- {
362
- className: clsx(styles.docLinkOperation),
363
- onClick: /* @__PURE__ */ __name(() => {
364
- navigator.clipboard.writeText(url), messageService.show({
365
- content: localeService.t("docLink.info.coped"),
366
- type: MessageType.Info
367
- });
368
- }, "onClick")
369
- },
370
- /* @__PURE__ */ React.createElement(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.copy") }, /* @__PURE__ */ React.createElement(CopySingle, null))
371
- ), /* @__PURE__ */ React.createElement(
372
- "div",
373
- {
374
- className: styles.docLinkOperation,
375
- onClick: /* @__PURE__ */ __name(() => {
376
- commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id, {
377
- link: currentPopup
378
- });
379
- }, "onClick")
380
- },
381
- /* @__PURE__ */ React.createElement(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.edit") }, /* @__PURE__ */ React.createElement(WriteSingle, null))
382
- ), /* @__PURE__ */ React.createElement(
383
- "div",
384
- {
385
- className: styles.docLinkOperation,
386
- onClick: /* @__PURE__ */ __name(() => {
387
- commandService.executeCommand(DeleteDocHyperLinkCommand.id, {
388
- unitId,
389
- linkId: link.rangeId,
390
- segmentId
391
- });
392
- }, "onClick")
376
+ className: k.docLink,
377
+ onClick: () => {
378
+ n.hideInfoPopup();
393
379
  },
394
- /* @__PURE__ */ React.createElement(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.cancel") }, /* @__PURE__ */ React.createElement(UnlinkSingle, null))
395
- ))
380
+ children: [
381
+ /* @__PURE__ */ a.jsxs("div", { className: Le(k.docLinkContent), onClick: () => window.open(h), children: [
382
+ /* @__PURE__ */ a.jsx("div", { className: k.docLinkType, children: /* @__PURE__ */ a.jsx(se, {}) }),
383
+ /* @__PURE__ */ a.jsx(B, { showIfEllipsis: !0, title: h, children: /* @__PURE__ */ a.jsx("span", { className: k.docLinkUrl, children: h }) })
384
+ ] }),
385
+ /* @__PURE__ */ a.jsxs("div", { className: k.docLinkOperations, children: [
386
+ /* @__PURE__ */ a.jsx(
387
+ "div",
388
+ {
389
+ className: Le(k.docLinkOperation),
390
+ onClick: () => {
391
+ navigator.clipboard.writeText(h), t.show({
392
+ content: i.t("docLink.info.coped"),
393
+ type: vn.Info
394
+ });
395
+ },
396
+ children: /* @__PURE__ */ a.jsx(B, { placement: "bottom", title: i.t("docLink.info.copy"), children: /* @__PURE__ */ a.jsx(be, {}) })
397
+ }
398
+ ),
399
+ /* @__PURE__ */ a.jsx(
400
+ "div",
401
+ {
402
+ className: k.docLinkOperation,
403
+ onClick: () => {
404
+ e.executeCommand(R.id, {
405
+ link: r
406
+ });
407
+ },
408
+ children: /* @__PURE__ */ a.jsx(B, { placement: "bottom", title: i.t("docLink.info.edit"), children: /* @__PURE__ */ a.jsx(we, {}) })
409
+ }
410
+ ),
411
+ /* @__PURE__ */ a.jsx(
412
+ "div",
413
+ {
414
+ className: k.docLinkOperation,
415
+ onClick: () => {
416
+ e.executeCommand(Ne.id, {
417
+ unitId: o,
418
+ linkId: d.rangeId,
419
+ segmentId: g
420
+ });
421
+ },
422
+ children: /* @__PURE__ */ a.jsx(B, { placement: "bottom", title: i.t("docLink.info.cancel"), children: /* @__PURE__ */ a.jsx(Me, {}) })
423
+ }
424
+ )
425
+ ] })
426
+ ]
427
+ }
396
428
  );
397
- }, "DocLinkPopup");
398
- DocLinkPopup.componentKey = "univer.doc.link-info-popup";
399
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
400
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
401
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
402
- return kind && result && __defProp$5(target, key, result), result;
403
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
404
- const SKIT_PLACEHOLDER = 0;
405
- var _a;
406
- let DocHyperLinkPopupService = (_a = class extends Disposable {
407
- constructor(_docCanvasPopupManagerService, _textSelectionManagerService, _univerInstanceService) {
429
+ };
430
+ V.componentKey = "univer.doc.link-info-popup";
431
+ var st = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, dt = (n, e, t, i) => {
432
+ for (var r = i > 1 ? void 0 : i ? ct(e, t) : e, s = n.length - 1, o; s >= 0; s--)
433
+ (o = n[s]) && (r = (i ? o(e, t, r) : o(r)) || r);
434
+ return i && r && st(e, t, r), r;
435
+ }, J = (n, e) => (t, i) => e(t, i, n);
436
+ let S = class extends D {
437
+ constructor(e, t, i) {
408
438
  super();
409
- __publicField(this, "_editingLink$", new BehaviorSubject(null));
410
- __publicField(this, "_showingLink$", new BehaviorSubject(null));
411
- __publicField(this, "editingLink$", this._editingLink$.asObservable());
412
- __publicField(this, "showingLink$", this._showingLink$.asObservable());
413
- __publicField(this, "_editPopup", null);
414
- __publicField(this, "_infoPopup", null);
415
- this._docCanvasPopupManagerService = _docCanvasPopupManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._univerInstanceService = _univerInstanceService, this.disposeWithMe(() => {
439
+ P(this, "_editingLink$", new me(null));
440
+ P(this, "_showingLink$", new me(null));
441
+ P(this, "editingLink$", this._editingLink$.asObservable());
442
+ P(this, "showingLink$", this._showingLink$.asObservable());
443
+ P(this, "_editPopup", null);
444
+ P(this, "_infoPopup", null);
445
+ this._docCanvasPopupManagerService = e, this._textSelectionManagerService = t, this._univerInstanceService = i, this.disposeWithMe(() => {
416
446
  this._editingLink$.complete(), this._showingLink$.complete();
417
447
  });
418
448
  }
@@ -422,101 +452,93 @@ let DocHyperLinkPopupService = (_a = class extends Disposable {
422
452
  get showing() {
423
453
  return this._showingLink$.value;
424
454
  }
425
- showEditPopup(unitId, linkInfo) {
426
- var _a7, _b, _c;
427
- this._editPopup && this._editPopup.dispose(), this._editingLink$.next(linkInfo);
428
- let activeRange = this._textSelectionManagerService.getActiveTextRange();
429
- if (linkInfo) {
430
- const { unitId: unitId2, linkId, segmentId, segmentPage } = linkInfo, doc = this._univerInstanceService.getUnit(unitId2, UniverInstanceType.UNIVER_DOC), range = (_c = (_b = (_a7 = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a7.getBody()) == null ? void 0 : _b.customRanges) == null ? void 0 : _c.find((i) => i.rangeId === linkId);
431
- range && (activeRange = {
455
+ showEditPopup(e, t) {
456
+ this._editPopup && this._editPopup.dispose(), this._editingLink$.next(t);
457
+ let i = this._textSelectionManagerService.getActiveTextRange();
458
+ if (t) {
459
+ const { segmentId: r, segmentPage: s, startIndex: o, endIndex: c } = t;
460
+ i = {
432
461
  collapsed: !1,
433
- startOffset: range.startIndex + SKIT_PLACEHOLDER,
434
- endOffset: range.endIndex + 1,
435
- segmentId,
436
- segmentPage
437
- }, this._textSelectionManagerService.replaceTextRanges([{
438
- startOffset: range.startIndex,
439
- endOffset: range.endIndex + 1
440
- }]));
462
+ startOffset: o,
463
+ endOffset: c + 1,
464
+ segmentId: r,
465
+ segmentPage: s
466
+ }, this._textSelectionManagerService.replaceDocRanges([{
467
+ startOffset: o,
468
+ endOffset: c + 1
469
+ }]);
441
470
  }
442
- return activeRange ? (this._editPopup = this._docCanvasPopupManagerService.attachPopupToRange(
443
- activeRange,
471
+ return i ? (this._editPopup = this._docCanvasPopupManagerService.attachPopupToRange(
472
+ i,
444
473
  {
445
- componentKey: DocHyperLinkEdit.componentKey,
474
+ componentKey: K.componentKey,
446
475
  direction: "bottom"
447
476
  },
448
- unitId
477
+ e
449
478
  ), this._editPopup) : null;
450
479
  }
451
480
  hideEditPopup() {
452
- var _a7;
453
- this._editingLink$.next(null), (_a7 = this._editPopup) == null || _a7.dispose();
454
- }
455
- showInfoPopup(info) {
456
- var _a7, _b, _c, _d, _e, _f;
457
- const { linkId, unitId, segmentId, segmentPage } = info;
458
- if (((_a7 = this.showing) == null ? void 0 : _a7.linkId) === linkId && ((_b = this.showing) == null ? void 0 : _b.unitId) === unitId && ((_c = this.showing) == null ? void 0 : _c.segmentId) === segmentId && ((_d = this.showing) == null ? void 0 : _d.segmentPage) === segmentPage)
459
- return;
460
- this._infoPopup && this._infoPopup.dispose();
461
- const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
462
- if (!doc)
463
- return;
464
- const range = (_f = (_e = doc.getSelfOrHeaderFooterModel(info.segmentId).getBody()) == null ? void 0 : _e.customRanges) == null ? void 0 : _f.find((i) => i.rangeId === linkId);
465
- if (this._showingLink$.next({ unitId, linkId, segmentId, segmentPage }), !!range)
466
- return this._infoPopup = this._docCanvasPopupManagerService.attachPopupToRange(
481
+ var e;
482
+ this._editingLink$.next(null), (e = this._editPopup) == null || e.dispose();
483
+ }
484
+ showInfoPopup(e) {
485
+ var l, u, v, p, d, h;
486
+ const { linkId: t, unitId: i, segmentId: r, segmentPage: s, startIndex: o, endIndex: c } = e;
487
+ if (!(((l = this.showing) == null ? void 0 : l.linkId) === t && ((u = this.showing) == null ? void 0 : u.unitId) === i && ((v = this.showing) == null ? void 0 : v.segmentId) === r && ((p = this.showing) == null ? void 0 : p.segmentPage) === s && ((d = this.showing) == null ? void 0 : d.startIndex) === o && ((h = this.showing) == null ? void 0 : h.endIndex) === c || (this._infoPopup && this._infoPopup.dispose(), !this._univerInstanceService.getUnit(i, I.UNIVER_DOC))))
488
+ return this._showingLink$.next({ unitId: i, linkId: t, segmentId: r, segmentPage: s, startIndex: o, endIndex: c }), this._infoPopup = this._docCanvasPopupManagerService.attachPopupToRange(
467
489
  {
468
490
  collapsed: !1,
469
- startOffset: range.startIndex + SKIT_PLACEHOLDER,
470
- endOffset: range.endIndex + 1,
471
- segmentId: info.segmentId,
472
- segmentPage: info.segmentPage
491
+ startOffset: o,
492
+ endOffset: c + 1,
493
+ segmentId: r,
494
+ segmentPage: s
473
495
  },
474
496
  {
475
- componentKey: DocLinkPopup.componentKey,
497
+ componentKey: V.componentKey,
476
498
  direction: "top-center",
477
499
  multipleDirection: "top",
478
- onClickOutside: /* @__PURE__ */ __name(() => {
500
+ onClickOutside: () => {
479
501
  this.hideInfoPopup();
480
- }, "onClickOutside")
502
+ }
481
503
  },
482
- info.unitId
504
+ i
483
505
  ), this._infoPopup;
484
506
  }
485
507
  hideInfoPopup() {
486
- var _a7;
487
- this._showingLink$.next(null), (_a7 = this._infoPopup) == null || _a7.dispose();
488
- }
489
- }, __name(_a, "DocHyperLinkPopupService"), _a);
490
- DocHyperLinkPopupService = __decorateClass$5([
491
- __decorateParam$5(0, Inject(DocCanvasPopManagerService)),
492
- __decorateParam$5(1, Inject(DocSelectionManagerService)),
493
- __decorateParam$5(2, IUniverInstanceService)
494
- ], DocHyperLinkPopupService);
495
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
496
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
497
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
498
- return kind && result && __defProp$4(target, key, result), result;
499
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a2;
500
- let DocHyperLinkSelectionController = (_a2 = class extends Disposable {
501
- constructor(_commandService, _univerInstanceService, _docHyperLinkService) {
502
- super(), this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._docHyperLinkService = _docHyperLinkService, this._initSelectionChange();
508
+ var e;
509
+ this._showingLink$.next(null), (e = this._infoPopup) == null || e.dispose();
510
+ }
511
+ };
512
+ S = dt([
513
+ J(0, _(on)),
514
+ J(1, _(M)),
515
+ J(2, O)
516
+ ], S);
517
+ var at = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, ut = (n, e, t, i) => {
518
+ for (var r = i > 1 ? void 0 : i ? lt(e, t) : e, s = n.length - 1, o; s >= 0; s--)
519
+ (o = n[s]) && (r = (i ? o(e, t, r) : o(r)) || r);
520
+ return i && r && at(e, t, r), r;
521
+ }, Q = (n, e) => (t, i) => e(t, i, n);
522
+ let W = class extends D {
523
+ constructor(n, e, t) {
524
+ super(), this._commandService = n, this._univerInstanceService = e, this._docHyperLinkService = t, this._initSelectionChange();
503
525
  }
504
526
  _initSelectionChange() {
505
527
  this.disposeWithMe(
506
- this._commandService.onCommandExecuted((commandInfo) => {
507
- var _a7, _b, _c;
508
- if (commandInfo.id === SetTextSelectionsOperation.id) {
509
- const params = commandInfo.params, { unitId, ranges, segmentId } = params, doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), primary = ranges[0];
510
- if (primary && doc) {
511
- const { startOffset, endOffset, collapsed, segmentPage } = primary, customRanges = (_b = (_a7 = doc.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a7.getBody()) == null ? void 0 : _b.customRanges;
512
- if (collapsed) {
513
- const index = (_c = customRanges == null ? void 0 : customRanges.findIndex((value) => value.startIndex < startOffset && value.endIndex > endOffset - 1)) != null ? _c : -1;
514
- if (index > -1) {
515
- const customRange = customRanges[index];
516
- this._docHyperLinkService.showInfoPopup({ unitId, linkId: customRange.rangeId, segmentId, segmentPage });
528
+ this._commandService.onCommandExecuted((n) => {
529
+ var e, t, i;
530
+ if (n.id === en.id) {
531
+ const r = n.params, { unitId: s, ranges: o, segmentId: c } = r, g = this._univerInstanceService.getUnit(s, I.UNIVER_DOC), l = o[0];
532
+ if (l && g) {
533
+ const { startOffset: u, endOffset: v, collapsed: p, segmentPage: d } = l, h = (t = (e = g.getSelfOrHeaderFooterModel(c)) == null ? void 0 : e.getBody()) == null ? void 0 : t.customRanges;
534
+ if (p) {
535
+ const C = (i = h == null ? void 0 : h.findIndex((f) => f.startIndex < u && f.endIndex > v - 1)) != null ? i : -1;
536
+ if (C > -1) {
537
+ const f = h[C];
538
+ this._docHyperLinkService.showInfoPopup({ unitId: s, linkId: f.rangeId, segmentId: c, segmentPage: d, startIndex: f.startIndex, endIndex: f.endIndex });
517
539
  return;
518
540
  }
519
- } else if (customRanges == null ? void 0 : customRanges.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1))
541
+ } else if (h == null ? void 0 : h.find((f) => f.startIndex <= u && f.endIndex >= v - 1))
520
542
  return;
521
543
  }
522
544
  this._docHyperLinkService.hideInfoPopup(), this._docHyperLinkService.hideEditPopup();
@@ -524,46 +546,48 @@ let DocHyperLinkSelectionController = (_a2 = class extends Disposable {
524
546
  })
525
547
  );
526
548
  }
527
- }, __name(_a2, "DocHyperLinkSelectionController"), _a2);
528
- DocHyperLinkSelectionController = __decorateClass$4([
529
- __decorateParam$4(0, ICommandService),
530
- __decorateParam$4(1, IUniverInstanceService),
531
- __decorateParam$4(2, Inject(DocHyperLinkPopupService))
532
- ], DocHyperLinkSelectionController);
533
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
534
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
535
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
536
- return kind && result && __defProp$3(target, key, result), result;
537
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a3;
538
- let DocHyperLinkEventRenderController = (_a3 = class extends Disposable {
539
- constructor(_context, _docEventManagerService, _commandService, _hyperLinkPopupService, _docSkeletonManagerService, _docSelectionManagerService) {
540
- super(), this._context = _context, this._docEventManagerService = _docEventManagerService, this._commandService = _commandService, this._hyperLinkPopupService = _hyperLinkPopupService, this._docSkeletonManagerService = _docSkeletonManagerService, this._docSelectionManagerService = _docSelectionManagerService, this._initHover(), this._initClick();
549
+ };
550
+ W = ut([
551
+ Q(0, x),
552
+ Q(1, O),
553
+ Q(2, _(S))
554
+ ], W);
555
+ var pt = Object.defineProperty, ft = Object.getOwnPropertyDescriptor, gt = (n, e, t, i) => {
556
+ for (var r = i > 1 ? void 0 : i ? ft(e, t) : e, s = n.length - 1, o; s >= 0; s--)
557
+ (o = n[s]) && (r = (i ? o(e, t, r) : o(r)) || r);
558
+ return i && r && pt(e, t, r), r;
559
+ }, w = (n, e) => (t, i) => e(t, i, n);
560
+ let re = class extends D {
561
+ constructor(n, e, t, i, r, s) {
562
+ super(), this._context = n, this._docEventManagerService = e, this._commandService = t, this._hyperLinkPopupService = i, this._docSkeletonManagerService = r, this._docSelectionManagerService = s, this._initHover(), this._initClick();
541
563
  }
542
564
  get _skeleton() {
543
565
  return this._docSkeletonManagerService.getSkeleton();
544
566
  }
545
567
  _hideInfoPopup() {
546
568
  this._hyperLinkPopupService.showing && this._commandService.executeCommand(
547
- ToggleDocHyperLinkInfoPopupOperation.id
569
+ ie.id
548
570
  );
549
571
  }
550
572
  _initHover() {
551
573
  this.disposeWithMe(
552
- this._docEventManagerService.hoverCustomRanges$.subscribe((ranges) => {
553
- var _a7;
554
- const link = ranges.find((range) => range.range.rangeType === CustomRangeType.HYPERLINK), activeRanges = this._docSelectionManagerService.getTextRanges(), currentSegmentId = activeRanges == null ? void 0 : activeRanges[0].segmentId;
555
- if (((_a7 = link == null ? void 0 : link.segmentId) != null ? _a7 : "") !== currentSegmentId) {
574
+ this._docEventManagerService.hoverCustomRanges$.subscribe((n) => {
575
+ var r;
576
+ const e = n.find((s) => s.range.rangeType === b.HYPERLINK), t = this._docSelectionManagerService.getTextRanges(), i = t == null ? void 0 : t[0].segmentId;
577
+ if (((r = e == null ? void 0 : e.segmentId) != null ? r : "") !== i) {
556
578
  this._hideInfoPopup();
557
579
  return;
558
580
  }
559
- link ? this._commandService.executeCommand(
560
- ToggleDocHyperLinkInfoPopupOperation.id,
581
+ e ? this._commandService.executeCommand(
582
+ ie.id,
561
583
  {
562
584
  unitId: this._context.unitId,
563
- linkId: link.range.rangeId,
564
- segmentId: link.segmentId,
565
- segmentPage: link.segmentPageIndex,
566
- rangeId: link.range.rangeId
585
+ linkId: e.range.rangeId,
586
+ segmentId: e.segmentId,
587
+ segmentPage: e.segmentPageIndex,
588
+ rangeId: e.range.rangeId,
589
+ startIndex: e.range.startIndex,
590
+ endIndex: e.range.endIndex
567
591
  }
568
592
  ) : this._hideInfoPopup();
569
593
  })
@@ -571,193 +595,198 @@ let DocHyperLinkEventRenderController = (_a3 = class extends Disposable {
571
595
  }
572
596
  _initClick() {
573
597
  this.disposeWithMe(
574
- this._docEventManagerService.clickCustomRanges$.subscribe((range) => {
575
- const link = range.range;
576
- link && this._commandService.executeCommand(
577
- ClickDocHyperLinkOperation.id,
598
+ this._docEventManagerService.clickCustomRanges$.subscribe((n) => {
599
+ const e = n.range;
600
+ e && this._commandService.executeCommand(
601
+ $e.id,
578
602
  {
579
603
  unitId: this._context.unitId,
580
- linkId: link.rangeId,
581
- segmentId: range.segmentId
604
+ linkId: e.rangeId,
605
+ segmentId: n.segmentId
582
606
  }
583
607
  );
584
608
  })
585
609
  );
586
610
  }
587
- }, __name(_a3, "DocHyperLinkEventRenderController"), _a3);
588
- DocHyperLinkEventRenderController = __decorateClass$3([
589
- __decorateParam$3(1, Inject(DocEventManagerService)),
590
- __decorateParam$3(2, ICommandService),
591
- __decorateParam$3(3, Inject(DocHyperLinkPopupService)),
592
- __decorateParam$3(4, Inject(DocSkeletonManagerService)),
593
- __decorateParam$3(5, Inject(DocSelectionManagerService))
594
- ], DocHyperLinkEventRenderController);
595
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
596
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
597
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
598
- return kind && result && __defProp$2(target, key, result), result;
599
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a4;
600
- let DocHyperLinkRenderController = (_a4 = class extends Disposable {
601
- constructor(_context, _docInterceptorService, _hyperLinkService, _docRenderController) {
602
- super(), this._context = _context, this._docInterceptorService = _docInterceptorService, this._hyperLinkService = _hyperLinkService, this._docRenderController = _docRenderController, this._init(), this._initReRender();
611
+ };
612
+ re = gt([
613
+ w(1, _(sn)),
614
+ w(2, x),
615
+ w(3, _(S)),
616
+ w(4, _(nn)),
617
+ w(5, _(M))
618
+ ], re);
619
+ var ht = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, mt = (n, e, t, i) => {
620
+ for (var r = i > 1 ? void 0 : i ? vt(e, t) : e, s = n.length - 1, o; s >= 0; s--)
621
+ (o = n[s]) && (r = (i ? o(e, t, r) : o(r)) || r);
622
+ return i && r && ht(e, t, r), r;
623
+ }, X = (n, e) => (t, i) => e(t, i, n);
624
+ let oe = class extends D {
625
+ constructor(n, e, t, i) {
626
+ super(), this._context = n, this._docInterceptorService = e, this._hyperLinkService = t, this._docRenderController = i, this._init(), this._initReRender();
603
627
  }
604
628
  _init() {
605
- this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_RANGE, {
606
- handler: /* @__PURE__ */ __name((data, pos, next) => {
607
- if (!data)
608
- return next(data);
609
- const { unitId } = pos, activeLink = this._hyperLinkService.showing, { linkId, unitId: linkUnitId } = activeLink || {}, isActive = linkUnitId === unitId && data.rangeId === linkId;
610
- return next({
611
- ...data,
612
- active: isActive
629
+ this._docInterceptorService.intercept(rn.CUSTOM_RANGE, {
630
+ handler: (n, e, t) => {
631
+ if (!n)
632
+ return t(n);
633
+ const { unitId: i, index: r } = e, s = this._hyperLinkService.showing;
634
+ if (!s)
635
+ return t({
636
+ ...n,
637
+ active: !1
638
+ });
639
+ const { linkId: o, unitId: c, startIndex: g, endIndex: l } = s, u = c === i && n.rangeId === o && r >= g && r <= l;
640
+ return t({
641
+ ...n,
642
+ active: u
613
643
  });
614
- }, "handler")
644
+ }
615
645
  });
616
646
  }
617
647
  _initReRender() {
618
648
  this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(
619
- distinctUntilChanged((prev, aft) => (prev == null ? void 0 : prev.linkId) === (aft == null ? void 0 : aft.linkId) && (prev == null ? void 0 : prev.unitId) === (aft == null ? void 0 : aft.unitId)),
620
- pairwise()
621
- ).subscribe(([preLink, link]) => {
622
- link ? link.unitId === this._context.unitId && this._docRenderController.reRender(link.unitId) : preLink && preLink.unitId === this._context.unitId && this._docRenderController.reRender(preLink.unitId);
649
+ an((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)),
650
+ ln()
651
+ ).subscribe(([n, e]) => {
652
+ e ? e.unitId === this._context.unitId && this._docRenderController.reRender(e.unitId) : n && n.unitId === this._context.unitId && this._docRenderController.reRender(n.unitId);
623
653
  }));
624
654
  }
625
- }, __name(_a4, "DocHyperLinkRenderController"), _a4);
626
- DocHyperLinkRenderController = __decorateClass$2([
627
- __decorateParam$2(1, Inject(DocInterceptorService)),
628
- __decorateParam$2(2, Inject(DocHyperLinkPopupService)),
629
- __decorateParam$2(3, Inject(DocRenderController))
630
- ], DocHyperLinkRenderController);
631
- const DOC_LINK_ICON = "doc-hyper-link-icon";
632
- function AddHyperLinkMenuItemFactory(accessor) {
655
+ };
656
+ oe = mt([
657
+ X(1, _(tn)),
658
+ X(2, _(S)),
659
+ X(3, _(cn))
660
+ ], oe);
661
+ const Ue = "doc-hyper-link-icon";
662
+ function Se(n) {
633
663
  return {
634
- id: ShowDocHyperLinkEditPopupOperation.id,
635
- type: MenuItemType.BUTTON,
636
- icon: DOC_LINK_ICON,
664
+ id: R.id,
665
+ type: Cn.BUTTON,
666
+ icon: Ue,
637
667
  title: "docLink.menu.tooltip",
638
668
  tooltip: "docLink.menu.tooltip",
639
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
640
- disabled$: new Observable(function(subscribe) {
641
- const observer = accessor.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe(() => {
642
- subscribe.next(shouldDisableAddLink(accessor));
669
+ hidden$: Ln(n, I.UNIVER_DOC),
670
+ disabled$: new un(function(e) {
671
+ const i = n.get(M).textSelection$.pipe(pn(16)).subscribe(() => {
672
+ e.next(je(n));
643
673
  });
644
674
  return () => {
645
- observer.unsubscribe();
675
+ i.unsubscribe();
646
676
  };
647
677
  })
648
678
  };
649
679
  }
650
- __name(AddHyperLinkMenuItemFactory, "AddHyperLinkMenuItemFactory");
651
- const addLinkShortcut = {
652
- id: ShowDocHyperLinkEditPopupOperation.id,
653
- binding: MetaKeys.CTRL_COMMAND | KeyCode.K,
680
+ const _t = {
681
+ id: R.id,
682
+ binding: In.CTRL_COMMAND | te.K,
654
683
  description: "docLink.menu.tooltip",
655
- preconditions: whenDocAndEditorFocused
656
- }, menuSchema = {
657
- [RibbonStartGroup.OTHERS]: {
658
- [ShowDocHyperLinkEditPopupOperation.id]: {
684
+ preconditions: dn
685
+ }, It = {
686
+ [Sn.OTHERS]: {
687
+ [R.id]: {
659
688
  order: 0,
660
- menuItemFactory: AddHyperLinkMenuItemFactory
689
+ menuItemFactory: Se
661
690
  }
662
691
  },
663
- [ContextMenuPosition.MAIN_AREA]: {
664
- [ContextMenuGroup.DATA]: {
665
- [ShowDocHyperLinkEditPopupOperation.id]: {
692
+ [yn.MAIN_AREA]: {
693
+ [kn.DATA]: {
694
+ [R.id]: {
666
695
  order: 0,
667
- menuItemFactory: AddHyperLinkMenuItemFactory
696
+ menuItemFactory: Se
668
697
  }
669
698
  }
670
699
  }
671
700
  };
672
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
673
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
674
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
675
- return kind && result && __defProp$1(target, key, result), result;
676
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a5;
677
- let DocHyperLinkUIController = (_a5 = class extends Disposable {
678
- constructor(_componentManager, _commandService, _menuManagerService, _shortcutService) {
679
- super(), this._componentManager = _componentManager, this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortcut();
701
+ var Ct = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, St = (n, e, t, i) => {
702
+ for (var r = i > 1 ? void 0 : i ? Lt(e, t) : e, s = n.length - 1, o; s >= 0; s--)
703
+ (o = n[s]) && (r = (i ? o(e, t, r) : o(r)) || r);
704
+ return i && r && Ct(e, t, r), r;
705
+ }, F = (n, e) => (t, i) => e(t, i, n);
706
+ let Y = class extends D {
707
+ constructor(n, e, t, i) {
708
+ super(), this._componentManager = n, this._commandService = e, this._menuManagerService = t, this._shortcutService = i, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortcut();
680
709
  }
681
710
  _initComponents() {
682
711
  [
683
- [DocHyperLinkEdit, DocHyperLinkEdit.componentKey],
684
- [DocLinkPopup, DocLinkPopup.componentKey],
685
- [LinkSingle, DOC_LINK_ICON]
686
- ].forEach(([comp, key]) => {
687
- this._componentManager.register(key, comp);
712
+ [K, K.componentKey],
713
+ [V, V.componentKey],
714
+ [se, Ue]
715
+ ].forEach(([n, e]) => {
716
+ this._componentManager.register(e, n);
688
717
  });
689
718
  }
690
719
  _initCommands() {
691
720
  [
692
- AddDocHyperLinkCommand,
693
- UpdateDocHyperLinkCommand,
694
- DeleteDocHyperLinkCommand,
695
- ShowDocHyperLinkEditPopupOperation,
696
- ToggleDocHyperLinkInfoPopupOperation,
697
- ClickDocHyperLinkOperation
698
- ].forEach((command) => {
699
- this._commandService.registerCommand(command);
721
+ Pe,
722
+ Re,
723
+ Ne,
724
+ R,
725
+ ie,
726
+ $e
727
+ ].forEach((n) => {
728
+ this._commandService.registerCommand(n);
700
729
  });
701
730
  }
702
731
  _initShortcut() {
703
- [addLinkShortcut].forEach((shortcut) => {
704
- this._shortcutService.registerShortcut(shortcut);
732
+ [_t].forEach((n) => {
733
+ this._shortcutService.registerShortcut(n);
705
734
  });
706
735
  }
707
736
  _initMenus() {
708
- this._menuManagerService.mergeMenu(menuSchema);
709
- }
710
- }, __name(_a5, "DocHyperLinkUIController"), _a5);
711
- DocHyperLinkUIController = __decorateClass$1([
712
- __decorateParam$1(0, Inject(ComponentManager)),
713
- __decorateParam$1(1, ICommandService),
714
- __decorateParam$1(2, IMenuManagerService),
715
- __decorateParam$1(3, IShortcutService)
716
- ], DocHyperLinkUIController);
717
- const DOC_HYPER_LINK_UI_PLUGIN = "DOC_HYPER_LINK_UI_PLUGIN";
718
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
719
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
720
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
721
- return kind && result && __defProp2(target, key, result), result;
722
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a6;
723
- let UniverDocsHyperLinkUIPlugin = (_a6 = class extends Plugin {
724
- constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
725
- super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._configService = _configService;
726
- const { menu, ...rest } = this._config;
727
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
737
+ this._menuManagerService.mergeMenu(It);
738
+ }
739
+ };
740
+ Y = St([
741
+ F(0, _(xn)),
742
+ F(1, x),
743
+ F(2, On),
744
+ F(3, Pn)
745
+ ], Y);
746
+ const yt = "DOC_HYPER_LINK_UI_PLUGIN";
747
+ var Te = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, xt = (n, e, t) => e in n ? Te(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, Ot = (n, e, t, i) => {
748
+ for (var r = i > 1 ? void 0 : i ? kt(e, t) : e, s = n.length - 1, o; s >= 0; s--)
749
+ (o = n[s]) && (r = (i ? o(e, t, r) : o(r)) || r);
750
+ return i && r && Te(e, t, r), r;
751
+ }, ee = (n, e) => (t, i) => e(t, i, n), He = (n, e, t) => xt(n, typeof e != "symbol" ? e + "" : e, t);
752
+ let G = class extends Ge {
753
+ constructor(n = En, e, t, i) {
754
+ super(), this._config = n, this._injector = e, this._renderManagerSrv = t, this._configService = i;
755
+ const { menu: r, ...s } = this._config;
756
+ r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Rn, s);
728
757
  }
729
758
  onStarting() {
730
759
  [
731
- [DocHyperLinkPopupService],
732
- [DocHyperLinkUIController],
733
- [DocHyperLinkSelectionController]
734
- ].forEach((dep) => {
735
- this._injector.add(dep);
736
- }), this._injector.get(DocHyperLinkUIController);
760
+ [S],
761
+ [Y],
762
+ [W]
763
+ ].forEach((e) => {
764
+ this._injector.add(e);
765
+ }), this._injector.get(Y);
737
766
  }
738
767
  onReady() {
739
- this._injector.get(DocHyperLinkSelectionController);
768
+ this._injector.get(W);
740
769
  }
741
770
  onRendered() {
742
771
  this._initRenderModule();
743
772
  }
744
773
  _initRenderModule() {
745
774
  [
746
- [DocHyperLinkRenderController],
747
- [DocHyperLinkEventRenderController]
748
- ].forEach((dep) => {
749
- this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, dep);
775
+ [oe],
776
+ [re]
777
+ ].forEach((n) => {
778
+ this._renderManagerSrv.registerRenderModule(I.UNIVER_DOC, n);
750
779
  });
751
780
  }
752
- }, __name(_a6, "UniverDocsHyperLinkUIPlugin"), _a6);
753
- __publicField2(UniverDocsHyperLinkUIPlugin, "pluginName", DOC_HYPER_LINK_UI_PLUGIN);
754
- __publicField2(UniverDocsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
755
- UniverDocsHyperLinkUIPlugin = __decorateClass([
756
- DependentOn(UniverDocsHyperLinkPlugin),
757
- __decorateParam(1, Inject(Injector)),
758
- __decorateParam(2, IRenderManagerService),
759
- __decorateParam(3, IConfigService)
760
- ], UniverDocsHyperLinkUIPlugin);
781
+ };
782
+ He(G, "pluginName", yt);
783
+ He(G, "type", I.UNIVER_DOC);
784
+ G = Ot([
785
+ We(ze),
786
+ ee(1, _(Ye)),
787
+ ee(2, qe),
788
+ ee(3, Ze)
789
+ ], G);
761
790
  export {
762
- UniverDocsHyperLinkUIPlugin
791
+ G as UniverDocsHyperLinkUIPlugin
763
792
  };