@univerjs/docs-hyper-link-ui 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +536 -453
- package/lib/types/commands/operations/popup.operation.d.ts +1 -2
- package/lib/types/controllers/doc-hyper-link-clipboard.controller.d.ts +3 -2
- package/lib/types/controllers/doc-hyper-link-custom-range.controller.d.ts +11 -0
- package/lib/types/controllers/menu.d.ts +1 -1
- package/lib/types/controllers/ui.controller.d.ts +1 -2
- package/lib/types/plugin.d.ts +2 -3
- package/lib/types/services/hyper-link-popup.service.d.ts +1 -2
- package/lib/umd/index.js +1 -1
- package/package.json +19 -21
package/lib/es/index.js
CHANGED
|
@@ -1,217 +1,220 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import { Inject as
|
|
6
|
-
import { DocHyperLinkModel
|
|
7
|
-
import { IRenderManagerService
|
|
8
|
-
import { IMessageService
|
|
9
|
-
import { Tooltip
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
t =
|
|
21
|
-
for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
|
|
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, IUniverInstanceService, UniverInstanceType, useDependency, LocaleService, Disposable, Inject, generateRandomId, CustomRangeType, sequenceExecuteAsync, useObservable as useObservable$1, Tools, OnLifecycle, LifecycleStages, Injector, updateAttributeByDelete, DependentOn, Plugin } from "@univerjs/core";
|
|
6
|
+
import { DocHyperLinkModel, AddDocHyperLinkMutation, UpdateDocHyperLinkMutation, UniverDocsHyperLinkPlugin } from "@univerjs/docs-hyper-link";
|
|
7
|
+
import { IRenderManagerService, DocumentEditArea, ITextSelectionRenderManager } from "@univerjs/engine-render";
|
|
8
|
+
import { IMessageService, useObservable, MetaKeys, KeyCode, MenuGroup, MenuItemType, MenuPosition, getMenuHiddenObservable, ComponentManager, IMenuService, IShortcutService } from "@univerjs/ui";
|
|
9
|
+
import { Tooltip, MessageType, FormLayout, Input, Button } from "@univerjs/design";
|
|
10
|
+
import React, { forwardRef, useRef, createElement, useState, useEffect } from "react";
|
|
11
|
+
import { deleteCustomRangeFactory, TextSelectionManagerService, DocSkeletonManagerService, addCustomRangeBySelectionFactory, SetTextSelectionsOperation, DocInterceptorService, DOC_INTERCEPTOR_POINT, DocCustomRangeService } from "@univerjs/docs";
|
|
12
|
+
import { DocCanvasPopManagerService, whenDocAndEditorFocused, IDocClipboardService } from "@univerjs/docs-ui";
|
|
13
|
+
import { BehaviorSubject, Observable, debounceTime } from "rxjs";
|
|
14
|
+
import cs from "clsx";
|
|
15
|
+
const DOC_HYPER_LINK_UI_PLUGIN = "DOC_HYPER_LINK_UI_PLUGIN";
|
|
16
|
+
var __assign = function() {
|
|
17
|
+
return __assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
22
21
|
}
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
var
|
|
27
|
-
for (var
|
|
28
|
-
if (
|
|
29
|
-
for (var
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
var
|
|
34
|
-
return
|
|
22
|
+
return t;
|
|
23
|
+
}, __assign.apply(this, arguments);
|
|
24
|
+
}, __rest = function(s, e) {
|
|
25
|
+
var t = {};
|
|
26
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
27
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
28
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
29
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
30
|
+
return t;
|
|
31
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
32
|
+
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()));
|
|
33
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
35
34
|
});
|
|
36
|
-
function
|
|
37
|
-
return
|
|
38
|
-
return
|
|
35
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
36
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
37
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
39
38
|
}));
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
__name(render, "render");
|
|
41
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
42
|
+
var attrs = __assign({}, node.attrs);
|
|
43
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
44
|
+
var defIds = runtimeProps.defIds;
|
|
45
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a8) {
|
|
46
|
+
var key = _a8[0], value = _a8[1];
|
|
47
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
48
|
+
})), attrs;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
51
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
52
|
+
var _a8, defIds = runtimeProps.defIds;
|
|
53
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a8 = node.children) === null || _a8 === void 0) && _a8.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
54
|
+
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;
|
|
55
|
+
}) }) : node;
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
58
|
+
function generateShortUuid() {
|
|
57
59
|
return Math.random().toString(36).substring(2, 8);
|
|
58
60
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
62
|
+
IconBase.displayName = "UniverIcon";
|
|
63
|
+
var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] }, CloseSingle = forwardRef(function(props, ref) {
|
|
64
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
62
65
|
id: "close-single",
|
|
63
|
-
ref
|
|
64
|
-
icon:
|
|
66
|
+
ref,
|
|
67
|
+
icon: element$4
|
|
65
68
|
}));
|
|
66
69
|
});
|
|
67
|
-
|
|
68
|
-
var
|
|
69
|
-
return
|
|
70
|
+
CloseSingle.displayName = "CloseSingle";
|
|
71
|
+
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) {
|
|
72
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
70
73
|
id: "copy-single",
|
|
71
|
-
ref
|
|
72
|
-
icon:
|
|
74
|
+
ref,
|
|
75
|
+
icon: element$3
|
|
73
76
|
}));
|
|
74
77
|
});
|
|
75
|
-
|
|
76
|
-
var
|
|
77
|
-
return
|
|
78
|
+
CopySingle.displayName = "CopySingle";
|
|
79
|
+
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) {
|
|
80
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
78
81
|
id: "link-single",
|
|
79
|
-
ref
|
|
80
|
-
icon:
|
|
82
|
+
ref,
|
|
83
|
+
icon: element$2
|
|
81
84
|
}));
|
|
82
85
|
});
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
return
|
|
86
|
+
LinkSingle.displayName = "LinkSingle";
|
|
87
|
+
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) {
|
|
88
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
86
89
|
id: "unlink-single",
|
|
87
|
-
ref
|
|
88
|
-
icon:
|
|
90
|
+
ref,
|
|
91
|
+
icon: element$1
|
|
89
92
|
}));
|
|
90
93
|
});
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
return
|
|
94
|
+
UnlinkSingle.displayName = "UnlinkSingle";
|
|
95
|
+
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) {
|
|
96
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
94
97
|
id: "write-single",
|
|
95
|
-
ref
|
|
96
|
-
icon:
|
|
98
|
+
ref,
|
|
99
|
+
icon: element
|
|
97
100
|
}));
|
|
98
101
|
});
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
type:
|
|
102
|
+
WriteSingle.displayName = "WriteSingle";
|
|
103
|
+
const DeleteDocHyperLinkCommand = {
|
|
104
|
+
type: CommandType.COMMAND,
|
|
102
105
|
id: "docs.command.delete-hyper-link",
|
|
103
|
-
async handler(
|
|
104
|
-
if (!
|
|
106
|
+
async handler(accessor, params) {
|
|
107
|
+
if (!params)
|
|
105
108
|
return !1;
|
|
106
|
-
const { unitId
|
|
107
|
-
if (!
|
|
109
|
+
const { unitId, linkId } = params, commandService = accessor.get(ICommandService);
|
|
110
|
+
if (!accessor.get(DocHyperLinkModel).getLink(unitId, linkId))
|
|
108
111
|
return !1;
|
|
109
|
-
const
|
|
110
|
-
return
|
|
112
|
+
const doMutation = deleteCustomRangeFactory(accessor, { unitId, rangeId: linkId });
|
|
113
|
+
return doMutation ? await commandService.syncExecuteCommand(doMutation.id, doMutation.params) : !1;
|
|
111
114
|
}
|
|
112
|
-
},
|
|
113
|
-
var
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
115
|
+
}, shouldDisableAddLink = /* @__PURE__ */ __name((accessor) => {
|
|
116
|
+
var _a8;
|
|
117
|
+
const textSelectionService = accessor.get(TextSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), activeRange = textSelectionService.getActiveRange(), render2 = accessor.get(IRenderManagerService).getCurrent(), skeleton = render2 == null ? void 0 : render2.with(DocSkeletonManagerService).getSkeleton(), editArea = skeleton == null ? void 0 : skeleton.getViewModel().getEditArea();
|
|
118
|
+
if (editArea === DocumentEditArea.FOOTER || editArea === DocumentEditArea.HEADER)
|
|
116
119
|
return !0;
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
120
|
+
const doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
121
|
+
if (!doc || !activeRange || activeRange.collapsed)
|
|
119
122
|
return !0;
|
|
120
|
-
const
|
|
121
|
-
if (!
|
|
123
|
+
const paragraphs = (_a8 = doc.getBody()) == null ? void 0 : _a8.paragraphs;
|
|
124
|
+
if (!paragraphs)
|
|
122
125
|
return !0;
|
|
123
|
-
for (let
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
+
for (let i = 0, len = paragraphs.length; i < len; i++) {
|
|
127
|
+
const p = paragraphs[i];
|
|
128
|
+
if (activeRange.startOffset <= p.startIndex && activeRange.endOffset > p.startIndex)
|
|
126
129
|
return !0;
|
|
127
|
-
if (
|
|
130
|
+
if (p.startIndex > activeRange.endOffset)
|
|
128
131
|
break;
|
|
129
132
|
}
|
|
130
133
|
return !1;
|
|
131
|
-
},
|
|
132
|
-
type:
|
|
134
|
+
}, "shouldDisableAddLink"), ShowDocHyperLinkEditPopupOperation = {
|
|
135
|
+
type: CommandType.OPERATION,
|
|
133
136
|
id: "docs.operation.show-hyper-link-edit-popup",
|
|
134
|
-
handler(
|
|
135
|
-
const
|
|
136
|
-
return
|
|
137
|
+
handler(accessor, params) {
|
|
138
|
+
const linkInfo = params == null ? void 0 : params.link;
|
|
139
|
+
return shouldDisableAddLink(accessor) && !linkInfo ? !1 : (accessor.get(DocHyperLinkPopupService).showEditPopup(linkInfo), !0);
|
|
137
140
|
}
|
|
138
|
-
},
|
|
139
|
-
docLink
|
|
140
|
-
docLinkType
|
|
141
|
-
docLinkContent
|
|
142
|
-
docLinkContentError
|
|
143
|
-
docLinkUrl
|
|
144
|
-
docLinkOperations
|
|
145
|
-
docLinkOperation
|
|
146
|
-
docLinkOperationError
|
|
147
|
-
},
|
|
148
|
-
const
|
|
149
|
-
if (!
|
|
141
|
+
}, 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$1 = {
|
|
142
|
+
docLink,
|
|
143
|
+
docLinkType,
|
|
144
|
+
docLinkContent,
|
|
145
|
+
docLinkContentError,
|
|
146
|
+
docLinkUrl,
|
|
147
|
+
docLinkOperations,
|
|
148
|
+
docLinkOperation,
|
|
149
|
+
docLinkOperationError
|
|
150
|
+
}, DocLinkPopup = /* @__PURE__ */ __name(() => {
|
|
151
|
+
const hyperLinkService = useDependency(DocHyperLinkPopupService), hyperLinkModel = useDependency(DocHyperLinkModel), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), currentPopup = useObservable(hyperLinkService.showingLink$);
|
|
152
|
+
if (!currentPopup)
|
|
150
153
|
return null;
|
|
151
|
-
const { unitId
|
|
152
|
-
return
|
|
154
|
+
const { unitId, linkId } = currentPopup, link = hyperLinkModel.getLink(unitId, linkId);
|
|
155
|
+
return link ? /* @__PURE__ */ React.createElement(
|
|
153
156
|
"div",
|
|
154
157
|
{
|
|
155
|
-
className:
|
|
156
|
-
onClick: () => {
|
|
157
|
-
|
|
158
|
-
}
|
|
158
|
+
className: styles$1.docLink,
|
|
159
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
160
|
+
hyperLinkService.hideInfoPopup();
|
|
161
|
+
}, "onClick")
|
|
159
162
|
},
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */
|
|
163
|
+
/* @__PURE__ */ React.createElement("div", { className: cs(styles$1.docLinkContent), onClick: /* @__PURE__ */ __name(() => window.open(link.payload), "onClick") }, /* @__PURE__ */ React.createElement("div", { className: styles$1.docLinkType }, /* @__PURE__ */ React.createElement(LinkSingle, null)), /* @__PURE__ */ React.createElement(Tooltip, { showIfEllipsis: !0, title: link.payload }, /* @__PURE__ */ React.createElement("span", { className: styles$1.docLinkUrl }, link.payload))),
|
|
164
|
+
/* @__PURE__ */ React.createElement("div", { className: styles$1.docLinkOperations }, /* @__PURE__ */ React.createElement(
|
|
162
165
|
"div",
|
|
163
166
|
{
|
|
164
|
-
className:
|
|
165
|
-
onClick: () => {
|
|
166
|
-
navigator.clipboard.writeText(
|
|
167
|
-
content:
|
|
168
|
-
type:
|
|
167
|
+
className: cs(styles$1.docLinkOperation),
|
|
168
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
169
|
+
navigator.clipboard.writeText(link.payload), messageService.show({
|
|
170
|
+
content: localeService.t("docLink.info.coped"),
|
|
171
|
+
type: MessageType.Info
|
|
169
172
|
});
|
|
170
|
-
}
|
|
173
|
+
}, "onClick")
|
|
171
174
|
},
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
), /* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ React.createElement(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.copy") }, /* @__PURE__ */ React.createElement(CopySingle, null))
|
|
176
|
+
), /* @__PURE__ */ React.createElement(
|
|
174
177
|
"div",
|
|
175
178
|
{
|
|
176
|
-
className:
|
|
177
|
-
onClick: () => {
|
|
178
|
-
|
|
179
|
-
link:
|
|
179
|
+
className: styles$1.docLinkOperation,
|
|
180
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
181
|
+
commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id, {
|
|
182
|
+
link: currentPopup
|
|
180
183
|
});
|
|
181
|
-
}
|
|
184
|
+
}, "onClick")
|
|
182
185
|
},
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
), /* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ React.createElement(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.edit") }, /* @__PURE__ */ React.createElement(WriteSingle, null))
|
|
187
|
+
), /* @__PURE__ */ React.createElement(
|
|
185
188
|
"div",
|
|
186
189
|
{
|
|
187
|
-
className:
|
|
188
|
-
onClick: () => {
|
|
189
|
-
|
|
190
|
-
unitId
|
|
191
|
-
linkId:
|
|
190
|
+
className: styles$1.docLinkOperation,
|
|
191
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
192
|
+
commandService.executeCommand(DeleteDocHyperLinkCommand.id, {
|
|
193
|
+
unitId,
|
|
194
|
+
linkId: link.id
|
|
192
195
|
});
|
|
193
|
-
}
|
|
196
|
+
}, "onClick")
|
|
194
197
|
},
|
|
195
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ React.createElement(Tooltip, { placement: "bottom", title: localeService.t("docLink.info.cancel") }, /* @__PURE__ */ React.createElement(UnlinkSingle, null))
|
|
196
199
|
))
|
|
197
200
|
) : null;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
var
|
|
201
|
-
for (var
|
|
202
|
-
(
|
|
203
|
-
return
|
|
204
|
-
},
|
|
205
|
-
let
|
|
206
|
-
constructor(
|
|
201
|
+
}, "DocLinkPopup");
|
|
202
|
+
DocLinkPopup.componentKey = "univer.doc.link-info-popup";
|
|
203
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
204
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
205
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
206
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
207
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a;
|
|
208
|
+
let DocHyperLinkPopupService = (_a = class extends Disposable {
|
|
209
|
+
constructor(_docCanvasPopupManagerService, _textSelectionManagerService, _docHyperLinkModel, _univerInstanceService, _commandService) {
|
|
207
210
|
super();
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
this._docCanvasPopupManagerService =
|
|
211
|
+
__publicField(this, "_editingLink$", new BehaviorSubject(null));
|
|
212
|
+
__publicField(this, "_showingLink$", new BehaviorSubject(null));
|
|
213
|
+
__publicField(this, "editingLink$", this._editingLink$.asObservable());
|
|
214
|
+
__publicField(this, "showingLink$", this._showingLink$.asObservable());
|
|
215
|
+
__publicField(this, "_editPopup", null);
|
|
216
|
+
__publicField(this, "_infoPopup", null);
|
|
217
|
+
this._docCanvasPopupManagerService = _docCanvasPopupManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._docHyperLinkModel = _docHyperLinkModel, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this.disposeWithMe(() => {
|
|
215
218
|
this._editingLink$.complete(), this._showingLink$.complete();
|
|
216
219
|
});
|
|
217
220
|
}
|
|
@@ -221,282 +224,286 @@ let S = class extends T {
|
|
|
221
224
|
get showing() {
|
|
222
225
|
return this._showingLink$.value;
|
|
223
226
|
}
|
|
224
|
-
showEditPopup(
|
|
225
|
-
var
|
|
226
|
-
this._editPopup && this._editPopup.dispose(), this._editingLink$.next(
|
|
227
|
-
let
|
|
228
|
-
if (
|
|
229
|
-
const { unitId
|
|
230
|
-
|
|
227
|
+
showEditPopup(linkInfo) {
|
|
228
|
+
var _a8, _b;
|
|
229
|
+
this._editPopup && this._editPopup.dispose(), this._editingLink$.next(linkInfo);
|
|
230
|
+
let activeRange = this._textSelectionManagerService.getActiveRange();
|
|
231
|
+
if (linkInfo) {
|
|
232
|
+
const { unitId, rangeIndex } = linkInfo, doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), range = (_b = (_a8 = doc == null ? void 0 : doc.getBody()) == null ? void 0 : _a8.customRanges) == null ? void 0 : _b[rangeIndex];
|
|
233
|
+
range && (activeRange = {
|
|
231
234
|
collapsed: !1,
|
|
232
|
-
startOffset:
|
|
233
|
-
endOffset:
|
|
235
|
+
startOffset: range.startIndex,
|
|
236
|
+
endOffset: range.endIndex + 1
|
|
234
237
|
}, this._textSelectionManagerService.replaceTextRanges([{
|
|
235
|
-
startOffset:
|
|
236
|
-
endOffset:
|
|
238
|
+
startOffset: range.startIndex,
|
|
239
|
+
endOffset: range.endIndex + 1
|
|
237
240
|
}]));
|
|
238
241
|
}
|
|
239
|
-
return
|
|
240
|
-
|
|
242
|
+
return activeRange ? (this._editPopup = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
243
|
+
activeRange,
|
|
241
244
|
{
|
|
242
|
-
componentKey:
|
|
245
|
+
componentKey: DocHyperLinkEdit.componentKey,
|
|
243
246
|
direction: "bottom"
|
|
244
247
|
}
|
|
245
248
|
), this._editPopup) : null;
|
|
246
249
|
}
|
|
247
250
|
hideEditPopup() {
|
|
248
|
-
var
|
|
249
|
-
this._editingLink$.next(null), (
|
|
251
|
+
var _a8;
|
|
252
|
+
this._editingLink$.next(null), (_a8 = this._editPopup) == null || _a8.dispose();
|
|
250
253
|
}
|
|
251
|
-
showInfoPopup(
|
|
252
|
-
var
|
|
253
|
-
const { linkId
|
|
254
|
-
if (((
|
|
254
|
+
showInfoPopup(info) {
|
|
255
|
+
var _a8, _b, _c, _d;
|
|
256
|
+
const { linkId, unitId, rangeIndex } = info;
|
|
257
|
+
if (((_a8 = this.showing) == null ? void 0 : _a8.linkId) === linkId && ((_b = this.showing) == null ? void 0 : _b.unitId) === unitId && this.showing.rangeIndex === rangeIndex)
|
|
255
258
|
return;
|
|
256
259
|
this._infoPopup && this._infoPopup.dispose();
|
|
257
|
-
const
|
|
258
|
-
if (!
|
|
260
|
+
const link = this._docHyperLinkModel.getLink(unitId, linkId), doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
261
|
+
if (!doc || !link)
|
|
259
262
|
return;
|
|
260
|
-
const
|
|
261
|
-
if (this._showingLink$.next({ unitId
|
|
263
|
+
const range = (_d = (_c = doc.getBody()) == null ? void 0 : _c.customRanges) == null ? void 0 : _d[rangeIndex];
|
|
264
|
+
if (this._showingLink$.next({ unitId, linkId, rangeIndex }), !!range)
|
|
262
265
|
return this._infoPopup = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
263
266
|
{
|
|
264
267
|
collapsed: !1,
|
|
265
|
-
startOffset:
|
|
266
|
-
endOffset:
|
|
268
|
+
startOffset: range.startIndex,
|
|
269
|
+
endOffset: range.endIndex + 1
|
|
267
270
|
},
|
|
268
271
|
{
|
|
269
|
-
componentKey:
|
|
272
|
+
componentKey: DocLinkPopup.componentKey,
|
|
270
273
|
direction: "top",
|
|
271
274
|
closeOnSelfTarget: !0,
|
|
272
|
-
onClickOutside: () => {
|
|
275
|
+
onClickOutside: /* @__PURE__ */ __name(() => {
|
|
273
276
|
this.hideInfoPopup();
|
|
274
|
-
}
|
|
277
|
+
}, "onClickOutside")
|
|
275
278
|
}
|
|
276
279
|
), this._infoPopup;
|
|
277
280
|
}
|
|
278
281
|
hideInfoPopup() {
|
|
279
|
-
var
|
|
280
|
-
this._showingLink$.next(null), (
|
|
282
|
+
var _a8;
|
|
283
|
+
this._showingLink$.next(null), (_a8 = this._infoPopup) == null || _a8.dispose();
|
|
281
284
|
}
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
],
|
|
290
|
-
const
|
|
291
|
-
type:
|
|
285
|
+
}, __name(_a, "DocHyperLinkPopupService"), _a);
|
|
286
|
+
DocHyperLinkPopupService = __decorateClass$6([
|
|
287
|
+
__decorateParam$6(0, Inject(DocCanvasPopManagerService)),
|
|
288
|
+
__decorateParam$6(1, Inject(TextSelectionManagerService)),
|
|
289
|
+
__decorateParam$6(2, Inject(DocHyperLinkModel)),
|
|
290
|
+
__decorateParam$6(3, IUniverInstanceService),
|
|
291
|
+
__decorateParam$6(4, ICommandService)
|
|
292
|
+
], DocHyperLinkPopupService);
|
|
293
|
+
const AddDocHyperLinkCommand = {
|
|
294
|
+
type: CommandType.COMMAND,
|
|
292
295
|
id: "docs.command.add-hyper-link",
|
|
293
|
-
async handler(
|
|
294
|
-
if (!
|
|
296
|
+
async handler(accessor, params) {
|
|
297
|
+
if (!params)
|
|
295
298
|
return !1;
|
|
296
|
-
const { payload
|
|
297
|
-
|
|
299
|
+
const { payload, unitId } = params, commandService = accessor.get(ICommandService), id = generateRandomId(), doMutation = addCustomRangeBySelectionFactory(
|
|
300
|
+
accessor,
|
|
298
301
|
{
|
|
299
|
-
rangeId:
|
|
300
|
-
rangeType:
|
|
302
|
+
rangeId: id,
|
|
303
|
+
rangeType: CustomRangeType.HYPERLINK
|
|
301
304
|
}
|
|
302
305
|
);
|
|
303
|
-
if (
|
|
304
|
-
const
|
|
305
|
-
id:
|
|
306
|
-
params: { unitId
|
|
306
|
+
if (doMutation) {
|
|
307
|
+
const hyperLinkMutation = {
|
|
308
|
+
id: AddDocHyperLinkMutation.id,
|
|
309
|
+
params: { unitId, link: { payload, id } }
|
|
307
310
|
};
|
|
308
|
-
return (await
|
|
311
|
+
return (await sequenceExecuteAsync([hyperLinkMutation, doMutation], commandService)).result;
|
|
309
312
|
}
|
|
310
313
|
return !1;
|
|
311
314
|
}
|
|
312
|
-
},
|
|
315
|
+
}, UpdateDocHyperLinkCommand = {
|
|
313
316
|
id: "docs.command.update-hyper-link",
|
|
314
|
-
type:
|
|
315
|
-
handler(
|
|
316
|
-
return
|
|
317
|
+
type: CommandType.COMMAND,
|
|
318
|
+
handler(accessor, params) {
|
|
319
|
+
return params ? accessor.get(ICommandService).syncExecuteCommand(UpdateDocHyperLinkMutation.id, params) : !1;
|
|
317
320
|
}
|
|
318
|
-
},
|
|
319
|
-
docsLinkEdit
|
|
320
|
-
docsLinkEditTitle
|
|
321
|
-
docsLinkEditClose
|
|
322
|
-
docsLinkEditButtons
|
|
323
|
-
docsLinkEditButton
|
|
321
|
+
}, 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 = {
|
|
322
|
+
docsLinkEdit,
|
|
323
|
+
docsLinkEditTitle,
|
|
324
|
+
docsLinkEditClose,
|
|
325
|
+
docsLinkEditButtons,
|
|
326
|
+
docsLinkEditButton
|
|
324
327
|
};
|
|
325
|
-
function
|
|
326
|
-
return /^[a-zA-Z]+:\/\//.test(
|
|
328
|
+
function hasProtocol(urlString) {
|
|
329
|
+
return /^[a-zA-Z]+:\/\//.test(urlString);
|
|
327
330
|
}
|
|
328
|
-
|
|
329
|
-
|
|
331
|
+
__name(hasProtocol, "hasProtocol");
|
|
332
|
+
function isEmail(url) {
|
|
333
|
+
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
|
|
330
334
|
}
|
|
331
|
-
|
|
332
|
-
|
|
335
|
+
__name(isEmail, "isEmail");
|
|
336
|
+
function transformUrl(urlStr) {
|
|
337
|
+
return hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `https://${urlStr}`;
|
|
333
338
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
__name(transformUrl, "transformUrl");
|
|
340
|
+
const DocHyperLinkEdit = /* @__PURE__ */ __name(() => {
|
|
341
|
+
const hyperLinkService = useDependency(DocHyperLinkPopupService), localeService = useDependency(LocaleService), hyperLinkModel = useDependency(DocHyperLinkModel), editingId = useObservable$1(hyperLinkService.editingLink$), commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), textSelectionRenderManager = useDependency(ITextSelectionRenderManager), textSelectionManagerService = useDependency(TextSelectionManagerService), [link, setLink] = useState(""), [showError, setShowError] = useState(!1), isLegal = Tools.isLegalUrl(link), doc = editingId ? univerInstanceService.getUnit(editingId.unitId, UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
342
|
+
useEffect(() => {
|
|
343
|
+
var _a8, _b, _c, _d;
|
|
344
|
+
if (editingId) {
|
|
345
|
+
const linkDetail = editingId ? hyperLinkModel.getLink(editingId.unitId, editingId.linkId) : null;
|
|
346
|
+
setLink((_a8 = linkDetail == null ? void 0 : linkDetail.payload) != null ? _a8 : "");
|
|
341
347
|
return;
|
|
342
348
|
}
|
|
343
|
-
const
|
|
344
|
-
if (!
|
|
349
|
+
const activeRange = textSelectionManagerService.getActiveRange();
|
|
350
|
+
if (!activeRange)
|
|
345
351
|
return;
|
|
346
|
-
const
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
|
|
352
|
+
const doc2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), matchedRange = (_c = (_b = doc2 == null ? void 0 : doc2.getBody()) == null ? void 0 : _b.customRanges) == null ? void 0 : _c.find((i) => Math.max(activeRange.startOffset, i.startIndex) <= Math.min(activeRange.endOffset - 1, i.endIndex));
|
|
353
|
+
if (doc2 && matchedRange) {
|
|
354
|
+
const linkDetail = hyperLinkModel.getLink(doc2.getUnitId(), matchedRange.rangeId);
|
|
355
|
+
setLink((_d = linkDetail == null ? void 0 : linkDetail.payload) != null ? _d : "");
|
|
350
356
|
}
|
|
351
|
-
}, [
|
|
352
|
-
|
|
353
|
-
}), [
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
},
|
|
357
|
-
if (
|
|
357
|
+
}, [editingId, hyperLinkModel, textSelectionManagerService, univerInstanceService]), useEffect(() => (textSelectionRenderManager.blurEditor(), () => {
|
|
358
|
+
textSelectionRenderManager.focusEditor();
|
|
359
|
+
}), [textSelectionRenderManager]);
|
|
360
|
+
const handleCancel = /* @__PURE__ */ __name(() => {
|
|
361
|
+
hyperLinkService.hideEditPopup();
|
|
362
|
+
}, "handleCancel"), handleConfirm = /* @__PURE__ */ __name(() => {
|
|
363
|
+
if (setShowError(!0), !isLegal || !doc)
|
|
358
364
|
return;
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
unitId:
|
|
362
|
-
payload:
|
|
363
|
-
linkId:
|
|
364
|
-
}) :
|
|
365
|
-
unitId:
|
|
366
|
-
payload:
|
|
367
|
-
}),
|
|
368
|
-
};
|
|
369
|
-
if (
|
|
370
|
-
return /* @__PURE__ */
|
|
371
|
-
|
|
365
|
+
const linkFinal = transformUrl(link);
|
|
366
|
+
editingId ? commandService.executeCommand(UpdateDocHyperLinkCommand.id, {
|
|
367
|
+
unitId: doc.getUnitId(),
|
|
368
|
+
payload: linkFinal,
|
|
369
|
+
linkId: editingId.linkId
|
|
370
|
+
}) : commandService.executeCommand(AddDocHyperLinkCommand.id, {
|
|
371
|
+
unitId: doc.getUnitId(),
|
|
372
|
+
payload: linkFinal
|
|
373
|
+
}), hyperLinkService.hideEditPopup();
|
|
374
|
+
}, "handleConfirm");
|
|
375
|
+
if (doc)
|
|
376
|
+
return /* @__PURE__ */ React.createElement("div", { className: styles.docsLinkEdit }, /* @__PURE__ */ React.createElement("div", { className: styles.docsLinkEditTitle }, /* @__PURE__ */ React.createElement("span", null, localeService.t("docLink.edit.title")), /* @__PURE__ */ React.createElement(CloseSingle, { className: styles.docsLinkEditClose, onClick: handleCancel })), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
|
|
377
|
+
FormLayout,
|
|
372
378
|
{
|
|
373
|
-
label:
|
|
374
|
-
error:
|
|
379
|
+
label: localeService.t("docLink.edit.address"),
|
|
380
|
+
error: showError && !isLegal ? localeService.t("docLink.edit.addressError") : ""
|
|
375
381
|
},
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
)), /* @__PURE__ */
|
|
378
|
-
|
|
382
|
+
/* @__PURE__ */ React.createElement(Input, { value: link, onChange: setLink, autoFocus: !0 })
|
|
383
|
+
)), /* @__PURE__ */ React.createElement("div", { className: styles.docsLinkEditButtons }, /* @__PURE__ */ React.createElement(
|
|
384
|
+
Button,
|
|
379
385
|
{
|
|
380
|
-
className:
|
|
381
|
-
onClick:
|
|
386
|
+
className: styles.docsLinkEditButton,
|
|
387
|
+
onClick: handleCancel
|
|
382
388
|
},
|
|
383
|
-
|
|
384
|
-
), /* @__PURE__ */
|
|
385
|
-
|
|
389
|
+
localeService.t("docLink.edit.cancel")
|
|
390
|
+
), /* @__PURE__ */ React.createElement(
|
|
391
|
+
Button,
|
|
386
392
|
{
|
|
387
|
-
disabled: !
|
|
388
|
-
className:
|
|
393
|
+
disabled: !link,
|
|
394
|
+
className: styles.docsLinkEditButton,
|
|
389
395
|
type: "primary",
|
|
390
|
-
onClick:
|
|
396
|
+
onClick: handleConfirm
|
|
391
397
|
},
|
|
392
|
-
|
|
398
|
+
localeService.t("docLink.edit.confirm")
|
|
393
399
|
)));
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
const
|
|
397
|
-
function
|
|
400
|
+
}, "DocHyperLinkEdit");
|
|
401
|
+
DocHyperLinkEdit.componentKey = "docs-hyper-link-edit";
|
|
402
|
+
const DOC_LINK_ICON = "doc-hyper-link-icon";
|
|
403
|
+
function AddHyperLinkMenuItemFactory(accessor) {
|
|
398
404
|
return {
|
|
399
|
-
id:
|
|
400
|
-
group:
|
|
401
|
-
type:
|
|
402
|
-
icon:
|
|
405
|
+
id: ShowDocHyperLinkEditPopupOperation.id,
|
|
406
|
+
group: MenuGroup.CONTEXT_MENU_DATA,
|
|
407
|
+
type: MenuItemType.BUTTON,
|
|
408
|
+
icon: DOC_LINK_ICON,
|
|
403
409
|
title: "docLink.menu.tooltip",
|
|
404
410
|
tooltip: "docLink.menu.tooltip",
|
|
405
|
-
positions: [
|
|
406
|
-
hidden$:
|
|
407
|
-
disabled$: new
|
|
408
|
-
const
|
|
409
|
-
|
|
411
|
+
positions: [MenuPosition.TOOLBAR_START, MenuPosition.CONTEXT_MENU],
|
|
412
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
|
|
413
|
+
disabled$: new Observable(function(subscribe) {
|
|
414
|
+
const observer = accessor.get(TextSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe(() => {
|
|
415
|
+
subscribe.next(shouldDisableAddLink(accessor));
|
|
410
416
|
});
|
|
411
417
|
return () => {
|
|
412
|
-
|
|
418
|
+
observer.unsubscribe();
|
|
413
419
|
};
|
|
414
420
|
})
|
|
415
421
|
};
|
|
416
422
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
423
|
+
__name(AddHyperLinkMenuItemFactory, "AddHyperLinkMenuItemFactory");
|
|
424
|
+
const addLinkShortcut = {
|
|
425
|
+
id: ShowDocHyperLinkEditPopupOperation.id,
|
|
426
|
+
binding: MetaKeys.CTRL_COMMAND | KeyCode.K,
|
|
420
427
|
description: "docLink.menu.tooltip",
|
|
421
|
-
preconditions:
|
|
428
|
+
preconditions: whenDocAndEditorFocused
|
|
422
429
|
};
|
|
423
|
-
var
|
|
424
|
-
for (var
|
|
425
|
-
(
|
|
426
|
-
return
|
|
427
|
-
},
|
|
428
|
-
let
|
|
429
|
-
constructor(
|
|
430
|
-
super(), this._config =
|
|
430
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
431
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
432
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
433
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
434
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a2;
|
|
435
|
+
let DocHyperLinkUIController = (_a2 = class extends Disposable {
|
|
436
|
+
constructor(_config, _componentManager, _commandService, _menuService, _injector, _shortcutService) {
|
|
437
|
+
super(), this._config = _config, this._componentManager = _componentManager, this._commandService = _commandService, this._menuService = _menuService, this._injector = _injector, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortcut();
|
|
431
438
|
}
|
|
432
439
|
_initComponents() {
|
|
433
440
|
[
|
|
434
|
-
[
|
|
435
|
-
[
|
|
436
|
-
[
|
|
437
|
-
].forEach(([
|
|
438
|
-
this._componentManager.register(
|
|
441
|
+
[DocHyperLinkEdit, DocHyperLinkEdit.componentKey],
|
|
442
|
+
[DocLinkPopup, DocLinkPopup.componentKey],
|
|
443
|
+
[LinkSingle, DOC_LINK_ICON]
|
|
444
|
+
].forEach(([comp, key]) => {
|
|
445
|
+
this._componentManager.register(key, comp);
|
|
439
446
|
});
|
|
440
447
|
}
|
|
441
448
|
_initCommands() {
|
|
442
449
|
[
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
].forEach((
|
|
448
|
-
this._commandService.registerCommand(
|
|
450
|
+
AddDocHyperLinkCommand,
|
|
451
|
+
UpdateDocHyperLinkCommand,
|
|
452
|
+
DeleteDocHyperLinkCommand,
|
|
453
|
+
ShowDocHyperLinkEditPopupOperation
|
|
454
|
+
].forEach((command) => {
|
|
455
|
+
this._commandService.registerCommand(command);
|
|
449
456
|
});
|
|
450
457
|
}
|
|
451
458
|
_initShortcut() {
|
|
452
|
-
[
|
|
453
|
-
this._shortcutService.registerShortcut(
|
|
459
|
+
[addLinkShortcut].forEach((shortcut) => {
|
|
460
|
+
this._shortcutService.registerShortcut(shortcut);
|
|
454
461
|
});
|
|
455
462
|
}
|
|
456
463
|
_initMenus() {
|
|
457
|
-
[
|
|
458
|
-
this.disposeWithMe(this._menuService.addMenuItem(
|
|
464
|
+
[AddHyperLinkMenuItemFactory].forEach((menuFactory) => {
|
|
465
|
+
this.disposeWithMe(this._menuService.addMenuItem(menuFactory(this._injector), {}));
|
|
459
466
|
});
|
|
460
467
|
}
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
],
|
|
470
|
-
var
|
|
471
|
-
for (var
|
|
472
|
-
(
|
|
473
|
-
return
|
|
474
|
-
},
|
|
475
|
-
let
|
|
476
|
-
constructor(
|
|
477
|
-
super(), this._commandService =
|
|
468
|
+
}, __name(_a2, "DocHyperLinkUIController"), _a2);
|
|
469
|
+
DocHyperLinkUIController = __decorateClass$5([
|
|
470
|
+
OnLifecycle(LifecycleStages.Starting, DocHyperLinkUIController),
|
|
471
|
+
__decorateParam$5(1, Inject(ComponentManager)),
|
|
472
|
+
__decorateParam$5(2, ICommandService),
|
|
473
|
+
__decorateParam$5(3, IMenuService),
|
|
474
|
+
__decorateParam$5(4, Inject(Injector)),
|
|
475
|
+
__decorateParam$5(5, IShortcutService)
|
|
476
|
+
], DocHyperLinkUIController);
|
|
477
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
478
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
479
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
480
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
481
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a3;
|
|
482
|
+
let DocHyperLinkSelectionController = (_a3 = class extends Disposable {
|
|
483
|
+
constructor(_commandService, _univerInstanceService, _docHyperLinkService, _renderMangerService) {
|
|
484
|
+
super(), this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._docHyperLinkService = _docHyperLinkService, this._renderMangerService = _renderMangerService, this._initSelectionChange();
|
|
478
485
|
}
|
|
479
486
|
_initSelectionChange() {
|
|
480
487
|
this.disposeWithMe(
|
|
481
|
-
this._commandService.onCommandExecuted((
|
|
482
|
-
var
|
|
483
|
-
if (
|
|
484
|
-
const
|
|
485
|
-
if ((
|
|
488
|
+
this._commandService.onCommandExecuted((commandInfo) => {
|
|
489
|
+
var _a8, _b;
|
|
490
|
+
if (commandInfo.id === SetTextSelectionsOperation.id) {
|
|
491
|
+
const params = commandInfo.params, { unitId, ranges } = params, render2 = this._renderMangerService.getRenderById(unitId), skeleton = render2 == null ? void 0 : render2.with(DocSkeletonManagerService).getSkeleton();
|
|
492
|
+
if ((skeleton == null ? void 0 : skeleton.getViewModel().getEditArea()) !== DocumentEditArea.BODY) {
|
|
486
493
|
this._docHyperLinkService.hideInfoPopup(), this._docHyperLinkService.hideEditPopup();
|
|
487
494
|
return;
|
|
488
495
|
}
|
|
489
|
-
const
|
|
490
|
-
if (
|
|
491
|
-
const { startOffset
|
|
492
|
-
if (
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
495
|
-
const
|
|
496
|
-
this._docHyperLinkService.showInfoPopup({ unitId
|
|
496
|
+
const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), primary = ranges[0];
|
|
497
|
+
if (primary && doc) {
|
|
498
|
+
const { startOffset, endOffset, collapsed } = primary, customRanges = (_a8 = doc.getBody()) == null ? void 0 : _a8.customRanges;
|
|
499
|
+
if (collapsed) {
|
|
500
|
+
const index = (_b = customRanges == null ? void 0 : customRanges.findIndex((value) => value.startIndex < startOffset && value.endIndex > endOffset - 1)) != null ? _b : -1;
|
|
501
|
+
if (index > -1) {
|
|
502
|
+
const customRange = customRanges[index];
|
|
503
|
+
this._docHyperLinkService.showInfoPopup({ unitId, linkId: customRange.rangeId, rangeIndex: index });
|
|
497
504
|
return;
|
|
498
505
|
}
|
|
499
|
-
} else if (
|
|
506
|
+
} else if (customRanges != null && customRanges.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1))
|
|
500
507
|
return;
|
|
501
508
|
}
|
|
502
509
|
this._docHyperLinkService.hideInfoPopup(), this._docHyperLinkService.hideEditPopup();
|
|
@@ -504,144 +511,220 @@ let V = class extends T {
|
|
|
504
511
|
})
|
|
505
512
|
);
|
|
506
513
|
}
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
],
|
|
515
|
-
var
|
|
516
|
-
for (var
|
|
517
|
-
(
|
|
518
|
-
return
|
|
519
|
-
},
|
|
520
|
-
let
|
|
521
|
-
constructor(
|
|
522
|
-
super(), this._context =
|
|
514
|
+
}, __name(_a3, "DocHyperLinkSelectionController"), _a3);
|
|
515
|
+
DocHyperLinkSelectionController = __decorateClass$4([
|
|
516
|
+
OnLifecycle(LifecycleStages.Ready, DocHyperLinkSelectionController),
|
|
517
|
+
__decorateParam$4(0, ICommandService),
|
|
518
|
+
__decorateParam$4(1, IUniverInstanceService),
|
|
519
|
+
__decorateParam$4(2, Inject(DocHyperLinkPopupService)),
|
|
520
|
+
__decorateParam$4(3, IRenderManagerService)
|
|
521
|
+
], DocHyperLinkSelectionController);
|
|
522
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
523
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
524
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
525
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
526
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a4;
|
|
527
|
+
let DocHyperLinkRenderController = (_a4 = class extends Disposable {
|
|
528
|
+
constructor(_context, _docInterceptorService, _hyperLinkService) {
|
|
529
|
+
super(), this._context = _context, this._docInterceptorService = _docInterceptorService, this._hyperLinkService = _hyperLinkService, this._init();
|
|
523
530
|
}
|
|
524
531
|
_init() {
|
|
525
|
-
this._docInterceptorService.intercept(
|
|
526
|
-
handler: (
|
|
527
|
-
if (!
|
|
528
|
-
return
|
|
529
|
-
const { unitId
|
|
530
|
-
return
|
|
531
|
-
...
|
|
532
|
-
active:
|
|
532
|
+
this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_RANGE, {
|
|
533
|
+
handler: /* @__PURE__ */ __name((data, pos, next) => {
|
|
534
|
+
if (!data)
|
|
535
|
+
return next(data);
|
|
536
|
+
const { unitId } = pos, activeLink = this._hyperLinkService.showing, { linkId, unitId: linkUnitId } = activeLink || {}, isActive = linkUnitId === unitId && data.rangeId === linkId;
|
|
537
|
+
return next({
|
|
538
|
+
...data,
|
|
539
|
+
active: isActive
|
|
533
540
|
});
|
|
534
|
-
}
|
|
541
|
+
}, "handler")
|
|
535
542
|
});
|
|
536
543
|
}
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
],
|
|
542
|
-
var
|
|
543
|
-
for (var
|
|
544
|
-
(
|
|
545
|
-
return
|
|
546
|
-
},
|
|
547
|
-
let
|
|
548
|
-
constructor(
|
|
549
|
-
super(), this._docClipboardService =
|
|
544
|
+
}, __name(_a4, "DocHyperLinkRenderController"), _a4);
|
|
545
|
+
DocHyperLinkRenderController = __decorateClass$3([
|
|
546
|
+
__decorateParam$3(1, Inject(DocInterceptorService)),
|
|
547
|
+
__decorateParam$3(2, Inject(DocHyperLinkPopupService))
|
|
548
|
+
], DocHyperLinkRenderController);
|
|
549
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
550
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
551
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
552
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
553
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a5;
|
|
554
|
+
let DocHyperLinkClipboardController = (_a5 = class extends Disposable {
|
|
555
|
+
constructor(_docClipboardService, _univerInstanceService, _hyperLinkModel, _textSelectionManagerService, _commandService) {
|
|
556
|
+
super(), this._docClipboardService = _docClipboardService, this._univerInstanceService = _univerInstanceService, this._hyperLinkModel = _hyperLinkModel, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, this._initClipboard();
|
|
550
557
|
}
|
|
551
558
|
_initClipboard() {
|
|
552
559
|
this.disposeWithMe(this._docClipboardService.addClipboardHook({
|
|
553
|
-
onBeforePaste: (
|
|
554
|
-
var
|
|
555
|
-
const
|
|
556
|
-
if (!
|
|
557
|
-
return
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
560
|
-
(
|
|
560
|
+
onBeforePaste: /* @__PURE__ */ __name((body) => {
|
|
561
|
+
var _a8, _b;
|
|
562
|
+
const doc = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
563
|
+
if (!doc)
|
|
564
|
+
return body;
|
|
565
|
+
const activeRange = this._textSelectionManagerService.getActiveRange(), customRanges = (_a8 = doc.getBody()) == null ? void 0 : _a8.customRanges;
|
|
566
|
+
if (activeRange ? customRanges == null ? void 0 : customRanges.find(
|
|
567
|
+
(range) => range.rangeType === CustomRangeType.HYPERLINK && range.startIndex <= activeRange.startOffset && range.endIndex >= activeRange.endOffset - 1
|
|
561
568
|
) : null) {
|
|
562
|
-
const { customRanges:
|
|
563
|
-
...
|
|
564
|
-
customRanges:
|
|
569
|
+
const { customRanges: customRanges2 = [], ...extBody } = body, deleteIndexes = customRanges2.filter((range) => range.rangeType === CustomRangeType.HYPERLINK).map((i) => [i.startIndex, i.endIndex]).flat().sort((pre, aft) => pre - aft), bodyWithoutLink = {
|
|
570
|
+
...extBody,
|
|
571
|
+
customRanges: customRanges2.filter((range) => range.rangeType !== CustomRangeType.HYPERLINK)
|
|
565
572
|
};
|
|
566
|
-
for (let
|
|
567
|
-
|
|
568
|
-
return
|
|
573
|
+
for (let i = 0; i < deleteIndexes.length; i++)
|
|
574
|
+
updateAttributeByDelete(bodyWithoutLink, 1, deleteIndexes[i] - i);
|
|
575
|
+
return bodyWithoutLink;
|
|
569
576
|
} else {
|
|
570
|
-
const
|
|
571
|
-
(
|
|
572
|
-
var
|
|
573
|
-
if (
|
|
574
|
-
if (
|
|
575
|
-
const
|
|
576
|
-
if (
|
|
577
|
-
const
|
|
578
|
-
this.
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
577
|
+
const unitId = doc.getUnitId(), customRangeIds = new Set(customRanges == null ? void 0 : customRanges.map((i) => i.rangeType === CustomRangeType.HYPERLINK && i.rangeId));
|
|
578
|
+
(_b = body.customRanges) == null || _b.forEach((range) => {
|
|
579
|
+
var _a9;
|
|
580
|
+
if (range.rangeType === CustomRangeType.HYPERLINK) {
|
|
581
|
+
if (customRangeIds.has(range.rangeId)) {
|
|
582
|
+
const link = this._hyperLinkModel.getLink(unitId, range.rangeId);
|
|
583
|
+
if (link) {
|
|
584
|
+
const newId = Tools.generateRandomId();
|
|
585
|
+
this._commandService.executeCommand(
|
|
586
|
+
AddDocHyperLinkMutation.id,
|
|
587
|
+
{
|
|
588
|
+
unitId,
|
|
589
|
+
link: {
|
|
590
|
+
id: newId,
|
|
591
|
+
payload: link.payload
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
), range.rangeId = newId;
|
|
582
595
|
}
|
|
583
|
-
} else if ((
|
|
584
|
-
const
|
|
585
|
-
this.
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
596
|
+
} else if ((_a9 = body.payloads) != null && _a9[range.rangeId]) {
|
|
597
|
+
const url = body.payloads[range.rangeId];
|
|
598
|
+
this._commandService.executeCommand(
|
|
599
|
+
AddDocHyperLinkMutation.id,
|
|
600
|
+
{
|
|
601
|
+
unitId,
|
|
602
|
+
link: {
|
|
603
|
+
id: range.rangeId,
|
|
604
|
+
payload: url
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
);
|
|
589
608
|
}
|
|
590
609
|
}
|
|
591
610
|
});
|
|
592
611
|
}
|
|
593
|
-
return
|
|
594
|
-
}
|
|
612
|
+
return body;
|
|
613
|
+
}, "onBeforePaste")
|
|
595
614
|
}));
|
|
596
615
|
}
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
616
|
+
}, __name(_a5, "DocHyperLinkClipboardController"), _a5);
|
|
617
|
+
DocHyperLinkClipboardController = __decorateClass$2([
|
|
618
|
+
OnLifecycle(LifecycleStages.Ready, DocHyperLinkClipboardController),
|
|
619
|
+
__decorateParam$2(0, Inject(IDocClipboardService)),
|
|
620
|
+
__decorateParam$2(1, IUniverInstanceService),
|
|
621
|
+
__decorateParam$2(2, Inject(DocHyperLinkModel)),
|
|
622
|
+
__decorateParam$2(3, Inject(TextSelectionManagerService)),
|
|
623
|
+
__decorateParam$2(4, ICommandService)
|
|
624
|
+
], DocHyperLinkClipboardController);
|
|
625
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
626
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(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$1(target, key, result), result;
|
|
629
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a6;
|
|
630
|
+
let DocHyperLinkCustomRangeController = (_a6 = class extends Disposable {
|
|
631
|
+
constructor(_docCustomRangeService, _docHyperLinkModel, _commandService) {
|
|
632
|
+
super(), this._docCustomRangeService = _docCustomRangeService, this._docHyperLinkModel = _docHyperLinkModel, this._commandService = _commandService, this._initCustomRangeHooks();
|
|
613
633
|
}
|
|
614
|
-
|
|
634
|
+
_initCustomRangeHooks() {
|
|
635
|
+
this.disposeWithMe(
|
|
636
|
+
this._docCustomRangeService.addClipboardHook({
|
|
637
|
+
onCopyCustomRange: /* @__PURE__ */ __name((unitId, range) => {
|
|
638
|
+
const { rangeId, rangeType, data, ...ext } = range;
|
|
639
|
+
if (rangeType === CustomRangeType.HYPERLINK) {
|
|
640
|
+
if (data) {
|
|
641
|
+
const id = Tools.generateRandomId();
|
|
642
|
+
return this._commandService.executeCommand(
|
|
643
|
+
AddDocHyperLinkMutation.id,
|
|
644
|
+
{
|
|
645
|
+
unitId,
|
|
646
|
+
link: {
|
|
647
|
+
id,
|
|
648
|
+
payload: data
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
), {
|
|
652
|
+
...range,
|
|
653
|
+
rangeId: id
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
const link = this._docHyperLinkModel.getLink(unitId, rangeId);
|
|
657
|
+
if (!link)
|
|
658
|
+
return range;
|
|
659
|
+
const newId = Tools.generateRandomId();
|
|
660
|
+
return this._commandService.executeCommand(
|
|
661
|
+
AddDocHyperLinkMutation.id,
|
|
662
|
+
{
|
|
663
|
+
unitId,
|
|
664
|
+
link: {
|
|
665
|
+
id: newId,
|
|
666
|
+
payload: link.payload
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
), {
|
|
670
|
+
...ext,
|
|
671
|
+
rangeId: newId,
|
|
672
|
+
rangeType
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
return range;
|
|
676
|
+
}, "onCopyCustomRange")
|
|
677
|
+
})
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
}, __name(_a6, "DocHyperLinkCustomRangeController"), _a6);
|
|
681
|
+
DocHyperLinkCustomRangeController = __decorateClass$1([
|
|
682
|
+
OnLifecycle(LifecycleStages.Ready, DocHyperLinkCustomRangeController),
|
|
683
|
+
__decorateParam$1(0, Inject(DocCustomRangeService)),
|
|
684
|
+
__decorateParam$1(1, Inject(DocHyperLinkModel)),
|
|
685
|
+
__decorateParam$1(2, ICommandService)
|
|
686
|
+
], DocHyperLinkCustomRangeController);
|
|
687
|
+
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) => {
|
|
688
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
689
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
690
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
691
|
+
}, "__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"), _a7;
|
|
692
|
+
let UniverDocsHyperLinkUIPlugin = (_a7 = class extends Plugin {
|
|
693
|
+
constructor(_config = { menu: {} }, _injector, _renderManagerSrv) {
|
|
694
|
+
super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv;
|
|
695
|
+
}
|
|
696
|
+
onStarting() {
|
|
615
697
|
[
|
|
616
|
-
[
|
|
698
|
+
[DocHyperLinkPopupService],
|
|
617
699
|
[
|
|
618
|
-
|
|
700
|
+
DocHyperLinkUIController,
|
|
619
701
|
{
|
|
620
|
-
useFactory: () => this._injector.createInstance(
|
|
702
|
+
useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(DocHyperLinkUIController, this._config), "useFactory")
|
|
621
703
|
}
|
|
622
704
|
],
|
|
623
|
-
[
|
|
624
|
-
[
|
|
625
|
-
|
|
626
|
-
|
|
705
|
+
[DocHyperLinkSelectionController],
|
|
706
|
+
[DocHyperLinkClipboardController],
|
|
707
|
+
[DocHyperLinkCustomRangeController]
|
|
708
|
+
].forEach((dep) => {
|
|
709
|
+
this._injector.add(dep);
|
|
627
710
|
});
|
|
628
711
|
}
|
|
629
712
|
onRendered() {
|
|
630
713
|
this._initRenderModule();
|
|
631
714
|
}
|
|
632
715
|
_initRenderModule() {
|
|
633
|
-
[
|
|
634
|
-
this._renderManagerSrv.registerRenderModule(
|
|
716
|
+
[DocHyperLinkRenderController].forEach((dep) => {
|
|
717
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, dep);
|
|
635
718
|
});
|
|
636
719
|
}
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
],
|
|
720
|
+
}, __name(_a7, "UniverDocsHyperLinkUIPlugin"), _a7);
|
|
721
|
+
__publicField2(UniverDocsHyperLinkUIPlugin, "pluginName", DOC_HYPER_LINK_UI_PLUGIN);
|
|
722
|
+
__publicField2(UniverDocsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
723
|
+
UniverDocsHyperLinkUIPlugin = __decorateClass([
|
|
724
|
+
DependentOn(UniverDocsHyperLinkPlugin),
|
|
725
|
+
__decorateParam(1, Inject(Injector)),
|
|
726
|
+
__decorateParam(2, IRenderManagerService)
|
|
727
|
+
], UniverDocsHyperLinkUIPlugin);
|
|
645
728
|
export {
|
|
646
|
-
|
|
729
|
+
UniverDocsHyperLinkUIPlugin
|
|
647
730
|
};
|