@univerjs/sheets-hyper-link-ui 0.5.4 → 0.5.5-experimental.20250123-34738ff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -9
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +14 -10
- package/lib/es/index.js +1316 -1326
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/types/views/CellLinkEdit/index.d.ts +16 -2
- package/lib/types/views/CellLinkPopup/index.d.ts +2 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -9
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +17 -17
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -1,466 +1,448 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { Tools, Inject, LocaleService, UniverInstanceType, isValidRange, IUniverInstanceService, ICommandService, IConfigService, RANGE_TYPE, Rectangle, Injector, Disposable, Range, ObjectMatrix, useDependency, IContextService, ThemeService, DataStreamTreeTokenType, CustomRangeType, BuildTextUtils, ColorKit, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DisposableCollection, FOCUSING_SHEET, generateRandomId, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DataValidationType, CommandType, FOCUSING_FX_BAR_EDITOR, IPermissionService, InterceptorEffectEnum, DependentOn, Plugin, merge } from "@univerjs/core";
|
|
6
|
+
import { SheetHyperLinkType, ERROR_RANGE, HyperLinkModel, RemoveHyperLinkMutation, AddHyperLinkMutation, SheetsHyperLinkParserService, UpdateRichHyperLinkCommand, UpdateHyperLinkCommand, AddRichHyperLinkCommand, AddHyperLinkCommand, CancelRichHyperLinkCommand, CancelHyperLinkCommand, UniverSheetsHyperLinkPlugin } from "@univerjs/sheets-hyper-link";
|
|
7
|
+
import { ScrollToRangeOperation, COPY_TYPE, virtualizeDiscreteRanges, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, IEditorBridgeService, IMarkSelectionService, SheetCanvasPopManagerService, getEditingCustomRangePosition, getCustomRangePosition, whenSheetEditorFocused, getCurrentRangeDisable$, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange, HoverManagerService, HoverRenderController, SheetSkeletonManagerService } from "@univerjs/sheets-ui";
|
|
8
|
+
import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
|
|
9
|
+
import { deserializeRangeWithSheet, IDefinedNamesService, serializeRangeWithSheet, serializeRangeToRefString, serializeRange } from "@univerjs/engine-formula";
|
|
10
|
+
import { SetSelectionsOperation, SetWorksheetActiveOperation, SheetsSelectionsService, getSheetCommandTarget, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission, RangeProtectionPermissionEditPoint, SheetPermissionCheckController, WorkbookViewPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, WorkbookCopyPermission, WorksheetCopyPermission, ClearSelectionContentCommand, ClearSelectionAllCommand, ClearSelectionFormatCommand, SheetInterceptorService, INTERCEPTOR_POINT } from "@univerjs/sheets";
|
|
11
|
+
import { IMessageService, useObservable, IZenZoneService, useEvent, KeyCode, MenuItemType, MetaKeys, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IShortcutService, IMenuManagerService } from "@univerjs/ui";
|
|
12
|
+
import { DocSelectionRenderService, DocBackScrollRenderController, DocCanvasPopManagerService, calcDocRangePositions, DocEventManagerService, UniverDocsUIPlugin } from "@univerjs/docs-ui";
|
|
13
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
14
|
+
import { Subject, BehaviorSubject, of, map, filter, switchMap, combineLatest, distinctUntilChanged, debounceTime, Observable } from "rxjs";
|
|
15
|
+
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
16
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
17
|
+
import { RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
18
|
+
import { useState, useMemo, useRef, useCallback, useEffect, forwardRef, createElement } from "react";
|
|
19
|
+
import { SheetDataValidationModel } from "@univerjs/sheets-data-validation";
|
|
20
|
+
function isLegalLink(link) {
|
|
21
|
+
return Tools.isLegalUrl(link);
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
__name(isLegalLink, "isLegalLink");
|
|
24
|
+
function hasProtocol(urlString) {
|
|
25
|
+
return /^[a-zA-Z]+:\/\//.test(urlString);
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
__name(hasProtocol, "hasProtocol");
|
|
28
|
+
function isEmail(url) {
|
|
29
|
+
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
__name(isEmail, "isEmail");
|
|
32
|
+
function serializeUrl(urlStr) {
|
|
33
|
+
if (isLegalLink(urlStr)) {
|
|
34
|
+
const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`;
|
|
35
|
+
let url;
|
|
31
36
|
try {
|
|
32
|
-
|
|
37
|
+
url = new URL(transformedUrl);
|
|
33
38
|
} catch {
|
|
34
|
-
return
|
|
39
|
+
return urlStr;
|
|
35
40
|
}
|
|
36
|
-
return
|
|
41
|
+
return url.hostname === location.hostname && url.port === location.port && url.protocol === location.protocol && url.pathname === location.pathname && url.hash && !url.search ? url.hash : transformedUrl;
|
|
37
42
|
}
|
|
38
|
-
return
|
|
43
|
+
return urlStr;
|
|
39
44
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
__name(serializeUrl, "serializeUrl");
|
|
46
|
+
const SHEETS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY = "sheets-hyper-link-ui.config", defaultPluginConfig = {};
|
|
47
|
+
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
48
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
49
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
50
|
+
return kind && result && __defProp$9(target, key, result), result;
|
|
51
|
+
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
|
|
52
|
+
function getContainRange(range, worksheet) {
|
|
53
|
+
const mergedCells = worksheet.getMergeData(), maxCol = worksheet.getMaxColumns() - 1, maxRow = worksheet.getMaxRows() - 1;
|
|
54
|
+
if (maxCol < range.endColumn && (range.endColumn = maxCol), maxRow < range.endRow && (range.endRow = maxRow), range.rangeType === RANGE_TYPE.COLUMN || RANGE_TYPE.ROW)
|
|
55
|
+
return range;
|
|
56
|
+
const relativeCells = [];
|
|
57
|
+
return mergedCells.forEach((cell) => {
|
|
58
|
+
Rectangle.intersects(range, cell) && relativeCells.push(cell);
|
|
59
|
+
}), Rectangle.realUnion(range, ...relativeCells);
|
|
54
60
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
__name(getContainRange, "getContainRange");
|
|
62
|
+
var _a;
|
|
63
|
+
let SheetsHyperLinkResolverService = (_a = class {
|
|
64
|
+
constructor(_univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService, _configService) {
|
|
65
|
+
this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService, this._configService = _configService;
|
|
66
|
+
}
|
|
67
|
+
navigate(info) {
|
|
68
|
+
switch (info.type) {
|
|
69
|
+
case SheetHyperLinkType.URL:
|
|
70
|
+
this.navigateToOtherWebsite(info.url);
|
|
63
71
|
break;
|
|
64
72
|
default:
|
|
65
|
-
this._navigateToUniver(
|
|
73
|
+
this._navigateToUniver(info.searchObj);
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
|
-
_navigateToUniver(
|
|
69
|
-
const { gid
|
|
70
|
-
if (!
|
|
76
|
+
_navigateToUniver(params) {
|
|
77
|
+
const { gid, range, rangeid } = params, workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
78
|
+
if (!workbook)
|
|
71
79
|
return;
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
80
|
+
const unitId = workbook.getUnitId();
|
|
81
|
+
if (rangeid) {
|
|
82
|
+
const item = this._definedNamesService.getValueById(unitId, rangeid);
|
|
83
|
+
if (!item)
|
|
76
84
|
return;
|
|
77
|
-
const { formulaOrRefString
|
|
78
|
-
if (!
|
|
85
|
+
const { formulaOrRefString } = item, worksheet = this._definedNamesService.getWorksheetByRef(unitId, formulaOrRefString);
|
|
86
|
+
if (!worksheet) {
|
|
79
87
|
this._messageService.show({
|
|
80
88
|
content: this._localeService.t("hyperLink.message.refError"),
|
|
81
|
-
type:
|
|
89
|
+
type: MessageType.Error
|
|
82
90
|
});
|
|
83
91
|
return;
|
|
84
92
|
}
|
|
85
|
-
if (
|
|
93
|
+
if (worksheet.isSheetHidden()) {
|
|
86
94
|
this._messageService.show({
|
|
87
95
|
content: this._localeService.t("hyperLink.message.hiddenSheet"),
|
|
88
|
-
type:
|
|
96
|
+
type: MessageType.Error
|
|
89
97
|
});
|
|
90
98
|
return;
|
|
91
99
|
}
|
|
92
|
-
this.navigateToDefineName(
|
|
100
|
+
this.navigateToDefineName(unitId, rangeid);
|
|
93
101
|
}
|
|
94
|
-
if (
|
|
95
|
-
if (
|
|
96
|
-
const
|
|
97
|
-
|
|
102
|
+
if (gid) {
|
|
103
|
+
if (range) {
|
|
104
|
+
const rangeInfo = deserializeRangeWithSheet(range);
|
|
105
|
+
isValidRange(rangeInfo.range) && range !== ERROR_RANGE && this.navigateToRange(unitId, gid, rangeInfo.range);
|
|
98
106
|
return;
|
|
99
107
|
}
|
|
100
|
-
this.navigateToSheetById(
|
|
108
|
+
this.navigateToSheetById(unitId, gid);
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
|
-
async navigateToRange(
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
111
|
+
async navigateToRange(unitId, subUnitId, range, forceTop) {
|
|
112
|
+
const worksheet = await this.navigateToSheetById(unitId, subUnitId);
|
|
113
|
+
if (worksheet) {
|
|
114
|
+
const realRange = getContainRange(range, worksheet);
|
|
107
115
|
await this._commandService.executeCommand(
|
|
108
|
-
|
|
116
|
+
SetSelectionsOperation.id,
|
|
109
117
|
{
|
|
110
|
-
unitId
|
|
111
|
-
subUnitId
|
|
118
|
+
unitId,
|
|
119
|
+
subUnitId,
|
|
112
120
|
selections: [{
|
|
113
|
-
range:
|
|
121
|
+
range: realRange,
|
|
114
122
|
primary: null
|
|
115
123
|
}]
|
|
116
124
|
}
|
|
117
|
-
), await this._commandService.executeCommand(
|
|
118
|
-
range:
|
|
119
|
-
forceTop
|
|
125
|
+
), await this._commandService.executeCommand(ScrollToRangeOperation.id, {
|
|
126
|
+
range: realRange,
|
|
127
|
+
forceTop
|
|
120
128
|
});
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
|
-
async navigateToSheetById(
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
131
|
+
async navigateToSheetById(unitId, subUnitId) {
|
|
132
|
+
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
133
|
+
if (!workbook)
|
|
126
134
|
return !1;
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
135
|
+
const worksheet = workbook.getActiveSheet();
|
|
136
|
+
if (!worksheet)
|
|
129
137
|
return !1;
|
|
130
|
-
if (
|
|
131
|
-
return
|
|
132
|
-
const
|
|
133
|
-
return
|
|
138
|
+
if (worksheet.getSheetId() === subUnitId)
|
|
139
|
+
return worksheet;
|
|
140
|
+
const targetSheet = workbook.getSheetBySheetId(subUnitId);
|
|
141
|
+
return targetSheet ? workbook.getHiddenWorksheets().indexOf(subUnitId) > -1 ? (this._messageService.show({
|
|
134
142
|
content: this._localeService.t("hyperLink.message.hiddenSheet"),
|
|
135
|
-
type:
|
|
136
|
-
}), !1) : await this._commandService.executeCommand(
|
|
143
|
+
type: MessageType.Error
|
|
144
|
+
}), !1) : await this._commandService.executeCommand(SetWorksheetActiveOperation.id, { unitId, subUnitId }) ? targetSheet : !1 : (this._messageService.show({
|
|
137
145
|
content: this._localeService.t("hyperLink.message.noSheet"),
|
|
138
|
-
type:
|
|
146
|
+
type: MessageType.Error
|
|
139
147
|
}), !1);
|
|
140
148
|
}
|
|
141
|
-
async navigateToDefineName(
|
|
142
|
-
return this._definedNamesService.focusRange(
|
|
143
|
-
}
|
|
144
|
-
async navigateToOtherWebsite(
|
|
145
|
-
var
|
|
146
|
-
const
|
|
147
|
-
if ((
|
|
148
|
-
return
|
|
149
|
-
window.open(
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
],
|
|
160
|
-
const
|
|
161
|
-
var
|
|
162
|
-
for (var
|
|
163
|
-
(
|
|
164
|
-
return
|
|
165
|
-
},
|
|
166
|
-
let
|
|
167
|
-
constructor(
|
|
149
|
+
async navigateToDefineName(unitId, rangeId) {
|
|
150
|
+
return this._definedNamesService.focusRange(unitId, rangeId), !0;
|
|
151
|
+
}
|
|
152
|
+
async navigateToOtherWebsite(url) {
|
|
153
|
+
var _a12;
|
|
154
|
+
const config = this._configService.getConfig(SHEETS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY);
|
|
155
|
+
if ((_a12 = config == null ? void 0 : config.urlHandler) != null && _a12.navigateToOtherWebsite)
|
|
156
|
+
return config.urlHandler.navigateToOtherWebsite(url);
|
|
157
|
+
window.open(url, "_blank", "noopener noreferrer");
|
|
158
|
+
}
|
|
159
|
+
}, __name(_a, "SheetsHyperLinkResolverService"), _a);
|
|
160
|
+
SheetsHyperLinkResolverService = __decorateClass$9([
|
|
161
|
+
__decorateParam$9(0, IUniverInstanceService),
|
|
162
|
+
__decorateParam$9(1, ICommandService),
|
|
163
|
+
__decorateParam$9(2, IDefinedNamesService),
|
|
164
|
+
__decorateParam$9(3, IMessageService),
|
|
165
|
+
__decorateParam$9(4, Inject(LocaleService)),
|
|
166
|
+
__decorateParam$9(5, IConfigService)
|
|
167
|
+
], SheetsHyperLinkResolverService);
|
|
168
|
+
const SHEET_HYPER_LINK_UI_PLUGIN = "SHEET_HYPER_LINK_UI_PLUGIN";
|
|
169
|
+
var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
170
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
171
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
172
|
+
return kind && result && __defProp$8(target, key, result), result;
|
|
173
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a2;
|
|
174
|
+
let SheetsHyperLinkCopyPasteController = (_a2 = class extends Disposable {
|
|
175
|
+
constructor(_sheetClipboardService, _hyperLinkModel, _injector, _resolverService) {
|
|
168
176
|
super();
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this._sheetClipboardService =
|
|
177
|
+
__publicField(this, "_plainTextFilter", /* @__PURE__ */ new Set());
|
|
178
|
+
__publicField(this, "_copyInfo");
|
|
179
|
+
this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste(), this.disposeWithMe(() => {
|
|
172
180
|
this._plainTextFilter.clear();
|
|
173
181
|
});
|
|
174
182
|
}
|
|
175
|
-
registerPlainTextFilter(
|
|
176
|
-
this._plainTextFilter.add(
|
|
183
|
+
registerPlainTextFilter(filter2) {
|
|
184
|
+
this._plainTextFilter.add(filter2);
|
|
177
185
|
}
|
|
178
|
-
removePlainTextFilter(
|
|
179
|
-
this._plainTextFilter.delete(
|
|
186
|
+
removePlainTextFilter(filter2) {
|
|
187
|
+
this._plainTextFilter.delete(filter2);
|
|
180
188
|
}
|
|
181
189
|
/* If return false the process of paste text will be stop */
|
|
182
|
-
_filterPlainText(
|
|
183
|
-
return Array.from(this._plainTextFilter).every((
|
|
190
|
+
_filterPlainText(text) {
|
|
191
|
+
return Array.from(this._plainTextFilter).every((filter2) => filter2(text));
|
|
184
192
|
}
|
|
185
193
|
_initCopyPaste() {
|
|
186
194
|
this._sheetClipboardService.addClipboardHook({
|
|
187
|
-
id:
|
|
188
|
-
onBeforeCopy: (
|
|
189
|
-
onPasteCells: (
|
|
190
|
-
const { copyType
|
|
191
|
-
return this._generateMutations(
|
|
192
|
-
},
|
|
193
|
-
onPastePlainText: (
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
const { range
|
|
197
|
-
return
|
|
198
|
-
const { row
|
|
199
|
-
|
|
200
|
-
id:
|
|
195
|
+
id: SHEET_HYPER_LINK_UI_PLUGIN,
|
|
196
|
+
onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
|
|
197
|
+
onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
|
|
198
|
+
const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
|
|
199
|
+
return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
|
|
200
|
+
}, "onPasteCells"),
|
|
201
|
+
onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => {
|
|
202
|
+
const filterResult = this._filterPlainText(clipText);
|
|
203
|
+
if (isLegalLink(clipText) && filterResult) {
|
|
204
|
+
const { range, unitId, subUnitId } = pasteTo, { ranges: [pasteToRange], mapFunc } = virtualizeDiscreteRanges([range]), redos = [], undos = [];
|
|
205
|
+
return Range.foreach(pasteToRange, (originRow, originCol) => {
|
|
206
|
+
const { row, col: column } = mapFunc(originRow, originCol), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
|
|
207
|
+
link && redos.push({
|
|
208
|
+
id: RemoveHyperLinkMutation.id,
|
|
201
209
|
params: {
|
|
202
|
-
unitId
|
|
203
|
-
subUnitId
|
|
204
|
-
id:
|
|
210
|
+
unitId,
|
|
211
|
+
subUnitId,
|
|
212
|
+
id: link.id
|
|
205
213
|
}
|
|
206
|
-
}),
|
|
207
|
-
id:
|
|
214
|
+
}), link && undos.push({
|
|
215
|
+
id: AddHyperLinkMutation.id,
|
|
208
216
|
params: {
|
|
209
|
-
unitId
|
|
210
|
-
subUnitId
|
|
211
|
-
link
|
|
217
|
+
unitId,
|
|
218
|
+
subUnitId,
|
|
219
|
+
link
|
|
212
220
|
}
|
|
213
221
|
});
|
|
214
|
-
}), { redos
|
|
222
|
+
}), { redos, undos };
|
|
215
223
|
}
|
|
216
224
|
return { undos: [], redos: [] };
|
|
217
|
-
},
|
|
225
|
+
}, "onPastePlainText"),
|
|
218
226
|
priority: 99
|
|
219
227
|
});
|
|
220
228
|
}
|
|
221
|
-
_collect(
|
|
222
|
-
const
|
|
229
|
+
_collect(unitId, subUnitId, range) {
|
|
230
|
+
const matrix = new ObjectMatrix();
|
|
223
231
|
this._copyInfo = {
|
|
224
|
-
unitId
|
|
225
|
-
subUnitId
|
|
226
|
-
matrix
|
|
232
|
+
unitId,
|
|
233
|
+
subUnitId,
|
|
234
|
+
matrix
|
|
227
235
|
};
|
|
228
|
-
const
|
|
229
|
-
if (!
|
|
236
|
+
const discreteRange = this._injector.invoke((accessor) => rangeToDiscreteRange(range, accessor, unitId, subUnitId));
|
|
237
|
+
if (!discreteRange)
|
|
230
238
|
return;
|
|
231
|
-
const { rows
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
var
|
|
235
|
-
const
|
|
236
|
-
|
|
239
|
+
const { rows, cols } = discreteRange;
|
|
240
|
+
rows.forEach((row, rowIndex) => {
|
|
241
|
+
cols.forEach((col, colIndex) => {
|
|
242
|
+
var _a12;
|
|
243
|
+
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
244
|
+
matrix.setValue(rowIndex, colIndex, (_a12 = link == null ? void 0 : link.id) != null ? _a12 : "");
|
|
237
245
|
});
|
|
238
246
|
});
|
|
239
247
|
}
|
|
240
248
|
// eslint-disable-next-line max-lines-per-function
|
|
241
|
-
_generateMutations(
|
|
249
|
+
_generateMutations(pastedRange, copyInfo) {
|
|
242
250
|
if (!this._copyInfo)
|
|
243
251
|
return { redos: [], undos: [] };
|
|
244
|
-
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !
|
|
252
|
+
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange)
|
|
245
253
|
return { redos: [], undos: [] };
|
|
246
254
|
if ([
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
].includes(
|
|
255
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
|
|
256
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
|
|
257
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
|
|
258
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
|
|
259
|
+
].includes(copyInfo.pasteType))
|
|
252
260
|
return { redos: [], undos: [] };
|
|
253
|
-
const { unitId
|
|
254
|
-
return
|
|
255
|
-
var
|
|
256
|
-
(
|
|
257
|
-
const
|
|
261
|
+
const { unitId, subUnitId } = this._copyInfo, redos = [], undos = [], { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
|
|
262
|
+
return getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
|
|
263
|
+
var _a12;
|
|
264
|
+
(_a12 = this._copyInfo) == null || _a12.matrix.forValue((row, col, ruleId) => {
|
|
265
|
+
const range = Rectangle.getPositionRange(
|
|
258
266
|
{
|
|
259
|
-
startRow:
|
|
260
|
-
endRow:
|
|
261
|
-
startColumn:
|
|
262
|
-
endColumn:
|
|
267
|
+
startRow: row,
|
|
268
|
+
endRow: row,
|
|
269
|
+
startColumn: col,
|
|
270
|
+
endColumn: col
|
|
263
271
|
},
|
|
264
|
-
|
|
265
|
-
),
|
|
266
|
-
|
|
267
|
-
id:
|
|
272
|
+
startRange
|
|
273
|
+
), 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();
|
|
274
|
+
currentLink && redos.push({
|
|
275
|
+
id: RemoveHyperLinkMutation.id,
|
|
268
276
|
params: {
|
|
269
|
-
unitId:
|
|
270
|
-
subUnitId:
|
|
271
|
-
id:
|
|
277
|
+
unitId: copyInfo.unitId,
|
|
278
|
+
subUnitId: copyInfo.subUnitId,
|
|
279
|
+
id: currentLink.id
|
|
272
280
|
}
|
|
273
|
-
}),
|
|
274
|
-
id:
|
|
281
|
+
}), oldLink && (redos.push({
|
|
282
|
+
id: AddHyperLinkMutation.id,
|
|
275
283
|
params: {
|
|
276
|
-
unitId:
|
|
277
|
-
subUnitId:
|
|
284
|
+
unitId: copyInfo.unitId,
|
|
285
|
+
subUnitId: copyInfo.subUnitId,
|
|
278
286
|
link: {
|
|
279
|
-
...
|
|
280
|
-
id
|
|
281
|
-
row:
|
|
282
|
-
column:
|
|
287
|
+
...oldLink,
|
|
288
|
+
id,
|
|
289
|
+
row: startRow,
|
|
290
|
+
column: startColumn
|
|
283
291
|
}
|
|
284
292
|
}
|
|
285
|
-
}),
|
|
286
|
-
id:
|
|
293
|
+
}), undos.push({
|
|
294
|
+
id: RemoveHyperLinkMutation.id,
|
|
287
295
|
params: {
|
|
288
|
-
unitId:
|
|
289
|
-
subUnitId:
|
|
290
|
-
id
|
|
296
|
+
unitId: copyInfo.unitId,
|
|
297
|
+
subUnitId: copyInfo.subUnitId,
|
|
298
|
+
id
|
|
291
299
|
}
|
|
292
|
-
})),
|
|
293
|
-
id:
|
|
300
|
+
})), currentLink && undos.push({
|
|
301
|
+
id: AddHyperLinkMutation.id,
|
|
294
302
|
params: {
|
|
295
|
-
unitId:
|
|
296
|
-
subUnitId:
|
|
297
|
-
link:
|
|
303
|
+
unitId: copyInfo.unitId,
|
|
304
|
+
subUnitId: copyInfo.subUnitId,
|
|
305
|
+
link: currentLink
|
|
298
306
|
}
|
|
299
307
|
});
|
|
300
308
|
});
|
|
301
|
-
}), { redos
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
],
|
|
310
|
-
var
|
|
311
|
-
|
|
312
|
-
* @license React
|
|
313
|
-
* react-jsx-runtime.production.min.js
|
|
314
|
-
*
|
|
315
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
316
|
-
*
|
|
317
|
-
* This source code is licensed under the MIT license found in the
|
|
318
|
-
* LICENSE file in the root directory of this source tree.
|
|
319
|
-
*/
|
|
320
|
-
var fn;
|
|
321
|
-
function wi() {
|
|
322
|
-
if (fn) return ke;
|
|
323
|
-
fn = 1;
|
|
324
|
-
var t = fi, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, r = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
325
|
-
function s(c, l, p) {
|
|
326
|
-
var u, g = {}, d = null, v = null;
|
|
327
|
-
p !== void 0 && (d = "" + p), l.key !== void 0 && (d = "" + l.key), l.ref !== void 0 && (v = l.ref);
|
|
328
|
-
for (u in l) i.call(l, u) && !o.hasOwnProperty(u) && (g[u] = l[u]);
|
|
329
|
-
if (c && c.defaultProps) for (u in l = c.defaultProps, l) g[u] === void 0 && (g[u] = l[u]);
|
|
330
|
-
return { $$typeof: e, type: c, key: d, ref: v, props: g, _owner: r.current };
|
|
331
|
-
}
|
|
332
|
-
return ke.Fragment = n, ke.jsx = s, ke.jsxs = s, ke;
|
|
333
|
-
}
|
|
334
|
-
var mn;
|
|
335
|
-
function Oi() {
|
|
336
|
-
return mn || (mn = 1, Et.exports = wi()), Et.exports;
|
|
337
|
-
}
|
|
338
|
-
var f = Oi();
|
|
339
|
-
class jn extends z {
|
|
309
|
+
}), { redos, undos };
|
|
310
|
+
}
|
|
311
|
+
}, __name(_a2, "SheetsHyperLinkCopyPasteController"), _a2);
|
|
312
|
+
SheetsHyperLinkCopyPasteController = __decorateClass$8([
|
|
313
|
+
__decorateParam$8(0, ISheetClipboardService),
|
|
314
|
+
__decorateParam$8(1, Inject(HyperLinkModel)),
|
|
315
|
+
__decorateParam$8(2, Inject(Injector)),
|
|
316
|
+
__decorateParam$8(3, Inject(SheetsHyperLinkResolverService))
|
|
317
|
+
], SheetsHyperLinkCopyPasteController);
|
|
318
|
+
var HyperLinkEditSourceType = /* @__PURE__ */ ((HyperLinkEditSourceType2) => (HyperLinkEditSourceType2.EDITING = "editing", HyperLinkEditSourceType2.VIEWING = "viewing", HyperLinkEditSourceType2.ZEN_EDITOR = "zen_mode", HyperLinkEditSourceType2))(HyperLinkEditSourceType || {});
|
|
319
|
+
const _SheetsHyperLinkSidePanelService = class _SheetsHyperLinkSidePanelService extends Disposable {
|
|
340
320
|
constructor() {
|
|
341
321
|
super(...arguments);
|
|
342
|
-
|
|
322
|
+
__publicField(this, "_customHyperLinks", /* @__PURE__ */ new Map());
|
|
343
323
|
}
|
|
344
|
-
isBuiltInLinkType(
|
|
345
|
-
return
|
|
324
|
+
isBuiltInLinkType(type) {
|
|
325
|
+
return type !== SheetHyperLinkType.URL;
|
|
346
326
|
}
|
|
347
327
|
getOptions() {
|
|
348
|
-
return Array.from(this._customHyperLinks.values()).map(({ option
|
|
328
|
+
return Array.from(this._customHyperLinks.values()).map(({ option }) => option);
|
|
349
329
|
}
|
|
350
|
-
findCustomHyperLink(
|
|
351
|
-
return Array.from(this._customHyperLinks.values()).find((
|
|
330
|
+
findCustomHyperLink(link) {
|
|
331
|
+
return Array.from(this._customHyperLinks.values()).find((item) => item.match(link));
|
|
352
332
|
}
|
|
353
|
-
registerCustomHyperLink(
|
|
354
|
-
this._customHyperLinks.set(
|
|
333
|
+
registerCustomHyperLink(customHyperLink) {
|
|
334
|
+
this._customHyperLinks.set(customHyperLink.type, customHyperLink);
|
|
355
335
|
}
|
|
356
|
-
getCustomHyperLink(
|
|
357
|
-
return this._customHyperLinks.get(
|
|
336
|
+
getCustomHyperLink(type) {
|
|
337
|
+
return this._customHyperLinks.get(type);
|
|
358
338
|
}
|
|
359
|
-
removeCustomHyperLink(
|
|
360
|
-
const { _customHyperLinks
|
|
361
|
-
|
|
339
|
+
removeCustomHyperLink(type) {
|
|
340
|
+
const { _customHyperLinks } = this;
|
|
341
|
+
_customHyperLinks.delete(type);
|
|
362
342
|
}
|
|
363
343
|
dispose() {
|
|
364
344
|
super.dispose(), this._customHyperLinks.clear();
|
|
365
345
|
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}, [
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
let
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
346
|
+
};
|
|
347
|
+
__name(_SheetsHyperLinkSidePanelService, "SheetsHyperLinkSidePanelService");
|
|
348
|
+
let SheetsHyperLinkSidePanelService = _SheetsHyperLinkSidePanelService;
|
|
349
|
+
const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
350
|
+
cellLinkEdit,
|
|
351
|
+
cellLinkEditButtons
|
|
352
|
+
}, CellLinkEdit = /* @__PURE__ */ __name(() => {
|
|
353
|
+
var _a12;
|
|
354
|
+
const [id, setId] = useState(""), [hide, setHide] = useState(!1), [display, _setDisplay] = useState(""), [showLabel, setShowLabel] = useState(!0), [type, setType] = useState(SheetHyperLinkType.URL), [payload, setPayload] = useState(""), localeService = useDependency(LocaleService), definedNameService = useDependency(IDefinedNamesService), editorBridgeService = useDependency(IEditorBridgeService), univerInstanceService = useDependency(IUniverInstanceService), popupService = useDependency(SheetsHyperLinkPopupService), editing = useObservable(popupService.currentEditing$), parserService = useDependency(SheetsHyperLinkParserService), resolverService = useDependency(SheetsHyperLinkResolverService), commandService = useDependency(ICommandService), sidePanelService = useDependency(SheetsHyperLinkSidePanelService), sidePanelOptions = useMemo(() => sidePanelService.getOptions(), [sidePanelService]), zenZoneService = useDependency(IZenZoneService), renderManagerService = useDependency(IRenderManagerService), markSelectionService = useDependency(IMarkSelectionService), textSelectionService = useDependency(DocSelectionManagerService), contextService = useDependency(IContextService), themeService = useDependency(ThemeService), docSelectionManagerService = useDependency(DocSelectionManagerService), rangeSelectorActionsRef = useRef({}), customHyperLinkSidePanel = useMemo(() => {
|
|
355
|
+
if (!sidePanelService.isBuiltInLinkType(type))
|
|
356
|
+
return sidePanelService.getCustomHyperLink(type);
|
|
357
|
+
}, [sidePanelService, type]), [showError, setShowError] = useState(!1), [isFocusRangeSelector, isFocusRangeSelectorSet] = useState(!1), setByPayload = useRef(!1), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), subUnitId = (workbook == null ? void 0 : workbook.getActiveSheet().getSheetId()) || "", setDisplay = useCallback((value) => {
|
|
358
|
+
_setDisplay(value.replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, ""));
|
|
359
|
+
}, [_setDisplay]);
|
|
360
|
+
useEffect(() => {
|
|
361
|
+
var _a13, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
362
|
+
if ((editing == null ? void 0 : editing.row) !== void 0 && editing.col !== void 0) {
|
|
363
|
+
const { customRange, row, col } = editing;
|
|
364
|
+
let { label } = editing;
|
|
365
|
+
typeof label == "number" && (label = `${label}`);
|
|
366
|
+
let link;
|
|
367
|
+
if (customRange)
|
|
368
|
+
link = {
|
|
369
|
+
id: (_a13 = customRange == null ? void 0 : customRange.rangeId) != null ? _a13 : "",
|
|
370
|
+
display: label != null ? label : "",
|
|
371
|
+
payload: (_c = (_b = customRange == null ? void 0 : customRange.properties) == null ? void 0 : _b.url) != null ? _c : "",
|
|
372
|
+
row,
|
|
373
|
+
column: col
|
|
392
374
|
};
|
|
393
|
-
else if (
|
|
394
|
-
const
|
|
395
|
-
var
|
|
396
|
-
return
|
|
397
|
-
}),
|
|
398
|
-
|
|
375
|
+
else if (editing.type === HyperLinkEditSourceType.VIEWING) {
|
|
376
|
+
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.col), range = (_f = (_e = (_d = cell == null ? void 0 : cell.p) == null ? void 0 : _d.body) == null ? void 0 : _e.customRanges) == null ? void 0 : _f.find((range2) => {
|
|
377
|
+
var _a14;
|
|
378
|
+
return range2.rangeType === CustomRangeType.HYPERLINK && ((_a14 = range2.properties) == null ? void 0 : _a14.url);
|
|
379
|
+
}), cellValue = cell == null ? void 0 : cell.v;
|
|
380
|
+
cell && (!BuildTextUtils.transform.isEmptyDocument((_h = (_g = cell.p) == null ? void 0 : _g.body) == null ? void 0 : _h.dataStream) || Tools.isDefine(cellValue)) && setShowLabel(!1), link = {
|
|
399
381
|
id: "",
|
|
400
382
|
display: "",
|
|
401
|
-
payload: (
|
|
402
|
-
row
|
|
403
|
-
column:
|
|
383
|
+
payload: (_j = (_i = range == null ? void 0 : range.properties) == null ? void 0 : _i.url) != null ? _j : "",
|
|
384
|
+
row,
|
|
385
|
+
column: col
|
|
404
386
|
};
|
|
405
387
|
} else {
|
|
406
|
-
const
|
|
407
|
-
|
|
388
|
+
const doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), currentSelection = textSelectionService.getActiveTextRange(), body = doc == null ? void 0 : doc.getBody(), selection = currentSelection && body ? currentSelection : null, customRange2 = selection && ((_l = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_k = body == null ? void 0 : body.customRanges) != null ? _k : [])) == null ? void 0 : _l[0]);
|
|
389
|
+
setShowLabel(!1), link = {
|
|
408
390
|
id: "",
|
|
409
|
-
display:
|
|
410
|
-
payload: (
|
|
411
|
-
row
|
|
412
|
-
column:
|
|
391
|
+
display: label != null ? label : "",
|
|
392
|
+
payload: (_n = (_m = customRange2 == null ? void 0 : customRange2.properties) == null ? void 0 : _m.url) != null ? _n : "",
|
|
393
|
+
row,
|
|
394
|
+
column: col
|
|
413
395
|
};
|
|
414
396
|
}
|
|
415
|
-
|
|
416
|
-
const
|
|
417
|
-
if (
|
|
418
|
-
const
|
|
419
|
-
|
|
397
|
+
setId(link.id);
|
|
398
|
+
const customLink = sidePanelService.findCustomHyperLink(link);
|
|
399
|
+
if (customLink) {
|
|
400
|
+
const customLinkInfo = customLink.convert(link);
|
|
401
|
+
setType(customLinkInfo.type), setPayload(customLinkInfo.payload), setDisplay(customLinkInfo.display);
|
|
420
402
|
return;
|
|
421
403
|
}
|
|
422
|
-
|
|
423
|
-
const
|
|
424
|
-
switch (
|
|
425
|
-
case
|
|
426
|
-
|
|
404
|
+
setDisplay(link.display);
|
|
405
|
+
const linkInfo = parserService.parseHyperLink(link.payload);
|
|
406
|
+
switch (setType(linkInfo.type === SheetHyperLinkType.INVALID ? SheetHyperLinkType.RANGE : linkInfo.type), linkInfo.type) {
|
|
407
|
+
case SheetHyperLinkType.URL: {
|
|
408
|
+
setPayload(linkInfo.url), linkInfo.url === link.display && (setByPayload.current = !0);
|
|
427
409
|
break;
|
|
428
410
|
}
|
|
429
|
-
case
|
|
430
|
-
const
|
|
431
|
-
|
|
411
|
+
case SheetHyperLinkType.RANGE: {
|
|
412
|
+
const params = linkInfo.searchObj, sheetName = params.gid && (_q = (_p = (_o = univerInstanceService.getUnit(editing.unitId)) == null ? void 0 : _o.getSheetBySheetId(params.gid)) == null ? void 0 : _p.getName()) != null ? _q : "", payload2 = serializeRangeWithSheet(sheetName, deserializeRangeWithSheet(params.range).range);
|
|
413
|
+
setPayload(payload2), payload2 === link.display && (setByPayload.current = !0);
|
|
432
414
|
break;
|
|
433
415
|
}
|
|
434
|
-
case
|
|
435
|
-
const
|
|
436
|
-
|
|
416
|
+
case SheetHyperLinkType.SHEET: {
|
|
417
|
+
const params = linkInfo.searchObj;
|
|
418
|
+
setPayload(params.gid);
|
|
437
419
|
break;
|
|
438
420
|
}
|
|
439
|
-
case
|
|
440
|
-
const
|
|
441
|
-
|
|
421
|
+
case SheetHyperLinkType.DEFINE_NAME: {
|
|
422
|
+
const params = linkInfo.searchObj;
|
|
423
|
+
setPayload(params.rangeid);
|
|
442
424
|
break;
|
|
443
425
|
}
|
|
444
426
|
default:
|
|
445
|
-
|
|
427
|
+
setPayload("");
|
|
446
428
|
break;
|
|
447
429
|
}
|
|
448
430
|
}
|
|
449
|
-
}, [
|
|
450
|
-
let
|
|
451
|
-
if (
|
|
452
|
-
const
|
|
453
|
-
|
|
431
|
+
}, [editing, resolverService, sidePanelService, textSelectionService, univerInstanceService]), useEffect(() => {
|
|
432
|
+
let id2 = null;
|
|
433
|
+
if (editing && !editing.customRangeId && editing.type === HyperLinkEditSourceType.VIEWING && Tools.isDefine(editing.row) && Tools.isDefine(editing.col)) {
|
|
434
|
+
const workbook2 = univerInstanceService.getUnit(editing.unitId, UniverInstanceType.UNIVER_SHEET), worksheet = workbook2 == null ? void 0 : workbook2.getSheetBySheetId(editing.subUnitId), mergeInfo = worksheet == null ? void 0 : worksheet.getMergedCell(editing.row, editing.col), color = new ColorKit(themeService.getCurrentTheme().hyacinth500).toRgb();
|
|
435
|
+
id2 = markSelectionService.addShape(
|
|
454
436
|
{
|
|
455
|
-
range:
|
|
456
|
-
startColumn:
|
|
457
|
-
endColumn:
|
|
458
|
-
startRow:
|
|
459
|
-
endRow:
|
|
437
|
+
range: mergeInfo != null ? mergeInfo : {
|
|
438
|
+
startColumn: editing.col,
|
|
439
|
+
endColumn: editing.col,
|
|
440
|
+
startRow: editing.row,
|
|
441
|
+
endRow: editing.row
|
|
460
442
|
},
|
|
461
443
|
style: {
|
|
462
444
|
// hasAutoFill: false,
|
|
463
|
-
fill: `rgb(${
|
|
445
|
+
fill: `rgb(${color.r}, ${color.g}, ${color.b}, 0.12)`,
|
|
464
446
|
strokeWidth: 1,
|
|
465
447
|
stroke: "#FFBD37",
|
|
466
448
|
widgets: {}
|
|
@@ -472,517 +454,524 @@ const ki = "univer-cell-link-edit", Ti = "univer-cell-link-edit-buttons", _n = {
|
|
|
472
454
|
);
|
|
473
455
|
}
|
|
474
456
|
return () => {
|
|
475
|
-
|
|
457
|
+
id2 && markSelectionService.removeShape(id2);
|
|
476
458
|
};
|
|
477
|
-
}, [
|
|
478
|
-
|
|
479
|
-
}, [
|
|
480
|
-
const
|
|
481
|
-
if (
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
459
|
+
}, [editing, markSelectionService, themeService, univerInstanceService]), useEffect(() => {
|
|
460
|
+
isFocusRangeSelectorSet(type === SheetHyperLinkType.RANGE);
|
|
461
|
+
}, [type]), useEffect(() => {
|
|
462
|
+
const render2 = (editing == null ? void 0 : editing.type) === HyperLinkEditSourceType.ZEN_EDITOR ? renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY) : renderManagerService.getRenderById(editorBridgeService.getCurrentEditorId()), disposeCollection = new DisposableCollection();
|
|
463
|
+
if (render2) {
|
|
464
|
+
const selectionRenderService = render2.with(DocSelectionRenderService);
|
|
465
|
+
selectionRenderService.setReserveRangesStatus(!0), disposeCollection.add(() => {
|
|
466
|
+
selectionRenderService.setReserveRangesStatus(!1);
|
|
485
467
|
});
|
|
486
468
|
}
|
|
487
469
|
return () => {
|
|
488
|
-
|
|
470
|
+
editorBridgeService.disableForceKeepVisible(), disposeCollection.dispose();
|
|
489
471
|
};
|
|
490
|
-
}, [
|
|
491
|
-
|
|
492
|
-
}), [
|
|
493
|
-
|
|
494
|
-
}, [
|
|
495
|
-
if (
|
|
496
|
-
return
|
|
497
|
-
|
|
472
|
+
}, [editing == null ? void 0 : editing.type, editorBridgeService, renderManagerService]), useEffect(() => (popupService.setIsKeepVisible(isFocusRangeSelector), () => {
|
|
473
|
+
popupService.setIsKeepVisible(!1);
|
|
474
|
+
}), [isFocusRangeSelector, popupService]), useEffect(() => () => {
|
|
475
|
+
zenZoneService.temporaryHidden && (zenZoneService.show(), contextService.setContextValue(FOCUSING_SHEET, !1));
|
|
476
|
+
}, [contextService, zenZoneService]), useEffect(() => {
|
|
477
|
+
if (isFocusRangeSelector)
|
|
478
|
+
return editorBridgeService.enableForceKeepVisible(), () => {
|
|
479
|
+
editorBridgeService.disableForceKeepVisible();
|
|
498
480
|
};
|
|
499
|
-
}, [
|
|
500
|
-
const
|
|
481
|
+
}, [isFocusRangeSelector, editorBridgeService]);
|
|
482
|
+
const linkTypeOptions = [
|
|
501
483
|
{
|
|
502
|
-
label:
|
|
503
|
-
value:
|
|
484
|
+
label: localeService.t("hyperLink.form.link"),
|
|
485
|
+
value: SheetHyperLinkType.URL
|
|
504
486
|
},
|
|
505
487
|
{
|
|
506
|
-
label:
|
|
507
|
-
value:
|
|
488
|
+
label: localeService.t("hyperLink.form.range"),
|
|
489
|
+
value: SheetHyperLinkType.RANGE
|
|
508
490
|
},
|
|
509
491
|
{
|
|
510
|
-
label:
|
|
511
|
-
value:
|
|
492
|
+
label: localeService.t("hyperLink.form.worksheet"),
|
|
493
|
+
value: SheetHyperLinkType.SHEET
|
|
512
494
|
},
|
|
513
495
|
{
|
|
514
|
-
label:
|
|
515
|
-
value:
|
|
496
|
+
label: localeService.t("hyperLink.form.definedName"),
|
|
497
|
+
value: SheetHyperLinkType.DEFINE_NAME
|
|
516
498
|
},
|
|
517
|
-
...
|
|
499
|
+
...sidePanelOptions
|
|
518
500
|
];
|
|
519
|
-
if (!
|
|
501
|
+
if (!workbook)
|
|
520
502
|
return;
|
|
521
|
-
const
|
|
522
|
-
label:
|
|
523
|
-
value:
|
|
524
|
-
})),
|
|
525
|
-
if (
|
|
526
|
-
return
|
|
527
|
-
if (
|
|
528
|
-
const
|
|
529
|
-
if (
|
|
530
|
-
return `#gid=${
|
|
503
|
+
const hiddens = workbook.getHiddenWorksheets(), sheetsOption = workbook.getSheets().map((sheet) => ({ label: sheet.getName(), value: sheet.getSheetId() })).filter((opt) => hiddens.indexOf(opt.value) === -1), definedNames = Object.values((_a12 = definedNameService.getDefinedNameMap(workbook.getUnitId())) != null ? _a12 : {}).map((value) => ({
|
|
504
|
+
label: value.name,
|
|
505
|
+
value: value.id
|
|
506
|
+
})), formatUrl = /* @__PURE__ */ __name((type2, payload2) => {
|
|
507
|
+
if (type2 === SheetHyperLinkType.URL)
|
|
508
|
+
return serializeUrl(payload2);
|
|
509
|
+
if (type2 === SheetHyperLinkType.RANGE) {
|
|
510
|
+
const info = deserializeRangeWithSheet(payload2), worksheet = workbook.getSheetBySheetName(info.sheetName);
|
|
511
|
+
if (worksheet)
|
|
512
|
+
return `#gid=${worksheet.getSheetId()}&range=${serializeRange(info.range)}`;
|
|
531
513
|
}
|
|
532
|
-
return `#${
|
|
533
|
-
},
|
|
534
|
-
var
|
|
535
|
-
const
|
|
536
|
-
if (!
|
|
514
|
+
return `#${type2}=${payload2}`;
|
|
515
|
+
}, "formatUrl"), handleRangeChange = useEvent((rangeText) => {
|
|
516
|
+
var _a13;
|
|
517
|
+
const range = rangeText.split(",").map(deserializeRangeWithSheet)[0];
|
|
518
|
+
if (!range || !isValidRange(range.range))
|
|
537
519
|
return;
|
|
538
|
-
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
}),
|
|
542
|
-
if (
|
|
543
|
-
|
|
520
|
+
range.sheetName || (range.sheetName = ((_a13 = workbook.getActiveSheet()) == null ? void 0 : _a13.getName()) || "");
|
|
521
|
+
const newPayload = serializeRangeToRefString(range);
|
|
522
|
+
setPayload(newPayload), newPayload && (setByPayload.current || !display) && (setDisplay(newPayload), setByPayload.current = !0);
|
|
523
|
+
}), handleSubmit = /* @__PURE__ */ __name(async () => {
|
|
524
|
+
if (showLabel && !display || !payload || type === SheetHyperLinkType.URL && !isLegalLink(payload)) {
|
|
525
|
+
setShowError(!0);
|
|
544
526
|
return;
|
|
545
527
|
}
|
|
546
|
-
if (
|
|
547
|
-
if (
|
|
548
|
-
const
|
|
549
|
-
await
|
|
550
|
-
id
|
|
551
|
-
unitId:
|
|
552
|
-
subUnitId:
|
|
528
|
+
if (editing)
|
|
529
|
+
if (id) {
|
|
530
|
+
const commandId = editing.type === HyperLinkEditSourceType.ZEN_EDITOR || editing.type === HyperLinkEditSourceType.EDITING ? UpdateRichHyperLinkCommand.id : UpdateHyperLinkCommand.id;
|
|
531
|
+
await commandService.executeCommand(commandId, {
|
|
532
|
+
id,
|
|
533
|
+
unitId: editing.unitId,
|
|
534
|
+
subUnitId: editing.subUnitId,
|
|
553
535
|
payload: {
|
|
554
|
-
display:
|
|
555
|
-
payload:
|
|
536
|
+
display: showLabel ? display : "",
|
|
537
|
+
payload: formatUrl(type, payload)
|
|
556
538
|
},
|
|
557
|
-
row:
|
|
558
|
-
column:
|
|
559
|
-
documentId:
|
|
539
|
+
row: editing.row,
|
|
540
|
+
column: editing.col,
|
|
541
|
+
documentId: editing.type === HyperLinkEditSourceType.ZEN_EDITOR ? DOCS_ZEN_EDITOR_UNIT_ID_KEY : editorBridgeService.getCurrentEditorId()
|
|
560
542
|
});
|
|
561
543
|
} else {
|
|
562
|
-
const
|
|
563
|
-
await
|
|
564
|
-
unitId:
|
|
565
|
-
subUnitId:
|
|
544
|
+
const commandId = editing.type === HyperLinkEditSourceType.ZEN_EDITOR || editing.type === HyperLinkEditSourceType.EDITING ? AddRichHyperLinkCommand.id : AddHyperLinkCommand.id;
|
|
545
|
+
await commandService.executeCommand(commandId, {
|
|
546
|
+
unitId: editing.unitId,
|
|
547
|
+
subUnitId: editing.subUnitId,
|
|
566
548
|
link: {
|
|
567
|
-
id:
|
|
568
|
-
row:
|
|
569
|
-
column:
|
|
570
|
-
payload:
|
|
571
|
-
display:
|
|
549
|
+
id: generateRandomId(),
|
|
550
|
+
row: editing.row,
|
|
551
|
+
column: editing.col,
|
|
552
|
+
payload: formatUrl(type, payload),
|
|
553
|
+
display: showLabel ? display : ""
|
|
572
554
|
},
|
|
573
|
-
documentId:
|
|
555
|
+
documentId: editing.type === HyperLinkEditSourceType.ZEN_EDITOR ? DOCS_ZEN_EDITOR_UNIT_ID_KEY : editorBridgeService.getCurrentEditorId()
|
|
574
556
|
});
|
|
575
557
|
}
|
|
576
|
-
if ((
|
|
577
|
-
await
|
|
578
|
-
unitId:
|
|
579
|
-
subUnitId:
|
|
558
|
+
if ((editing == null ? void 0 : editing.type) === HyperLinkEditSourceType.VIEWING) {
|
|
559
|
+
await commandService.executeCommand(SetWorksheetActiveOperation.id, {
|
|
560
|
+
unitId: editing.unitId,
|
|
561
|
+
subUnitId: editing.subUnitId
|
|
580
562
|
});
|
|
581
|
-
const
|
|
582
|
-
await
|
|
563
|
+
const GAP = 1;
|
|
564
|
+
await commandService.executeCommand(ScrollToRangeOperation.id, {
|
|
583
565
|
range: {
|
|
584
|
-
startRow: Math.max(
|
|
585
|
-
endRow:
|
|
586
|
-
startColumn: Math.max(
|
|
587
|
-
endColumn:
|
|
566
|
+
startRow: Math.max(editing.row - GAP, 0),
|
|
567
|
+
endRow: editing.row + GAP,
|
|
568
|
+
startColumn: Math.max(editing.col - GAP, 0),
|
|
569
|
+
endColumn: editing.col + GAP
|
|
588
570
|
}
|
|
589
571
|
});
|
|
590
572
|
}
|
|
591
|
-
|
|
592
|
-
},
|
|
593
|
-
var
|
|
594
|
-
if (
|
|
573
|
+
commandService.executeCommand(CloseHyperLinkPopupOperation.id);
|
|
574
|
+
}, "handleSubmit"), handlePanelClick = /* @__PURE__ */ __name((e) => {
|
|
575
|
+
var _a13;
|
|
576
|
+
if (type !== SheetHyperLinkType.RANGE)
|
|
595
577
|
return;
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
};
|
|
599
|
-
return
|
|
600
|
-
|
|
601
|
-
|
|
578
|
+
const handleOutClick = (_a13 = rangeSelectorActionsRef.current) == null ? void 0 : _a13.handleOutClick;
|
|
579
|
+
handleOutClick && handleOutClick(e, () => isFocusRangeSelectorSet(!1));
|
|
580
|
+
}, "handlePanelClick");
|
|
581
|
+
return editing ? /* @__PURE__ */ jsxs("div", { className: styles$1.cellLinkEdit, style: { display: hide ? "none" : "block" }, onClick: handlePanelClick, children: [
|
|
582
|
+
showLabel ? /* @__PURE__ */ jsx(
|
|
583
|
+
FormLayout,
|
|
602
584
|
{
|
|
603
|
-
label:
|
|
604
|
-
error:
|
|
605
|
-
children: /* @__PURE__ */
|
|
606
|
-
|
|
585
|
+
label: localeService.t("hyperLink.form.label"),
|
|
586
|
+
error: showError && !display ? localeService.t("hyperLink.form.inputError") : "",
|
|
587
|
+
children: /* @__PURE__ */ jsx(
|
|
588
|
+
Input,
|
|
607
589
|
{
|
|
608
|
-
value:
|
|
609
|
-
onChange: (
|
|
610
|
-
|
|
611
|
-
},
|
|
612
|
-
placeholder:
|
|
590
|
+
value: display,
|
|
591
|
+
onChange: /* @__PURE__ */ __name((v) => {
|
|
592
|
+
setDisplay(v), setByPayload.current = !1;
|
|
593
|
+
}, "onChange"),
|
|
594
|
+
placeholder: localeService.t("hyperLink.form.labelPlaceholder"),
|
|
613
595
|
autoFocus: !0,
|
|
614
|
-
onKeyDown: (
|
|
615
|
-
|
|
616
|
-
}
|
|
596
|
+
onKeyDown: /* @__PURE__ */ __name((e) => {
|
|
597
|
+
e.keyCode === KeyCode.ENTER && handleSubmit();
|
|
598
|
+
}, "onKeyDown")
|
|
617
599
|
}
|
|
618
600
|
)
|
|
619
601
|
}
|
|
620
602
|
) : null,
|
|
621
|
-
/* @__PURE__ */
|
|
622
|
-
|
|
603
|
+
/* @__PURE__ */ jsx(FormLayout, { label: localeService.t("hyperLink.form.type"), children: /* @__PURE__ */ jsx(
|
|
604
|
+
Select,
|
|
623
605
|
{
|
|
624
|
-
options:
|
|
625
|
-
value:
|
|
626
|
-
onChange: (
|
|
627
|
-
|
|
628
|
-
}
|
|
606
|
+
options: linkTypeOptions,
|
|
607
|
+
value: type,
|
|
608
|
+
onChange: /* @__PURE__ */ __name((newType) => {
|
|
609
|
+
setType(newType), setPayload("");
|
|
610
|
+
}, "onChange")
|
|
629
611
|
}
|
|
630
612
|
) }),
|
|
631
|
-
|
|
632
|
-
|
|
613
|
+
type === SheetHyperLinkType.URL && /* @__PURE__ */ jsx(
|
|
614
|
+
FormLayout,
|
|
633
615
|
{
|
|
634
|
-
error:
|
|
635
|
-
children: /* @__PURE__ */
|
|
636
|
-
|
|
616
|
+
error: showError ? payload ? isLegalLink(payload) ? "" : localeService.t("hyperLink.form.linkError") : localeService.t("hyperLink.form.inputError") : "",
|
|
617
|
+
children: /* @__PURE__ */ jsx(
|
|
618
|
+
Input,
|
|
637
619
|
{
|
|
638
|
-
value:
|
|
639
|
-
onChange: (
|
|
640
|
-
|
|
641
|
-
},
|
|
642
|
-
placeholder:
|
|
620
|
+
value: payload,
|
|
621
|
+
onChange: /* @__PURE__ */ __name((newLink) => {
|
|
622
|
+
setPayload(newLink), newLink && (setByPayload.current || !display || display === payload) && (setDisplay(newLink), setByPayload.current = !0);
|
|
623
|
+
}, "onChange"),
|
|
624
|
+
placeholder: localeService.t("hyperLink.form.linkPlaceholder"),
|
|
643
625
|
autoFocus: !0,
|
|
644
|
-
onKeyDown: (
|
|
645
|
-
|
|
646
|
-
}
|
|
626
|
+
onKeyDown: /* @__PURE__ */ __name((e) => {
|
|
627
|
+
e.keyCode === KeyCode.ENTER && handleSubmit();
|
|
628
|
+
}, "onKeyDown")
|
|
647
629
|
}
|
|
648
630
|
)
|
|
649
631
|
}
|
|
650
632
|
),
|
|
651
|
-
|
|
652
|
-
|
|
633
|
+
type === SheetHyperLinkType.RANGE && /* @__PURE__ */ jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ jsx(
|
|
634
|
+
RangeSelector,
|
|
653
635
|
{
|
|
654
|
-
unitId:
|
|
655
|
-
subUnitId
|
|
636
|
+
unitId: workbook.getUnitId(),
|
|
637
|
+
subUnitId,
|
|
656
638
|
isOnlyOneRange: !0,
|
|
657
639
|
isSupportAcrossSheet: !0,
|
|
658
|
-
initValue:
|
|
659
|
-
onChange:
|
|
660
|
-
isFocus:
|
|
661
|
-
onFocus: () =>
|
|
662
|
-
actions:
|
|
663
|
-
onRangeSelectorDialogVisibleChange: async (
|
|
664
|
-
var
|
|
665
|
-
if (
|
|
666
|
-
|
|
640
|
+
initValue: payload,
|
|
641
|
+
onChange: handleRangeChange,
|
|
642
|
+
isFocus: isFocusRangeSelector,
|
|
643
|
+
onFocus: /* @__PURE__ */ __name(() => isFocusRangeSelectorSet(!0), "onFocus"),
|
|
644
|
+
actions: rangeSelectorActionsRef.current,
|
|
645
|
+
onRangeSelectorDialogVisibleChange: /* @__PURE__ */ __name(async (visible) => {
|
|
646
|
+
var _a13, _b;
|
|
647
|
+
if (visible)
|
|
648
|
+
editing.type === HyperLinkEditSourceType.ZEN_EDITOR && (zenZoneService.hide(), contextService.setContextValue(FOCUSING_SHEET, !0)), editing.type !== HyperLinkEditSourceType.VIEWING && editorBridgeService.enableForceKeepVisible(), setHide(!0);
|
|
667
649
|
else {
|
|
668
|
-
if (await
|
|
669
|
-
await
|
|
670
|
-
unitId:
|
|
671
|
-
subUnitId:
|
|
672
|
-
selections: [{ range: { startRow:
|
|
673
|
-
}),
|
|
674
|
-
const
|
|
675
|
-
|
|
650
|
+
if (await resolverService.navigateToRange(editing.unitId, editing.subUnitId, { startRow: editing.row, endRow: editing.row, startColumn: editing.col, endColumn: editing.col }, !0), editing.type === HyperLinkEditSourceType.ZEN_EDITOR) {
|
|
651
|
+
await commandService.executeCommand(SetSelectionsOperation.id, {
|
|
652
|
+
unitId: editing.unitId,
|
|
653
|
+
subUnitId: editing.subUnitId,
|
|
654
|
+
selections: [{ range: { startRow: editing.row, endRow: editing.row, startColumn: editing.col, endColumn: editing.col } }]
|
|
655
|
+
}), zenZoneService.show(), contextService.setContextValue(FOCUSING_SHEET, !1);
|
|
656
|
+
const docBackScrollRenderController = (_a13 = renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY)) == null ? void 0 : _a13.with(DocBackScrollRenderController), range = (_b = docSelectionManagerService.getTextRanges({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY })) == null ? void 0 : _b[0];
|
|
657
|
+
docBackScrollRenderController && range && (docBackScrollRenderController.scrollToRange(range), docSelectionManagerService.refreshSelection({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY }));
|
|
676
658
|
}
|
|
677
|
-
|
|
659
|
+
editorBridgeService.disableForceKeepVisible(), setHide(!1);
|
|
678
660
|
}
|
|
679
|
-
}
|
|
661
|
+
}, "onRangeSelectorDialogVisibleChange")
|
|
680
662
|
}
|
|
681
663
|
) }),
|
|
682
|
-
|
|
683
|
-
|
|
664
|
+
type === SheetHyperLinkType.SHEET && /* @__PURE__ */ jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsx(
|
|
665
|
+
Select,
|
|
684
666
|
{
|
|
685
|
-
options:
|
|
686
|
-
value:
|
|
687
|
-
onChange: (
|
|
688
|
-
var
|
|
689
|
-
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
}
|
|
667
|
+
options: sheetsOption,
|
|
668
|
+
value: payload,
|
|
669
|
+
onChange: /* @__PURE__ */ __name((newPayload) => {
|
|
670
|
+
var _a13, _b;
|
|
671
|
+
setPayload(newPayload);
|
|
672
|
+
const label = (_a13 = sheetsOption.find((i) => i.value === newPayload)) == null ? void 0 : _a13.label, oldLabel = (_b = sheetsOption.find((i) => i.value === payload)) == null ? void 0 : _b.label;
|
|
673
|
+
label && (setByPayload.current || !display || display === oldLabel) && (setDisplay(label), setByPayload.current = !0);
|
|
674
|
+
}, "onChange")
|
|
693
675
|
}
|
|
694
676
|
) }),
|
|
695
|
-
|
|
696
|
-
|
|
677
|
+
type === SheetHyperLinkType.DEFINE_NAME && /* @__PURE__ */ jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsx(
|
|
678
|
+
Select,
|
|
697
679
|
{
|
|
698
|
-
options:
|
|
699
|
-
value:
|
|
700
|
-
onChange: (
|
|
701
|
-
var
|
|
702
|
-
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
}
|
|
680
|
+
options: definedNames,
|
|
681
|
+
value: payload,
|
|
682
|
+
onChange: /* @__PURE__ */ __name((newValue) => {
|
|
683
|
+
var _a13, _b;
|
|
684
|
+
setPayload(newValue);
|
|
685
|
+
const label = (_a13 = definedNames.find((i) => i.value === newValue)) == null ? void 0 : _a13.label, oldLabel = (_b = definedNames.find((i) => i.value === payload)) == null ? void 0 : _b.label;
|
|
686
|
+
label && (setByPayload.current || !display || display === oldLabel) && (setDisplay(label), setByPayload.current = !0);
|
|
687
|
+
}, "onChange")
|
|
706
688
|
}
|
|
707
689
|
) }),
|
|
708
|
-
(
|
|
709
|
-
|
|
690
|
+
(customHyperLinkSidePanel == null ? void 0 : customHyperLinkSidePanel.Form) && /* @__PURE__ */ jsx(
|
|
691
|
+
customHyperLinkSidePanel.Form,
|
|
710
692
|
{
|
|
711
|
-
linkId:
|
|
712
|
-
payload
|
|
713
|
-
display
|
|
714
|
-
showError
|
|
715
|
-
setByPayload
|
|
716
|
-
setDisplay: (
|
|
717
|
-
|
|
718
|
-
},
|
|
719
|
-
setPayload
|
|
693
|
+
linkId: id,
|
|
694
|
+
payload,
|
|
695
|
+
display,
|
|
696
|
+
showError,
|
|
697
|
+
setByPayload,
|
|
698
|
+
setDisplay: /* @__PURE__ */ __name((newLink) => {
|
|
699
|
+
setDisplay(newLink), setByPayload.current = !0;
|
|
700
|
+
}, "setDisplay"),
|
|
701
|
+
setPayload
|
|
720
702
|
}
|
|
721
703
|
),
|
|
722
|
-
/* @__PURE__ */
|
|
723
|
-
/* @__PURE__ */
|
|
724
|
-
|
|
704
|
+
/* @__PURE__ */ jsxs("div", { className: styles$1.cellLinkEditButtons, children: [
|
|
705
|
+
/* @__PURE__ */ jsx(
|
|
706
|
+
Button,
|
|
725
707
|
{
|
|
726
|
-
onClick: () => {
|
|
727
|
-
|
|
728
|
-
},
|
|
729
|
-
children:
|
|
708
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
709
|
+
editing && resolverService.navigateToRange(editing.unitId, editing.subUnitId, { startRow: editing.row, endRow: editing.row, startColumn: editing.col, endColumn: editing.col }, !0), commandService.executeCommand(CloseHyperLinkPopupOperation.id);
|
|
710
|
+
}, "onClick"),
|
|
711
|
+
children: localeService.t("hyperLink.form.cancel")
|
|
730
712
|
}
|
|
731
713
|
),
|
|
732
|
-
/* @__PURE__ */
|
|
733
|
-
|
|
714
|
+
/* @__PURE__ */ jsx(
|
|
715
|
+
Button,
|
|
734
716
|
{
|
|
735
717
|
type: "primary",
|
|
736
718
|
style: { marginLeft: 8 },
|
|
737
|
-
onClick: async () => {
|
|
738
|
-
|
|
739
|
-
},
|
|
740
|
-
children:
|
|
719
|
+
onClick: /* @__PURE__ */ __name(async () => {
|
|
720
|
+
handleSubmit();
|
|
721
|
+
}, "onClick"),
|
|
722
|
+
children: localeService.t("hyperLink.form.ok")
|
|
741
723
|
}
|
|
742
724
|
)
|
|
743
725
|
] })
|
|
744
726
|
] }) : null;
|
|
745
|
-
};
|
|
746
|
-
|
|
747
|
-
var
|
|
748
|
-
return
|
|
749
|
-
for (var
|
|
750
|
-
|
|
751
|
-
for (var
|
|
727
|
+
}, "CellLinkEdit");
|
|
728
|
+
CellLinkEdit.componentKey = "univer.sheet.cell-link-edit";
|
|
729
|
+
var __assign = function() {
|
|
730
|
+
return __assign = Object.assign || function(t) {
|
|
731
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
732
|
+
s = arguments[i];
|
|
733
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
752
734
|
}
|
|
753
735
|
return t;
|
|
754
|
-
},
|
|
755
|
-
},
|
|
756
|
-
var
|
|
757
|
-
for (var
|
|
758
|
-
if (
|
|
759
|
-
for (var
|
|
760
|
-
e.indexOf(i
|
|
761
|
-
return
|
|
762
|
-
},
|
|
763
|
-
var
|
|
764
|
-
return
|
|
736
|
+
}, __assign.apply(this, arguments);
|
|
737
|
+
}, __rest = function(s, e) {
|
|
738
|
+
var t = {};
|
|
739
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
740
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
741
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
742
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
743
|
+
return t;
|
|
744
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
745
|
+
var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
|
|
746
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
765
747
|
});
|
|
766
|
-
function
|
|
767
|
-
return
|
|
768
|
-
return
|
|
748
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
749
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
750
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
769
751
|
}));
|
|
770
752
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
753
|
+
__name(render, "render");
|
|
754
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
755
|
+
var attrs = __assign({}, node.attrs);
|
|
756
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
757
|
+
var defIds = runtimeProps.defIds;
|
|
758
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a12) {
|
|
759
|
+
var key = _a12[0], value = _a12[1];
|
|
760
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
761
|
+
})), attrs;
|
|
779
762
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
763
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
764
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
765
|
+
var _a12, defIds = runtimeProps.defIds;
|
|
766
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a12 = node.children) === null || _a12 === void 0) && _a12.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
767
|
+
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
768
|
+
}) }) : node;
|
|
785
769
|
}
|
|
786
|
-
|
|
770
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
771
|
+
function generateShortUuid() {
|
|
787
772
|
return Math.random().toString(36).substring(2, 8);
|
|
788
773
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
774
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
775
|
+
IconBase.displayName = "UniverIcon";
|
|
776
|
+
var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, AllBorderSingle = forwardRef(function(props, ref) {
|
|
777
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
792
778
|
id: "all-border-single",
|
|
793
|
-
ref
|
|
794
|
-
icon:
|
|
779
|
+
ref,
|
|
780
|
+
icon: element$5
|
|
795
781
|
}));
|
|
796
782
|
});
|
|
797
|
-
|
|
798
|
-
var
|
|
799
|
-
return
|
|
783
|
+
AllBorderSingle.displayName = "AllBorderSingle";
|
|
784
|
+
var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CopySingle = forwardRef(function(props, ref) {
|
|
785
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
800
786
|
id: "copy-single",
|
|
801
|
-
ref
|
|
802
|
-
icon:
|
|
787
|
+
ref,
|
|
788
|
+
icon: element$4
|
|
803
789
|
}));
|
|
804
790
|
});
|
|
805
|
-
|
|
806
|
-
var $
|
|
807
|
-
return
|
|
791
|
+
CopySingle.displayName = "CopySingle";
|
|
792
|
+
var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z" } }] }, LinkSingle = forwardRef(function(props, ref) {
|
|
793
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
808
794
|
id: "link-single",
|
|
809
|
-
ref
|
|
810
|
-
icon: $
|
|
795
|
+
ref,
|
|
796
|
+
icon: element$3
|
|
811
797
|
}));
|
|
812
798
|
});
|
|
813
|
-
|
|
814
|
-
var
|
|
815
|
-
return
|
|
799
|
+
LinkSingle.displayName = "LinkSingle";
|
|
800
|
+
var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z" } }] }, UnlinkSingle = forwardRef(function(props, ref) {
|
|
801
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
816
802
|
id: "unlink-single",
|
|
817
|
-
ref
|
|
818
|
-
icon:
|
|
803
|
+
ref,
|
|
804
|
+
icon: element$2
|
|
819
805
|
}));
|
|
820
806
|
});
|
|
821
|
-
|
|
822
|
-
var
|
|
823
|
-
return
|
|
807
|
+
UnlinkSingle.displayName = "UnlinkSingle";
|
|
808
|
+
var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z" } }] }, WriteSingle = forwardRef(function(props, ref) {
|
|
809
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
824
810
|
id: "write-single",
|
|
825
|
-
ref
|
|
826
|
-
icon:
|
|
811
|
+
ref,
|
|
812
|
+
icon: element$1
|
|
827
813
|
}));
|
|
828
814
|
});
|
|
829
|
-
|
|
830
|
-
var
|
|
831
|
-
return
|
|
815
|
+
WriteSingle.displayName = "WriteSingle";
|
|
816
|
+
var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#35BD4B", d: "M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z" } }, { tag: "path", attrs: { fill: "#32A846", d: "M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Xlsx = forwardRef(function(props, ref) {
|
|
817
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
832
818
|
id: "xlsx",
|
|
833
|
-
ref
|
|
834
|
-
icon:
|
|
819
|
+
ref,
|
|
820
|
+
icon: element
|
|
835
821
|
}));
|
|
836
822
|
});
|
|
837
|
-
|
|
838
|
-
function
|
|
839
|
-
var
|
|
840
|
-
if (typeof
|
|
841
|
-
else if (typeof
|
|
842
|
-
var
|
|
843
|
-
for (
|
|
844
|
-
} else for (
|
|
845
|
-
return
|
|
823
|
+
Xlsx.displayName = "Xlsx";
|
|
824
|
+
function r(e) {
|
|
825
|
+
var t, f, n = "";
|
|
826
|
+
if (typeof e == "string" || typeof e == "number") n += e;
|
|
827
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
828
|
+
var o = e.length;
|
|
829
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
830
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
831
|
+
return n;
|
|
846
832
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
833
|
+
__name(r, "r");
|
|
834
|
+
function clsx() {
|
|
835
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
836
|
+
return n;
|
|
850
837
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
[
|
|
863
|
-
[
|
|
864
|
-
[
|
|
865
|
-
[
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
838
|
+
__name(clsx, "clsx");
|
|
839
|
+
const 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 = {
|
|
840
|
+
cellLink,
|
|
841
|
+
cellLinkType,
|
|
842
|
+
cellLinkContent,
|
|
843
|
+
cellLinkContentError,
|
|
844
|
+
cellLinkUrl,
|
|
845
|
+
cellLinkOperations,
|
|
846
|
+
cellLinkOperation,
|
|
847
|
+
cellLinkOperationError
|
|
848
|
+
}, iconsMap = {
|
|
849
|
+
[SheetHyperLinkType.URL]: /* @__PURE__ */ jsx(LinkSingle, {}),
|
|
850
|
+
[SheetHyperLinkType.SHEET]: /* @__PURE__ */ jsx(Xlsx, {}),
|
|
851
|
+
[SheetHyperLinkType.RANGE]: /* @__PURE__ */ jsx(AllBorderSingle, {}),
|
|
852
|
+
[SheetHyperLinkType.DEFINE_NAME]: /* @__PURE__ */ jsx(AllBorderSingle, {}),
|
|
853
|
+
[SheetHyperLinkType.INVALID]: /* @__PURE__ */ jsx(AllBorderSingle, {})
|
|
854
|
+
}, CellLinkPopupPure = /* @__PURE__ */ __name((props) => {
|
|
855
|
+
var _a12, _b;
|
|
856
|
+
const popupService = useDependency(SheetsHyperLinkPopupService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), resolverService = useDependency(SheetsHyperLinkResolverService), editorBridgeService = useDependency(IEditorBridgeService), parserHyperLinkService = useDependency(SheetsHyperLinkParserService), zenZoneService = useDependency(IZenZoneService), { customRange, row, col, unitId, subUnitId, editPermission, copyPermission, type } = props;
|
|
857
|
+
if (!((_a12 = customRange == null ? void 0 : customRange.properties) != null && _a12.url))
|
|
870
858
|
return null;
|
|
871
|
-
const
|
|
872
|
-
return /* @__PURE__ */
|
|
873
|
-
/* @__PURE__ */
|
|
859
|
+
const linkObj = parserHyperLinkService.parseHyperLink((_b = customRange.properties.url) != null ? _b : ""), isError = linkObj.type === SheetHyperLinkType.INVALID;
|
|
860
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.cellLink, onClick: /* @__PURE__ */ __name(() => popupService.hideCurrentPopup(), "onClick"), children: [
|
|
861
|
+
/* @__PURE__ */ jsxs(
|
|
874
862
|
"div",
|
|
875
863
|
{
|
|
876
|
-
className:
|
|
877
|
-
onClick: () => {
|
|
878
|
-
|
|
879
|
-
},
|
|
864
|
+
className: clsx(styles.cellLinkContent, { [styles.cellLinkContentError]: isError }),
|
|
865
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
866
|
+
zenZoneService.visible || isError || resolverService.navigate(linkObj);
|
|
867
|
+
}, "onClick"),
|
|
880
868
|
children: [
|
|
881
|
-
/* @__PURE__ */
|
|
882
|
-
/* @__PURE__ */
|
|
869
|
+
/* @__PURE__ */ jsx("div", { className: styles.cellLinkType, children: iconsMap[linkObj.type] }),
|
|
870
|
+
/* @__PURE__ */ jsx(Tooltip, { showIfEllipsis: !0, title: linkObj.name, asChild: !0, children: /* @__PURE__ */ jsx("span", { className: styles.cellLinkUrl, children: linkObj.name }) })
|
|
883
871
|
]
|
|
884
872
|
}
|
|
885
873
|
),
|
|
886
|
-
/* @__PURE__ */
|
|
887
|
-
|
|
874
|
+
/* @__PURE__ */ jsxs("div", { className: styles.cellLinkOperations, children: [
|
|
875
|
+
copyPermission && /* @__PURE__ */ jsx(
|
|
888
876
|
"div",
|
|
889
877
|
{
|
|
890
|
-
className:
|
|
891
|
-
onClick: () => {
|
|
892
|
-
if (!
|
|
893
|
-
if (
|
|
894
|
-
const
|
|
895
|
-
|
|
878
|
+
className: clsx(styles.cellLinkOperation, { [styles.cellLinkOperationError]: isError }),
|
|
879
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
880
|
+
if (!isError) {
|
|
881
|
+
if (linkObj.type !== SheetHyperLinkType.URL) {
|
|
882
|
+
const url = new URL(window.location.href);
|
|
883
|
+
url.hash = linkObj.url.slice(1), navigator.clipboard.writeText(url.href);
|
|
896
884
|
} else
|
|
897
|
-
navigator.clipboard.writeText(
|
|
898
|
-
|
|
899
|
-
content:
|
|
900
|
-
type:
|
|
885
|
+
navigator.clipboard.writeText(linkObj.url);
|
|
886
|
+
messageService.show({
|
|
887
|
+
content: localeService.t("hyperLink.message.coped"),
|
|
888
|
+
type: MessageType.Info
|
|
901
889
|
});
|
|
902
890
|
}
|
|
903
|
-
},
|
|
904
|
-
children: /* @__PURE__ */
|
|
891
|
+
}, "onClick"),
|
|
892
|
+
children: /* @__PURE__ */ jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.copy"), children: /* @__PURE__ */ jsx(CopySingle, {}) })
|
|
905
893
|
}
|
|
906
894
|
),
|
|
907
|
-
|
|
908
|
-
/* @__PURE__ */
|
|
895
|
+
editPermission && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
896
|
+
/* @__PURE__ */ jsx(
|
|
909
897
|
"div",
|
|
910
898
|
{
|
|
911
|
-
className:
|
|
912
|
-
onClick: () => {
|
|
913
|
-
|
|
914
|
-
unitId
|
|
915
|
-
subUnitId
|
|
916
|
-
row
|
|
917
|
-
col
|
|
918
|
-
customRangeId:
|
|
919
|
-
type
|
|
899
|
+
className: styles.cellLinkOperation,
|
|
900
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
901
|
+
commandService.executeCommand(OpenHyperLinkEditPanelOperation.id, {
|
|
902
|
+
unitId,
|
|
903
|
+
subUnitId,
|
|
904
|
+
row,
|
|
905
|
+
col,
|
|
906
|
+
customRangeId: customRange.rangeId,
|
|
907
|
+
type
|
|
920
908
|
});
|
|
921
|
-
},
|
|
922
|
-
children: /* @__PURE__ */
|
|
909
|
+
}, "onClick"),
|
|
910
|
+
children: /* @__PURE__ */ jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.edit"), children: /* @__PURE__ */ jsx(WriteSingle, {}) })
|
|
923
911
|
}
|
|
924
912
|
),
|
|
925
|
-
/* @__PURE__ */
|
|
913
|
+
/* @__PURE__ */ jsx(
|
|
926
914
|
"div",
|
|
927
915
|
{
|
|
928
|
-
className:
|
|
929
|
-
onClick: () => {
|
|
930
|
-
const
|
|
931
|
-
|
|
932
|
-
unitId
|
|
933
|
-
subUnitId
|
|
934
|
-
id:
|
|
935
|
-
row
|
|
936
|
-
column:
|
|
937
|
-
documentId:
|
|
938
|
-
}) &&
|
|
939
|
-
},
|
|
940
|
-
children: /* @__PURE__ */
|
|
916
|
+
className: styles.cellLinkOperation,
|
|
917
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
918
|
+
const commandId = type === HyperLinkEditSourceType.EDITING || type === HyperLinkEditSourceType.ZEN_EDITOR ? CancelRichHyperLinkCommand.id : CancelHyperLinkCommand.id;
|
|
919
|
+
commandService.syncExecuteCommand(commandId, {
|
|
920
|
+
unitId,
|
|
921
|
+
subUnitId,
|
|
922
|
+
id: customRange.rangeId,
|
|
923
|
+
row,
|
|
924
|
+
column: col,
|
|
925
|
+
documentId: type === HyperLinkEditSourceType.ZEN_EDITOR ? DOCS_ZEN_EDITOR_UNIT_ID_KEY : editorBridgeService.getCurrentEditorId()
|
|
926
|
+
}) && popupService.hideCurrentPopup(void 0, !0);
|
|
927
|
+
}, "onClick"),
|
|
928
|
+
children: /* @__PURE__ */ jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ jsx(UnlinkSingle, {}) })
|
|
941
929
|
}
|
|
942
930
|
)
|
|
943
931
|
] })
|
|
944
932
|
] })
|
|
945
933
|
] });
|
|
946
|
-
},
|
|
947
|
-
var
|
|
948
|
-
const
|
|
949
|
-
if (
|
|
950
|
-
|
|
951
|
-
const
|
|
952
|
-
|
|
934
|
+
}, "CellLinkPopupPure"), CellLinkPopup = /* @__PURE__ */ __name(() => {
|
|
935
|
+
var _a12, _b;
|
|
936
|
+
const popupService = useDependency(SheetsHyperLinkPopupService), [currentPopup, setCurrentPopup] = useState(null), univerInstanceService = useDependency(IUniverInstanceService);
|
|
937
|
+
if (useEffect(() => {
|
|
938
|
+
setCurrentPopup(popupService.currentPopup);
|
|
939
|
+
const ob = popupService.currentPopup$.subscribe((popup) => {
|
|
940
|
+
setCurrentPopup(popup);
|
|
953
941
|
});
|
|
954
942
|
return () => {
|
|
955
|
-
|
|
943
|
+
ob.unsubscribe();
|
|
956
944
|
};
|
|
957
|
-
}, [
|
|
945
|
+
}, [popupService.currentPopup, popupService.currentPopup$]), !currentPopup)
|
|
958
946
|
return null;
|
|
959
|
-
if (
|
|
960
|
-
const
|
|
961
|
-
return
|
|
962
|
-
}
|
|
963
|
-
return /* @__PURE__ */
|
|
964
|
-
};
|
|
965
|
-
|
|
966
|
-
var
|
|
967
|
-
for (var
|
|
968
|
-
(
|
|
969
|
-
return
|
|
970
|
-
},
|
|
971
|
-
const
|
|
972
|
-
var
|
|
973
|
-
return
|
|
974
|
-
};
|
|
975
|
-
|
|
976
|
-
|
|
947
|
+
if (currentPopup.showAll) {
|
|
948
|
+
const workbook = univerInstanceService.getUnit(currentPopup.unitId, UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(currentPopup.subUnitId), cell = worksheet == null ? void 0 : worksheet.getCell(currentPopup.row, currentPopup.col), customRanges = (_b = (_a12 = cell == null ? void 0 : cell.p) == null ? void 0 : _a12.body) == null ? void 0 : _b.customRanges;
|
|
949
|
+
return customRanges != null && customRanges.length ? /* @__PURE__ */ jsx("div", { children: customRanges.map((customRange) => /* @__PURE__ */ jsx(CellLinkPopupPure, { ...currentPopup, customRange }, customRange.rangeId)) }) : null;
|
|
950
|
+
}
|
|
951
|
+
return /* @__PURE__ */ jsx(CellLinkPopupPure, { ...currentPopup });
|
|
952
|
+
}, "CellLinkPopup");
|
|
953
|
+
CellLinkPopup.componentKey = "univer.sheet.cell-link-popup";
|
|
954
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
955
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
956
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
957
|
+
return kind && result && __defProp$7(target, key, result), result;
|
|
958
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7");
|
|
959
|
+
const isEqualLink = /* @__PURE__ */ __name((a, b) => {
|
|
960
|
+
var _a12, _b;
|
|
961
|
+
return a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.row === b.row && a.col === b.col && ((_a12 = a.customRange) == null ? void 0 : _a12.rangeId) === ((_b = b.customRange) == null ? void 0 : _b.rangeId) && a.type === b.type;
|
|
962
|
+
}, "isEqualLink");
|
|
963
|
+
var _a3;
|
|
964
|
+
let SheetsHyperLinkPopupService = (_a3 = class extends Disposable {
|
|
965
|
+
constructor(_sheetCanvasPopManagerService, _injector, _univerInstanceService, _editorBridgeService, _textSelectionManagerService, _docCanvasPopManagerService, _zenZoneService) {
|
|
977
966
|
super();
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
this._sheetCanvasPopManagerService =
|
|
967
|
+
__publicField(this, "_currentPopup", null);
|
|
968
|
+
__publicField(this, "_currentPopup$", new Subject());
|
|
969
|
+
__publicField(this, "currentPopup$", this._currentPopup$.asObservable());
|
|
970
|
+
__publicField(this, "_currentEditingPopup", null);
|
|
971
|
+
__publicField(this, "_currentEditing$", new BehaviorSubject(null));
|
|
972
|
+
__publicField(this, "currentEditing$", this._currentEditing$.asObservable());
|
|
973
|
+
__publicField(this, "_isKeepVisible", !1);
|
|
974
|
+
this._sheetCanvasPopManagerService = _sheetCanvasPopManagerService, this._injector = _injector, this._univerInstanceService = _univerInstanceService, this._editorBridgeService = _editorBridgeService, this._textSelectionManagerService = _textSelectionManagerService, this._docCanvasPopManagerService = _docCanvasPopManagerService, this._zenZoneService = _zenZoneService, this.disposeWithMe(() => {
|
|
986
975
|
this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete();
|
|
987
976
|
});
|
|
988
977
|
}
|
|
@@ -992,898 +981,899 @@ let K = class extends z {
|
|
|
992
981
|
get currentEditing() {
|
|
993
982
|
return this._currentEditing$.getValue();
|
|
994
983
|
}
|
|
995
|
-
setIsKeepVisible(
|
|
996
|
-
this._isKeepVisible =
|
|
984
|
+
setIsKeepVisible(v) {
|
|
985
|
+
this._isKeepVisible = v;
|
|
997
986
|
}
|
|
998
987
|
getIsKeepVisible() {
|
|
999
988
|
return this._isKeepVisible;
|
|
1000
989
|
}
|
|
1001
|
-
showPopup(
|
|
1002
|
-
if (this._currentPopup &&
|
|
990
|
+
showPopup(location2) {
|
|
991
|
+
if (this._currentPopup && isEqualLink(location2, this._currentPopup) || (this.hideCurrentPopup(void 0, !0), location2.type !== HyperLinkEditSourceType.ZEN_EDITOR && this._zenZoneService.visible))
|
|
1003
992
|
return;
|
|
1004
|
-
const
|
|
1005
|
-
if (
|
|
993
|
+
const currentEditing = this._currentEditing$.getValue();
|
|
994
|
+
if (currentEditing && isEqualLink(location2, currentEditing))
|
|
1006
995
|
return;
|
|
1007
|
-
const { unitId
|
|
1008
|
-
let
|
|
1009
|
-
const
|
|
1010
|
-
componentKey:
|
|
996
|
+
const { unitId, subUnitId, row, col, customRangeRect, customRange } = location2;
|
|
997
|
+
let disposable;
|
|
998
|
+
const popup = {
|
|
999
|
+
componentKey: CellLinkPopup.componentKey,
|
|
1011
1000
|
direction: "bottom",
|
|
1012
|
-
onClickOutside: () => {
|
|
1001
|
+
onClickOutside: /* @__PURE__ */ __name(() => {
|
|
1013
1002
|
this.hideCurrentPopup();
|
|
1014
|
-
},
|
|
1015
|
-
onClick: () => {
|
|
1016
|
-
this.hideCurrentPopup(
|
|
1017
|
-
}
|
|
1003
|
+
}, "onClickOutside"),
|
|
1004
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
1005
|
+
this.hideCurrentPopup(location2.type, !0);
|
|
1006
|
+
}, "onClick")
|
|
1018
1007
|
};
|
|
1019
|
-
if (
|
|
1020
|
-
if (!
|
|
1008
|
+
if (location2.type === HyperLinkEditSourceType.EDITING) {
|
|
1009
|
+
if (!customRange)
|
|
1021
1010
|
return;
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1011
|
+
disposable = customRangeRect && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
|
|
1012
|
+
customRangeRect,
|
|
1013
|
+
popup
|
|
1025
1014
|
);
|
|
1026
|
-
} else if (
|
|
1027
|
-
if (!
|
|
1015
|
+
} else if (location2.type === HyperLinkEditSourceType.ZEN_EDITOR) {
|
|
1016
|
+
if (!customRange)
|
|
1028
1017
|
return;
|
|
1029
|
-
|
|
1018
|
+
disposable = this._docCanvasPopManagerService.attachPopupToRange(
|
|
1030
1019
|
{
|
|
1031
|
-
startOffset:
|
|
1032
|
-
endOffset:
|
|
1020
|
+
startOffset: customRange.startIndex,
|
|
1021
|
+
endOffset: customRange.endIndex + 1,
|
|
1033
1022
|
collapsed: !1
|
|
1034
1023
|
},
|
|
1035
|
-
|
|
1036
|
-
|
|
1024
|
+
popup,
|
|
1025
|
+
DOCS_ZEN_EDITOR_UNIT_ID_KEY
|
|
1037
1026
|
);
|
|
1038
|
-
} else if (
|
|
1039
|
-
|
|
1027
|
+
} else if (location2.showAll)
|
|
1028
|
+
disposable = this._sheetCanvasPopManagerService.attachPopupToCell(location2.row, location2.col, popup, unitId, subUnitId);
|
|
1040
1029
|
else {
|
|
1041
|
-
if (!
|
|
1030
|
+
if (!customRange)
|
|
1042
1031
|
return;
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1032
|
+
disposable = customRangeRect && this._sheetCanvasPopManagerService.attachPopupByPosition(
|
|
1033
|
+
customRangeRect,
|
|
1034
|
+
popup,
|
|
1035
|
+
location2
|
|
1047
1036
|
);
|
|
1048
1037
|
}
|
|
1049
|
-
|
|
1050
|
-
unitId
|
|
1051
|
-
subUnitId
|
|
1052
|
-
disposable
|
|
1053
|
-
row
|
|
1054
|
-
col
|
|
1055
|
-
editPermission: !!
|
|
1056
|
-
copyPermission: !!
|
|
1057
|
-
customRange
|
|
1058
|
-
type:
|
|
1059
|
-
showAll:
|
|
1038
|
+
disposable && (this._currentPopup = {
|
|
1039
|
+
unitId,
|
|
1040
|
+
subUnitId,
|
|
1041
|
+
disposable,
|
|
1042
|
+
row,
|
|
1043
|
+
col,
|
|
1044
|
+
editPermission: !!location2.editPermission,
|
|
1045
|
+
copyPermission: !!location2.copyPermission,
|
|
1046
|
+
customRange,
|
|
1047
|
+
type: location2.type,
|
|
1048
|
+
showAll: location2.showAll
|
|
1060
1049
|
}, this._currentPopup$.next(this._currentPopup));
|
|
1061
1050
|
}
|
|
1062
|
-
hideCurrentPopup(
|
|
1063
|
-
var
|
|
1064
|
-
this._currentPopup && ((!
|
|
1051
|
+
hideCurrentPopup(type, force) {
|
|
1052
|
+
var _a12, _b;
|
|
1053
|
+
this._currentPopup && ((!type || type === this._currentPopup.type) && this._currentPopup.disposable.canDispose() || force) && ((_b = (_a12 = this._currentPopup) == null ? void 0 : _a12.disposable) == null || _b.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
|
|
1065
1054
|
}
|
|
1066
1055
|
_getEditingRange() {
|
|
1067
|
-
var
|
|
1068
|
-
const
|
|
1069
|
-
if (
|
|
1070
|
-
const
|
|
1071
|
-
if (!
|
|
1056
|
+
var _a12, _b, _c;
|
|
1057
|
+
const visible = this._editorBridgeService.isVisible().visible, state = this._editorBridgeService.getEditCellState();
|
|
1058
|
+
if (visible && state) {
|
|
1059
|
+
const textRange = this._textSelectionManagerService.getActiveTextRange(), body = (_a12 = state.documentLayoutObject.documentModel) == null ? void 0 : _a12.getBody();
|
|
1060
|
+
if (!body)
|
|
1072
1061
|
return null;
|
|
1073
|
-
if (!
|
|
1062
|
+
if (!textRange || textRange.collapsed)
|
|
1074
1063
|
return {
|
|
1075
1064
|
startOffset: 0,
|
|
1076
|
-
endOffset:
|
|
1077
|
-
collapsed:
|
|
1078
|
-
label:
|
|
1065
|
+
endOffset: body.dataStream.length - 2,
|
|
1066
|
+
collapsed: body.dataStream.length - 2 === 0,
|
|
1067
|
+
label: BuildTextUtils.transform.getPlainText(body.dataStream)
|
|
1079
1068
|
};
|
|
1080
|
-
const
|
|
1081
|
-
let
|
|
1082
|
-
return
|
|
1083
|
-
|
|
1069
|
+
const links = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, (_c = (_b = body.customRanges) == null ? void 0 : _b.filter((i) => i.rangeType === CustomRangeType.HYPERLINK)) != null ? _c : []);
|
|
1070
|
+
let start = textRange.startOffset, end = textRange.endOffset;
|
|
1071
|
+
return links.forEach((link) => {
|
|
1072
|
+
start = Math.min(start, link.startIndex), end = Math.max(end, link.endIndex + 1);
|
|
1084
1073
|
}), {
|
|
1085
|
-
startOffset:
|
|
1086
|
-
endOffset:
|
|
1087
|
-
collapsed:
|
|
1088
|
-
label:
|
|
1074
|
+
startOffset: start,
|
|
1075
|
+
endOffset: end,
|
|
1076
|
+
collapsed: start === end,
|
|
1077
|
+
label: BuildTextUtils.transform.getPlainText(body.dataStream.slice(start, end))
|
|
1089
1078
|
};
|
|
1090
1079
|
}
|
|
1091
1080
|
return null;
|
|
1092
1081
|
}
|
|
1093
1082
|
get _editPopup() {
|
|
1094
1083
|
return {
|
|
1095
|
-
componentKey:
|
|
1084
|
+
componentKey: CellLinkEdit.componentKey,
|
|
1096
1085
|
direction: "vertical",
|
|
1097
|
-
onClickOutside: () => {
|
|
1086
|
+
onClickOutside: /* @__PURE__ */ __name(() => {
|
|
1098
1087
|
this.getIsKeepVisible() || this.endEditing();
|
|
1099
|
-
},
|
|
1100
|
-
onContextMenu: () => {
|
|
1088
|
+
}, "onClickOutside"),
|
|
1089
|
+
onContextMenu: /* @__PURE__ */ __name(() => {
|
|
1101
1090
|
this.getIsKeepVisible() || this.endEditing();
|
|
1102
|
-
},
|
|
1091
|
+
}, "onContextMenu"),
|
|
1103
1092
|
hiddenType: "hide"
|
|
1104
1093
|
};
|
|
1105
1094
|
}
|
|
1106
|
-
startAddEditing(
|
|
1107
|
-
var
|
|
1108
|
-
const { unitId
|
|
1109
|
-
if (
|
|
1110
|
-
const
|
|
1111
|
-
if (!
|
|
1095
|
+
startAddEditing(link) {
|
|
1096
|
+
var _a12, _b, _c, _d, _e;
|
|
1097
|
+
const { unitId, subUnitId, type } = link;
|
|
1098
|
+
if (type === HyperLinkEditSourceType.ZEN_EDITOR) {
|
|
1099
|
+
const document = this._univerInstanceService.getUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
|
|
1100
|
+
if (!document)
|
|
1112
1101
|
return;
|
|
1113
|
-
const
|
|
1114
|
-
if (!
|
|
1102
|
+
const range = this._textSelectionManagerService.getActiveTextRange();
|
|
1103
|
+
if (!range)
|
|
1115
1104
|
return;
|
|
1116
1105
|
this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
|
|
1117
|
-
|
|
1106
|
+
range,
|
|
1118
1107
|
this._editPopup,
|
|
1119
|
-
|
|
1108
|
+
DOCS_ZEN_EDITOR_UNIT_ID_KEY
|
|
1120
1109
|
);
|
|
1121
|
-
const
|
|
1110
|
+
const label = (_a12 = document.getBody()) == null ? void 0 : _a12.dataStream.slice(range.startOffset, range.endOffset);
|
|
1122
1111
|
this._currentEditing$.next({
|
|
1123
|
-
...
|
|
1124
|
-
label
|
|
1112
|
+
...link,
|
|
1113
|
+
label
|
|
1125
1114
|
});
|
|
1126
|
-
} else if (
|
|
1127
|
-
const
|
|
1128
|
-
if (!
|
|
1115
|
+
} else if (type === HyperLinkEditSourceType.EDITING) {
|
|
1116
|
+
const range = this._getEditingRange();
|
|
1117
|
+
if (!range)
|
|
1129
1118
|
return;
|
|
1130
|
-
this._textSelectionManagerService.replaceDocRanges([{ ...
|
|
1131
|
-
const
|
|
1132
|
-
if (!
|
|
1119
|
+
this._textSelectionManagerService.replaceDocRanges([{ ...range }], { unitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY });
|
|
1120
|
+
const currentRender = this._injector.get(IRenderManagerService).getRenderById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
|
|
1121
|
+
if (!currentRender)
|
|
1133
1122
|
return;
|
|
1134
|
-
const
|
|
1135
|
-
if (!(
|
|
1123
|
+
const rects = calcDocRangePositions(range, currentRender);
|
|
1124
|
+
if (!(rects != null && rects.length))
|
|
1136
1125
|
return;
|
|
1137
1126
|
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
|
|
1138
|
-
|
|
1127
|
+
rects.pop(),
|
|
1139
1128
|
this._editPopup,
|
|
1140
|
-
|
|
1141
|
-
|
|
1129
|
+
unitId,
|
|
1130
|
+
subUnitId
|
|
1142
1131
|
), this._currentEditing$.next({
|
|
1143
|
-
...
|
|
1144
|
-
label: (
|
|
1132
|
+
...link,
|
|
1133
|
+
label: (_b = range == null ? void 0 : range.label) != null ? _b : ""
|
|
1145
1134
|
});
|
|
1146
1135
|
} else {
|
|
1147
1136
|
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
|
|
1148
|
-
|
|
1149
|
-
|
|
1137
|
+
link.row,
|
|
1138
|
+
link.col,
|
|
1150
1139
|
this._editPopup,
|
|
1151
|
-
|
|
1152
|
-
|
|
1140
|
+
unitId,
|
|
1141
|
+
subUnitId
|
|
1153
1142
|
);
|
|
1154
|
-
const
|
|
1143
|
+
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId), cell = worksheet == null ? void 0 : worksheet.getCellRaw(link.row, link.col);
|
|
1155
1144
|
this._currentEditing$.next({
|
|
1156
|
-
...
|
|
1157
|
-
label:
|
|
1145
|
+
...link,
|
|
1146
|
+
label: cell != null && cell.p ? BuildTextUtils.transform.getPlainText((_d = (_c = cell.p.body) == null ? void 0 : _c.dataStream) != null ? _d : "") : ((_e = cell == null ? void 0 : cell.v) != null ? _e : "").toString()
|
|
1158
1147
|
});
|
|
1159
1148
|
}
|
|
1160
1149
|
}
|
|
1161
1150
|
// eslint-disable-next-line complexity, max-lines-per-function
|
|
1162
|
-
startEditing(
|
|
1163
|
-
var
|
|
1164
|
-
(
|
|
1165
|
-
const { unitId
|
|
1166
|
-
let
|
|
1167
|
-
if (
|
|
1168
|
-
const
|
|
1169
|
-
if (
|
|
1151
|
+
startEditing(link) {
|
|
1152
|
+
var _a12, _b, _c, _d, _e, _f;
|
|
1153
|
+
(_a12 = this._currentEditingPopup) == null || _a12.dispose(), this.hideCurrentPopup(void 0, !0);
|
|
1154
|
+
const { unitId, subUnitId } = link;
|
|
1155
|
+
let customRange, label;
|
|
1156
|
+
if (link.type === HyperLinkEditSourceType.ZEN_EDITOR) {
|
|
1157
|
+
const document = this._univerInstanceService.getUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
|
|
1158
|
+
if (customRange = (_c = (_b = document == null ? void 0 : document.getBody()) == null ? void 0 : _b.customRanges) == null ? void 0 : _c.find((range) => range.rangeId === link.customRangeId), label = customRange ? (_d = document == null ? void 0 : document.getBody()) == null ? void 0 : _d.dataStream.slice(customRange.startIndex, customRange.endIndex + 1) : "", !customRange || !label)
|
|
1170
1159
|
return;
|
|
1171
1160
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1172
1161
|
{
|
|
1173
|
-
startOffset:
|
|
1174
|
-
endOffset:
|
|
1162
|
+
startOffset: customRange.startIndex,
|
|
1163
|
+
endOffset: customRange.endIndex + 1
|
|
1175
1164
|
}
|
|
1176
1165
|
]), this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
|
|
1177
1166
|
{
|
|
1178
|
-
startOffset:
|
|
1179
|
-
endOffset:
|
|
1167
|
+
startOffset: customRange.startIndex,
|
|
1168
|
+
endOffset: customRange.endIndex,
|
|
1180
1169
|
collapsed: !1
|
|
1181
1170
|
},
|
|
1182
1171
|
this._editPopup,
|
|
1183
|
-
|
|
1172
|
+
DOCS_ZEN_EDITOR_UNIT_ID_KEY
|
|
1184
1173
|
);
|
|
1185
|
-
} else if (
|
|
1186
|
-
const
|
|
1187
|
-
if (!
|
|
1174
|
+
} else if (link.type === HyperLinkEditSourceType.EDITING) {
|
|
1175
|
+
const customRangeInfo = getEditingCustomRangePosition(this._injector, link.unitId, link.subUnitId, link.row, link.col, link.customRangeId);
|
|
1176
|
+
if (!customRangeInfo || !((_e = customRangeInfo.rects) != null && _e.length))
|
|
1188
1177
|
return;
|
|
1189
|
-
|
|
1178
|
+
customRange = customRangeInfo.customRange, label = customRangeInfo.label, this._textSelectionManagerService.replaceTextRanges([
|
|
1190
1179
|
{
|
|
1191
|
-
startOffset:
|
|
1192
|
-
endOffset:
|
|
1180
|
+
startOffset: customRange.startIndex,
|
|
1181
|
+
endOffset: customRange.endIndex + 1
|
|
1193
1182
|
}
|
|
1194
1183
|
]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
|
|
1195
|
-
|
|
1184
|
+
customRangeInfo.rects.pop(),
|
|
1196
1185
|
this._editPopup,
|
|
1197
|
-
|
|
1198
|
-
|
|
1186
|
+
unitId,
|
|
1187
|
+
subUnitId
|
|
1199
1188
|
);
|
|
1200
1189
|
} else {
|
|
1201
|
-
const
|
|
1202
|
-
if (!
|
|
1190
|
+
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId), cell = worksheet == null ? void 0 : worksheet.getCellRaw(link.row, link.col), style = workbook == null ? void 0 : workbook.getStyles().getStyleByCell(cell), tr = style == null ? void 0 : style.tr, customRangeInfo = getCustomRangePosition(this._injector, link.unitId, link.subUnitId, link.row, link.col, link.customRangeId);
|
|
1191
|
+
if (!customRangeInfo || !((_f = customRangeInfo.rects) != null && _f.length))
|
|
1203
1192
|
return;
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1193
|
+
customRange = customRangeInfo.customRange, label = customRangeInfo.label, tr ? this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
|
|
1194
|
+
link.row,
|
|
1195
|
+
link.col,
|
|
1207
1196
|
this._editPopup,
|
|
1208
|
-
|
|
1209
|
-
|
|
1197
|
+
unitId,
|
|
1198
|
+
subUnitId
|
|
1210
1199
|
) : this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupByPosition(
|
|
1211
|
-
|
|
1200
|
+
customRangeInfo.rects.pop(),
|
|
1212
1201
|
this._editPopup,
|
|
1213
1202
|
{
|
|
1214
|
-
unitId
|
|
1215
|
-
subUnitId
|
|
1216
|
-
row:
|
|
1217
|
-
col:
|
|
1203
|
+
unitId,
|
|
1204
|
+
subUnitId,
|
|
1205
|
+
row: link.row,
|
|
1206
|
+
col: link.col
|
|
1218
1207
|
}
|
|
1219
1208
|
);
|
|
1220
1209
|
}
|
|
1221
1210
|
this._currentEditing$.next({
|
|
1222
|
-
...
|
|
1223
|
-
customRange
|
|
1224
|
-
label
|
|
1211
|
+
...link,
|
|
1212
|
+
customRange,
|
|
1213
|
+
label
|
|
1225
1214
|
});
|
|
1226
1215
|
}
|
|
1227
|
-
endEditing(
|
|
1228
|
-
var
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1231
|
-
}
|
|
1232
|
-
};
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
],
|
|
1242
|
-
var
|
|
1243
|
-
const
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
]),
|
|
1248
|
-
var
|
|
1249
|
-
const
|
|
1250
|
-
if (
|
|
1216
|
+
endEditing(type) {
|
|
1217
|
+
var _a12;
|
|
1218
|
+
const current = this._currentEditing$.getValue();
|
|
1219
|
+
current && (!type || type === current.type) && ((_a12 = this._currentEditingPopup) == null || _a12.dispose(), this._currentEditing$.next(null));
|
|
1220
|
+
}
|
|
1221
|
+
}, __name(_a3, "SheetsHyperLinkPopupService"), _a3);
|
|
1222
|
+
SheetsHyperLinkPopupService = __decorateClass$7([
|
|
1223
|
+
__decorateParam$7(0, Inject(SheetCanvasPopManagerService)),
|
|
1224
|
+
__decorateParam$7(1, Inject(Injector)),
|
|
1225
|
+
__decorateParam$7(2, IUniverInstanceService),
|
|
1226
|
+
__decorateParam$7(3, IEditorBridgeService),
|
|
1227
|
+
__decorateParam$7(4, Inject(DocSelectionManagerService)),
|
|
1228
|
+
__decorateParam$7(5, Inject(DocCanvasPopManagerService)),
|
|
1229
|
+
__decorateParam$7(6, IZenZoneService)
|
|
1230
|
+
], SheetsHyperLinkPopupService);
|
|
1231
|
+
var DisableLinkType = /* @__PURE__ */ ((DisableLinkType2) => (DisableLinkType2[DisableLinkType2.ALLOWED = 0] = "ALLOWED", DisableLinkType2[DisableLinkType2.DISABLED_BY_CELL = 1] = "DISABLED_BY_CELL", DisableLinkType2[DisableLinkType2.ALLOW_ON_EDITING = 2] = "ALLOW_ON_EDITING", DisableLinkType2))(DisableLinkType || {});
|
|
1232
|
+
const disables = /* @__PURE__ */ new Set([
|
|
1233
|
+
DataValidationType.CHECKBOX,
|
|
1234
|
+
DataValidationType.LIST,
|
|
1235
|
+
DataValidationType.LIST_MULTIPLE
|
|
1236
|
+
]), getShouldDisableCellLink = /* @__PURE__ */ __name((accessor, worksheet, row, col) => {
|
|
1237
|
+
var _a12, _b;
|
|
1238
|
+
const cell = worksheet.getCell(row, col);
|
|
1239
|
+
if (cell != null && cell.f || cell != null && cell.si)
|
|
1251
1240
|
return 1;
|
|
1252
|
-
const
|
|
1253
|
-
return
|
|
1254
|
-
},
|
|
1255
|
-
const
|
|
1256
|
-
if (!
|
|
1241
|
+
const dataValidationModel = accessor.has(SheetDataValidationModel) ? accessor.get(SheetDataValidationModel) : null, rule = dataValidationModel == null ? void 0 : dataValidationModel.getRuleByLocation(worksheet.getUnitId(), worksheet.getSheetId(), row, col);
|
|
1242
|
+
return rule && disables.has(rule.type) ? !0 : (_b = (_a12 = cell == null ? void 0 : cell.p) == null ? void 0 : _a12.drawingsOrder) != null && _b.length ? 2 : 0;
|
|
1243
|
+
}, "getShouldDisableCellLink"), getShouldDisableCurrentCellLink = /* @__PURE__ */ __name((accessor) => {
|
|
1244
|
+
const unit = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
1245
|
+
if (!unit)
|
|
1257
1246
|
return !0;
|
|
1258
|
-
const
|
|
1259
|
-
if (!
|
|
1247
|
+
const worksheet = unit.getActiveSheet(), selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
|
|
1248
|
+
if (!selections.length)
|
|
1260
1249
|
return !0;
|
|
1261
|
-
const
|
|
1262
|
-
return
|
|
1263
|
-
},
|
|
1264
|
-
const
|
|
1265
|
-
if (!(
|
|
1250
|
+
const row = selections[0].range.startRow, col = selections[0].range.startColumn;
|
|
1251
|
+
return getShouldDisableCellLink(accessor, worksheet, row, col) === 1;
|
|
1252
|
+
}, "getShouldDisableCurrentCellLink"), shouldDisableAddLink = /* @__PURE__ */ __name((accessor) => {
|
|
1253
|
+
const textSelectionService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), textRanges = textSelectionService.getTextRanges();
|
|
1254
|
+
if (!(textRanges != null && textRanges.length))
|
|
1266
1255
|
return !0;
|
|
1267
|
-
const
|
|
1268
|
-
return !!(!
|
|
1269
|
-
},
|
|
1270
|
-
type:
|
|
1256
|
+
const doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
1257
|
+
return !!(!doc || textRanges.every((range) => range.collapsed) || !doc.getSelfOrHeaderFooterModel(textRanges[0].segmentId).getBody());
|
|
1258
|
+
}, "shouldDisableAddLink"), OpenHyperLinkEditPanelOperation = {
|
|
1259
|
+
type: CommandType.OPERATION,
|
|
1271
1260
|
id: "sheet.operation.open-hyper-link-edit-panel",
|
|
1272
|
-
handler(
|
|
1273
|
-
if (!
|
|
1261
|
+
handler(accessor, params) {
|
|
1262
|
+
if (!params)
|
|
1274
1263
|
return !1;
|
|
1275
|
-
const
|
|
1276
|
-
return
|
|
1264
|
+
const popupService = accessor.get(SheetsHyperLinkPopupService);
|
|
1265
|
+
return params.customRangeId ? popupService.startEditing(params) : popupService.startAddEditing(params), !0;
|
|
1277
1266
|
}
|
|
1278
|
-
},
|
|
1279
|
-
type:
|
|
1267
|
+
}, CloseHyperLinkPopupOperation = {
|
|
1268
|
+
type: CommandType.OPERATION,
|
|
1280
1269
|
id: "sheet.operation.close-hyper-link-popup",
|
|
1281
|
-
handler(
|
|
1282
|
-
return
|
|
1270
|
+
handler(accessor) {
|
|
1271
|
+
return accessor.get(SheetsHyperLinkPopupService).endEditing(), !0;
|
|
1283
1272
|
}
|
|
1284
|
-
},
|
|
1285
|
-
type:
|
|
1273
|
+
}, InsertHyperLinkOperation = {
|
|
1274
|
+
type: CommandType.OPERATION,
|
|
1286
1275
|
id: "sheet.operation.insert-hyper-link",
|
|
1287
|
-
handler(
|
|
1288
|
-
var
|
|
1289
|
-
const
|
|
1290
|
-
if (!
|
|
1276
|
+
handler(accessor) {
|
|
1277
|
+
var _a12;
|
|
1278
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService), editorBridgeService = accessor.get(IEditorBridgeService);
|
|
1279
|
+
if (!target)
|
|
1291
1280
|
return !1;
|
|
1292
|
-
const
|
|
1293
|
-
if (!
|
|
1281
|
+
const commandService = accessor.get(ICommandService), selection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
1282
|
+
if (!selection)
|
|
1294
1283
|
return !1;
|
|
1295
|
-
const
|
|
1296
|
-
return
|
|
1297
|
-
unitId:
|
|
1298
|
-
subUnitId:
|
|
1299
|
-
row
|
|
1300
|
-
col
|
|
1301
|
-
type:
|
|
1284
|
+
const row = selection.range.startRow, col = selection.range.startColumn, visible = editorBridgeService.isVisible(), isZenEditor = ((_a12 = univerInstanceService.getFocusedUnit()) == null ? void 0 : _a12.getUnitId()) === DOCS_ZEN_EDITOR_UNIT_ID_KEY;
|
|
1285
|
+
return commandService.executeCommand(OpenHyperLinkEditPanelOperation.id, {
|
|
1286
|
+
unitId: target.unitId,
|
|
1287
|
+
subUnitId: target.subUnitId,
|
|
1288
|
+
row,
|
|
1289
|
+
col,
|
|
1290
|
+
type: isZenEditor ? HyperLinkEditSourceType.ZEN_EDITOR : visible.visible ? HyperLinkEditSourceType.EDITING : HyperLinkEditSourceType.VIEWING
|
|
1302
1291
|
});
|
|
1303
1292
|
}
|
|
1304
|
-
},
|
|
1305
|
-
type:
|
|
1293
|
+
}, InsertHyperLinkToolbarOperation = {
|
|
1294
|
+
type: CommandType.OPERATION,
|
|
1306
1295
|
id: "sheet.operation.insert-hyper-link-toolbar",
|
|
1307
|
-
handler(
|
|
1308
|
-
if (
|
|
1296
|
+
handler(accessor) {
|
|
1297
|
+
if (getShouldDisableCurrentCellLink(accessor))
|
|
1309
1298
|
return !1;
|
|
1310
|
-
const
|
|
1311
|
-
return
|
|
1312
|
-
}
|
|
1313
|
-
},
|
|
1314
|
-
var
|
|
1315
|
-
const
|
|
1316
|
-
return
|
|
1317
|
-
const
|
|
1318
|
-
if (!
|
|
1299
|
+
const commandService = accessor.get(ICommandService);
|
|
1300
|
+
return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkPopupOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
|
|
1301
|
+
}
|
|
1302
|
+
}, getEditingLinkDisable$ = /* @__PURE__ */ __name((accessor, unitId = DOCS_ZEN_EDITOR_UNIT_ID_KEY) => {
|
|
1303
|
+
var _a12;
|
|
1304
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), docSelctionService = (_a12 = accessor.get(IRenderManagerService).getRenderById(unitId)) == null ? void 0 : _a12.with(DocSelectionRenderService);
|
|
1305
|
+
return docSelctionService ? docSelctionService.textSelectionInner$.pipe(map(() => {
|
|
1306
|
+
const state = accessor.get(IEditorBridgeService).getEditCellState();
|
|
1307
|
+
if (!state)
|
|
1319
1308
|
return !0;
|
|
1320
|
-
const
|
|
1321
|
-
return !(
|
|
1322
|
-
})) :
|
|
1323
|
-
},
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
if (!
|
|
1332
|
-
return
|
|
1333
|
-
const { selections
|
|
1334
|
-
if (!
|
|
1335
|
-
return
|
|
1336
|
-
const
|
|
1337
|
-
return
|
|
1309
|
+
const target = getSheetCommandTarget(univerInstanceService, { unitId: state.unitId, subUnitId: state.sheetId });
|
|
1310
|
+
return !(target != null && target.worksheet) || getShouldDisableCellLink(accessor, target.worksheet, state.row, state.column) === 1 ? !0 : shouldDisableAddLink(accessor);
|
|
1311
|
+
})) : of(!0);
|
|
1312
|
+
}, "getEditingLinkDisable$"), getLinkDisable$ = /* @__PURE__ */ __name((accessor) => {
|
|
1313
|
+
const disableRange$ = getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }, !0), univerInstanceService = accessor.get(IUniverInstanceService), sheetSelectionService = accessor.get(SheetsSelectionsService), editorBridgeService = accessor.has(IEditorBridgeService) ? accessor.get(IEditorBridgeService) : null, disableCell$ = univerInstanceService.focused$.pipe(
|
|
1314
|
+
filter((focused) => !!focused),
|
|
1315
|
+
map((focused) => univerInstanceService.getUnit(focused, UniverInstanceType.UNIVER_SHEET)),
|
|
1316
|
+
filter((unit) => !!unit),
|
|
1317
|
+
switchMap((unit) => unit.activeSheet$),
|
|
1318
|
+
switchMap((sheet) => sheetSelectionService.selectionMoveEnd$.pipe(map((selections) => sheet && { selections, sheet }))),
|
|
1319
|
+
map((sheetWithSelection) => {
|
|
1320
|
+
if (!sheetWithSelection)
|
|
1321
|
+
return DisableLinkType.DISABLED_BY_CELL;
|
|
1322
|
+
const { selections, sheet } = sheetWithSelection;
|
|
1323
|
+
if (!selections.length)
|
|
1324
|
+
return DisableLinkType.DISABLED_BY_CELL;
|
|
1325
|
+
const row = selections[0].range.startRow, col = selections[0].range.startColumn;
|
|
1326
|
+
return getShouldDisableCellLink(accessor, sheet, row, col);
|
|
1338
1327
|
}),
|
|
1339
|
-
|
|
1340
|
-
if (
|
|
1341
|
-
return
|
|
1342
|
-
const
|
|
1343
|
-
return
|
|
1344
|
-
|
|
1345
|
-
([
|
|
1328
|
+
switchMap((disableCell) => {
|
|
1329
|
+
if (disableCell === DisableLinkType.DISABLED_BY_CELL)
|
|
1330
|
+
return of(!0);
|
|
1331
|
+
const isEditing$ = (editorBridgeService ? editorBridgeService.visible$ : of(null)).pipe(map((visible) => visible != null && visible.visible ? DOCS_NORMAL_EDITOR_UNIT_ID_KEY : void 0)), focusingFxBarEditor$ = accessor.get(IContextService).subscribeContextValue$(FOCUSING_FX_BAR_EDITOR);
|
|
1332
|
+
return combineLatest([isEditing$, focusingFxBarEditor$]).pipe(
|
|
1333
|
+
switchMap(
|
|
1334
|
+
([editing, focusingFxBarEditor]) => editing ? focusingFxBarEditor ? of(!0) : getEditingLinkDisable$(accessor, editing) : of(disableCell === DisableLinkType.ALLOW_ON_EDITING)
|
|
1346
1335
|
)
|
|
1347
1336
|
);
|
|
1348
1337
|
})
|
|
1349
1338
|
);
|
|
1350
|
-
return
|
|
1351
|
-
|
|
1352
|
-
|
|
1339
|
+
return disableRange$.pipe(
|
|
1340
|
+
distinctUntilChanged(),
|
|
1341
|
+
switchMap((disableRange) => disableCell$.pipe(map((disableCell) => disableRange || disableCell)))
|
|
1353
1342
|
);
|
|
1354
|
-
},
|
|
1355
|
-
commandId:
|
|
1356
|
-
type:
|
|
1343
|
+
}, "getLinkDisable$"), linkMenu = {
|
|
1344
|
+
commandId: InsertHyperLinkOperation.id,
|
|
1345
|
+
type: MenuItemType.BUTTON,
|
|
1357
1346
|
title: "hyperLink.menu.add",
|
|
1358
1347
|
icon: "LinkSingle"
|
|
1359
|
-
},
|
|
1360
|
-
...
|
|
1361
|
-
id:
|
|
1362
|
-
hidden$:
|
|
1363
|
-
disabled$:
|
|
1348
|
+
}, genZenEditorMenuId = /* @__PURE__ */ __name((id) => `${id}-zen-editor`, "genZenEditorMenuId"), insertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1349
|
+
...linkMenu,
|
|
1350
|
+
id: linkMenu.commandId,
|
|
1351
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1352
|
+
disabled$: getLinkDisable$(accessor)
|
|
1364
1353
|
// disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
|
|
1365
|
-
}),
|
|
1366
|
-
...
|
|
1367
|
-
id:
|
|
1368
|
-
hidden$:
|
|
1369
|
-
disabled$:
|
|
1370
|
-
}),
|
|
1354
|
+
}), "insertLinkMenuFactory"), zenEditorInsertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1355
|
+
...linkMenu,
|
|
1356
|
+
id: genZenEditorMenuId(linkMenu.commandId),
|
|
1357
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
|
|
1358
|
+
disabled$: getEditingLinkDisable$(accessor)
|
|
1359
|
+
}), "zenEditorInsertLinkMenuFactory"), linkToolbarMenu = {
|
|
1371
1360
|
tooltip: "hyperLink.form.addTitle",
|
|
1372
|
-
commandId:
|
|
1373
|
-
type:
|
|
1361
|
+
commandId: InsertHyperLinkToolbarOperation.id,
|
|
1362
|
+
type: MenuItemType.BUTTON,
|
|
1374
1363
|
icon: "LinkSingle"
|
|
1375
|
-
},
|
|
1376
|
-
...
|
|
1377
|
-
id:
|
|
1378
|
-
hidden$:
|
|
1379
|
-
disabled$:
|
|
1380
|
-
}),
|
|
1381
|
-
...
|
|
1382
|
-
id:
|
|
1383
|
-
hidden$:
|
|
1384
|
-
disabled$:
|
|
1385
|
-
}),
|
|
1386
|
-
id:
|
|
1387
|
-
binding:
|
|
1388
|
-
preconditions:
|
|
1364
|
+
}, insertLinkMenuToolbarFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1365
|
+
...linkToolbarMenu,
|
|
1366
|
+
id: linkToolbarMenu.commandId,
|
|
1367
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1368
|
+
disabled$: getLinkDisable$(accessor)
|
|
1369
|
+
}), "insertLinkMenuToolbarFactory"), zenEditorInsertLinkMenuToolbarFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
1370
|
+
...linkToolbarMenu,
|
|
1371
|
+
id: genZenEditorMenuId(linkToolbarMenu.commandId),
|
|
1372
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
|
|
1373
|
+
disabled$: getEditingLinkDisable$(accessor)
|
|
1374
|
+
}), "zenEditorInsertLinkMenuToolbarFactory"), InsertLinkShortcut = {
|
|
1375
|
+
id: InsertHyperLinkToolbarOperation.id,
|
|
1376
|
+
binding: KeyCode.K | MetaKeys.CTRL_COMMAND,
|
|
1377
|
+
preconditions: whenSheetEditorFocused
|
|
1389
1378
|
};
|
|
1390
|
-
var
|
|
1391
|
-
for (var
|
|
1392
|
-
(
|
|
1393
|
-
return
|
|
1394
|
-
},
|
|
1395
|
-
let
|
|
1396
|
-
constructor(
|
|
1397
|
-
super(), this._autoFillService =
|
|
1379
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1380
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1381
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1382
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
1383
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a4;
|
|
1384
|
+
let SheetsHyperLinkAutoFillController = (_a4 = class extends Disposable {
|
|
1385
|
+
constructor(_autoFillService, _hyperLinkModel) {
|
|
1386
|
+
super(), this._autoFillService = _autoFillService, this._hyperLinkModel = _hyperLinkModel, this._initAutoFill();
|
|
1398
1387
|
}
|
|
1399
1388
|
// eslint-disable-next-line max-lines-per-function
|
|
1400
1389
|
_initAutoFill() {
|
|
1401
|
-
const
|
|
1402
|
-
const { source:
|
|
1403
|
-
row:
|
|
1404
|
-
col:
|
|
1405
|
-
},
|
|
1406
|
-
return
|
|
1407
|
-
const
|
|
1408
|
-
startRow:
|
|
1409
|
-
startColumn:
|
|
1410
|
-
endColumn:
|
|
1411
|
-
endRow:
|
|
1412
|
-
},
|
|
1413
|
-
startRow:
|
|
1414
|
-
startColumn:
|
|
1415
|
-
endColumn:
|
|
1416
|
-
endRow:
|
|
1390
|
+
const noopReturnFunc = /* @__PURE__ */ __name(() => ({ redos: [], undos: [] }), "noopReturnFunc"), generalApplyFunc = /* @__PURE__ */ __name((location2, applyType) => {
|
|
1391
|
+
const { source: sourceRange, target: targetRange, unitId, subUnitId } = location2, virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]), [vSourceRange, vTargetRange] = virtualRange.ranges, { mapFunc } = virtualRange, sourceStartCell = {
|
|
1392
|
+
row: vSourceRange.startRow,
|
|
1393
|
+
col: vSourceRange.startColumn
|
|
1394
|
+
}, repeats = getAutoFillRepeatRange(vSourceRange, vTargetRange), redos = [], undos = [];
|
|
1395
|
+
return repeats.forEach((repeat) => {
|
|
1396
|
+
const targetStartCell = repeat.repeatStartCell, relativeRange = repeat.relativeRange, sourceRange2 = {
|
|
1397
|
+
startRow: sourceStartCell.row,
|
|
1398
|
+
startColumn: sourceStartCell.col,
|
|
1399
|
+
endColumn: sourceStartCell.col,
|
|
1400
|
+
endRow: sourceStartCell.row
|
|
1401
|
+
}, targetRange2 = {
|
|
1402
|
+
startRow: targetStartCell.row,
|
|
1403
|
+
startColumn: targetStartCell.col,
|
|
1404
|
+
endColumn: targetStartCell.col,
|
|
1405
|
+
endRow: targetStartCell.row
|
|
1417
1406
|
};
|
|
1418
|
-
|
|
1419
|
-
const
|
|
1407
|
+
Range.foreach(relativeRange, (row, col) => {
|
|
1408
|
+
const sourcePositionRange = Rectangle.getPositionRange(
|
|
1420
1409
|
{
|
|
1421
|
-
startRow:
|
|
1422
|
-
startColumn:
|
|
1423
|
-
endColumn:
|
|
1424
|
-
endRow:
|
|
1410
|
+
startRow: row,
|
|
1411
|
+
startColumn: col,
|
|
1412
|
+
endColumn: col,
|
|
1413
|
+
endRow: row
|
|
1425
1414
|
},
|
|
1426
|
-
|
|
1427
|
-
), { row:
|
|
1415
|
+
sourceRange2
|
|
1416
|
+
), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol), targetPositionRange = Rectangle.getPositionRange(
|
|
1428
1417
|
{
|
|
1429
|
-
startRow:
|
|
1430
|
-
startColumn:
|
|
1431
|
-
endColumn:
|
|
1432
|
-
endRow:
|
|
1418
|
+
startRow: row,
|
|
1419
|
+
startColumn: col,
|
|
1420
|
+
endColumn: col,
|
|
1421
|
+
endRow: row
|
|
1433
1422
|
},
|
|
1434
|
-
|
|
1435
|
-
), { row:
|
|
1436
|
-
|
|
1437
|
-
id:
|
|
1423
|
+
targetRange2
|
|
1424
|
+
), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn), id = Tools.generateRandomId(), currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
|
|
1425
|
+
currentLink && redos.push({
|
|
1426
|
+
id: RemoveHyperLinkMutation.id,
|
|
1438
1427
|
params: {
|
|
1439
|
-
unitId
|
|
1440
|
-
subUnitId
|
|
1441
|
-
id:
|
|
1428
|
+
unitId,
|
|
1429
|
+
subUnitId,
|
|
1430
|
+
id: currentLink.id
|
|
1442
1431
|
}
|
|
1443
|
-
}), (
|
|
1444
|
-
id:
|
|
1432
|
+
}), (APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) && link && (redos.push({
|
|
1433
|
+
id: AddHyperLinkMutation.id,
|
|
1445
1434
|
params: {
|
|
1446
|
-
unitId
|
|
1447
|
-
subUnitId
|
|
1435
|
+
unitId,
|
|
1436
|
+
subUnitId,
|
|
1448
1437
|
link: {
|
|
1449
|
-
...
|
|
1450
|
-
id
|
|
1451
|
-
row:
|
|
1452
|
-
column:
|
|
1438
|
+
...link,
|
|
1439
|
+
id,
|
|
1440
|
+
row: targetRow,
|
|
1441
|
+
column: targetCol
|
|
1453
1442
|
}
|
|
1454
1443
|
}
|
|
1455
|
-
}),
|
|
1456
|
-
id:
|
|
1444
|
+
}), undos.push({
|
|
1445
|
+
id: RemoveHyperLinkMutation.id,
|
|
1457
1446
|
params: {
|
|
1458
|
-
unitId
|
|
1459
|
-
subUnitId
|
|
1460
|
-
id
|
|
1447
|
+
unitId,
|
|
1448
|
+
subUnitId,
|
|
1449
|
+
id
|
|
1461
1450
|
}
|
|
1462
|
-
})),
|
|
1463
|
-
id:
|
|
1451
|
+
})), currentLink && undos.push({
|
|
1452
|
+
id: AddHyperLinkMutation.id,
|
|
1464
1453
|
params: {
|
|
1465
|
-
unitId
|
|
1466
|
-
subUnitId
|
|
1467
|
-
link:
|
|
1454
|
+
unitId,
|
|
1455
|
+
subUnitId,
|
|
1456
|
+
link: currentLink
|
|
1468
1457
|
}
|
|
1469
1458
|
});
|
|
1470
1459
|
});
|
|
1471
1460
|
}), {
|
|
1472
|
-
undos
|
|
1473
|
-
redos
|
|
1461
|
+
undos,
|
|
1462
|
+
redos
|
|
1474
1463
|
};
|
|
1475
|
-
},
|
|
1476
|
-
id:
|
|
1477
|
-
onFillData: (
|
|
1464
|
+
}, "generalApplyFunc"), hook = {
|
|
1465
|
+
id: SHEET_HYPER_LINK_UI_PLUGIN,
|
|
1466
|
+
onFillData: /* @__PURE__ */ __name((location2, direction, applyType) => applyType === APPLY_TYPE.COPY || applyType === APPLY_TYPE.ONLY_FORMAT || applyType === APPLY_TYPE.SERIES ? generalApplyFunc(location2, applyType) : noopReturnFunc(), "onFillData")
|
|
1478
1467
|
};
|
|
1479
|
-
this.disposeWithMe(this._autoFillService.addHook(
|
|
1480
|
-
}
|
|
1481
|
-
};
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
],
|
|
1486
|
-
var
|
|
1487
|
-
for (var
|
|
1488
|
-
(
|
|
1489
|
-
return
|
|
1490
|
-
},
|
|
1491
|
-
let
|
|
1492
|
-
constructor(
|
|
1493
|
-
super(), this._localeService =
|
|
1468
|
+
this.disposeWithMe(this._autoFillService.addHook(hook));
|
|
1469
|
+
}
|
|
1470
|
+
}, __name(_a4, "SheetsHyperLinkAutoFillController"), _a4);
|
|
1471
|
+
SheetsHyperLinkAutoFillController = __decorateClass$6([
|
|
1472
|
+
__decorateParam$6(0, IAutoFillService),
|
|
1473
|
+
__decorateParam$6(1, Inject(HyperLinkModel))
|
|
1474
|
+
], SheetsHyperLinkAutoFillController);
|
|
1475
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1476
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1477
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1478
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
1479
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a5;
|
|
1480
|
+
let SheetsHyperLinkPermissionController = (_a5 = class extends Disposable {
|
|
1481
|
+
constructor(_localeService, _commandService, _sheetPermissionCheckController) {
|
|
1482
|
+
super(), this._localeService = _localeService, this._commandService = _commandService, this._sheetPermissionCheckController = _sheetPermissionCheckController, this._commandExecutedListener();
|
|
1494
1483
|
}
|
|
1495
1484
|
_commandExecutedListener() {
|
|
1496
1485
|
this.disposeWithMe(
|
|
1497
|
-
this._commandService.beforeCommandExecuted((
|
|
1498
|
-
|
|
1499
|
-
workbookTypes: [
|
|
1500
|
-
rangeTypes: [
|
|
1501
|
-
worksheetTypes: [
|
|
1486
|
+
this._commandService.beforeCommandExecuted((command) => {
|
|
1487
|
+
command.id === InsertLinkShortcut.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
1488
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
1489
|
+
rangeTypes: [RangeProtectionPermissionEditPoint],
|
|
1490
|
+
worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission]
|
|
1502
1491
|
}) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")));
|
|
1503
1492
|
})
|
|
1504
1493
|
);
|
|
1505
1494
|
}
|
|
1506
|
-
};
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
],
|
|
1512
|
-
var
|
|
1513
|
-
for (var
|
|
1514
|
-
(
|
|
1515
|
-
return
|
|
1516
|
-
},
|
|
1517
|
-
let
|
|
1518
|
-
constructor(
|
|
1519
|
-
super(), this._hoverManagerService =
|
|
1520
|
-
}
|
|
1521
|
-
_getLinkPermission(
|
|
1522
|
-
const { unitId
|
|
1523
|
-
if (!(
|
|
1495
|
+
}, __name(_a5, "SheetsHyperLinkPermissionController"), _a5);
|
|
1496
|
+
SheetsHyperLinkPermissionController = __decorateClass$5([
|
|
1497
|
+
__decorateParam$5(0, Inject(LocaleService)),
|
|
1498
|
+
__decorateParam$5(1, ICommandService),
|
|
1499
|
+
__decorateParam$5(2, Inject(SheetPermissionCheckController))
|
|
1500
|
+
], SheetsHyperLinkPermissionController);
|
|
1501
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1502
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1503
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1504
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
1505
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a6;
|
|
1506
|
+
let SheetsHyperLinkPopupController = (_a6 = class extends Disposable {
|
|
1507
|
+
constructor(_hoverManagerService, _sheetsHyperLinkPopupService, _renderManagerService, _permissionService, _sheetPermissionCheckController, _commandService, _editorBridgeService, _textSelectionManagerService, _univerInstanceService, _zenZoneService) {
|
|
1508
|
+
super(), this._hoverManagerService = _hoverManagerService, this._sheetsHyperLinkPopupService = _sheetsHyperLinkPopupService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._sheetPermissionCheckController = _sheetPermissionCheckController, this._commandService = _commandService, this._editorBridgeService = _editorBridgeService, this._textSelectionManagerService = _textSelectionManagerService, this._univerInstanceService = _univerInstanceService, this._zenZoneService = _zenZoneService, this._initHoverListener(), this._initCommandListener(), this._initHoverEditingListener(), this._initTextSelectionListener(), this._initZenEditor();
|
|
1509
|
+
}
|
|
1510
|
+
_getLinkPermission(location2) {
|
|
1511
|
+
const { unitId, subUnitId, row: currentRow, col: currentCol } = location2, workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
1512
|
+
if (!(workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId)))
|
|
1524
1513
|
return {
|
|
1525
1514
|
viewPermission: !1,
|
|
1526
1515
|
editPermission: !1,
|
|
1527
1516
|
copyPermission: !1
|
|
1528
1517
|
};
|
|
1529
|
-
const
|
|
1530
|
-
workbookTypes: [
|
|
1531
|
-
worksheetTypes: [
|
|
1532
|
-
rangeTypes: [
|
|
1533
|
-
}, [{ startRow:
|
|
1534
|
-
workbookTypes: [
|
|
1535
|
-
worksheetTypes: [
|
|
1536
|
-
rangeTypes: [
|
|
1537
|
-
}, [{ startRow:
|
|
1518
|
+
const viewPermission = this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
1519
|
+
workbookTypes: [WorkbookViewPermission],
|
|
1520
|
+
worksheetTypes: [WorksheetViewPermission],
|
|
1521
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
1522
|
+
}, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }]), editPermission = this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
1523
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
1524
|
+
worksheetTypes: [WorksheetEditPermission, WorksheetInsertHyperlinkPermission],
|
|
1525
|
+
rangeTypes: [RangeProtectionPermissionEditPoint]
|
|
1526
|
+
}, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }]), copyPermission = this._permissionService.composePermission([new WorkbookCopyPermission(unitId).id, new WorksheetCopyPermission(unitId, subUnitId).id]).every((permission) => permission.value);
|
|
1538
1527
|
return {
|
|
1539
|
-
viewPermission
|
|
1540
|
-
editPermission
|
|
1541
|
-
copyPermission
|
|
1528
|
+
viewPermission,
|
|
1529
|
+
editPermission,
|
|
1530
|
+
copyPermission
|
|
1542
1531
|
};
|
|
1543
1532
|
}
|
|
1544
1533
|
_initHoverListener() {
|
|
1545
1534
|
this.disposeWithMe(
|
|
1546
1535
|
// hover over not editing cell
|
|
1547
|
-
this._hoverManagerService.currentRichText$.pipe(
|
|
1548
|
-
var
|
|
1549
|
-
if (!
|
|
1536
|
+
this._hoverManagerService.currentRichText$.pipe(debounceTime(200)).subscribe((currentCell) => {
|
|
1537
|
+
var _a12, _b;
|
|
1538
|
+
if (!currentCell) {
|
|
1550
1539
|
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1551
1540
|
return;
|
|
1552
1541
|
}
|
|
1553
|
-
const { unitId
|
|
1554
|
-
if (!
|
|
1542
|
+
const { unitId, subUnitId, row, col } = currentCell, renderer = this._renderManagerService.getRenderById(unitId);
|
|
1543
|
+
if (!renderer)
|
|
1555
1544
|
return;
|
|
1556
|
-
const
|
|
1557
|
-
if (!
|
|
1545
|
+
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
1546
|
+
if (!worksheet)
|
|
1558
1547
|
return;
|
|
1559
|
-
if (!
|
|
1560
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup(
|
|
1548
|
+
if (!renderer.with(HoverRenderController).active) {
|
|
1549
|
+
this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING);
|
|
1561
1550
|
return;
|
|
1562
1551
|
}
|
|
1563
|
-
const
|
|
1564
|
-
let
|
|
1565
|
-
|
|
1566
|
-
|
|
1552
|
+
const skeleton = (_a12 = renderer == null ? void 0 : renderer.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _a12.skeleton, currentCol = col, currentRow = row;
|
|
1553
|
+
let targetRow = currentRow, targetCol = currentCol;
|
|
1554
|
+
skeleton && skeleton.overflowCache.forValue((row2, col2, value) => {
|
|
1555
|
+
Rectangle.contains(value, { startColumn: currentCol, endColumn: currentCol, startRow: currentRow, endRow: currentRow }) && (targetRow = row2, targetCol = col2);
|
|
1567
1556
|
});
|
|
1568
|
-
const { viewPermission
|
|
1569
|
-
if (!
|
|
1557
|
+
const { viewPermission, editPermission, copyPermission } = this._getLinkPermission(currentCell);
|
|
1558
|
+
if (!viewPermission) {
|
|
1570
1559
|
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1571
1560
|
return;
|
|
1572
1561
|
}
|
|
1573
|
-
const
|
|
1574
|
-
if (!
|
|
1562
|
+
const cell = worksheet.getCellStyleOnly(targetRow, targetCol), style = workbook.getStyles().getStyleByCell(cell), tr = (_b = style == null ? void 0 : style.tr) == null ? void 0 : _b.a;
|
|
1563
|
+
if (!tr && !currentCell.customRange) {
|
|
1575
1564
|
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1576
1565
|
return;
|
|
1577
1566
|
}
|
|
1578
1567
|
this._sheetsHyperLinkPopupService.showPopup({
|
|
1579
|
-
row:
|
|
1580
|
-
col:
|
|
1581
|
-
editPermission
|
|
1582
|
-
copyPermission
|
|
1583
|
-
customRange:
|
|
1584
|
-
customRangeRect:
|
|
1585
|
-
type:
|
|
1586
|
-
unitId
|
|
1587
|
-
subUnitId
|
|
1588
|
-
showAll: !!
|
|
1568
|
+
row: targetRow,
|
|
1569
|
+
col: targetCol,
|
|
1570
|
+
editPermission,
|
|
1571
|
+
copyPermission,
|
|
1572
|
+
customRange: currentCell.customRange,
|
|
1573
|
+
customRangeRect: currentCell.rect,
|
|
1574
|
+
type: HyperLinkEditSourceType.VIEWING,
|
|
1575
|
+
unitId,
|
|
1576
|
+
subUnitId,
|
|
1577
|
+
showAll: !!tr
|
|
1589
1578
|
});
|
|
1590
1579
|
})
|
|
1591
1580
|
);
|
|
1592
1581
|
}
|
|
1593
1582
|
_initHoverEditingListener() {
|
|
1594
|
-
let
|
|
1583
|
+
let subscribe = null;
|
|
1595
1584
|
this.disposeWithMe(
|
|
1596
|
-
this._editorBridgeService.currentEditCellState$.pipe(
|
|
1597
|
-
if (!
|
|
1585
|
+
this._editorBridgeService.currentEditCellState$.pipe(switchMap((state) => this._editorBridgeService.visible$.pipe(map((visible) => ({ visible, state }))))).subscribe(({ visible, state }) => {
|
|
1586
|
+
if (!state || state.editorUnitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY)
|
|
1598
1587
|
return;
|
|
1599
|
-
if (!
|
|
1600
|
-
|
|
1588
|
+
if (!visible.visible) {
|
|
1589
|
+
subscribe == null || subscribe.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING), this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING);
|
|
1601
1590
|
return;
|
|
1602
1591
|
}
|
|
1603
|
-
const { editorUnitId
|
|
1604
|
-
if (!
|
|
1592
|
+
const { editorUnitId, unitId, sheetId, row, column } = state, renderer = this._renderManagerService.getRenderById(editorUnitId);
|
|
1593
|
+
if (!renderer)
|
|
1605
1594
|
return;
|
|
1606
|
-
const { editPermission
|
|
1607
|
-
|
|
1608
|
-
var
|
|
1609
|
-
const
|
|
1610
|
-
if (!
|
|
1595
|
+
const { editPermission, viewPermission, copyPermission } = this._getLinkPermission({ unitId, subUnitId: sheetId, row, col: column }), docEventService = renderer.with(DocEventManagerService);
|
|
1596
|
+
viewPermission && (subscribe == null || subscribe.unsubscribe(), subscribe = docEventService.hoverCustomRanges$.pipe(debounceTime(200)).subscribe((customRanges) => {
|
|
1597
|
+
var _a12, _b;
|
|
1598
|
+
const customRange = customRanges.find((customRange2) => customRange2.range.rangeType === CustomRangeType.HYPERLINK);
|
|
1599
|
+
if (!customRange) {
|
|
1611
1600
|
this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1612
1601
|
return;
|
|
1613
1602
|
}
|
|
1614
|
-
const
|
|
1615
|
-
if (!((
|
|
1603
|
+
const rect = customRange.rects[customRange.rects.length - 1];
|
|
1604
|
+
if (!((_b = (_a12 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a12.with(SheetSkeletonManagerService).getWorksheetSkeleton(sheetId)) == null ? void 0 : _b.skeleton) || !rect)
|
|
1616
1605
|
return;
|
|
1617
|
-
const
|
|
1606
|
+
const canvasClientRect = renderer.engine.getCanvasElement().getBoundingClientRect();
|
|
1618
1607
|
this._sheetsHyperLinkPopupService.showPopup({
|
|
1619
|
-
unitId
|
|
1620
|
-
subUnitId:
|
|
1621
|
-
row
|
|
1622
|
-
col:
|
|
1623
|
-
customRange:
|
|
1608
|
+
unitId,
|
|
1609
|
+
subUnitId: sheetId,
|
|
1610
|
+
row,
|
|
1611
|
+
col: column,
|
|
1612
|
+
customRange: customRange.range,
|
|
1624
1613
|
customRangeRect: {
|
|
1625
|
-
left:
|
|
1626
|
-
top:
|
|
1627
|
-
bottom:
|
|
1628
|
-
right:
|
|
1614
|
+
left: rect.left + canvasClientRect.left,
|
|
1615
|
+
top: rect.top + canvasClientRect.top,
|
|
1616
|
+
bottom: rect.bottom + canvasClientRect.top,
|
|
1617
|
+
right: rect.right + canvasClientRect.left
|
|
1629
1618
|
},
|
|
1630
|
-
editPermission
|
|
1631
|
-
copyPermission
|
|
1632
|
-
type:
|
|
1619
|
+
editPermission,
|
|
1620
|
+
copyPermission,
|
|
1621
|
+
type: HyperLinkEditSourceType.EDITING
|
|
1633
1622
|
});
|
|
1634
1623
|
}));
|
|
1635
1624
|
})
|
|
1636
1625
|
), this.disposeWithMe(() => {
|
|
1637
|
-
|
|
1626
|
+
subscribe == null || subscribe.unsubscribe();
|
|
1638
1627
|
});
|
|
1639
1628
|
}
|
|
1640
1629
|
_initZenEditor() {
|
|
1641
1630
|
this.disposeWithMe(
|
|
1642
|
-
this._zenZoneService.visible$.subscribe((
|
|
1643
|
-
|
|
1631
|
+
this._zenZoneService.visible$.subscribe((visible) => {
|
|
1632
|
+
visible ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING), this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.ZEN_EDITOR));
|
|
1644
1633
|
})
|
|
1645
1634
|
), this.disposeWithMe(
|
|
1646
1635
|
this._univerInstanceService.focused$.pipe(
|
|
1647
|
-
|
|
1648
|
-
const
|
|
1649
|
-
return
|
|
1650
|
-
|
|
1636
|
+
switchMap((id) => {
|
|
1637
|
+
const render2 = id === DOCS_ZEN_EDITOR_UNIT_ID_KEY ? this._renderManagerService.getRenderById(id) : null;
|
|
1638
|
+
return render2 ? render2.with(DocEventManagerService).hoverCustomRanges$.pipe(debounceTime(200)) : new Observable((sub) => {
|
|
1639
|
+
sub.next(null);
|
|
1651
1640
|
});
|
|
1652
1641
|
})
|
|
1653
|
-
).subscribe((
|
|
1654
|
-
const
|
|
1655
|
-
if (
|
|
1656
|
-
const { unitId
|
|
1657
|
-
|
|
1658
|
-
type:
|
|
1659
|
-
unitId
|
|
1660
|
-
subUnitId:
|
|
1661
|
-
row
|
|
1662
|
-
col:
|
|
1663
|
-
customRange:
|
|
1664
|
-
editPermission
|
|
1665
|
-
copyPermission
|
|
1642
|
+
).subscribe((value) => {
|
|
1643
|
+
const range = value == null ? void 0 : value.find((range2) => range2.range.rangeType === CustomRangeType.HYPERLINK), state = this._editorBridgeService.getEditCellState();
|
|
1644
|
+
if (range && state) {
|
|
1645
|
+
const { unitId, sheetId, row, column } = state, { editPermission, viewPermission, copyPermission } = this._getLinkPermission({ unitId, subUnitId: sheetId, row, col: column });
|
|
1646
|
+
viewPermission && this._sheetsHyperLinkPopupService.showPopup({
|
|
1647
|
+
type: HyperLinkEditSourceType.ZEN_EDITOR,
|
|
1648
|
+
unitId,
|
|
1649
|
+
subUnitId: sheetId,
|
|
1650
|
+
row,
|
|
1651
|
+
col: column,
|
|
1652
|
+
customRange: range.range,
|
|
1653
|
+
editPermission,
|
|
1654
|
+
copyPermission
|
|
1666
1655
|
});
|
|
1667
1656
|
} else
|
|
1668
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup(
|
|
1657
|
+
this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.ZEN_EDITOR);
|
|
1669
1658
|
})
|
|
1670
1659
|
);
|
|
1671
1660
|
}
|
|
1672
1661
|
_initTextSelectionListener() {
|
|
1673
1662
|
this.disposeWithMe(
|
|
1674
|
-
this._textSelectionManagerService.textSelection$.subscribe((
|
|
1675
|
-
|
|
1663
|
+
this._textSelectionManagerService.textSelection$.subscribe((selection) => {
|
|
1664
|
+
selection && selection.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY && this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING);
|
|
1676
1665
|
})
|
|
1677
1666
|
);
|
|
1678
1667
|
}
|
|
1679
1668
|
_initCommandListener() {
|
|
1680
|
-
const
|
|
1681
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
1682
|
-
|
|
1669
|
+
const HIDE_COMMAND_LIST = [ClearSelectionContentCommand.id, ClearSelectionAllCommand.id, ClearSelectionFormatCommand.id];
|
|
1670
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1671
|
+
HIDE_COMMAND_LIST.includes(command.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
|
|
1683
1672
|
}));
|
|
1684
1673
|
}
|
|
1685
|
-
};
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
],
|
|
1698
|
-
var
|
|
1699
|
-
for (var
|
|
1700
|
-
(
|
|
1701
|
-
return
|
|
1702
|
-
},
|
|
1703
|
-
let
|
|
1704
|
-
constructor(
|
|
1705
|
-
super(), this._context =
|
|
1674
|
+
}, __name(_a6, "SheetsHyperLinkPopupController"), _a6);
|
|
1675
|
+
SheetsHyperLinkPopupController = __decorateClass$4([
|
|
1676
|
+
__decorateParam$4(0, Inject(HoverManagerService)),
|
|
1677
|
+
__decorateParam$4(1, Inject(SheetsHyperLinkPopupService)),
|
|
1678
|
+
__decorateParam$4(2, Inject(IRenderManagerService)),
|
|
1679
|
+
__decorateParam$4(3, Inject(IPermissionService)),
|
|
1680
|
+
__decorateParam$4(4, Inject(SheetPermissionCheckController)),
|
|
1681
|
+
__decorateParam$4(5, ICommandService),
|
|
1682
|
+
__decorateParam$4(6, IEditorBridgeService),
|
|
1683
|
+
__decorateParam$4(7, Inject(DocSelectionManagerService)),
|
|
1684
|
+
__decorateParam$4(8, IUniverInstanceService),
|
|
1685
|
+
__decorateParam$4(9, IZenZoneService)
|
|
1686
|
+
], SheetsHyperLinkPopupController);
|
|
1687
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1688
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1689
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1690
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
1691
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a7;
|
|
1692
|
+
let SheetsHyperLinkRenderController = (_a7 = class extends Disposable {
|
|
1693
|
+
constructor(_context, _hyperLinkModel) {
|
|
1694
|
+
super(), this._context = _context, this._hyperLinkModel = _hyperLinkModel, this._initSkeletonChange();
|
|
1706
1695
|
}
|
|
1707
1696
|
_initSkeletonChange() {
|
|
1708
|
-
const
|
|
1709
|
-
var
|
|
1710
|
-
(
|
|
1711
|
-
};
|
|
1712
|
-
this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(
|
|
1713
|
-
|
|
1697
|
+
const markSkeletonDirty = /* @__PURE__ */ __name(() => {
|
|
1698
|
+
var _a12;
|
|
1699
|
+
(_a12 = this._context.mainComponent) == null || _a12.makeForceDirty();
|
|
1700
|
+
}, "markSkeletonDirty");
|
|
1701
|
+
this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(debounceTime(16)).subscribe(() => {
|
|
1702
|
+
markSkeletonDirty();
|
|
1714
1703
|
}));
|
|
1715
1704
|
}
|
|
1716
|
-
};
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
],
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1705
|
+
}, __name(_a7, "SheetsHyperLinkRenderController"), _a7);
|
|
1706
|
+
SheetsHyperLinkRenderController = __decorateClass$3([
|
|
1707
|
+
__decorateParam$3(1, Inject(HyperLinkModel))
|
|
1708
|
+
], SheetsHyperLinkRenderController);
|
|
1709
|
+
var _a8;
|
|
1710
|
+
let SheetsHyperLinkRenderManagerController = (_a8 = class extends Disposable {
|
|
1711
|
+
constructor(_sheetInterceptorService, _hyperLinkModel) {
|
|
1712
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._hyperLinkModel = _hyperLinkModel, this._initViewModelIntercept();
|
|
1723
1713
|
}
|
|
1724
1714
|
_initViewModelIntercept() {
|
|
1725
1715
|
this.disposeWithMe(
|
|
1726
1716
|
this._sheetInterceptorService.intercept(
|
|
1727
|
-
|
|
1717
|
+
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
1728
1718
|
{
|
|
1729
|
-
effect:
|
|
1719
|
+
effect: InterceptorEffectEnum.Value,
|
|
1730
1720
|
priority: 100,
|
|
1731
|
-
handler: (
|
|
1732
|
-
const { row
|
|
1733
|
-
return
|
|
1734
|
-
...
|
|
1735
|
-
linkUrl:
|
|
1736
|
-
linkId:
|
|
1737
|
-
} :
|
|
1738
|
-
}
|
|
1721
|
+
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
1722
|
+
const { row, col, unitId, subUnitId } = pos, link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1723
|
+
return next(link ? {
|
|
1724
|
+
...cell,
|
|
1725
|
+
linkUrl: link.payload,
|
|
1726
|
+
linkId: link.id
|
|
1727
|
+
} : cell);
|
|
1728
|
+
}, "handler")
|
|
1739
1729
|
}
|
|
1740
1730
|
)
|
|
1741
1731
|
);
|
|
1742
1732
|
}
|
|
1743
|
-
};
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
],
|
|
1748
|
-
const
|
|
1749
|
-
[
|
|
1750
|
-
[
|
|
1733
|
+
}, __name(_a8, "SheetsHyperLinkRenderManagerController"), _a8);
|
|
1734
|
+
SheetsHyperLinkRenderManagerController = __decorateClass$3([
|
|
1735
|
+
__decorateParam$3(0, Inject(SheetInterceptorService)),
|
|
1736
|
+
__decorateParam$3(1, Inject(HyperLinkModel))
|
|
1737
|
+
], SheetsHyperLinkRenderManagerController);
|
|
1738
|
+
const menuSchema = {
|
|
1739
|
+
[RibbonStartGroup.OTHERS]: {
|
|
1740
|
+
[InsertHyperLinkToolbarOperation.id]: {
|
|
1751
1741
|
order: 2,
|
|
1752
|
-
menuItemFactory:
|
|
1742
|
+
menuItemFactory: insertLinkMenuToolbarFactory
|
|
1753
1743
|
},
|
|
1754
|
-
[
|
|
1744
|
+
[genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]: {
|
|
1755
1745
|
order: 2,
|
|
1756
|
-
menuItemFactory:
|
|
1746
|
+
menuItemFactory: zenEditorInsertLinkMenuToolbarFactory
|
|
1757
1747
|
}
|
|
1758
1748
|
},
|
|
1759
|
-
[
|
|
1760
|
-
[
|
|
1749
|
+
[ContextMenuPosition.MAIN_AREA]: {
|
|
1750
|
+
[ContextMenuGroup.OTHERS]: {
|
|
1761
1751
|
order: 1,
|
|
1762
|
-
[
|
|
1752
|
+
[InsertHyperLinkToolbarOperation.id]: {
|
|
1763
1753
|
order: 0,
|
|
1764
|
-
menuItemFactory:
|
|
1754
|
+
menuItemFactory: insertLinkMenuFactory
|
|
1765
1755
|
},
|
|
1766
|
-
[
|
|
1756
|
+
[genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]: {
|
|
1767
1757
|
order: 0,
|
|
1768
|
-
menuItemFactory:
|
|
1758
|
+
menuItemFactory: zenEditorInsertLinkMenuFactory
|
|
1769
1759
|
}
|
|
1770
1760
|
}
|
|
1771
1761
|
}
|
|
1772
1762
|
};
|
|
1773
|
-
var
|
|
1774
|
-
for (var
|
|
1775
|
-
(
|
|
1776
|
-
return
|
|
1777
|
-
},
|
|
1778
|
-
let
|
|
1779
|
-
constructor(
|
|
1780
|
-
super(), this._componentManager =
|
|
1763
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1764
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1765
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1766
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
1767
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a9;
|
|
1768
|
+
let SheetsHyperLinkUIController = (_a9 = class extends Disposable {
|
|
1769
|
+
constructor(_componentManager, _commandService, _menuManagerService, _injector, _shortcutService) {
|
|
1770
|
+
super(), this._componentManager = _componentManager, this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._injector = _injector, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
|
|
1781
1771
|
}
|
|
1782
1772
|
_initComponents() {
|
|
1783
1773
|
[
|
|
1784
|
-
[
|
|
1785
|
-
[
|
|
1786
|
-
[
|
|
1787
|
-
].forEach(([
|
|
1788
|
-
this._componentManager.register(
|
|
1774
|
+
[CellLinkPopup, CellLinkPopup.componentKey],
|
|
1775
|
+
[CellLinkEdit, CellLinkEdit.componentKey],
|
|
1776
|
+
[LinkSingle, "LinkSingle"]
|
|
1777
|
+
].forEach(([comp, key]) => {
|
|
1778
|
+
this._componentManager.register(key, comp);
|
|
1789
1779
|
});
|
|
1790
1780
|
}
|
|
1791
1781
|
_initCommands() {
|
|
1792
1782
|
[
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
].forEach((
|
|
1798
|
-
this._commandService.registerCommand(
|
|
1783
|
+
OpenHyperLinkEditPanelOperation,
|
|
1784
|
+
CloseHyperLinkPopupOperation,
|
|
1785
|
+
InsertHyperLinkOperation,
|
|
1786
|
+
InsertHyperLinkToolbarOperation
|
|
1787
|
+
].forEach((command) => {
|
|
1788
|
+
this._commandService.registerCommand(command);
|
|
1799
1789
|
});
|
|
1800
1790
|
}
|
|
1801
1791
|
_initMenus() {
|
|
1802
|
-
this._menuManagerService.mergeMenu(
|
|
1792
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
1803
1793
|
}
|
|
1804
1794
|
_initShortCut() {
|
|
1805
|
-
this._shortcutService.registerShortcut(
|
|
1806
|
-
}
|
|
1807
|
-
};
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
],
|
|
1815
|
-
var
|
|
1816
|
-
for (var
|
|
1817
|
-
(
|
|
1818
|
-
return
|
|
1819
|
-
},
|
|
1820
|
-
let
|
|
1821
|
-
constructor(
|
|
1822
|
-
super(), this._parserService =
|
|
1795
|
+
this._shortcutService.registerShortcut(InsertLinkShortcut);
|
|
1796
|
+
}
|
|
1797
|
+
}, __name(_a9, "SheetsHyperLinkUIController"), _a9);
|
|
1798
|
+
SheetsHyperLinkUIController = __decorateClass$2([
|
|
1799
|
+
__decorateParam$2(0, Inject(ComponentManager)),
|
|
1800
|
+
__decorateParam$2(1, ICommandService),
|
|
1801
|
+
__decorateParam$2(2, IMenuManagerService),
|
|
1802
|
+
__decorateParam$2(3, Inject(Injector)),
|
|
1803
|
+
__decorateParam$2(4, Inject(IShortcutService))
|
|
1804
|
+
], SheetsHyperLinkUIController);
|
|
1805
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1806
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1807
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1808
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
1809
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a10;
|
|
1810
|
+
let SheetHyperLinkUrlController = (_a10 = class extends Disposable {
|
|
1811
|
+
constructor(_parserService, _resolverService) {
|
|
1812
|
+
super(), this._parserService = _parserService, this._resolverService = _resolverService, this._handleInitUrl();
|
|
1823
1813
|
}
|
|
1824
1814
|
_handleInitUrl() {
|
|
1825
|
-
const
|
|
1826
|
-
if (
|
|
1827
|
-
const
|
|
1828
|
-
this._resolverService.navigate(
|
|
1815
|
+
const hash = location.hash;
|
|
1816
|
+
if (hash) {
|
|
1817
|
+
const linkInfo = this._parserService.parseHyperLink(hash);
|
|
1818
|
+
this._resolverService.navigate(linkInfo);
|
|
1829
1819
|
}
|
|
1830
1820
|
}
|
|
1831
|
-
};
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
],
|
|
1836
|
-
var
|
|
1837
|
-
for (var
|
|
1838
|
-
(
|
|
1839
|
-
return
|
|
1840
|
-
},
|
|
1841
|
-
let
|
|
1842
|
-
constructor(
|
|
1843
|
-
super(), this._config =
|
|
1844
|
-
const { menu
|
|
1821
|
+
}, __name(_a10, "SheetHyperLinkUrlController"), _a10);
|
|
1822
|
+
SheetHyperLinkUrlController = __decorateClass$1([
|
|
1823
|
+
__decorateParam$1(0, Inject(SheetsHyperLinkParserService)),
|
|
1824
|
+
__decorateParam$1(1, Inject(SheetsHyperLinkResolverService))
|
|
1825
|
+
], SheetHyperLinkUrlController);
|
|
1826
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1827
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1828
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1829
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
1830
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a11;
|
|
1831
|
+
let UniverSheetsHyperLinkUIPlugin = (_a11 = class extends Plugin {
|
|
1832
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
1833
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService;
|
|
1834
|
+
const { menu, ...rest } = merge(
|
|
1845
1835
|
{},
|
|
1846
|
-
|
|
1836
|
+
defaultPluginConfig,
|
|
1847
1837
|
this._config
|
|
1848
1838
|
);
|
|
1849
|
-
|
|
1839
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(SHEETS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY, rest);
|
|
1850
1840
|
}
|
|
1851
1841
|
onStarting() {
|
|
1852
1842
|
[
|
|
1853
|
-
[
|
|
1854
|
-
[
|
|
1855
|
-
[
|
|
1856
|
-
[
|
|
1857
|
-
[
|
|
1858
|
-
[
|
|
1859
|
-
[
|
|
1860
|
-
[
|
|
1861
|
-
[
|
|
1862
|
-
[
|
|
1863
|
-
].forEach((
|
|
1843
|
+
[SheetsHyperLinkResolverService],
|
|
1844
|
+
[SheetsHyperLinkPopupService],
|
|
1845
|
+
[SheetsHyperLinkSidePanelService],
|
|
1846
|
+
[SheetsHyperLinkRenderManagerController],
|
|
1847
|
+
[SheetsHyperLinkPopupController],
|
|
1848
|
+
[SheetsHyperLinkUIController],
|
|
1849
|
+
[SheetsHyperLinkAutoFillController],
|
|
1850
|
+
[SheetsHyperLinkCopyPasteController],
|
|
1851
|
+
[SheetsHyperLinkPermissionController],
|
|
1852
|
+
[SheetHyperLinkUrlController]
|
|
1853
|
+
].forEach((dep) => this._injector.add(dep)), this._injector.get(SheetsHyperLinkRenderManagerController);
|
|
1864
1854
|
}
|
|
1865
1855
|
onReady() {
|
|
1866
|
-
this._injector.get(
|
|
1856
|
+
this._injector.get(IRenderManagerService).registerRenderModule(UniverInstanceType.UNIVER_SHEET, [SheetsHyperLinkRenderController]), this._injector.get(SheetsHyperLinkAutoFillController), this._injector.get(SheetsHyperLinkCopyPasteController), this._injector.get(SheetsHyperLinkUIController);
|
|
1867
1857
|
}
|
|
1868
1858
|
onRendered() {
|
|
1869
|
-
this._injector.get(
|
|
1870
|
-
}
|
|
1871
|
-
};
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
],
|
|
1859
|
+
this._injector.get(SheetsHyperLinkPermissionController), this._injector.get(SheetHyperLinkUrlController), this._injector.get(SheetsHyperLinkPopupController);
|
|
1860
|
+
}
|
|
1861
|
+
}, __name(_a11, "UniverSheetsHyperLinkUIPlugin"), _a11);
|
|
1862
|
+
__publicField2(UniverSheetsHyperLinkUIPlugin, "pluginName", SHEET_HYPER_LINK_UI_PLUGIN);
|
|
1863
|
+
__publicField2(UniverSheetsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1864
|
+
UniverSheetsHyperLinkUIPlugin = __decorateClass([
|
|
1865
|
+
DependentOn(UniverSheetsHyperLinkPlugin, UniverDocsUIPlugin),
|
|
1866
|
+
__decorateParam(1, Inject(Injector)),
|
|
1867
|
+
__decorateParam(2, IConfigService)
|
|
1868
|
+
], UniverSheetsHyperLinkUIPlugin);
|
|
1879
1869
|
export {
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1870
|
+
CloseHyperLinkPopupOperation,
|
|
1871
|
+
InsertHyperLinkOperation,
|
|
1872
|
+
InsertLinkShortcut,
|
|
1873
|
+
OpenHyperLinkEditPanelOperation,
|
|
1874
|
+
SheetsHyperLinkCopyPasteController,
|
|
1875
|
+
SheetsHyperLinkPopupService,
|
|
1876
|
+
SheetsHyperLinkResolverService,
|
|
1877
|
+
SheetsHyperLinkSidePanelService,
|
|
1878
|
+
UniverSheetsHyperLinkUIPlugin
|
|
1889
1879
|
};
|