@univerjs/sheets-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 +2 -2
- package/lib/es/index.js +1089 -1076
- package/lib/types/controllers/copy-paste.controller.d.ts +1 -2
- package/lib/types/controllers/menu.d.ts +1 -1
- package/lib/types/controllers/set-range.controller.d.ts +1 -2
- package/lib/types/controllers/ui.controller.d.ts +1 -2
- package/lib/types/plugin.d.ts +2 -3
- package/lib/types/services/popup.service.d.ts +1 -2
- package/lib/umd/index.js +2 -2
- package/package.json +25 -27
package/lib/es/index.js
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { RemoveHyperLinkMutation
|
|
8
|
-
import { SheetSkeletonManagerService
|
|
9
|
-
import { IRenderManagerService
|
|
10
|
-
import { debounceTime
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
super(), this._sheetInterceptorService = e, this._univerInstanceService = t, this._hyperLinkModel = n, this._initSheetChange();
|
|
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 { Disposable, UniverInstanceType, OnLifecycle, LifecycleStages, Inject, IUniverInstanceService, BooleanNumber, ThemeService, isValidRange, LocaleService, RANGE_TYPE, Rectangle, ICommandService, Tools, DEFAULT_EMPTY_DOCUMENT_VALUE, useDependency, createInternalEditorID, CommandType, CellValueType, ObjectMatrix, Range, CustomRangeType, Injector, IPermissionService, Plugin, DependentOn } from "@univerjs/core";
|
|
6
|
+
import { RemoveSheetCommand, SheetInterceptorService, INTERCEPTOR_POINT, SetSelectionsOperation, SetWorksheetActiveOperation, getSheetCommandTarget, SheetsSelectionsService, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetRangeValuesCommand, ClearSelectionContentCommand, ClearSelectionAllCommand, ClearSelectionFormatCommand, WorkbookViewPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetInsertHyperlinkPermission, RangeProtectionPermissionEditPoint, WorkbookCopyPermission, WorksheetCopyPermission, WorksheetSetCellValuePermission } from "@univerjs/sheets";
|
|
7
|
+
import { RemoveHyperLinkMutation, AddHyperLinkMutation, HyperLinkModel, ERROR_RANGE, UpdateHyperLinkCommand, AddHyperLinkCommand, CancelHyperLinkCommand, UniverSheetsHyperLinkPlugin } from "@univerjs/sheets-hyper-link";
|
|
8
|
+
import { SheetSkeletonManagerService, ScrollToRangeOperation, SheetCanvasPopManagerService, IEditorBridgeService, HoverManagerService, SheetPermissionInterceptorBaseController, whenSheetEditorFocused, getCurrentRangeDisable$, APPLY_TYPE, IAutoFillService, virtualizeDiscreteRanges, getAutoFillRepeatRange, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService } from "@univerjs/sheets-ui";
|
|
9
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
10
|
+
import { debounceTime, Subject, BehaviorSubject } from "rxjs";
|
|
11
|
+
import require$$0, { forwardRef, useRef, createElement, useState, useEffect, useMemo } from "react";
|
|
12
|
+
import cs from "clsx";
|
|
13
|
+
import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
|
|
14
|
+
import { IMessageService, useObservable, useEvent, RangeSelector, ISidebarService, KeyCode, MetaKeys, MenuItemType, MenuPosition, getMenuHiddenObservable, MenuGroup, ComponentManager, IShortcutService, IMenuService } from "@univerjs/ui";
|
|
15
|
+
import { deserializeRangeWithSheet, serializeRangeWithSheet, IDefinedNamesService, serializeRangeToRefString, serializeRange } from "@univerjs/engine-formula";
|
|
16
|
+
import { DOC_HYPER_LINK_PLUGIN } from "@univerjs/docs-hyper-link";
|
|
17
|
+
import { getPlainTextFormDocument } from "@univerjs/docs";
|
|
18
|
+
var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
19
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
20
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
21
|
+
return kind && result && __defProp$b(target, key, result), result;
|
|
22
|
+
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a;
|
|
23
|
+
let SheetsHyperLinkRemoveSheetController = (_a = class extends Disposable {
|
|
24
|
+
constructor(_sheetInterceptorService, _univerInstanceService, _hyperLinkModel) {
|
|
25
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._hyperLinkModel = _hyperLinkModel, this._initSheetChange();
|
|
27
26
|
}
|
|
28
27
|
_initSheetChange() {
|
|
29
28
|
this.disposeWithMe(
|
|
30
29
|
this._sheetInterceptorService.interceptCommand({
|
|
31
|
-
getMutations: (
|
|
32
|
-
var
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
30
|
+
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
31
|
+
var _a14;
|
|
32
|
+
if (commandInfo.id === RemoveSheetCommand.id) {
|
|
33
|
+
const params = commandInfo.params, workbook = params.unitId ? this._univerInstanceService.getUnit(params.unitId) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
34
|
+
if (!workbook)
|
|
36
35
|
return { redos: [], undos: [] };
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
36
|
+
const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a14 = workbook.getActiveSheet()) == null ? void 0 : _a14.getSheetId());
|
|
37
|
+
if (!subUnitId)
|
|
39
38
|
return { redos: [], undos: [] };
|
|
40
|
-
const
|
|
41
|
-
id:
|
|
39
|
+
const links = this._hyperLinkModel.getSubUnit(unitId, subUnitId), redos = links.map((link) => ({
|
|
40
|
+
id: RemoveHyperLinkMutation.id,
|
|
42
41
|
params: {
|
|
43
|
-
unitId
|
|
44
|
-
subUnitId
|
|
45
|
-
id:
|
|
42
|
+
unitId,
|
|
43
|
+
subUnitId,
|
|
44
|
+
id: link.id
|
|
46
45
|
}
|
|
47
|
-
})),
|
|
48
|
-
id:
|
|
46
|
+
})), undos = links.map((link) => ({
|
|
47
|
+
id: AddHyperLinkMutation.id,
|
|
49
48
|
params: {
|
|
50
|
-
unitId
|
|
51
|
-
subUnitId
|
|
52
|
-
link
|
|
49
|
+
unitId,
|
|
50
|
+
subUnitId,
|
|
51
|
+
link
|
|
53
52
|
}
|
|
54
53
|
}));
|
|
55
|
-
return { redos
|
|
54
|
+
return { redos, undos };
|
|
56
55
|
}
|
|
57
56
|
return { redos: [], undos: [] };
|
|
58
|
-
}
|
|
57
|
+
}, "getMutations")
|
|
59
58
|
})
|
|
60
59
|
);
|
|
61
60
|
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
],
|
|
69
|
-
var
|
|
70
|
-
for (var
|
|
71
|
-
(
|
|
72
|
-
return
|
|
73
|
-
},
|
|
74
|
-
let
|
|
75
|
-
constructor(
|
|
76
|
-
super(), this._context =
|
|
61
|
+
}, __name(_a, "SheetsHyperLinkRemoveSheetController"), _a);
|
|
62
|
+
SheetsHyperLinkRemoveSheetController = __decorateClass$b([
|
|
63
|
+
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkRemoveSheetController),
|
|
64
|
+
__decorateParam$b(0, Inject(SheetInterceptorService)),
|
|
65
|
+
__decorateParam$b(1, IUniverInstanceService),
|
|
66
|
+
__decorateParam$b(2, Inject(HyperLinkModel))
|
|
67
|
+
], SheetsHyperLinkRemoveSheetController);
|
|
68
|
+
var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
69
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
70
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
71
|
+
return kind && result && __defProp$a(target, key, result), result;
|
|
72
|
+
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a2;
|
|
73
|
+
let SheetsHyperLinkRenderController = (_a2 = class extends Disposable {
|
|
74
|
+
constructor(_context, _hyperLinkModel, _sheetSkeletonManagerService, _renderManagerService) {
|
|
75
|
+
super(), this._context = _context, this._hyperLinkModel = _hyperLinkModel, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._renderManagerService = _renderManagerService, this._initSkeletonChange();
|
|
77
76
|
}
|
|
78
77
|
_initSkeletonChange() {
|
|
79
|
-
const
|
|
80
|
-
var
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
78
|
+
const markSkeletonDirty = /* @__PURE__ */ __name(() => {
|
|
79
|
+
var _a14;
|
|
80
|
+
const workbook = this._context.unit, unitId = workbook.getUnitId(), subUnitId = (_a14 = workbook.getActiveSheet()) == null ? void 0 : _a14.getSheetId();
|
|
81
|
+
if (!subUnitId) {
|
|
83
82
|
console.warn("No active sheet found");
|
|
84
83
|
return;
|
|
85
84
|
}
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(
|
|
90
|
-
|
|
85
|
+
const skeleton = this._sheetSkeletonManagerService.getOrCreateSkeleton({ sheetId: subUnitId }), currentRender = this._renderManagerService.getRenderById(unitId);
|
|
86
|
+
skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
|
|
87
|
+
}, "markSkeletonDirty");
|
|
88
|
+
this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(debounceTime(16)).subscribe(() => {
|
|
89
|
+
markSkeletonDirty();
|
|
91
90
|
}));
|
|
92
91
|
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
],
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
}, __name(_a2, "SheetsHyperLinkRenderController"), _a2);
|
|
93
|
+
SheetsHyperLinkRenderController = __decorateClass$a([
|
|
94
|
+
__decorateParam$a(1, Inject(HyperLinkModel)),
|
|
95
|
+
__decorateParam$a(2, Inject(SheetSkeletonManagerService)),
|
|
96
|
+
__decorateParam$a(3, IRenderManagerService)
|
|
97
|
+
], SheetsHyperLinkRenderController);
|
|
98
|
+
var _a3;
|
|
99
|
+
let SheetsHyperLinkRenderManagerController = (_a3 = class extends Disposable {
|
|
100
|
+
constructor(_sheetInterceptorService, _hyperLinkModel, _themeService) {
|
|
101
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._hyperLinkModel = _hyperLinkModel, this._themeService = _themeService, this._initViewModelIntercept();
|
|
102
102
|
}
|
|
103
103
|
_initViewModelIntercept() {
|
|
104
104
|
this.disposeWithMe(
|
|
105
105
|
this._sheetInterceptorService.intercept(
|
|
106
|
-
|
|
106
|
+
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
107
107
|
{
|
|
108
|
-
handler: (
|
|
109
|
-
const { row
|
|
110
|
-
return
|
|
111
|
-
...
|
|
108
|
+
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
109
|
+
const { row, col, unitId, subUnitId } = pos, link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col), styleSheet = this._themeService.getCurrentTheme();
|
|
110
|
+
return next(link ? {
|
|
111
|
+
...cell,
|
|
112
112
|
interceptorStyle: {
|
|
113
113
|
ul: {
|
|
114
|
-
s:
|
|
114
|
+
s: BooleanNumber.TRUE
|
|
115
115
|
},
|
|
116
116
|
cl: {
|
|
117
|
-
rgb:
|
|
117
|
+
rgb: styleSheet.blue500
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
} :
|
|
121
|
-
},
|
|
120
|
+
} : cell);
|
|
121
|
+
}, "handler"),
|
|
122
122
|
priority: 100
|
|
123
123
|
}
|
|
124
124
|
)
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
],
|
|
134
|
-
var
|
|
127
|
+
}, __name(_a3, "SheetsHyperLinkRenderManagerController"), _a3);
|
|
128
|
+
SheetsHyperLinkRenderManagerController = __decorateClass$a([
|
|
129
|
+
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkRenderManagerController),
|
|
130
|
+
__decorateParam$a(0, Inject(SheetInterceptorService)),
|
|
131
|
+
__decorateParam$a(1, Inject(HyperLinkModel)),
|
|
132
|
+
__decorateParam$a(2, Inject(ThemeService))
|
|
133
|
+
], SheetsHyperLinkRenderManagerController);
|
|
134
|
+
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
135
135
|
/**
|
|
136
136
|
* @license React
|
|
137
137
|
* react-jsx-runtime.production.min.js
|
|
@@ -141,158 +141,165 @@ var $t = { exports: {} }, Ae = {};
|
|
|
141
141
|
* This source code is licensed under the MIT license found in the
|
|
142
142
|
* LICENSE file in the root directory of this source tree.
|
|
143
143
|
*/
|
|
144
|
-
var
|
|
145
|
-
function
|
|
146
|
-
var
|
|
147
|
-
|
|
148
|
-
for (
|
|
149
|
-
if (
|
|
150
|
-
return { $$typeof:
|
|
144
|
+
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 };
|
|
145
|
+
function q(c, a, g) {
|
|
146
|
+
var b, d = {}, e = null, h = null;
|
|
147
|
+
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
|
|
148
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
149
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
150
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
151
151
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
__name(q, "q");
|
|
153
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
154
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
155
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
156
|
+
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
157
|
+
var jsxRuntimeExports = jsxRuntime.exports, __assign = function() {
|
|
158
|
+
return __assign = Object.assign || function(t) {
|
|
159
|
+
for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
|
|
160
|
+
s = arguments[i];
|
|
161
|
+
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
|
|
161
162
|
}
|
|
162
|
-
return
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
var
|
|
166
|
-
for (var
|
|
167
|
-
if (
|
|
168
|
-
for (var i = 0,
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
},
|
|
172
|
-
var
|
|
173
|
-
return
|
|
163
|
+
return t;
|
|
164
|
+
}, __assign.apply(this, arguments);
|
|
165
|
+
}, __rest = function(s, e) {
|
|
166
|
+
var t = {};
|
|
167
|
+
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
|
|
168
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
169
|
+
for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
|
|
170
|
+
e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
|
|
171
|
+
return t;
|
|
172
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
173
|
+
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()));
|
|
174
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
174
175
|
});
|
|
175
|
-
function
|
|
176
|
-
return
|
|
177
|
-
return
|
|
176
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
177
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
178
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
178
179
|
}));
|
|
179
180
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
181
|
+
__name(render, "render");
|
|
182
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
183
|
+
var attrs = __assign({}, node.attrs);
|
|
184
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
185
|
+
var defIds = runtimeProps.defIds;
|
|
186
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a14) {
|
|
187
|
+
var key = _a14[0], value = _a14[1];
|
|
188
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
189
|
+
})), attrs;
|
|
188
190
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
192
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
193
|
+
var _a14, defIds = runtimeProps.defIds;
|
|
194
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a14 = node.children) === null || _a14 === void 0) && _a14.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
195
|
+
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;
|
|
196
|
+
}) }) : node;
|
|
194
197
|
}
|
|
195
|
-
|
|
198
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
199
|
+
function generateShortUuid() {
|
|
196
200
|
return Math.random().toString(36).substring(2, 8);
|
|
197
201
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
202
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
203
|
+
IconBase.displayName = "UniverIcon";
|
|
204
|
+
var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, AllBorderSingle = forwardRef(function(props, ref) {
|
|
205
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
201
206
|
id: "all-border-single",
|
|
202
|
-
ref
|
|
203
|
-
icon:
|
|
207
|
+
ref,
|
|
208
|
+
icon: element$5
|
|
204
209
|
}));
|
|
205
210
|
});
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
return
|
|
211
|
+
AllBorderSingle.displayName = "AllBorderSingle";
|
|
212
|
+
var element$4 = { 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) {
|
|
213
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
209
214
|
id: "copy-single",
|
|
210
|
-
ref
|
|
211
|
-
icon:
|
|
215
|
+
ref,
|
|
216
|
+
icon: element$4
|
|
212
217
|
}));
|
|
213
218
|
});
|
|
214
|
-
|
|
215
|
-
var
|
|
216
|
-
return
|
|
219
|
+
CopySingle.displayName = "CopySingle";
|
|
220
|
+
var element$3 = { 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) {
|
|
221
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
217
222
|
id: "link-single",
|
|
218
|
-
ref
|
|
219
|
-
icon:
|
|
223
|
+
ref,
|
|
224
|
+
icon: element$3
|
|
220
225
|
}));
|
|
221
226
|
});
|
|
222
|
-
|
|
223
|
-
var
|
|
224
|
-
return
|
|
227
|
+
LinkSingle.displayName = "LinkSingle";
|
|
228
|
+
var element$2 = { 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) {
|
|
229
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
225
230
|
id: "unlink-single",
|
|
226
|
-
ref
|
|
227
|
-
icon:
|
|
231
|
+
ref,
|
|
232
|
+
icon: element$2
|
|
228
233
|
}));
|
|
229
234
|
});
|
|
230
|
-
|
|
231
|
-
var
|
|
232
|
-
return
|
|
235
|
+
UnlinkSingle.displayName = "UnlinkSingle";
|
|
236
|
+
var element$1 = { 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) {
|
|
237
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
233
238
|
id: "write-single",
|
|
234
|
-
ref
|
|
235
|
-
icon:
|
|
239
|
+
ref,
|
|
240
|
+
icon: element$1
|
|
236
241
|
}));
|
|
237
242
|
});
|
|
238
|
-
|
|
239
|
-
var
|
|
240
|
-
return
|
|
243
|
+
WriteSingle.displayName = "WriteSingle";
|
|
244
|
+
var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#35BD4B", d: "M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z" } }, { tag: "path", attrs: { fill: "#32A846", d: "M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Xlsx = forwardRef(function(props, ref) {
|
|
245
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
241
246
|
id: "xlsx",
|
|
242
|
-
ref
|
|
243
|
-
icon:
|
|
247
|
+
ref,
|
|
248
|
+
icon: element
|
|
244
249
|
}));
|
|
245
250
|
});
|
|
246
|
-
|
|
247
|
-
var
|
|
248
|
-
for (var
|
|
249
|
-
(
|
|
250
|
-
return
|
|
251
|
-
},
|
|
252
|
-
function
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
255
|
-
return
|
|
256
|
-
const
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
}),
|
|
251
|
+
Xlsx.displayName = "Xlsx";
|
|
252
|
+
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
253
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
254
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
255
|
+
return kind && result && __defProp$9(target, key, result), result;
|
|
256
|
+
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
|
|
257
|
+
function getContainRange(range, worksheet) {
|
|
258
|
+
const mergedCells = worksheet.getMergeData(), maxCol = worksheet.getMaxColumns() - 1, maxRow = worksheet.getMaxRows() - 1;
|
|
259
|
+
if (maxCol < range.endColumn && (range.endColumn = maxCol), maxRow < range.endRow && (range.endRow = maxRow), range.rangeType === RANGE_TYPE.COLUMN || RANGE_TYPE.ROW)
|
|
260
|
+
return range;
|
|
261
|
+
const relativeCells = [];
|
|
262
|
+
return mergedCells.forEach((cell) => {
|
|
263
|
+
Rectangle.intersects(range, cell) && relativeCells.push(cell);
|
|
264
|
+
}), Rectangle.realUnion(range, ...relativeCells);
|
|
260
265
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
266
|
+
__name(getContainRange, "getContainRange");
|
|
267
|
+
var _a4;
|
|
268
|
+
let SheetsHyperLinkResolverService = (_a4 = class {
|
|
269
|
+
constructor(_univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService) {
|
|
270
|
+
this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService;
|
|
264
271
|
}
|
|
265
|
-
_getURLName(
|
|
266
|
-
var
|
|
267
|
-
const { gid
|
|
268
|
-
if (!
|
|
272
|
+
_getURLName(params) {
|
|
273
|
+
var _a14;
|
|
274
|
+
const { gid, range, rangeid } = params, workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
275
|
+
if (!workbook)
|
|
269
276
|
return null;
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
273
|
-
return
|
|
277
|
+
const sheet = gid ? workbook.getSheetBySheetId(gid) : workbook.getActiveSheet(), sheetName = (_a14 = sheet == null ? void 0 : sheet.getName()) != null ? _a14 : "";
|
|
278
|
+
if (range) {
|
|
279
|
+
const rangeObj = deserializeRangeWithSheet(range).range;
|
|
280
|
+
return isValidRange(rangeObj) && range !== ERROR_RANGE ? {
|
|
274
281
|
type: "range",
|
|
275
|
-
name:
|
|
282
|
+
name: serializeRangeWithSheet(sheetName, rangeObj)
|
|
276
283
|
} : {
|
|
277
284
|
type: "range-error",
|
|
278
285
|
name: this._localeService.t("hyperLink.message.refError")
|
|
279
286
|
};
|
|
280
287
|
}
|
|
281
|
-
if (
|
|
282
|
-
const
|
|
283
|
-
return
|
|
288
|
+
if (rangeid) {
|
|
289
|
+
const range2 = this._definedNamesService.getValueById(workbook.getUnitId(), rangeid);
|
|
290
|
+
return range2 ? {
|
|
284
291
|
type: "defineName",
|
|
285
|
-
name:
|
|
292
|
+
name: range2.formulaOrRefString
|
|
286
293
|
} : {
|
|
287
294
|
type: "range-error",
|
|
288
295
|
name: this._localeService.t("hyperLink.message.refError")
|
|
289
296
|
};
|
|
290
297
|
}
|
|
291
|
-
if (
|
|
292
|
-
const
|
|
293
|
-
return
|
|
298
|
+
if (gid) {
|
|
299
|
+
const worksheet = workbook.getSheetBySheetId(gid);
|
|
300
|
+
return worksheet ? {
|
|
294
301
|
type: "sheet",
|
|
295
|
-
name:
|
|
302
|
+
name: worksheet.getName()
|
|
296
303
|
} : {
|
|
297
304
|
type: "sheet-error",
|
|
298
305
|
name: this._localeService.t("hyperLink.message.refError")
|
|
@@ -300,558 +307,564 @@ let F = class {
|
|
|
300
307
|
}
|
|
301
308
|
return null;
|
|
302
309
|
}
|
|
303
|
-
navigateTo(
|
|
304
|
-
const { gid
|
|
305
|
-
if (!
|
|
310
|
+
navigateTo(params) {
|
|
311
|
+
const { gid, range, rangeid } = params, workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
312
|
+
if (!workbook)
|
|
306
313
|
return;
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
|
|
314
|
+
const unitId = workbook.getUnitId();
|
|
315
|
+
if (rangeid && this.navigateToDefineName(unitId, rangeid), !!gid) {
|
|
316
|
+
if (range) {
|
|
317
|
+
const rangeInfo = deserializeRangeWithSheet(range);
|
|
318
|
+
isValidRange(rangeInfo.range) && range !== ERROR_RANGE && this.navigateToRange(unitId, gid, rangeInfo.range);
|
|
312
319
|
return;
|
|
313
320
|
}
|
|
314
|
-
this.navigateToSheetById(
|
|
321
|
+
this.navigateToSheetById(unitId, gid);
|
|
315
322
|
}
|
|
316
323
|
}
|
|
317
|
-
parseHyperLink(
|
|
318
|
-
var
|
|
319
|
-
if (
|
|
320
|
-
const
|
|
321
|
-
gid: (
|
|
322
|
-
range: (
|
|
323
|
-
rangeid: (
|
|
324
|
-
},
|
|
324
|
+
parseHyperLink(urlStr) {
|
|
325
|
+
var _a14, _b, _c;
|
|
326
|
+
if (urlStr != null && urlStr.startsWith("#")) {
|
|
327
|
+
const search = new URLSearchParams(urlStr.slice(1)), searchObj = {
|
|
328
|
+
gid: (_a14 = search.get("gid")) != null ? _a14 : "",
|
|
329
|
+
range: (_b = search.get("range")) != null ? _b : "",
|
|
330
|
+
rangeid: (_c = search.get("rangeid")) != null ? _c : ""
|
|
331
|
+
}, urlInfo = this._getURLName(searchObj);
|
|
325
332
|
return {
|
|
326
|
-
type: (
|
|
327
|
-
name: (
|
|
328
|
-
url:
|
|
329
|
-
searchObj
|
|
330
|
-
handler: () => {
|
|
331
|
-
this.navigateTo(
|
|
332
|
-
}
|
|
333
|
+
type: (urlInfo == null ? void 0 : urlInfo.type) || "link",
|
|
334
|
+
name: (urlInfo == null ? void 0 : urlInfo.name) || urlStr,
|
|
335
|
+
url: urlStr,
|
|
336
|
+
searchObj,
|
|
337
|
+
handler: /* @__PURE__ */ __name(() => {
|
|
338
|
+
this.navigateTo(searchObj);
|
|
339
|
+
}, "handler")
|
|
333
340
|
};
|
|
334
341
|
} else
|
|
335
342
|
return {
|
|
336
343
|
type: "outer",
|
|
337
|
-
name:
|
|
338
|
-
url:
|
|
339
|
-
handler: () => {
|
|
340
|
-
this.navigateToOtherWebsite(
|
|
341
|
-
}
|
|
344
|
+
name: urlStr,
|
|
345
|
+
url: urlStr,
|
|
346
|
+
handler: /* @__PURE__ */ __name(() => {
|
|
347
|
+
this.navigateToOtherWebsite(urlStr);
|
|
348
|
+
}, "handler")
|
|
342
349
|
};
|
|
343
350
|
}
|
|
344
|
-
async navigateToRange(
|
|
345
|
-
const
|
|
346
|
-
if (
|
|
347
|
-
const
|
|
351
|
+
async navigateToRange(unitId, subUnitId, range) {
|
|
352
|
+
const worksheet = await this.navigateToSheetById(unitId, subUnitId);
|
|
353
|
+
if (worksheet) {
|
|
354
|
+
const realRange = getContainRange(range, worksheet);
|
|
348
355
|
await this._commandService.executeCommand(
|
|
349
|
-
|
|
356
|
+
SetSelectionsOperation.id,
|
|
350
357
|
{
|
|
351
|
-
unitId
|
|
352
|
-
subUnitId
|
|
358
|
+
unitId,
|
|
359
|
+
subUnitId,
|
|
353
360
|
selections: [{
|
|
354
|
-
range:
|
|
361
|
+
range: realRange
|
|
355
362
|
}]
|
|
356
363
|
}
|
|
357
|
-
), await this._commandService.executeCommand(
|
|
358
|
-
range:
|
|
364
|
+
), await this._commandService.executeCommand(ScrollToRangeOperation.id, {
|
|
365
|
+
range: realRange
|
|
359
366
|
});
|
|
360
367
|
}
|
|
361
368
|
}
|
|
362
|
-
async navigateToSheet(
|
|
363
|
-
const
|
|
364
|
-
if (!
|
|
369
|
+
async navigateToSheet(unitId, sheetName) {
|
|
370
|
+
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
371
|
+
if (!workbook)
|
|
365
372
|
return !1;
|
|
366
|
-
const
|
|
367
|
-
if ((
|
|
373
|
+
const worksheet = workbook.getActiveSheet();
|
|
374
|
+
if ((worksheet == null ? void 0 : worksheet.getName()) === sheetName)
|
|
368
375
|
return !0;
|
|
369
|
-
const
|
|
370
|
-
if (!
|
|
376
|
+
const targetSheet = workbook.getSheetBySheetName(sheetName);
|
|
377
|
+
if (!targetSheet) {
|
|
371
378
|
this._messageService.show({
|
|
372
379
|
content: this._localeService.t("hyperLink.message.noSheet"),
|
|
373
|
-
type:
|
|
380
|
+
type: MessageType.Error
|
|
374
381
|
});
|
|
375
382
|
return;
|
|
376
383
|
}
|
|
377
|
-
const
|
|
378
|
-
return
|
|
384
|
+
const sheetId = targetSheet.getSheetId();
|
|
385
|
+
return workbook.getHiddenWorksheets().indexOf(sheetId) > -1 && this._messageService.show({
|
|
379
386
|
content: this._localeService.t("hyperLink.message.hiddenSheet"),
|
|
380
|
-
type:
|
|
381
|
-
}), await this._commandService.executeCommand(
|
|
387
|
+
type: MessageType.Error
|
|
388
|
+
}), await this._commandService.executeCommand(SetWorksheetActiveOperation.id, { unitId, subUnitId: sheetId });
|
|
382
389
|
}
|
|
383
|
-
async navigateToSheetById(
|
|
384
|
-
const
|
|
385
|
-
if (!
|
|
390
|
+
async navigateToSheetById(unitId, subUnitId) {
|
|
391
|
+
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
392
|
+
if (!workbook)
|
|
386
393
|
return !1;
|
|
387
|
-
const
|
|
388
|
-
if (!
|
|
394
|
+
const worksheet = workbook.getActiveSheet();
|
|
395
|
+
if (!worksheet)
|
|
389
396
|
return !1;
|
|
390
|
-
if (
|
|
391
|
-
return
|
|
392
|
-
const
|
|
393
|
-
return
|
|
397
|
+
if (worksheet.getSheetId() === subUnitId)
|
|
398
|
+
return worksheet;
|
|
399
|
+
const targetSheet = workbook.getSheetBySheetId(subUnitId);
|
|
400
|
+
return targetSheet ? workbook.getHiddenWorksheets().indexOf(subUnitId) > -1 ? (this._messageService.show({
|
|
394
401
|
content: this._localeService.t("hyperLink.message.hiddenSheet"),
|
|
395
|
-
type:
|
|
396
|
-
}), !1) : await this._commandService.executeCommand(
|
|
402
|
+
type: MessageType.Error
|
|
403
|
+
}), !1) : await this._commandService.executeCommand(SetWorksheetActiveOperation.id, { unitId, subUnitId }) ? targetSheet : !1 : (this._messageService.show({
|
|
397
404
|
content: this._localeService.t("hyperLink.message.noSheet"),
|
|
398
|
-
type:
|
|
405
|
+
type: MessageType.Error
|
|
399
406
|
}), !1);
|
|
400
407
|
}
|
|
401
|
-
async navigateToDefineName(
|
|
402
|
-
return this._definedNamesService.focusRange(
|
|
408
|
+
async navigateToDefineName(unitId, rangeid) {
|
|
409
|
+
return this._definedNamesService.focusRange(unitId, rangeid), !0;
|
|
403
410
|
}
|
|
404
|
-
async navigateToOtherWebsite(
|
|
405
|
-
window.open(
|
|
411
|
+
async navigateToOtherWebsite(url) {
|
|
412
|
+
window.open(url, "_blank", "noopener noreferrer");
|
|
406
413
|
}
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
],
|
|
415
|
-
function
|
|
416
|
-
return
|
|
414
|
+
}, __name(_a4, "SheetsHyperLinkResolverService"), _a4);
|
|
415
|
+
SheetsHyperLinkResolverService = __decorateClass$9([
|
|
416
|
+
__decorateParam$9(0, IUniverInstanceService),
|
|
417
|
+
__decorateParam$9(1, ICommandService),
|
|
418
|
+
__decorateParam$9(2, IDefinedNamesService),
|
|
419
|
+
__decorateParam$9(3, IMessageService),
|
|
420
|
+
__decorateParam$9(4, Inject(LocaleService))
|
|
421
|
+
], SheetsHyperLinkResolverService);
|
|
422
|
+
function isLegalLink(link) {
|
|
423
|
+
return Tools.isLegalUrl(link);
|
|
417
424
|
}
|
|
418
|
-
|
|
419
|
-
|
|
425
|
+
__name(isLegalLink, "isLegalLink");
|
|
426
|
+
function hasProtocol(urlString) {
|
|
427
|
+
return /^[a-zA-Z]+:\/\//.test(urlString);
|
|
420
428
|
}
|
|
421
|
-
|
|
422
|
-
|
|
429
|
+
__name(hasProtocol, "hasProtocol");
|
|
430
|
+
function isEmail(url) {
|
|
431
|
+
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
|
|
423
432
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
433
|
+
__name(isEmail, "isEmail");
|
|
434
|
+
function serializeUrl(urlStr) {
|
|
435
|
+
if (isLegalLink(urlStr)) {
|
|
436
|
+
const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`, url = new URL(transformedUrl);
|
|
437
|
+
return url.hostname === location.hostname && url.port === location.port && url.protocol === location.protocol && url.pathname === location.pathname && url.hash && !url.search ? url.hash : transformedUrl;
|
|
428
438
|
}
|
|
429
|
-
return
|
|
439
|
+
return urlStr;
|
|
430
440
|
}
|
|
431
|
-
|
|
432
|
-
|
|
441
|
+
__name(serializeUrl, "serializeUrl");
|
|
442
|
+
function getCellValueOrigin(cell) {
|
|
443
|
+
if (cell === null)
|
|
433
444
|
return "";
|
|
434
|
-
if (
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
445
|
+
if (cell != null && cell.p) {
|
|
446
|
+
const body = cell == null ? void 0 : cell.p.body;
|
|
447
|
+
if (body == null)
|
|
437
448
|
return "";
|
|
438
|
-
const
|
|
439
|
-
return
|
|
449
|
+
const data = body.dataStream;
|
|
450
|
+
return data.substring(data.length - 2, data.length) === DEFAULT_EMPTY_DOCUMENT_VALUE ? data.substring(0, data.length - 2) : data;
|
|
440
451
|
}
|
|
441
|
-
return
|
|
452
|
+
return cell == null ? void 0 : cell.v;
|
|
442
453
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
454
|
+
__name(getCellValueOrigin, "getCellValueOrigin");
|
|
455
|
+
const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
456
|
+
cellLinkEditButtons
|
|
457
|
+
}, CellLinkEdit = /* @__PURE__ */ __name(() => {
|
|
458
|
+
var _a14;
|
|
459
|
+
const [id, setId] = useState(""), [display, setDisplay] = useState(""), [type, setType] = useState(
|
|
448
460
|
"link"
|
|
449
461
|
/* link */
|
|
450
|
-
), [
|
|
451
|
-
|
|
452
|
-
var
|
|
453
|
-
if ((
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
|
|
462
|
+
), [payload, setPayload] = useState(""), localeService = useDependency(LocaleService), definedNameService = useDependency(IDefinedNamesService), univerInstanceService = useDependency(IUniverInstanceService), popupService = useDependency(SheetsHyperLinkPopupService), editing = useObservable(popupService.currentEditing$), hyperLinkModel = useDependency(HyperLinkModel), resolverService = useDependency(SheetsHyperLinkResolverService), commandService = useDependency(ICommandService), [showError, setShowError] = useState(!1), setByPayload = useRef(!1);
|
|
463
|
+
useEffect(() => {
|
|
464
|
+
var _a15, _b, _c;
|
|
465
|
+
if ((editing == null ? void 0 : editing.row) !== void 0 && editing.column !== void 0) {
|
|
466
|
+
const link = hyperLinkModel.getHyperLinkByLocationSync(editing.unitId, editing.subUnitId, editing.row, editing.column);
|
|
467
|
+
if (link) {
|
|
468
|
+
const linkInfo = resolverService.parseHyperLink(link.payload);
|
|
469
|
+
if (setId(link.id), setDisplay(link.display), linkInfo.type === "outer") {
|
|
470
|
+
setType(
|
|
459
471
|
"link"
|
|
460
472
|
/* link */
|
|
461
|
-
),
|
|
473
|
+
), setPayload(linkInfo.url), linkInfo.url === link.display && (setByPayload.current = !0);
|
|
462
474
|
return;
|
|
463
475
|
} else {
|
|
464
|
-
const
|
|
465
|
-
if (
|
|
466
|
-
|
|
476
|
+
const params = linkInfo.searchObj;
|
|
477
|
+
if (params.rangeid) {
|
|
478
|
+
setType(
|
|
467
479
|
"rangeid"
|
|
468
480
|
/* definedName */
|
|
469
|
-
),
|
|
481
|
+
), setPayload(params.rangeid);
|
|
470
482
|
return;
|
|
471
483
|
}
|
|
472
|
-
if (
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
484
|
+
if (params.range) {
|
|
485
|
+
const sheetName = params.gid && (_c = (_b = (_a15 = univerInstanceService.getUnit(editing.unitId)) == null ? void 0 : _a15.getSheetBySheetId(params.gid)) == null ? void 0 : _b.getName()) != null ? _c : "";
|
|
486
|
+
if (setType(
|
|
475
487
|
"range"
|
|
476
488
|
/* range */
|
|
477
|
-
),
|
|
478
|
-
|
|
489
|
+
), params.range === ERROR_RANGE)
|
|
490
|
+
setPayload("");
|
|
479
491
|
else {
|
|
480
|
-
const
|
|
481
|
-
|
|
492
|
+
const payload2 = serializeRangeWithSheet(sheetName, deserializeRangeWithSheet(params.range).range);
|
|
493
|
+
setPayload(payload2), payload2 === link.display && (setByPayload.current = !0);
|
|
482
494
|
}
|
|
483
495
|
return;
|
|
484
496
|
}
|
|
485
|
-
if (
|
|
486
|
-
|
|
497
|
+
if (params.gid) {
|
|
498
|
+
setType(
|
|
487
499
|
"gid"
|
|
488
500
|
/* sheet */
|
|
489
|
-
),
|
|
501
|
+
), setPayload(params.gid);
|
|
490
502
|
return;
|
|
491
503
|
}
|
|
492
504
|
}
|
|
493
505
|
}
|
|
494
|
-
const
|
|
495
|
-
|
|
506
|
+
const workbook2 = univerInstanceService.getUnit(editing.unitId), worksheet = workbook2 == null ? void 0 : workbook2.getSheetBySheetId(editing.subUnitId), cell = worksheet == null ? void 0 : worksheet.getCellRaw(editing.row, editing.column), cellValue = getCellValueOrigin(cell);
|
|
507
|
+
setType(
|
|
496
508
|
"link"
|
|
497
509
|
/* link */
|
|
498
|
-
),
|
|
510
|
+
), setPayload(""), setDisplay((cellValue != null ? cellValue : "").toString()), setId("");
|
|
499
511
|
return;
|
|
500
512
|
}
|
|
501
|
-
|
|
513
|
+
setType(
|
|
502
514
|
"link"
|
|
503
515
|
/* link */
|
|
504
|
-
),
|
|
505
|
-
}, [
|
|
506
|
-
const
|
|
516
|
+
), setPayload(""), setDisplay(""), setId("");
|
|
517
|
+
}, [editing, hyperLinkModel, resolverService, univerInstanceService]);
|
|
518
|
+
const payloadInitial = useMemo(() => payload, [type]), linkTypeOptions = [
|
|
507
519
|
{
|
|
508
|
-
label:
|
|
520
|
+
label: localeService.t("hyperLink.form.link"),
|
|
509
521
|
value: "link"
|
|
510
522
|
/* link */
|
|
511
523
|
},
|
|
512
524
|
{
|
|
513
|
-
label:
|
|
525
|
+
label: localeService.t("hyperLink.form.range"),
|
|
514
526
|
value: "range"
|
|
515
527
|
/* range */
|
|
516
528
|
},
|
|
517
529
|
{
|
|
518
|
-
label:
|
|
530
|
+
label: localeService.t("hyperLink.form.worksheet"),
|
|
519
531
|
value: "gid"
|
|
520
532
|
/* sheet */
|
|
521
533
|
},
|
|
522
534
|
{
|
|
523
|
-
label:
|
|
535
|
+
label: localeService.t("hyperLink.form.definedName"),
|
|
524
536
|
value: "rangeid"
|
|
525
537
|
/* definedName */
|
|
526
538
|
}
|
|
527
|
-
],
|
|
528
|
-
if (!
|
|
539
|
+
], workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
540
|
+
if (!workbook)
|
|
529
541
|
return;
|
|
530
|
-
const
|
|
531
|
-
label:
|
|
532
|
-
value:
|
|
533
|
-
})),
|
|
534
|
-
if (
|
|
535
|
-
return
|
|
536
|
-
if (
|
|
537
|
-
const
|
|
538
|
-
if (
|
|
539
|
-
return `#gid=${
|
|
542
|
+
const hiddens = workbook.getHiddenWorksheets(), sheetsOption = workbook.getSheets().map((sheet) => ({ label: sheet.getName(), value: sheet.getSheetId() })).filter((opt) => hiddens.indexOf(opt.value) === -1), definedNames = Object.values((_a14 = definedNameService.getDefinedNameMap(workbook.getUnitId())) != null ? _a14 : {}).map((value) => ({
|
|
543
|
+
label: value.name,
|
|
544
|
+
value: value.id
|
|
545
|
+
})), formatUrl = /* @__PURE__ */ __name((type2, payload2) => {
|
|
546
|
+
if (type2 === "link")
|
|
547
|
+
return serializeUrl(payload2);
|
|
548
|
+
if (type2 === "range") {
|
|
549
|
+
const info = deserializeRangeWithSheet(payload2), worksheet = workbook.getSheetBySheetName(info.sheetName);
|
|
550
|
+
if (worksheet)
|
|
551
|
+
return `#gid=${worksheet.getSheetId()}&range=${serializeRange(info.range)}`;
|
|
540
552
|
}
|
|
541
|
-
return `#${
|
|
542
|
-
},
|
|
543
|
-
var
|
|
544
|
-
const
|
|
545
|
-
if (!
|
|
553
|
+
return `#${type2}=${payload2}`;
|
|
554
|
+
}, "formatUrl"), handleRangeChange = useEvent((newValue) => {
|
|
555
|
+
var _a15;
|
|
556
|
+
const range = newValue[0];
|
|
557
|
+
if (!range || !isValidRange(range.range))
|
|
546
558
|
return;
|
|
547
|
-
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
}),
|
|
551
|
-
if (
|
|
552
|
-
unitId:
|
|
553
|
-
subUnitId:
|
|
554
|
-
id
|
|
559
|
+
range.sheetName || (range.sheetName = ((_a15 = workbook.getActiveSheet()) == null ? void 0 : _a15.getName()) || "");
|
|
560
|
+
const newPayload = serializeRangeToRefString(range);
|
|
561
|
+
setPayload(newPayload), newPayload && (setByPayload.current || !display) && (setDisplay(newPayload), setByPayload.current = !0);
|
|
562
|
+
}), handleSubmit = /* @__PURE__ */ __name(async () => {
|
|
563
|
+
if (editing && (id ? await commandService.executeCommand(UpdateHyperLinkCommand.id, {
|
|
564
|
+
unitId: editing.unitId,
|
|
565
|
+
subUnitId: editing.subUnitId,
|
|
566
|
+
id,
|
|
555
567
|
payload: {
|
|
556
|
-
display
|
|
557
|
-
payload:
|
|
568
|
+
display,
|
|
569
|
+
payload: formatUrl(type, payload)
|
|
558
570
|
}
|
|
559
|
-
}) : await
|
|
560
|
-
unitId:
|
|
561
|
-
subUnitId:
|
|
571
|
+
}) : await commandService.executeCommand(AddHyperLinkCommand.id, {
|
|
572
|
+
unitId: editing.unitId,
|
|
573
|
+
subUnitId: editing.subUnitId,
|
|
562
574
|
link: {
|
|
563
|
-
id:
|
|
564
|
-
row:
|
|
565
|
-
column:
|
|
566
|
-
payload:
|
|
567
|
-
display
|
|
575
|
+
id: Tools.generateRandomId(),
|
|
576
|
+
row: editing.row,
|
|
577
|
+
column: editing.column,
|
|
578
|
+
payload: formatUrl(type, payload),
|
|
579
|
+
display
|
|
568
580
|
}
|
|
569
|
-
})),
|
|
570
|
-
await
|
|
571
|
-
unitId:
|
|
572
|
-
subUnitId:
|
|
581
|
+
})), editing) {
|
|
582
|
+
await commandService.executeCommand(SetWorksheetActiveOperation.id, {
|
|
583
|
+
unitId: editing.unitId,
|
|
584
|
+
subUnitId: editing.subUnitId
|
|
573
585
|
});
|
|
574
|
-
const
|
|
575
|
-
await
|
|
586
|
+
const GAP = 1;
|
|
587
|
+
await commandService.executeCommand(ScrollToRangeOperation.id, {
|
|
576
588
|
range: {
|
|
577
|
-
startRow: Math.max(
|
|
578
|
-
endRow:
|
|
579
|
-
startColumn: Math.max(
|
|
580
|
-
endColumn:
|
|
589
|
+
startRow: Math.max(editing.row - GAP, 0),
|
|
590
|
+
endRow: editing.row + GAP,
|
|
591
|
+
startColumn: Math.max(editing.column - GAP, 0),
|
|
592
|
+
endColumn: editing.column + GAP
|
|
581
593
|
}
|
|
582
594
|
});
|
|
583
595
|
}
|
|
584
|
-
|
|
585
|
-
};
|
|
586
|
-
return /* @__PURE__ */
|
|
587
|
-
/* @__PURE__ */
|
|
588
|
-
|
|
596
|
+
commandService.executeCommand(CloseHyperLinkSidebarOperation.id);
|
|
597
|
+
}, "handleSubmit");
|
|
598
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
599
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
600
|
+
FormLayout,
|
|
589
601
|
{
|
|
590
|
-
label:
|
|
591
|
-
error:
|
|
592
|
-
children: /* @__PURE__ */
|
|
593
|
-
|
|
602
|
+
label: localeService.t("hyperLink.form.label"),
|
|
603
|
+
error: showError && !display ? localeService.t("hyperLink.form.inputError") : "",
|
|
604
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
605
|
+
Input,
|
|
594
606
|
{
|
|
595
|
-
value:
|
|
596
|
-
onChange: (
|
|
597
|
-
|
|
598
|
-
},
|
|
599
|
-
placeholder:
|
|
607
|
+
value: display,
|
|
608
|
+
onChange: /* @__PURE__ */ __name((v) => {
|
|
609
|
+
setDisplay(v), setByPayload.current = !1;
|
|
610
|
+
}, "onChange"),
|
|
611
|
+
placeholder: localeService.t("hyperLink.form.labelPlaceholder")
|
|
600
612
|
}
|
|
601
613
|
)
|
|
602
614
|
}
|
|
603
615
|
),
|
|
604
|
-
/* @__PURE__ */
|
|
605
|
-
|
|
616
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("hyperLink.form.type"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
617
|
+
Select,
|
|
606
618
|
{
|
|
607
|
-
options:
|
|
608
|
-
value:
|
|
609
|
-
onChange: (
|
|
610
|
-
|
|
611
|
-
}
|
|
619
|
+
options: linkTypeOptions,
|
|
620
|
+
value: type,
|
|
621
|
+
onChange: /* @__PURE__ */ __name((newType) => {
|
|
622
|
+
setType(newType), setPayload("");
|
|
623
|
+
}, "onChange")
|
|
612
624
|
}
|
|
613
625
|
) }),
|
|
614
|
-
|
|
615
|
-
|
|
626
|
+
type === "link" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
627
|
+
FormLayout,
|
|
616
628
|
{
|
|
617
|
-
error:
|
|
618
|
-
children: /* @__PURE__ */
|
|
619
|
-
|
|
629
|
+
error: showError ? payload ? isLegalLink(payload) ? "" : localeService.t("hyperLink.form.linkError") : localeService.t("hyperLink.form.inputError") : "",
|
|
630
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
631
|
+
Input,
|
|
620
632
|
{
|
|
621
|
-
value:
|
|
622
|
-
onChange: (
|
|
623
|
-
|
|
624
|
-
},
|
|
625
|
-
placeholder:
|
|
633
|
+
value: payload,
|
|
634
|
+
onChange: /* @__PURE__ */ __name((newLink) => {
|
|
635
|
+
setPayload(newLink), newLink && (setByPayload.current || !display || display === payload) && (setDisplay(newLink), setByPayload.current = !0);
|
|
636
|
+
}, "onChange"),
|
|
637
|
+
placeholder: localeService.t("hyperLink.form.linkPlaceholder")
|
|
626
638
|
}
|
|
627
639
|
)
|
|
628
640
|
}
|
|
629
641
|
),
|
|
630
|
-
|
|
631
|
-
|
|
642
|
+
type === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
643
|
+
RangeSelector,
|
|
632
644
|
{
|
|
633
|
-
openForSheetUnitId:
|
|
634
|
-
id:
|
|
645
|
+
openForSheetUnitId: workbook.getUnitId(),
|
|
646
|
+
id: createInternalEditorID("hyper-link-edit"),
|
|
635
647
|
isSingleChoice: !0,
|
|
636
|
-
value:
|
|
637
|
-
onChange:
|
|
648
|
+
value: payloadInitial,
|
|
649
|
+
onChange: handleRangeChange
|
|
638
650
|
}
|
|
639
651
|
) }),
|
|
640
|
-
|
|
641
|
-
|
|
652
|
+
type === "gid" && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
653
|
+
Select,
|
|
642
654
|
{
|
|
643
|
-
options:
|
|
644
|
-
value:
|
|
645
|
-
onChange: (
|
|
646
|
-
var
|
|
647
|
-
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
}
|
|
655
|
+
options: sheetsOption,
|
|
656
|
+
value: payload,
|
|
657
|
+
onChange: /* @__PURE__ */ __name((newPayload) => {
|
|
658
|
+
var _a15, _b;
|
|
659
|
+
setPayload(newPayload);
|
|
660
|
+
const label = (_a15 = sheetsOption.find((i) => i.value === newPayload)) == null ? void 0 : _a15.label, oldLabel = (_b = sheetsOption.find((i) => i.value === payload)) == null ? void 0 : _b.label;
|
|
661
|
+
label && (setByPayload.current || !display || display === oldLabel) && (setDisplay(label), setByPayload.current = !0);
|
|
662
|
+
}, "onChange")
|
|
651
663
|
}
|
|
652
664
|
) }),
|
|
653
|
-
|
|
654
|
-
|
|
665
|
+
type === "rangeid" && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
666
|
+
Select,
|
|
655
667
|
{
|
|
656
|
-
options:
|
|
657
|
-
value:
|
|
658
|
-
onChange: (
|
|
659
|
-
var
|
|
660
|
-
|
|
661
|
-
const
|
|
662
|
-
|
|
663
|
-
}
|
|
668
|
+
options: definedNames,
|
|
669
|
+
value: payload,
|
|
670
|
+
onChange: /* @__PURE__ */ __name((newValue) => {
|
|
671
|
+
var _a15, _b;
|
|
672
|
+
setPayload(newValue);
|
|
673
|
+
const label = (_a15 = definedNames.find((i) => i.value === newValue)) == null ? void 0 : _a15.label, oldLabel = (_b = definedNames.find((i) => i.value === payload)) == null ? void 0 : _b.label;
|
|
674
|
+
label && (setByPayload.current || !display || display === oldLabel) && (setDisplay(label), setByPayload.current = !0);
|
|
675
|
+
}, "onChange")
|
|
664
676
|
}
|
|
665
677
|
) }),
|
|
666
|
-
/* @__PURE__ */
|
|
667
|
-
/* @__PURE__ */
|
|
668
|
-
|
|
678
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkEditButtons, children: [
|
|
679
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
680
|
+
Button,
|
|
669
681
|
{
|
|
670
|
-
onClick: () => {
|
|
671
|
-
|
|
672
|
-
unitId:
|
|
673
|
-
subUnitId:
|
|
674
|
-
}),
|
|
675
|
-
},
|
|
676
|
-
children:
|
|
682
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
683
|
+
editing && commandService.executeCommand(SetWorksheetActiveOperation.id, {
|
|
684
|
+
unitId: editing.unitId,
|
|
685
|
+
subUnitId: editing.subUnitId
|
|
686
|
+
}), commandService.executeCommand(CloseHyperLinkSidebarOperation.id);
|
|
687
|
+
}, "onClick"),
|
|
688
|
+
children: localeService.t("hyperLink.form.cancel")
|
|
677
689
|
}
|
|
678
690
|
),
|
|
679
|
-
/* @__PURE__ */
|
|
680
|
-
|
|
691
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
692
|
+
Button,
|
|
681
693
|
{
|
|
682
694
|
type: "primary",
|
|
683
695
|
style: { marginLeft: 8 },
|
|
684
|
-
onClick: async () => {
|
|
685
|
-
if (!
|
|
686
|
-
|
|
696
|
+
onClick: /* @__PURE__ */ __name(async () => {
|
|
697
|
+
if (!display || !payload || type === "link" && !isLegalLink(payload)) {
|
|
698
|
+
setShowError(!0);
|
|
687
699
|
return;
|
|
688
700
|
}
|
|
689
|
-
|
|
690
|
-
},
|
|
691
|
-
children:
|
|
701
|
+
handleSubmit();
|
|
702
|
+
}, "onClick"),
|
|
703
|
+
children: localeService.t("hyperLink.form.ok")
|
|
692
704
|
}
|
|
693
705
|
)
|
|
694
706
|
] })
|
|
695
707
|
] });
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
type:
|
|
708
|
+
}, "CellLinkEdit");
|
|
709
|
+
CellLinkEdit.componentKey = "univer.sheet.cell-link-edit";
|
|
710
|
+
const OpenHyperLinkSidebarOperation = {
|
|
711
|
+
type: CommandType.OPERATION,
|
|
700
712
|
id: "sheet.operation.open-hyper-link-sidebar",
|
|
701
|
-
handler(
|
|
702
|
-
if (!
|
|
713
|
+
handler(accessor, params) {
|
|
714
|
+
if (!params)
|
|
703
715
|
return !1;
|
|
704
|
-
const { unitId
|
|
705
|
-
return
|
|
716
|
+
const { unitId, subUnitId, row, column } = params, hyperLinkModel = accessor.get(HyperLinkModel), sidebarService = accessor.get(ISidebarService), popupService = accessor.get(SheetsHyperLinkPopupService), currentLink = hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
|
|
717
|
+
return popupService.startEditing(params), sidebarService.open({
|
|
706
718
|
header: {
|
|
707
|
-
title:
|
|
719
|
+
title: currentLink ? "hyperLink.form.editTitle" : "hyperLink.form.addTitle"
|
|
708
720
|
},
|
|
709
721
|
children: {
|
|
710
|
-
label:
|
|
722
|
+
label: CellLinkEdit.componentKey
|
|
711
723
|
}
|
|
712
724
|
}), !0;
|
|
713
725
|
}
|
|
714
|
-
},
|
|
715
|
-
type:
|
|
726
|
+
}, CloseHyperLinkSidebarOperation = {
|
|
727
|
+
type: CommandType.OPERATION,
|
|
716
728
|
id: "sheet.operation.close-hyper-link-sidebar",
|
|
717
|
-
handler(
|
|
718
|
-
const
|
|
719
|
-
return
|
|
729
|
+
handler(accessor) {
|
|
730
|
+
const sidebarService = accessor.get(ISidebarService), popupService = accessor.get(SheetsHyperLinkPopupService);
|
|
731
|
+
return sidebarService.close(), popupService.endEditing(), !0;
|
|
720
732
|
}
|
|
721
|
-
},
|
|
722
|
-
type:
|
|
733
|
+
}, InsertHyperLinkOperation = {
|
|
734
|
+
type: CommandType.OPERATION,
|
|
723
735
|
id: "sheet.operation.insert-hyper-link",
|
|
724
|
-
handler(
|
|
725
|
-
const
|
|
726
|
-
if (!
|
|
736
|
+
handler(accessor) {
|
|
737
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
|
|
738
|
+
if (!target)
|
|
727
739
|
return !1;
|
|
728
|
-
const
|
|
729
|
-
if (!
|
|
740
|
+
const commandService = accessor.get(ICommandService), selection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
741
|
+
if (!selection)
|
|
730
742
|
return !1;
|
|
731
|
-
const
|
|
732
|
-
return
|
|
733
|
-
unitId:
|
|
734
|
-
subUnitId:
|
|
735
|
-
row
|
|
736
|
-
column
|
|
743
|
+
const row = selection.primary.startRow, column = selection.primary.startColumn;
|
|
744
|
+
return commandService.executeCommand(OpenHyperLinkSidebarOperation.id, {
|
|
745
|
+
unitId: target.unitId,
|
|
746
|
+
subUnitId: target.subUnitId,
|
|
747
|
+
row,
|
|
748
|
+
column
|
|
737
749
|
});
|
|
738
750
|
}
|
|
739
|
-
},
|
|
740
|
-
type:
|
|
751
|
+
}, InsertHyperLinkToolbarOperation = {
|
|
752
|
+
type: CommandType.OPERATION,
|
|
741
753
|
id: "sheet.operation.insert-hyper-link-toolbar",
|
|
742
|
-
handler(
|
|
743
|
-
const
|
|
744
|
-
return
|
|
754
|
+
handler(accessor) {
|
|
755
|
+
const commandService = accessor.get(ICommandService);
|
|
756
|
+
return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkSidebarOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
|
|
745
757
|
}
|
|
746
|
-
},
|
|
747
|
-
cellLink
|
|
748
|
-
cellLinkType
|
|
749
|
-
cellLinkContent
|
|
750
|
-
cellLinkContentError
|
|
751
|
-
cellLinkUrl
|
|
752
|
-
cellLinkOperations
|
|
753
|
-
cellLinkOperation
|
|
754
|
-
cellLinkOperationError
|
|
755
|
-
},
|
|
756
|
-
outer: /* @__PURE__ */
|
|
757
|
-
link: /* @__PURE__ */
|
|
758
|
-
sheet: /* @__PURE__ */
|
|
759
|
-
range: /* @__PURE__ */
|
|
760
|
-
defineName: /* @__PURE__ */
|
|
761
|
-
"range-error": /* @__PURE__ */
|
|
762
|
-
"sheet-error": /* @__PURE__ */
|
|
763
|
-
},
|
|
764
|
-
const
|
|
765
|
-
if (
|
|
766
|
-
|
|
767
|
-
const
|
|
768
|
-
|
|
758
|
+
}, cellLink = "univer-cell-link", cellLinkType = "univer-cell-link-type", cellLinkContent = "univer-cell-link-content", cellLinkContentError = "univer-cell-link-content-error", cellLinkUrl = "univer-cell-link-url", cellLinkOperations = "univer-cell-link-operations", cellLinkOperation = "univer-cell-link-operation", cellLinkOperationError = "univer-cell-link-operation-error", styles = {
|
|
759
|
+
cellLink,
|
|
760
|
+
cellLinkType,
|
|
761
|
+
cellLinkContent,
|
|
762
|
+
cellLinkContentError,
|
|
763
|
+
cellLinkUrl,
|
|
764
|
+
cellLinkOperations,
|
|
765
|
+
cellLinkOperation,
|
|
766
|
+
cellLinkOperationError
|
|
767
|
+
}, iconsMap = {
|
|
768
|
+
outer: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkSingle, {}),
|
|
769
|
+
link: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkSingle, {}),
|
|
770
|
+
sheet: /* @__PURE__ */ jsxRuntimeExports.jsx(Xlsx, {}),
|
|
771
|
+
range: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
|
|
772
|
+
defineName: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
|
|
773
|
+
"range-error": /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
|
|
774
|
+
"sheet-error": /* @__PURE__ */ jsxRuntimeExports.jsx(Xlsx, {})
|
|
775
|
+
}, CellLinkPopup = /* @__PURE__ */ __name(() => {
|
|
776
|
+
const popupService = useDependency(SheetsHyperLinkPopupService), hyperLinkModel = useDependency(HyperLinkModel), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), [currentPopup, setCurrentPopup] = useState(null), resolverService = useDependency(SheetsHyperLinkResolverService);
|
|
777
|
+
if (useEffect(() => {
|
|
778
|
+
setCurrentPopup(popupService.currentPopup);
|
|
779
|
+
const ob = popupService.currentPopup$.subscribe((popup) => {
|
|
780
|
+
setCurrentPopup(popup);
|
|
769
781
|
});
|
|
770
782
|
return () => {
|
|
771
|
-
|
|
783
|
+
ob.unsubscribe();
|
|
772
784
|
};
|
|
773
|
-
}, [
|
|
785
|
+
}, [popupService.currentPopup, popupService.currentPopup$]), !currentPopup)
|
|
774
786
|
return null;
|
|
775
|
-
const { unitId
|
|
776
|
-
if (!
|
|
787
|
+
const { unitId, subUnitId, id } = currentPopup, link = hyperLinkModel.getHyperLink(unitId, subUnitId, id);
|
|
788
|
+
if (!link)
|
|
777
789
|
return null;
|
|
778
|
-
const
|
|
779
|
-
return /* @__PURE__ */
|
|
780
|
-
/* @__PURE__ */
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
/* @__PURE__ */
|
|
790
|
+
const linkObj = resolverService.parseHyperLink(link.payload), isError = linkObj.type.indexOf("error") > -1;
|
|
791
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLink, onClick: /* @__PURE__ */ __name(() => popupService.hideCurrentPopup(), "onClick"), children: [
|
|
792
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cs(styles.cellLinkContent, { [styles.cellLinkContentError]: isError }), onClick: linkObj.handler, children: [
|
|
793
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.cellLinkType, children: iconsMap[linkObj.type] }),
|
|
794
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { showIfEllipsis: !0, title: linkObj.name, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles.cellLinkUrl, children: linkObj.name }) })
|
|
783
795
|
] }),
|
|
784
|
-
/* @__PURE__ */
|
|
785
|
-
|
|
796
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLinkOperations, children: [
|
|
797
|
+
currentPopup.copyPermission && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
786
798
|
"div",
|
|
787
799
|
{
|
|
788
|
-
className:
|
|
789
|
-
onClick: () => {
|
|
790
|
-
if (!
|
|
791
|
-
if (
|
|
792
|
-
const
|
|
793
|
-
|
|
800
|
+
className: cs(styles.cellLinkOperation, { [styles.cellLinkOperationError]: isError }),
|
|
801
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
802
|
+
if (!isError) {
|
|
803
|
+
if (linkObj.type !== "outer") {
|
|
804
|
+
const url = new URL(window.location.href);
|
|
805
|
+
url.hash = linkObj.url.slice(1), navigator.clipboard.writeText(url.href);
|
|
794
806
|
} else
|
|
795
|
-
navigator.clipboard.writeText(
|
|
796
|
-
|
|
797
|
-
content:
|
|
798
|
-
type:
|
|
807
|
+
navigator.clipboard.writeText(linkObj.url);
|
|
808
|
+
messageService.show({
|
|
809
|
+
content: localeService.t("hyperLink.message.coped"),
|
|
810
|
+
type: MessageType.Info
|
|
799
811
|
});
|
|
800
812
|
}
|
|
801
|
-
},
|
|
802
|
-
children: /* @__PURE__ */
|
|
813
|
+
}, "onClick"),
|
|
814
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.copy"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopySingle, {}) })
|
|
803
815
|
}
|
|
804
816
|
),
|
|
805
|
-
|
|
806
|
-
/* @__PURE__ */
|
|
817
|
+
currentPopup.editPermission && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
818
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
807
819
|
"div",
|
|
808
820
|
{
|
|
809
|
-
className:
|
|
810
|
-
onClick: () => {
|
|
811
|
-
|
|
812
|
-
unitId
|
|
813
|
-
subUnitId
|
|
814
|
-
row:
|
|
815
|
-
column:
|
|
821
|
+
className: styles.cellLinkOperation,
|
|
822
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
823
|
+
commandService.executeCommand(OpenHyperLinkSidebarOperation.id, {
|
|
824
|
+
unitId,
|
|
825
|
+
subUnitId,
|
|
826
|
+
row: link.row,
|
|
827
|
+
column: link.column
|
|
816
828
|
});
|
|
817
|
-
},
|
|
818
|
-
children: /* @__PURE__ */
|
|
829
|
+
}, "onClick"),
|
|
830
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.edit"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(WriteSingle, {}) })
|
|
819
831
|
}
|
|
820
832
|
),
|
|
821
|
-
/* @__PURE__ */
|
|
833
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
822
834
|
"div",
|
|
823
835
|
{
|
|
824
|
-
className:
|
|
825
|
-
onClick: () => {
|
|
826
|
-
|
|
827
|
-
unitId
|
|
828
|
-
subUnitId
|
|
829
|
-
id:
|
|
836
|
+
className: styles.cellLinkOperation,
|
|
837
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
838
|
+
commandService.executeCommand(CancelHyperLinkCommand.id, {
|
|
839
|
+
unitId,
|
|
840
|
+
subUnitId,
|
|
841
|
+
id: link.id
|
|
830
842
|
});
|
|
831
|
-
},
|
|
832
|
-
children: /* @__PURE__ */
|
|
843
|
+
}, "onClick"),
|
|
844
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(UnlinkSingle, {}) })
|
|
833
845
|
}
|
|
834
846
|
)
|
|
835
847
|
] })
|
|
836
848
|
] })
|
|
837
849
|
] });
|
|
838
|
-
};
|
|
839
|
-
|
|
840
|
-
var
|
|
841
|
-
for (var
|
|
842
|
-
(
|
|
843
|
-
return
|
|
844
|
-
},
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
-
|
|
850
|
+
}, "CellLinkPopup");
|
|
851
|
+
CellLinkPopup.componentKey = "univer.sheet.cell-link-popup";
|
|
852
|
+
var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
853
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
854
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
855
|
+
return kind && result && __defProp$8(target, key, result), result;
|
|
856
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8");
|
|
857
|
+
const isEqualLink = /* @__PURE__ */ __name((a, b) => a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.row === b.row && a.col === b.col, "isEqualLink");
|
|
858
|
+
var _a5;
|
|
859
|
+
let SheetsHyperLinkPopupService = (_a5 = class extends Disposable {
|
|
860
|
+
constructor(_hyperLinkModel, _sheetCanvasPopManagerService) {
|
|
848
861
|
super();
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
this._hyperLinkModel =
|
|
862
|
+
__publicField(this, "_currentPopup", null);
|
|
863
|
+
__publicField(this, "_currentPopup$", new Subject());
|
|
864
|
+
__publicField(this, "currentPopup$", this._currentPopup$.asObservable());
|
|
865
|
+
__publicField(this, "_currentEditing$", new BehaviorSubject(null));
|
|
866
|
+
__publicField(this, "currentEditing$", this._currentEditing$.asObservable());
|
|
867
|
+
this._hyperLinkModel = _hyperLinkModel, this._sheetCanvasPopManagerService = _sheetCanvasPopManagerService, this.disposeWithMe(() => {
|
|
855
868
|
this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete();
|
|
856
869
|
});
|
|
857
870
|
}
|
|
@@ -861,78 +874,78 @@ let $ = class extends O {
|
|
|
861
874
|
get currentEditing() {
|
|
862
875
|
return this._currentEditing$.getValue();
|
|
863
876
|
}
|
|
864
|
-
showPopup(
|
|
865
|
-
if (this._currentPopup &&
|
|
877
|
+
showPopup(location2) {
|
|
878
|
+
if (this._currentPopup && isEqualLink(location2, this._currentPopup))
|
|
866
879
|
return;
|
|
867
880
|
this.hideCurrentPopup();
|
|
868
|
-
const { unitId
|
|
869
|
-
if (!
|
|
881
|
+
const { unitId, subUnitId, row, col } = location2, link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
882
|
+
if (!link)
|
|
870
883
|
return;
|
|
871
|
-
const
|
|
872
|
-
componentKey:
|
|
884
|
+
const disposable = this._sheetCanvasPopManagerService.attachPopupToCell(row, col, {
|
|
885
|
+
componentKey: CellLinkPopup.componentKey,
|
|
873
886
|
direction: "bottom",
|
|
874
887
|
closeOnSelfTarget: !0,
|
|
875
|
-
onClickOutside: () => {
|
|
888
|
+
onClickOutside: /* @__PURE__ */ __name(() => {
|
|
876
889
|
this.hideCurrentPopup();
|
|
877
|
-
}
|
|
890
|
+
}, "onClickOutside")
|
|
878
891
|
});
|
|
879
|
-
|
|
880
|
-
unitId
|
|
881
|
-
subUnitId
|
|
882
|
-
id:
|
|
883
|
-
disposable
|
|
884
|
-
row
|
|
885
|
-
col
|
|
886
|
-
editPermission: !!
|
|
887
|
-
copyPermission: !!
|
|
892
|
+
disposable && (this._currentPopup = {
|
|
893
|
+
unitId,
|
|
894
|
+
subUnitId,
|
|
895
|
+
id: link.id,
|
|
896
|
+
disposable,
|
|
897
|
+
row,
|
|
898
|
+
col,
|
|
899
|
+
editPermission: !!location2.editPermission,
|
|
900
|
+
copyPermission: !!location2.copyPermission
|
|
888
901
|
}, this._currentPopup$.next(this._currentPopup));
|
|
889
902
|
}
|
|
890
903
|
hideCurrentPopup() {
|
|
891
|
-
var
|
|
892
|
-
this._currentPopup && ((
|
|
904
|
+
var _a14;
|
|
905
|
+
this._currentPopup && ((_a14 = this._currentPopup.disposable) == null || _a14.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
|
|
893
906
|
}
|
|
894
|
-
startEditing(
|
|
895
|
-
this._currentEditing$.next(
|
|
907
|
+
startEditing(link) {
|
|
908
|
+
this._currentEditing$.next(link);
|
|
896
909
|
}
|
|
897
910
|
endEditing() {
|
|
898
911
|
this._currentEditing$.next(null);
|
|
899
912
|
}
|
|
900
|
-
};
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
],
|
|
905
|
-
var
|
|
906
|
-
for (var
|
|
907
|
-
(
|
|
908
|
-
return
|
|
909
|
-
},
|
|
910
|
-
let
|
|
911
|
-
constructor(
|
|
912
|
-
super(), this._sheetInterceptorService =
|
|
913
|
+
}, __name(_a5, "SheetsHyperLinkPopupService"), _a5);
|
|
914
|
+
SheetsHyperLinkPopupService = __decorateClass$8([
|
|
915
|
+
__decorateParam$8(0, Inject(HyperLinkModel)),
|
|
916
|
+
__decorateParam$8(1, Inject(SheetCanvasPopManagerService))
|
|
917
|
+
], SheetsHyperLinkPopupService);
|
|
918
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
919
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
920
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
921
|
+
return kind && result && __defProp$7(target, key, result), result;
|
|
922
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a6;
|
|
923
|
+
let SheetHyperLinkSetRangeController = (_a6 = class extends Disposable {
|
|
924
|
+
constructor(_sheetInterceptorService, _injector, _hyperLinkModel, _selectionManagerService, _univerInstanceService, _editorBridgeService) {
|
|
925
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._injector = _injector, this._hyperLinkModel = _hyperLinkModel, this._selectionManagerService = _selectionManagerService, this._univerInstanceService = _univerInstanceService, this._editorBridgeService = _editorBridgeService, this._initCommandInterceptor();
|
|
913
926
|
}
|
|
914
927
|
_initCommandInterceptor() {
|
|
915
928
|
this._initAddHyperLinkCommandInterceptor(), this._initSetRangeValuesCommandInterceptor(), this._initUpdateHyperLinkCommandInterceptor(), this._initClearSelectionCommandInterceptor(), this._initRichTextEditorInterceptor();
|
|
916
929
|
}
|
|
917
|
-
_getCurrentCell(
|
|
918
|
-
var
|
|
919
|
-
return (
|
|
930
|
+
_getCurrentCell(unitId, subUnitId, row, col) {
|
|
931
|
+
var _a14, _b;
|
|
932
|
+
return (_b = (_a14 = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a14.getSheetBySheetId(subUnitId)) == null ? void 0 : _b.getCell(row, col);
|
|
920
933
|
}
|
|
921
934
|
_initAddHyperLinkCommandInterceptor() {
|
|
922
935
|
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
923
|
-
getMutations: (
|
|
924
|
-
var
|
|
925
|
-
if (
|
|
926
|
-
const
|
|
927
|
-
unitId
|
|
928
|
-
subUnitId
|
|
936
|
+
getMutations: /* @__PURE__ */ __name((command) => {
|
|
937
|
+
var _a14;
|
|
938
|
+
if (command.id === AddHyperLinkCommand.id) {
|
|
939
|
+
const params = command.params, { unitId, subUnitId, link } = params, currentCell = this._getCurrentCell(unitId, subUnitId, link.row, link.column), redoParams = {
|
|
940
|
+
unitId,
|
|
941
|
+
subUnitId,
|
|
929
942
|
cellValue: {
|
|
930
|
-
[
|
|
931
|
-
[
|
|
932
|
-
v:
|
|
943
|
+
[link.row]: {
|
|
944
|
+
[link.column]: {
|
|
945
|
+
v: link.display,
|
|
933
946
|
// t: CellValueType.STRING, // Setting a link to a number is still a number
|
|
934
947
|
p: null,
|
|
935
|
-
t: (
|
|
948
|
+
t: (_a14 = currentCell == null ? void 0 : currentCell.t) != null ? _a14 : void 0
|
|
936
949
|
// Keep force string type
|
|
937
950
|
}
|
|
938
951
|
}
|
|
@@ -940,12 +953,12 @@ let Ie = class extends O {
|
|
|
940
953
|
};
|
|
941
954
|
return {
|
|
942
955
|
redos: [{
|
|
943
|
-
id:
|
|
944
|
-
params:
|
|
956
|
+
id: SetRangeValuesMutation.id,
|
|
957
|
+
params: redoParams
|
|
945
958
|
}],
|
|
946
959
|
undos: [{
|
|
947
|
-
id:
|
|
948
|
-
params:
|
|
960
|
+
id: SetRangeValuesMutation.id,
|
|
961
|
+
params: SetRangeValuesUndoMutationFactory(this._injector, redoParams)
|
|
949
962
|
}]
|
|
950
963
|
};
|
|
951
964
|
}
|
|
@@ -953,23 +966,23 @@ let Ie = class extends O {
|
|
|
953
966
|
redos: [],
|
|
954
967
|
undos: []
|
|
955
968
|
};
|
|
956
|
-
}
|
|
969
|
+
}, "getMutations")
|
|
957
970
|
}));
|
|
958
971
|
}
|
|
959
972
|
_initUpdateHyperLinkCommandInterceptor() {
|
|
960
973
|
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
961
|
-
getMutations: (
|
|
962
|
-
if (
|
|
963
|
-
const
|
|
964
|
-
if (
|
|
965
|
-
const
|
|
966
|
-
unitId
|
|
967
|
-
subUnitId
|
|
974
|
+
getMutations: /* @__PURE__ */ __name((command) => {
|
|
975
|
+
if (command.id === UpdateHyperLinkCommand.id) {
|
|
976
|
+
const params = command.params, { unitId, subUnitId, id, payload } = params, current = this._hyperLinkModel.getHyperLink(unitId, subUnitId, id);
|
|
977
|
+
if (current && current.display !== payload.display) {
|
|
978
|
+
const redoParams = {
|
|
979
|
+
unitId,
|
|
980
|
+
subUnitId,
|
|
968
981
|
cellValue: {
|
|
969
|
-
[
|
|
970
|
-
[
|
|
971
|
-
v:
|
|
972
|
-
t:
|
|
982
|
+
[current.row]: {
|
|
983
|
+
[current.column]: {
|
|
984
|
+
v: payload.display,
|
|
985
|
+
t: CellValueType.STRING,
|
|
973
986
|
p: null
|
|
974
987
|
}
|
|
975
988
|
}
|
|
@@ -977,12 +990,12 @@ let Ie = class extends O {
|
|
|
977
990
|
};
|
|
978
991
|
return {
|
|
979
992
|
redos: [{
|
|
980
|
-
id:
|
|
981
|
-
params:
|
|
993
|
+
id: SetRangeValuesMutation.id,
|
|
994
|
+
params: redoParams
|
|
982
995
|
}],
|
|
983
996
|
undos: [{
|
|
984
|
-
id:
|
|
985
|
-
params:
|
|
997
|
+
id: SetRangeValuesMutation.id,
|
|
998
|
+
params: SetRangeValuesUndoMutationFactory(this._injector, redoParams)
|
|
986
999
|
}]
|
|
987
1000
|
};
|
|
988
1001
|
}
|
|
@@ -991,107 +1004,107 @@ let Ie = class extends O {
|
|
|
991
1004
|
redos: [],
|
|
992
1005
|
undos: []
|
|
993
1006
|
};
|
|
994
|
-
}
|
|
1007
|
+
}, "getMutations")
|
|
995
1008
|
}));
|
|
996
1009
|
}
|
|
997
1010
|
_initSetRangeValuesCommandInterceptor() {
|
|
998
1011
|
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
999
|
-
getMutations: (
|
|
1000
|
-
if (
|
|
1001
|
-
const
|
|
1002
|
-
return
|
|
1003
|
-
var
|
|
1004
|
-
const
|
|
1005
|
-
if (!
|
|
1006
|
-
if (
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1009
|
-
id:
|
|
1012
|
+
getMutations: /* @__PURE__ */ __name((command) => {
|
|
1013
|
+
if (command.id === SetRangeValuesCommand.id) {
|
|
1014
|
+
const params = command.params, { unitId, subUnitId } = params, redos = [], undos = [];
|
|
1015
|
+
return params.cellValue && new ObjectMatrix(params.cellValue).forValue((row, col, cell) => {
|
|
1016
|
+
var _a14, _b, _c, _d, _e, _f, _g;
|
|
1017
|
+
const cellValueRaw = (_c = cell == null ? void 0 : cell.v) != null ? _c : (_b = (_a14 = cell == null ? void 0 : cell.p) == null ? void 0 : _a14.body) == null ? void 0 : _b.dataStream.slice(0, -2), cellValue = (cellValueRaw != null ? cellValueRaw : "").toString(), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1018
|
+
if (!link) {
|
|
1019
|
+
if (isLegalLink(cellValue) || (_d = cell == null ? void 0 : cell.custom) != null && _d.__link_url) {
|
|
1020
|
+
const url = (_f = (_e = cell == null ? void 0 : cell.custom) == null ? void 0 : _e.__link_url) != null ? _f : cellValue, id = Tools.generateRandomId();
|
|
1021
|
+
undos.push({
|
|
1022
|
+
id: RemoveHyperLinkMutation.id,
|
|
1010
1023
|
params: {
|
|
1011
|
-
unitId
|
|
1012
|
-
subUnitId
|
|
1013
|
-
id
|
|
1024
|
+
unitId,
|
|
1025
|
+
subUnitId,
|
|
1026
|
+
id
|
|
1014
1027
|
}
|
|
1015
|
-
}),
|
|
1016
|
-
id:
|
|
1028
|
+
}), redos.push({
|
|
1029
|
+
id: AddHyperLinkMutation.id,
|
|
1017
1030
|
params: {
|
|
1018
|
-
unitId
|
|
1019
|
-
subUnitId
|
|
1031
|
+
unitId,
|
|
1032
|
+
subUnitId,
|
|
1020
1033
|
link: {
|
|
1021
|
-
id
|
|
1022
|
-
row
|
|
1023
|
-
column:
|
|
1024
|
-
display:
|
|
1025
|
-
payload:
|
|
1034
|
+
id,
|
|
1035
|
+
row,
|
|
1036
|
+
column: col,
|
|
1037
|
+
display: cellValue,
|
|
1038
|
+
payload: serializeUrl(url)
|
|
1026
1039
|
}
|
|
1027
1040
|
}
|
|
1028
1041
|
});
|
|
1029
1042
|
}
|
|
1030
1043
|
return;
|
|
1031
1044
|
}
|
|
1032
|
-
(
|
|
1033
|
-
id:
|
|
1045
|
+
(cellValueRaw === "" || ((_g = cell == null ? void 0 : cell.custom) == null ? void 0 : _g.__link_url) === "") && (redos.push({
|
|
1046
|
+
id: RemoveHyperLinkMutation.id,
|
|
1034
1047
|
params: {
|
|
1035
|
-
unitId
|
|
1036
|
-
subUnitId
|
|
1037
|
-
id:
|
|
1048
|
+
unitId,
|
|
1049
|
+
subUnitId,
|
|
1050
|
+
id: link.id
|
|
1038
1051
|
}
|
|
1039
|
-
}),
|
|
1040
|
-
id:
|
|
1052
|
+
}), undos.push({
|
|
1053
|
+
id: AddHyperLinkMutation.id,
|
|
1041
1054
|
params: {
|
|
1042
|
-
unitId
|
|
1043
|
-
subUnitId
|
|
1044
|
-
link
|
|
1055
|
+
unitId,
|
|
1056
|
+
subUnitId,
|
|
1057
|
+
link
|
|
1045
1058
|
}
|
|
1046
1059
|
}));
|
|
1047
1060
|
}), {
|
|
1048
|
-
undos
|
|
1049
|
-
redos
|
|
1061
|
+
undos,
|
|
1062
|
+
redos
|
|
1050
1063
|
};
|
|
1051
1064
|
}
|
|
1052
1065
|
return {
|
|
1053
1066
|
redos: [],
|
|
1054
1067
|
undos: []
|
|
1055
1068
|
};
|
|
1056
|
-
}
|
|
1069
|
+
}, "getMutations")
|
|
1057
1070
|
}));
|
|
1058
1071
|
}
|
|
1059
1072
|
_initClearSelectionCommandInterceptor() {
|
|
1060
1073
|
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
1061
|
-
getMutations: (
|
|
1062
|
-
if (
|
|
1063
|
-
const
|
|
1064
|
-
if (
|
|
1065
|
-
const { unitId
|
|
1066
|
-
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1069
|
-
id:
|
|
1074
|
+
getMutations: /* @__PURE__ */ __name((command) => {
|
|
1075
|
+
if (command.id === ClearSelectionContentCommand.id || command.id === ClearSelectionAllCommand.id || command.id === ClearSelectionFormatCommand.id) {
|
|
1076
|
+
const redos = [], undos = [], selection = this._selectionManagerService.getCurrentLastSelection(), target = getSheetCommandTarget(this._univerInstanceService);
|
|
1077
|
+
if (selection && target) {
|
|
1078
|
+
const { unitId, subUnitId } = target;
|
|
1079
|
+
Range.foreach(selection.range, (row, col) => {
|
|
1080
|
+
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1081
|
+
link && (redos.push({
|
|
1082
|
+
id: RemoveHyperLinkMutation.id,
|
|
1070
1083
|
params: {
|
|
1071
|
-
unitId
|
|
1072
|
-
subUnitId
|
|
1073
|
-
id:
|
|
1084
|
+
unitId,
|
|
1085
|
+
subUnitId,
|
|
1086
|
+
id: link.id
|
|
1074
1087
|
}
|
|
1075
|
-
}),
|
|
1076
|
-
id:
|
|
1088
|
+
}), undos.push({
|
|
1089
|
+
id: AddHyperLinkMutation.id,
|
|
1077
1090
|
params: {
|
|
1078
|
-
unitId
|
|
1079
|
-
subUnitId
|
|
1080
|
-
link
|
|
1091
|
+
unitId,
|
|
1092
|
+
subUnitId,
|
|
1093
|
+
link
|
|
1081
1094
|
}
|
|
1082
1095
|
}));
|
|
1083
1096
|
});
|
|
1084
1097
|
}
|
|
1085
1098
|
return {
|
|
1086
|
-
redos
|
|
1087
|
-
undos
|
|
1099
|
+
redos,
|
|
1100
|
+
undos
|
|
1088
1101
|
};
|
|
1089
1102
|
}
|
|
1090
1103
|
return {
|
|
1091
1104
|
redos: [],
|
|
1092
1105
|
undos: []
|
|
1093
1106
|
};
|
|
1094
|
-
}
|
|
1107
|
+
}, "getMutations")
|
|
1095
1108
|
}));
|
|
1096
1109
|
}
|
|
1097
1110
|
_initRichTextEditorInterceptor() {
|
|
@@ -1099,522 +1112,522 @@ let Ie = class extends O {
|
|
|
1099
1112
|
this._editorBridgeService.interceptor.intercept(
|
|
1100
1113
|
this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,
|
|
1101
1114
|
{
|
|
1102
|
-
handler: (
|
|
1103
|
-
var
|
|
1104
|
-
if (
|
|
1105
|
-
const
|
|
1106
|
-
if (
|
|
1107
|
-
const
|
|
1108
|
-
return
|
|
1109
|
-
...
|
|
1115
|
+
handler: /* @__PURE__ */ __name((data, context, next) => {
|
|
1116
|
+
var _a14, _b, _c, _d, _e, _f;
|
|
1117
|
+
if (data != null && data.p) {
|
|
1118
|
+
const range = (_b = (_a14 = data.p.body) == null ? void 0 : _a14.customRanges) == null ? void 0 : _b.find((i) => i.rangeType === CustomRangeType.HYPERLINK), resource = (_c = data.p.resources) == null ? void 0 : _c.find((i) => i.name === DOC_HYPER_LINK_PLUGIN);
|
|
1119
|
+
if (range && resource) {
|
|
1120
|
+
const rangeId = range.rangeId, url = (_f = (_e = (_d = JSON.parse(resource.data)) == null ? void 0 : _d.links) == null ? void 0 : _e.find((i) => i.id === rangeId)) == null ? void 0 : _f.payload;
|
|
1121
|
+
return next({
|
|
1122
|
+
...data,
|
|
1110
1123
|
p: null,
|
|
1111
|
-
v:
|
|
1112
|
-
t:
|
|
1124
|
+
v: getPlainTextFormDocument(data.p),
|
|
1125
|
+
t: CellValueType.STRING,
|
|
1113
1126
|
custom: {
|
|
1114
|
-
__link_url:
|
|
1127
|
+
__link_url: url
|
|
1115
1128
|
}
|
|
1116
1129
|
});
|
|
1117
1130
|
}
|
|
1118
1131
|
}
|
|
1119
|
-
return
|
|
1120
|
-
}
|
|
1132
|
+
return next(data);
|
|
1133
|
+
}, "handler")
|
|
1121
1134
|
}
|
|
1122
1135
|
)
|
|
1123
1136
|
);
|
|
1124
1137
|
}
|
|
1125
|
-
};
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
],
|
|
1135
|
-
var
|
|
1136
|
-
for (var
|
|
1137
|
-
(
|
|
1138
|
-
return
|
|
1139
|
-
},
|
|
1140
|
-
let
|
|
1141
|
-
constructor(
|
|
1142
|
-
super(), this._hoverManagerService =
|
|
1138
|
+
}, __name(_a6, "SheetHyperLinkSetRangeController"), _a6);
|
|
1139
|
+
SheetHyperLinkSetRangeController = __decorateClass$7([
|
|
1140
|
+
OnLifecycle(LifecycleStages.Starting, SheetHyperLinkSetRangeController),
|
|
1141
|
+
__decorateParam$7(0, Inject(SheetInterceptorService)),
|
|
1142
|
+
__decorateParam$7(1, Inject(Injector)),
|
|
1143
|
+
__decorateParam$7(2, Inject(HyperLinkModel)),
|
|
1144
|
+
__decorateParam$7(3, Inject(SheetsSelectionsService)),
|
|
1145
|
+
__decorateParam$7(4, IUniverInstanceService),
|
|
1146
|
+
__decorateParam$7(5, IEditorBridgeService)
|
|
1147
|
+
], SheetHyperLinkSetRangeController);
|
|
1148
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1149
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1150
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1151
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
1152
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a7;
|
|
1153
|
+
let SheetsHyperLinkPopupController = (_a7 = class extends Disposable {
|
|
1154
|
+
constructor(_hoverManagerService, _sheetsHyperLinkPopupService, _renderManagerService, _permissionService, _sheetPermissionInterceptorBaseController) {
|
|
1155
|
+
super(), this._hoverManagerService = _hoverManagerService, this._sheetsHyperLinkPopupService = _sheetsHyperLinkPopupService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._initHoverListener();
|
|
1143
1156
|
}
|
|
1144
1157
|
_initHoverListener() {
|
|
1145
1158
|
this.disposeWithMe(
|
|
1146
|
-
this._hoverManagerService.currentCell$.pipe(
|
|
1147
|
-
var
|
|
1148
|
-
if (!
|
|
1159
|
+
this._hoverManagerService.currentCell$.pipe(debounceTime(200)).subscribe((currentCell) => {
|
|
1160
|
+
var _a14, _b;
|
|
1161
|
+
if (!currentCell) {
|
|
1149
1162
|
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1150
1163
|
return;
|
|
1151
1164
|
}
|
|
1152
|
-
const
|
|
1153
|
-
let
|
|
1154
|
-
if (
|
|
1155
|
-
|
|
1165
|
+
const skeleton = (_b = (_a14 = this._renderManagerService.getRenderById(currentCell.location.unitId)) == null ? void 0 : _a14.with(SheetSkeletonManagerService).getWorksheetSkeleton(currentCell.location.subUnitId)) == null ? void 0 : _b.skeleton, currentCol = currentCell.location.col, currentRow = currentCell.location.row;
|
|
1166
|
+
let targetRow = currentRow, targetCol = currentCol;
|
|
1167
|
+
if (skeleton && skeleton.overflowCache.forValue((row, col, value) => {
|
|
1168
|
+
Rectangle.contains(value, { startColumn: currentCol, endColumn: currentCol, startRow: currentRow, endRow: currentRow }) && (targetRow = row, targetCol = col);
|
|
1156
1169
|
}), !this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
|
|
1157
|
-
workbookTypes: [
|
|
1158
|
-
worksheetTypes: [
|
|
1159
|
-
rangeTypes: [
|
|
1160
|
-
}, [{ startRow:
|
|
1170
|
+
workbookTypes: [WorkbookViewPermission],
|
|
1171
|
+
worksheetTypes: [WorksheetViewPermission],
|
|
1172
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
1173
|
+
}, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }])) {
|
|
1161
1174
|
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1162
1175
|
return;
|
|
1163
1176
|
}
|
|
1164
|
-
const
|
|
1165
|
-
workbookTypes: [
|
|
1166
|
-
worksheetTypes: [
|
|
1167
|
-
rangeTypes: [
|
|
1168
|
-
}, [{ startRow:
|
|
1177
|
+
const editPermission = this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
|
|
1178
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
1179
|
+
worksheetTypes: [WorksheetEditPermission, WorksheetInsertHyperlinkPermission],
|
|
1180
|
+
rangeTypes: [RangeProtectionPermissionEditPoint]
|
|
1181
|
+
}, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }]), unitId = currentCell.location.unitId, subUnitId = currentCell.location.subUnitId, copyPermission = this._permissionService.composePermission([new WorkbookCopyPermission(unitId).id, new WorksheetCopyPermission(unitId, subUnitId).id]).every((permission) => permission.value);
|
|
1169
1182
|
this._sheetsHyperLinkPopupService.showPopup({
|
|
1170
|
-
...
|
|
1171
|
-
row:
|
|
1172
|
-
col:
|
|
1173
|
-
editPermission
|
|
1174
|
-
copyPermission
|
|
1183
|
+
...currentCell.location,
|
|
1184
|
+
row: targetRow,
|
|
1185
|
+
col: targetCol,
|
|
1186
|
+
editPermission,
|
|
1187
|
+
copyPermission
|
|
1175
1188
|
});
|
|
1176
1189
|
})
|
|
1177
1190
|
);
|
|
1178
1191
|
}
|
|
1179
|
-
};
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
],
|
|
1188
|
-
const
|
|
1189
|
-
id:
|
|
1190
|
-
type:
|
|
1191
|
-
positions: [
|
|
1192
|
+
}, __name(_a7, "SheetsHyperLinkPopupController"), _a7);
|
|
1193
|
+
SheetsHyperLinkPopupController = __decorateClass$6([
|
|
1194
|
+
OnLifecycle(LifecycleStages.Rendered, SheetsHyperLinkPopupController),
|
|
1195
|
+
__decorateParam$6(0, Inject(HoverManagerService)),
|
|
1196
|
+
__decorateParam$6(1, Inject(SheetsHyperLinkPopupService)),
|
|
1197
|
+
__decorateParam$6(2, Inject(IRenderManagerService)),
|
|
1198
|
+
__decorateParam$6(3, Inject(IPermissionService)),
|
|
1199
|
+
__decorateParam$6(4, Inject(SheetPermissionInterceptorBaseController))
|
|
1200
|
+
], SheetsHyperLinkPopupController);
|
|
1201
|
+
const insertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1202
|
+
id: InsertHyperLinkOperation.id,
|
|
1203
|
+
type: MenuItemType.BUTTON,
|
|
1204
|
+
positions: [MenuPosition.CONTEXT_MENU],
|
|
1192
1205
|
title: "hyperLink.menu.add",
|
|
1193
|
-
hidden$:
|
|
1206
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1194
1207
|
icon: "LinkSingle",
|
|
1195
|
-
disabled$:
|
|
1196
|
-
}),
|
|
1208
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1209
|
+
}), "insertLinkMenuFactory"), insertLinkMenuToolbarFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1197
1210
|
tooltip: "hyperLink.form.addTitle",
|
|
1198
|
-
positions:
|
|
1199
|
-
group:
|
|
1200
|
-
id:
|
|
1201
|
-
type:
|
|
1211
|
+
positions: MenuPosition.TOOLBAR_START,
|
|
1212
|
+
group: MenuGroup.TOOLBAR_OTHERS,
|
|
1213
|
+
id: InsertHyperLinkToolbarOperation.id,
|
|
1214
|
+
type: MenuItemType.BUTTON,
|
|
1202
1215
|
icon: "LinkSingle",
|
|
1203
|
-
hidden$:
|
|
1204
|
-
disabled$:
|
|
1205
|
-
}),
|
|
1206
|
-
id:
|
|
1207
|
-
binding:
|
|
1208
|
-
preconditions:
|
|
1216
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1217
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1218
|
+
}), "insertLinkMenuToolbarFactory"), InsertLinkShortcut = {
|
|
1219
|
+
id: InsertHyperLinkToolbarOperation.id,
|
|
1220
|
+
binding: KeyCode.K | MetaKeys.CTRL_COMMAND,
|
|
1221
|
+
preconditions: whenSheetEditorFocused
|
|
1209
1222
|
};
|
|
1210
|
-
var
|
|
1211
|
-
for (var
|
|
1212
|
-
(
|
|
1213
|
-
return
|
|
1214
|
-
},
|
|
1215
|
-
let
|
|
1216
|
-
constructor(
|
|
1217
|
-
super(), this._config =
|
|
1223
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1224
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1225
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1226
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
1227
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a8;
|
|
1228
|
+
let SheetsHyperLinkUIController = (_a8 = class extends Disposable {
|
|
1229
|
+
constructor(_config, _componentManager, _commandService, _localeService, _menuService, _injector, _shortcutService) {
|
|
1230
|
+
super(), this._config = _config, this._componentManager = _componentManager, this._commandService = _commandService, this._localeService = _localeService, this._menuService = _menuService, this._injector = _injector, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
|
|
1218
1231
|
}
|
|
1219
1232
|
_initComponents() {
|
|
1220
1233
|
[
|
|
1221
|
-
[
|
|
1222
|
-
[
|
|
1223
|
-
[
|
|
1224
|
-
].forEach(([
|
|
1225
|
-
this._componentManager.register(
|
|
1234
|
+
[CellLinkPopup, CellLinkPopup.componentKey],
|
|
1235
|
+
[CellLinkEdit, CellLinkEdit.componentKey],
|
|
1236
|
+
[LinkSingle, "LinkSingle"]
|
|
1237
|
+
].forEach(([comp, key]) => {
|
|
1238
|
+
this._componentManager.register(key, comp);
|
|
1226
1239
|
});
|
|
1227
1240
|
}
|
|
1228
1241
|
_initCommands() {
|
|
1229
1242
|
[
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
].forEach((
|
|
1235
|
-
this._commandService.registerCommand(
|
|
1243
|
+
OpenHyperLinkSidebarOperation,
|
|
1244
|
+
CloseHyperLinkSidebarOperation,
|
|
1245
|
+
InsertHyperLinkOperation,
|
|
1246
|
+
InsertHyperLinkToolbarOperation
|
|
1247
|
+
].forEach((command) => {
|
|
1248
|
+
this._commandService.registerCommand(command);
|
|
1236
1249
|
});
|
|
1237
1250
|
}
|
|
1238
1251
|
_initMenus() {
|
|
1239
|
-
var
|
|
1240
|
-
this._menuService.addMenuItem(
|
|
1252
|
+
var _a14, _b, _c, _d;
|
|
1253
|
+
this._menuService.addMenuItem(insertLinkMenuFactory(this._injector), (_b = (_a14 = this._config) == null ? void 0 : _a14.menu) != null ? _b : {}), this._menuService.addMenuItem(insertLinkMenuToolbarFactory(this._injector), (_d = (_c = this._config) == null ? void 0 : _c.menu) != null ? _d : {});
|
|
1241
1254
|
}
|
|
1242
1255
|
_initShortCut() {
|
|
1243
|
-
this._shortcutService.registerShortcut(
|
|
1256
|
+
this._shortcutService.registerShortcut(InsertLinkShortcut);
|
|
1244
1257
|
}
|
|
1245
|
-
};
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
],
|
|
1255
|
-
const
|
|
1256
|
-
var
|
|
1257
|
-
for (var
|
|
1258
|
-
(
|
|
1259
|
-
return
|
|
1260
|
-
},
|
|
1261
|
-
let
|
|
1262
|
-
constructor(
|
|
1263
|
-
super(), this._autoFillService =
|
|
1258
|
+
}, __name(_a8, "SheetsHyperLinkUIController"), _a8);
|
|
1259
|
+
SheetsHyperLinkUIController = __decorateClass$5([
|
|
1260
|
+
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkUIController),
|
|
1261
|
+
__decorateParam$5(1, Inject(ComponentManager)),
|
|
1262
|
+
__decorateParam$5(2, ICommandService),
|
|
1263
|
+
__decorateParam$5(3, Inject(LocaleService)),
|
|
1264
|
+
__decorateParam$5(4, IMenuService),
|
|
1265
|
+
__decorateParam$5(5, Inject(Injector)),
|
|
1266
|
+
__decorateParam$5(6, Inject(IShortcutService))
|
|
1267
|
+
], SheetsHyperLinkUIController);
|
|
1268
|
+
const SHEET_HYPER_LINK_UI_PLUGIN = "SHEET_HYPER_LINK_UI_PLUGIN";
|
|
1269
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1270
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1271
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1272
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
1273
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a9;
|
|
1274
|
+
let SheetsHyperLinkAutoFillController = (_a9 = class extends Disposable {
|
|
1275
|
+
constructor(_autoFillService, _hyperLinkModel) {
|
|
1276
|
+
super(), this._autoFillService = _autoFillService, this._hyperLinkModel = _hyperLinkModel, this._initAutoFill();
|
|
1264
1277
|
}
|
|
1265
1278
|
// eslint-disable-next-line max-lines-per-function
|
|
1266
1279
|
_initAutoFill() {
|
|
1267
|
-
const
|
|
1268
|
-
const { source:
|
|
1269
|
-
row:
|
|
1270
|
-
col:
|
|
1271
|
-
},
|
|
1272
|
-
return
|
|
1273
|
-
const
|
|
1274
|
-
startRow:
|
|
1275
|
-
startColumn:
|
|
1276
|
-
endColumn:
|
|
1277
|
-
endRow:
|
|
1278
|
-
},
|
|
1279
|
-
startRow:
|
|
1280
|
-
startColumn:
|
|
1281
|
-
endColumn:
|
|
1282
|
-
endRow:
|
|
1280
|
+
const noopReturnFunc = /* @__PURE__ */ __name(() => ({ redos: [], undos: [] }), "noopReturnFunc"), generalApplyFunc = /* @__PURE__ */ __name((location2, applyType) => {
|
|
1281
|
+
const { source: sourceRange, target: targetRange, unitId, subUnitId } = location2, virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]), [vSourceRange, vTargetRange] = virtualRange.ranges, { mapFunc } = virtualRange, sourceStartCell = {
|
|
1282
|
+
row: vSourceRange.startRow,
|
|
1283
|
+
col: vSourceRange.startColumn
|
|
1284
|
+
}, repeats = getAutoFillRepeatRange(vSourceRange, vTargetRange), redos = [], undos = [];
|
|
1285
|
+
return repeats.forEach((repeat) => {
|
|
1286
|
+
const targetStartCell = repeat.repeatStartCell, relativeRange = repeat.relativeRange, sourceRange2 = {
|
|
1287
|
+
startRow: sourceStartCell.row,
|
|
1288
|
+
startColumn: sourceStartCell.col,
|
|
1289
|
+
endColumn: sourceStartCell.col,
|
|
1290
|
+
endRow: sourceStartCell.row
|
|
1291
|
+
}, targetRange2 = {
|
|
1292
|
+
startRow: targetStartCell.row,
|
|
1293
|
+
startColumn: targetStartCell.col,
|
|
1294
|
+
endColumn: targetStartCell.col,
|
|
1295
|
+
endRow: targetStartCell.row
|
|
1283
1296
|
};
|
|
1284
|
-
|
|
1285
|
-
const
|
|
1297
|
+
Range.foreach(relativeRange, (row, col) => {
|
|
1298
|
+
const sourcePositionRange = Rectangle.getPositionRange(
|
|
1286
1299
|
{
|
|
1287
|
-
startRow:
|
|
1288
|
-
startColumn:
|
|
1289
|
-
endColumn:
|
|
1290
|
-
endRow:
|
|
1300
|
+
startRow: row,
|
|
1301
|
+
startColumn: col,
|
|
1302
|
+
endColumn: col,
|
|
1303
|
+
endRow: row
|
|
1291
1304
|
},
|
|
1292
|
-
|
|
1293
|
-
), { row:
|
|
1294
|
-
if (
|
|
1295
|
-
const
|
|
1305
|
+
sourceRange2
|
|
1306
|
+
), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol);
|
|
1307
|
+
if (link) {
|
|
1308
|
+
const targetPositionRange = Rectangle.getPositionRange(
|
|
1296
1309
|
{
|
|
1297
|
-
startRow:
|
|
1298
|
-
startColumn:
|
|
1299
|
-
endColumn:
|
|
1300
|
-
endRow:
|
|
1310
|
+
startRow: row,
|
|
1311
|
+
startColumn: col,
|
|
1312
|
+
endColumn: col,
|
|
1313
|
+
endRow: row
|
|
1301
1314
|
},
|
|
1302
|
-
|
|
1303
|
-
), { row:
|
|
1304
|
-
|
|
1305
|
-
id:
|
|
1315
|
+
targetRange2
|
|
1316
|
+
), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn), id = Tools.generateRandomId(), currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
|
|
1317
|
+
currentLink && redos.push({
|
|
1318
|
+
id: RemoveHyperLinkMutation.id,
|
|
1306
1319
|
params: {
|
|
1307
|
-
unitId
|
|
1308
|
-
subUnitId
|
|
1309
|
-
id:
|
|
1320
|
+
unitId,
|
|
1321
|
+
subUnitId,
|
|
1322
|
+
id: currentLink.id
|
|
1310
1323
|
}
|
|
1311
|
-
}), (
|
|
1312
|
-
id:
|
|
1324
|
+
}), (APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) && (redos.push({
|
|
1325
|
+
id: AddHyperLinkMutation.id,
|
|
1313
1326
|
params: {
|
|
1314
|
-
unitId
|
|
1315
|
-
subUnitId
|
|
1327
|
+
unitId,
|
|
1328
|
+
subUnitId,
|
|
1316
1329
|
link: {
|
|
1317
|
-
...
|
|
1318
|
-
id
|
|
1319
|
-
row:
|
|
1320
|
-
column:
|
|
1330
|
+
...link,
|
|
1331
|
+
id,
|
|
1332
|
+
row: targetRow,
|
|
1333
|
+
column: targetCol
|
|
1321
1334
|
}
|
|
1322
1335
|
}
|
|
1323
|
-
}),
|
|
1324
|
-
id:
|
|
1336
|
+
}), undos.push({
|
|
1337
|
+
id: RemoveHyperLinkMutation.id,
|
|
1325
1338
|
params: {
|
|
1326
|
-
unitId
|
|
1327
|
-
subUnitId
|
|
1328
|
-
id
|
|
1339
|
+
unitId,
|
|
1340
|
+
subUnitId,
|
|
1341
|
+
id
|
|
1329
1342
|
}
|
|
1330
|
-
})),
|
|
1331
|
-
id:
|
|
1343
|
+
})), currentLink && undos.push({
|
|
1344
|
+
id: AddHyperLinkMutation.id,
|
|
1332
1345
|
params: {
|
|
1333
|
-
unitId
|
|
1334
|
-
subUnitId
|
|
1335
|
-
link:
|
|
1346
|
+
unitId,
|
|
1347
|
+
subUnitId,
|
|
1348
|
+
link: currentLink
|
|
1336
1349
|
}
|
|
1337
1350
|
});
|
|
1338
1351
|
}
|
|
1339
1352
|
});
|
|
1340
1353
|
}), {
|
|
1341
|
-
undos
|
|
1342
|
-
redos
|
|
1354
|
+
undos,
|
|
1355
|
+
redos
|
|
1343
1356
|
};
|
|
1344
|
-
},
|
|
1345
|
-
id:
|
|
1346
|
-
onFillData: (
|
|
1357
|
+
}, "generalApplyFunc"), hook = {
|
|
1358
|
+
id: SHEET_HYPER_LINK_UI_PLUGIN,
|
|
1359
|
+
onFillData: /* @__PURE__ */ __name((location2, direction, applyType) => applyType === APPLY_TYPE.COPY || applyType === APPLY_TYPE.ONLY_FORMAT || applyType === APPLY_TYPE.SERIES ? generalApplyFunc(location2, applyType) : noopReturnFunc(), "onFillData")
|
|
1347
1360
|
};
|
|
1348
|
-
this.disposeWithMe(this._autoFillService.addHook(
|
|
1361
|
+
this.disposeWithMe(this._autoFillService.addHook(hook));
|
|
1349
1362
|
}
|
|
1350
|
-
};
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
],
|
|
1356
|
-
var
|
|
1357
|
-
for (var
|
|
1358
|
-
(
|
|
1359
|
-
return
|
|
1360
|
-
},
|
|
1361
|
-
let
|
|
1362
|
-
constructor(
|
|
1363
|
+
}, __name(_a9, "SheetsHyperLinkAutoFillController"), _a9);
|
|
1364
|
+
SheetsHyperLinkAutoFillController = __decorateClass$4([
|
|
1365
|
+
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkAutoFillController),
|
|
1366
|
+
__decorateParam$4(0, IAutoFillService),
|
|
1367
|
+
__decorateParam$4(1, Inject(HyperLinkModel))
|
|
1368
|
+
], SheetsHyperLinkAutoFillController);
|
|
1369
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1370
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1371
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1372
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
1373
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a10;
|
|
1374
|
+
let SheetsHyperLinkCopyPasteController = (_a10 = class extends Disposable {
|
|
1375
|
+
constructor(_sheetClipboardService, _hyperLinkModel, _injector, _resolverService) {
|
|
1363
1376
|
super();
|
|
1364
|
-
|
|
1365
|
-
this._sheetClipboardService =
|
|
1377
|
+
__publicField(this, "_copyInfo");
|
|
1378
|
+
this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste();
|
|
1366
1379
|
}
|
|
1367
1380
|
_initCopyPaste() {
|
|
1368
1381
|
this._sheetClipboardService.addClipboardHook({
|
|
1369
|
-
id:
|
|
1370
|
-
onBeforeCopy: (
|
|
1371
|
-
onPasteCells: (
|
|
1372
|
-
const { copyType
|
|
1373
|
-
return this._generateMutations(
|
|
1374
|
-
},
|
|
1375
|
-
onPastePlainText: (
|
|
1376
|
-
if (
|
|
1377
|
-
const
|
|
1378
|
-
return
|
|
1379
|
-
const { row
|
|
1380
|
-
|
|
1381
|
-
id:
|
|
1382
|
+
id: SHEET_HYPER_LINK_UI_PLUGIN,
|
|
1383
|
+
onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
|
|
1384
|
+
onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
|
|
1385
|
+
const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
|
|
1386
|
+
return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
|
|
1387
|
+
}, "onPasteCells"),
|
|
1388
|
+
onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => {
|
|
1389
|
+
if (isLegalLink(clipText)) {
|
|
1390
|
+
const text = serializeUrl(clipText), { range, unitId, subUnitId } = pasteTo, { ranges: [pasteToRange], mapFunc } = virtualizeDiscreteRanges([range]), redos = [], undos = [];
|
|
1391
|
+
return Range.foreach(pasteToRange, (originRow, originCol) => {
|
|
1392
|
+
const { row, col: column } = mapFunc(originRow, originCol), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
|
|
1393
|
+
link && redos.push({
|
|
1394
|
+
id: RemoveHyperLinkMutation.id,
|
|
1382
1395
|
params: {
|
|
1383
|
-
unitId
|
|
1384
|
-
subUnitId
|
|
1385
|
-
id:
|
|
1396
|
+
unitId,
|
|
1397
|
+
subUnitId,
|
|
1398
|
+
id: link.id
|
|
1386
1399
|
}
|
|
1387
1400
|
});
|
|
1388
|
-
const
|
|
1389
|
-
|
|
1390
|
-
id:
|
|
1401
|
+
const newId = Tools.generateRandomId();
|
|
1402
|
+
redos.push({
|
|
1403
|
+
id: AddHyperLinkMutation.id,
|
|
1391
1404
|
params: {
|
|
1392
|
-
unitId
|
|
1393
|
-
subUnitId
|
|
1405
|
+
unitId,
|
|
1406
|
+
subUnitId,
|
|
1394
1407
|
link: {
|
|
1395
|
-
id:
|
|
1396
|
-
row
|
|
1397
|
-
column
|
|
1398
|
-
payload:
|
|
1408
|
+
id: newId,
|
|
1409
|
+
row,
|
|
1410
|
+
column,
|
|
1411
|
+
payload: text
|
|
1399
1412
|
}
|
|
1400
1413
|
}
|
|
1401
|
-
}),
|
|
1402
|
-
id:
|
|
1414
|
+
}), undos.push({
|
|
1415
|
+
id: RemoveHyperLinkMutation.id,
|
|
1403
1416
|
params: {
|
|
1404
|
-
unitId
|
|
1405
|
-
subUnitId
|
|
1406
|
-
id:
|
|
1417
|
+
unitId,
|
|
1418
|
+
subUnitId,
|
|
1419
|
+
id: newId
|
|
1407
1420
|
}
|
|
1408
|
-
}),
|
|
1409
|
-
id:
|
|
1421
|
+
}), link && undos.push({
|
|
1422
|
+
id: AddHyperLinkMutation.id,
|
|
1410
1423
|
params: {
|
|
1411
|
-
unitId
|
|
1412
|
-
subUnitId
|
|
1413
|
-
link
|
|
1424
|
+
unitId,
|
|
1425
|
+
subUnitId,
|
|
1426
|
+
link
|
|
1414
1427
|
}
|
|
1415
1428
|
});
|
|
1416
|
-
}), { redos
|
|
1429
|
+
}), { redos, undos };
|
|
1417
1430
|
}
|
|
1418
1431
|
return { undos: [], redos: [] };
|
|
1419
|
-
}
|
|
1432
|
+
}, "onPastePlainText")
|
|
1420
1433
|
});
|
|
1421
1434
|
}
|
|
1422
|
-
_collect(
|
|
1423
|
-
const
|
|
1435
|
+
_collect(unitId, subUnitId, range) {
|
|
1436
|
+
const matrix = new ObjectMatrix();
|
|
1424
1437
|
this._copyInfo = {
|
|
1425
|
-
unitId
|
|
1426
|
-
subUnitId
|
|
1427
|
-
matrix
|
|
1438
|
+
unitId,
|
|
1439
|
+
subUnitId,
|
|
1440
|
+
matrix
|
|
1428
1441
|
};
|
|
1429
|
-
const
|
|
1442
|
+
const accessor = {
|
|
1430
1443
|
get: this._injector.get.bind(this._injector)
|
|
1431
|
-
},
|
|
1432
|
-
if (!
|
|
1444
|
+
}, discreteRange = rangeToDiscreteRange(range, accessor, unitId, subUnitId);
|
|
1445
|
+
if (!discreteRange)
|
|
1433
1446
|
return;
|
|
1434
|
-
const { rows
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
var
|
|
1438
|
-
const
|
|
1439
|
-
|
|
1447
|
+
const { rows, cols } = discreteRange;
|
|
1448
|
+
rows.forEach((row, rowIndex) => {
|
|
1449
|
+
cols.forEach((col, colIndex) => {
|
|
1450
|
+
var _a14;
|
|
1451
|
+
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1452
|
+
matrix.setValue(rowIndex, colIndex, (_a14 = link == null ? void 0 : link.id) != null ? _a14 : "");
|
|
1440
1453
|
});
|
|
1441
1454
|
});
|
|
1442
1455
|
}
|
|
1443
1456
|
// eslint-disable-next-line max-lines-per-function
|
|
1444
|
-
_generateMutations(
|
|
1457
|
+
_generateMutations(pastedRange, copyInfo) {
|
|
1445
1458
|
if (!this._copyInfo)
|
|
1446
1459
|
return { redos: [], undos: [] };
|
|
1447
|
-
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !
|
|
1460
|
+
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange)
|
|
1448
1461
|
return { redos: [], undos: [] };
|
|
1449
1462
|
if ([
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1463
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
|
|
1464
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
|
|
1465
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
|
|
1466
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
|
|
1454
1467
|
].includes(
|
|
1455
|
-
|
|
1468
|
+
copyInfo.pasteType
|
|
1456
1469
|
))
|
|
1457
1470
|
return { redos: [], undos: [] };
|
|
1458
|
-
const { unitId
|
|
1459
|
-
return
|
|
1460
|
-
var
|
|
1461
|
-
(
|
|
1462
|
-
const
|
|
1471
|
+
const { unitId, subUnitId } = this._copyInfo, redos = [], undos = [], { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
|
|
1472
|
+
return getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
|
|
1473
|
+
var _a14;
|
|
1474
|
+
(_a14 = this._copyInfo) == null || _a14.matrix.forValue((row, col, ruleId) => {
|
|
1475
|
+
const range = Rectangle.getPositionRange(
|
|
1463
1476
|
{
|
|
1464
|
-
startRow:
|
|
1465
|
-
endRow:
|
|
1466
|
-
startColumn:
|
|
1467
|
-
endColumn:
|
|
1477
|
+
startRow: row,
|
|
1478
|
+
endRow: row,
|
|
1479
|
+
startColumn: col,
|
|
1480
|
+
endColumn: col
|
|
1468
1481
|
},
|
|
1469
|
-
|
|
1470
|
-
),
|
|
1471
|
-
|
|
1472
|
-
id:
|
|
1482
|
+
startRange
|
|
1483
|
+
), oldLink = this._hyperLinkModel.getHyperLink(unitId, subUnitId, ruleId), { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn), currentLink = this._hyperLinkModel.getHyperLinkByLocation(copyInfo.unitId, copyInfo.subUnitId, startRow, startColumn), id = Tools.generateRandomId();
|
|
1484
|
+
currentLink && redos.push({
|
|
1485
|
+
id: RemoveHyperLinkMutation.id,
|
|
1473
1486
|
params: {
|
|
1474
|
-
unitId:
|
|
1475
|
-
subUnitId:
|
|
1476
|
-
id:
|
|
1487
|
+
unitId: copyInfo.unitId,
|
|
1488
|
+
subUnitId: copyInfo.subUnitId,
|
|
1489
|
+
id: currentLink.id
|
|
1477
1490
|
}
|
|
1478
|
-
}),
|
|
1479
|
-
id:
|
|
1491
|
+
}), oldLink && (redos.push({
|
|
1492
|
+
id: AddHyperLinkMutation.id,
|
|
1480
1493
|
params: {
|
|
1481
|
-
unitId:
|
|
1482
|
-
subUnitId:
|
|
1494
|
+
unitId: copyInfo.unitId,
|
|
1495
|
+
subUnitId: copyInfo.subUnitId,
|
|
1483
1496
|
link: {
|
|
1484
|
-
...
|
|
1485
|
-
id
|
|
1486
|
-
row:
|
|
1487
|
-
column:
|
|
1497
|
+
...oldLink,
|
|
1498
|
+
id,
|
|
1499
|
+
row: startRow,
|
|
1500
|
+
column: startColumn
|
|
1488
1501
|
}
|
|
1489
1502
|
}
|
|
1490
|
-
}),
|
|
1491
|
-
id:
|
|
1503
|
+
}), undos.push({
|
|
1504
|
+
id: RemoveHyperLinkMutation.id,
|
|
1492
1505
|
params: {
|
|
1493
|
-
unitId:
|
|
1494
|
-
subUnitId:
|
|
1495
|
-
id
|
|
1506
|
+
unitId: copyInfo.unitId,
|
|
1507
|
+
subUnitId: copyInfo.subUnitId,
|
|
1508
|
+
id
|
|
1496
1509
|
}
|
|
1497
|
-
})),
|
|
1498
|
-
id:
|
|
1510
|
+
})), currentLink && undos.push({
|
|
1511
|
+
id: AddHyperLinkMutation.id,
|
|
1499
1512
|
params: {
|
|
1500
|
-
unitId:
|
|
1501
|
-
subUnitId:
|
|
1502
|
-
link:
|
|
1513
|
+
unitId: copyInfo.unitId,
|
|
1514
|
+
subUnitId: copyInfo.subUnitId,
|
|
1515
|
+
link: currentLink
|
|
1503
1516
|
}
|
|
1504
1517
|
});
|
|
1505
1518
|
});
|
|
1506
|
-
}), { redos
|
|
1519
|
+
}), { redos, undos };
|
|
1507
1520
|
}
|
|
1508
|
-
};
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
],
|
|
1516
|
-
var
|
|
1517
|
-
for (var
|
|
1518
|
-
(
|
|
1519
|
-
return
|
|
1520
|
-
},
|
|
1521
|
-
let
|
|
1522
|
-
constructor(
|
|
1523
|
-
super(), this._resolverService =
|
|
1521
|
+
}, __name(_a10, "SheetsHyperLinkCopyPasteController"), _a10);
|
|
1522
|
+
SheetsHyperLinkCopyPasteController = __decorateClass$3([
|
|
1523
|
+
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkCopyPasteController),
|
|
1524
|
+
__decorateParam$3(0, ISheetClipboardService),
|
|
1525
|
+
__decorateParam$3(1, Inject(HyperLinkModel)),
|
|
1526
|
+
__decorateParam$3(2, Inject(Injector)),
|
|
1527
|
+
__decorateParam$3(3, Inject(SheetsHyperLinkResolverService))
|
|
1528
|
+
], SheetsHyperLinkCopyPasteController);
|
|
1529
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1530
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1531
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1532
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
1533
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a11;
|
|
1534
|
+
let SheetHyperLinkUrlController = (_a11 = class extends Disposable {
|
|
1535
|
+
constructor(_resolverService) {
|
|
1536
|
+
super(), this._resolverService = _resolverService, this._handleInitUrl();
|
|
1524
1537
|
}
|
|
1525
1538
|
_handleInitUrl() {
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1539
|
+
const hash = location.hash;
|
|
1540
|
+
hash && this._resolverService.parseHyperLink(hash).handler();
|
|
1528
1541
|
}
|
|
1529
|
-
};
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
],
|
|
1534
|
-
var
|
|
1535
|
-
for (var
|
|
1536
|
-
(
|
|
1537
|
-
return
|
|
1538
|
-
},
|
|
1539
|
-
let
|
|
1540
|
-
constructor(
|
|
1541
|
-
super(), this._localeService =
|
|
1542
|
+
}, __name(_a11, "SheetHyperLinkUrlController"), _a11);
|
|
1543
|
+
SheetHyperLinkUrlController = __decorateClass$2([
|
|
1544
|
+
OnLifecycle(LifecycleStages.Rendered, SheetHyperLinkUrlController),
|
|
1545
|
+
__decorateParam$2(0, Inject(SheetsHyperLinkResolverService))
|
|
1546
|
+
], SheetHyperLinkUrlController);
|
|
1547
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1548
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1549
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1550
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
1551
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a12;
|
|
1552
|
+
let SheetsHyperLinkPermissionController = (_a12 = class extends Disposable {
|
|
1553
|
+
constructor(_localeService, _commandService, _sheetPermissionInterceptorBaseController) {
|
|
1554
|
+
super(), this._localeService = _localeService, this._commandService = _commandService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._commandExecutedListener();
|
|
1542
1555
|
}
|
|
1543
1556
|
_commandExecutedListener() {
|
|
1544
1557
|
this.disposeWithMe(
|
|
1545
|
-
this._commandService.beforeCommandExecuted((
|
|
1546
|
-
|
|
1547
|
-
workbookTypes: [
|
|
1548
|
-
rangeTypes: [
|
|
1549
|
-
worksheetTypes: [
|
|
1558
|
+
this._commandService.beforeCommandExecuted((command) => {
|
|
1559
|
+
command.id === InsertLinkShortcut.id && (this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
|
|
1560
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
1561
|
+
rangeTypes: [RangeProtectionPermissionEditPoint],
|
|
1562
|
+
worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission]
|
|
1550
1563
|
}) || this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")));
|
|
1551
1564
|
})
|
|
1552
1565
|
);
|
|
1553
1566
|
}
|
|
1554
|
-
};
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
],
|
|
1561
|
-
var
|
|
1562
|
-
for (var
|
|
1563
|
-
(
|
|
1564
|
-
return
|
|
1565
|
-
},
|
|
1566
|
-
let
|
|
1567
|
-
constructor(
|
|
1568
|
-
super(), this._config =
|
|
1567
|
+
}, __name(_a12, "SheetsHyperLinkPermissionController"), _a12);
|
|
1568
|
+
SheetsHyperLinkPermissionController = __decorateClass$1([
|
|
1569
|
+
OnLifecycle(LifecycleStages.Rendered, SheetsHyperLinkPermissionController),
|
|
1570
|
+
__decorateParam$1(0, Inject(LocaleService)),
|
|
1571
|
+
__decorateParam$1(1, ICommandService),
|
|
1572
|
+
__decorateParam$1(2, Inject(SheetPermissionInterceptorBaseController))
|
|
1573
|
+
], SheetsHyperLinkPermissionController);
|
|
1574
|
+
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) => {
|
|
1575
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1576
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1577
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
1578
|
+
}, "__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"), _a13;
|
|
1579
|
+
let UniverSheetsHyperLinkUIPlugin = (_a13 = class extends Plugin {
|
|
1580
|
+
constructor(_config, _injector, _renderManagerService) {
|
|
1581
|
+
super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService;
|
|
1569
1582
|
}
|
|
1570
|
-
onStarting(
|
|
1583
|
+
onStarting() {
|
|
1571
1584
|
[
|
|
1572
|
-
[
|
|
1573
|
-
[
|
|
1574
|
-
[
|
|
1575
|
-
[
|
|
1576
|
-
[
|
|
1577
|
-
[
|
|
1585
|
+
[SheetsHyperLinkResolverService],
|
|
1586
|
+
[SheetsHyperLinkPopupService],
|
|
1587
|
+
[SheetsHyperLinkRemoveSheetController],
|
|
1588
|
+
[SheetsHyperLinkRenderManagerController],
|
|
1589
|
+
[SheetHyperLinkSetRangeController],
|
|
1590
|
+
[SheetsHyperLinkPopupController],
|
|
1578
1591
|
[
|
|
1579
|
-
|
|
1592
|
+
SheetsHyperLinkUIController,
|
|
1580
1593
|
{
|
|
1581
|
-
useFactory: () => this._injector.createInstance(
|
|
1594
|
+
useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetsHyperLinkUIController, this._config), "useFactory")
|
|
1582
1595
|
}
|
|
1583
1596
|
],
|
|
1584
|
-
[
|
|
1585
|
-
[
|
|
1586
|
-
[
|
|
1587
|
-
[
|
|
1588
|
-
].forEach((
|
|
1597
|
+
[SheetsHyperLinkAutoFillController],
|
|
1598
|
+
[SheetsHyperLinkCopyPasteController],
|
|
1599
|
+
[SheetsHyperLinkPermissionController],
|
|
1600
|
+
[SheetHyperLinkUrlController]
|
|
1601
|
+
].forEach((dep) => this._injector.add(dep));
|
|
1589
1602
|
}
|
|
1590
1603
|
onReady() {
|
|
1591
1604
|
[
|
|
1592
|
-
[
|
|
1593
|
-
].forEach((
|
|
1605
|
+
[SheetsHyperLinkRenderController]
|
|
1606
|
+
].forEach((d) => this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, d));
|
|
1594
1607
|
}
|
|
1595
|
-
};
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
],
|
|
1608
|
+
}, __name(_a13, "UniverSheetsHyperLinkUIPlugin"), _a13);
|
|
1609
|
+
__publicField2(UniverSheetsHyperLinkUIPlugin, "pluginName", SHEET_HYPER_LINK_UI_PLUGIN);
|
|
1610
|
+
__publicField2(UniverSheetsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1611
|
+
UniverSheetsHyperLinkUIPlugin = __decorateClass([
|
|
1612
|
+
DependentOn(UniverSheetsHyperLinkPlugin),
|
|
1613
|
+
__decorateParam(1, Inject(Injector)),
|
|
1614
|
+
__decorateParam(2, IRenderManagerService)
|
|
1615
|
+
], UniverSheetsHyperLinkUIPlugin);
|
|
1603
1616
|
export {
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1617
|
+
CloseHyperLinkSidebarOperation,
|
|
1618
|
+
InsertHyperLinkOperation,
|
|
1619
|
+
InsertLinkShortcut,
|
|
1620
|
+
OpenHyperLinkSidebarOperation,
|
|
1621
|
+
SheetHyperLinkSetRangeController,
|
|
1622
|
+
SheetHyperLinkUrlController,
|
|
1623
|
+
SheetsHyperLinkAutoFillController,
|
|
1624
|
+
SheetsHyperLinkCopyPasteController,
|
|
1625
|
+
SheetsHyperLinkPopupController,
|
|
1626
|
+
SheetsHyperLinkPopupService,
|
|
1627
|
+
SheetsHyperLinkRemoveSheetController,
|
|
1628
|
+
SheetsHyperLinkRenderController,
|
|
1629
|
+
SheetsHyperLinkRenderManagerController,
|
|
1630
|
+
SheetsHyperLinkResolverService,
|
|
1631
|
+
SheetsHyperLinkUIController,
|
|
1632
|
+
UniverSheetsHyperLinkUIPlugin
|
|
1620
1633
|
};
|