@univerjs/sheets-hyper-link-ui 0.2.6 → 0.2.8
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/README.md +23 -0
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +687 -508
- package/lib/types/commands/commands/add-hyper-link.command.d.ts +11 -0
- package/lib/types/commands/commands/remove-hyper-link.command.d.ts +11 -0
- package/lib/types/commands/commands/update-hyper-link.command.d.ts +9 -0
- package/lib/types/commands/operations/sidebar.operations.d.ts +0 -1
- package/lib/types/common/util.d.ts +0 -1
- package/lib/types/controllers/auto-fill.controller.d.ts +0 -1
- package/lib/types/controllers/copy-paste.controller.d.ts +4 -1
- package/lib/types/controllers/hyper-link-permission.controller.d.ts +0 -1
- package/lib/types/controllers/menu.d.ts +0 -1
- package/lib/types/controllers/popup.controller.d.ts +4 -3
- package/lib/types/controllers/remove-sheet.controller.d.ts +0 -1
- package/lib/types/controllers/render-controllers/render.controller.d.ts +0 -1
- package/lib/types/controllers/set-range.controller.d.ts +0 -1
- package/lib/types/controllers/ui.controller.d.ts +4 -7
- package/lib/types/controllers/url.controller.d.ts +0 -1
- package/lib/types/index.d.ts +5 -7
- package/lib/types/locale/en-US.d.ts +0 -1
- package/lib/types/locale/ru-RU.d.ts +0 -1
- package/lib/types/locale/vi-VN.d.ts +0 -1
- package/lib/types/locale/zh-TW.d.ts +0 -1
- package/lib/types/plugin.d.ts +3 -4
- package/lib/types/services/popup.service.d.ts +0 -1
- package/lib/types/services/resolver.service.d.ts +10 -3
- package/lib/types/services/side-panel.service.d.ts +45 -0
- package/lib/types/types/interfaces/i-config.d.ts +8 -0
- package/lib/types/views/CellLinkEdit/index.d.ts +0 -1
- package/lib/types/views/CellLinkPopup/index.d.ts +0 -1
- package/lib/umd/index.js +2 -2
- package/package.json +24 -24
package/lib/es/index.js
CHANGED
|
@@ -2,135 +2,50 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { Disposable, UniverInstanceType,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { debounceTime, Subject, BehaviorSubject } from "rxjs";
|
|
11
|
-
import require$$0, { forwardRef, useRef, createElement, useState, useEffect, useMemo } from "react";
|
|
5
|
+
import { Disposable, UniverInstanceType, isValidRange, Inject, LocaleService, RANGE_TYPE, Rectangle, IUniverInstanceService, ICommandService, Tools, DEFAULT_EMPTY_DOCUMENT_VALUE, CommandType, IUndoRedoService, sequenceExecuteAsync, useDependency, createInternalEditorID, Range, ObjectMatrix, OnLifecycle, LifecycleStages, Injector, BooleanNumber, ThemeService, CellValueType, CustomRangeType, IPermissionService, Plugin, DependentOn } from "@univerjs/core";
|
|
6
|
+
import { ERROR_RANGE, AddHyperLinkMutation, RemoveHyperLinkMutation, HyperLinkModel, UpdateHyperLinkMutation, UniverSheetsHyperLinkPlugin } from "@univerjs/sheets-hyper-link";
|
|
7
|
+
import { ScrollToRangeOperation, SheetCanvasPopManagerService, COPY_TYPE, virtualizeDiscreteRanges, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, SheetSkeletonManagerService, IEditorBridgeService, HoverManagerService, SheetPermissionInterceptorBaseController, whenSheetEditorFocused, getCurrentRangeDisable$, APPLY_TYPE, IAutoFillService, getAutoFillRepeatRange } from "@univerjs/sheets-ui";
|
|
8
|
+
import { Subject, BehaviorSubject, debounceTime } from "rxjs";
|
|
9
|
+
import require$$0, { forwardRef, useRef, createElement, useState, useMemo, useEffect } from "react";
|
|
12
10
|
import cs from "clsx";
|
|
13
11
|
import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
|
|
14
12
|
import { IMessageService, useObservable, useEvent, RangeSelector, ISidebarService, KeyCode, MetaKeys, MenuItemType, MenuPosition, getMenuHiddenObservable, MenuGroup, ComponentManager, IShortcutService, IMenuService } from "@univerjs/ui";
|
|
15
13
|
import { deserializeRangeWithSheet, serializeRangeWithSheet, IDefinedNamesService, serializeRangeToRefString, serializeRange } from "@univerjs/engine-formula";
|
|
14
|
+
import { SetSelectionsOperation, SetWorksheetActiveOperation, SheetInterceptorService, getSheetCommandTarget, SheetsSelectionsService, RemoveSheetCommand, INTERCEPTOR_POINT, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetRangeValuesCommand, ClearSelectionContentCommand, ClearSelectionAllCommand, ClearSelectionFormatCommand, WorkbookViewPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetInsertHyperlinkPermission, RangeProtectionPermissionEditPoint, WorkbookCopyPermission, WorksheetCopyPermission, WorksheetSetCellValuePermission } from "@univerjs/sheets";
|
|
15
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
16
16
|
import { DOC_HYPER_LINK_PLUGIN } from "@univerjs/docs-hyper-link";
|
|
17
17
|
import { getPlainTextFormDocument } from "@univerjs/docs";
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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();
|
|
18
|
+
var LinkType = /* @__PURE__ */ ((LinkType2) => (LinkType2.link = "link", LinkType2.range = "range", LinkType2.sheet = "gid", LinkType2.definedName = "rangeid", LinkType2))(LinkType || {});
|
|
19
|
+
const _SheetsHyperLinkSidePanelService = class _SheetsHyperLinkSidePanelService extends Disposable {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
__publicField(this, "_customHyperLinks", /* @__PURE__ */ new Map());
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this._sheetInterceptorService.interceptCommand({
|
|
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)
|
|
35
|
-
return { redos: [], undos: [] };
|
|
36
|
-
const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a14 = workbook.getActiveSheet()) == null ? void 0 : _a14.getSheetId());
|
|
37
|
-
if (!subUnitId)
|
|
38
|
-
return { redos: [], undos: [] };
|
|
39
|
-
const links = this._hyperLinkModel.getSubUnit(unitId, subUnitId), redos = links.map((link) => ({
|
|
40
|
-
id: RemoveHyperLinkMutation.id,
|
|
41
|
-
params: {
|
|
42
|
-
unitId,
|
|
43
|
-
subUnitId,
|
|
44
|
-
id: link.id
|
|
45
|
-
}
|
|
46
|
-
})), undos = links.map((link) => ({
|
|
47
|
-
id: AddHyperLinkMutation.id,
|
|
48
|
-
params: {
|
|
49
|
-
unitId,
|
|
50
|
-
subUnitId,
|
|
51
|
-
link
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
return { redos, undos };
|
|
55
|
-
}
|
|
56
|
-
return { redos: [], undos: [] };
|
|
57
|
-
}, "getMutations")
|
|
58
|
-
})
|
|
59
|
-
);
|
|
24
|
+
isBuiltInLinkType(type) {
|
|
25
|
+
return !!LinkType[type];
|
|
60
26
|
}
|
|
61
|
-
|
|
62
|
-
|
|
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();
|
|
27
|
+
getOptions() {
|
|
28
|
+
return Array.from(this._customHyperLinks.values()).map(({ option }) => option);
|
|
76
29
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var _a14;
|
|
80
|
-
const workbook = this._context.unit, unitId = workbook.getUnitId(), subUnitId = (_a14 = workbook.getActiveSheet()) == null ? void 0 : _a14.getSheetId();
|
|
81
|
-
if (!subUnitId) {
|
|
82
|
-
console.warn("No active sheet found");
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
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();
|
|
90
|
-
}));
|
|
30
|
+
findCustomHyperLink(link) {
|
|
31
|
+
return Array.from(this._customHyperLinks.values()).find((item) => item.match(link));
|
|
91
32
|
}
|
|
92
|
-
|
|
93
|
-
|
|
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();
|
|
33
|
+
registerCustomHyperLink(customHyperLink) {
|
|
34
|
+
this._customHyperLinks.set(customHyperLink.type, customHyperLink);
|
|
102
35
|
}
|
|
103
|
-
|
|
104
|
-
this.
|
|
105
|
-
this._sheetInterceptorService.intercept(
|
|
106
|
-
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
107
|
-
{
|
|
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
|
-
interceptorStyle: {
|
|
113
|
-
ul: {
|
|
114
|
-
s: BooleanNumber.TRUE
|
|
115
|
-
},
|
|
116
|
-
cl: {
|
|
117
|
-
rgb: styleSheet.blue500
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
} : cell);
|
|
121
|
-
}, "handler"),
|
|
122
|
-
priority: 100
|
|
123
|
-
}
|
|
124
|
-
)
|
|
125
|
-
);
|
|
36
|
+
getCustomHyperLink(type) {
|
|
37
|
+
return this._customHyperLinks.get(type);
|
|
126
38
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
39
|
+
removeCustomHyperLink(type) {
|
|
40
|
+
const { _customHyperLinks } = this;
|
|
41
|
+
_customHyperLinks.delete(type);
|
|
42
|
+
}
|
|
43
|
+
dispose() {
|
|
44
|
+
super.dispose(), this._customHyperLinks.clear();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
__name(_SheetsHyperLinkSidePanelService, "SheetsHyperLinkSidePanelService");
|
|
48
|
+
let SheetsHyperLinkSidePanelService = _SheetsHyperLinkSidePanelService;
|
|
134
49
|
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
135
50
|
/**
|
|
136
51
|
* @license React
|
|
@@ -249,11 +164,11 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width:
|
|
|
249
164
|
}));
|
|
250
165
|
});
|
|
251
166
|
Xlsx.displayName = "Xlsx";
|
|
252
|
-
var __defProp$
|
|
253
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
167
|
+
var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
168
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
254
169
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
255
|
-
return kind && result && __defProp$
|
|
256
|
-
}, "__decorateClass$
|
|
170
|
+
return kind && result && __defProp$b(target, key, result), result;
|
|
171
|
+
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b");
|
|
257
172
|
function getContainRange(range, worksheet) {
|
|
258
173
|
const mergedCells = worksheet.getMergeData(), maxCol = worksheet.getMaxColumns() - 1, maxRow = worksheet.getMaxRows() - 1;
|
|
259
174
|
if (maxCol < range.endColumn && (range.endColumn = maxCol), maxRow < range.endRow && (range.endRow = maxRow), range.rangeType === RANGE_TYPE.COLUMN || RANGE_TYPE.ROW)
|
|
@@ -264,10 +179,10 @@ function getContainRange(range, worksheet) {
|
|
|
264
179
|
}), Rectangle.realUnion(range, ...relativeCells);
|
|
265
180
|
}
|
|
266
181
|
__name(getContainRange, "getContainRange");
|
|
267
|
-
var
|
|
268
|
-
let SheetsHyperLinkResolverService = (
|
|
269
|
-
constructor(_univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService) {
|
|
270
|
-
this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService;
|
|
182
|
+
var _a;
|
|
183
|
+
let SheetsHyperLinkResolverService = (_a = class {
|
|
184
|
+
constructor(_urlHandler, _univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService) {
|
|
185
|
+
this._urlHandler = _urlHandler, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService;
|
|
271
186
|
}
|
|
272
187
|
_getURLName(params) {
|
|
273
188
|
var _a14;
|
|
@@ -409,15 +324,18 @@ let SheetsHyperLinkResolverService = (_a4 = class {
|
|
|
409
324
|
return this._definedNamesService.focusRange(unitId, rangeid), !0;
|
|
410
325
|
}
|
|
411
326
|
async navigateToOtherWebsite(url) {
|
|
327
|
+
var _a14;
|
|
328
|
+
if ((_a14 = this._urlHandler) != null && _a14.navigateToOtherWebsite)
|
|
329
|
+
return this._urlHandler.navigateToOtherWebsite(url);
|
|
412
330
|
window.open(url, "_blank", "noopener noreferrer");
|
|
413
331
|
}
|
|
414
|
-
}, __name(
|
|
415
|
-
SheetsHyperLinkResolverService = __decorateClass$
|
|
416
|
-
__decorateParam$
|
|
417
|
-
__decorateParam$
|
|
418
|
-
__decorateParam$
|
|
419
|
-
__decorateParam$
|
|
420
|
-
__decorateParam$
|
|
332
|
+
}, __name(_a, "SheetsHyperLinkResolverService"), _a);
|
|
333
|
+
SheetsHyperLinkResolverService = __decorateClass$b([
|
|
334
|
+
__decorateParam$b(1, IUniverInstanceService),
|
|
335
|
+
__decorateParam$b(2, ICommandService),
|
|
336
|
+
__decorateParam$b(3, IDefinedNamesService),
|
|
337
|
+
__decorateParam$b(4, IMessageService),
|
|
338
|
+
__decorateParam$b(5, Inject(LocaleService))
|
|
421
339
|
], SheetsHyperLinkResolverService);
|
|
422
340
|
function isLegalLink(link) {
|
|
423
341
|
return Tools.isLegalUrl(link);
|
|
@@ -433,7 +351,13 @@ function isEmail(url) {
|
|
|
433
351
|
__name(isEmail, "isEmail");
|
|
434
352
|
function serializeUrl(urlStr) {
|
|
435
353
|
if (isLegalLink(urlStr)) {
|
|
436
|
-
const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}
|
|
354
|
+
const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`;
|
|
355
|
+
let url;
|
|
356
|
+
try {
|
|
357
|
+
url = new URL(transformedUrl);
|
|
358
|
+
} catch {
|
|
359
|
+
return urlStr;
|
|
360
|
+
}
|
|
437
361
|
return url.hostname === location.hostname && url.port === location.port && url.protocol === location.protocol && url.pathname === location.pathname && url.hash && !url.search ? url.hash : transformedUrl;
|
|
438
362
|
}
|
|
439
363
|
return urlStr;
|
|
@@ -452,41 +376,102 @@ function getCellValueOrigin(cell) {
|
|
|
452
376
|
return cell == null ? void 0 : cell.v;
|
|
453
377
|
}
|
|
454
378
|
__name(getCellValueOrigin, "getCellValueOrigin");
|
|
455
|
-
const
|
|
379
|
+
const AddHyperLinkCommand = {
|
|
380
|
+
type: CommandType.COMMAND,
|
|
381
|
+
id: "sheets.command.add-hyper-link",
|
|
382
|
+
async handler(accessor, params) {
|
|
383
|
+
if (!params)
|
|
384
|
+
return !1;
|
|
385
|
+
const sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), { unitId, subUnitId, link } = params, { redos, undos } = sheetInterceptorService.onCommandExecute({
|
|
386
|
+
id: AddHyperLinkCommand.id,
|
|
387
|
+
params
|
|
388
|
+
}), redo = {
|
|
389
|
+
id: AddHyperLinkMutation.id,
|
|
390
|
+
params
|
|
391
|
+
}, undo = {
|
|
392
|
+
id: RemoveHyperLinkMutation.id,
|
|
393
|
+
params: {
|
|
394
|
+
unitId,
|
|
395
|
+
subUnitId,
|
|
396
|
+
id: link.id
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
return (await sequenceExecuteAsync([redo, ...redos], commandService)).result ? (undoRedoService.pushUndoRedo({
|
|
400
|
+
redoMutations: [redo, ...redos],
|
|
401
|
+
undoMutations: [undo, ...undos],
|
|
402
|
+
unitID: unitId
|
|
403
|
+
}), !0) : !1;
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
function getHyperLinkContent(link) {
|
|
407
|
+
const { row, column, id, ...content } = link;
|
|
408
|
+
return content;
|
|
409
|
+
}
|
|
410
|
+
__name(getHyperLinkContent, "getHyperLinkContent");
|
|
411
|
+
const UpdateHyperLinkCommand = {
|
|
412
|
+
type: CommandType.COMMAND,
|
|
413
|
+
id: "sheets.command.update-hyper-link",
|
|
414
|
+
async handler(accessor, params) {
|
|
415
|
+
if (!params)
|
|
416
|
+
return !1;
|
|
417
|
+
const sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params, link = model.getHyperLink(unitId, subUnitId, id);
|
|
418
|
+
if (!link)
|
|
419
|
+
return !1;
|
|
420
|
+
const { redos, undos } = sheetInterceptorService.onCommandExecute({
|
|
421
|
+
id: UpdateHyperLinkCommand.id,
|
|
422
|
+
params
|
|
423
|
+
}), redo = {
|
|
424
|
+
id: UpdateHyperLinkMutation.id,
|
|
425
|
+
params
|
|
426
|
+
}, undo = {
|
|
427
|
+
id: UpdateHyperLinkMutation.id,
|
|
428
|
+
params: {
|
|
429
|
+
unitId,
|
|
430
|
+
subUnitId,
|
|
431
|
+
id,
|
|
432
|
+
payload: getHyperLinkContent(link)
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
return (await sequenceExecuteAsync([redo, ...redos], commandService)).result ? (undoRedoService.pushUndoRedo({
|
|
436
|
+
redoMutations: [redo, ...redos],
|
|
437
|
+
undoMutations: [undo, ...undos],
|
|
438
|
+
unitID: unitId
|
|
439
|
+
}), !0) : !1;
|
|
440
|
+
}
|
|
441
|
+
}, cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
456
442
|
cellLinkEditButtons
|
|
457
443
|
}, CellLinkEdit = /* @__PURE__ */ __name(() => {
|
|
458
444
|
var _a14;
|
|
459
|
-
const [id, setId] = useState(""), [display, setDisplay] = useState(""), [type, setType] = useState(
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
445
|
+
const [id, setId] = useState(""), [display, setDisplay] = useState(""), [type, setType] = useState(LinkType.link), [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), sidePanelService = useDependency(SheetsHyperLinkSidePanelService), sidePanelOptions = useMemo(() => sidePanelService.getOptions(), [sidePanelService]), customHyperLinkSidePanel = useMemo(() => {
|
|
446
|
+
if (!sidePanelService.isBuiltInLinkType(type))
|
|
447
|
+
return sidePanelService.getCustomHyperLink(type);
|
|
448
|
+
}, [sidePanelService, type]), [showError, setShowError] = useState(!1), setByPayload = useRef(!1);
|
|
463
449
|
useEffect(() => {
|
|
464
450
|
var _a15, _b, _c;
|
|
465
451
|
if ((editing == null ? void 0 : editing.row) !== void 0 && editing.column !== void 0) {
|
|
466
452
|
const link = hyperLinkModel.getHyperLinkByLocationSync(editing.unitId, editing.subUnitId, editing.row, editing.column);
|
|
467
453
|
if (link) {
|
|
454
|
+
setId(link.id);
|
|
455
|
+
const customLink = sidePanelService.findCustomHyperLink(link);
|
|
456
|
+
if (customLink) {
|
|
457
|
+
const customLinkInfo = customLink.convert(link);
|
|
458
|
+
setType(customLinkInfo.type), setPayload(customLinkInfo.payload), setDisplay(customLinkInfo.display);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
setDisplay(link.display);
|
|
468
462
|
const linkInfo = resolverService.parseHyperLink(link.payload);
|
|
469
|
-
if (
|
|
470
|
-
setType(
|
|
471
|
-
"link"
|
|
472
|
-
/* link */
|
|
473
|
-
), setPayload(linkInfo.url), linkInfo.url === link.display && (setByPayload.current = !0);
|
|
463
|
+
if (linkInfo.type === "outer") {
|
|
464
|
+
setType(LinkType.link), setPayload(linkInfo.url), linkInfo.url === link.display && (setByPayload.current = !0);
|
|
474
465
|
return;
|
|
475
466
|
} else {
|
|
476
467
|
const params = linkInfo.searchObj;
|
|
477
468
|
if (params.rangeid) {
|
|
478
|
-
setType(
|
|
479
|
-
"rangeid"
|
|
480
|
-
/* definedName */
|
|
481
|
-
), setPayload(params.rangeid);
|
|
469
|
+
setType(LinkType.definedName), setPayload(params.rangeid);
|
|
482
470
|
return;
|
|
483
471
|
}
|
|
484
472
|
if (params.range) {
|
|
485
473
|
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(
|
|
487
|
-
"range"
|
|
488
|
-
/* range */
|
|
489
|
-
), params.range === ERROR_RANGE)
|
|
474
|
+
if (setType(LinkType.range), params.range === ERROR_RANGE)
|
|
490
475
|
setPayload("");
|
|
491
476
|
else {
|
|
492
477
|
const payload2 = serializeRangeWithSheet(sheetName, deserializeRangeWithSheet(params.range).range);
|
|
@@ -495,47 +480,35 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
|
495
480
|
return;
|
|
496
481
|
}
|
|
497
482
|
if (params.gid) {
|
|
498
|
-
setType(
|
|
499
|
-
"gid"
|
|
500
|
-
/* sheet */
|
|
501
|
-
), setPayload(params.gid);
|
|
483
|
+
setType(LinkType.sheet), setPayload(params.gid);
|
|
502
484
|
return;
|
|
503
485
|
}
|
|
504
486
|
}
|
|
505
487
|
}
|
|
506
488
|
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(
|
|
508
|
-
"link"
|
|
509
|
-
/* link */
|
|
510
|
-
), setPayload(""), setDisplay((cellValue != null ? cellValue : "").toString()), setId("");
|
|
489
|
+
setType(LinkType.link), setPayload(""), setDisplay((cellValue != null ? cellValue : "").toString()), setId("");
|
|
511
490
|
return;
|
|
512
491
|
}
|
|
513
|
-
setType(
|
|
514
|
-
"link"
|
|
515
|
-
/* link */
|
|
516
|
-
), setPayload(""), setDisplay(""), setId("");
|
|
492
|
+
setType(LinkType.link), setPayload(""), setDisplay(""), setId("");
|
|
517
493
|
}, [editing, hyperLinkModel, resolverService, univerInstanceService]);
|
|
518
494
|
const payloadInitial = useMemo(() => payload, [type]), linkTypeOptions = [
|
|
519
495
|
{
|
|
520
496
|
label: localeService.t("hyperLink.form.link"),
|
|
521
|
-
value:
|
|
522
|
-
/* link */
|
|
497
|
+
value: LinkType.link
|
|
523
498
|
},
|
|
524
499
|
{
|
|
525
500
|
label: localeService.t("hyperLink.form.range"),
|
|
526
|
-
value:
|
|
527
|
-
/* range */
|
|
501
|
+
value: LinkType.range
|
|
528
502
|
},
|
|
529
503
|
{
|
|
530
504
|
label: localeService.t("hyperLink.form.worksheet"),
|
|
531
|
-
value:
|
|
532
|
-
/* sheet */
|
|
505
|
+
value: LinkType.sheet
|
|
533
506
|
},
|
|
534
507
|
{
|
|
535
508
|
label: localeService.t("hyperLink.form.definedName"),
|
|
536
|
-
value:
|
|
537
|
-
|
|
538
|
-
|
|
509
|
+
value: LinkType.definedName
|
|
510
|
+
},
|
|
511
|
+
...sidePanelOptions
|
|
539
512
|
], workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
540
513
|
if (!workbook)
|
|
541
514
|
return;
|
|
@@ -543,9 +516,9 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
|
543
516
|
label: value.name,
|
|
544
517
|
value: value.id
|
|
545
518
|
})), formatUrl = /* @__PURE__ */ __name((type2, payload2) => {
|
|
546
|
-
if (type2 ===
|
|
519
|
+
if (type2 === LinkType.link)
|
|
547
520
|
return serializeUrl(payload2);
|
|
548
|
-
if (type2 ===
|
|
521
|
+
if (type2 === LinkType.range) {
|
|
549
522
|
const info = deserializeRangeWithSheet(payload2), worksheet = workbook.getSheetBySheetName(info.sheetName);
|
|
550
523
|
if (worksheet)
|
|
551
524
|
return `#gid=${worksheet.getSheetId()}&range=${serializeRange(info.range)}`;
|
|
@@ -623,7 +596,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
|
623
596
|
}, "onChange")
|
|
624
597
|
}
|
|
625
598
|
) }),
|
|
626
|
-
type ===
|
|
599
|
+
type === LinkType.link && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
627
600
|
FormLayout,
|
|
628
601
|
{
|
|
629
602
|
error: showError ? payload ? isLegalLink(payload) ? "" : localeService.t("hyperLink.form.linkError") : localeService.t("hyperLink.form.inputError") : "",
|
|
@@ -639,7 +612,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
|
639
612
|
)
|
|
640
613
|
}
|
|
641
614
|
),
|
|
642
|
-
type ===
|
|
615
|
+
type === LinkType.range && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
643
616
|
RangeSelector,
|
|
644
617
|
{
|
|
645
618
|
openForSheetUnitId: workbook.getUnitId(),
|
|
@@ -649,7 +622,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
|
649
622
|
onChange: handleRangeChange
|
|
650
623
|
}
|
|
651
624
|
) }),
|
|
652
|
-
type ===
|
|
625
|
+
type === LinkType.sheet && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
653
626
|
Select,
|
|
654
627
|
{
|
|
655
628
|
options: sheetsOption,
|
|
@@ -662,7 +635,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
|
662
635
|
}, "onChange")
|
|
663
636
|
}
|
|
664
637
|
) }),
|
|
665
|
-
type ===
|
|
638
|
+
type === LinkType.definedName && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
666
639
|
Select,
|
|
667
640
|
{
|
|
668
641
|
options: definedNames,
|
|
@@ -675,6 +648,20 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
|
675
648
|
}, "onChange")
|
|
676
649
|
}
|
|
677
650
|
) }),
|
|
651
|
+
(customHyperLinkSidePanel == null ? void 0 : customHyperLinkSidePanel.Form) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
652
|
+
customHyperLinkSidePanel.Form,
|
|
653
|
+
{
|
|
654
|
+
linkId: id,
|
|
655
|
+
payload,
|
|
656
|
+
display,
|
|
657
|
+
showError,
|
|
658
|
+
setByPayload,
|
|
659
|
+
setDisplay: /* @__PURE__ */ __name((newLink) => {
|
|
660
|
+
setDisplay(newLink), setByPayload.current = !0;
|
|
661
|
+
}, "setDisplay"),
|
|
662
|
+
setPayload
|
|
663
|
+
}
|
|
664
|
+
),
|
|
678
665
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkEditButtons, children: [
|
|
679
666
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
680
667
|
Button,
|
|
@@ -694,7 +681,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
|
694
681
|
type: "primary",
|
|
695
682
|
style: { marginLeft: 8 },
|
|
696
683
|
onClick: /* @__PURE__ */ __name(async () => {
|
|
697
|
-
if (!display || !payload || type ===
|
|
684
|
+
if (!display || !payload || type === LinkType.link && !isLegalLink(payload)) {
|
|
698
685
|
setShowError(!0);
|
|
699
686
|
return;
|
|
700
687
|
}
|
|
@@ -755,6 +742,55 @@ const OpenHyperLinkSidebarOperation = {
|
|
|
755
742
|
const commandService = accessor.get(ICommandService);
|
|
756
743
|
return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkSidebarOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
|
|
757
744
|
}
|
|
745
|
+
}, RemoveHyperLinkCommand = {
|
|
746
|
+
type: CommandType.COMMAND,
|
|
747
|
+
id: "sheets.command.remove-hyper-link",
|
|
748
|
+
async handler(accessor, params) {
|
|
749
|
+
if (!params)
|
|
750
|
+
return !1;
|
|
751
|
+
const sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params, link = model.getHyperLink(unitId, subUnitId, id), { redos, undos } = sheetInterceptorService.onCommandExecute({
|
|
752
|
+
id: RemoveHyperLinkCommand.id,
|
|
753
|
+
params
|
|
754
|
+
}), redo = {
|
|
755
|
+
id: RemoveHyperLinkMutation.id,
|
|
756
|
+
params
|
|
757
|
+
}, undo = {
|
|
758
|
+
id: AddHyperLinkMutation.id,
|
|
759
|
+
params: {
|
|
760
|
+
unitId,
|
|
761
|
+
subUnitId,
|
|
762
|
+
link
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
return (await sequenceExecuteAsync([redo, ...redos], commandService)).result ? (undoRedoService.pushUndoRedo({
|
|
766
|
+
redoMutations: [redo, ...redos],
|
|
767
|
+
undoMutations: [undo, ...undos],
|
|
768
|
+
unitID: unitId
|
|
769
|
+
}), !0) : !1;
|
|
770
|
+
}
|
|
771
|
+
}, CancelHyperLinkCommand = {
|
|
772
|
+
type: CommandType.COMMAND,
|
|
773
|
+
id: "sheets.command.cancel-hyper-link",
|
|
774
|
+
async handler(accessor, params) {
|
|
775
|
+
if (!params)
|
|
776
|
+
return !1;
|
|
777
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params, link = model.getHyperLink(unitId, subUnitId, id), redo = {
|
|
778
|
+
id: RemoveHyperLinkMutation.id,
|
|
779
|
+
params
|
|
780
|
+
}, undo = {
|
|
781
|
+
id: AddHyperLinkMutation.id,
|
|
782
|
+
params: {
|
|
783
|
+
unitId,
|
|
784
|
+
subUnitId,
|
|
785
|
+
link
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
return (await sequenceExecuteAsync([redo], commandService)).result ? (undoRedoService.pushUndoRedo({
|
|
789
|
+
redoMutations: [redo],
|
|
790
|
+
undoMutations: [undo],
|
|
791
|
+
unitID: unitId
|
|
792
|
+
}), !0) : !1;
|
|
793
|
+
}
|
|
758
794
|
}, 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
795
|
cellLink,
|
|
760
796
|
cellLinkType,
|
|
@@ -849,14 +885,14 @@ const OpenHyperLinkSidebarOperation = {
|
|
|
849
885
|
] });
|
|
850
886
|
}, "CellLinkPopup");
|
|
851
887
|
CellLinkPopup.componentKey = "univer.sheet.cell-link-popup";
|
|
852
|
-
var __defProp$
|
|
853
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
888
|
+
var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
889
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
854
890
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
855
|
-
return kind && result && __defProp$
|
|
856
|
-
}, "__decorateClass$
|
|
891
|
+
return kind && result && __defProp$a(target, key, result), result;
|
|
892
|
+
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a");
|
|
857
893
|
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
|
|
859
|
-
let SheetsHyperLinkPopupService = (
|
|
894
|
+
var _a2;
|
|
895
|
+
let SheetsHyperLinkPopupService = (_a2 = class extends Disposable {
|
|
860
896
|
constructor(_hyperLinkModel, _sheetCanvasPopManagerService) {
|
|
861
897
|
super();
|
|
862
898
|
__publicField(this, "_currentPopup", null);
|
|
@@ -910,77 +946,367 @@ let SheetsHyperLinkPopupService = (_a5 = class extends Disposable {
|
|
|
910
946
|
endEditing() {
|
|
911
947
|
this._currentEditing$.next(null);
|
|
912
948
|
}
|
|
913
|
-
}, __name(
|
|
914
|
-
SheetsHyperLinkPopupService = __decorateClass$
|
|
915
|
-
__decorateParam$
|
|
916
|
-
__decorateParam$
|
|
949
|
+
}, __name(_a2, "SheetsHyperLinkPopupService"), _a2);
|
|
950
|
+
SheetsHyperLinkPopupService = __decorateClass$a([
|
|
951
|
+
__decorateParam$a(0, Inject(HyperLinkModel)),
|
|
952
|
+
__decorateParam$a(1, Inject(SheetCanvasPopManagerService))
|
|
917
953
|
], SheetsHyperLinkPopupService);
|
|
918
|
-
|
|
919
|
-
|
|
954
|
+
const SHEET_HYPER_LINK_UI_PLUGIN = "SHEET_HYPER_LINK_UI_PLUGIN";
|
|
955
|
+
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
956
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
920
957
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
921
|
-
return kind && result && __defProp$
|
|
922
|
-
}, "__decorateClass$
|
|
923
|
-
let
|
|
924
|
-
constructor(
|
|
925
|
-
super()
|
|
958
|
+
return kind && result && __defProp$9(target, key, result), result;
|
|
959
|
+
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9"), _a3;
|
|
960
|
+
let SheetsHyperLinkCopyPasteController = (_a3 = class extends Disposable {
|
|
961
|
+
constructor(_sheetClipboardService, _hyperLinkModel, _injector, _resolverService) {
|
|
962
|
+
super();
|
|
963
|
+
__publicField(this, "_plainTextFilter", /* @__PURE__ */ new Set());
|
|
964
|
+
__publicField(this, "_copyInfo");
|
|
965
|
+
this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste(), this.disposeWithMe(() => {
|
|
966
|
+
this._plainTextFilter.clear();
|
|
967
|
+
});
|
|
926
968
|
}
|
|
927
|
-
|
|
928
|
-
this.
|
|
969
|
+
registerPlainTextFilter(filter) {
|
|
970
|
+
this._plainTextFilter.add(filter);
|
|
929
971
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
return (_b = (_a14 = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a14.getSheetBySheetId(subUnitId)) == null ? void 0 : _b.getCell(row, col);
|
|
972
|
+
removePlainTextFilter(filter) {
|
|
973
|
+
this._plainTextFilter.delete(filter);
|
|
933
974
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
975
|
+
/* If return false the process of paste text will be stop */
|
|
976
|
+
_filterPlainText(text) {
|
|
977
|
+
return Array.from(this._plainTextFilter).every((filter) => filter(text));
|
|
978
|
+
}
|
|
979
|
+
_initCopyPaste() {
|
|
980
|
+
this._sheetClipboardService.addClipboardHook({
|
|
981
|
+
id: SHEET_HYPER_LINK_UI_PLUGIN,
|
|
982
|
+
onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
|
|
983
|
+
onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
|
|
984
|
+
const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
|
|
985
|
+
return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
|
|
986
|
+
}, "onPasteCells"),
|
|
987
|
+
onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => {
|
|
988
|
+
const filterResult = this._filterPlainText(clipText);
|
|
989
|
+
if (isLegalLink(clipText) && filterResult) {
|
|
990
|
+
const text = serializeUrl(clipText), { range, unitId, subUnitId } = pasteTo, { ranges: [pasteToRange], mapFunc } = virtualizeDiscreteRanges([range]), redos = [], undos = [];
|
|
991
|
+
return Range.foreach(pasteToRange, (originRow, originCol) => {
|
|
992
|
+
const { row, col: column } = mapFunc(originRow, originCol), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
|
|
993
|
+
link && redos.push({
|
|
994
|
+
id: RemoveHyperLinkMutation.id,
|
|
995
|
+
params: {
|
|
996
|
+
unitId,
|
|
997
|
+
subUnitId,
|
|
998
|
+
id: link.id
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
const newId = Tools.generateRandomId();
|
|
1002
|
+
redos.push({
|
|
1003
|
+
id: AddHyperLinkMutation.id,
|
|
1004
|
+
params: {
|
|
1005
|
+
unitId,
|
|
1006
|
+
subUnitId,
|
|
1007
|
+
link: {
|
|
1008
|
+
id: newId,
|
|
1009
|
+
row,
|
|
1010
|
+
column,
|
|
1011
|
+
payload: text
|
|
950
1012
|
}
|
|
951
1013
|
}
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
undos
|
|
960
|
-
id:
|
|
961
|
-
params:
|
|
962
|
-
|
|
963
|
-
|
|
1014
|
+
}), undos.push({
|
|
1015
|
+
id: RemoveHyperLinkMutation.id,
|
|
1016
|
+
params: {
|
|
1017
|
+
unitId,
|
|
1018
|
+
subUnitId,
|
|
1019
|
+
id: newId
|
|
1020
|
+
}
|
|
1021
|
+
}), link && undos.push({
|
|
1022
|
+
id: AddHyperLinkMutation.id,
|
|
1023
|
+
params: {
|
|
1024
|
+
unitId,
|
|
1025
|
+
subUnitId,
|
|
1026
|
+
link
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
}), { redos, undos };
|
|
964
1030
|
}
|
|
965
|
-
return {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}, "getMutations")
|
|
970
|
-
}));
|
|
1031
|
+
return { undos: [], redos: [] };
|
|
1032
|
+
}, "onPastePlainText"),
|
|
1033
|
+
priority: 99
|
|
1034
|
+
});
|
|
971
1035
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1036
|
+
_collect(unitId, subUnitId, range) {
|
|
1037
|
+
const matrix = new ObjectMatrix();
|
|
1038
|
+
this._copyInfo = {
|
|
1039
|
+
unitId,
|
|
1040
|
+
subUnitId,
|
|
1041
|
+
matrix
|
|
1042
|
+
};
|
|
1043
|
+
const discreteRange = this._injector.invoke((accessor) => rangeToDiscreteRange(range, accessor, unitId, subUnitId));
|
|
1044
|
+
if (!discreteRange)
|
|
1045
|
+
return;
|
|
1046
|
+
const { rows, cols } = discreteRange;
|
|
1047
|
+
rows.forEach((row, rowIndex) => {
|
|
1048
|
+
cols.forEach((col, colIndex) => {
|
|
1049
|
+
var _a14;
|
|
1050
|
+
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1051
|
+
matrix.setValue(rowIndex, colIndex, (_a14 = link == null ? void 0 : link.id) != null ? _a14 : "");
|
|
1052
|
+
});
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
// eslint-disable-next-line max-lines-per-function
|
|
1056
|
+
_generateMutations(pastedRange, copyInfo) {
|
|
1057
|
+
if (!this._copyInfo)
|
|
1058
|
+
return { redos: [], undos: [] };
|
|
1059
|
+
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange)
|
|
1060
|
+
return { redos: [], undos: [] };
|
|
1061
|
+
if ([
|
|
1062
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
|
|
1063
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
|
|
1064
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
|
|
1065
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
|
|
1066
|
+
].includes(
|
|
1067
|
+
copyInfo.pasteType
|
|
1068
|
+
))
|
|
1069
|
+
return { redos: [], undos: [] };
|
|
1070
|
+
const { unitId, subUnitId } = this._copyInfo, redos = [], undos = [], { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
|
|
1071
|
+
return getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
|
|
1072
|
+
var _a14;
|
|
1073
|
+
(_a14 = this._copyInfo) == null || _a14.matrix.forValue((row, col, ruleId) => {
|
|
1074
|
+
const range = Rectangle.getPositionRange(
|
|
1075
|
+
{
|
|
1076
|
+
startRow: row,
|
|
1077
|
+
endRow: row,
|
|
1078
|
+
startColumn: col,
|
|
1079
|
+
endColumn: col
|
|
1080
|
+
},
|
|
1081
|
+
startRange
|
|
1082
|
+
), 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();
|
|
1083
|
+
currentLink && redos.push({
|
|
1084
|
+
id: RemoveHyperLinkMutation.id,
|
|
1085
|
+
params: {
|
|
1086
|
+
unitId: copyInfo.unitId,
|
|
1087
|
+
subUnitId: copyInfo.subUnitId,
|
|
1088
|
+
id: currentLink.id
|
|
1089
|
+
}
|
|
1090
|
+
}), oldLink && (redos.push({
|
|
1091
|
+
id: AddHyperLinkMutation.id,
|
|
1092
|
+
params: {
|
|
1093
|
+
unitId: copyInfo.unitId,
|
|
1094
|
+
subUnitId: copyInfo.subUnitId,
|
|
1095
|
+
link: {
|
|
1096
|
+
...oldLink,
|
|
1097
|
+
id,
|
|
1098
|
+
row: startRow,
|
|
1099
|
+
column: startColumn
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}), undos.push({
|
|
1103
|
+
id: RemoveHyperLinkMutation.id,
|
|
1104
|
+
params: {
|
|
1105
|
+
unitId: copyInfo.unitId,
|
|
1106
|
+
subUnitId: copyInfo.subUnitId,
|
|
1107
|
+
id
|
|
1108
|
+
}
|
|
1109
|
+
})), currentLink && undos.push({
|
|
1110
|
+
id: AddHyperLinkMutation.id,
|
|
1111
|
+
params: {
|
|
1112
|
+
unitId: copyInfo.unitId,
|
|
1113
|
+
subUnitId: copyInfo.subUnitId,
|
|
1114
|
+
link: currentLink
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
});
|
|
1118
|
+
}), { redos, undos };
|
|
1119
|
+
}
|
|
1120
|
+
}, __name(_a3, "SheetsHyperLinkCopyPasteController"), _a3);
|
|
1121
|
+
SheetsHyperLinkCopyPasteController = __decorateClass$9([
|
|
1122
|
+
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkCopyPasteController),
|
|
1123
|
+
__decorateParam$9(0, ISheetClipboardService),
|
|
1124
|
+
__decorateParam$9(1, Inject(HyperLinkModel)),
|
|
1125
|
+
__decorateParam$9(2, Inject(Injector)),
|
|
1126
|
+
__decorateParam$9(3, Inject(SheetsHyperLinkResolverService))
|
|
1127
|
+
], SheetsHyperLinkCopyPasteController);
|
|
1128
|
+
var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1129
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1130
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1131
|
+
return kind && result && __defProp$8(target, key, result), result;
|
|
1132
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a4;
|
|
1133
|
+
let SheetsHyperLinkRemoveSheetController = (_a4 = class extends Disposable {
|
|
1134
|
+
constructor(_sheetInterceptorService, _univerInstanceService, _hyperLinkModel) {
|
|
1135
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._hyperLinkModel = _hyperLinkModel, this._initSheetChange();
|
|
1136
|
+
}
|
|
1137
|
+
_initSheetChange() {
|
|
1138
|
+
this.disposeWithMe(
|
|
1139
|
+
this._sheetInterceptorService.interceptCommand({
|
|
1140
|
+
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
1141
|
+
var _a14;
|
|
1142
|
+
if (commandInfo.id === RemoveSheetCommand.id) {
|
|
1143
|
+
const params = commandInfo.params, workbook = params.unitId ? this._univerInstanceService.getUnit(params.unitId) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
1144
|
+
if (!workbook)
|
|
1145
|
+
return { redos: [], undos: [] };
|
|
1146
|
+
const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a14 = workbook.getActiveSheet()) == null ? void 0 : _a14.getSheetId());
|
|
1147
|
+
if (!subUnitId)
|
|
1148
|
+
return { redos: [], undos: [] };
|
|
1149
|
+
const links = this._hyperLinkModel.getSubUnit(unitId, subUnitId), redos = links.map((link) => ({
|
|
1150
|
+
id: RemoveHyperLinkMutation.id,
|
|
1151
|
+
params: {
|
|
1152
|
+
unitId,
|
|
1153
|
+
subUnitId,
|
|
1154
|
+
id: link.id
|
|
1155
|
+
}
|
|
1156
|
+
})), undos = links.map((link) => ({
|
|
1157
|
+
id: AddHyperLinkMutation.id,
|
|
1158
|
+
params: {
|
|
1159
|
+
unitId,
|
|
1160
|
+
subUnitId,
|
|
1161
|
+
link
|
|
1162
|
+
}
|
|
1163
|
+
}));
|
|
1164
|
+
return { redos, undos };
|
|
1165
|
+
}
|
|
1166
|
+
return { redos: [], undos: [] };
|
|
1167
|
+
}, "getMutations")
|
|
1168
|
+
})
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
}, __name(_a4, "SheetsHyperLinkRemoveSheetController"), _a4);
|
|
1172
|
+
SheetsHyperLinkRemoveSheetController = __decorateClass$8([
|
|
1173
|
+
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkRemoveSheetController),
|
|
1174
|
+
__decorateParam$8(0, Inject(SheetInterceptorService)),
|
|
1175
|
+
__decorateParam$8(1, IUniverInstanceService),
|
|
1176
|
+
__decorateParam$8(2, Inject(HyperLinkModel))
|
|
1177
|
+
], SheetsHyperLinkRemoveSheetController);
|
|
1178
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1179
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1180
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1181
|
+
return kind && result && __defProp$7(target, key, result), result;
|
|
1182
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a5;
|
|
1183
|
+
let SheetsHyperLinkRenderController = (_a5 = class extends Disposable {
|
|
1184
|
+
constructor(_context, _hyperLinkModel, _sheetSkeletonManagerService, _renderManagerService) {
|
|
1185
|
+
super(), this._context = _context, this._hyperLinkModel = _hyperLinkModel, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._renderManagerService = _renderManagerService, this._initSkeletonChange();
|
|
1186
|
+
}
|
|
1187
|
+
_initSkeletonChange() {
|
|
1188
|
+
const markSkeletonDirty = /* @__PURE__ */ __name(() => {
|
|
1189
|
+
var _a14;
|
|
1190
|
+
const workbook = this._context.unit, unitId = workbook.getUnitId(), subUnitId = (_a14 = workbook.getActiveSheet()) == null ? void 0 : _a14.getSheetId();
|
|
1191
|
+
if (!subUnitId) {
|
|
1192
|
+
console.warn("No active sheet found");
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
const skeleton = this._sheetSkeletonManagerService.getOrCreateSkeleton({ sheetId: subUnitId }), currentRender = this._renderManagerService.getRenderById(unitId);
|
|
1196
|
+
skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
|
|
1197
|
+
}, "markSkeletonDirty");
|
|
1198
|
+
this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(debounceTime(16)).subscribe(() => {
|
|
1199
|
+
markSkeletonDirty();
|
|
1200
|
+
}));
|
|
1201
|
+
}
|
|
1202
|
+
}, __name(_a5, "SheetsHyperLinkRenderController"), _a5);
|
|
1203
|
+
SheetsHyperLinkRenderController = __decorateClass$7([
|
|
1204
|
+
__decorateParam$7(1, Inject(HyperLinkModel)),
|
|
1205
|
+
__decorateParam$7(2, Inject(SheetSkeletonManagerService)),
|
|
1206
|
+
__decorateParam$7(3, IRenderManagerService)
|
|
1207
|
+
], SheetsHyperLinkRenderController);
|
|
1208
|
+
var _a6;
|
|
1209
|
+
let SheetsHyperLinkRenderManagerController = (_a6 = class extends Disposable {
|
|
1210
|
+
constructor(_sheetInterceptorService, _hyperLinkModel, _themeService) {
|
|
1211
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._hyperLinkModel = _hyperLinkModel, this._themeService = _themeService, this._initViewModelIntercept();
|
|
1212
|
+
}
|
|
1213
|
+
_initViewModelIntercept() {
|
|
1214
|
+
this.disposeWithMe(
|
|
1215
|
+
this._sheetInterceptorService.intercept(
|
|
1216
|
+
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
1217
|
+
{
|
|
1218
|
+
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
1219
|
+
const { row, col, unitId, subUnitId } = pos, link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col), styleSheet = this._themeService.getCurrentTheme();
|
|
1220
|
+
return next(link ? {
|
|
1221
|
+
...cell,
|
|
1222
|
+
interceptorStyle: {
|
|
1223
|
+
ul: {
|
|
1224
|
+
s: BooleanNumber.TRUE
|
|
1225
|
+
},
|
|
1226
|
+
cl: {
|
|
1227
|
+
rgb: styleSheet.blue500
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
} : cell);
|
|
1231
|
+
}, "handler"),
|
|
1232
|
+
priority: 100
|
|
1233
|
+
}
|
|
1234
|
+
)
|
|
1235
|
+
);
|
|
1236
|
+
}
|
|
1237
|
+
}, __name(_a6, "SheetsHyperLinkRenderManagerController"), _a6);
|
|
1238
|
+
SheetsHyperLinkRenderManagerController = __decorateClass$7([
|
|
1239
|
+
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkRenderManagerController),
|
|
1240
|
+
__decorateParam$7(0, Inject(SheetInterceptorService)),
|
|
1241
|
+
__decorateParam$7(1, Inject(HyperLinkModel)),
|
|
1242
|
+
__decorateParam$7(2, Inject(ThemeService))
|
|
1243
|
+
], SheetsHyperLinkRenderManagerController);
|
|
1244
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1245
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1246
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1247
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
1248
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a7;
|
|
1249
|
+
let SheetHyperLinkSetRangeController = (_a7 = class extends Disposable {
|
|
1250
|
+
constructor(_sheetInterceptorService, _injector, _hyperLinkModel, _selectionManagerService, _univerInstanceService, _editorBridgeService) {
|
|
1251
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._injector = _injector, this._hyperLinkModel = _hyperLinkModel, this._selectionManagerService = _selectionManagerService, this._univerInstanceService = _univerInstanceService, this._editorBridgeService = _editorBridgeService, this._initCommandInterceptor();
|
|
1252
|
+
}
|
|
1253
|
+
_initCommandInterceptor() {
|
|
1254
|
+
this._initAddHyperLinkCommandInterceptor(), this._initSetRangeValuesCommandInterceptor(), this._initUpdateHyperLinkCommandInterceptor(), this._initClearSelectionCommandInterceptor(), this._initRichTextEditorInterceptor();
|
|
1255
|
+
}
|
|
1256
|
+
_getCurrentCell(unitId, subUnitId, row, col) {
|
|
1257
|
+
var _a14, _b;
|
|
1258
|
+
return (_b = (_a14 = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a14.getSheetBySheetId(subUnitId)) == null ? void 0 : _b.getCell(row, col);
|
|
1259
|
+
}
|
|
1260
|
+
_initAddHyperLinkCommandInterceptor() {
|
|
1261
|
+
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
1262
|
+
getMutations: /* @__PURE__ */ __name((command) => {
|
|
1263
|
+
var _a14;
|
|
1264
|
+
if (command.id === AddHyperLinkCommand.id) {
|
|
1265
|
+
const params = command.params, { unitId, subUnitId, link } = params, currentCell = this._getCurrentCell(unitId, subUnitId, link.row, link.column), redoParams = {
|
|
1266
|
+
unitId,
|
|
1267
|
+
subUnitId,
|
|
1268
|
+
cellValue: {
|
|
1269
|
+
[link.row]: {
|
|
1270
|
+
[link.column]: {
|
|
1271
|
+
v: link.display,
|
|
1272
|
+
// t: CellValueType.STRING, // Setting a link to a number is still a number
|
|
1273
|
+
p: null,
|
|
1274
|
+
t: (_a14 = currentCell == null ? void 0 : currentCell.t) != null ? _a14 : void 0
|
|
1275
|
+
// Keep force string type
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
return {
|
|
1281
|
+
redos: [{
|
|
1282
|
+
id: SetRangeValuesMutation.id,
|
|
1283
|
+
params: redoParams
|
|
1284
|
+
}],
|
|
1285
|
+
undos: [{
|
|
1286
|
+
id: SetRangeValuesMutation.id,
|
|
1287
|
+
params: SetRangeValuesUndoMutationFactory(this._injector, redoParams)
|
|
1288
|
+
}]
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
return {
|
|
1292
|
+
redos: [],
|
|
1293
|
+
undos: []
|
|
1294
|
+
};
|
|
1295
|
+
}, "getMutations")
|
|
1296
|
+
}));
|
|
1297
|
+
}
|
|
1298
|
+
_initUpdateHyperLinkCommandInterceptor() {
|
|
1299
|
+
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
1300
|
+
getMutations: /* @__PURE__ */ __name((command) => {
|
|
1301
|
+
if (command.id === UpdateHyperLinkCommand.id) {
|
|
1302
|
+
const params = command.params, { unitId, subUnitId, id, payload } = params, current = this._hyperLinkModel.getHyperLink(unitId, subUnitId, id);
|
|
1303
|
+
if (current && current.display !== payload.display) {
|
|
1304
|
+
const redoParams = {
|
|
1305
|
+
unitId,
|
|
1306
|
+
subUnitId,
|
|
1307
|
+
cellValue: {
|
|
1308
|
+
[current.row]: {
|
|
1309
|
+
[current.column]: {
|
|
984
1310
|
v: payload.display,
|
|
985
1311
|
t: CellValueType.STRING,
|
|
986
1312
|
p: null
|
|
@@ -1135,24 +1461,24 @@ let SheetHyperLinkSetRangeController = (_a6 = class extends Disposable {
|
|
|
1135
1461
|
)
|
|
1136
1462
|
);
|
|
1137
1463
|
}
|
|
1138
|
-
}, __name(
|
|
1139
|
-
SheetHyperLinkSetRangeController = __decorateClass$
|
|
1464
|
+
}, __name(_a7, "SheetHyperLinkSetRangeController"), _a7);
|
|
1465
|
+
SheetHyperLinkSetRangeController = __decorateClass$6([
|
|
1140
1466
|
OnLifecycle(LifecycleStages.Starting, SheetHyperLinkSetRangeController),
|
|
1141
|
-
__decorateParam$
|
|
1142
|
-
__decorateParam$
|
|
1143
|
-
__decorateParam$
|
|
1144
|
-
__decorateParam$
|
|
1145
|
-
__decorateParam$
|
|
1146
|
-
__decorateParam$
|
|
1467
|
+
__decorateParam$6(0, Inject(SheetInterceptorService)),
|
|
1468
|
+
__decorateParam$6(1, Inject(Injector)),
|
|
1469
|
+
__decorateParam$6(2, Inject(HyperLinkModel)),
|
|
1470
|
+
__decorateParam$6(3, Inject(SheetsSelectionsService)),
|
|
1471
|
+
__decorateParam$6(4, IUniverInstanceService),
|
|
1472
|
+
__decorateParam$6(5, IEditorBridgeService)
|
|
1147
1473
|
], SheetHyperLinkSetRangeController);
|
|
1148
|
-
var __defProp$
|
|
1149
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1474
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1475
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1150
1476
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1151
|
-
return kind && result && __defProp$
|
|
1152
|
-
}, "__decorateClass$
|
|
1153
|
-
let SheetsHyperLinkPopupController = (
|
|
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();
|
|
1477
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
1478
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a8;
|
|
1479
|
+
let SheetsHyperLinkPopupController = (_a8 = class extends Disposable {
|
|
1480
|
+
constructor(_hoverManagerService, _sheetsHyperLinkPopupService, _renderManagerService, _permissionService, _sheetPermissionInterceptorBaseController, _commandService) {
|
|
1481
|
+
super(), this._hoverManagerService = _hoverManagerService, this._sheetsHyperLinkPopupService = _sheetsHyperLinkPopupService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._commandService = _commandService, this._initHoverListener(), this._initCommandListener();
|
|
1156
1482
|
}
|
|
1157
1483
|
_initHoverListener() {
|
|
1158
1484
|
this.disposeWithMe(
|
|
@@ -1189,14 +1515,21 @@ let SheetsHyperLinkPopupController = (_a7 = class extends Disposable {
|
|
|
1189
1515
|
})
|
|
1190
1516
|
);
|
|
1191
1517
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1518
|
+
_initCommandListener() {
|
|
1519
|
+
const HIDE_COMMAND_LIST = [ClearSelectionContentCommand.id, ClearSelectionAllCommand.id, ClearSelectionFormatCommand.id];
|
|
1520
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1521
|
+
HIDE_COMMAND_LIST.includes(command.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1522
|
+
}));
|
|
1523
|
+
}
|
|
1524
|
+
}, __name(_a8, "SheetsHyperLinkPopupController"), _a8);
|
|
1525
|
+
SheetsHyperLinkPopupController = __decorateClass$5([
|
|
1194
1526
|
OnLifecycle(LifecycleStages.Rendered, SheetsHyperLinkPopupController),
|
|
1195
|
-
__decorateParam$
|
|
1196
|
-
__decorateParam$
|
|
1197
|
-
__decorateParam$
|
|
1198
|
-
__decorateParam$
|
|
1199
|
-
__decorateParam$
|
|
1527
|
+
__decorateParam$5(0, Inject(HoverManagerService)),
|
|
1528
|
+
__decorateParam$5(1, Inject(SheetsHyperLinkPopupService)),
|
|
1529
|
+
__decorateParam$5(2, Inject(IRenderManagerService)),
|
|
1530
|
+
__decorateParam$5(3, Inject(IPermissionService)),
|
|
1531
|
+
__decorateParam$5(4, Inject(SheetPermissionInterceptorBaseController)),
|
|
1532
|
+
__decorateParam$5(5, ICommandService)
|
|
1200
1533
|
], SheetsHyperLinkPopupController);
|
|
1201
1534
|
const insertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1202
1535
|
id: InsertHyperLinkOperation.id,
|
|
@@ -1220,12 +1553,12 @@ const insertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
|
1220
1553
|
binding: KeyCode.K | MetaKeys.CTRL_COMMAND,
|
|
1221
1554
|
preconditions: whenSheetEditorFocused
|
|
1222
1555
|
};
|
|
1223
|
-
var __defProp$
|
|
1224
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1556
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1557
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1225
1558
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1226
|
-
return kind && result && __defProp$
|
|
1227
|
-
}, "__decorateClass$
|
|
1228
|
-
let SheetsHyperLinkUIController = (
|
|
1559
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
1560
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a9;
|
|
1561
|
+
let SheetsHyperLinkUIController = (_a9 = class extends Disposable {
|
|
1229
1562
|
constructor(_config, _componentManager, _commandService, _localeService, _menuService, _injector, _shortcutService) {
|
|
1230
1563
|
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();
|
|
1231
1564
|
}
|
|
@@ -1243,7 +1576,11 @@ let SheetsHyperLinkUIController = (_a8 = class extends Disposable {
|
|
|
1243
1576
|
OpenHyperLinkSidebarOperation,
|
|
1244
1577
|
CloseHyperLinkSidebarOperation,
|
|
1245
1578
|
InsertHyperLinkOperation,
|
|
1246
|
-
InsertHyperLinkToolbarOperation
|
|
1579
|
+
InsertHyperLinkToolbarOperation,
|
|
1580
|
+
AddHyperLinkCommand,
|
|
1581
|
+
UpdateHyperLinkCommand,
|
|
1582
|
+
RemoveHyperLinkCommand,
|
|
1583
|
+
CancelHyperLinkCommand
|
|
1247
1584
|
].forEach((command) => {
|
|
1248
1585
|
this._commandService.registerCommand(command);
|
|
1249
1586
|
});
|
|
@@ -1255,23 +1592,22 @@ let SheetsHyperLinkUIController = (_a8 = class extends Disposable {
|
|
|
1255
1592
|
_initShortCut() {
|
|
1256
1593
|
this._shortcutService.registerShortcut(InsertLinkShortcut);
|
|
1257
1594
|
}
|
|
1258
|
-
}, __name(
|
|
1259
|
-
SheetsHyperLinkUIController = __decorateClass$
|
|
1595
|
+
}, __name(_a9, "SheetsHyperLinkUIController"), _a9);
|
|
1596
|
+
SheetsHyperLinkUIController = __decorateClass$4([
|
|
1260
1597
|
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkUIController),
|
|
1261
|
-
__decorateParam$
|
|
1262
|
-
__decorateParam$
|
|
1263
|
-
__decorateParam$
|
|
1264
|
-
__decorateParam$
|
|
1265
|
-
__decorateParam$
|
|
1266
|
-
__decorateParam$
|
|
1598
|
+
__decorateParam$4(1, Inject(ComponentManager)),
|
|
1599
|
+
__decorateParam$4(2, ICommandService),
|
|
1600
|
+
__decorateParam$4(3, Inject(LocaleService)),
|
|
1601
|
+
__decorateParam$4(4, IMenuService),
|
|
1602
|
+
__decorateParam$4(5, Inject(Injector)),
|
|
1603
|
+
__decorateParam$4(6, Inject(IShortcutService))
|
|
1267
1604
|
], SheetsHyperLinkUIController);
|
|
1268
|
-
|
|
1269
|
-
var
|
|
1270
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1605
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1606
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1271
1607
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1272
|
-
return kind && result && __defProp$
|
|
1273
|
-
}, "__decorateClass$
|
|
1274
|
-
let SheetsHyperLinkAutoFillController = (
|
|
1608
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
1609
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a10;
|
|
1610
|
+
let SheetsHyperLinkAutoFillController = (_a10 = class extends Disposable {
|
|
1275
1611
|
constructor(_autoFillService, _hyperLinkModel) {
|
|
1276
1612
|
super(), this._autoFillService = _autoFillService, this._hyperLinkModel = _hyperLinkModel, this._initAutoFill();
|
|
1277
1613
|
}
|
|
@@ -1303,52 +1639,49 @@ let SheetsHyperLinkAutoFillController = (_a9 = class extends Disposable {
|
|
|
1303
1639
|
endRow: row
|
|
1304
1640
|
},
|
|
1305
1641
|
sourceRange2
|
|
1306
|
-
), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol)
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
row: targetRow,
|
|
1333
|
-
column: targetCol
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
}), undos.push({
|
|
1337
|
-
id: RemoveHyperLinkMutation.id,
|
|
1338
|
-
params: {
|
|
1339
|
-
unitId,
|
|
1340
|
-
subUnitId,
|
|
1341
|
-
id
|
|
1342
|
-
}
|
|
1343
|
-
})), currentLink && undos.push({
|
|
1344
|
-
id: AddHyperLinkMutation.id,
|
|
1345
|
-
params: {
|
|
1346
|
-
unitId,
|
|
1347
|
-
subUnitId,
|
|
1348
|
-
link: currentLink
|
|
1642
|
+
), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol), targetPositionRange = Rectangle.getPositionRange(
|
|
1643
|
+
{
|
|
1644
|
+
startRow: row,
|
|
1645
|
+
startColumn: col,
|
|
1646
|
+
endColumn: col,
|
|
1647
|
+
endRow: row
|
|
1648
|
+
},
|
|
1649
|
+
targetRange2
|
|
1650
|
+
), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn), id = Tools.generateRandomId(), currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
|
|
1651
|
+
currentLink && redos.push({
|
|
1652
|
+
id: RemoveHyperLinkMutation.id,
|
|
1653
|
+
params: {
|
|
1654
|
+
unitId,
|
|
1655
|
+
subUnitId,
|
|
1656
|
+
id: currentLink.id
|
|
1657
|
+
}
|
|
1658
|
+
}), (APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) && link && (redos.push({
|
|
1659
|
+
id: AddHyperLinkMutation.id,
|
|
1660
|
+
params: {
|
|
1661
|
+
unitId,
|
|
1662
|
+
subUnitId,
|
|
1663
|
+
link: {
|
|
1664
|
+
...link,
|
|
1665
|
+
id,
|
|
1666
|
+
row: targetRow,
|
|
1667
|
+
column: targetCol
|
|
1349
1668
|
}
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1669
|
+
}
|
|
1670
|
+
}), undos.push({
|
|
1671
|
+
id: RemoveHyperLinkMutation.id,
|
|
1672
|
+
params: {
|
|
1673
|
+
unitId,
|
|
1674
|
+
subUnitId,
|
|
1675
|
+
id
|
|
1676
|
+
}
|
|
1677
|
+
})), currentLink && undos.push({
|
|
1678
|
+
id: AddHyperLinkMutation.id,
|
|
1679
|
+
params: {
|
|
1680
|
+
unitId,
|
|
1681
|
+
subUnitId,
|
|
1682
|
+
link: currentLink
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1352
1685
|
});
|
|
1353
1686
|
}), {
|
|
1354
1687
|
undos,
|
|
@@ -1360,172 +1693,12 @@ let SheetsHyperLinkAutoFillController = (_a9 = class extends Disposable {
|
|
|
1360
1693
|
};
|
|
1361
1694
|
this.disposeWithMe(this._autoFillService.addHook(hook));
|
|
1362
1695
|
}
|
|
1363
|
-
}, __name(
|
|
1364
|
-
SheetsHyperLinkAutoFillController = __decorateClass$
|
|
1696
|
+
}, __name(_a10, "SheetsHyperLinkAutoFillController"), _a10);
|
|
1697
|
+
SheetsHyperLinkAutoFillController = __decorateClass$3([
|
|
1365
1698
|
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkAutoFillController),
|
|
1366
|
-
__decorateParam$
|
|
1367
|
-
__decorateParam$
|
|
1699
|
+
__decorateParam$3(0, IAutoFillService),
|
|
1700
|
+
__decorateParam$3(1, Inject(HyperLinkModel))
|
|
1368
1701
|
], 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) {
|
|
1376
|
-
super();
|
|
1377
|
-
__publicField(this, "_copyInfo");
|
|
1378
|
-
this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste();
|
|
1379
|
-
}
|
|
1380
|
-
_initCopyPaste() {
|
|
1381
|
-
this._sheetClipboardService.addClipboardHook({
|
|
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,
|
|
1395
|
-
params: {
|
|
1396
|
-
unitId,
|
|
1397
|
-
subUnitId,
|
|
1398
|
-
id: link.id
|
|
1399
|
-
}
|
|
1400
|
-
});
|
|
1401
|
-
const newId = Tools.generateRandomId();
|
|
1402
|
-
redos.push({
|
|
1403
|
-
id: AddHyperLinkMutation.id,
|
|
1404
|
-
params: {
|
|
1405
|
-
unitId,
|
|
1406
|
-
subUnitId,
|
|
1407
|
-
link: {
|
|
1408
|
-
id: newId,
|
|
1409
|
-
row,
|
|
1410
|
-
column,
|
|
1411
|
-
payload: text
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
}), undos.push({
|
|
1415
|
-
id: RemoveHyperLinkMutation.id,
|
|
1416
|
-
params: {
|
|
1417
|
-
unitId,
|
|
1418
|
-
subUnitId,
|
|
1419
|
-
id: newId
|
|
1420
|
-
}
|
|
1421
|
-
}), link && undos.push({
|
|
1422
|
-
id: AddHyperLinkMutation.id,
|
|
1423
|
-
params: {
|
|
1424
|
-
unitId,
|
|
1425
|
-
subUnitId,
|
|
1426
|
-
link
|
|
1427
|
-
}
|
|
1428
|
-
});
|
|
1429
|
-
}), { redos, undos };
|
|
1430
|
-
}
|
|
1431
|
-
return { undos: [], redos: [] };
|
|
1432
|
-
}, "onPastePlainText")
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
_collect(unitId, subUnitId, range) {
|
|
1436
|
-
const matrix = new ObjectMatrix();
|
|
1437
|
-
this._copyInfo = {
|
|
1438
|
-
unitId,
|
|
1439
|
-
subUnitId,
|
|
1440
|
-
matrix
|
|
1441
|
-
};
|
|
1442
|
-
const accessor = {
|
|
1443
|
-
get: this._injector.get.bind(this._injector)
|
|
1444
|
-
}, discreteRange = rangeToDiscreteRange(range, accessor, unitId, subUnitId);
|
|
1445
|
-
if (!discreteRange)
|
|
1446
|
-
return;
|
|
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 : "");
|
|
1453
|
-
});
|
|
1454
|
-
});
|
|
1455
|
-
}
|
|
1456
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1457
|
-
_generateMutations(pastedRange, copyInfo) {
|
|
1458
|
-
if (!this._copyInfo)
|
|
1459
|
-
return { redos: [], undos: [] };
|
|
1460
|
-
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange)
|
|
1461
|
-
return { redos: [], undos: [] };
|
|
1462
|
-
if ([
|
|
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
|
|
1467
|
-
].includes(
|
|
1468
|
-
copyInfo.pasteType
|
|
1469
|
-
))
|
|
1470
|
-
return { redos: [], undos: [] };
|
|
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(
|
|
1476
|
-
{
|
|
1477
|
-
startRow: row,
|
|
1478
|
-
endRow: row,
|
|
1479
|
-
startColumn: col,
|
|
1480
|
-
endColumn: col
|
|
1481
|
-
},
|
|
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,
|
|
1486
|
-
params: {
|
|
1487
|
-
unitId: copyInfo.unitId,
|
|
1488
|
-
subUnitId: copyInfo.subUnitId,
|
|
1489
|
-
id: currentLink.id
|
|
1490
|
-
}
|
|
1491
|
-
}), oldLink && (redos.push({
|
|
1492
|
-
id: AddHyperLinkMutation.id,
|
|
1493
|
-
params: {
|
|
1494
|
-
unitId: copyInfo.unitId,
|
|
1495
|
-
subUnitId: copyInfo.subUnitId,
|
|
1496
|
-
link: {
|
|
1497
|
-
...oldLink,
|
|
1498
|
-
id,
|
|
1499
|
-
row: startRow,
|
|
1500
|
-
column: startColumn
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
}), undos.push({
|
|
1504
|
-
id: RemoveHyperLinkMutation.id,
|
|
1505
|
-
params: {
|
|
1506
|
-
unitId: copyInfo.unitId,
|
|
1507
|
-
subUnitId: copyInfo.subUnitId,
|
|
1508
|
-
id
|
|
1509
|
-
}
|
|
1510
|
-
})), currentLink && undos.push({
|
|
1511
|
-
id: AddHyperLinkMutation.id,
|
|
1512
|
-
params: {
|
|
1513
|
-
unitId: copyInfo.unitId,
|
|
1514
|
-
subUnitId: copyInfo.subUnitId,
|
|
1515
|
-
link: currentLink
|
|
1516
|
-
}
|
|
1517
|
-
});
|
|
1518
|
-
});
|
|
1519
|
-
}), { redos, undos };
|
|
1520
|
-
}
|
|
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
1702
|
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1530
1703
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1531
1704
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -1582,8 +1755,17 @@ let UniverSheetsHyperLinkUIPlugin = (_a13 = class extends Plugin {
|
|
|
1582
1755
|
}
|
|
1583
1756
|
onStarting() {
|
|
1584
1757
|
[
|
|
1585
|
-
[
|
|
1758
|
+
[
|
|
1759
|
+
SheetsHyperLinkResolverService,
|
|
1760
|
+
{
|
|
1761
|
+
useFactory: /* @__PURE__ */ __name(() => {
|
|
1762
|
+
var _a14;
|
|
1763
|
+
return this._injector.createInstance(SheetsHyperLinkResolverService, (_a14 = this._config) == null ? void 0 : _a14.urlHandler);
|
|
1764
|
+
}, "useFactory")
|
|
1765
|
+
}
|
|
1766
|
+
],
|
|
1586
1767
|
[SheetsHyperLinkPopupService],
|
|
1768
|
+
[SheetsHyperLinkSidePanelService],
|
|
1587
1769
|
[SheetsHyperLinkRemoveSheetController],
|
|
1588
1770
|
[SheetsHyperLinkRenderManagerController],
|
|
1589
1771
|
[SheetHyperLinkSetRangeController],
|
|
@@ -1614,20 +1796,17 @@ UniverSheetsHyperLinkUIPlugin = __decorateClass([
|
|
|
1614
1796
|
__decorateParam(2, IRenderManagerService)
|
|
1615
1797
|
], UniverSheetsHyperLinkUIPlugin);
|
|
1616
1798
|
export {
|
|
1799
|
+
AddHyperLinkCommand,
|
|
1800
|
+
CancelHyperLinkCommand,
|
|
1617
1801
|
CloseHyperLinkSidebarOperation,
|
|
1618
1802
|
InsertHyperLinkOperation,
|
|
1619
1803
|
InsertLinkShortcut,
|
|
1620
1804
|
OpenHyperLinkSidebarOperation,
|
|
1621
|
-
|
|
1622
|
-
SheetHyperLinkUrlController,
|
|
1623
|
-
SheetsHyperLinkAutoFillController,
|
|
1805
|
+
RemoveHyperLinkCommand,
|
|
1624
1806
|
SheetsHyperLinkCopyPasteController,
|
|
1625
|
-
SheetsHyperLinkPopupController,
|
|
1626
1807
|
SheetsHyperLinkPopupService,
|
|
1627
|
-
SheetsHyperLinkRemoveSheetController,
|
|
1628
|
-
SheetsHyperLinkRenderController,
|
|
1629
|
-
SheetsHyperLinkRenderManagerController,
|
|
1630
1808
|
SheetsHyperLinkResolverService,
|
|
1631
|
-
|
|
1632
|
-
UniverSheetsHyperLinkUIPlugin
|
|
1809
|
+
SheetsHyperLinkSidePanelService,
|
|
1810
|
+
UniverSheetsHyperLinkUIPlugin,
|
|
1811
|
+
UpdateHyperLinkCommand
|
|
1633
1812
|
};
|