@univerjs/docs-hyper-link-ui 0.5.5-nightly.202501210734 → 0.5.5-nightly.202501210849
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 +541 -528
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/package.json +8 -8
package/lib/es/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
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, useDependency, LocaleService, useObservable, Tools, BuildTextUtils, Disposable, Inject, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Injector, Plugin, merge, IConfigService } from "@univerjs/core";
|
|
6
|
+
import { UniverDocsHyperLinkPlugin } from "@univerjs/docs-hyper-link";
|
|
7
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
8
|
+
import { addCustomRangeBySelectionFactory, DocSelectionManagerService, replaceSelectionFactory, deleteCustomRangeFactory, SetTextSelectionsOperation, DocSkeletonManagerService, DocInterceptorService, DOC_INTERCEPTOR_POINT } from "@univerjs/docs";
|
|
9
|
+
import { DocCanvasPopManagerService, DocEventManagerService, DocRenderController, whenDocAndEditorFocused } from "@univerjs/docs-ui";
|
|
10
|
+
import { BehaviorSubject, distinctUntilChanged, pairwise, Observable, debounceTime } from "rxjs";
|
|
11
|
+
import require$$0, { useState, useEffect, forwardRef, useRef, createElement } from "react";
|
|
12
|
+
import { FormLayout, Input, Button, Tooltip, MessageType } from "@univerjs/design";
|
|
13
|
+
import { KeyCode, IMessageService, useObservable as useObservable$1, MetaKeys, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IMenuManagerService, IShortcutService } from "@univerjs/ui";
|
|
14
|
+
const DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY = "docs-hyper-link-ui.config", defaultPluginConfig = {};
|
|
15
|
+
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
15
16
|
/**
|
|
16
17
|
* @license React
|
|
17
18
|
* react-jsx-runtime.production.min.js
|
|
@@ -21,421 +22,432 @@ var z = { exports: {} }, M = {};
|
|
|
21
22
|
* This source code is licensed under the MIT license found in the
|
|
22
23
|
* LICENSE file in the root directory of this source tree.
|
|
23
24
|
*/
|
|
24
|
-
var
|
|
25
|
-
function
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
function
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
for (
|
|
33
|
-
if (c && c.defaultProps) for (
|
|
34
|
-
return { $$typeof:
|
|
35
|
-
}
|
|
36
|
-
return
|
|
25
|
+
var hasRequiredReactJsxRuntime_production_min;
|
|
26
|
+
function requireReactJsxRuntime_production_min() {
|
|
27
|
+
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
28
|
+
hasRequiredReactJsxRuntime_production_min = 1;
|
|
29
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
30
|
+
function q(c, a, g) {
|
|
31
|
+
var b, d = {}, e = null, h = null;
|
|
32
|
+
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
|
|
33
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
34
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
35
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
36
|
+
}
|
|
37
|
+
return __name(q, "q"), reactJsxRuntime_production_min.Fragment = l, reactJsxRuntime_production_min.jsx = q, reactJsxRuntime_production_min.jsxs = q, reactJsxRuntime_production_min;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
__name(requireReactJsxRuntime_production_min, "requireReactJsxRuntime_production_min");
|
|
40
|
+
var hasRequiredJsxRuntime;
|
|
41
|
+
function requireJsxRuntime() {
|
|
42
|
+
return hasRequiredJsxRuntime || (hasRequiredJsxRuntime = 1, jsxRuntime.exports = requireReactJsxRuntime_production_min()), jsxRuntime.exports;
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
__name(requireJsxRuntime, "requireJsxRuntime");
|
|
45
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
46
|
+
const AddDocHyperLinkCommand = {
|
|
47
|
+
type: CommandType.COMMAND,
|
|
45
48
|
id: "docs.command.add-hyper-link",
|
|
46
|
-
async handler(
|
|
47
|
-
if (!
|
|
49
|
+
async handler(accessor, params) {
|
|
50
|
+
if (!params)
|
|
48
51
|
return !1;
|
|
49
|
-
const { payload
|
|
50
|
-
|
|
52
|
+
const { payload, unitId, selections } = params, commandService = accessor.get(ICommandService), id = generateRandomId(), doMutation = addCustomRangeBySelectionFactory(
|
|
53
|
+
accessor,
|
|
51
54
|
{
|
|
52
|
-
rangeId:
|
|
53
|
-
rangeType:
|
|
55
|
+
rangeId: id,
|
|
56
|
+
rangeType: CustomRangeType.HYPERLINK,
|
|
54
57
|
properties: {
|
|
55
|
-
url:
|
|
58
|
+
url: payload
|
|
56
59
|
},
|
|
57
|
-
unitId
|
|
58
|
-
selections
|
|
60
|
+
unitId,
|
|
61
|
+
selections
|
|
59
62
|
}
|
|
60
63
|
);
|
|
61
|
-
return
|
|
64
|
+
return doMutation ? commandService.syncExecuteCommand(doMutation.id, doMutation.params) : !1;
|
|
62
65
|
}
|
|
63
|
-
},
|
|
66
|
+
}, UpdateDocHyperLinkCommand = {
|
|
64
67
|
id: "docs.command.update-hyper-link",
|
|
65
|
-
type:
|
|
66
|
-
handler(
|
|
67
|
-
var
|
|
68
|
-
if (!
|
|
68
|
+
type: CommandType.COMMAND,
|
|
69
|
+
handler(accessor, params) {
|
|
70
|
+
var _a7;
|
|
71
|
+
if (!params)
|
|
69
72
|
return !1;
|
|
70
|
-
const { unitId
|
|
71
|
-
if (!
|
|
73
|
+
const { unitId, payload, segmentId, linkId } = params, commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), currentSelection = accessor.get(DocSelectionManagerService).getActiveTextRange(), doc = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
74
|
+
if (!currentSelection || !doc)
|
|
72
75
|
return !1;
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
unitId
|
|
76
|
+
const textRun = (_a7 = getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(), currentSelection.startOffset, currentSelection.endOffset).textRuns) == null ? void 0 : _a7[0];
|
|
77
|
+
textRun && (textRun.ed = params.label.length + 1);
|
|
78
|
+
const replaceSelection = replaceSelectionFactory(accessor, {
|
|
79
|
+
unitId,
|
|
77
80
|
body: {
|
|
78
|
-
dataStream: `${
|
|
81
|
+
dataStream: `${params.label}`,
|
|
79
82
|
customRanges: [{
|
|
80
|
-
rangeId:
|
|
81
|
-
rangeType:
|
|
83
|
+
rangeId: linkId,
|
|
84
|
+
rangeType: CustomRangeType.HYPERLINK,
|
|
82
85
|
startIndex: 0,
|
|
83
|
-
endIndex:
|
|
86
|
+
endIndex: params.label.length + 1,
|
|
84
87
|
properties: {
|
|
85
|
-
url:
|
|
88
|
+
url: payload
|
|
86
89
|
}
|
|
87
90
|
}],
|
|
88
|
-
textRuns:
|
|
91
|
+
textRuns: textRun ? [textRun] : void 0
|
|
89
92
|
},
|
|
90
93
|
selection: {
|
|
91
|
-
startOffset:
|
|
92
|
-
endOffset:
|
|
94
|
+
startOffset: currentSelection.startOffset,
|
|
95
|
+
endOffset: currentSelection.endOffset,
|
|
93
96
|
collapsed: !1,
|
|
94
|
-
segmentId
|
|
97
|
+
segmentId
|
|
95
98
|
}
|
|
96
99
|
});
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
docsLinkEdit
|
|
101
|
-
docsLinkEditTitle
|
|
102
|
-
docsLinkEditClose
|
|
103
|
-
docsLinkEditButtons
|
|
104
|
-
docsLinkEditButton
|
|
100
|
+
return replaceSelection ? commandService.syncExecuteCommand(replaceSelection.id, replaceSelection.params) : !1;
|
|
101
|
+
}
|
|
102
|
+
}, 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 = {
|
|
103
|
+
docsLinkEdit,
|
|
104
|
+
docsLinkEditTitle,
|
|
105
|
+
docsLinkEditClose,
|
|
106
|
+
docsLinkEditButtons,
|
|
107
|
+
docsLinkEditButton
|
|
105
108
|
};
|
|
106
|
-
function
|
|
107
|
-
return /^[a-zA-Z]+:\/\//.test(
|
|
109
|
+
function hasProtocol(urlString) {
|
|
110
|
+
return /^[a-zA-Z]+:\/\//.test(urlString);
|
|
108
111
|
}
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
__name(hasProtocol, "hasProtocol");
|
|
113
|
+
function isEmail(url) {
|
|
114
|
+
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
|
|
111
115
|
}
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
__name(isEmail, "isEmail");
|
|
117
|
+
function transformUrl(urlStr) {
|
|
118
|
+
return hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `https://${urlStr}`;
|
|
114
119
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
__name(transformUrl, "transformUrl");
|
|
121
|
+
const DocHyperLinkEdit = /* @__PURE__ */ __name(() => {
|
|
122
|
+
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);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
var _a7, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
125
|
+
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
126
|
+
if (!activeRange)
|
|
121
127
|
return;
|
|
122
|
-
if (
|
|
123
|
-
const
|
|
124
|
-
|
|
128
|
+
if (editing) {
|
|
129
|
+
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 && i.startIndex === editing.startIndex && i.endIndex === editing.endIndex);
|
|
130
|
+
doc && matchedRange2 && (setLink((_d = (_c = matchedRange2.properties) == null ? void 0 : _c.url) != null ? _d : ""), setLabel(BuildTextUtils.transform.getPlainText(getBodySlice(body2, matchedRange2.startIndex, matchedRange2.endIndex + 1).dataStream)));
|
|
125
131
|
return;
|
|
126
132
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
}, [
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
if (
|
|
133
|
+
const body = (_e = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(activeRange.segmentId)) == null ? void 0 : _e.getBody(), selection = body ? activeRange : null, matchedRange = selection && ((_g = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_f = body == null ? void 0 : body.customRanges) != null ? _f : [])) == null ? void 0 : _g[0]);
|
|
134
|
+
doc && matchedRange && setLink((_i = (_h = matchedRange == null ? void 0 : matchedRange.properties) == null ? void 0 : _h.url) != null ? _i : "");
|
|
135
|
+
}, [doc, editing, docSelectionManagerService, univerInstanceService]);
|
|
136
|
+
const handleCancel = /* @__PURE__ */ __name(() => {
|
|
137
|
+
hyperLinkService.hideEditPopup();
|
|
138
|
+
}, "handleCancel"), handleConfirm = /* @__PURE__ */ __name(() => {
|
|
139
|
+
if (setShowError(!0), !isLegal || !doc)
|
|
134
140
|
return;
|
|
135
|
-
const
|
|
136
|
-
if (!
|
|
137
|
-
|
|
138
|
-
unitId:
|
|
139
|
-
payload:
|
|
141
|
+
const linkFinal = transformUrl(link);
|
|
142
|
+
if (!editing)
|
|
143
|
+
commandService.executeCommand(AddDocHyperLinkCommand.id, {
|
|
144
|
+
unitId: doc.getUnitId(),
|
|
145
|
+
payload: linkFinal
|
|
140
146
|
});
|
|
141
147
|
else {
|
|
142
|
-
if (!
|
|
148
|
+
if (!label)
|
|
143
149
|
return;
|
|
144
|
-
|
|
145
|
-
unitId:
|
|
146
|
-
payload:
|
|
147
|
-
linkId:
|
|
148
|
-
label
|
|
149
|
-
segmentId:
|
|
150
|
+
commandService.executeCommand(UpdateDocHyperLinkCommand.id, {
|
|
151
|
+
unitId: doc.getUnitId(),
|
|
152
|
+
payload: linkFinal,
|
|
153
|
+
linkId: editing.linkId,
|
|
154
|
+
label,
|
|
155
|
+
segmentId: editing.segmentId
|
|
150
156
|
});
|
|
151
157
|
}
|
|
152
|
-
|
|
153
|
-
};
|
|
154
|
-
if (
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
hyperLinkService.hideEditPopup();
|
|
159
|
+
}, "handleConfirm");
|
|
160
|
+
if (doc)
|
|
161
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.docsLinkEdit, children: [
|
|
162
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
163
|
+
editing ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
164
|
+
FormLayout,
|
|
159
165
|
{
|
|
160
|
-
label:
|
|
161
|
-
error:
|
|
162
|
-
children: /* @__PURE__ */
|
|
163
|
-
|
|
166
|
+
label: localeService.t("docLink.edit.label"),
|
|
167
|
+
error: showError && !label ? localeService.t("docLink.edit.labelError") : "",
|
|
168
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
169
|
+
Input,
|
|
164
170
|
{
|
|
165
|
-
value:
|
|
166
|
-
onChange:
|
|
171
|
+
value: label,
|
|
172
|
+
onChange: setLabel,
|
|
167
173
|
autoFocus: !0,
|
|
168
|
-
onKeyDown: (
|
|
169
|
-
|
|
170
|
-
}
|
|
174
|
+
onKeyDown: /* @__PURE__ */ __name((evt) => {
|
|
175
|
+
evt.keyCode === KeyCode.ENTER && handleConfirm();
|
|
176
|
+
}, "onKeyDown")
|
|
171
177
|
}
|
|
172
178
|
)
|
|
173
179
|
}
|
|
174
180
|
) : null,
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
|
|
181
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
182
|
+
FormLayout,
|
|
177
183
|
{
|
|
178
|
-
label:
|
|
179
|
-
error:
|
|
180
|
-
children: /* @__PURE__ */
|
|
181
|
-
|
|
184
|
+
label: localeService.t("docLink.edit.address"),
|
|
185
|
+
error: showError && !isLegal ? localeService.t("docLink.edit.addressError") : "",
|
|
186
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
187
|
+
Input,
|
|
182
188
|
{
|
|
183
|
-
value:
|
|
184
|
-
onChange:
|
|
189
|
+
value: link,
|
|
190
|
+
onChange: setLink,
|
|
185
191
|
autoFocus: !0,
|
|
186
|
-
onKeyDown: (
|
|
187
|
-
|
|
188
|
-
}
|
|
192
|
+
onKeyDown: /* @__PURE__ */ __name((evt) => {
|
|
193
|
+
evt.keyCode === KeyCode.ENTER && handleConfirm();
|
|
194
|
+
}, "onKeyDown")
|
|
189
195
|
}
|
|
190
196
|
)
|
|
191
197
|
}
|
|
192
198
|
)
|
|
193
199
|
] }),
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
/* @__PURE__ */
|
|
196
|
-
|
|
200
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.docsLinkEditButtons, children: [
|
|
201
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
202
|
+
Button,
|
|
197
203
|
{
|
|
198
|
-
className:
|
|
199
|
-
onClick:
|
|
200
|
-
children:
|
|
204
|
+
className: styles$1.docsLinkEditButton,
|
|
205
|
+
onClick: handleCancel,
|
|
206
|
+
children: localeService.t("docLink.edit.cancel")
|
|
201
207
|
}
|
|
202
208
|
),
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
|
|
209
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
210
|
+
Button,
|
|
205
211
|
{
|
|
206
|
-
disabled: !
|
|
207
|
-
className:
|
|
212
|
+
disabled: !link,
|
|
213
|
+
className: styles$1.docsLinkEditButton,
|
|
208
214
|
type: "primary",
|
|
209
|
-
onClick:
|
|
210
|
-
children:
|
|
215
|
+
onClick: handleConfirm,
|
|
216
|
+
children: localeService.t("docLink.edit.confirm")
|
|
211
217
|
}
|
|
212
218
|
)
|
|
213
219
|
] })
|
|
214
220
|
] });
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
var
|
|
218
|
-
return
|
|
219
|
-
for (var
|
|
220
|
-
|
|
221
|
-
for (var
|
|
221
|
+
}, "DocHyperLinkEdit");
|
|
222
|
+
DocHyperLinkEdit.componentKey = "docs-hyper-link-edit";
|
|
223
|
+
var __assign = function() {
|
|
224
|
+
return __assign = Object.assign || function(t) {
|
|
225
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
226
|
+
s = arguments[i];
|
|
227
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
222
228
|
}
|
|
223
|
-
return
|
|
224
|
-
},
|
|
225
|
-
},
|
|
229
|
+
return t;
|
|
230
|
+
}, __assign.apply(this, arguments);
|
|
231
|
+
}, __rest = function(s, e) {
|
|
226
232
|
var t = {};
|
|
227
|
-
for (var
|
|
228
|
-
if (
|
|
229
|
-
for (var
|
|
230
|
-
e.indexOf(i
|
|
233
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
234
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
235
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
236
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
231
237
|
return t;
|
|
232
|
-
},
|
|
233
|
-
var
|
|
234
|
-
return
|
|
238
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
239
|
+
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()));
|
|
240
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
235
241
|
});
|
|
236
|
-
function
|
|
237
|
-
return
|
|
238
|
-
return
|
|
242
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
243
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
244
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
239
245
|
}));
|
|
240
246
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
__name(render, "render");
|
|
248
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
249
|
+
var attrs = __assign({}, node.attrs);
|
|
250
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
251
|
+
var defIds = runtimeProps.defIds;
|
|
252
|
+
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) {
|
|
253
|
+
var key = _a7[0], value = _a7[1];
|
|
254
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
255
|
+
})), attrs;
|
|
249
256
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
257
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
258
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
259
|
+
var _a7, defIds = runtimeProps.defIds;
|
|
260
|
+
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) {
|
|
261
|
+
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;
|
|
262
|
+
}) }) : node;
|
|
255
263
|
}
|
|
256
|
-
|
|
264
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
265
|
+
function generateShortUuid() {
|
|
257
266
|
return Math.random().toString(36).substring(2, 8);
|
|
258
267
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
268
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
269
|
+
IconBase.displayName = "UniverIcon";
|
|
270
|
+
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) {
|
|
271
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
262
272
|
id: "copy-single",
|
|
263
|
-
ref
|
|
264
|
-
icon:
|
|
273
|
+
ref,
|
|
274
|
+
icon: element$3
|
|
265
275
|
}));
|
|
266
276
|
});
|
|
267
|
-
|
|
268
|
-
var
|
|
269
|
-
return
|
|
277
|
+
CopySingle.displayName = "CopySingle";
|
|
278
|
+
var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", 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" } }, { tag: "path", attrs: { fill: "currentColor", 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" } }] }, LinkSingle = forwardRef(function(props, ref) {
|
|
279
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
270
280
|
id: "link-single",
|
|
271
|
-
ref
|
|
272
|
-
icon:
|
|
281
|
+
ref,
|
|
282
|
+
icon: element$2
|
|
273
283
|
}));
|
|
274
284
|
});
|
|
275
|
-
|
|
276
|
-
var
|
|
277
|
-
return
|
|
285
|
+
LinkSingle.displayName = "LinkSingle";
|
|
286
|
+
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) {
|
|
287
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
278
288
|
id: "unlink-single",
|
|
279
|
-
ref
|
|
280
|
-
icon:
|
|
289
|
+
ref,
|
|
290
|
+
icon: element$1
|
|
281
291
|
}));
|
|
282
292
|
});
|
|
283
|
-
|
|
284
|
-
var
|
|
285
|
-
return
|
|
293
|
+
UnlinkSingle.displayName = "UnlinkSingle";
|
|
294
|
+
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) {
|
|
295
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
286
296
|
id: "write-single",
|
|
287
|
-
ref
|
|
288
|
-
icon:
|
|
297
|
+
ref,
|
|
298
|
+
icon: element
|
|
289
299
|
}));
|
|
290
300
|
});
|
|
291
|
-
|
|
292
|
-
function
|
|
293
|
-
var
|
|
294
|
-
if (typeof
|
|
295
|
-
else if (typeof
|
|
296
|
-
var
|
|
297
|
-
for (
|
|
298
|
-
} else for (
|
|
299
|
-
return
|
|
301
|
+
WriteSingle.displayName = "WriteSingle";
|
|
302
|
+
function r(e) {
|
|
303
|
+
var t, f, n = "";
|
|
304
|
+
if (typeof e == "string" || typeof e == "number") n += e;
|
|
305
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
306
|
+
var o = e.length;
|
|
307
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
308
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
309
|
+
return n;
|
|
300
310
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
311
|
+
__name(r, "r");
|
|
312
|
+
function clsx() {
|
|
313
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
314
|
+
return n;
|
|
304
315
|
}
|
|
305
|
-
|
|
306
|
-
|
|
316
|
+
__name(clsx, "clsx");
|
|
317
|
+
const DeleteDocHyperLinkCommand = {
|
|
318
|
+
type: CommandType.COMMAND,
|
|
307
319
|
id: "docs.command.delete-hyper-link",
|
|
308
|
-
async handler(
|
|
309
|
-
if (!
|
|
320
|
+
async handler(accessor, params) {
|
|
321
|
+
if (!params)
|
|
310
322
|
return !1;
|
|
311
|
-
const { unitId
|
|
312
|
-
return
|
|
323
|
+
const { unitId, linkId, segmentId } = params, commandService = accessor.get(ICommandService), doMutation = deleteCustomRangeFactory(accessor, { unitId, rangeId: linkId, segmentId });
|
|
324
|
+
return doMutation ? await commandService.syncExecuteCommand(doMutation.id, doMutation.params) : !1;
|
|
313
325
|
}
|
|
314
|
-
},
|
|
315
|
-
const
|
|
316
|
-
if (!(
|
|
326
|
+
}, shouldDisableAddLink = /* @__PURE__ */ __name((accessor) => {
|
|
327
|
+
const textSelectionService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), textRanges = textSelectionService.getTextRanges();
|
|
328
|
+
if (!(textRanges != null && textRanges.length))
|
|
317
329
|
return !0;
|
|
318
|
-
const
|
|
319
|
-
return !!(!
|
|
320
|
-
},
|
|
321
|
-
type:
|
|
330
|
+
const activeRange = textRanges[0];
|
|
331
|
+
return !!(!univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC) || !activeRange || activeRange.collapsed);
|
|
332
|
+
}, "shouldDisableAddLink"), ShowDocHyperLinkEditPopupOperation = {
|
|
333
|
+
type: CommandType.OPERATION,
|
|
322
334
|
id: "doc.operation.show-hyper-link-edit-popup",
|
|
323
|
-
handler(
|
|
324
|
-
var
|
|
325
|
-
const
|
|
326
|
-
if (
|
|
335
|
+
handler(accessor, params) {
|
|
336
|
+
var _a7;
|
|
337
|
+
const linkInfo = params == null ? void 0 : params.link, univerInstanceService = accessor.get(IUniverInstanceService);
|
|
338
|
+
if (shouldDisableAddLink(accessor) && !linkInfo)
|
|
327
339
|
return !1;
|
|
328
|
-
const
|
|
329
|
-
return
|
|
340
|
+
const hyperLinkService = accessor.get(DocHyperLinkPopupService), unitId = (linkInfo == null ? void 0 : linkInfo.unitId) || ((_a7 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a7.getUnitId());
|
|
341
|
+
return unitId ? (hyperLinkService.showEditPopup(unitId, linkInfo), !0) : !1;
|
|
330
342
|
}
|
|
331
|
-
},
|
|
332
|
-
type:
|
|
343
|
+
}, ToggleDocHyperLinkInfoPopupOperation = {
|
|
344
|
+
type: CommandType.OPERATION,
|
|
333
345
|
id: "doc.operation.toggle-hyper-link-info-popup",
|
|
334
|
-
handler(
|
|
335
|
-
const
|
|
336
|
-
return
|
|
346
|
+
handler(accessor, params) {
|
|
347
|
+
const hyperLinkService = accessor.get(DocHyperLinkPopupService);
|
|
348
|
+
return params ? (hyperLinkService.showInfoPopup(params), !0) : (hyperLinkService.hideInfoPopup(), !0);
|
|
337
349
|
}
|
|
338
|
-
},
|
|
339
|
-
type:
|
|
350
|
+
}, ClickDocHyperLinkOperation = {
|
|
351
|
+
type: CommandType.OPERATION,
|
|
340
352
|
id: "doc.operation.click-hyper-link",
|
|
341
|
-
handler(
|
|
342
|
-
var
|
|
343
|
-
if (!
|
|
353
|
+
handler(accessor, params) {
|
|
354
|
+
var _a7, _b, _c;
|
|
355
|
+
if (!params)
|
|
344
356
|
return !1;
|
|
345
|
-
const { unitId
|
|
346
|
-
return
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
docLink
|
|
350
|
-
docLinkType
|
|
351
|
-
docLinkContent
|
|
352
|
-
docLinkContentError
|
|
353
|
-
docLinkUrl
|
|
354
|
-
docLinkOperations
|
|
355
|
-
docLinkOperation
|
|
356
|
-
docLinkOperationError
|
|
357
|
-
},
|
|
358
|
-
var
|
|
359
|
-
const
|
|
360
|
-
if (!
|
|
357
|
+
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;
|
|
358
|
+
return link && window.open(link, "_blank", "noopener noreferrer"), !0;
|
|
359
|
+
}
|
|
360
|
+
}, 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 = {
|
|
361
|
+
docLink,
|
|
362
|
+
docLinkType,
|
|
363
|
+
docLinkContent,
|
|
364
|
+
docLinkContentError,
|
|
365
|
+
docLinkUrl,
|
|
366
|
+
docLinkOperations,
|
|
367
|
+
docLinkOperation,
|
|
368
|
+
docLinkOperationError
|
|
369
|
+
}, DocLinkPopup = /* @__PURE__ */ __name(() => {
|
|
370
|
+
var _a7, _b;
|
|
371
|
+
const hyperLinkService = useDependency(DocHyperLinkPopupService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), currentPopup = useObservable$1(hyperLinkService.showingLink$), univerInstanceService = useDependency(IUniverInstanceService);
|
|
372
|
+
if (!currentPopup)
|
|
361
373
|
return null;
|
|
362
|
-
const { unitId
|
|
363
|
-
if (!
|
|
374
|
+
const { unitId, linkId, segmentId, startIndex, endIndex } = 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 && range.startIndex === startIndex && range.endIndex === endIndex);
|
|
375
|
+
if (!link)
|
|
364
376
|
return null;
|
|
365
|
-
const
|
|
366
|
-
return /* @__PURE__ */
|
|
377
|
+
const url = (_b = link.properties) == null ? void 0 : _b.url;
|
|
378
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
367
379
|
"div",
|
|
368
380
|
{
|
|
369
|
-
className:
|
|
370
|
-
onClick: () => {
|
|
371
|
-
|
|
372
|
-
},
|
|
381
|
+
className: styles.docLink,
|
|
382
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
383
|
+
hyperLinkService.hideInfoPopup();
|
|
384
|
+
}, "onClick"),
|
|
373
385
|
children: [
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: clsx(styles.docLinkContent), onClick: /* @__PURE__ */ __name(() => window.open(url), "onClick"), children: [
|
|
387
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.docLinkType, children: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkSingle, {}) }),
|
|
388
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { showIfEllipsis: !0, title: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles.docLinkUrl, children: url }) })
|
|
377
389
|
] }),
|
|
378
|
-
/* @__PURE__ */
|
|
379
|
-
/* @__PURE__ */
|
|
390
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.docLinkOperations, children: [
|
|
391
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
380
392
|
"div",
|
|
381
393
|
{
|
|
382
|
-
className:
|
|
383
|
-
onClick: () => {
|
|
384
|
-
navigator.clipboard.writeText(
|
|
385
|
-
content:
|
|
386
|
-
type:
|
|
394
|
+
className: clsx(styles.docLinkOperation),
|
|
395
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
396
|
+
navigator.clipboard.writeText(url), messageService.show({
|
|
397
|
+
content: localeService.t("docLink.info.coped"),
|
|
398
|
+
type: MessageType.Info
|
|
387
399
|
});
|
|
388
|
-
},
|
|
389
|
-
children: /* @__PURE__ */
|
|
400
|
+
}, "onClick"),
|
|
401
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.copy"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopySingle, {}) })
|
|
390
402
|
}
|
|
391
403
|
),
|
|
392
|
-
/* @__PURE__ */
|
|
404
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
393
405
|
"div",
|
|
394
406
|
{
|
|
395
|
-
className:
|
|
396
|
-
onClick: () => {
|
|
397
|
-
|
|
398
|
-
link:
|
|
407
|
+
className: styles.docLinkOperation,
|
|
408
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
409
|
+
commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id, {
|
|
410
|
+
link: currentPopup
|
|
399
411
|
});
|
|
400
|
-
},
|
|
401
|
-
children: /* @__PURE__ */
|
|
412
|
+
}, "onClick"),
|
|
413
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.edit"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(WriteSingle, {}) })
|
|
402
414
|
}
|
|
403
415
|
),
|
|
404
|
-
/* @__PURE__ */
|
|
416
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
405
417
|
"div",
|
|
406
418
|
{
|
|
407
|
-
className:
|
|
408
|
-
onClick: () => {
|
|
409
|
-
|
|
410
|
-
unitId
|
|
411
|
-
linkId:
|
|
412
|
-
segmentId
|
|
419
|
+
className: styles.docLinkOperation,
|
|
420
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
421
|
+
commandService.executeCommand(DeleteDocHyperLinkCommand.id, {
|
|
422
|
+
unitId,
|
|
423
|
+
linkId: link.rangeId,
|
|
424
|
+
segmentId
|
|
413
425
|
});
|
|
414
|
-
},
|
|
415
|
-
children: /* @__PURE__ */
|
|
426
|
+
}, "onClick"),
|
|
427
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.cancel"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(UnlinkSingle, {}) })
|
|
416
428
|
}
|
|
417
429
|
)
|
|
418
430
|
] })
|
|
419
431
|
]
|
|
420
432
|
}
|
|
421
433
|
);
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
var
|
|
425
|
-
for (var
|
|
426
|
-
(
|
|
427
|
-
return
|
|
428
|
-
},
|
|
429
|
-
let
|
|
430
|
-
constructor(
|
|
434
|
+
}, "DocLinkPopup");
|
|
435
|
+
DocLinkPopup.componentKey = "univer.doc.link-info-popup";
|
|
436
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
437
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
438
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
439
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
440
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a;
|
|
441
|
+
let DocHyperLinkPopupService = (_a = class extends Disposable {
|
|
442
|
+
constructor(_docCanvasPopupManagerService, _textSelectionManagerService, _univerInstanceService) {
|
|
431
443
|
super();
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
this._docCanvasPopupManagerService =
|
|
444
|
+
__publicField(this, "_editingLink$", new BehaviorSubject(null));
|
|
445
|
+
__publicField(this, "_showingLink$", new BehaviorSubject(null));
|
|
446
|
+
__publicField(this, "editingLink$", this._editingLink$.asObservable());
|
|
447
|
+
__publicField(this, "showingLink$", this._showingLink$.asObservable());
|
|
448
|
+
__publicField(this, "_editPopup", null);
|
|
449
|
+
__publicField(this, "_infoPopup", null);
|
|
450
|
+
this._docCanvasPopupManagerService = _docCanvasPopupManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._univerInstanceService = _univerInstanceService, this.disposeWithMe(() => {
|
|
439
451
|
this._editingLink$.complete(), this._showingLink$.complete();
|
|
440
452
|
});
|
|
441
453
|
}
|
|
@@ -445,94 +457,94 @@ let L = class extends N {
|
|
|
445
457
|
get showing() {
|
|
446
458
|
return this._showingLink$.value;
|
|
447
459
|
}
|
|
448
|
-
showEditPopup(
|
|
449
|
-
this._editPopup && this._editPopup.dispose(), this._editingLink$.next(
|
|
450
|
-
const
|
|
451
|
-
let
|
|
452
|
-
if (
|
|
453
|
-
const { segmentId
|
|
454
|
-
|
|
460
|
+
showEditPopup(unitId, linkInfo) {
|
|
461
|
+
this._editPopup && this._editPopup.dispose(), this._editingLink$.next(linkInfo);
|
|
462
|
+
const textRanges = this._textSelectionManagerService.getTextRanges({ unitId, subUnitId: unitId });
|
|
463
|
+
let activeRange = textRanges == null ? void 0 : textRanges[textRanges.length - 1];
|
|
464
|
+
if (linkInfo) {
|
|
465
|
+
const { segmentId, segmentPage, startIndex, endIndex } = linkInfo;
|
|
466
|
+
activeRange = {
|
|
455
467
|
collapsed: !1,
|
|
456
|
-
startOffset:
|
|
457
|
-
endOffset:
|
|
458
|
-
segmentId
|
|
459
|
-
segmentPage
|
|
468
|
+
startOffset: startIndex,
|
|
469
|
+
endOffset: endIndex + 1,
|
|
470
|
+
segmentId,
|
|
471
|
+
segmentPage
|
|
460
472
|
}, this._textSelectionManagerService.replaceDocRanges([{
|
|
461
|
-
startOffset:
|
|
462
|
-
endOffset:
|
|
473
|
+
startOffset: startIndex,
|
|
474
|
+
endOffset: endIndex + 1
|
|
463
475
|
}]);
|
|
464
476
|
}
|
|
465
|
-
return
|
|
466
|
-
|
|
477
|
+
return activeRange ? (this._editPopup = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
478
|
+
activeRange,
|
|
467
479
|
{
|
|
468
|
-
componentKey:
|
|
480
|
+
componentKey: DocHyperLinkEdit.componentKey,
|
|
469
481
|
direction: "bottom"
|
|
470
482
|
},
|
|
471
|
-
|
|
483
|
+
unitId
|
|
472
484
|
), this._editPopup) : null;
|
|
473
485
|
}
|
|
474
486
|
hideEditPopup() {
|
|
475
|
-
var
|
|
476
|
-
this._editingLink$.next(null), (
|
|
477
|
-
}
|
|
478
|
-
showInfoPopup(
|
|
479
|
-
var
|
|
480
|
-
const { linkId
|
|
481
|
-
if (!(((
|
|
482
|
-
return this._showingLink$.next({ unitId
|
|
487
|
+
var _a7;
|
|
488
|
+
this._editingLink$.next(null), (_a7 = this._editPopup) == null || _a7.dispose();
|
|
489
|
+
}
|
|
490
|
+
showInfoPopup(info) {
|
|
491
|
+
var _a7, _b, _c, _d, _e, _f;
|
|
492
|
+
const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
|
|
493
|
+
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 && ((_e = this.showing) == null ? void 0 : _e.startIndex) === startIndex && ((_f = this.showing) == null ? void 0 : _f.endIndex) === endIndex || (this._infoPopup && this._infoPopup.dispose(), !this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC))))
|
|
494
|
+
return this._showingLink$.next({ unitId, linkId, segmentId, segmentPage, startIndex, endIndex }), this._infoPopup = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
483
495
|
{
|
|
484
496
|
collapsed: !1,
|
|
485
|
-
startOffset:
|
|
486
|
-
endOffset:
|
|
487
|
-
segmentId
|
|
488
|
-
segmentPage
|
|
497
|
+
startOffset: startIndex,
|
|
498
|
+
endOffset: endIndex + 1,
|
|
499
|
+
segmentId,
|
|
500
|
+
segmentPage
|
|
489
501
|
},
|
|
490
502
|
{
|
|
491
|
-
componentKey:
|
|
503
|
+
componentKey: DocLinkPopup.componentKey,
|
|
492
504
|
direction: "top-center",
|
|
493
505
|
multipleDirection: "top",
|
|
494
|
-
onClickOutside: () => {
|
|
506
|
+
onClickOutside: /* @__PURE__ */ __name(() => {
|
|
495
507
|
this.hideInfoPopup();
|
|
496
|
-
}
|
|
508
|
+
}, "onClickOutside")
|
|
497
509
|
},
|
|
498
|
-
|
|
510
|
+
unitId
|
|
499
511
|
), this._infoPopup;
|
|
500
512
|
}
|
|
501
513
|
hideInfoPopup() {
|
|
502
|
-
var
|
|
503
|
-
this._showingLink$.next(null), (
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
],
|
|
511
|
-
var
|
|
512
|
-
for (var
|
|
513
|
-
(
|
|
514
|
-
return
|
|
515
|
-
},
|
|
516
|
-
let
|
|
517
|
-
constructor(
|
|
518
|
-
super(), this._commandService =
|
|
514
|
+
var _a7;
|
|
515
|
+
this._showingLink$.next(null), (_a7 = this._infoPopup) == null || _a7.dispose();
|
|
516
|
+
}
|
|
517
|
+
}, __name(_a, "DocHyperLinkPopupService"), _a);
|
|
518
|
+
DocHyperLinkPopupService = __decorateClass$5([
|
|
519
|
+
__decorateParam$5(0, Inject(DocCanvasPopManagerService)),
|
|
520
|
+
__decorateParam$5(1, Inject(DocSelectionManagerService)),
|
|
521
|
+
__decorateParam$5(2, IUniverInstanceService)
|
|
522
|
+
], DocHyperLinkPopupService);
|
|
523
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
524
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
525
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
526
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
527
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a2;
|
|
528
|
+
let DocHyperLinkSelectionController = (_a2 = class extends Disposable {
|
|
529
|
+
constructor(_commandService, _univerInstanceService, _docHyperLinkService) {
|
|
530
|
+
super(), this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._docHyperLinkService = _docHyperLinkService, this._initSelectionChange();
|
|
519
531
|
}
|
|
520
532
|
_initSelectionChange() {
|
|
521
533
|
this.disposeWithMe(
|
|
522
|
-
this._commandService.onCommandExecuted((
|
|
523
|
-
var
|
|
524
|
-
if (
|
|
525
|
-
const
|
|
526
|
-
if (
|
|
527
|
-
const { startOffset
|
|
528
|
-
if (
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
531
|
-
const
|
|
532
|
-
this._docHyperLinkService.showInfoPopup({ unitId
|
|
534
|
+
this._commandService.onCommandExecuted((commandInfo) => {
|
|
535
|
+
var _a7, _b, _c;
|
|
536
|
+
if (commandInfo.id === SetTextSelectionsOperation.id) {
|
|
537
|
+
const params = commandInfo.params, { unitId, ranges, segmentId } = params, doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), primary = ranges[0];
|
|
538
|
+
if (primary && doc) {
|
|
539
|
+
const { startOffset, endOffset, collapsed, segmentPage } = primary, customRanges = (_b = (_a7 = doc.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a7.getBody()) == null ? void 0 : _b.customRanges;
|
|
540
|
+
if (collapsed) {
|
|
541
|
+
const index = (_c = customRanges == null ? void 0 : customRanges.findIndex((value) => value.startIndex < startOffset && value.endIndex > endOffset - 1)) != null ? _c : -1;
|
|
542
|
+
if (index > -1) {
|
|
543
|
+
const customRange = customRanges[index];
|
|
544
|
+
this._docHyperLinkService.showInfoPopup({ unitId, linkId: customRange.rangeId, segmentId, segmentPage, startIndex: customRange.startIndex, endIndex: customRange.endIndex });
|
|
533
545
|
return;
|
|
534
546
|
}
|
|
535
|
-
} else if (
|
|
547
|
+
} else if (customRanges == null ? void 0 : customRanges.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1))
|
|
536
548
|
return;
|
|
537
549
|
}
|
|
538
550
|
this._docHyperLinkService.hideInfoPopup(), this._docHyperLinkService.hideEditPopup();
|
|
@@ -540,48 +552,48 @@ let Z = class extends N {
|
|
|
540
552
|
})
|
|
541
553
|
);
|
|
542
554
|
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
],
|
|
549
|
-
var
|
|
550
|
-
for (var
|
|
551
|
-
(
|
|
552
|
-
return
|
|
553
|
-
},
|
|
554
|
-
let
|
|
555
|
-
constructor(
|
|
556
|
-
super(), this._context =
|
|
555
|
+
}, __name(_a2, "DocHyperLinkSelectionController"), _a2);
|
|
556
|
+
DocHyperLinkSelectionController = __decorateClass$4([
|
|
557
|
+
__decorateParam$4(0, ICommandService),
|
|
558
|
+
__decorateParam$4(1, IUniverInstanceService),
|
|
559
|
+
__decorateParam$4(2, Inject(DocHyperLinkPopupService))
|
|
560
|
+
], DocHyperLinkSelectionController);
|
|
561
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
562
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
563
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
564
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
565
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a3;
|
|
566
|
+
let DocHyperLinkEventRenderController = (_a3 = class extends Disposable {
|
|
567
|
+
constructor(_context, _docEventManagerService, _commandService, _hyperLinkPopupService, _docSkeletonManagerService, _docSelectionManagerService) {
|
|
568
|
+
super(), this._context = _context, this._docEventManagerService = _docEventManagerService, this._commandService = _commandService, this._hyperLinkPopupService = _hyperLinkPopupService, this._docSkeletonManagerService = _docSkeletonManagerService, this._docSelectionManagerService = _docSelectionManagerService, !(this._context.unitId === DOCS_ZEN_EDITOR_UNIT_ID_KEY || this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY) && (this._initHover(), this._initClick());
|
|
557
569
|
}
|
|
558
570
|
get _skeleton() {
|
|
559
571
|
return this._docSkeletonManagerService.getSkeleton();
|
|
560
572
|
}
|
|
561
573
|
_hideInfoPopup() {
|
|
562
574
|
this._hyperLinkPopupService.showing && this._commandService.executeCommand(
|
|
563
|
-
|
|
575
|
+
ToggleDocHyperLinkInfoPopupOperation.id
|
|
564
576
|
);
|
|
565
577
|
}
|
|
566
578
|
_initHover() {
|
|
567
579
|
this.disposeWithMe(
|
|
568
|
-
this._docEventManagerService.hoverCustomRanges$.subscribe((
|
|
569
|
-
var
|
|
570
|
-
const
|
|
571
|
-
if (((
|
|
580
|
+
this._docEventManagerService.hoverCustomRanges$.subscribe((ranges) => {
|
|
581
|
+
var _a7;
|
|
582
|
+
const link = ranges.find((range) => range.range.rangeType === CustomRangeType.HYPERLINK), activeRanges = this._docSelectionManagerService.getTextRanges(), currentSegmentId = activeRanges == null ? void 0 : activeRanges[0].segmentId;
|
|
583
|
+
if (((_a7 = link == null ? void 0 : link.segmentId) != null ? _a7 : "") !== currentSegmentId) {
|
|
572
584
|
this._hideInfoPopup();
|
|
573
585
|
return;
|
|
574
586
|
}
|
|
575
|
-
|
|
576
|
-
|
|
587
|
+
link ? this._commandService.executeCommand(
|
|
588
|
+
ToggleDocHyperLinkInfoPopupOperation.id,
|
|
577
589
|
{
|
|
578
590
|
unitId: this._context.unitId,
|
|
579
|
-
linkId:
|
|
580
|
-
segmentId:
|
|
581
|
-
segmentPage:
|
|
582
|
-
rangeId:
|
|
583
|
-
startIndex:
|
|
584
|
-
endIndex:
|
|
591
|
+
linkId: link.range.rangeId,
|
|
592
|
+
segmentId: link.segmentId,
|
|
593
|
+
segmentPage: link.segmentPageIndex,
|
|
594
|
+
rangeId: link.range.rangeId,
|
|
595
|
+
startIndex: link.range.startIndex,
|
|
596
|
+
endIndex: link.range.endIndex
|
|
585
597
|
}
|
|
586
598
|
) : this._hideInfoPopup();
|
|
587
599
|
})
|
|
@@ -589,202 +601,203 @@ let re = class extends N {
|
|
|
589
601
|
}
|
|
590
602
|
_initClick() {
|
|
591
603
|
this.disposeWithMe(
|
|
592
|
-
this._docEventManagerService.clickCustomRanges$.subscribe((
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
604
|
+
this._docEventManagerService.clickCustomRanges$.subscribe((range) => {
|
|
605
|
+
const link = range.range;
|
|
606
|
+
link && this._commandService.executeCommand(
|
|
607
|
+
ClickDocHyperLinkOperation.id,
|
|
596
608
|
{
|
|
597
609
|
unitId: this._context.unitId,
|
|
598
|
-
linkId:
|
|
599
|
-
segmentId:
|
|
610
|
+
linkId: link.rangeId,
|
|
611
|
+
segmentId: range.segmentId
|
|
600
612
|
}
|
|
601
613
|
);
|
|
602
614
|
})
|
|
603
615
|
);
|
|
604
616
|
}
|
|
605
|
-
};
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
],
|
|
613
|
-
var
|
|
614
|
-
for (var
|
|
615
|
-
(
|
|
616
|
-
return
|
|
617
|
-
},
|
|
618
|
-
let
|
|
619
|
-
constructor(
|
|
620
|
-
super(), this._context =
|
|
617
|
+
}, __name(_a3, "DocHyperLinkEventRenderController"), _a3);
|
|
618
|
+
DocHyperLinkEventRenderController = __decorateClass$3([
|
|
619
|
+
__decorateParam$3(1, Inject(DocEventManagerService)),
|
|
620
|
+
__decorateParam$3(2, ICommandService),
|
|
621
|
+
__decorateParam$3(3, Inject(DocHyperLinkPopupService)),
|
|
622
|
+
__decorateParam$3(4, Inject(DocSkeletonManagerService)),
|
|
623
|
+
__decorateParam$3(5, Inject(DocSelectionManagerService))
|
|
624
|
+
], DocHyperLinkEventRenderController);
|
|
625
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
626
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
627
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
628
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
629
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a4;
|
|
630
|
+
let DocHyperLinkRenderController = (_a4 = class extends Disposable {
|
|
631
|
+
constructor(_context, _docInterceptorService, _hyperLinkService, _docRenderController) {
|
|
632
|
+
super(), this._context = _context, this._docInterceptorService = _docInterceptorService, this._hyperLinkService = _hyperLinkService, this._docRenderController = _docRenderController, this._init(), this._initReRender();
|
|
621
633
|
}
|
|
622
634
|
_init() {
|
|
623
|
-
this._docInterceptorService.intercept(
|
|
624
|
-
handler: (
|
|
625
|
-
if (!
|
|
626
|
-
return
|
|
627
|
-
const { unitId
|
|
628
|
-
if (!
|
|
629
|
-
return
|
|
630
|
-
...
|
|
635
|
+
this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_RANGE, {
|
|
636
|
+
handler: /* @__PURE__ */ __name((data, pos, next) => {
|
|
637
|
+
if (!data)
|
|
638
|
+
return next(data);
|
|
639
|
+
const { unitId, index } = pos, activeLink = this._hyperLinkService.showing;
|
|
640
|
+
if (!activeLink)
|
|
641
|
+
return next({
|
|
642
|
+
...data,
|
|
631
643
|
active: !1
|
|
632
644
|
});
|
|
633
|
-
const { linkId
|
|
634
|
-
return
|
|
635
|
-
...
|
|
636
|
-
active:
|
|
645
|
+
const { linkId, unitId: linkUnitId, startIndex, endIndex } = activeLink, isActive = linkUnitId === unitId && data.rangeId === linkId && index >= startIndex && index <= endIndex;
|
|
646
|
+
return next({
|
|
647
|
+
...data,
|
|
648
|
+
active: isActive
|
|
637
649
|
});
|
|
638
|
-
}
|
|
650
|
+
}, "handler")
|
|
639
651
|
});
|
|
640
652
|
}
|
|
641
653
|
_initReRender() {
|
|
642
654
|
this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
).subscribe(([
|
|
646
|
-
|
|
655
|
+
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) && (prev == null ? void 0 : prev.startIndex) === (aft == null ? void 0 : aft.startIndex)),
|
|
656
|
+
pairwise()
|
|
657
|
+
).subscribe(([preLink, link]) => {
|
|
658
|
+
link ? link.unitId === this._context.unitId && this._docRenderController.reRender(link.unitId) : preLink && preLink.unitId === this._context.unitId && this._docRenderController.reRender(preLink.unitId);
|
|
647
659
|
}));
|
|
648
660
|
}
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
],
|
|
655
|
-
const
|
|
656
|
-
function
|
|
661
|
+
}, __name(_a4, "DocHyperLinkRenderController"), _a4);
|
|
662
|
+
DocHyperLinkRenderController = __decorateClass$2([
|
|
663
|
+
__decorateParam$2(1, Inject(DocInterceptorService)),
|
|
664
|
+
__decorateParam$2(2, Inject(DocHyperLinkPopupService)),
|
|
665
|
+
__decorateParam$2(3, Inject(DocRenderController))
|
|
666
|
+
], DocHyperLinkRenderController);
|
|
667
|
+
const DOC_LINK_ICON = "doc-hyper-link-icon";
|
|
668
|
+
function AddHyperLinkMenuItemFactory(accessor) {
|
|
657
669
|
return {
|
|
658
|
-
id:
|
|
659
|
-
type:
|
|
660
|
-
icon:
|
|
670
|
+
id: ShowDocHyperLinkEditPopupOperation.id,
|
|
671
|
+
type: MenuItemType.BUTTON,
|
|
672
|
+
icon: DOC_LINK_ICON,
|
|
661
673
|
title: "docLink.menu.tooltip",
|
|
662
674
|
tooltip: "docLink.menu.tooltip",
|
|
663
|
-
hidden$:
|
|
664
|
-
disabled$: new
|
|
665
|
-
const
|
|
666
|
-
|
|
675
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
|
|
676
|
+
disabled$: new Observable(function(subscribe) {
|
|
677
|
+
const observer = accessor.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe(() => {
|
|
678
|
+
subscribe.next(shouldDisableAddLink(accessor));
|
|
667
679
|
});
|
|
668
680
|
return () => {
|
|
669
|
-
|
|
681
|
+
observer.unsubscribe();
|
|
670
682
|
};
|
|
671
683
|
})
|
|
672
684
|
};
|
|
673
685
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
686
|
+
__name(AddHyperLinkMenuItemFactory, "AddHyperLinkMenuItemFactory");
|
|
687
|
+
const addLinkShortcut = {
|
|
688
|
+
id: ShowDocHyperLinkEditPopupOperation.id,
|
|
689
|
+
binding: MetaKeys.CTRL_COMMAND | KeyCode.K,
|
|
677
690
|
description: "docLink.menu.tooltip",
|
|
678
|
-
preconditions:
|
|
679
|
-
},
|
|
680
|
-
[
|
|
681
|
-
[
|
|
691
|
+
preconditions: whenDocAndEditorFocused
|
|
692
|
+
}, menuSchema = {
|
|
693
|
+
[RibbonStartGroup.OTHERS]: {
|
|
694
|
+
[ShowDocHyperLinkEditPopupOperation.id]: {
|
|
682
695
|
order: 0,
|
|
683
|
-
menuItemFactory:
|
|
696
|
+
menuItemFactory: AddHyperLinkMenuItemFactory
|
|
684
697
|
}
|
|
685
698
|
},
|
|
686
|
-
[
|
|
687
|
-
[
|
|
688
|
-
[
|
|
699
|
+
[ContextMenuPosition.MAIN_AREA]: {
|
|
700
|
+
[ContextMenuGroup.DATA]: {
|
|
701
|
+
[ShowDocHyperLinkEditPopupOperation.id]: {
|
|
689
702
|
order: 0,
|
|
690
|
-
menuItemFactory:
|
|
703
|
+
menuItemFactory: AddHyperLinkMenuItemFactory
|
|
691
704
|
}
|
|
692
705
|
}
|
|
693
706
|
}
|
|
694
707
|
};
|
|
695
|
-
var
|
|
696
|
-
for (var
|
|
697
|
-
(
|
|
698
|
-
return
|
|
699
|
-
},
|
|
700
|
-
let
|
|
701
|
-
constructor(
|
|
702
|
-
super(), this._componentManager =
|
|
708
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
709
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
710
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
711
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
712
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a5;
|
|
713
|
+
let DocHyperLinkUIController = (_a5 = class extends Disposable {
|
|
714
|
+
constructor(_componentManager, _commandService, _menuManagerService, _shortcutService) {
|
|
715
|
+
super(), this._componentManager = _componentManager, this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortcut();
|
|
703
716
|
}
|
|
704
717
|
_initComponents() {
|
|
705
718
|
[
|
|
706
|
-
[
|
|
707
|
-
[
|
|
708
|
-
[
|
|
709
|
-
].forEach(([
|
|
710
|
-
this._componentManager.register(
|
|
719
|
+
[DocHyperLinkEdit, DocHyperLinkEdit.componentKey],
|
|
720
|
+
[DocLinkPopup, DocLinkPopup.componentKey],
|
|
721
|
+
[LinkSingle, DOC_LINK_ICON]
|
|
722
|
+
].forEach(([comp, key]) => {
|
|
723
|
+
this._componentManager.register(key, comp);
|
|
711
724
|
});
|
|
712
725
|
}
|
|
713
726
|
_initCommands() {
|
|
714
727
|
[
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
].forEach((
|
|
722
|
-
this._commandService.registerCommand(
|
|
728
|
+
AddDocHyperLinkCommand,
|
|
729
|
+
UpdateDocHyperLinkCommand,
|
|
730
|
+
DeleteDocHyperLinkCommand,
|
|
731
|
+
ShowDocHyperLinkEditPopupOperation,
|
|
732
|
+
ToggleDocHyperLinkInfoPopupOperation,
|
|
733
|
+
ClickDocHyperLinkOperation
|
|
734
|
+
].forEach((command) => {
|
|
735
|
+
this._commandService.registerCommand(command);
|
|
723
736
|
});
|
|
724
737
|
}
|
|
725
738
|
_initShortcut() {
|
|
726
|
-
[
|
|
727
|
-
this._shortcutService.registerShortcut(
|
|
739
|
+
[addLinkShortcut].forEach((shortcut) => {
|
|
740
|
+
this._shortcutService.registerShortcut(shortcut);
|
|
728
741
|
});
|
|
729
742
|
}
|
|
730
743
|
_initMenus() {
|
|
731
|
-
this._menuManagerService.mergeMenu(
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
],
|
|
740
|
-
const
|
|
741
|
-
var
|
|
742
|
-
for (var
|
|
743
|
-
(
|
|
744
|
-
return
|
|
745
|
-
},
|
|
746
|
-
let
|
|
747
|
-
constructor(
|
|
748
|
-
super(), this._config =
|
|
749
|
-
const { menu
|
|
744
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
745
|
+
}
|
|
746
|
+
}, __name(_a5, "DocHyperLinkUIController"), _a5);
|
|
747
|
+
DocHyperLinkUIController = __decorateClass$1([
|
|
748
|
+
__decorateParam$1(0, Inject(ComponentManager)),
|
|
749
|
+
__decorateParam$1(1, ICommandService),
|
|
750
|
+
__decorateParam$1(2, IMenuManagerService),
|
|
751
|
+
__decorateParam$1(3, IShortcutService)
|
|
752
|
+
], DocHyperLinkUIController);
|
|
753
|
+
const DOC_HYPER_LINK_UI_PLUGIN = "DOC_HYPER_LINK_UI_PLUGIN";
|
|
754
|
+
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) => {
|
|
755
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
756
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
757
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
758
|
+
}, "__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;
|
|
759
|
+
let UniverDocsHyperLinkUIPlugin = (_a6 = class extends Plugin {
|
|
760
|
+
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
|
|
761
|
+
super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._configService = _configService;
|
|
762
|
+
const { menu, ...rest } = merge(
|
|
750
763
|
{},
|
|
751
|
-
|
|
764
|
+
defaultPluginConfig,
|
|
752
765
|
this._config
|
|
753
766
|
);
|
|
754
|
-
|
|
767
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY, rest);
|
|
755
768
|
}
|
|
756
769
|
onStarting() {
|
|
757
770
|
[
|
|
758
|
-
[
|
|
759
|
-
[
|
|
760
|
-
[
|
|
761
|
-
].forEach((
|
|
762
|
-
this._injector.add(
|
|
763
|
-
}), this._injector.get(
|
|
771
|
+
[DocHyperLinkPopupService],
|
|
772
|
+
[DocHyperLinkUIController],
|
|
773
|
+
[DocHyperLinkSelectionController]
|
|
774
|
+
].forEach((dep) => {
|
|
775
|
+
this._injector.add(dep);
|
|
776
|
+
}), this._injector.get(DocHyperLinkUIController);
|
|
764
777
|
}
|
|
765
778
|
onReady() {
|
|
766
|
-
this._injector.get(
|
|
779
|
+
this._injector.get(DocHyperLinkSelectionController);
|
|
767
780
|
}
|
|
768
781
|
onRendered() {
|
|
769
782
|
this._initRenderModule();
|
|
770
783
|
}
|
|
771
784
|
_initRenderModule() {
|
|
772
785
|
[
|
|
773
|
-
[
|
|
774
|
-
[
|
|
775
|
-
].forEach((
|
|
776
|
-
this._renderManagerSrv.registerRenderModule(
|
|
786
|
+
[DocHyperLinkRenderController],
|
|
787
|
+
[DocHyperLinkEventRenderController]
|
|
788
|
+
].forEach((dep) => {
|
|
789
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, dep);
|
|
777
790
|
});
|
|
778
791
|
}
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
],
|
|
792
|
+
}, __name(_a6, "UniverDocsHyperLinkUIPlugin"), _a6);
|
|
793
|
+
__publicField2(UniverDocsHyperLinkUIPlugin, "pluginName", DOC_HYPER_LINK_UI_PLUGIN);
|
|
794
|
+
__publicField2(UniverDocsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
795
|
+
UniverDocsHyperLinkUIPlugin = __decorateClass([
|
|
796
|
+
DependentOn(UniverDocsHyperLinkPlugin),
|
|
797
|
+
__decorateParam(1, Inject(Injector)),
|
|
798
|
+
__decorateParam(2, IRenderManagerService),
|
|
799
|
+
__decorateParam(3, IConfigService)
|
|
800
|
+
], UniverDocsHyperLinkUIPlugin);
|
|
788
801
|
export {
|
|
789
|
-
|
|
802
|
+
UniverDocsHyperLinkUIPlugin
|
|
790
803
|
};
|