@univerjs/sheets-hyper-link-ui 0.2.7 → 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 +544 -428
- 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 +0 -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 +0 -1
- package/lib/types/controllers/url.controller.d.ts +0 -1
- package/lib/types/index.d.ts +3 -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 +0 -1
- package/lib/types/services/popup.service.d.ts +0 -1
- package/lib/types/services/resolver.service.d.ts +0 -1
- package/lib/types/services/side-panel.service.d.ts +0 -1
- package/lib/types/types/interfaces/i-config.d.ts +0 -1
- 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 +23 -23
package/lib/es/index.js
CHANGED
|
@@ -2,135 +2,19 @@ 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 { IRenderManagerService } from "@univerjs/engine-render";
|
|
10
|
-
import { debounceTime, Subject, BehaviorSubject } from "rxjs";
|
|
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";
|
|
11
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 __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();
|
|
26
|
-
}
|
|
27
|
-
_initSheetChange() {
|
|
28
|
-
this.disposeWithMe(
|
|
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
|
-
);
|
|
60
|
-
}
|
|
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();
|
|
76
|
-
}
|
|
77
|
-
_initSkeletonChange() {
|
|
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) {
|
|
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
|
-
}));
|
|
91
|
-
}
|
|
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
|
-
}
|
|
103
|
-
_initViewModelIntercept() {
|
|
104
|
-
this.disposeWithMe(
|
|
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
|
-
);
|
|
126
|
-
}
|
|
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
18
|
var LinkType = /* @__PURE__ */ ((LinkType2) => (LinkType2.link = "link", LinkType2.range = "range", LinkType2.sheet = "gid", LinkType2.definedName = "rangeid", LinkType2))(LinkType || {});
|
|
135
19
|
const _SheetsHyperLinkSidePanelService = class _SheetsHyperLinkSidePanelService extends Disposable {
|
|
136
20
|
constructor() {
|
|
@@ -280,11 +164,11 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width:
|
|
|
280
164
|
}));
|
|
281
165
|
});
|
|
282
166
|
Xlsx.displayName = "Xlsx";
|
|
283
|
-
var __defProp$
|
|
284
|
-
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--)
|
|
285
169
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
286
|
-
return kind && result && __defProp$
|
|
287
|
-
}, "__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");
|
|
288
172
|
function getContainRange(range, worksheet) {
|
|
289
173
|
const mergedCells = worksheet.getMergeData(), maxCol = worksheet.getMaxColumns() - 1, maxRow = worksheet.getMaxRows() - 1;
|
|
290
174
|
if (maxCol < range.endColumn && (range.endColumn = maxCol), maxRow < range.endRow && (range.endRow = maxRow), range.rangeType === RANGE_TYPE.COLUMN || RANGE_TYPE.ROW)
|
|
@@ -295,8 +179,8 @@ function getContainRange(range, worksheet) {
|
|
|
295
179
|
}), Rectangle.realUnion(range, ...relativeCells);
|
|
296
180
|
}
|
|
297
181
|
__name(getContainRange, "getContainRange");
|
|
298
|
-
var
|
|
299
|
-
let SheetsHyperLinkResolverService = (
|
|
182
|
+
var _a;
|
|
183
|
+
let SheetsHyperLinkResolverService = (_a = class {
|
|
300
184
|
constructor(_urlHandler, _univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService) {
|
|
301
185
|
this._urlHandler = _urlHandler, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService;
|
|
302
186
|
}
|
|
@@ -445,13 +329,13 @@ let SheetsHyperLinkResolverService = (_a4 = class {
|
|
|
445
329
|
return this._urlHandler.navigateToOtherWebsite(url);
|
|
446
330
|
window.open(url, "_blank", "noopener noreferrer");
|
|
447
331
|
}
|
|
448
|
-
}, __name(
|
|
449
|
-
SheetsHyperLinkResolverService = __decorateClass$
|
|
450
|
-
__decorateParam$
|
|
451
|
-
__decorateParam$
|
|
452
|
-
__decorateParam$
|
|
453
|
-
__decorateParam$
|
|
454
|
-
__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))
|
|
455
339
|
], SheetsHyperLinkResolverService);
|
|
456
340
|
function isLegalLink(link) {
|
|
457
341
|
return Tools.isLegalUrl(link);
|
|
@@ -492,7 +376,69 @@ function getCellValueOrigin(cell) {
|
|
|
492
376
|
return cell == null ? void 0 : cell.v;
|
|
493
377
|
}
|
|
494
378
|
__name(getCellValueOrigin, "getCellValueOrigin");
|
|
495
|
-
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 = {
|
|
496
442
|
cellLinkEditButtons
|
|
497
443
|
}, CellLinkEdit = /* @__PURE__ */ __name(() => {
|
|
498
444
|
var _a14;
|
|
@@ -796,6 +742,55 @@ const OpenHyperLinkSidebarOperation = {
|
|
|
796
742
|
const commandService = accessor.get(ICommandService);
|
|
797
743
|
return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkSidebarOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
|
|
798
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
|
+
}
|
|
799
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 = {
|
|
800
795
|
cellLink,
|
|
801
796
|
cellLinkType,
|
|
@@ -890,14 +885,14 @@ const OpenHyperLinkSidebarOperation = {
|
|
|
890
885
|
] });
|
|
891
886
|
}, "CellLinkPopup");
|
|
892
887
|
CellLinkPopup.componentKey = "univer.sheet.cell-link-popup";
|
|
893
|
-
var __defProp$
|
|
894
|
-
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--)
|
|
895
890
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
896
|
-
return kind && result && __defProp$
|
|
897
|
-
}, "__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");
|
|
898
893
|
const isEqualLink = /* @__PURE__ */ __name((a, b) => a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.row === b.row && a.col === b.col, "isEqualLink");
|
|
899
|
-
var
|
|
900
|
-
let SheetsHyperLinkPopupService = (
|
|
894
|
+
var _a2;
|
|
895
|
+
let SheetsHyperLinkPopupService = (_a2 = class extends Disposable {
|
|
901
896
|
constructor(_hyperLinkModel, _sheetCanvasPopManagerService) {
|
|
902
897
|
super();
|
|
903
898
|
__publicField(this, "_currentPopup", null);
|
|
@@ -951,71 +946,361 @@ let SheetsHyperLinkPopupService = (_a5 = class extends Disposable {
|
|
|
951
946
|
endEditing() {
|
|
952
947
|
this._currentEditing$.next(null);
|
|
953
948
|
}
|
|
954
|
-
}, __name(
|
|
955
|
-
SheetsHyperLinkPopupService = __decorateClass$
|
|
956
|
-
__decorateParam$
|
|
957
|
-
__decorateParam$
|
|
949
|
+
}, __name(_a2, "SheetsHyperLinkPopupService"), _a2);
|
|
950
|
+
SheetsHyperLinkPopupService = __decorateClass$a([
|
|
951
|
+
__decorateParam$a(0, Inject(HyperLinkModel)),
|
|
952
|
+
__decorateParam$a(1, Inject(SheetCanvasPopManagerService))
|
|
958
953
|
], SheetsHyperLinkPopupService);
|
|
959
|
-
|
|
960
|
-
|
|
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--)
|
|
961
957
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
962
|
-
return kind && result && __defProp$
|
|
963
|
-
}, "__decorateClass$
|
|
964
|
-
let
|
|
965
|
-
constructor(
|
|
966
|
-
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
|
+
});
|
|
967
968
|
}
|
|
968
|
-
|
|
969
|
-
this.
|
|
969
|
+
registerPlainTextFilter(filter) {
|
|
970
|
+
this._plainTextFilter.add(filter);
|
|
970
971
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
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);
|
|
974
974
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
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
|
|
991
1012
|
}
|
|
992
1013
|
}
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
undos
|
|
1001
|
-
id:
|
|
1002
|
-
params:
|
|
1003
|
-
|
|
1004
|
-
|
|
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 };
|
|
1005
1030
|
}
|
|
1006
|
-
return {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}, "getMutations")
|
|
1011
|
-
}));
|
|
1031
|
+
return { undos: [], redos: [] };
|
|
1032
|
+
}, "onPastePlainText"),
|
|
1033
|
+
priority: 99
|
|
1034
|
+
});
|
|
1012
1035
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
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) {
|
|
1019
1304
|
const redoParams = {
|
|
1020
1305
|
unitId,
|
|
1021
1306
|
subUnitId,
|
|
@@ -1176,24 +1461,24 @@ let SheetHyperLinkSetRangeController = (_a6 = class extends Disposable {
|
|
|
1176
1461
|
)
|
|
1177
1462
|
);
|
|
1178
1463
|
}
|
|
1179
|
-
}, __name(
|
|
1180
|
-
SheetHyperLinkSetRangeController = __decorateClass$
|
|
1464
|
+
}, __name(_a7, "SheetHyperLinkSetRangeController"), _a7);
|
|
1465
|
+
SheetHyperLinkSetRangeController = __decorateClass$6([
|
|
1181
1466
|
OnLifecycle(LifecycleStages.Starting, SheetHyperLinkSetRangeController),
|
|
1182
|
-
__decorateParam$
|
|
1183
|
-
__decorateParam$
|
|
1184
|
-
__decorateParam$
|
|
1185
|
-
__decorateParam$
|
|
1186
|
-
__decorateParam$
|
|
1187
|
-
__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)
|
|
1188
1473
|
], SheetHyperLinkSetRangeController);
|
|
1189
|
-
var __defProp$
|
|
1190
|
-
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--)
|
|
1191
1476
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1192
|
-
return kind && result && __defProp$
|
|
1193
|
-
}, "__decorateClass$
|
|
1194
|
-
let SheetsHyperLinkPopupController = (
|
|
1195
|
-
constructor(_hoverManagerService, _sheetsHyperLinkPopupService, _renderManagerService, _permissionService, _sheetPermissionInterceptorBaseController) {
|
|
1196
|
-
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();
|
|
1197
1482
|
}
|
|
1198
1483
|
_initHoverListener() {
|
|
1199
1484
|
this.disposeWithMe(
|
|
@@ -1230,14 +1515,21 @@ let SheetsHyperLinkPopupController = (_a7 = class extends Disposable {
|
|
|
1230
1515
|
})
|
|
1231
1516
|
);
|
|
1232
1517
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
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([
|
|
1235
1526
|
OnLifecycle(LifecycleStages.Rendered, SheetsHyperLinkPopupController),
|
|
1236
|
-
__decorateParam$
|
|
1237
|
-
__decorateParam$
|
|
1238
|
-
__decorateParam$
|
|
1239
|
-
__decorateParam$
|
|
1240
|
-
__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)
|
|
1241
1533
|
], SheetsHyperLinkPopupController);
|
|
1242
1534
|
const insertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1243
1535
|
id: InsertHyperLinkOperation.id,
|
|
@@ -1261,12 +1553,12 @@ const insertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
|
1261
1553
|
binding: KeyCode.K | MetaKeys.CTRL_COMMAND,
|
|
1262
1554
|
preconditions: whenSheetEditorFocused
|
|
1263
1555
|
};
|
|
1264
|
-
var __defProp$
|
|
1265
|
-
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--)
|
|
1266
1558
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1267
|
-
return kind && result && __defProp$
|
|
1268
|
-
}, "__decorateClass$
|
|
1269
|
-
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 {
|
|
1270
1562
|
constructor(_config, _componentManager, _commandService, _localeService, _menuService, _injector, _shortcutService) {
|
|
1271
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();
|
|
1272
1564
|
}
|
|
@@ -1284,7 +1576,11 @@ let SheetsHyperLinkUIController = (_a8 = class extends Disposable {
|
|
|
1284
1576
|
OpenHyperLinkSidebarOperation,
|
|
1285
1577
|
CloseHyperLinkSidebarOperation,
|
|
1286
1578
|
InsertHyperLinkOperation,
|
|
1287
|
-
InsertHyperLinkToolbarOperation
|
|
1579
|
+
InsertHyperLinkToolbarOperation,
|
|
1580
|
+
AddHyperLinkCommand,
|
|
1581
|
+
UpdateHyperLinkCommand,
|
|
1582
|
+
RemoveHyperLinkCommand,
|
|
1583
|
+
CancelHyperLinkCommand
|
|
1288
1584
|
].forEach((command) => {
|
|
1289
1585
|
this._commandService.registerCommand(command);
|
|
1290
1586
|
});
|
|
@@ -1296,23 +1592,22 @@ let SheetsHyperLinkUIController = (_a8 = class extends Disposable {
|
|
|
1296
1592
|
_initShortCut() {
|
|
1297
1593
|
this._shortcutService.registerShortcut(InsertLinkShortcut);
|
|
1298
1594
|
}
|
|
1299
|
-
}, __name(
|
|
1300
|
-
SheetsHyperLinkUIController = __decorateClass$
|
|
1595
|
+
}, __name(_a9, "SheetsHyperLinkUIController"), _a9);
|
|
1596
|
+
SheetsHyperLinkUIController = __decorateClass$4([
|
|
1301
1597
|
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkUIController),
|
|
1302
|
-
__decorateParam$
|
|
1303
|
-
__decorateParam$
|
|
1304
|
-
__decorateParam$
|
|
1305
|
-
__decorateParam$
|
|
1306
|
-
__decorateParam$
|
|
1307
|
-
__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))
|
|
1308
1604
|
], SheetsHyperLinkUIController);
|
|
1309
|
-
|
|
1310
|
-
var
|
|
1311
|
-
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--)
|
|
1312
1607
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1313
|
-
return kind && result && __defProp$
|
|
1314
|
-
}, "__decorateClass$
|
|
1315
|
-
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 {
|
|
1316
1611
|
constructor(_autoFillService, _hyperLinkModel) {
|
|
1317
1612
|
super(), this._autoFillService = _autoFillService, this._hyperLinkModel = _hyperLinkModel, this._initAutoFill();
|
|
1318
1613
|
}
|
|
@@ -1398,187 +1693,12 @@ let SheetsHyperLinkAutoFillController = (_a9 = class extends Disposable {
|
|
|
1398
1693
|
};
|
|
1399
1694
|
this.disposeWithMe(this._autoFillService.addHook(hook));
|
|
1400
1695
|
}
|
|
1401
|
-
}, __name(
|
|
1402
|
-
SheetsHyperLinkAutoFillController = __decorateClass$
|
|
1696
|
+
}, __name(_a10, "SheetsHyperLinkAutoFillController"), _a10);
|
|
1697
|
+
SheetsHyperLinkAutoFillController = __decorateClass$3([
|
|
1403
1698
|
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkAutoFillController),
|
|
1404
|
-
__decorateParam$
|
|
1405
|
-
__decorateParam$
|
|
1699
|
+
__decorateParam$3(0, IAutoFillService),
|
|
1700
|
+
__decorateParam$3(1, Inject(HyperLinkModel))
|
|
1406
1701
|
], SheetsHyperLinkAutoFillController);
|
|
1407
|
-
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1408
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1409
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1410
|
-
return kind && result && __defProp$3(target, key, result), result;
|
|
1411
|
-
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a10;
|
|
1412
|
-
let SheetsHyperLinkCopyPasteController = (_a10 = class extends Disposable {
|
|
1413
|
-
constructor(_sheetClipboardService, _hyperLinkModel, _injector, _resolverService) {
|
|
1414
|
-
super();
|
|
1415
|
-
__publicField(this, "_plainTextFilter", /* @__PURE__ */ new Set());
|
|
1416
|
-
__publicField(this, "_copyInfo");
|
|
1417
|
-
this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste(), this.disposeWithMe(() => {
|
|
1418
|
-
this._plainTextFilter.clear();
|
|
1419
|
-
});
|
|
1420
|
-
}
|
|
1421
|
-
registerPlainTextFilter(filter) {
|
|
1422
|
-
this._plainTextFilter.add(filter);
|
|
1423
|
-
}
|
|
1424
|
-
removePlainTextFilter(filter) {
|
|
1425
|
-
this._plainTextFilter.delete(filter);
|
|
1426
|
-
}
|
|
1427
|
-
/* If return false the process of paste text will be stop */
|
|
1428
|
-
_filterPlainText(text) {
|
|
1429
|
-
return Array.from(this._plainTextFilter).every((filter) => filter(text));
|
|
1430
|
-
}
|
|
1431
|
-
_initCopyPaste() {
|
|
1432
|
-
this._sheetClipboardService.addClipboardHook({
|
|
1433
|
-
id: SHEET_HYPER_LINK_UI_PLUGIN,
|
|
1434
|
-
onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
|
|
1435
|
-
onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
|
|
1436
|
-
const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
|
|
1437
|
-
return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
|
|
1438
|
-
}, "onPasteCells"),
|
|
1439
|
-
onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => {
|
|
1440
|
-
const filterResult = this._filterPlainText(clipText);
|
|
1441
|
-
if (isLegalLink(clipText) && filterResult) {
|
|
1442
|
-
const text = serializeUrl(clipText), { range, unitId, subUnitId } = pasteTo, { ranges: [pasteToRange], mapFunc } = virtualizeDiscreteRanges([range]), redos = [], undos = [];
|
|
1443
|
-
return Range.foreach(pasteToRange, (originRow, originCol) => {
|
|
1444
|
-
const { row, col: column } = mapFunc(originRow, originCol), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
|
|
1445
|
-
link && redos.push({
|
|
1446
|
-
id: RemoveHyperLinkMutation.id,
|
|
1447
|
-
params: {
|
|
1448
|
-
unitId,
|
|
1449
|
-
subUnitId,
|
|
1450
|
-
id: link.id
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
const newId = Tools.generateRandomId();
|
|
1454
|
-
redos.push({
|
|
1455
|
-
id: AddHyperLinkMutation.id,
|
|
1456
|
-
params: {
|
|
1457
|
-
unitId,
|
|
1458
|
-
subUnitId,
|
|
1459
|
-
link: {
|
|
1460
|
-
id: newId,
|
|
1461
|
-
row,
|
|
1462
|
-
column,
|
|
1463
|
-
payload: text
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
}), undos.push({
|
|
1467
|
-
id: RemoveHyperLinkMutation.id,
|
|
1468
|
-
params: {
|
|
1469
|
-
unitId,
|
|
1470
|
-
subUnitId,
|
|
1471
|
-
id: newId
|
|
1472
|
-
}
|
|
1473
|
-
}), link && undos.push({
|
|
1474
|
-
id: AddHyperLinkMutation.id,
|
|
1475
|
-
params: {
|
|
1476
|
-
unitId,
|
|
1477
|
-
subUnitId,
|
|
1478
|
-
link
|
|
1479
|
-
}
|
|
1480
|
-
});
|
|
1481
|
-
}), { redos, undos };
|
|
1482
|
-
}
|
|
1483
|
-
return { undos: [], redos: [] };
|
|
1484
|
-
}, "onPastePlainText"),
|
|
1485
|
-
priority: 99
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
_collect(unitId, subUnitId, range) {
|
|
1489
|
-
const matrix = new ObjectMatrix();
|
|
1490
|
-
this._copyInfo = {
|
|
1491
|
-
unitId,
|
|
1492
|
-
subUnitId,
|
|
1493
|
-
matrix
|
|
1494
|
-
};
|
|
1495
|
-
const accessor = {
|
|
1496
|
-
get: this._injector.get.bind(this._injector)
|
|
1497
|
-
}, discreteRange = rangeToDiscreteRange(range, accessor, unitId, subUnitId);
|
|
1498
|
-
if (!discreteRange)
|
|
1499
|
-
return;
|
|
1500
|
-
const { rows, cols } = discreteRange;
|
|
1501
|
-
rows.forEach((row, rowIndex) => {
|
|
1502
|
-
cols.forEach((col, colIndex) => {
|
|
1503
|
-
var _a14;
|
|
1504
|
-
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1505
|
-
matrix.setValue(rowIndex, colIndex, (_a14 = link == null ? void 0 : link.id) != null ? _a14 : "");
|
|
1506
|
-
});
|
|
1507
|
-
});
|
|
1508
|
-
}
|
|
1509
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1510
|
-
_generateMutations(pastedRange, copyInfo) {
|
|
1511
|
-
if (!this._copyInfo)
|
|
1512
|
-
return { redos: [], undos: [] };
|
|
1513
|
-
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange)
|
|
1514
|
-
return { redos: [], undos: [] };
|
|
1515
|
-
if ([
|
|
1516
|
-
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
|
|
1517
|
-
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
|
|
1518
|
-
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
|
|
1519
|
-
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
|
|
1520
|
-
].includes(
|
|
1521
|
-
copyInfo.pasteType
|
|
1522
|
-
))
|
|
1523
|
-
return { redos: [], undos: [] };
|
|
1524
|
-
const { unitId, subUnitId } = this._copyInfo, redos = [], undos = [], { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
|
|
1525
|
-
return getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
|
|
1526
|
-
var _a14;
|
|
1527
|
-
(_a14 = this._copyInfo) == null || _a14.matrix.forValue((row, col, ruleId) => {
|
|
1528
|
-
const range = Rectangle.getPositionRange(
|
|
1529
|
-
{
|
|
1530
|
-
startRow: row,
|
|
1531
|
-
endRow: row,
|
|
1532
|
-
startColumn: col,
|
|
1533
|
-
endColumn: col
|
|
1534
|
-
},
|
|
1535
|
-
startRange
|
|
1536
|
-
), 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();
|
|
1537
|
-
currentLink && redos.push({
|
|
1538
|
-
id: RemoveHyperLinkMutation.id,
|
|
1539
|
-
params: {
|
|
1540
|
-
unitId: copyInfo.unitId,
|
|
1541
|
-
subUnitId: copyInfo.subUnitId,
|
|
1542
|
-
id: currentLink.id
|
|
1543
|
-
}
|
|
1544
|
-
}), oldLink && (redos.push({
|
|
1545
|
-
id: AddHyperLinkMutation.id,
|
|
1546
|
-
params: {
|
|
1547
|
-
unitId: copyInfo.unitId,
|
|
1548
|
-
subUnitId: copyInfo.subUnitId,
|
|
1549
|
-
link: {
|
|
1550
|
-
...oldLink,
|
|
1551
|
-
id,
|
|
1552
|
-
row: startRow,
|
|
1553
|
-
column: startColumn
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
}), undos.push({
|
|
1557
|
-
id: RemoveHyperLinkMutation.id,
|
|
1558
|
-
params: {
|
|
1559
|
-
unitId: copyInfo.unitId,
|
|
1560
|
-
subUnitId: copyInfo.subUnitId,
|
|
1561
|
-
id
|
|
1562
|
-
}
|
|
1563
|
-
})), currentLink && undos.push({
|
|
1564
|
-
id: AddHyperLinkMutation.id,
|
|
1565
|
-
params: {
|
|
1566
|
-
unitId: copyInfo.unitId,
|
|
1567
|
-
subUnitId: copyInfo.subUnitId,
|
|
1568
|
-
link: currentLink
|
|
1569
|
-
}
|
|
1570
|
-
});
|
|
1571
|
-
});
|
|
1572
|
-
}), { redos, undos };
|
|
1573
|
-
}
|
|
1574
|
-
}, __name(_a10, "SheetsHyperLinkCopyPasteController"), _a10);
|
|
1575
|
-
SheetsHyperLinkCopyPasteController = __decorateClass$3([
|
|
1576
|
-
OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkCopyPasteController),
|
|
1577
|
-
__decorateParam$3(0, ISheetClipboardService),
|
|
1578
|
-
__decorateParam$3(1, Inject(HyperLinkModel)),
|
|
1579
|
-
__decorateParam$3(2, Inject(Injector)),
|
|
1580
|
-
__decorateParam$3(3, Inject(SheetsHyperLinkResolverService))
|
|
1581
|
-
], SheetsHyperLinkCopyPasteController);
|
|
1582
1702
|
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1583
1703
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1584
1704
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -1676,21 +1796,17 @@ UniverSheetsHyperLinkUIPlugin = __decorateClass([
|
|
|
1676
1796
|
__decorateParam(2, IRenderManagerService)
|
|
1677
1797
|
], UniverSheetsHyperLinkUIPlugin);
|
|
1678
1798
|
export {
|
|
1799
|
+
AddHyperLinkCommand,
|
|
1800
|
+
CancelHyperLinkCommand,
|
|
1679
1801
|
CloseHyperLinkSidebarOperation,
|
|
1680
1802
|
InsertHyperLinkOperation,
|
|
1681
1803
|
InsertLinkShortcut,
|
|
1682
1804
|
OpenHyperLinkSidebarOperation,
|
|
1683
|
-
|
|
1684
|
-
SheetHyperLinkUrlController,
|
|
1685
|
-
SheetsHyperLinkAutoFillController,
|
|
1805
|
+
RemoveHyperLinkCommand,
|
|
1686
1806
|
SheetsHyperLinkCopyPasteController,
|
|
1687
|
-
SheetsHyperLinkPopupController,
|
|
1688
1807
|
SheetsHyperLinkPopupService,
|
|
1689
|
-
SheetsHyperLinkRemoveSheetController,
|
|
1690
|
-
SheetsHyperLinkRenderController,
|
|
1691
|
-
SheetsHyperLinkRenderManagerController,
|
|
1692
1808
|
SheetsHyperLinkResolverService,
|
|
1693
1809
|
SheetsHyperLinkSidePanelService,
|
|
1694
|
-
|
|
1695
|
-
|
|
1810
|
+
UniverSheetsHyperLinkUIPlugin,
|
|
1811
|
+
UpdateHyperLinkCommand
|
|
1696
1812
|
};
|