@univerjs/sheets-hyper-link-ui 0.4.2 → 0.5.0-nightly.202411091605

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.
Files changed (48) hide show
  1. package/lib/cjs/facade.js +1 -0
  2. package/lib/cjs/index.js +2 -2
  3. package/lib/cjs/locale/en-US.js +1 -0
  4. package/lib/cjs/locale/fa-IR.js +1 -0
  5. package/lib/cjs/locale/ru-RU.js +1 -0
  6. package/lib/cjs/locale/vi-VN.js +1 -0
  7. package/lib/cjs/locale/zh-CN.js +1 -0
  8. package/lib/cjs/locale/zh-TW.js +1 -0
  9. package/lib/es/facade.js +1 -0
  10. package/lib/es/index.js +1343 -2023
  11. package/lib/es/locale/en-US.js +38 -0
  12. package/lib/es/locale/fa-IR.js +38 -0
  13. package/lib/es/locale/ru-RU.js +38 -0
  14. package/lib/es/locale/vi-VN.js +38 -0
  15. package/lib/es/locale/zh-CN.js +38 -0
  16. package/lib/es/locale/zh-TW.js +38 -0
  17. package/lib/index.css +1 -1
  18. package/lib/types/controllers/url.controller.d.ts +3 -1
  19. package/lib/types/facade/f-workbook.d.ts +13 -0
  20. package/lib/types/{types/interfaces/i-sheet-url-params.d.ts → facade/index.d.ts} +0 -6
  21. package/lib/types/index.d.ts +0 -4
  22. package/lib/types/services/popup.service.d.ts +5 -5
  23. package/lib/types/services/resolver.service.d.ts +5 -9
  24. package/lib/types/views/CellLinkPopup/index.d.ts +14 -0
  25. package/lib/umd/facade.js +1 -0
  26. package/lib/umd/index.js +2 -2
  27. package/lib/umd/locale/en-US.js +1 -0
  28. package/lib/umd/locale/fa-IR.js +1 -0
  29. package/lib/umd/locale/ru-RU.js +1 -0
  30. package/lib/umd/locale/vi-VN.js +1 -0
  31. package/lib/umd/locale/zh-CN.js +1 -0
  32. package/lib/umd/locale/zh-TW.js +1 -0
  33. package/package.json +44 -25
  34. package/LICENSE +0 -176
  35. package/lib/locale/en-US.json +0 -35
  36. package/lib/locale/fa-IR.json +0 -35
  37. package/lib/locale/ru-RU.json +0 -35
  38. package/lib/locale/vi-VN.json +0 -35
  39. package/lib/locale/zh-CN.json +0 -35
  40. package/lib/locale/zh-TW.json +0 -35
  41. package/lib/types/commands/commands/add-hyper-link.command.d.ts +0 -19
  42. package/lib/types/commands/commands/remove-hyper-link.command.d.ts +0 -19
  43. package/lib/types/commands/commands/update-hyper-link.command.d.ts +0 -17
  44. package/lib/types/controllers/remove-sheet.controller.d.ts +0 -10
  45. package/lib/types/controllers/rich-text-ref-range.controller.d.ts +0 -15
  46. package/lib/types/controllers/set-range.controller.d.ts +0 -18
  47. package/lib/types/types/interfaces/i-sheet-hyper-link-info.d.ts +0 -10
  48. package/lib/types/types/interfaces/index.d.ts +0 -17
package/lib/es/index.js CHANGED
@@ -1,396 +1,313 @@
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, CommandType, IUndoRedoService, BuildTextUtils, DataStreamTreeTokenType, CustomRangeType, TextX, CellValueType, sequenceExecuteAsync, generateRandomId, getBodySlice, useDependency, IContextService, ThemeService, ColorKit, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DisposableCollection, FOCUSING_SHEET, sequenceExecute, useObservable as useObservable$1, DataValidationType, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, IPermissionService, InterceptorEffectEnum, DependentOn, Plugin } from "@univerjs/core";
6
- import { SheetHyperLinkType, ERROR_RANGE, HyperLinkModel, RemoveHyperLinkMutation, AddHyperLinkMutation, UniverSheetsHyperLinkPlugin } from "@univerjs/sheets-hyper-link";
7
- import { ScrollToRangeOperation, COPY_TYPE, virtualizeDiscreteRanges, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, IEditorBridgeService, SheetSkeletonManagerService, IMarkSelectionService, SheetCanvasPopManagerService, getEditingCustomRangePosition, getCustomRangePosition, whenSheetEditorFocused, getCurrentRangeDisable$, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange, SheetPermissionInterceptorBaseController, HoverManagerService, HoverRenderController } from "@univerjs/sheets-ui";
8
- import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
9
- import { deserializeRangeWithSheet, serializeRangeWithSheet, serializeRange, IDefinedNamesService, serializeRangeToRefString } from "@univerjs/engine-formula";
10
- import { SetSelectionsOperation, SetWorksheetActiveOperation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetsSelectionsService, getSheetCommandTarget, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission, RangeProtectionPermissionEditPoint, WorkbookViewPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, WorkbookCopyPermission, WorksheetCopyPermission, ClearSelectionContentCommand, ClearSelectionAllCommand, ClearSelectionFormatCommand, SheetInterceptorService, RemoveSheetCommand, INTERCEPTOR_POINT, RefRangeService, SetRangeValuesCommand } from "@univerjs/sheets";
11
- import { IMessageService, useObservable, IZenZoneService, useEvent, KeyCode, MenuItemType, MenuPosition, MenuGroup, MetaKeys, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IShortcutService, IMenuManagerService } from "@univerjs/ui";
12
- import { addCustomRangeBySelectionFactory, replaceSelectionFactory, DocSelectionRenderService, DocBackScrollRenderController, deleteCustomRangeFactory, DocCanvasPopManagerService, IEditorService, IRangeSelectorService, DocEventManagerService, UniverDocsUIPlugin } from "@univerjs/docs-ui";
13
- import { IRenderManagerService } from "@univerjs/engine-render";
14
- import { Subject, BehaviorSubject, of, map, filter, switchMap, distinctUntilChanged, debounceTime, Observable } from "rxjs";
15
- import { DocSelectionManagerService } from "@univerjs/docs";
16
- import require$$0, { useState, useMemo, useRef, useEffect, forwardRef, createElement } from "react";
17
- import { RangeSelector } from "@univerjs/sheets-formula-ui";
18
- function isLegalLink(link) {
19
- return Tools.isLegalUrl(link);
1
+ var er = Object.defineProperty;
2
+ var tr = (t, e, n) => e in t ? er(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var V = (t, e, n) => tr(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { Tools as Ce, Inject as R, LocaleService as it, UniverInstanceType as O, isValidRange as _n, IUniverInstanceService as K, ICommandService as re, IConfigService as Sn, RANGE_TYPE as nn, Rectangle as Ie, Injector as st, Disposable as z, Range as Cn, ObjectMatrix as nr, useDependency as E, IContextService as In, ThemeService as rr, DataStreamTreeTokenType as rn, CustomRangeType as Me, BuildTextUtils as de, ColorKit as ir, DOCS_ZEN_EDITOR_UNIT_ID_KEY as x, DisposableCollection as sr, FOCUSING_SHEET as _t, generateRandomId as or, DataValidationType as St, CommandType as ot, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as yt, FOCUSING_FX_BAR_EDITOR as ar, IPermissionService as cr, InterceptorEffectEnum as lr, DependentOn as ur, Plugin as dr } from "@univerjs/core";
5
+ import { SheetHyperLinkType as S, ERROR_RANGE as pr, HyperLinkModel as at, RemoveHyperLinkMutation as xe, AddHyperLinkMutation as Ne, SheetsHyperLinkParserService as wt, UpdateRichHyperLinkCommand as hr, UpdateHyperLinkCommand as gr, AddRichHyperLinkCommand as mr, AddHyperLinkCommand as fr, CancelRichHyperLinkCommand as vr, CancelHyperLinkCommand as _r, UniverSheetsHyperLinkPlugin as Sr } from "@univerjs/sheets-hyper-link";
6
+ import { ScrollToRangeOperation as yn, COPY_TYPE as Cr, virtualizeDiscreteRanges as Et, rangeToDiscreteRange as Ir, PREDEFINED_HOOK_NAME as De, getRepeatRange as yr, ISheetClipboardService as Er, IEditorBridgeService as ne, IMarkSelectionService as Rr, SheetCanvasPopManagerService as Pr, getEditingCustomRangePosition as Lr, getCustomRangePosition as br, whenSheetEditorFocused as wr, getCurrentRangeDisable$ as Or, IAutoFillService as kr, APPLY_TYPE as we, getAutoFillRepeatRange as Tr, SheetPermissionInterceptorBaseController as En, HoverManagerService as xr, HoverRenderController as Nr, SheetSkeletonManagerService as sn } from "@univerjs/sheets-ui";
7
+ import { MessageType as ke, FormLayout as _e, Input as on, Select as Ct, Button as an, Tooltip as $e } from "@univerjs/design";
8
+ import { deserializeRangeWithSheet as Ve, IDefinedNamesService as Rn, serializeRangeWithSheet as Mr, serializeRangeToRefString as Ur, serializeRange as Hr } from "@univerjs/engine-formula";
9
+ import { SetSelectionsOperation as Pn, SetWorksheetActiveOperation as Ln, SheetsSelectionsService as Ot, getSheetCommandTarget as bn, WorkbookEditablePermission as kt, WorksheetEditPermission as Tt, WorksheetSetCellValuePermission as wn, WorksheetInsertHyperlinkPermission as xt, RangeProtectionPermissionEditPoint as Nt, WorkbookViewPermission as Dr, WorksheetViewPermission as $r, RangeProtectionPermissionViewPoint as jr, WorkbookCopyPermission as Vr, WorksheetCopyPermission as Br, ClearSelectionContentCommand as Ar, ClearSelectionAllCommand as Fr, ClearSelectionFormatCommand as Wr, SheetInterceptorService as Zr, INTERCEPTOR_POINT as Gr } from "@univerjs/sheets";
10
+ import { IMessageService as On, useObservable as Kr, IZenZoneService as ct, useEvent as zr, KeyCode as Rt, MenuItemType as kn, MenuPosition as Tn, MenuGroup as Yr, MetaKeys as Xr, getMenuHiddenObservable as lt, RibbonStartGroup as qr, ContextMenuPosition as Jr, ContextMenuGroup as Qr, ComponentManager as ei, IShortcutService as ti, IMenuManagerService as ni } from "@univerjs/ui";
11
+ import { DocSelectionRenderService as xn, DocBackScrollRenderController as ri, DocCanvasPopManagerService as ii, DocEventManagerService as cn, UniverDocsUIPlugin as si } from "@univerjs/docs-ui";
12
+ import { IRenderManagerService as ut } from "@univerjs/engine-render";
13
+ import { Subject as oi, BehaviorSubject as ai, of as Te, map as le, filter as ln, switchMap as ue, combineLatest as ci, distinctUntilChanged as li, debounceTime as Be, Observable as ui } from "rxjs";
14
+ import { DocSelectionManagerService as Ue } from "@univerjs/docs";
15
+ import di, { useState as X, useMemo as un, useRef as Pt, useCallback as pi, useEffect as te, forwardRef as ge, createElement as me } from "react";
16
+ import { RangeSelector as hi } from "@univerjs/sheets-formula-ui";
17
+ function Fe(t) {
18
+ return Ce.isLegalUrl(t);
20
19
  }
21
- __name(isLegalLink, "isLegalLink");
22
- function hasProtocol(urlString) {
23
- return /^[a-zA-Z]+:\/\//.test(urlString);
20
+ function gi(t) {
21
+ return /^[a-zA-Z]+:\/\//.test(t);
24
22
  }
25
- __name(hasProtocol, "hasProtocol");
26
- function isEmail(url) {
27
- return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
23
+ function mi(t) {
24
+ return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t);
28
25
  }
29
- __name(isEmail, "isEmail");
30
- function serializeUrl(urlStr) {
31
- if (isLegalLink(urlStr)) {
32
- const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`;
33
- let url;
26
+ function fi(t) {
27
+ if (Fe(t)) {
28
+ const e = gi(t) ? t : mi(t) ? `mailto://${t}` : `http://${t}`;
29
+ let n;
34
30
  try {
35
- url = new URL(transformedUrl);
31
+ n = new URL(e);
36
32
  } catch {
37
- return urlStr;
33
+ return t;
38
34
  }
39
- return url.hostname === location.hostname && url.port === location.port && url.protocol === location.protocol && url.pathname === location.pathname && url.hash && !url.search ? url.hash : transformedUrl;
35
+ return n.hostname === location.hostname && n.port === location.port && n.protocol === location.protocol && n.pathname === location.pathname && n.hash && !n.search ? n.hash : e;
40
36
  }
41
- return urlStr;
37
+ return t;
42
38
  }
43
- __name(serializeUrl, "serializeUrl");
44
- const PLUGIN_CONFIG_KEY = "sheets-hyper-link-ui.config", defaultPluginConfig = {};
45
- var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
46
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
47
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
48
- return kind && result && __defProp$c(target, key, result), result;
49
- }, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c");
50
- function getContainRange(range, worksheet) {
51
- const mergedCells = worksheet.getMergeData(), maxCol = worksheet.getMaxColumns() - 1, maxRow = worksheet.getMaxRows() - 1;
52
- if (maxCol < range.endColumn && (range.endColumn = maxCol), maxRow < range.endRow && (range.endRow = maxRow), range.rangeType === RANGE_TYPE.COLUMN || RANGE_TYPE.ROW)
53
- return range;
54
- const relativeCells = [];
55
- return mergedCells.forEach((cell) => {
56
- Rectangle.intersects(range, cell) && relativeCells.push(cell);
57
- }), Rectangle.realUnion(range, ...relativeCells);
39
+ const Nn = "sheets-hyper-link-ui.config", vi = {};
40
+ var _i = Object.defineProperty, Si = Object.getOwnPropertyDescriptor, Ci = (t, e, n, r) => {
41
+ for (var i = r > 1 ? void 0 : r ? Si(e, n) : e, o = t.length - 1, s; o >= 0; o--)
42
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
43
+ return r && i && _i(e, n, i), i;
44
+ }, Se = (t, e) => (n, r) => e(n, r, t);
45
+ function Ii(t, e) {
46
+ const n = e.getMergeData(), r = e.getMaxColumns() - 1, i = e.getMaxRows() - 1;
47
+ if (r < t.endColumn && (t.endColumn = r), i < t.endRow && (t.endRow = i), t.rangeType === nn.COLUMN || nn.ROW)
48
+ return t;
49
+ const o = [];
50
+ return n.forEach((s) => {
51
+ Ie.intersects(t, s) && o.push(s);
52
+ }), Ie.realUnion(t, ...o);
58
53
  }
59
- __name(getContainRange, "getContainRange");
60
- var _a;
61
- let SheetsHyperLinkResolverService = (_a = class {
62
- constructor(_univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService, _configService) {
63
- this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService, this._configService = _configService;
64
- }
65
- _getURLName(params) {
66
- var _a15;
67
- const { gid, range, rangeid, unitid } = params, workbook = unitid ? this._univerInstanceService.getUnit(unitid, UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), invalidLink = {
68
- type: SheetHyperLinkType.INVALID,
69
- name: this._localeService.t("hyperLink.message.refError")
70
- };
71
- if (!workbook)
72
- return invalidLink;
73
- const sheet = gid ? workbook.getSheetBySheetId(gid) : workbook.getActiveSheet(), sheetName = (_a15 = sheet == null ? void 0 : sheet.getName()) != null ? _a15 : "";
74
- if (range) {
75
- if (!sheet) return invalidLink;
76
- const rangeObj = deserializeRangeWithSheet(range).range;
77
- return isValidRange(rangeObj, sheet) && range !== ERROR_RANGE ? {
78
- type: SheetHyperLinkType.RANGE,
79
- name: serializeRangeWithSheet(sheetName, rangeObj)
80
- } : invalidLink;
81
- }
82
- if (rangeid) {
83
- const range2 = this._definedNamesService.getValueById(workbook.getUnitId(), rangeid);
84
- return range2 ? {
85
- type: SheetHyperLinkType.DEFINE_NAME,
86
- name: range2.formulaOrRefString
87
- } : invalidLink;
54
+ let he = class {
55
+ constructor(t, e, n, r, i, o) {
56
+ this._univerInstanceService = t, this._commandService = e, this._definedNamesService = n, this._messageService = r, this._localeService = i, this._configService = o;
57
+ }
58
+ navigate(t) {
59
+ switch (t.type) {
60
+ case S.URL:
61
+ this.navigateToOtherWebsite(t.url);
62
+ break;
63
+ default:
64
+ this._navigateToUniver(t.searchObj);
88
65
  }
89
- if (gid) {
90
- const worksheet = workbook.getSheetBySheetId(gid);
91
- return worksheet ? {
92
- type: SheetHyperLinkType.SHEET,
93
- name: worksheet.getName()
94
- } : invalidLink;
95
- }
96
- return invalidLink;
97
66
  }
98
- navigateTo(params) {
99
- const { gid, range, rangeid } = params, workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
100
- if (!workbook)
67
+ _navigateToUniver(t) {
68
+ const { gid: e, range: n, rangeid: r } = t, i = this._univerInstanceService.getCurrentUnitForType(O.UNIVER_SHEET);
69
+ if (!i)
101
70
  return;
102
- const unitId = workbook.getUnitId();
103
- if (rangeid) {
104
- const item = this._definedNamesService.getValueById(unitId, rangeid);
105
- if (!item)
71
+ const o = i.getUnitId();
72
+ if (r) {
73
+ const s = this._definedNamesService.getValueById(o, r);
74
+ if (!s)
106
75
  return;
107
- const { formulaOrRefString } = item, worksheet = this._definedNamesService.getWorksheetByRef(unitId, formulaOrRefString);
108
- if (!worksheet) {
76
+ const { formulaOrRefString: c } = s, u = this._definedNamesService.getWorksheetByRef(o, c);
77
+ if (!u) {
109
78
  this._messageService.show({
110
79
  content: this._localeService.t("hyperLink.message.refError"),
111
- type: MessageType.Error
80
+ type: ke.Error
112
81
  });
113
82
  return;
114
83
  }
115
- if (worksheet.isSheetHidden()) {
84
+ if (u.isSheetHidden()) {
116
85
  this._messageService.show({
117
86
  content: this._localeService.t("hyperLink.message.hiddenSheet"),
118
- type: MessageType.Error
87
+ type: ke.Error
119
88
  });
120
89
  return;
121
90
  }
122
- this.navigateToDefineName(unitId, rangeid);
91
+ this.navigateToDefineName(o, r);
123
92
  }
124
- if (gid) {
125
- if (range) {
126
- const rangeInfo = deserializeRangeWithSheet(range);
127
- isValidRange(rangeInfo.range) && range !== ERROR_RANGE && this.navigateToRange(unitId, gid, rangeInfo.range);
93
+ if (e) {
94
+ if (n) {
95
+ const s = Ve(n);
96
+ _n(s.range) && n !== pr && this.navigateToRange(o, e, s.range);
128
97
  return;
129
98
  }
130
- this.navigateToSheetById(unitId, gid);
99
+ this.navigateToSheetById(o, e);
131
100
  }
132
101
  }
133
- buildHyperLink(unitId, sheetId, range) {
134
- return `#${SheetHyperLinkType.SHEET}=${sheetId}${range ? `&${typeof range == "string" ? SheetHyperLinkType.DEFINE_NAME : SheetHyperLinkType.RANGE}=${typeof range == "string" ? range : serializeRange(range)}` : ""}`;
135
- }
136
- parseHyperLink(urlStr) {
137
- var _a15, _b, _c, _d;
138
- if (urlStr.startsWith("#")) {
139
- const search = new URLSearchParams(urlStr.slice(1)), searchObj = {
140
- gid: (_a15 = search.get("gid")) != null ? _a15 : "",
141
- range: (_b = search.get("range")) != null ? _b : "",
142
- rangeid: (_c = search.get("rangeid")) != null ? _c : "",
143
- unitid: (_d = search.get("unitid")) != null ? _d : ""
144
- }, urlInfo = this._getURLName(searchObj);
145
- return {
146
- type: urlInfo.type,
147
- name: urlInfo.name,
148
- url: urlStr,
149
- searchObj,
150
- handler: /* @__PURE__ */ __name(() => {
151
- this.navigateTo(searchObj);
152
- }, "handler")
153
- };
154
- } else
155
- return {
156
- type: SheetHyperLinkType.URL,
157
- name: urlStr,
158
- url: urlStr,
159
- handler: /* @__PURE__ */ __name(() => {
160
- this.navigateToOtherWebsite(urlStr);
161
- }, "handler"),
162
- searchObj: null
163
- };
164
- }
165
- async navigateToRange(unitId, subUnitId, range) {
166
- const worksheet = await this.navigateToSheetById(unitId, subUnitId);
167
- if (worksheet) {
168
- const realRange = getContainRange(range, worksheet);
102
+ async navigateToRange(t, e, n, r) {
103
+ const i = await this.navigateToSheetById(t, e);
104
+ if (i) {
105
+ const o = Ii(n, i);
169
106
  await this._commandService.executeCommand(
170
- SetSelectionsOperation.id,
107
+ Pn.id,
171
108
  {
172
- unitId,
173
- subUnitId,
109
+ unitId: t,
110
+ subUnitId: e,
174
111
  selections: [{
175
- range: realRange
112
+ range: o
176
113
  }]
177
114
  }
178
- ), await this._commandService.executeCommand(ScrollToRangeOperation.id, {
179
- range: realRange
180
- });
181
- }
182
- }
183
- async navigateToSheet(unitId, sheetName) {
184
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
185
- if (!workbook)
186
- return !1;
187
- const worksheet = workbook.getActiveSheet();
188
- if ((worksheet == null ? void 0 : worksheet.getName()) === sheetName)
189
- return !0;
190
- const targetSheet = workbook.getSheetBySheetName(sheetName);
191
- if (!targetSheet) {
192
- this._messageService.show({
193
- content: this._localeService.t("hyperLink.message.noSheet"),
194
- type: MessageType.Error
115
+ ), await this._commandService.executeCommand(yn.id, {
116
+ range: o,
117
+ forceTop: r
195
118
  });
196
- return;
197
119
  }
198
- const sheetId = targetSheet.getSheetId();
199
- return workbook.getHiddenWorksheets().indexOf(sheetId) > -1 && this._messageService.show({
200
- content: this._localeService.t("hyperLink.message.hiddenSheet"),
201
- type: MessageType.Error
202
- }), await this._commandService.executeCommand(SetWorksheetActiveOperation.id, { unitId, subUnitId: sheetId });
203
120
  }
204
- async navigateToSheetById(unitId, subUnitId) {
205
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
206
- if (!workbook)
121
+ async navigateToSheetById(t, e) {
122
+ const n = this._univerInstanceService.getUnit(t, O.UNIVER_SHEET);
123
+ if (!n)
207
124
  return !1;
208
- const worksheet = workbook.getActiveSheet();
209
- if (!worksheet)
125
+ const r = n.getActiveSheet();
126
+ if (!r)
210
127
  return !1;
211
- if (worksheet.getSheetId() === subUnitId)
212
- return worksheet;
213
- const targetSheet = workbook.getSheetBySheetId(subUnitId);
214
- return targetSheet ? workbook.getHiddenWorksheets().indexOf(subUnitId) > -1 ? (this._messageService.show({
128
+ if (r.getSheetId() === e)
129
+ return r;
130
+ const i = n.getSheetBySheetId(e);
131
+ return i ? n.getHiddenWorksheets().indexOf(e) > -1 ? (this._messageService.show({
215
132
  content: this._localeService.t("hyperLink.message.hiddenSheet"),
216
- type: MessageType.Error
217
- }), !1) : await this._commandService.executeCommand(SetWorksheetActiveOperation.id, { unitId, subUnitId }) ? targetSheet : !1 : (this._messageService.show({
133
+ type: ke.Error
134
+ }), !1) : await this._commandService.executeCommand(Ln.id, { unitId: t, subUnitId: e }) ? i : !1 : (this._messageService.show({
218
135
  content: this._localeService.t("hyperLink.message.noSheet"),
219
- type: MessageType.Error
136
+ type: ke.Error
220
137
  }), !1);
221
138
  }
222
- async navigateToDefineName(unitId, rangeid) {
223
- return this._definedNamesService.focusRange(unitId, rangeid), !0;
224
- }
225
- async navigateToOtherWebsite(url) {
226
- var _a15;
227
- const config = this._configService.getConfig(PLUGIN_CONFIG_KEY);
228
- if ((_a15 = config == null ? void 0 : config.urlHandler) != null && _a15.navigateToOtherWebsite)
229
- return config.urlHandler.navigateToOtherWebsite(url);
230
- window.open(url, "_blank", "noopener noreferrer");
231
- }
232
- }, __name(_a, "SheetsHyperLinkResolverService"), _a);
233
- SheetsHyperLinkResolverService = __decorateClass$c([
234
- __decorateParam$c(0, IUniverInstanceService),
235
- __decorateParam$c(1, ICommandService),
236
- __decorateParam$c(2, IDefinedNamesService),
237
- __decorateParam$c(3, IMessageService),
238
- __decorateParam$c(4, Inject(LocaleService)),
239
- __decorateParam$c(5, IConfigService)
240
- ], SheetsHyperLinkResolverService);
241
- const SHEET_HYPER_LINK_UI_PLUGIN = "SHEET_HYPER_LINK_UI_PLUGIN";
242
- var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
243
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
244
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
245
- return kind && result && __defProp$b(target, key, result), result;
246
- }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a2;
247
- let SheetsHyperLinkCopyPasteController = (_a2 = class extends Disposable {
248
- constructor(_sheetClipboardService, _hyperLinkModel, _injector, _resolverService) {
139
+ async navigateToDefineName(t, e) {
140
+ return this._definedNamesService.focusRange(t, e), !0;
141
+ }
142
+ async navigateToOtherWebsite(t) {
143
+ var n;
144
+ const e = this._configService.getConfig(Nn);
145
+ if ((n = e == null ? void 0 : e.urlHandler) != null && n.navigateToOtherWebsite)
146
+ return e.urlHandler.navigateToOtherWebsite(t);
147
+ window.open(t, "_blank", "noopener noreferrer");
148
+ }
149
+ };
150
+ he = Ci([
151
+ Se(0, K),
152
+ Se(1, re),
153
+ Se(2, Rn),
154
+ Se(3, On),
155
+ Se(4, R(it)),
156
+ Se(5, Sn)
157
+ ], he);
158
+ const Mt = "SHEET_HYPER_LINK_UI_PLUGIN";
159
+ var yi = Object.defineProperty, Ei = Object.getOwnPropertyDescriptor, Ri = (t, e, n, r) => {
160
+ for (var i = r > 1 ? void 0 : r ? Ei(e, n) : e, o = t.length - 1, s; o >= 0; o--)
161
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
162
+ return r && i && yi(e, n, i), i;
163
+ }, je = (t, e) => (n, r) => e(n, r, t);
164
+ let We = class extends z {
165
+ constructor(e, n, r, i) {
249
166
  super();
250
- __publicField(this, "_plainTextFilter", /* @__PURE__ */ new Set());
251
- __publicField(this, "_copyInfo");
252
- this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste(), this.disposeWithMe(() => {
167
+ V(this, "_plainTextFilter", /* @__PURE__ */ new Set());
168
+ V(this, "_copyInfo");
169
+ this._sheetClipboardService = e, this._hyperLinkModel = n, this._injector = r, this._resolverService = i, this._initCopyPaste(), this.disposeWithMe(() => {
253
170
  this._plainTextFilter.clear();
254
171
  });
255
172
  }
256
- registerPlainTextFilter(filter2) {
257
- this._plainTextFilter.add(filter2);
173
+ registerPlainTextFilter(e) {
174
+ this._plainTextFilter.add(e);
258
175
  }
259
- removePlainTextFilter(filter2) {
260
- this._plainTextFilter.delete(filter2);
176
+ removePlainTextFilter(e) {
177
+ this._plainTextFilter.delete(e);
261
178
  }
262
179
  /* If return false the process of paste text will be stop */
263
- _filterPlainText(text) {
264
- return Array.from(this._plainTextFilter).every((filter2) => filter2(text));
180
+ _filterPlainText(e) {
181
+ return Array.from(this._plainTextFilter).every((n) => n(e));
265
182
  }
266
183
  _initCopyPaste() {
267
184
  this._sheetClipboardService.addClipboardHook({
268
- id: SHEET_HYPER_LINK_UI_PLUGIN,
269
- onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
270
- onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
271
- const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
272
- return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
273
- }, "onPasteCells"),
274
- onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => {
275
- const filterResult = this._filterPlainText(clipText);
276
- if (isLegalLink(clipText) && filterResult) {
277
- const { range, unitId, subUnitId } = pasteTo, { ranges: [pasteToRange], mapFunc } = virtualizeDiscreteRanges([range]), redos = [], undos = [];
278
- return Range.foreach(pasteToRange, (originRow, originCol) => {
279
- const { row, col: column } = mapFunc(originRow, originCol), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
280
- link && redos.push({
281
- id: RemoveHyperLinkMutation.id,
185
+ id: Mt,
186
+ onBeforeCopy: (e, n, r) => this._collect(e, n, r),
187
+ onPasteCells: (e, n, r, i) => {
188
+ const { copyType: o = Cr.COPY, pasteType: s } = i, { range: c } = e || {}, { range: u, unitId: d, subUnitId: l } = n;
189
+ return this._generateMutations(u, { copyType: o, pasteType: s, copyRange: c, unitId: d, subUnitId: l });
190
+ },
191
+ onPastePlainText: (e, n) => {
192
+ const r = this._filterPlainText(n);
193
+ if (Fe(n) && r) {
194
+ const { range: i, unitId: o, subUnitId: s } = e, { ranges: [c], mapFunc: u } = Et([i]), d = [], l = [];
195
+ return Cn.foreach(c, (g, p) => {
196
+ const { row: v, col: C } = u(g, p), _ = this._hyperLinkModel.getHyperLinkByLocation(o, s, v, C);
197
+ _ && d.push({
198
+ id: xe.id,
282
199
  params: {
283
- unitId,
284
- subUnitId,
285
- id: link.id
200
+ unitId: o,
201
+ subUnitId: s,
202
+ id: _.id
286
203
  }
287
- }), link && undos.push({
288
- id: AddHyperLinkMutation.id,
204
+ }), _ && l.push({
205
+ id: Ne.id,
289
206
  params: {
290
- unitId,
291
- subUnitId,
292
- link
207
+ unitId: o,
208
+ subUnitId: s,
209
+ link: _
293
210
  }
294
211
  });
295
- }), { redos, undos };
212
+ }), { redos: d, undos: l };
296
213
  }
297
214
  return { undos: [], redos: [] };
298
- }, "onPastePlainText"),
215
+ },
299
216
  priority: 99
300
217
  });
301
218
  }
302
- _collect(unitId, subUnitId, range) {
303
- const matrix = new ObjectMatrix();
219
+ _collect(e, n, r) {
220
+ const i = new nr();
304
221
  this._copyInfo = {
305
- unitId,
306
- subUnitId,
307
- matrix
222
+ unitId: e,
223
+ subUnitId: n,
224
+ matrix: i
308
225
  };
309
- const discreteRange = this._injector.invoke((accessor) => rangeToDiscreteRange(range, accessor, unitId, subUnitId));
310
- if (!discreteRange)
226
+ const o = this._injector.invoke((u) => Ir(r, u, e, n));
227
+ if (!o)
311
228
  return;
312
- const { rows, cols } = discreteRange;
313
- rows.forEach((row, rowIndex) => {
314
- cols.forEach((col, colIndex) => {
315
- var _a15;
316
- const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
317
- matrix.setValue(rowIndex, colIndex, (_a15 = link == null ? void 0 : link.id) != null ? _a15 : "");
229
+ const { rows: s, cols: c } = o;
230
+ s.forEach((u, d) => {
231
+ c.forEach((l, g) => {
232
+ var v;
233
+ const p = this._hyperLinkModel.getHyperLinkByLocation(e, n, u, l);
234
+ i.setValue(d, g, (v = p == null ? void 0 : p.id) != null ? v : "");
318
235
  });
319
236
  });
320
237
  }
321
238
  // eslint-disable-next-line max-lines-per-function
322
- _generateMutations(pastedRange, copyInfo) {
239
+ _generateMutations(e, n) {
323
240
  if (!this._copyInfo)
324
241
  return { redos: [], undos: [] };
325
- if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange)
242
+ if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !n.copyRange)
326
243
  return { redos: [], undos: [] };
327
244
  if ([
328
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
329
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
330
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
331
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
245
+ De.SPECIAL_PASTE_COL_WIDTH,
246
+ De.SPECIAL_PASTE_VALUE,
247
+ De.SPECIAL_PASTE_FORMAT,
248
+ De.SPECIAL_PASTE_FORMULA
332
249
  ].includes(
333
- copyInfo.pasteType
250
+ n.pasteType
334
251
  ))
335
252
  return { redos: [], undos: [] };
336
- const { unitId, subUnitId } = this._copyInfo, redos = [], undos = [], { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
337
- return getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
338
- var _a15;
339
- (_a15 = this._copyInfo) == null || _a15.matrix.forValue((row, col, ruleId) => {
340
- const range = Rectangle.getPositionRange(
253
+ const { unitId: r, subUnitId: i } = this._copyInfo, o = [], s = [], { ranges: [c, u], mapFunc: d } = Et([n.copyRange, e]);
254
+ return yr(c, u, !0).forEach(({ startRange: g }) => {
255
+ var p;
256
+ (p = this._copyInfo) == null || p.matrix.forValue((v, C, _) => {
257
+ const b = Ie.getPositionRange(
341
258
  {
342
- startRow: row,
343
- endRow: row,
344
- startColumn: col,
345
- endColumn: col
259
+ startRow: v,
260
+ endRow: v,
261
+ startColumn: C,
262
+ endColumn: C
346
263
  },
347
- startRange
348
- ), 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();
349
- currentLink && redos.push({
350
- id: RemoveHyperLinkMutation.id,
264
+ g
265
+ ), a = this._hyperLinkModel.getHyperLink(r, i, _), { row: w, col: M } = d(b.startRow, b.startColumn), P = this._hyperLinkModel.getHyperLinkByLocation(n.unitId, n.subUnitId, w, M), k = Ce.generateRandomId();
266
+ P && o.push({
267
+ id: xe.id,
351
268
  params: {
352
- unitId: copyInfo.unitId,
353
- subUnitId: copyInfo.subUnitId,
354
- id: currentLink.id
269
+ unitId: n.unitId,
270
+ subUnitId: n.subUnitId,
271
+ id: P.id
355
272
  }
356
- }), oldLink && (redos.push({
357
- id: AddHyperLinkMutation.id,
273
+ }), a && (o.push({
274
+ id: Ne.id,
358
275
  params: {
359
- unitId: copyInfo.unitId,
360
- subUnitId: copyInfo.subUnitId,
276
+ unitId: n.unitId,
277
+ subUnitId: n.subUnitId,
361
278
  link: {
362
- ...oldLink,
363
- id,
364
- row: startRow,
365
- column: startColumn
279
+ ...a,
280
+ id: k,
281
+ row: w,
282
+ column: M
366
283
  }
367
284
  }
368
- }), undos.push({
369
- id: RemoveHyperLinkMutation.id,
285
+ }), s.push({
286
+ id: xe.id,
370
287
  params: {
371
- unitId: copyInfo.unitId,
372
- subUnitId: copyInfo.subUnitId,
373
- id
288
+ unitId: n.unitId,
289
+ subUnitId: n.subUnitId,
290
+ id: k
374
291
  }
375
- })), currentLink && undos.push({
376
- id: AddHyperLinkMutation.id,
292
+ })), P && s.push({
293
+ id: Ne.id,
377
294
  params: {
378
- unitId: copyInfo.unitId,
379
- subUnitId: copyInfo.subUnitId,
380
- link: currentLink
295
+ unitId: n.unitId,
296
+ subUnitId: n.subUnitId,
297
+ link: P
381
298
  }
382
299
  });
383
300
  });
384
- }), { redos, undos };
385
- }
386
- }, __name(_a2, "SheetsHyperLinkCopyPasteController"), _a2);
387
- SheetsHyperLinkCopyPasteController = __decorateClass$b([
388
- __decorateParam$b(0, ISheetClipboardService),
389
- __decorateParam$b(1, Inject(HyperLinkModel)),
390
- __decorateParam$b(2, Inject(Injector)),
391
- __decorateParam$b(3, Inject(SheetsHyperLinkResolverService))
392
- ], SheetsHyperLinkCopyPasteController);
393
- var HyperLinkEditSourceType = /* @__PURE__ */ ((HyperLinkEditSourceType2) => (HyperLinkEditSourceType2.EDITING = "editing", HyperLinkEditSourceType2.VIEWING = "viewing", HyperLinkEditSourceType2.ZEN_EDITOR = "zen_mode", HyperLinkEditSourceType2))(HyperLinkEditSourceType || {}), jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
301
+ }), { redos: o, undos: s };
302
+ }
303
+ };
304
+ We = Ri([
305
+ je(0, Er),
306
+ je(1, R(at)),
307
+ je(2, R(st)),
308
+ je(3, R(he))
309
+ ], We);
310
+ var f = /* @__PURE__ */ ((t) => (t.EDITING = "editing", t.VIEWING = "viewing", t.ZEN_EDITOR = "zen_mode", t))(f || {}), Mn = { exports: {} }, dt = {};
394
311
  /**
395
312
  * @license React
396
313
  * react-jsx-runtime.production.min.js
@@ -400,381 +317,144 @@ var HyperLinkEditSourceType = /* @__PURE__ */ ((HyperLinkEditSourceType2) => (Hy
400
317
  * This source code is licensed under the MIT license found in the
401
318
  * LICENSE file in the root directory of this source tree.
402
319
  */
403
- var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
404
- function q(c, a, g) {
405
- var b, d = {}, e = null, h = null;
406
- g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
407
- for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
408
- if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
409
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
320
+ var Pi = di, Li = Symbol.for("react.element"), bi = Symbol.for("react.fragment"), wi = Object.prototype.hasOwnProperty, Oi = Pi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, ki = { key: !0, ref: !0, __self: !0, __source: !0 };
321
+ function Un(t, e, n) {
322
+ var r, i = {}, o = null, s = null;
323
+ n !== void 0 && (o = "" + n), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
324
+ for (r in e) wi.call(e, r) && !ki.hasOwnProperty(r) && (i[r] = e[r]);
325
+ if (t && t.defaultProps) for (r in e = t.defaultProps, e) i[r] === void 0 && (i[r] = e[r]);
326
+ return { $$typeof: Li, type: t, key: o, ref: s, props: i, _owner: Oi.current };
410
327
  }
411
- __name(q, "q");
412
- reactJsxRuntime_production_min.Fragment = l;
413
- reactJsxRuntime_production_min.jsx = q;
414
- reactJsxRuntime_production_min.jsxs = q;
415
- jsxRuntime.exports = reactJsxRuntime_production_min;
416
- var jsxRuntimeExports = jsxRuntime.exports;
417
- const AddHyperLinkCommand = {
418
- type: CommandType.COMMAND,
419
- id: "sheets.command.add-hyper-link",
420
- // eslint-disable-next-line max-lines-per-function
421
- async handler(accessor, params) {
422
- var _a15;
423
- if (!params)
424
- return !1;
425
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), renderManagerService = accessor.get(IRenderManagerService), univerInstanceService = accessor.get(IUniverInstanceService), hyperLinkModel = accessor.get(HyperLinkModel), editorBridgeService = accessor.get(IEditorBridgeService), { unitId, subUnitId, link } = params, workbook = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), currentRender = renderManagerService.getRenderById(unitId);
426
- if (!currentRender || !workbook)
427
- return !1;
428
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId), skeleton = (_a15 = currentRender.with(SheetSkeletonManagerService).getCurrent()) == null ? void 0 : _a15.skeleton;
429
- if (!worksheet || !skeleton)
430
- return !1;
431
- const { payload, display, row, column, id } = link, cellData = worksheet.getCell(row, column), doc = skeleton.getBlankCellDocumentModel(cellData), snapshot = doc.documentModel.getSnapshot(), body = Tools.deepClone(snapshot.body);
432
- if (!body)
433
- return !1;
434
- let textX;
435
- if (display ? textX = BuildTextUtils.selection.replace({
436
- selection: {
437
- startOffset: 0,
438
- endOffset: body.dataStream.length - 2,
439
- collapsed: !0
440
- },
441
- body: {
442
- dataStream: `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`,
443
- customRanges: [{
444
- startIndex: 0,
445
- endIndex: display.length + 1,
446
- rangeType: CustomRangeType.HYPERLINK,
447
- rangeId: id,
448
- properties: {
449
- url: payload
450
- // refId: id,
451
- }
452
- }]
453
- },
454
- doc: doc.documentModel
455
- }) : textX = BuildTextUtils.customRange.add({
456
- body,
457
- range: { startOffset: 0, endOffset: body.dataStream.length - 2, collapsed: !1 },
458
- rangeId: id,
459
- rangeType: CustomRangeType.HYPERLINK,
460
- properties: {
461
- url: payload,
462
- refId: id
463
- }
464
- }), !textX)
465
- return !1;
466
- const newBody = TextX.apply(body, textX.serialize()), newCellData = {
467
- p: {
468
- ...snapshot,
469
- body: newBody
470
- },
471
- t: CellValueType.STRING
472
- }, finalCellData = await editorBridgeService.beforeSetRangeValue(workbook, worksheet, row, column, newCellData), redoParams = {
473
- unitId,
474
- subUnitId,
475
- cellValue: {
476
- [link.row]: {
477
- [link.column]: finalCellData
478
- }
479
- }
480
- }, redo = {
481
- id: SetRangeValuesMutation.id,
482
- params: redoParams
483
- }, undoParams = SetRangeValuesUndoMutationFactory(accessor, redoParams), undo = {
484
- id: SetRangeValuesMutation.id,
485
- params: undoParams
486
- }, redos = [redo], undos = [undo], modelLink = hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
487
- return modelLink && (redos.push({
488
- id: RemoveHyperLinkMutation.id,
489
- params: {
490
- unitId,
491
- subUnitId,
492
- id: modelLink.id
493
- }
494
- }), undos.push({
495
- id: AddHyperLinkMutation.id,
496
- params: {
497
- unitId,
498
- subUnitId,
499
- link: modelLink
500
- }
501
- })), await sequenceExecuteAsync(redos, commandService) ? (undoRedoService.pushUndoRedo({
502
- redoMutations: redos,
503
- undoMutations: undos,
504
- unitID: unitId
505
- }), !0) : !1;
506
- }
507
- }, AddRichHyperLinkCommand = {
508
- id: "sheets.command.add-rich-hyper-link",
509
- type: CommandType.COMMAND,
510
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
511
- if (!params)
512
- return !1;
513
- const { documentId, link } = params, commandService = accessor.get(ICommandService), newId = generateRandomId(), { payload } = link, replaceSelection = addCustomRangeBySelectionFactory(accessor, {
514
- unitId: documentId,
515
- rangeId: newId,
516
- rangeType: CustomRangeType.HYPERLINK,
517
- properties: {
518
- url: payload,
519
- refId: newId
520
- }
521
- });
522
- return replaceSelection ? commandService.syncExecuteCommand(replaceSelection.id, replaceSelection.params) : !1;
523
- }, "handler")
524
- }, UpdateHyperLinkCommand = {
525
- type: CommandType.COMMAND,
526
- id: "sheets.command.update-hyper-link",
527
- // eslint-disable-next-line max-lines-per-function, complexity
528
- async handler(accessor, params) {
529
- var _a15, _b, _c, _d;
530
- if (!params)
531
- return !1;
532
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), renderManagerService = accessor.get(IRenderManagerService), univerInstanceService = accessor.get(IUniverInstanceService), hyperLinkModel = accessor.get(HyperLinkModel), editorBridgeService = accessor.get(IEditorBridgeService), { unitId, subUnitId, payload: link, row, column, id } = params, workbook = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), currentRender = renderManagerService.getRenderById(unitId);
533
- if (!currentRender || !workbook)
534
- return !1;
535
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId), skeleton = (_a15 = currentRender.with(SheetSkeletonManagerService).getCurrent()) == null ? void 0 : _a15.skeleton;
536
- if (!worksheet || !skeleton)
537
- return !1;
538
- const { payload, display = "" } = link, cellData = worksheet.getCell(row, column);
539
- if (!cellData)
540
- return !1;
541
- const doc = skeleton.getCellDocumentModelWithFormula(cellData);
542
- if (!(doc != null && doc.documentModel))
543
- return !1;
544
- const snapshot = doc.documentModel.getSnapshot(), range = (_c = (_b = snapshot.body) == null ? void 0 : _b.customRanges) == null ? void 0 : _c.find((range2) => range2.rangeId === id);
545
- if (!range)
546
- return !1;
547
- const newId = generateRandomId(), textRun = (_d = getBodySlice(doc.documentModel.getBody(), range.startIndex, range.endIndex + 1).textRuns) == null ? void 0 : _d[0];
548
- textRun && (textRun.ed = display.length + 1);
549
- const replaceSelection = replaceSelectionFactory(accessor, {
550
- unitId,
551
- body: {
552
- dataStream: `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`,
553
- customRanges: [{
554
- rangeId: newId,
555
- rangeType: CustomRangeType.HYPERLINK,
556
- startIndex: 0,
557
- endIndex: display.length + 1,
558
- properties: {
559
- url: payload
560
- }
561
- }],
562
- textRuns: textRun ? [textRun] : void 0
563
- },
564
- selection: {
565
- startOffset: range.startIndex,
566
- endOffset: range.endIndex + 1,
567
- collapsed: !1
568
- },
569
- doc: doc.documentModel
570
- });
571
- if (!replaceSelection)
572
- return !1;
573
- const newBody = TextX.apply(Tools.deepClone(snapshot.body), replaceSelection.textX.serialize()), newCellData = {
574
- p: {
575
- ...snapshot,
576
- body: newBody
577
- },
578
- t: CellValueType.STRING
579
- }, finalCellData = await editorBridgeService.beforeSetRangeValue(workbook, worksheet, row, column, newCellData), redo = {
580
- id: SetRangeValuesMutation.id,
581
- params: {
582
- unitId,
583
- subUnitId,
584
- cellValue: {
585
- [row]: {
586
- [column]: finalCellData
587
- }
588
- }
589
- }
590
- }, undoParams = SetRangeValuesUndoMutationFactory(accessor, redo.params), undo = {
591
- id: SetRangeValuesMutation.id,
592
- params: undoParams
593
- }, redos = [redo], undos = [undo], modelLink = hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
594
- return modelLink && (redos.push({
595
- id: RemoveHyperLinkMutation.id,
596
- params: {
597
- unitId,
598
- subUnitId,
599
- id: modelLink.id
600
- }
601
- }), undos.push({
602
- id: AddHyperLinkMutation.id,
603
- params: {
604
- unitId,
605
- subUnitId,
606
- link: modelLink
607
- }
608
- })), await sequenceExecuteAsync(redos, commandService) ? (undoRedoService.pushUndoRedo({
609
- redoMutations: redos,
610
- undoMutations: undos,
611
- unitID: unitId
612
- }), !0) : !1;
613
- }
614
- }, UpdateRichHyperLinkCommand = {
615
- type: CommandType.COMMAND,
616
- id: "sheets.command.update-rich-hyper-link",
617
- handler: /* @__PURE__ */ __name((accessor, params) => {
618
- var _a15, _b, _c, _d;
619
- if (!params)
620
- return !1;
621
- const { documentId: unitId, payload, id: rangeId } = params, univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), doc = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
622
- if (!doc)
623
- return !1;
624
- const range = (_b = (_a15 = doc.getBody()) == null ? void 0 : _a15.customRanges) == null ? void 0 : _b.find((range2) => range2.rangeId === rangeId);
625
- if (!range)
626
- return !1;
627
- const display = (_c = params.payload.display) != null ? _c : "", newId = generateRandomId(), textRun = (_d = getBodySlice(doc.getBody(), range.startIndex, range.endIndex + 1).textRuns) == null ? void 0 : _d[0];
628
- textRun && (textRun.ed = display.length + 1);
629
- const replaceSelection = replaceSelectionFactory(accessor, {
630
- unitId,
631
- body: {
632
- dataStream: `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`,
633
- customRanges: [{
634
- rangeId: newId,
635
- rangeType: CustomRangeType.HYPERLINK,
636
- startIndex: 0,
637
- endIndex: display.length + 1,
638
- properties: {
639
- url: payload.payload
640
- }
641
- }],
642
- textRuns: textRun ? [textRun] : void 0
643
- },
644
- selection: {
645
- startOffset: range.startIndex,
646
- endOffset: range.endIndex + 1,
647
- collapsed: !1
648
- },
649
- doc
650
- });
651
- return replaceSelection ? commandService.syncExecuteCommand(replaceSelection.id, replaceSelection.params) : !1;
652
- }, "handler")
653
- }, _SheetsHyperLinkSidePanelService = class _SheetsHyperLinkSidePanelService extends Disposable {
328
+ dt.Fragment = bi;
329
+ dt.jsx = Un;
330
+ dt.jsxs = Un;
331
+ Mn.exports = dt;
332
+ var m = Mn.exports;
333
+ class Hn extends z {
654
334
  constructor() {
655
335
  super(...arguments);
656
- __publicField(this, "_customHyperLinks", /* @__PURE__ */ new Map());
336
+ V(this, "_customHyperLinks", /* @__PURE__ */ new Map());
657
337
  }
658
- isBuiltInLinkType(type) {
659
- return type !== SheetHyperLinkType.URL;
338
+ isBuiltInLinkType(n) {
339
+ return n !== S.URL;
660
340
  }
661
341
  getOptions() {
662
- return Array.from(this._customHyperLinks.values()).map(({ option }) => option);
342
+ return Array.from(this._customHyperLinks.values()).map(({ option: n }) => n);
663
343
  }
664
- findCustomHyperLink(link) {
665
- return Array.from(this._customHyperLinks.values()).find((item) => item.match(link));
344
+ findCustomHyperLink(n) {
345
+ return Array.from(this._customHyperLinks.values()).find((i) => i.match(n));
666
346
  }
667
- registerCustomHyperLink(customHyperLink) {
668
- this._customHyperLinks.set(customHyperLink.type, customHyperLink);
347
+ registerCustomHyperLink(n) {
348
+ this._customHyperLinks.set(n.type, n);
669
349
  }
670
- getCustomHyperLink(type) {
671
- return this._customHyperLinks.get(type);
350
+ getCustomHyperLink(n) {
351
+ return this._customHyperLinks.get(n);
672
352
  }
673
- removeCustomHyperLink(type) {
674
- const { _customHyperLinks } = this;
675
- _customHyperLinks.delete(type);
353
+ removeCustomHyperLink(n) {
354
+ const { _customHyperLinks: r } = this;
355
+ r.delete(n);
676
356
  }
677
357
  dispose() {
678
358
  super.dispose(), this._customHyperLinks.clear();
679
359
  }
680
- };
681
- __name(_SheetsHyperLinkSidePanelService, "SheetsHyperLinkSidePanelService");
682
- let SheetsHyperLinkSidePanelService = _SheetsHyperLinkSidePanelService;
683
- const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
684
- cellLinkEdit,
685
- cellLinkEditButtons
686
- }, CellLinkEdit = /* @__PURE__ */ __name(() => {
687
- var _a15;
688
- 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$), 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(() => {
689
- if (!sidePanelService.isBuiltInLinkType(type))
690
- return sidePanelService.getCustomHyperLink(type);
691
- }, [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()) || "";
692
- useEffect(() => {
693
- isFocusRangeSelectorSet(!1);
694
- }, [subUnitId]), useEffect(() => {
695
- var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
696
- if ((editing == null ? void 0 : editing.row) !== void 0 && editing.col !== void 0) {
697
- const { label, customRange, row, col } = editing;
698
- let link;
699
- if (customRange)
700
- link = {
701
- id: (_a16 = customRange == null ? void 0 : customRange.rangeId) != null ? _a16 : "",
702
- display: label != null ? label : "",
703
- payload: (_c = (_b = customRange == null ? void 0 : customRange.properties) == null ? void 0 : _b.url) != null ? _c : "",
704
- row,
705
- column: col
360
+ }
361
+ const Ti = "univer-cell-link-edit", xi = "univer-cell-link-edit-buttons", dn = {
362
+ cellLinkEdit: Ti,
363
+ cellLinkEditButtons: xi
364
+ }, Ze = () => {
365
+ var Bt;
366
+ const [t, e] = X(""), [n, r] = X(!1), [i, o] = X(""), [s, c] = X(!0), [u, d] = X(S.URL), [l, g] = X(""), p = E(it), v = E(Rn), C = E(ne), _ = E(K), b = E(G), a = Kr(b.currentEditing$), w = E(wt), M = E(he), P = E(re), k = E(Hn), q = un(() => k.getOptions(), [k]), D = E(ct), ie = E(ut), ye = E(Rr), He = E(Ue), se = E(In), Ee = E(rr), Re = E(Ue), Pe = Pt({}), oe = un(() => {
367
+ if (!k.isBuiltInLinkType(u))
368
+ return k.getCustomHyperLink(u);
369
+ }, [k, u]), [j, zn] = X(!1), [Le, pt] = X(!1), H = Pt(!1), B = _.getCurrentUnitForType(O.UNIVER_SHEET), Yn = (B == null ? void 0 : B.getActiveSheet().getSheetId()) || "", J = pi((h) => {
370
+ o(h.replaceAll(rn.CUSTOM_RANGE_START, "").replaceAll(rn.CUSTOM_RANGE_END, ""));
371
+ }, [o]);
372
+ te(() => {
373
+ var h, y, I, L, N, A, At, Ft, Wt, Zt, Gt, Kt, zt, Yt, Xt, qt, Jt;
374
+ if ((a == null ? void 0 : a.row) !== void 0 && a.col !== void 0) {
375
+ const { customRange: ae, row: ft, col: vt } = a;
376
+ let { label: Y } = a;
377
+ typeof Y == "number" && (Y = `${Y}`);
378
+ let F;
379
+ if (ae)
380
+ F = {
381
+ id: (h = ae == null ? void 0 : ae.rangeId) != null ? h : "",
382
+ display: Y != null ? Y : "",
383
+ payload: (I = (y = ae == null ? void 0 : ae.properties) == null ? void 0 : y.url) != null ? I : "",
384
+ row: ft,
385
+ column: vt
706
386
  };
707
- else if (editing.type === HyperLinkEditSourceType.VIEWING) {
708
- 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) => {
709
- var _a17;
710
- return range2.rangeType === CustomRangeType.HYPERLINK && ((_a17 = range2.properties) == null ? void 0 : _a17.url);
711
- }), cellValue = cell == null ? void 0 : cell.v;
712
- cell && (!BuildTextUtils.transform.isEmptyDocument((_h = (_g = cell.p) == null ? void 0 : _g.body) == null ? void 0 : _h.dataStream) || cellValue) && setShowLabel(!1), link = {
387
+ else if (a.type === f.VIEWING) {
388
+ const T = _.getUnit(a.unitId), ee = T == null ? void 0 : T.getSheetBySheetId(a.subUnitId), U = ee == null ? void 0 : ee.getCellRaw(a.row, a.col), ve = (A = (N = (L = U == null ? void 0 : U.p) == null ? void 0 : L.body) == null ? void 0 : N.customRanges) == null ? void 0 : A.find((en) => {
389
+ var tn;
390
+ return en.rangeType === Me.HYPERLINK && ((tn = en.properties) == null ? void 0 : tn.url);
391
+ }), be = U == null ? void 0 : U.v;
392
+ U && (!de.transform.isEmptyDocument((Ft = (At = U.p) == null ? void 0 : At.body) == null ? void 0 : Ft.dataStream) || Ce.isDefine(be)) && c(!1), F = {
713
393
  id: "",
714
394
  display: "",
715
- payload: (_j = (_i = range == null ? void 0 : range.properties) == null ? void 0 : _i.url) != null ? _j : "",
716
- row,
717
- column: col
395
+ payload: (Zt = (Wt = ve == null ? void 0 : ve.properties) == null ? void 0 : Wt.url) != null ? Zt : "",
396
+ row: ft,
397
+ column: vt
718
398
  };
719
399
  } else {
720
- const doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), currentSelection = textSelectionService.getActiveTextRange(), body = doc == null ? void 0 : doc.getBody(), selection = currentSelection && body ? BuildTextUtils.selection.getInsertSelection(currentSelection, body) : null, customRange2 = selection && ((_l = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_k = body == null ? void 0 : body.customRanges) != null ? _k : [])) == null ? void 0 : _l[0]);
721
- setShowLabel(!1), link = {
400
+ const T = _.getCurrentUnitForType(O.UNIVER_DOC), ee = He.getActiveTextRange(), U = T == null ? void 0 : T.getBody(), ve = ee && U ? ee : null, be = ve && ((Kt = de.customRange.getCustomRangesInterestsWithSelection(ve, (Gt = U == null ? void 0 : U.customRanges) != null ? Gt : [])) == null ? void 0 : Kt[0]);
401
+ c(!1), F = {
722
402
  id: "",
723
- display: label != null ? label : "",
724
- payload: (_n = (_m = customRange2 == null ? void 0 : customRange2.properties) == null ? void 0 : _m.url) != null ? _n : "",
725
- row,
726
- column: col
403
+ display: Y != null ? Y : "",
404
+ payload: (Yt = (zt = be == null ? void 0 : be.properties) == null ? void 0 : zt.url) != null ? Yt : "",
405
+ row: ft,
406
+ column: vt
727
407
  };
728
408
  }
729
- setId(link.id);
730
- const customLink = sidePanelService.findCustomHyperLink(link);
731
- if (customLink) {
732
- const customLinkInfo = customLink.convert(link);
733
- setType(customLinkInfo.type), setPayload(customLinkInfo.payload), setDisplay(customLinkInfo.display);
409
+ e(F.id);
410
+ const Qt = k.findCustomHyperLink(F);
411
+ if (Qt) {
412
+ const T = Qt.convert(F);
413
+ d(T.type), g(T.payload), J(T.display);
734
414
  return;
735
415
  }
736
- setDisplay(link.display);
737
- const linkInfo = resolverService.parseHyperLink(link.payload);
738
- switch (setType(linkInfo.type === SheetHyperLinkType.INVALID ? SheetHyperLinkType.RANGE : linkInfo.type), linkInfo.type) {
739
- case SheetHyperLinkType.URL: {
740
- setPayload(linkInfo.url), linkInfo.url === link.display && (setByPayload.current = !0);
416
+ J(F.display);
417
+ const Q = w.parseHyperLink(F.payload);
418
+ switch (d(Q.type === S.INVALID ? S.RANGE : Q.type), Q.type) {
419
+ case S.URL: {
420
+ g(Q.url), Q.url === F.display && (H.current = !0);
741
421
  break;
742
422
  }
743
- case SheetHyperLinkType.RANGE: {
744
- 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);
745
- setPayload(payload2), payload2 === link.display && (setByPayload.current = !0);
423
+ case S.RANGE: {
424
+ const T = Q.searchObj, ee = T.gid && (Jt = (qt = (Xt = _.getUnit(a.unitId)) == null ? void 0 : Xt.getSheetBySheetId(T.gid)) == null ? void 0 : qt.getName()) != null ? Jt : "", U = Mr(ee, Ve(T.range).range);
425
+ g(U), U === F.display && (H.current = !0);
746
426
  break;
747
427
  }
748
- case SheetHyperLinkType.SHEET: {
749
- const params = linkInfo.searchObj;
750
- setPayload(params.gid);
428
+ case S.SHEET: {
429
+ const T = Q.searchObj;
430
+ g(T.gid);
751
431
  break;
752
432
  }
753
- case SheetHyperLinkType.DEFINE_NAME: {
754
- const params = linkInfo.searchObj;
755
- setPayload(params.rangeid);
433
+ case S.DEFINE_NAME: {
434
+ const T = Q.searchObj;
435
+ g(T.rangeid);
756
436
  break;
757
437
  }
758
438
  default:
759
- setPayload("");
439
+ g("");
760
440
  break;
761
441
  }
762
442
  }
763
- }, [editing, resolverService, sidePanelService, textSelectionService, univerInstanceService]), useEffect(() => {
764
- let id2 = null;
765
- if (editing && !editing.customRangeId && editing.type === HyperLinkEditSourceType.VIEWING && Tools.isDefine(editing.row) && Tools.isDefine(editing.col)) {
766
- 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();
767
- id2 = markSelectionService.addShape(
443
+ }, [a, M, k, He, _]), te(() => {
444
+ let h = null;
445
+ if (a && !a.customRangeId && a.type === f.VIEWING && Ce.isDefine(a.row) && Ce.isDefine(a.col)) {
446
+ const y = _.getUnit(a.unitId, O.UNIVER_SHEET), I = y == null ? void 0 : y.getSheetBySheetId(a.subUnitId), L = I == null ? void 0 : I.getMergedCell(a.row, a.col), N = new ir(Ee.getCurrentTheme().hyacinth500).toRgb();
447
+ h = ye.addShape(
768
448
  {
769
- range: mergeInfo != null ? mergeInfo : {
770
- startColumn: editing.col,
771
- endColumn: editing.col,
772
- startRow: editing.row,
773
- endRow: editing.row
449
+ range: L != null ? L : {
450
+ startColumn: a.col,
451
+ endColumn: a.col,
452
+ startRow: a.row,
453
+ endRow: a.row
774
454
  },
775
455
  style: {
776
456
  hasAutoFill: !1,
777
- fill: `rgb(${color.r}, ${color.g}, ${color.b}, 0.12)`,
457
+ fill: `rgb(${N.r}, ${N.g}, ${N.b}, 0.12)`,
778
458
  strokeWidth: 1,
779
459
  stroke: "#FFBD37",
780
460
  widgets: {}
@@ -786,602 +466,517 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
786
466
  );
787
467
  }
788
468
  return () => {
789
- id2 && markSelectionService.removeShape(id2);
469
+ h && ye.removeShape(h);
790
470
  };
791
- }, [editing, markSelectionService, themeService, univerInstanceService]), useEffect(() => {
792
- type === SheetHyperLinkType.RANGE && !showLabel && !isFocusRangeSelector && isFocusRangeSelectorSet(!0);
793
- }, [type, isFocusRangeSelector, showLabel, editorBridgeService]), useEffect(() => {
794
- 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();
795
- if (render2) {
796
- const selectionRenderService = render2.with(DocSelectionRenderService);
797
- selectionRenderService.setReserveRangesStatus(!0), disposeCollection.add(() => {
798
- selectionRenderService.setReserveRangesStatus(!1);
471
+ }, [a, ye, Ee, _]), te(() => {
472
+ pt(u === S.RANGE);
473
+ }, [u]), te(() => {
474
+ const h = (a == null ? void 0 : a.type) === f.ZEN_EDITOR ? ie.getRenderById(x) : ie.getRenderById(C.getCurrentEditorId()), y = new sr();
475
+ if (h) {
476
+ const I = h.with(xn);
477
+ I.setReserveRangesStatus(!0), y.add(() => {
478
+ I.setReserveRangesStatus(!1);
799
479
  });
800
480
  }
801
481
  return () => {
802
- editorBridgeService.disableForceKeepVisible(), disposeCollection.dispose();
482
+ C.disableForceKeepVisible(), y.dispose();
803
483
  };
804
- }, [editing == null ? void 0 : editing.type, editorBridgeService, renderManagerService]), useEffect(() => (popupService.setIsKeepVisible(isFocusRangeSelector), () => {
805
- popupService.setIsKeepVisible(!1);
806
- }), [isFocusRangeSelector, popupService]), useEffect(() => () => {
807
- zenZoneService.temporaryHidden && (zenZoneService.show(), contextService.setContextValue(FOCUSING_SHEET, !1));
808
- }, [contextService, zenZoneService]);
809
- const linkTypeOptions = [
484
+ }, [a == null ? void 0 : a.type, C, ie]), te(() => (b.setIsKeepVisible(Le), () => {
485
+ b.setIsKeepVisible(!1);
486
+ }), [Le, b]), te(() => () => {
487
+ D.temporaryHidden && (D.show(), se.setContextValue(_t, !1));
488
+ }, [se, D]), te(() => {
489
+ if (Le)
490
+ return C.enableForceKeepVisible(), () => {
491
+ C.disableForceKeepVisible();
492
+ };
493
+ }, [Le, C]);
494
+ const Xn = [
810
495
  {
811
- label: localeService.t("hyperLink.form.link"),
812
- value: SheetHyperLinkType.URL
496
+ label: p.t("hyperLink.form.link"),
497
+ value: S.URL
813
498
  },
814
499
  {
815
- label: localeService.t("hyperLink.form.range"),
816
- value: SheetHyperLinkType.RANGE
500
+ label: p.t("hyperLink.form.range"),
501
+ value: S.RANGE
817
502
  },
818
503
  {
819
- label: localeService.t("hyperLink.form.worksheet"),
820
- value: SheetHyperLinkType.SHEET
504
+ label: p.t("hyperLink.form.worksheet"),
505
+ value: S.SHEET
821
506
  },
822
507
  {
823
- label: localeService.t("hyperLink.form.definedName"),
824
- value: SheetHyperLinkType.DEFINE_NAME
508
+ label: p.t("hyperLink.form.definedName"),
509
+ value: S.DEFINE_NAME
825
510
  },
826
- ...sidePanelOptions
511
+ ...q
827
512
  ];
828
- if (!workbook)
513
+ if (!B)
829
514
  return;
830
- 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((_a15 = definedNameService.getDefinedNameMap(workbook.getUnitId())) != null ? _a15 : {}).map((value) => ({
831
- label: value.name,
832
- value: value.id
833
- })), formatUrl = /* @__PURE__ */ __name((type2, payload2) => {
834
- if (type2 === SheetHyperLinkType.URL)
835
- return serializeUrl(payload2);
836
- if (type2 === SheetHyperLinkType.RANGE) {
837
- const info = deserializeRangeWithSheet(payload2), worksheet = workbook.getSheetBySheetName(info.sheetName);
838
- if (worksheet)
839
- return `#gid=${worksheet.getSheetId()}&range=${serializeRange(info.range)}`;
515
+ const qn = B.getHiddenWorksheets(), ht = B.getSheets().map((h) => ({ label: h.getName(), value: h.getSheetId() })).filter((h) => qn.indexOf(h.value) === -1), gt = Object.values((Bt = v.getDefinedNameMap(B.getUnitId())) != null ? Bt : {}).map((h) => ({
516
+ label: h.name,
517
+ value: h.id
518
+ })), Vt = (h, y) => {
519
+ if (h === S.URL)
520
+ return fi(y);
521
+ if (h === S.RANGE) {
522
+ const I = Ve(y), L = B.getSheetBySheetName(I.sheetName);
523
+ if (L)
524
+ return `#gid=${L.getSheetId()}&range=${Hr(I.range)}`;
840
525
  }
841
- return `#${type2}=${payload2}`;
842
- }, "formatUrl"), handleRangeChange = useEvent((rangeText) => {
843
- var _a16;
844
- const range = rangeText.split(",").map(deserializeRangeWithSheet)[0];
845
- if (!range || !isValidRange(range.range))
526
+ return `#${h}=${y}`;
527
+ }, Jn = zr((h) => {
528
+ var N;
529
+ const I = h.split(",").map(Ve)[0];
530
+ if (!I || !_n(I.range))
846
531
  return;
847
- range.sheetName || (range.sheetName = ((_a16 = workbook.getActiveSheet()) == null ? void 0 : _a16.getName()) || "");
848
- const newPayload = serializeRangeToRefString(range);
849
- setPayload(newPayload), newPayload && (setByPayload.current || !display) && (setDisplay(newPayload), setByPayload.current = !0);
850
- }), handleSubmit = /* @__PURE__ */ __name(async () => {
851
- if (showLabel && !display || !payload || type === SheetHyperLinkType.URL && !isLegalLink(payload)) {
852
- setShowError(!0);
532
+ I.sheetName || (I.sheetName = ((N = B.getActiveSheet()) == null ? void 0 : N.getName()) || "");
533
+ const L = Ur(I);
534
+ g(L), L && (H.current || !i) && (J(L), H.current = !0);
535
+ }), mt = async () => {
536
+ if (s && !i || !l || u === S.URL && !Fe(l)) {
537
+ zn(!0);
853
538
  return;
854
539
  }
855
- if (editing)
856
- if (id) {
857
- const commandId = editing.type === HyperLinkEditSourceType.ZEN_EDITOR || editing.type === HyperLinkEditSourceType.EDITING ? UpdateRichHyperLinkCommand.id : UpdateHyperLinkCommand.id;
858
- await commandService.executeCommand(commandId, {
859
- id,
860
- unitId: editing.unitId,
861
- subUnitId: editing.subUnitId,
540
+ if (a)
541
+ if (t) {
542
+ const h = a.type === f.ZEN_EDITOR || a.type === f.EDITING ? hr.id : gr.id;
543
+ await P.executeCommand(h, {
544
+ id: t,
545
+ unitId: a.unitId,
546
+ subUnitId: a.subUnitId,
862
547
  payload: {
863
- display: showLabel ? display : "",
864
- payload: formatUrl(type, payload)
548
+ display: s ? i : "",
549
+ payload: Vt(u, l)
865
550
  },
866
- row: editing.row,
867
- column: editing.col,
868
- documentId: editing.type === HyperLinkEditSourceType.ZEN_EDITOR ? DOCS_ZEN_EDITOR_UNIT_ID_KEY : editorBridgeService.getCurrentEditorId()
551
+ row: a.row,
552
+ column: a.col,
553
+ documentId: a.type === f.ZEN_EDITOR ? x : C.getCurrentEditorId()
869
554
  });
870
555
  } else {
871
- const commandId = editing.type === HyperLinkEditSourceType.ZEN_EDITOR || editing.type === HyperLinkEditSourceType.EDITING ? AddRichHyperLinkCommand.id : AddHyperLinkCommand.id;
872
- await commandService.executeCommand(commandId, {
873
- unitId: editing.unitId,
874
- subUnitId: editing.subUnitId,
556
+ const h = a.type === f.ZEN_EDITOR || a.type === f.EDITING ? mr.id : fr.id;
557
+ await P.executeCommand(h, {
558
+ unitId: a.unitId,
559
+ subUnitId: a.subUnitId,
875
560
  link: {
876
- id: generateRandomId(),
877
- row: editing.row,
878
- column: editing.col,
879
- payload: formatUrl(type, payload),
880
- display: showLabel ? display : ""
561
+ id: or(),
562
+ row: a.row,
563
+ column: a.col,
564
+ payload: Vt(u, l),
565
+ display: s ? i : ""
881
566
  },
882
- documentId: editing.type === HyperLinkEditSourceType.ZEN_EDITOR ? DOCS_ZEN_EDITOR_UNIT_ID_KEY : editorBridgeService.getCurrentEditorId()
567
+ documentId: a.type === f.ZEN_EDITOR ? x : C.getCurrentEditorId()
883
568
  });
884
569
  }
885
- if ((editing == null ? void 0 : editing.type) === HyperLinkEditSourceType.VIEWING) {
886
- await commandService.executeCommand(SetWorksheetActiveOperation.id, {
887
- unitId: editing.unitId,
888
- subUnitId: editing.subUnitId
570
+ if ((a == null ? void 0 : a.type) === f.VIEWING) {
571
+ await P.executeCommand(Ln.id, {
572
+ unitId: a.unitId,
573
+ subUnitId: a.subUnitId
889
574
  });
890
- const GAP = 1;
891
- await commandService.executeCommand(ScrollToRangeOperation.id, {
575
+ const h = 1;
576
+ await P.executeCommand(yn.id, {
892
577
  range: {
893
- startRow: Math.max(editing.row - GAP, 0),
894
- endRow: editing.row + GAP,
895
- startColumn: Math.max(editing.col - GAP, 0),
896
- endColumn: editing.col + GAP
578
+ startRow: Math.max(a.row - h, 0),
579
+ endRow: a.row + h,
580
+ startColumn: Math.max(a.col - h, 0),
581
+ endColumn: a.col + h
897
582
  }
898
583
  });
899
584
  }
900
- commandService.executeCommand(CloseHyperLinkPopupOperation.id);
901
- }, "handleSubmit"), handlePanelClick = /* @__PURE__ */ __name((e) => {
902
- var _a16;
903
- if (type !== SheetHyperLinkType.RANGE)
585
+ P.executeCommand(Ke.id);
586
+ }, Qn = (h) => {
587
+ var I;
588
+ if (u !== S.RANGE)
904
589
  return;
905
- const handleOutClick = (_a16 = rangeSelectorActionsRef.current) == null ? void 0 : _a16.handleOutClick;
906
- handleOutClick && handleOutClick(e, isFocusRangeSelectorSet);
907
- }, "handlePanelClick");
908
- return editing ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkEdit, style: { display: hide ? "none" : "block" }, onClick: handlePanelClick, children: [
909
- showLabel ? /* @__PURE__ */ jsxRuntimeExports.jsx(
910
- FormLayout,
590
+ const y = (I = Pe.current) == null ? void 0 : I.handleOutClick;
591
+ y && y(h, () => pt(!1));
592
+ };
593
+ return a ? /* @__PURE__ */ m.jsxs("div", { className: dn.cellLinkEdit, style: { display: n ? "none" : "block" }, onClick: Qn, children: [
594
+ s ? /* @__PURE__ */ m.jsx(
595
+ _e,
911
596
  {
912
- label: localeService.t("hyperLink.form.label"),
913
- error: showError && !display ? localeService.t("hyperLink.form.inputError") : "",
914
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
915
- Input,
597
+ label: p.t("hyperLink.form.label"),
598
+ error: j && !i ? p.t("hyperLink.form.inputError") : "",
599
+ children: /* @__PURE__ */ m.jsx(
600
+ on,
916
601
  {
917
- value: display,
918
- onChange: /* @__PURE__ */ __name((v) => {
919
- setDisplay(v), setByPayload.current = !1;
920
- }, "onChange"),
921
- placeholder: localeService.t("hyperLink.form.labelPlaceholder"),
602
+ value: i,
603
+ onChange: (h) => {
604
+ J(h), H.current = !1;
605
+ },
606
+ placeholder: p.t("hyperLink.form.labelPlaceholder"),
922
607
  autoFocus: !0,
923
- onKeyDown: /* @__PURE__ */ __name((e) => {
924
- e.keyCode === KeyCode.ENTER && handleSubmit();
925
- }, "onKeyDown")
608
+ onKeyDown: (h) => {
609
+ h.keyCode === Rt.ENTER && mt();
610
+ }
926
611
  }
927
612
  )
928
613
  }
929
614
  ) : null,
930
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("hyperLink.form.type"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
931
- Select,
615
+ /* @__PURE__ */ m.jsx(_e, { label: p.t("hyperLink.form.type"), children: /* @__PURE__ */ m.jsx(
616
+ Ct,
932
617
  {
933
- options: linkTypeOptions,
934
- value: type,
935
- onChange: /* @__PURE__ */ __name((newType) => {
936
- setType(newType), setPayload("");
937
- }, "onChange")
618
+ options: Xn,
619
+ value: u,
620
+ onChange: (h) => {
621
+ d(h), g("");
622
+ }
938
623
  }
939
624
  ) }),
940
- type === SheetHyperLinkType.URL && /* @__PURE__ */ jsxRuntimeExports.jsx(
941
- FormLayout,
625
+ u === S.URL && /* @__PURE__ */ m.jsx(
626
+ _e,
942
627
  {
943
- error: showError ? payload ? isLegalLink(payload) ? "" : localeService.t("hyperLink.form.linkError") : localeService.t("hyperLink.form.inputError") : "",
944
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
945
- Input,
628
+ error: j ? l ? Fe(l) ? "" : p.t("hyperLink.form.linkError") : p.t("hyperLink.form.inputError") : "",
629
+ children: /* @__PURE__ */ m.jsx(
630
+ on,
946
631
  {
947
- value: payload,
948
- onChange: /* @__PURE__ */ __name((newLink) => {
949
- setPayload(newLink), newLink && (setByPayload.current || !display || display === payload) && (setDisplay(newLink), setByPayload.current = !0);
950
- }, "onChange"),
951
- placeholder: localeService.t("hyperLink.form.linkPlaceholder"),
632
+ value: l,
633
+ onChange: (h) => {
634
+ g(h), h && (H.current || !i || i === l) && (J(h), H.current = !0);
635
+ },
636
+ placeholder: p.t("hyperLink.form.linkPlaceholder"),
952
637
  autoFocus: !0,
953
- onKeyDown: /* @__PURE__ */ __name((e) => {
954
- e.keyCode === KeyCode.ENTER && handleSubmit();
955
- }, "onKeyDown")
638
+ onKeyDown: (h) => {
639
+ h.keyCode === Rt.ENTER && mt();
640
+ }
956
641
  }
957
642
  )
958
643
  }
959
644
  ),
960
- type === SheetHyperLinkType.RANGE && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
961
- RangeSelector,
645
+ u === S.RANGE && /* @__PURE__ */ m.jsx(_e, { error: j && !l ? p.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ m.jsx(
646
+ hi,
962
647
  {
963
- unitId: workbook.getUnitId(),
964
- subUnitId,
648
+ unitId: B.getUnitId(),
649
+ subUnitId: Yn,
965
650
  isOnlyOneRange: !0,
966
651
  isSupportAcrossSheet: !0,
967
- initValue: payload,
968
- onChange: handleRangeChange,
969
- isFocus: isFocusRangeSelector,
970
- onBlur: /* @__PURE__ */ __name(() => {
971
- isFocusRangeSelectorSet(!1);
972
- }, "onBlur"),
973
- actions: rangeSelectorActionsRef.current,
974
- onRangeSelectorDialogVisibleChange: /* @__PURE__ */ __name(async (visible) => {
975
- var _a16, _b;
976
- if (visible)
977
- editing.type === HyperLinkEditSourceType.ZEN_EDITOR && (zenZoneService.hide(), contextService.setContextValue(FOCUSING_SHEET, !0)), editing.type !== HyperLinkEditSourceType.VIEWING && editorBridgeService.enableForceKeepVisible(), setHide(!0);
652
+ initValue: l,
653
+ onChange: Jn,
654
+ isFocus: Le,
655
+ onFocus: () => pt(!0),
656
+ actions: Pe.current,
657
+ onRangeSelectorDialogVisibleChange: async (h) => {
658
+ var y, I;
659
+ if (h)
660
+ a.type === f.ZEN_EDITOR && (D.hide(), se.setContextValue(_t, !0)), a.type !== f.VIEWING && C.enableForceKeepVisible(), r(!0);
978
661
  else {
979
- if (await resolverService.navigateToRange(editing.unitId, editing.subUnitId, { startRow: editing.row, endRow: editing.row, startColumn: editing.col, endColumn: editing.col }), editing.type === HyperLinkEditSourceType.ZEN_EDITOR) {
980
- await commandService.executeCommand(SetSelectionsOperation.id, {
981
- unitId: editing.unitId,
982
- subUnitId: editing.subUnitId,
983
- selections: [{ range: { startRow: editing.row, endRow: editing.row, startColumn: editing.col, endColumn: editing.col } }]
984
- }), zenZoneService.show(), contextService.setContextValue(FOCUSING_SHEET, !1);
985
- const docBackScrollRenderController = (_a16 = renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY)) == null ? void 0 : _a16.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];
986
- docBackScrollRenderController && range && (docBackScrollRenderController.scrollToRange(range), docSelectionManagerService.refreshSelection({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY }));
662
+ if (await M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, !0), a.type === f.ZEN_EDITOR) {
663
+ await P.executeCommand(Pn.id, {
664
+ unitId: a.unitId,
665
+ subUnitId: a.subUnitId,
666
+ selections: [{ range: { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col } }]
667
+ }), D.show(), se.setContextValue(_t, !1);
668
+ const L = (y = ie.getRenderById(x)) == null ? void 0 : y.with(ri), N = (I = Re.getTextRanges({ unitId: x, subUnitId: x })) == null ? void 0 : I[0];
669
+ L && N && (L.scrollToRange(N), Re.refreshSelection({ unitId: x, subUnitId: x }));
987
670
  }
988
- editorBridgeService.disableForceKeepVisible(), setHide(!1);
671
+ C.disableForceKeepVisible(), r(!1);
989
672
  }
990
- }, "onRangeSelectorDialogVisibleChange")
673
+ }
991
674
  }
992
675
  ) }),
993
- type === SheetHyperLinkType.SHEET && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
994
- Select,
676
+ u === S.SHEET && /* @__PURE__ */ m.jsx(_e, { error: j && !l ? p.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ m.jsx(
677
+ Ct,
995
678
  {
996
- options: sheetsOption,
997
- value: payload,
998
- onChange: /* @__PURE__ */ __name((newPayload) => {
999
- var _a16, _b;
1000
- setPayload(newPayload);
1001
- const label = (_a16 = sheetsOption.find((i) => i.value === newPayload)) == null ? void 0 : _a16.label, oldLabel = (_b = sheetsOption.find((i) => i.value === payload)) == null ? void 0 : _b.label;
1002
- label && (setByPayload.current || !display || display === oldLabel) && (setDisplay(label), setByPayload.current = !0);
1003
- }, "onChange")
679
+ options: ht,
680
+ value: l,
681
+ onChange: (h) => {
682
+ var L, N;
683
+ g(h);
684
+ const y = (L = ht.find((A) => A.value === h)) == null ? void 0 : L.label, I = (N = ht.find((A) => A.value === l)) == null ? void 0 : N.label;
685
+ y && (H.current || !i || i === I) && (J(y), H.current = !0);
686
+ }
1004
687
  }
1005
688
  ) }),
1006
- type === SheetHyperLinkType.DEFINE_NAME && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1007
- Select,
689
+ u === S.DEFINE_NAME && /* @__PURE__ */ m.jsx(_e, { error: j && !l ? p.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ m.jsx(
690
+ Ct,
1008
691
  {
1009
- options: definedNames,
1010
- value: payload,
1011
- onChange: /* @__PURE__ */ __name((newValue) => {
1012
- var _a16, _b;
1013
- setPayload(newValue);
1014
- const label = (_a16 = definedNames.find((i) => i.value === newValue)) == null ? void 0 : _a16.label, oldLabel = (_b = definedNames.find((i) => i.value === payload)) == null ? void 0 : _b.label;
1015
- label && (setByPayload.current || !display || display === oldLabel) && (setDisplay(label), setByPayload.current = !0);
1016
- }, "onChange")
692
+ options: gt,
693
+ value: l,
694
+ onChange: (h) => {
695
+ var L, N;
696
+ g(h);
697
+ const y = (L = gt.find((A) => A.value === h)) == null ? void 0 : L.label, I = (N = gt.find((A) => A.value === l)) == null ? void 0 : N.label;
698
+ y && (H.current || !i || i === I) && (J(y), H.current = !0);
699
+ }
1017
700
  }
1018
701
  ) }),
1019
- (customHyperLinkSidePanel == null ? void 0 : customHyperLinkSidePanel.Form) && /* @__PURE__ */ jsxRuntimeExports.jsx(
1020
- customHyperLinkSidePanel.Form,
702
+ (oe == null ? void 0 : oe.Form) && /* @__PURE__ */ m.jsx(
703
+ oe.Form,
1021
704
  {
1022
- linkId: id,
1023
- payload,
1024
- display,
1025
- showError,
1026
- setByPayload,
1027
- setDisplay: /* @__PURE__ */ __name((newLink) => {
1028
- setDisplay(newLink), setByPayload.current = !0;
1029
- }, "setDisplay"),
1030
- setPayload
705
+ linkId: t,
706
+ payload: l,
707
+ display: i,
708
+ showError: j,
709
+ setByPayload: H,
710
+ setDisplay: (h) => {
711
+ J(h), H.current = !0;
712
+ },
713
+ setPayload: g
1031
714
  }
1032
715
  ),
1033
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkEditButtons, children: [
1034
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1035
- Button,
716
+ /* @__PURE__ */ m.jsxs("div", { className: dn.cellLinkEditButtons, children: [
717
+ /* @__PURE__ */ m.jsx(
718
+ an,
1036
719
  {
1037
- onClick: /* @__PURE__ */ __name(() => {
1038
- editing && resolverService.navigateToRange(editing.unitId, editing.subUnitId, { startRow: editing.row, endRow: editing.row, startColumn: editing.col, endColumn: editing.col }), commandService.executeCommand(CloseHyperLinkPopupOperation.id);
1039
- }, "onClick"),
1040
- children: localeService.t("hyperLink.form.cancel")
720
+ onClick: () => {
721
+ a && M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, !0), P.executeCommand(Ke.id);
722
+ },
723
+ children: p.t("hyperLink.form.cancel")
1041
724
  }
1042
725
  ),
1043
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1044
- Button,
726
+ /* @__PURE__ */ m.jsx(
727
+ an,
1045
728
  {
1046
729
  type: "primary",
1047
730
  style: { marginLeft: 8 },
1048
- onClick: /* @__PURE__ */ __name(async () => {
1049
- handleSubmit();
1050
- }, "onClick"),
1051
- children: localeService.t("hyperLink.form.ok")
731
+ onClick: async () => {
732
+ mt();
733
+ },
734
+ children: p.t("hyperLink.form.ok")
1052
735
  }
1053
736
  )
1054
737
  ] })
1055
738
  ] }) : null;
1056
- }, "CellLinkEdit");
1057
- CellLinkEdit.componentKey = "univer.sheet.cell-link-edit";
1058
- var __assign = function() {
1059
- return __assign = Object.assign || function(t) {
1060
- for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
1061
- s = arguments[i];
1062
- for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
739
+ };
740
+ Ze.componentKey = "univer.sheet.cell-link-edit";
741
+ var $ = function() {
742
+ return $ = Object.assign || function(t) {
743
+ for (var e, n = 1, r = arguments.length; n < r; n++) {
744
+ e = arguments[n];
745
+ for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
1063
746
  }
1064
747
  return t;
1065
- }, __assign.apply(this, arguments);
1066
- }, __rest = function(s, e) {
1067
- var t = {};
1068
- for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
1069
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
1070
- for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
1071
- e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
1072
- return t;
1073
- }, IconBase = forwardRef(function(props, ref) {
1074
- 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()));
1075
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
748
+ }, $.apply(this, arguments);
749
+ }, Ni = function(t, e) {
750
+ var n = {};
751
+ for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
752
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
753
+ for (var i = 0, r = Object.getOwnPropertySymbols(t); i < r.length; i++)
754
+ e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
755
+ return n;
756
+ }, fe = ge(function(t, e) {
757
+ var n = t.icon, r = t.id, i = t.className, o = t.extend, s = Ni(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), u = Pt("_".concat(Hi()));
758
+ return Dn(n, "".concat(r), { defIds: n.defIds, idSuffix: u.current }, $({ ref: e, className: c }, s), o);
1076
759
  });
1077
- function render(node, id, runtimeProps, rootProps, extend) {
1078
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
1079
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
760
+ function Dn(t, e, n, r, i) {
761
+ return me(t.tag, $($({ key: e }, Mi(t, n, i)), r), (Ui(t, n).children || []).map(function(o, s) {
762
+ return Dn(o, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, i);
1080
763
  }));
1081
764
  }
1082
- __name(render, "render");
1083
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
1084
- var attrs = __assign({}, node.attrs);
1085
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
1086
- var defIds = runtimeProps.defIds;
1087
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a15) {
1088
- var key = _a15[0], value = _a15[1];
1089
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
1090
- })), attrs;
765
+ function Mi(t, e, n) {
766
+ var r = $({}, t.attrs);
767
+ n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1);
768
+ var i = e.defIds;
769
+ return !i || i.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(o) {
770
+ var s = o[0], c = o[1];
771
+ typeof c == "string" && (r[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
772
+ })), r;
1091
773
  }
1092
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
1093
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
1094
- var _a15, defIds = runtimeProps.defIds;
1095
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a15 = node.children) === null || _a15 === void 0) && _a15.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
1096
- 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;
1097
- }) }) : node;
774
+ function Ui(t, e) {
775
+ var n, r = e.defIds;
776
+ return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? $($({}, t), { children: t.children.map(function(i) {
777
+ return typeof i.attrs.id == "string" && r && r.indexOf(i.attrs.id) > -1 ? $($({}, i), { attrs: $($({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
778
+ }) }) : t;
1098
779
  }
1099
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
1100
- function generateShortUuid() {
780
+ function Hi() {
1101
781
  return Math.random().toString(36).substring(2, 8);
1102
782
  }
1103
- __name(generateShortUuid, "generateShortUuid");
1104
- IconBase.displayName = "UniverIcon";
1105
- 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) {
1106
- return createElement(IconBase, Object.assign({}, props, {
783
+ fe.displayName = "UniverIcon";
784
+ var Di = { 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" } }] }, Ae = ge(function(t, e) {
785
+ return me(fe, Object.assign({}, t, {
1107
786
  id: "all-border-single",
1108
- ref,
1109
- icon: element$5
787
+ ref: e,
788
+ icon: Di
1110
789
  }));
1111
790
  });
1112
- AllBorderSingle.displayName = "AllBorderSingle";
1113
- 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) {
1114
- return createElement(IconBase, Object.assign({}, props, {
791
+ Ae.displayName = "AllBorderSingle";
792
+ var $i = { 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" } }] }, $n = ge(function(t, e) {
793
+ return me(fe, Object.assign({}, t, {
1115
794
  id: "copy-single",
1116
- ref,
1117
- icon: element$4
795
+ ref: e,
796
+ icon: $i
1118
797
  }));
1119
798
  });
1120
- CopySingle.displayName = "CopySingle";
1121
- var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332", fillRule: "evenodd", clipRule: "evenodd" } }] }, LinkSingle = forwardRef(function(props, ref) {
1122
- return createElement(IconBase, Object.assign({}, props, {
799
+ $n.displayName = "CopySingle";
800
+ var ji = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332", fillRule: "evenodd", clipRule: "evenodd" } }] }, Ut = ge(function(t, e) {
801
+ return me(fe, Object.assign({}, t, {
1123
802
  id: "link-single",
1124
- ref,
1125
- icon: element$3
803
+ ref: e,
804
+ icon: ji
1126
805
  }));
1127
806
  });
1128
- LinkSingle.displayName = "LinkSingle";
1129
- 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) {
1130
- return createElement(IconBase, Object.assign({}, props, {
807
+ Ut.displayName = "LinkSingle";
808
+ var Vi = { 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" } }] }, jn = ge(function(t, e) {
809
+ return me(fe, Object.assign({}, t, {
1131
810
  id: "unlink-single",
1132
- ref,
1133
- icon: element$2
811
+ ref: e,
812
+ icon: Vi
1134
813
  }));
1135
814
  });
1136
- UnlinkSingle.displayName = "UnlinkSingle";
1137
- 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) {
1138
- return createElement(IconBase, Object.assign({}, props, {
815
+ jn.displayName = "UnlinkSingle";
816
+ var Bi = { 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" } }] }, Vn = ge(function(t, e) {
817
+ return me(fe, Object.assign({}, t, {
1139
818
  id: "write-single",
1140
- ref,
1141
- icon: element$1
819
+ ref: e,
820
+ icon: Bi
1142
821
  }));
1143
822
  });
1144
- WriteSingle.displayName = "WriteSingle";
1145
- 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) {
1146
- return createElement(IconBase, Object.assign({}, props, {
823
+ Vn.displayName = "WriteSingle";
824
+ var Ai = { 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" } }] }, Bn = ge(function(t, e) {
825
+ return me(fe, Object.assign({}, t, {
1147
826
  id: "xlsx",
1148
- ref,
1149
- icon: element
827
+ ref: e,
828
+ icon: Ai
1150
829
  }));
1151
830
  });
1152
- Xlsx.displayName = "Xlsx";
1153
- function r(e) {
1154
- var t, f2, n2 = "";
1155
- if (typeof e == "string" || typeof e == "number") n2 += e;
1156
- else if (typeof e == "object") if (Array.isArray(e)) {
1157
- var o = e.length;
1158
- for (t = 0; t < o; t++) e[t] && (f2 = r(e[t])) && (n2 && (n2 += " "), n2 += f2);
1159
- } else for (f2 in e) e[f2] && (n2 && (n2 += " "), n2 += f2);
1160
- return n2;
831
+ Bn.displayName = "Xlsx";
832
+ function An(t) {
833
+ var e, n, r = "";
834
+ if (typeof t == "string" || typeof t == "number") r += t;
835
+ else if (typeof t == "object") if (Array.isArray(t)) {
836
+ var i = t.length;
837
+ for (e = 0; e < i; e++) t[e] && (n = An(t[e])) && (r && (r += " "), r += n);
838
+ } else for (n in t) t[n] && (r && (r += " "), r += n);
839
+ return r;
1161
840
  }
1162
- __name(r, "r");
1163
- function clsx() {
1164
- for (var e, t, f2 = 0, n2 = "", o = arguments.length; f2 < o; f2++) (e = arguments[f2]) && (t = r(e)) && (n2 && (n2 += " "), n2 += t);
1165
- return n2;
841
+ function pn() {
842
+ for (var t, e, n = 0, r = "", i = arguments.length; n < i; n++) (t = arguments[n]) && (e = An(t)) && (r && (r += " "), r += e);
843
+ return r;
1166
844
  }
1167
- __name(clsx, "clsx");
1168
- const CancelHyperLinkCommand = {
1169
- type: CommandType.COMMAND,
1170
- id: "sheets.command.cancel-hyper-link",
1171
- // eslint-disable-next-line max-lines-per-function
1172
- handler(accessor, params) {
1173
- var _a15, _b, _c;
1174
- if (!params)
1175
- return !1;
1176
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), renderManagerService = accessor.get(IRenderManagerService), univerInstanceService = accessor.get(IUniverInstanceService), hyperLinkModel = accessor.get(HyperLinkModel), { unitId, subUnitId, row, column, id } = params, workbook = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), currentRender = renderManagerService.getRenderById(unitId);
1177
- if (!currentRender || !workbook)
1178
- return !1;
1179
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId), skeleton = (_a15 = currentRender.with(SheetSkeletonManagerService).getCurrent()) == null ? void 0 : _a15.skeleton;
1180
- if (!worksheet || !skeleton)
1181
- return !1;
1182
- const cellData = worksheet.getCell(row, column);
1183
- if (!cellData)
1184
- return !1;
1185
- const doc = skeleton.getCellDocumentModelWithFormula(cellData);
1186
- if (!(doc != null && doc.documentModel))
1187
- return !1;
1188
- const snapshot = Tools.deepClone(doc.documentModel.getSnapshot());
1189
- if (!((_c = (_b = snapshot.body) == null ? void 0 : _b.customRanges) == null ? void 0 : _c.find((range2) => range2.rangeId === id)))
1190
- return !1;
1191
- const textX = BuildTextUtils.customRange.delete(accessor, { documentDataModel: doc.documentModel, rangeId: id });
1192
- if (!textX)
1193
- return !1;
1194
- const newBody = TextX.apply(snapshot.body, textX.serialize()), redos = [], undos = [], setRangeParams = {
1195
- unitId,
1196
- subUnitId,
1197
- cellValue: {
1198
- [row]: {
1199
- [column]: {
1200
- p: {
1201
- ...snapshot,
1202
- body: newBody
1203
- },
1204
- t: CellValueType.STRING
1205
- }
1206
- }
1207
- }
1208
- };
1209
- redos.push({
1210
- id: SetRangeValuesMutation.id,
1211
- params: setRangeParams
1212
- });
1213
- const undoParams = SetRangeValuesUndoMutationFactory(accessor, setRangeParams);
1214
- undos.push({
1215
- id: SetRangeValuesMutation.id,
1216
- params: undoParams
1217
- });
1218
- const link = hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
1219
- return link && (redos.push({
1220
- id: RemoveHyperLinkMutation.id,
1221
- params: {
1222
- unitId,
1223
- subUnitId,
1224
- id
1225
- }
1226
- }), undos.push({
1227
- id: AddHyperLinkMutation.id,
1228
- params: {
1229
- unitId,
1230
- subUnitId,
1231
- link: {
1232
- ...link
1233
- }
1234
- }
1235
- })), sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
1236
- redoMutations: redos,
1237
- undoMutations: undos,
1238
- unitID: unitId
1239
- }), !0) : !1;
1240
- }
1241
- }, CancelRichHyperLinkCommand = {
1242
- type: CommandType.COMMAND,
1243
- id: "sheets.command.cancel-rich-hyper-link",
1244
- handler(accessor, params) {
1245
- var _a15, _b;
1246
- if (!params)
1247
- return !1;
1248
- const { id: linkId, documentId } = params, commandService = accessor.get(ICommandService), doc = accessor.get(IUniverInstanceService).getUnit(documentId, UniverInstanceType.UNIVER_DOC), link = (_b = (_a15 = doc == null ? void 0 : doc.getBody()) == null ? void 0 : _a15.customRanges) == null ? void 0 : _b.find((i) => i.rangeId === linkId);
1249
- let insert = null;
1250
- link && link.endIndex === doc.getBody().dataStream.length - 3 && (insert = {
1251
- dataStream: " "
1252
- });
1253
- const doMutation = deleteCustomRangeFactory(accessor, { unitId: documentId, rangeId: linkId, insert });
1254
- return doMutation ? commandService.syncExecuteCommand(doMutation.id, doMutation.params) : !1;
1255
- }
1256
- }, 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 = {
1257
- cellLink,
1258
- cellLinkType,
1259
- cellLinkContent,
1260
- cellLinkContentError,
1261
- cellLinkUrl,
1262
- cellLinkOperations,
1263
- cellLinkOperation,
1264
- cellLinkOperationError
1265
- }, iconsMap = {
1266
- [SheetHyperLinkType.URL]: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkSingle, {}),
1267
- [SheetHyperLinkType.SHEET]: /* @__PURE__ */ jsxRuntimeExports.jsx(Xlsx, {}),
1268
- [SheetHyperLinkType.RANGE]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
1269
- [SheetHyperLinkType.DEFINE_NAME]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
1270
- [SheetHyperLinkType.INVALID]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {})
1271
- }, CellLinkPopup = /* @__PURE__ */ __name(() => {
1272
- var _a15, _b;
1273
- const popupService = useDependency(SheetsHyperLinkPopupService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), [currentPopup, setCurrentPopup] = useState(null), resolverService = useDependency(SheetsHyperLinkResolverService), editorBridgeService = useDependency(IEditorBridgeService), zenZoneService = useDependency(IZenZoneService);
1274
- if (useObservable$1(zenZoneService.visible$), useEffect(() => {
1275
- setCurrentPopup(popupService.currentPopup);
1276
- const ob = popupService.currentPopup$.subscribe((popup) => {
1277
- setCurrentPopup(popup);
1278
- });
1279
- return () => {
1280
- ob.unsubscribe();
1281
- };
1282
- }, [popupService.currentPopup, popupService.currentPopup$]), !currentPopup)
1283
- return null;
1284
- const { unitId, subUnitId, customRange, row, col } = currentPopup;
1285
- if (!((_a15 = customRange == null ? void 0 : customRange.properties) != null && _a15.url))
845
+ const Fi = "univer-cell-link", Wi = "univer-cell-link-type", Zi = "univer-cell-link-content", Gi = "univer-cell-link-content-error", Ki = "univer-cell-link-url", zi = "univer-cell-link-operations", Yi = "univer-cell-link-operation", Xi = "univer-cell-link-operation-error", W = {
846
+ cellLink: Fi,
847
+ cellLinkType: Wi,
848
+ cellLinkContent: Zi,
849
+ cellLinkContentError: Gi,
850
+ cellLinkUrl: Ki,
851
+ cellLinkOperations: zi,
852
+ cellLinkOperation: Yi,
853
+ cellLinkOperationError: Xi
854
+ }, qi = {
855
+ [S.URL]: /* @__PURE__ */ m.jsx(Ut, {}),
856
+ [S.SHEET]: /* @__PURE__ */ m.jsx(Bn, {}),
857
+ [S.RANGE]: /* @__PURE__ */ m.jsx(Ae, {}),
858
+ [S.DEFINE_NAME]: /* @__PURE__ */ m.jsx(Ae, {}),
859
+ [S.INVALID]: /* @__PURE__ */ m.jsx(Ae, {})
860
+ }, hn = (t) => {
861
+ var M, P;
862
+ const e = E(G), n = E(re), r = E(On), i = E(it), o = E(he), s = E(ne), c = E(wt), u = E(ct), { customRange: d, row: l, col: g, unitId: p, subUnitId: v, editPermission: C, copyPermission: _, type: b } = t;
863
+ if (!((M = d == null ? void 0 : d.properties) != null && M.url))
1286
864
  return null;
1287
- const linkObj = resolverService.parseHyperLink((_b = customRange.properties.url) != null ? _b : ""), isError = linkObj.type === SheetHyperLinkType.INVALID;
1288
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLink, onClick: /* @__PURE__ */ __name(() => popupService.hideCurrentPopup(), "onClick"), children: [
1289
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
865
+ const a = c.parseHyperLink((P = d.properties.url) != null ? P : ""), w = a.type === S.INVALID;
866
+ return /* @__PURE__ */ m.jsxs("div", { className: W.cellLink, onClick: () => e.hideCurrentPopup(), children: [
867
+ /* @__PURE__ */ m.jsxs(
1290
868
  "div",
1291
869
  {
1292
- className: clsx(styles.cellLinkContent, { [styles.cellLinkContentError]: isError }),
1293
- onClick: /* @__PURE__ */ __name(() => {
1294
- zenZoneService.visible || linkObj.handler();
1295
- }, "onClick"),
870
+ className: pn(W.cellLinkContent, { [W.cellLinkContentError]: w }),
871
+ onClick: () => {
872
+ u.visible || w || o.navigate(a);
873
+ },
1296
874
  children: [
1297
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.cellLinkType, children: iconsMap[linkObj.type] }),
1298
- /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { showIfEllipsis: !0, title: linkObj.name, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles.cellLinkUrl, children: linkObj.name }) })
875
+ /* @__PURE__ */ m.jsx("div", { className: W.cellLinkType, children: qi[a.type] }),
876
+ /* @__PURE__ */ m.jsx($e, { showIfEllipsis: !0, title: a.name, children: /* @__PURE__ */ m.jsx("span", { className: W.cellLinkUrl, children: a.name }) })
1299
877
  ]
1300
878
  }
1301
879
  ),
1302
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLinkOperations, children: [
1303
- currentPopup.copyPermission && /* @__PURE__ */ jsxRuntimeExports.jsx(
880
+ /* @__PURE__ */ m.jsxs("div", { className: W.cellLinkOperations, children: [
881
+ _ && /* @__PURE__ */ m.jsx(
1304
882
  "div",
1305
883
  {
1306
- className: clsx(styles.cellLinkOperation, { [styles.cellLinkOperationError]: isError }),
1307
- onClick: /* @__PURE__ */ __name(() => {
1308
- if (!isError) {
1309
- if (linkObj.type !== SheetHyperLinkType.URL) {
1310
- const url = new URL(window.location.href);
1311
- url.hash = linkObj.url.slice(1), navigator.clipboard.writeText(url.href);
884
+ className: pn(W.cellLinkOperation, { [W.cellLinkOperationError]: w }),
885
+ onClick: () => {
886
+ if (!w) {
887
+ if (a.type !== S.URL) {
888
+ const k = new URL(window.location.href);
889
+ k.hash = a.url.slice(1), navigator.clipboard.writeText(k.href);
1312
890
  } else
1313
- navigator.clipboard.writeText(linkObj.url);
1314
- messageService.show({
1315
- content: localeService.t("hyperLink.message.coped"),
1316
- type: MessageType.Info
891
+ navigator.clipboard.writeText(a.url);
892
+ r.show({
893
+ content: i.t("hyperLink.message.coped"),
894
+ type: ke.Info
1317
895
  });
1318
896
  }
1319
- }, "onClick"),
1320
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.copy"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopySingle, {}) })
897
+ },
898
+ children: /* @__PURE__ */ m.jsx($e, { placement: "bottom", title: i.t("hyperLink.popup.copy"), children: /* @__PURE__ */ m.jsx($n, {}) })
1321
899
  }
1322
900
  ),
1323
- currentPopup.editPermission && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1324
- /* @__PURE__ */ jsxRuntimeExports.jsx(
901
+ C && /* @__PURE__ */ m.jsxs(m.Fragment, { children: [
902
+ /* @__PURE__ */ m.jsx(
1325
903
  "div",
1326
904
  {
1327
- className: styles.cellLinkOperation,
1328
- onClick: /* @__PURE__ */ __name(() => {
1329
- commandService.executeCommand(OpenHyperLinkEditPanelOperation.id, {
1330
- unitId,
1331
- subUnitId,
1332
- row,
1333
- col,
1334
- customRangeId: customRange.rangeId,
1335
- type: currentPopup.type
905
+ className: W.cellLinkOperation,
906
+ onClick: () => {
907
+ n.executeCommand(Dt.id, {
908
+ unitId: p,
909
+ subUnitId: v,
910
+ row: l,
911
+ col: g,
912
+ customRangeId: d.rangeId,
913
+ type: b
1336
914
  });
1337
- }, "onClick"),
1338
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.edit"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(WriteSingle, {}) })
915
+ },
916
+ children: /* @__PURE__ */ m.jsx($e, { placement: "bottom", title: i.t("hyperLink.popup.edit"), children: /* @__PURE__ */ m.jsx(Vn, {}) })
1339
917
  }
1340
918
  ),
1341
- /* @__PURE__ */ jsxRuntimeExports.jsx(
919
+ /* @__PURE__ */ m.jsx(
1342
920
  "div",
1343
921
  {
1344
- className: styles.cellLinkOperation,
1345
- onClick: /* @__PURE__ */ __name(() => {
1346
- const commandId = currentPopup.type === HyperLinkEditSourceType.EDITING || currentPopup.type === HyperLinkEditSourceType.ZEN_EDITOR ? CancelRichHyperLinkCommand.id : CancelHyperLinkCommand.id;
1347
- commandService.syncExecuteCommand(commandId, {
1348
- unitId,
1349
- subUnitId,
1350
- id: customRange.rangeId,
1351
- row,
1352
- column: col,
1353
- documentId: currentPopup.type === HyperLinkEditSourceType.ZEN_EDITOR ? DOCS_ZEN_EDITOR_UNIT_ID_KEY : editorBridgeService.getCurrentEditorId()
1354
- }) && popupService.hideCurrentPopup(void 0, !0);
1355
- }, "onClick"),
1356
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(UnlinkSingle, {}) })
922
+ className: W.cellLinkOperation,
923
+ onClick: () => {
924
+ const k = b === f.EDITING || b === f.ZEN_EDITOR ? vr.id : _r.id;
925
+ n.syncExecuteCommand(k, {
926
+ unitId: p,
927
+ subUnitId: v,
928
+ id: d.rangeId,
929
+ row: l,
930
+ column: g,
931
+ documentId: b === f.ZEN_EDITOR ? x : s.getCurrentEditorId()
932
+ }) && e.hideCurrentPopup(void 0, !0);
933
+ },
934
+ children: /* @__PURE__ */ m.jsx($e, { placement: "bottom", title: i.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ m.jsx(jn, {}) })
1357
935
  }
1358
936
  )
1359
937
  ] })
1360
938
  ] })
1361
939
  ] });
1362
- }, "CellLinkPopup");
1363
- CellLinkPopup.componentKey = "univer.sheet.cell-link-popup";
1364
- var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1365
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1366
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1367
- return kind && result && __defProp$a(target, key, result), result;
1368
- }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a");
1369
- const isEqualLink = /* @__PURE__ */ __name((a, b) => {
1370
- var _a15, _b;
1371
- return a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.row === b.row && a.col === b.col && ((_a15 = a.customRange) == null ? void 0 : _a15.rangeId) === ((_b = b.customRange) == null ? void 0 : _b.rangeId) && a.type === b.type;
1372
- }, "isEqualLink");
1373
- var _a3;
1374
- let SheetsHyperLinkPopupService = (_a3 = class extends Disposable {
1375
- constructor(_sheetCanvasPopManagerService, _injector, _univerInstanceService, _editorBridgeService, _textSelectionManagerService, _docCanvasPopManagerService, _editorService, _rangeSelectorService, _zenZoneService) {
940
+ }, Ge = () => {
941
+ var i, o;
942
+ const t = E(G), [e, n] = X(null), r = E(K);
943
+ if (te(() => {
944
+ n(t.currentPopup);
945
+ const s = t.currentPopup$.subscribe((c) => {
946
+ n(c);
947
+ });
948
+ return () => {
949
+ s.unsubscribe();
950
+ };
951
+ }, [t.currentPopup, t.currentPopup$]), !e)
952
+ return null;
953
+ if (e.showAll) {
954
+ const s = r.getUnit(e.unitId, O.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(e.subUnitId), u = c == null ? void 0 : c.getCell(e.row, e.col), d = (o = (i = u == null ? void 0 : u.p) == null ? void 0 : i.body) == null ? void 0 : o.customRanges;
955
+ return d != null && d.length ? /* @__PURE__ */ m.jsx("div", { children: d.map((l) => /* @__PURE__ */ m.jsx(hn, { ...e, customRange: l }, l.rangeId)) }) : null;
956
+ }
957
+ return /* @__PURE__ */ m.jsx(hn, { ...e });
958
+ };
959
+ Ge.componentKey = "univer.sheet.cell-link-popup";
960
+ var Ji = Object.defineProperty, Qi = Object.getOwnPropertyDescriptor, es = (t, e, n, r) => {
961
+ for (var i = r > 1 ? void 0 : r ? Qi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
962
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
963
+ return r && i && Ji(e, n, i), i;
964
+ }, ce = (t, e) => (n, r) => e(n, r, t);
965
+ const gn = (t, e) => {
966
+ var n, r;
967
+ return t.unitId === e.unitId && t.subUnitId === e.subUnitId && t.row === e.row && t.col === e.col && ((n = t.customRange) == null ? void 0 : n.rangeId) === ((r = e.customRange) == null ? void 0 : r.rangeId) && t.type === e.type;
968
+ };
969
+ let G = class extends z {
970
+ constructor(e, n, r, i, o, s, c) {
1376
971
  super();
1377
- __publicField(this, "_currentPopup", null);
1378
- __publicField(this, "_currentPopup$", new Subject());
1379
- __publicField(this, "currentPopup$", this._currentPopup$.asObservable());
1380
- __publicField(this, "_currentEditingPopup", null);
1381
- __publicField(this, "_currentEditing$", new BehaviorSubject(null));
1382
- __publicField(this, "currentEditing$", this._currentEditing$.asObservable());
1383
- __publicField(this, "_isKeepVisible", !1);
1384
- this._sheetCanvasPopManagerService = _sheetCanvasPopManagerService, this._injector = _injector, this._univerInstanceService = _univerInstanceService, this._editorBridgeService = _editorBridgeService, this._textSelectionManagerService = _textSelectionManagerService, this._docCanvasPopManagerService = _docCanvasPopManagerService, this._editorService = _editorService, this._rangeSelectorService = _rangeSelectorService, this._zenZoneService = _zenZoneService, this.disposeWithMe(() => {
972
+ V(this, "_currentPopup", null);
973
+ V(this, "_currentPopup$", new oi());
974
+ V(this, "currentPopup$", this._currentPopup$.asObservable());
975
+ V(this, "_currentEditingPopup", null);
976
+ V(this, "_currentEditing$", new ai(null));
977
+ V(this, "currentEditing$", this._currentEditing$.asObservable());
978
+ V(this, "_isKeepVisible", !1);
979
+ this._sheetCanvasPopManagerService = e, this._injector = n, this._univerInstanceService = r, this._editorBridgeService = i, this._textSelectionManagerService = o, this._docCanvasPopManagerService = s, this._zenZoneService = c, this.disposeWithMe(() => {
1385
980
  this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete();
1386
981
  });
1387
982
  }
@@ -1391,1177 +986,902 @@ let SheetsHyperLinkPopupService = (_a3 = class extends Disposable {
1391
986
  get currentEditing() {
1392
987
  return this._currentEditing$.getValue();
1393
988
  }
1394
- setIsKeepVisible(v) {
1395
- this._isKeepVisible = v;
989
+ setIsKeepVisible(e) {
990
+ this._isKeepVisible = e;
1396
991
  }
1397
992
  getIsKeepVisible() {
1398
993
  return this._isKeepVisible;
1399
994
  }
1400
- showPopup(location2) {
1401
- if (this._currentPopup && isEqualLink(location2, this._currentPopup) || (this.hideCurrentPopup(void 0, !0), location2.type !== HyperLinkEditSourceType.ZEN_EDITOR && this._zenZoneService.visible))
995
+ showPopup(e) {
996
+ if (this._currentPopup && gn(e, this._currentPopup) || (this.hideCurrentPopup(void 0, !0), e.type !== f.ZEN_EDITOR && this._zenZoneService.visible))
1402
997
  return;
1403
- const currentEditing = this._currentEditing$.getValue();
1404
- if (currentEditing && isEqualLink(location2, currentEditing))
998
+ const n = this._currentEditing$.getValue();
999
+ if (n && gn(e, n))
1405
1000
  return;
1406
- const { unitId, subUnitId, row, col, customRangeRect, customRange } = location2;
1407
- if (!customRange)
1408
- return;
1409
- let disposable;
1410
- const popup = {
1411
- componentKey: CellLinkPopup.componentKey,
1001
+ const { unitId: r, subUnitId: i, row: o, col: s, customRangeRect: c, customRange: u } = e;
1002
+ let d;
1003
+ const l = {
1004
+ componentKey: Ge.componentKey,
1412
1005
  direction: "bottom",
1413
- onClickOutside: /* @__PURE__ */ __name(() => {
1006
+ onClickOutside: () => {
1414
1007
  this.hideCurrentPopup();
1415
- }, "onClickOutside"),
1416
- onClick: /* @__PURE__ */ __name(() => {
1417
- this.hideCurrentPopup(location2.type, !0);
1418
- }, "onClick")
1419
- };
1420
- location2.type === HyperLinkEditSourceType.EDITING ? disposable = customRangeRect && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
1421
- customRangeRect,
1422
- popup
1423
- ) : location2.type === HyperLinkEditSourceType.ZEN_EDITOR ? disposable = this._docCanvasPopManagerService.attachPopupToRange(
1424
- {
1425
- startOffset: customRange.startIndex,
1426
- endOffset: customRange.endIndex + 1,
1427
- collapsed: !1
1428
1008
  },
1429
- popup,
1430
- DOCS_ZEN_EDITOR_UNIT_ID_KEY
1431
- ) : disposable = customRangeRect && this._sheetCanvasPopManagerService.attachPopupByPosition(
1432
- customRangeRect,
1433
- popup
1434
- ), disposable && (this._currentPopup = {
1435
- unitId,
1436
- subUnitId,
1437
- disposable,
1438
- row,
1439
- col,
1440
- editPermission: !!location2.editPermission,
1441
- copyPermission: !!location2.copyPermission,
1442
- customRange,
1443
- type: location2.type
1009
+ onClick: () => {
1010
+ this.hideCurrentPopup(e.type, !0);
1011
+ }
1012
+ };
1013
+ if (e.type === f.EDITING) {
1014
+ if (!u)
1015
+ return;
1016
+ d = c && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
1017
+ c,
1018
+ l
1019
+ );
1020
+ } else if (e.type === f.ZEN_EDITOR) {
1021
+ if (!u)
1022
+ return;
1023
+ d = this._docCanvasPopManagerService.attachPopupToRange(
1024
+ {
1025
+ startOffset: u.startIndex,
1026
+ endOffset: u.endIndex + 1,
1027
+ collapsed: !1
1028
+ },
1029
+ l,
1030
+ x
1031
+ );
1032
+ } else if (e.showAll)
1033
+ d = this._sheetCanvasPopManagerService.attachPopupToCell(e.row, e.col, l, r, i);
1034
+ else {
1035
+ if (!u)
1036
+ return;
1037
+ d = c && this._sheetCanvasPopManagerService.attachPopupByPosition(
1038
+ c,
1039
+ l,
1040
+ e
1041
+ );
1042
+ }
1043
+ d && (this._currentPopup = {
1044
+ unitId: r,
1045
+ subUnitId: i,
1046
+ disposable: d,
1047
+ row: o,
1048
+ col: s,
1049
+ editPermission: !!e.editPermission,
1050
+ copyPermission: !!e.copyPermission,
1051
+ customRange: u,
1052
+ type: e.type,
1053
+ showAll: e.showAll
1444
1054
  }, this._currentPopup$.next(this._currentPopup));
1445
1055
  }
1446
- hideCurrentPopup(type, force) {
1447
- var _a15, _b;
1448
- this._currentPopup && ((!type || type === this._currentPopup.type) && this._currentPopup.disposable.canDispose() || force) && ((_b = (_a15 = this._currentPopup) == null ? void 0 : _a15.disposable) == null || _b.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
1056
+ hideCurrentPopup(e, n) {
1057
+ var r, i;
1058
+ this._currentPopup && ((!e || e === this._currentPopup.type) && this._currentPopup.disposable.canDispose() || n) && ((i = (r = this._currentPopup) == null ? void 0 : r.disposable) == null || i.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
1449
1059
  }
1450
1060
  _getEditingRange() {
1451
- var _a15, _b, _c;
1452
- const visible = this._editorBridgeService.isVisible().visible, state = this._editorBridgeService.getEditCellState();
1453
- if (visible && state) {
1454
- const textRange = this._textSelectionManagerService.getActiveTextRange(), body = (_a15 = state.documentLayoutObject.documentModel) == null ? void 0 : _a15.getBody();
1455
- if (!body)
1061
+ var r, i, o;
1062
+ const e = this._editorBridgeService.isVisible().visible, n = this._editorBridgeService.getEditCellState();
1063
+ if (e && n) {
1064
+ const s = this._textSelectionManagerService.getActiveTextRange(), c = (r = n.documentLayoutObject.documentModel) == null ? void 0 : r.getBody();
1065
+ if (!c)
1456
1066
  return null;
1457
- if (!textRange || textRange.collapsed)
1067
+ if (!s || s.collapsed)
1458
1068
  return {
1459
1069
  startOffset: 0,
1460
- endOffset: body.dataStream.length - 2,
1461
- collapsed: body.dataStream.length - 2 === 0,
1462
- label: BuildTextUtils.transform.getPlainText(body.dataStream)
1070
+ endOffset: c.dataStream.length - 2,
1071
+ collapsed: c.dataStream.length - 2 === 0,
1072
+ label: de.transform.getPlainText(c.dataStream)
1463
1073
  };
1464
- const links = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, (_c = (_b = body.customRanges) == null ? void 0 : _b.filter((i) => i.rangeType === CustomRangeType.HYPERLINK)) != null ? _c : []);
1465
- let start = textRange.startOffset, end = textRange.endOffset;
1466
- return links.forEach((link) => {
1467
- start = Math.min(start, link.startIndex), end = Math.max(end, link.endIndex + 1);
1074
+ const u = de.customRange.getCustomRangesInterestsWithSelection(s, (o = (i = c.customRanges) == null ? void 0 : i.filter((g) => g.rangeType === Me.HYPERLINK)) != null ? o : []);
1075
+ let d = s.startOffset, l = s.endOffset;
1076
+ return u.forEach((g) => {
1077
+ d = Math.min(d, g.startIndex), l = Math.max(l, g.endIndex + 1);
1468
1078
  }), {
1469
- startOffset: start,
1470
- endOffset: end,
1471
- collapsed: start === end,
1472
- label: BuildTextUtils.transform.getPlainText(body.dataStream.slice(start, end))
1079
+ startOffset: d,
1080
+ endOffset: l,
1081
+ collapsed: d === l,
1082
+ label: de.transform.getPlainText(c.dataStream.slice(d, l))
1473
1083
  };
1474
1084
  }
1475
1085
  return null;
1476
1086
  }
1477
1087
  get _editPopup() {
1478
1088
  return {
1479
- componentKey: CellLinkEdit.componentKey,
1089
+ componentKey: Ze.componentKey,
1480
1090
  direction: "bottom",
1481
- onClickOutside: /* @__PURE__ */ __name(() => {
1091
+ onClickOutside: () => {
1482
1092
  this.getIsKeepVisible() || this.endEditing();
1483
- }, "onClickOutside"),
1484
- onContextMenu: /* @__PURE__ */ __name(() => {
1093
+ },
1094
+ onContextMenu: () => {
1485
1095
  this.getIsKeepVisible() || this.endEditing();
1486
- }, "onContextMenu"),
1096
+ },
1487
1097
  hiddenType: "hide"
1488
1098
  };
1489
1099
  }
1490
- startAddEditing(link) {
1491
- var _a15, _b, _c, _d, _e;
1492
- const { unitId, subUnitId, type } = link;
1493
- if (type === HyperLinkEditSourceType.ZEN_EDITOR) {
1494
- const document = this._univerInstanceService.getUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
1495
- if (!document)
1100
+ startAddEditing(e) {
1101
+ var o, s, c, u, d;
1102
+ const { unitId: n, subUnitId: r, type: i } = e;
1103
+ if (i === f.ZEN_EDITOR) {
1104
+ const l = this._univerInstanceService.getUnit(x, O.UNIVER_DOC);
1105
+ if (!l)
1496
1106
  return;
1497
- const range = this._textSelectionManagerService.getActiveTextRange();
1498
- if (!range)
1107
+ const g = this._textSelectionManagerService.getActiveTextRange();
1108
+ if (!g)
1499
1109
  return;
1500
1110
  this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
1501
- range,
1111
+ g,
1502
1112
  this._editPopup,
1503
- DOCS_ZEN_EDITOR_UNIT_ID_KEY
1113
+ x
1504
1114
  );
1505
- const label = (_a15 = document.getBody()) == null ? void 0 : _a15.dataStream.slice(range.startOffset, range.endOffset - 1);
1115
+ const p = (o = l.getBody()) == null ? void 0 : o.dataStream.slice(g.startOffset, g.endOffset);
1506
1116
  this._currentEditing$.next({
1507
- ...link,
1508
- label
1117
+ ...e,
1118
+ label: p
1509
1119
  });
1510
- } else if (type === HyperLinkEditSourceType.EDITING) {
1511
- const range = this._getEditingRange();
1512
- range && this._textSelectionManagerService.replaceTextRanges([{ ...range }]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
1513
- link.row,
1514
- link.col,
1120
+ } else if (i === f.EDITING) {
1121
+ const l = this._getEditingRange();
1122
+ l && this._textSelectionManagerService.replaceTextRanges([{ ...l }]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
1123
+ e.row,
1124
+ e.col,
1515
1125
  this._editPopup,
1516
- unitId,
1517
- subUnitId
1126
+ n,
1127
+ r
1518
1128
  ), this._currentEditing$.next({
1519
- ...link,
1520
- label: (_b = range == null ? void 0 : range.label) != null ? _b : ""
1129
+ ...e,
1130
+ label: (s = l == null ? void 0 : l.label) != null ? s : ""
1521
1131
  });
1522
1132
  } else {
1523
1133
  this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
1524
- link.row,
1525
- link.col,
1134
+ e.row,
1135
+ e.col,
1526
1136
  this._editPopup,
1527
- unitId,
1528
- subUnitId
1137
+ n,
1138
+ r
1529
1139
  );
1530
- 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);
1140
+ const l = this._univerInstanceService.getUnit(n, O.UNIVER_SHEET), g = l == null ? void 0 : l.getSheetBySheetId(r), p = g == null ? void 0 : g.getCellRaw(e.row, e.col);
1531
1141
  this._currentEditing$.next({
1532
- ...link,
1533
- 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()
1142
+ ...e,
1143
+ label: p != null && p.p ? de.transform.getPlainText((u = (c = p.p.body) == null ? void 0 : c.dataStream) != null ? u : "") : ((d = p == null ? void 0 : p.v) != null ? d : "").toString()
1534
1144
  });
1535
1145
  }
1536
1146
  }
1537
- startEditing(link) {
1538
- var _a15, _b, _c, _d, _e, _f;
1539
- (_a15 = this._currentEditingPopup) == null || _a15.dispose(), this.hideCurrentPopup(void 0, !0);
1540
- const { unitId, subUnitId } = link;
1541
- let customRange, label;
1542
- if (link.type === HyperLinkEditSourceType.ZEN_EDITOR) {
1543
- const document = this._univerInstanceService.getUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
1544
- 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 + 1, customRange.endIndex) : "", !customRange || !label)
1147
+ // eslint-disable-next-line complexity, max-lines-per-function
1148
+ startEditing(e) {
1149
+ var s, c, u, d, l, g;
1150
+ (s = this._currentEditingPopup) == null || s.dispose(), this.hideCurrentPopup(void 0, !0);
1151
+ const { unitId: n, subUnitId: r } = e;
1152
+ let i, o;
1153
+ if (e.type === f.ZEN_EDITOR) {
1154
+ const p = this._univerInstanceService.getUnit(x, O.UNIVER_DOC);
1155
+ if (i = (u = (c = p == null ? void 0 : p.getBody()) == null ? void 0 : c.customRanges) == null ? void 0 : u.find((v) => v.rangeId === e.customRangeId), o = i ? (d = p == null ? void 0 : p.getBody()) == null ? void 0 : d.dataStream.slice(i.startIndex, i.endIndex + 1) : "", !i || !o)
1545
1156
  return;
1546
1157
  this._textSelectionManagerService.replaceTextRanges([
1547
1158
  {
1548
- startOffset: customRange.startIndex,
1549
- endOffset: customRange.endIndex + 1
1159
+ startOffset: i.startIndex,
1160
+ endOffset: i.endIndex + 1
1550
1161
  }
1551
1162
  ]), this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
1552
1163
  {
1553
- startOffset: customRange.startIndex,
1554
- endOffset: customRange.endIndex,
1164
+ startOffset: i.startIndex,
1165
+ endOffset: i.endIndex,
1555
1166
  collapsed: !1
1556
1167
  },
1557
1168
  this._editPopup,
1558
- DOCS_ZEN_EDITOR_UNIT_ID_KEY
1169
+ x
1559
1170
  );
1560
- } else if (link.type === HyperLinkEditSourceType.EDITING) {
1561
- const customRangeInfo = getEditingCustomRangePosition(this._injector, link.unitId, link.subUnitId, link.row, link.col, link.customRangeId);
1562
- if (!customRangeInfo || !((_e = customRangeInfo.rects) != null && _e.length))
1171
+ } else if (e.type === f.EDITING) {
1172
+ const p = Lr(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
1173
+ if (!p || !((l = p.rects) != null && l.length))
1563
1174
  return;
1564
- customRange = customRangeInfo.customRange, label = customRangeInfo.label, this._textSelectionManagerService.replaceTextRanges([
1175
+ i = p.customRange, o = p.label, this._textSelectionManagerService.replaceTextRanges([
1565
1176
  {
1566
- startOffset: customRange.startIndex,
1567
- endOffset: customRange.endIndex + 1
1177
+ startOffset: i.startIndex,
1178
+ endOffset: i.endIndex + 1
1568
1179
  }
1569
1180
  ]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
1570
- customRangeInfo.rects.pop(),
1181
+ p.rects.pop(),
1571
1182
  this._editPopup,
1572
- unitId,
1573
- subUnitId
1183
+ n,
1184
+ r
1574
1185
  );
1575
1186
  } else {
1576
- const customRangeInfo = getCustomRangePosition(this._injector, link.unitId, link.subUnitId, link.row, link.col, link.customRangeId);
1577
- if (!customRangeInfo || !((_f = customRangeInfo.rects) != null && _f.length))
1187
+ const p = this._univerInstanceService.getUnit(n, O.UNIVER_SHEET), v = p == null ? void 0 : p.getSheetBySheetId(r), C = v == null ? void 0 : v.getCellRaw(e.row, e.col), _ = p == null ? void 0 : p.getStyles().getStyleByCell(C), b = _ == null ? void 0 : _.tr, a = br(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
1188
+ if (!a || !((g = a.rects) != null && g.length))
1578
1189
  return;
1579
- customRange = customRangeInfo.customRange, label = customRangeInfo.label, this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupByPosition(
1580
- customRangeInfo.rects.pop(),
1190
+ i = a.customRange, o = a.label, b ? this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
1191
+ e.row,
1192
+ e.col,
1193
+ this._editPopup,
1194
+ n,
1195
+ r
1196
+ ) : this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupByPosition(
1197
+ a.rects.pop(),
1581
1198
  this._editPopup,
1582
- unitId,
1583
- subUnitId
1199
+ {
1200
+ unitId: n,
1201
+ subUnitId: r,
1202
+ row: e.row,
1203
+ col: e.col
1204
+ }
1584
1205
  );
1585
1206
  }
1586
1207
  this._currentEditing$.next({
1587
- ...link,
1588
- customRange,
1589
- label
1208
+ ...e,
1209
+ customRange: i,
1210
+ label: o
1590
1211
  });
1591
1212
  }
1592
- endEditing(type) {
1593
- var _a15;
1594
- const current = this._currentEditing$.getValue();
1595
- current && (!type || type === current.type) && ((_a15 = this._currentEditingPopup) == null || _a15.dispose(), this._currentEditing$.next(null));
1596
- }
1597
- }, __name(_a3, "SheetsHyperLinkPopupService"), _a3);
1598
- SheetsHyperLinkPopupService = __decorateClass$a([
1599
- __decorateParam$a(0, Inject(SheetCanvasPopManagerService)),
1600
- __decorateParam$a(1, Inject(Injector)),
1601
- __decorateParam$a(2, IUniverInstanceService),
1602
- __decorateParam$a(3, IEditorBridgeService),
1603
- __decorateParam$a(4, Inject(DocSelectionManagerService)),
1604
- __decorateParam$a(5, Inject(DocCanvasPopManagerService)),
1605
- __decorateParam$a(6, IEditorService),
1606
- __decorateParam$a(7, IRangeSelectorService),
1607
- __decorateParam$a(8, IZenZoneService)
1608
- ], SheetsHyperLinkPopupService);
1609
- const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) => {
1610
- const cell = worksheet.getCell(row, col);
1611
- if (cell != null && cell.f || cell != null && cell.si)
1213
+ endEditing(e) {
1214
+ var r;
1215
+ const n = this._currentEditing$.getValue();
1216
+ n && (!e || e === n.type) && ((r = this._currentEditingPopup) == null || r.dispose(), this._currentEditing$.next(null));
1217
+ }
1218
+ };
1219
+ G = es([
1220
+ ce(0, R(Pr)),
1221
+ ce(1, R(st)),
1222
+ ce(2, K),
1223
+ ce(3, ne),
1224
+ ce(4, R(Ue)),
1225
+ ce(5, R(ii)),
1226
+ ce(6, ct)
1227
+ ], G);
1228
+ const Ht = (t, e, n) => {
1229
+ const r = t.getCell(e, n);
1230
+ if (r != null && r.f || r != null && r.si)
1612
1231
  return !0;
1613
- const disables = [
1614
- DataValidationType.CHECKBOX,
1615
- DataValidationType.LIST,
1616
- DataValidationType.LIST_MULTIPLE
1232
+ const i = [
1233
+ St.CHECKBOX,
1234
+ St.LIST,
1235
+ St.LIST_MULTIPLE
1617
1236
  ];
1618
- return !!(cell != null && cell.dataValidation && disables.includes(cell.dataValidation.rule.type));
1619
- }, "getShouldDisableCellLink"), getShouldDisableCurrentCellLink = /* @__PURE__ */ __name((accessor) => {
1620
- const unit = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1621
- if (!unit)
1237
+ return !!(r != null && r.dataValidation && i.includes(r.dataValidation.rule.type));
1238
+ }, ts = (t) => {
1239
+ const e = t.get(K).getCurrentUnitForType(O.UNIVER_SHEET);
1240
+ if (!e)
1622
1241
  return !0;
1623
- const worksheet = unit.getActiveSheet(), selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
1624
- if (!selections.length)
1242
+ const n = e.getActiveSheet(), r = t.get(Ot).getCurrentSelections();
1243
+ if (!r.length)
1625
1244
  return !0;
1626
- const row = selections[0].range.startRow, col = selections[0].range.startColumn;
1627
- return getShouldDisableCellLink(worksheet, row, col);
1628
- }, "getShouldDisableCurrentCellLink"), shouldDisableAddLink = /* @__PURE__ */ __name((accessor) => {
1629
- var _a15, _b;
1630
- const textSelectionService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), textRanges = textSelectionService.getDocRanges();
1631
- if (!textRanges.length || textRanges.length > 1)
1245
+ const i = r[0].range.startRow, o = r[0].range.startColumn;
1246
+ return Ht(n, i, o);
1247
+ }, ns = (t) => {
1248
+ var d, l;
1249
+ const e = t.get(Ue), n = t.get(K), r = e.getDocRanges();
1250
+ if (!r.length || r.length > 1)
1632
1251
  return !0;
1633
- const activeRange = textRanges[0], doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
1634
- if (!doc || !activeRange || activeRange.collapsed)
1252
+ const i = r[0], o = n.getCurrentUnitForType(O.UNIVER_DOC);
1253
+ if (!o || !i || i.collapsed)
1635
1254
  return !0;
1636
- const body = doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody();
1637
- if (!body)
1255
+ const s = o.getSelfOrHeaderFooterModel(i.segmentId).getBody();
1256
+ if (!s)
1638
1257
  return !0;
1639
- const paragraphs = (_a15 = body == null ? void 0 : body.paragraphs) != null ? _a15 : [];
1640
- for (let i = 0, len = paragraphs.length; i < len; i++) {
1641
- const p2 = paragraphs[i];
1642
- if (activeRange.startOffset <= p2.startIndex && activeRange.endOffset > p2.startIndex)
1258
+ const c = (d = s == null ? void 0 : s.paragraphs) != null ? d : [];
1259
+ for (let g = 0, p = c.length; g < p; g++) {
1260
+ const v = c[g];
1261
+ if (i.startOffset <= v.startIndex && i.endOffset > v.startIndex)
1643
1262
  return !0;
1644
- if (p2.startIndex > activeRange.endOffset)
1263
+ if (v.startIndex > i.endOffset)
1645
1264
  break;
1646
1265
  }
1647
- return !BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(activeRange, (_b = body.customRanges) != null ? _b : []).every((range) => range.rangeType === CustomRangeType.HYPERLINK);
1648
- }, "shouldDisableAddLink"), OpenHyperLinkEditPanelOperation = {
1649
- type: CommandType.OPERATION,
1266
+ return !de.customRange.getCustomRangesInterestsWithSelection(i, (l = s.customRanges) != null ? l : []).every((g) => g.rangeType === Me.HYPERLINK);
1267
+ }, Dt = {
1268
+ type: ot.OPERATION,
1650
1269
  id: "sheet.operation.open-hyper-link-edit-panel",
1651
- handler(accessor, params) {
1652
- if (!params)
1270
+ handler(t, e) {
1271
+ if (!e)
1653
1272
  return !1;
1654
- const popupService = accessor.get(SheetsHyperLinkPopupService);
1655
- return params.customRangeId ? popupService.startEditing(params) : popupService.startAddEditing(params), !0;
1273
+ const n = t.get(G);
1274
+ return e.customRangeId ? n.startEditing(e) : n.startAddEditing(e), !0;
1656
1275
  }
1657
- }, CloseHyperLinkPopupOperation = {
1658
- type: CommandType.OPERATION,
1276
+ }, Ke = {
1277
+ type: ot.OPERATION,
1659
1278
  id: "sheet.operation.close-hyper-link-popup",
1660
- handler(accessor) {
1661
- return accessor.get(SheetsHyperLinkPopupService).endEditing(), !0;
1279
+ handler(t) {
1280
+ return t.get(G).endEditing(), !0;
1662
1281
  }
1663
- }, InsertHyperLinkOperation = {
1664
- type: CommandType.OPERATION,
1282
+ }, $t = {
1283
+ type: ot.OPERATION,
1665
1284
  id: "sheet.operation.insert-hyper-link",
1666
- handler(accessor) {
1667
- var _a15;
1668
- const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService), editorBridgeService = accessor.get(IEditorBridgeService);
1669
- if (!target)
1285
+ handler(t) {
1286
+ var g;
1287
+ const e = t.get(K), n = bn(e), r = t.get(ne);
1288
+ if (!n)
1670
1289
  return !1;
1671
- const commandService = accessor.get(ICommandService), selection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
1672
- if (!selection)
1290
+ const i = t.get(re), s = t.get(Ot).getCurrentLastSelection();
1291
+ if (!s)
1673
1292
  return !1;
1674
- const row = selection.range.startRow, col = selection.range.startColumn, visible = editorBridgeService.isVisible(), isZenEditor = ((_a15 = univerInstanceService.getFocusedUnit()) == null ? void 0 : _a15.getUnitId()) === DOCS_ZEN_EDITOR_UNIT_ID_KEY;
1675
- return commandService.executeCommand(OpenHyperLinkEditPanelOperation.id, {
1676
- unitId: target.unitId,
1677
- subUnitId: target.subUnitId,
1678
- row,
1679
- col,
1680
- type: isZenEditor ? HyperLinkEditSourceType.ZEN_EDITOR : visible.visible ? HyperLinkEditSourceType.EDITING : HyperLinkEditSourceType.VIEWING
1293
+ const c = s.range.startRow, u = s.range.startColumn, d = r.isVisible(), l = ((g = e.getFocusedUnit()) == null ? void 0 : g.getUnitId()) === x;
1294
+ return i.executeCommand(Dt.id, {
1295
+ unitId: n.unitId,
1296
+ subUnitId: n.subUnitId,
1297
+ row: c,
1298
+ col: u,
1299
+ type: l ? f.ZEN_EDITOR : d.visible ? f.EDITING : f.VIEWING
1681
1300
  });
1682
1301
  }
1683
- }, InsertHyperLinkToolbarOperation = {
1684
- type: CommandType.OPERATION,
1302
+ }, pe = {
1303
+ type: ot.OPERATION,
1685
1304
  id: "sheet.operation.insert-hyper-link-toolbar",
1686
- handler(accessor) {
1687
- if (getShouldDisableCurrentCellLink(accessor))
1305
+ handler(t) {
1306
+ if (ts(t))
1688
1307
  return !1;
1689
- const commandService = accessor.get(ICommandService);
1690
- return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkPopupOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
1691
- }
1692
- }, getEditingLinkDisable$ = /* @__PURE__ */ __name((accessor, unitId = DOCS_ZEN_EDITOR_UNIT_ID_KEY) => {
1693
- var _a15;
1694
- const univerInstanceService = accessor.get(IUniverInstanceService), docSelctionService = (_a15 = accessor.get(IRenderManagerService).getRenderById(unitId)) == null ? void 0 : _a15.with(DocSelectionRenderService);
1695
- return docSelctionService ? docSelctionService.textSelectionInner$.pipe(map(() => {
1696
- const state = accessor.get(IEditorBridgeService).getEditCellState();
1697
- if (!state)
1308
+ const e = t.get(re);
1309
+ return t.get(G).currentEditing ? e.executeCommand(Ke.id) : e.executeCommand($t.id);
1310
+ }
1311
+ }, jt = (t, e = x) => {
1312
+ var i;
1313
+ const n = t.get(K), r = (i = t.get(ut).getRenderById(e)) == null ? void 0 : i.with(xn);
1314
+ return r ? r.textSelectionInner$.pipe(le(() => {
1315
+ const s = t.get(ne).getEditCellState();
1316
+ if (!s)
1698
1317
  return !0;
1699
- const target = getSheetCommandTarget(univerInstanceService, { unitId: state.unitId, subUnitId: state.sheetId });
1700
- return !(target != null && target.worksheet) || getShouldDisableCellLink(target.worksheet, state.row, state.column) ? !0 : shouldDisableAddLink(accessor);
1701
- })) : of(!0);
1702
- }, "getEditingLinkDisable$"), getLinkDisable$ = /* @__PURE__ */ __name((accessor) => {
1703
- 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(
1704
- filter((focused) => !!focused),
1705
- map((focused) => univerInstanceService.getUnit(focused, UniverInstanceType.UNIVER_SHEET)),
1706
- filter((unit) => !!unit),
1707
- switchMap((unit) => unit.activeSheet$),
1708
- switchMap((sheet) => sheetSelectionService.selectionMoveEnd$.pipe(map((selections) => sheet && { selections, sheet }))),
1709
- map((sheetWithSelection) => {
1710
- if (!sheetWithSelection)
1318
+ const c = bn(n, { unitId: s.unitId, subUnitId: s.sheetId });
1319
+ return !(c != null && c.worksheet) || Ht(c.worksheet, s.row, s.column) ? !0 : ns(t);
1320
+ })) : Te(!0);
1321
+ }, Fn = (t) => {
1322
+ const e = Or(t, { workbookTypes: [kt], worksheetTypes: [Tt, wn, xt], rangeTypes: [Nt] }, !0), n = t.get(K), r = t.get(Ot), i = t.has(ne) ? t.get(ne) : null, o = n.focused$.pipe(
1323
+ ln((s) => !!s),
1324
+ le((s) => n.getUnit(s, O.UNIVER_SHEET)),
1325
+ ln((s) => !!s),
1326
+ ue((s) => s.activeSheet$),
1327
+ ue((s) => r.selectionMoveEnd$.pipe(le((c) => s && { selections: c, sheet: s }))),
1328
+ le((s) => {
1329
+ if (!s)
1711
1330
  return !0;
1712
- const { selections, sheet } = sheetWithSelection;
1713
- if (!selections.length)
1331
+ const { selections: c, sheet: u } = s;
1332
+ if (!c.length)
1714
1333
  return !0;
1715
- const row = selections[0].range.startRow, col = selections[0].range.startColumn;
1716
- if (getShouldDisableCellLink(sheet, row, col))
1334
+ const d = c[0].range.startRow, l = c[0].range.startColumn;
1335
+ if (Ht(u, d, l))
1717
1336
  return !0;
1718
1337
  }),
1719
- switchMap((disableCell) => disableCell ? of(!0) : (editorBridgeService ? editorBridgeService.visible$ : of(null)).pipe(map((visible) => visible != null && visible.visible ? DOCS_NORMAL_EDITOR_UNIT_ID_KEY : void 0)).pipe(
1720
- switchMap(
1721
- (editing) => editing ? getEditingLinkDisable$(accessor, editing) : of(!1)
1722
- )
1723
- ))
1338
+ ue((s) => {
1339
+ if (s)
1340
+ return Te(!0);
1341
+ const c = (i ? i.visible$ : Te(null)).pipe(le((d) => d != null && d.visible ? yt : void 0)), u = t.get(In).subscribeContextValue$(ar);
1342
+ return ci([c, u]).pipe(
1343
+ ue(
1344
+ ([d, l]) => d ? l ? Te(!0) : jt(t, d) : Te(!1)
1345
+ )
1346
+ );
1347
+ })
1724
1348
  );
1725
- return disableRange$.pipe(
1726
- distinctUntilChanged(),
1727
- switchMap((disableRange) => disableCell$.pipe(map((disableCell) => disableRange || disableCell)))
1349
+ return e.pipe(
1350
+ li(),
1351
+ ue((s) => o.pipe(le((c) => s || c)))
1728
1352
  );
1729
- }, "getLinkDisable$"), linkMenu = {
1730
- commandId: InsertHyperLinkOperation.id,
1731
- type: MenuItemType.BUTTON,
1732
- positions: [MenuPosition.CONTEXT_MENU],
1353
+ }, ze = {
1354
+ commandId: $t.id,
1355
+ type: kn.BUTTON,
1356
+ positions: [Tn.CONTEXT_MENU],
1733
1357
  title: "hyperLink.menu.add",
1734
1358
  icon: "LinkSingle"
1735
- }, genZenEditorMenuId = /* @__PURE__ */ __name((id) => `${id}-zen-editor`, "genZenEditorMenuId"), insertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
1736
- ...linkMenu,
1737
- id: linkMenu.commandId,
1738
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1739
- disabled$: getLinkDisable$(accessor)
1359
+ }, Ye = (t) => `${t}-zen-editor`, rs = (t) => ({
1360
+ ...ze,
1361
+ id: ze.commandId,
1362
+ hidden$: lt(t, O.UNIVER_SHEET),
1363
+ disabled$: Fn(t)
1740
1364
  // disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
1741
- }), "insertLinkMenuFactory"), zenEditorInsertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
1742
- ...linkMenu,
1743
- id: genZenEditorMenuId(linkMenu.commandId),
1744
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
1745
- disabled$: getEditingLinkDisable$(accessor)
1746
- }), "zenEditorInsertLinkMenuFactory"), linkToolbarMenu = {
1365
+ }), is = (t) => ({
1366
+ ...ze,
1367
+ id: Ye(ze.commandId),
1368
+ hidden$: lt(t, O.UNIVER_DOC, x),
1369
+ disabled$: jt(t)
1370
+ }), Xe = {
1747
1371
  tooltip: "hyperLink.form.addTitle",
1748
- positions: MenuPosition.TOOLBAR_START,
1749
- group: MenuGroup.TOOLBAR_OTHERS,
1750
- commandId: InsertHyperLinkToolbarOperation.id,
1751
- type: MenuItemType.BUTTON,
1372
+ positions: Tn.TOOLBAR_START,
1373
+ group: Yr.TOOLBAR_OTHERS,
1374
+ commandId: pe.id,
1375
+ type: kn.BUTTON,
1752
1376
  icon: "LinkSingle"
1753
- }, insertLinkMenuToolbarFactory = /* @__PURE__ */ __name((accessor) => ({
1754
- ...linkToolbarMenu,
1755
- id: linkToolbarMenu.commandId,
1756
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1757
- disabled$: getLinkDisable$(accessor)
1758
- }), "insertLinkMenuToolbarFactory"), zenEditorInsertLinkMenuToolbarFactory = /* @__PURE__ */ __name((accessor) => ({
1759
- ...linkToolbarMenu,
1760
- id: genZenEditorMenuId(linkToolbarMenu.commandId),
1761
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
1762
- disabled$: getEditingLinkDisable$(accessor)
1763
- }), "zenEditorInsertLinkMenuToolbarFactory"), InsertLinkShortcut = {
1764
- id: InsertHyperLinkToolbarOperation.id,
1765
- binding: KeyCode.K | MetaKeys.CTRL_COMMAND,
1766
- preconditions: whenSheetEditorFocused
1377
+ }, ss = (t) => ({
1378
+ ...Xe,
1379
+ id: Xe.commandId,
1380
+ hidden$: lt(t, O.UNIVER_SHEET),
1381
+ disabled$: Fn(t)
1382
+ }), os = (t) => ({
1383
+ ...Xe,
1384
+ id: Ye(Xe.commandId),
1385
+ hidden$: lt(t, O.UNIVER_DOC, x),
1386
+ disabled$: jt(t)
1387
+ }), Wn = {
1388
+ id: pe.id,
1389
+ binding: Rt.K | Xr.CTRL_COMMAND,
1390
+ preconditions: wr
1767
1391
  };
1768
- var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1769
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1770
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1771
- return kind && result && __defProp$9(target, key, result), result;
1772
- }, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9"), _a4;
1773
- let SheetsHyperLinkAutoFillController = (_a4 = class extends Disposable {
1774
- constructor(_autoFillService, _hyperLinkModel) {
1775
- super(), this._autoFillService = _autoFillService, this._hyperLinkModel = _hyperLinkModel, this._initAutoFill();
1392
+ var as = Object.defineProperty, cs = Object.getOwnPropertyDescriptor, ls = (t, e, n, r) => {
1393
+ for (var i = r > 1 ? void 0 : r ? cs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1394
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
1395
+ return r && i && as(e, n, i), i;
1396
+ }, mn = (t, e) => (n, r) => e(n, r, t);
1397
+ let qe = class extends z {
1398
+ constructor(t, e) {
1399
+ super(), this._autoFillService = t, this._hyperLinkModel = e, this._initAutoFill();
1776
1400
  }
1777
1401
  // eslint-disable-next-line max-lines-per-function
1778
1402
  _initAutoFill() {
1779
- const noopReturnFunc = /* @__PURE__ */ __name(() => ({ redos: [], undos: [] }), "noopReturnFunc"), generalApplyFunc = /* @__PURE__ */ __name((location2, applyType) => {
1780
- const { source: sourceRange, target: targetRange, unitId, subUnitId } = location2, virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]), [vSourceRange, vTargetRange] = virtualRange.ranges, { mapFunc } = virtualRange, sourceStartCell = {
1781
- row: vSourceRange.startRow,
1782
- col: vSourceRange.startColumn
1783
- }, repeats = getAutoFillRepeatRange(vSourceRange, vTargetRange), redos = [], undos = [];
1784
- return repeats.forEach((repeat) => {
1785
- const targetStartCell = repeat.repeatStartCell, relativeRange = repeat.relativeRange, sourceRange2 = {
1786
- startRow: sourceStartCell.row,
1787
- startColumn: sourceStartCell.col,
1788
- endColumn: sourceStartCell.col,
1789
- endRow: sourceStartCell.row
1790
- }, targetRange2 = {
1791
- startRow: targetStartCell.row,
1792
- startColumn: targetStartCell.col,
1793
- endColumn: targetStartCell.col,
1794
- endRow: targetStartCell.row
1403
+ const t = () => ({ redos: [], undos: [] }), e = (r, i) => {
1404
+ const { source: o, target: s, unitId: c, subUnitId: u } = r, d = Et([o, s]), [l, g] = d.ranges, { mapFunc: p } = d, v = {
1405
+ row: l.startRow,
1406
+ col: l.startColumn
1407
+ }, C = Tr(l, g), _ = [], b = [];
1408
+ return C.forEach((a) => {
1409
+ const w = a.repeatStartCell, M = a.relativeRange, P = {
1410
+ startRow: v.row,
1411
+ startColumn: v.col,
1412
+ endColumn: v.col,
1413
+ endRow: v.row
1414
+ }, k = {
1415
+ startRow: w.row,
1416
+ startColumn: w.col,
1417
+ endColumn: w.col,
1418
+ endRow: w.row
1795
1419
  };
1796
- Range.foreach(relativeRange, (row, col) => {
1797
- const sourcePositionRange = Rectangle.getPositionRange(
1420
+ Cn.foreach(M, (q, D) => {
1421
+ const ie = Ie.getPositionRange(
1798
1422
  {
1799
- startRow: row,
1800
- startColumn: col,
1801
- endColumn: col,
1802
- endRow: row
1423
+ startRow: q,
1424
+ startColumn: D,
1425
+ endColumn: D,
1426
+ endRow: q
1803
1427
  },
1804
- sourceRange2
1805
- ), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol), targetPositionRange = Rectangle.getPositionRange(
1428
+ P
1429
+ ), { row: ye, col: He } = p(ie.startRow, ie.startColumn), se = this._hyperLinkModel.getHyperLinkByLocation(c, u, ye, He), Ee = Ie.getPositionRange(
1806
1430
  {
1807
- startRow: row,
1808
- startColumn: col,
1809
- endColumn: col,
1810
- endRow: row
1431
+ startRow: q,
1432
+ startColumn: D,
1433
+ endColumn: D,
1434
+ endRow: q
1811
1435
  },
1812
- targetRange2
1813
- ), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn), id = Tools.generateRandomId(), currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
1814
- currentLink && redos.push({
1815
- id: RemoveHyperLinkMutation.id,
1436
+ k
1437
+ ), { row: Re, col: Pe } = p(Ee.startRow, Ee.startColumn), oe = Ce.generateRandomId(), j = this._hyperLinkModel.getHyperLinkByLocation(c, u, Re, Pe);
1438
+ j && _.push({
1439
+ id: xe.id,
1816
1440
  params: {
1817
- unitId,
1818
- subUnitId,
1819
- id: currentLink.id
1441
+ unitId: c,
1442
+ subUnitId: u,
1443
+ id: j.id
1820
1444
  }
1821
- }), (APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) && link && (redos.push({
1822
- id: AddHyperLinkMutation.id,
1445
+ }), (we.COPY === i || we.SERIES === i) && se && (_.push({
1446
+ id: Ne.id,
1823
1447
  params: {
1824
- unitId,
1825
- subUnitId,
1448
+ unitId: c,
1449
+ subUnitId: u,
1826
1450
  link: {
1827
- ...link,
1828
- id,
1829
- row: targetRow,
1830
- column: targetCol
1451
+ ...se,
1452
+ id: oe,
1453
+ row: Re,
1454
+ column: Pe
1831
1455
  }
1832
1456
  }
1833
- }), undos.push({
1834
- id: RemoveHyperLinkMutation.id,
1457
+ }), b.push({
1458
+ id: xe.id,
1835
1459
  params: {
1836
- unitId,
1837
- subUnitId,
1838
- id
1460
+ unitId: c,
1461
+ subUnitId: u,
1462
+ id: oe
1839
1463
  }
1840
- })), currentLink && undos.push({
1841
- id: AddHyperLinkMutation.id,
1464
+ })), j && b.push({
1465
+ id: Ne.id,
1842
1466
  params: {
1843
- unitId,
1844
- subUnitId,
1845
- link: currentLink
1467
+ unitId: c,
1468
+ subUnitId: u,
1469
+ link: j
1846
1470
  }
1847
1471
  });
1848
1472
  });
1849
1473
  }), {
1850
- undos,
1851
- redos
1474
+ undos: b,
1475
+ redos: _
1852
1476
  };
1853
- }, "generalApplyFunc"), hook = {
1854
- id: SHEET_HYPER_LINK_UI_PLUGIN,
1855
- onFillData: /* @__PURE__ */ __name((location2, direction, applyType) => applyType === APPLY_TYPE.COPY || applyType === APPLY_TYPE.ONLY_FORMAT || applyType === APPLY_TYPE.SERIES ? generalApplyFunc(location2, applyType) : noopReturnFunc(), "onFillData")
1477
+ }, n = {
1478
+ id: Mt,
1479
+ onFillData: (r, i, o) => o === we.COPY || o === we.ONLY_FORMAT || o === we.SERIES ? e(r, o) : t()
1856
1480
  };
1857
- this.disposeWithMe(this._autoFillService.addHook(hook));
1858
- }
1859
- }, __name(_a4, "SheetsHyperLinkAutoFillController"), _a4);
1860
- SheetsHyperLinkAutoFillController = __decorateClass$9([
1861
- __decorateParam$9(0, IAutoFillService),
1862
- __decorateParam$9(1, Inject(HyperLinkModel))
1863
- ], SheetsHyperLinkAutoFillController);
1864
- var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1865
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1866
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1867
- return kind && result && __defProp$8(target, key, result), result;
1868
- }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a5;
1869
- let SheetsHyperLinkPermissionController = (_a5 = class extends Disposable {
1870
- constructor(_localeService, _commandService, _sheetPermissionInterceptorBaseController) {
1871
- super(), this._localeService = _localeService, this._commandService = _commandService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._commandExecutedListener();
1481
+ this.disposeWithMe(this._autoFillService.addHook(n));
1482
+ }
1483
+ };
1484
+ qe = ls([
1485
+ mn(0, kr),
1486
+ mn(1, R(at))
1487
+ ], qe);
1488
+ var us = Object.defineProperty, ds = Object.getOwnPropertyDescriptor, ps = (t, e, n, r) => {
1489
+ for (var i = r > 1 ? void 0 : r ? ds(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1490
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
1491
+ return r && i && us(e, n, i), i;
1492
+ }, It = (t, e) => (n, r) => e(n, r, t);
1493
+ let Je = class extends z {
1494
+ constructor(t, e, n) {
1495
+ super(), this._localeService = t, this._commandService = e, this._sheetPermissionInterceptorBaseController = n, this._commandExecutedListener();
1872
1496
  }
1873
1497
  _commandExecutedListener() {
1874
1498
  this.disposeWithMe(
1875
- this._commandService.beforeCommandExecuted((command) => {
1876
- command.id === InsertLinkShortcut.id && (this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1877
- workbookTypes: [WorkbookEditablePermission],
1878
- rangeTypes: [RangeProtectionPermissionEditPoint],
1879
- worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission]
1499
+ this._commandService.beforeCommandExecuted((t) => {
1500
+ t.id === Wn.id && (this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1501
+ workbookTypes: [kt],
1502
+ rangeTypes: [Nt],
1503
+ worksheetTypes: [Tt, wn, xt]
1880
1504
  }) || this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")));
1881
1505
  })
1882
1506
  );
1883
1507
  }
1884
- }, __name(_a5, "SheetsHyperLinkPermissionController"), _a5);
1885
- SheetsHyperLinkPermissionController = __decorateClass$8([
1886
- __decorateParam$8(0, Inject(LocaleService)),
1887
- __decorateParam$8(1, ICommandService),
1888
- __decorateParam$8(2, Inject(SheetPermissionInterceptorBaseController))
1889
- ], SheetsHyperLinkPermissionController);
1890
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1891
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1892
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1893
- return kind && result && __defProp$7(target, key, result), result;
1894
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a6;
1895
- let SheetsHyperLinkPopupController = (_a6 = class extends Disposable {
1896
- constructor(_hoverManagerService, _sheetsHyperLinkPopupService, _renderManagerService, _permissionService, _sheetPermissionInterceptorBaseController, _commandService, _editorBridgeService, _textSelectionManagerService, _univerInstanceService, _zenZoneService) {
1897
- super(), this._hoverManagerService = _hoverManagerService, this._sheetsHyperLinkPopupService = _sheetsHyperLinkPopupService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, 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();
1898
- }
1899
- _getLinkPermission(location2) {
1900
- const { unitId, subUnitId, row: currentRow, col: currentCol } = location2, workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
1901
- if (!(workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId)))
1508
+ };
1509
+ Je = ps([
1510
+ It(0, R(it)),
1511
+ It(1, re),
1512
+ It(2, R(En))
1513
+ ], Je);
1514
+ var hs = Object.defineProperty, gs = Object.getOwnPropertyDescriptor, ms = (t, e, n, r) => {
1515
+ for (var i = r > 1 ? void 0 : r ? gs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1516
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
1517
+ return r && i && hs(e, n, i), i;
1518
+ }, Z = (t, e) => (n, r) => e(n, r, t);
1519
+ let Qe = class extends z {
1520
+ constructor(t, e, n, r, i, o, s, c, u, d) {
1521
+ super(), this._hoverManagerService = t, this._sheetsHyperLinkPopupService = e, this._renderManagerService = n, this._permissionService = r, this._sheetPermissionInterceptorBaseController = i, this._commandService = o, this._editorBridgeService = s, this._textSelectionManagerService = c, this._univerInstanceService = u, this._zenZoneService = d, this._initHoverListener(), this._initCommandListener(), this._initHoverEditingListener(), this._initTextSelectionListener(), this._initZenEditor();
1522
+ }
1523
+ _getLinkPermission(t) {
1524
+ const { unitId: e, subUnitId: n, row: r, col: i } = t, o = this._univerInstanceService.getUnit(e, O.UNIVER_SHEET);
1525
+ if (!(o == null ? void 0 : o.getSheetBySheetId(n)))
1902
1526
  return {
1903
1527
  viewPermission: !1,
1904
1528
  editPermission: !1,
1905
1529
  copyPermission: !1
1906
1530
  };
1907
- const viewPermission = this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1908
- workbookTypes: [WorkbookViewPermission],
1909
- worksheetTypes: [WorksheetViewPermission],
1910
- rangeTypes: [RangeProtectionPermissionViewPoint]
1911
- }, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }]), editPermission = this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1912
- workbookTypes: [WorkbookEditablePermission],
1913
- worksheetTypes: [WorksheetEditPermission, WorksheetInsertHyperlinkPermission],
1914
- rangeTypes: [RangeProtectionPermissionEditPoint]
1915
- }, [{ 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);
1531
+ const c = this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1532
+ workbookTypes: [Dr],
1533
+ worksheetTypes: [$r],
1534
+ rangeTypes: [jr]
1535
+ }, [{ startRow: r, startColumn: i, endRow: r, endColumn: i }]), u = this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1536
+ workbookTypes: [kt],
1537
+ worksheetTypes: [Tt, xt],
1538
+ rangeTypes: [Nt]
1539
+ }, [{ startRow: r, startColumn: i, endRow: r, endColumn: i }]), d = this._permissionService.composePermission([new Vr(e).id, new Br(e, n).id]).every((l) => l.value);
1916
1540
  return {
1917
- viewPermission,
1918
- editPermission,
1919
- copyPermission
1541
+ viewPermission: c,
1542
+ editPermission: u,
1543
+ copyPermission: d
1920
1544
  };
1921
1545
  }
1922
1546
  _initHoverListener() {
1923
1547
  this.disposeWithMe(
1924
1548
  // hover over not editing cell
1925
- this._hoverManagerService.currentRichText$.pipe(debounceTime(200)).subscribe((currentCell) => {
1926
- var _a15;
1927
- if (!currentCell) {
1549
+ this._hoverManagerService.currentRichText$.pipe(Be(200)).subscribe((t) => {
1550
+ var P;
1551
+ if (!t) {
1928
1552
  this._sheetsHyperLinkPopupService.hideCurrentPopup();
1929
1553
  return;
1930
1554
  }
1931
- const { unitId, subUnitId, row, col } = currentCell, renderer = this._renderManagerService.getRenderById(unitId);
1932
- if (!renderer)
1555
+ const { unitId: e, subUnitId: n, row: r, col: i } = t, o = this._renderManagerService.getRenderById(e);
1556
+ if (!o)
1557
+ return;
1558
+ const s = this._univerInstanceService.getUnit(e, O.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(n);
1559
+ if (!c)
1933
1560
  return;
1934
- if (!renderer.with(HoverRenderController).active) {
1935
- this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING);
1561
+ if (!o.with(Nr).active) {
1562
+ this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING);
1936
1563
  return;
1937
1564
  }
1938
- const skeleton = (_a15 = renderer == null ? void 0 : renderer.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _a15.skeleton, currentCol = col, currentRow = row;
1939
- let targetRow = currentRow, targetCol = currentCol;
1940
- skeleton && skeleton.overflowCache.forValue((row2, col2, value) => {
1941
- Rectangle.contains(value, { startColumn: currentCol, endColumn: currentCol, startRow: currentRow, endRow: currentRow }) && (targetRow = row2, targetCol = col2);
1565
+ const d = (P = o == null ? void 0 : o.with(sn).getWorksheetSkeleton(n)) == null ? void 0 : P.skeleton, l = i, g = r;
1566
+ let p = g, v = l;
1567
+ d && d.overflowCache.forValue((k, q, D) => {
1568
+ Ie.contains(D, { startColumn: l, endColumn: l, startRow: g, endRow: g }) && (p = k, v = q);
1942
1569
  });
1943
- const { viewPermission, editPermission, copyPermission } = this._getLinkPermission(currentCell);
1944
- if (!viewPermission || !currentCell.customRange) {
1570
+ const { viewPermission: C, editPermission: _, copyPermission: b } = this._getLinkPermission(t);
1571
+ if (!C) {
1572
+ this._sheetsHyperLinkPopupService.hideCurrentPopup();
1573
+ return;
1574
+ }
1575
+ const a = c.getCellStyleOnly(p, v), w = s.getStyles().getStyleByCell(a), M = w == null ? void 0 : w.tr;
1576
+ if (!M && !t.customRange) {
1945
1577
  this._sheetsHyperLinkPopupService.hideCurrentPopup();
1946
1578
  return;
1947
1579
  }
1948
1580
  this._sheetsHyperLinkPopupService.showPopup({
1949
- row: targetRow,
1950
- col: targetCol,
1951
- editPermission,
1952
- copyPermission,
1953
- customRange: currentCell.customRange,
1954
- customRangeRect: currentCell.rect,
1955
- type: HyperLinkEditSourceType.VIEWING,
1956
- unitId,
1957
- subUnitId
1581
+ row: p,
1582
+ col: v,
1583
+ editPermission: _,
1584
+ copyPermission: b,
1585
+ customRange: t.customRange,
1586
+ customRangeRect: t.rect,
1587
+ type: f.VIEWING,
1588
+ unitId: e,
1589
+ subUnitId: n,
1590
+ showAll: !!M
1958
1591
  });
1959
1592
  })
1960
1593
  );
1961
1594
  }
1962
1595
  _initHoverEditingListener() {
1963
- let subscribe = null;
1596
+ let t = null;
1964
1597
  this.disposeWithMe(
1965
- this._editorBridgeService.currentEditCellState$.pipe(switchMap((state) => this._editorBridgeService.visible$.pipe(map((visible) => ({ visible, state }))))).subscribe(({ visible, state }) => {
1966
- if (!state || state.editorUnitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY)
1598
+ this._editorBridgeService.currentEditCellState$.pipe(ue((e) => this._editorBridgeService.visible$.pipe(le((n) => ({ visible: n, state: e }))))).subscribe(({ visible: e, state: n }) => {
1599
+ if (!n || n.editorUnitId !== yt)
1967
1600
  return;
1968
- if (!visible.visible) {
1969
- subscribe == null || subscribe.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING), this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING);
1601
+ if (!e.visible) {
1602
+ t == null || t.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(f.EDITING), this._sheetsHyperLinkPopupService.endEditing(f.EDITING);
1970
1603
  return;
1971
1604
  }
1972
- const { editorUnitId, unitId, sheetId, row, column } = state, renderer = this._renderManagerService.getRenderById(editorUnitId);
1973
- if (!renderer)
1605
+ const { editorUnitId: r, unitId: i, sheetId: o, row: s, column: c } = n, u = this._renderManagerService.getRenderById(r);
1606
+ if (!u)
1974
1607
  return;
1975
- const { editPermission, viewPermission, copyPermission } = this._getLinkPermission({ unitId, subUnitId: sheetId, row, col: column }), docEventService = renderer.with(DocEventManagerService);
1976
- viewPermission && (subscribe == null || subscribe.unsubscribe(), subscribe = docEventService.hoverCustomRanges$.pipe(debounceTime(200)).subscribe((customRanges) => {
1977
- var _a15, _b;
1978
- const customRange = customRanges.find((customRange2) => customRange2.range.rangeType === CustomRangeType.HYPERLINK);
1979
- if (!customRange) {
1608
+ const { editPermission: d, viewPermission: l, copyPermission: g } = this._getLinkPermission({ unitId: i, subUnitId: o, row: s, col: c }), p = u.with(cn);
1609
+ l && (t == null || t.unsubscribe(), t = p.hoverCustomRanges$.pipe(Be(200)).subscribe((v) => {
1610
+ var w, M;
1611
+ const C = v.find((P) => P.range.rangeType === Me.HYPERLINK);
1612
+ if (!C) {
1980
1613
  this._sheetsHyperLinkPopupService.hideCurrentPopup();
1981
1614
  return;
1982
1615
  }
1983
- const rect = customRange.rects[customRange.rects.length - 1];
1984
- if (!((_b = (_a15 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a15.with(SheetSkeletonManagerService).getWorksheetSkeleton(sheetId)) == null ? void 0 : _b.skeleton) || !rect)
1616
+ const _ = C.rects[C.rects.length - 1];
1617
+ if (!((M = (w = this._renderManagerService.getRenderById(i)) == null ? void 0 : w.with(sn).getWorksheetSkeleton(o)) == null ? void 0 : M.skeleton) || !_)
1985
1618
  return;
1986
- const canvasClientRect = renderer.engine.getCanvasElement().getBoundingClientRect();
1619
+ const a = u.engine.getCanvasElement().getBoundingClientRect();
1987
1620
  this._sheetsHyperLinkPopupService.showPopup({
1988
- unitId,
1989
- subUnitId: sheetId,
1990
- row,
1991
- col: column,
1992
- customRange: customRange.range,
1621
+ unitId: i,
1622
+ subUnitId: o,
1623
+ row: s,
1624
+ col: c,
1625
+ customRange: C.range,
1993
1626
  customRangeRect: {
1994
- left: rect.left + canvasClientRect.left,
1995
- top: rect.top + canvasClientRect.top,
1996
- bottom: rect.bottom + canvasClientRect.top,
1997
- right: rect.right + canvasClientRect.left
1627
+ left: _.left + a.left,
1628
+ top: _.top + a.top,
1629
+ bottom: _.bottom + a.top,
1630
+ right: _.right + a.left
1998
1631
  },
1999
- editPermission,
2000
- copyPermission,
2001
- type: HyperLinkEditSourceType.EDITING
1632
+ editPermission: d,
1633
+ copyPermission: g,
1634
+ type: f.EDITING
2002
1635
  });
2003
1636
  }));
2004
1637
  })
2005
1638
  ), this.disposeWithMe(() => {
2006
- subscribe == null || subscribe.unsubscribe();
1639
+ t == null || t.unsubscribe();
2007
1640
  });
2008
1641
  }
2009
1642
  _initZenEditor() {
2010
1643
  this.disposeWithMe(
2011
- this._zenZoneService.visible$.subscribe((visible) => {
2012
- 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
+ this._zenZoneService.visible$.subscribe((t) => {
1645
+ t ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(f.EDITING), this._sheetsHyperLinkPopupService.endEditing(f.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(f.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(f.ZEN_EDITOR));
2013
1646
  })
2014
1647
  ), this.disposeWithMe(
2015
1648
  this._univerInstanceService.focused$.pipe(
2016
- switchMap((id) => {
2017
- const render2 = id === DOCS_ZEN_EDITOR_UNIT_ID_KEY ? this._renderManagerService.getRenderById(id) : null;
2018
- return render2 ? render2.with(DocEventManagerService).hoverCustomRanges$.pipe(debounceTime(200)) : new Observable((sub) => {
2019
- sub.next(null);
1649
+ ue((t) => {
1650
+ const e = t === x ? this._renderManagerService.getRenderById(t) : null;
1651
+ return e ? e.with(cn).hoverCustomRanges$.pipe(Be(200)) : new ui((n) => {
1652
+ n.next(null);
2020
1653
  });
2021
1654
  })
2022
- ).subscribe((value) => {
2023
- const range = value == null ? void 0 : value.find((range2) => range2.range.rangeType === CustomRangeType.HYPERLINK), state = this._editorBridgeService.getEditCellState();
2024
- if (range && state) {
2025
- const { unitId, sheetId, row, column } = state, { editPermission, viewPermission, copyPermission } = this._getLinkPermission({ unitId, subUnitId: sheetId, row, col: column });
2026
- viewPermission && this._sheetsHyperLinkPopupService.showPopup({
2027
- type: HyperLinkEditSourceType.ZEN_EDITOR,
2028
- unitId,
2029
- subUnitId: sheetId,
2030
- row,
2031
- col: column,
2032
- customRange: range.range,
2033
- editPermission,
2034
- copyPermission
1655
+ ).subscribe((t) => {
1656
+ const e = t == null ? void 0 : t.find((r) => r.range.rangeType === Me.HYPERLINK), n = this._editorBridgeService.getEditCellState();
1657
+ if (e && n) {
1658
+ const { unitId: r, sheetId: i, row: o, column: s } = n, { editPermission: c, viewPermission: u, copyPermission: d } = this._getLinkPermission({ unitId: r, subUnitId: i, row: o, col: s });
1659
+ u && this._sheetsHyperLinkPopupService.showPopup({
1660
+ type: f.ZEN_EDITOR,
1661
+ unitId: r,
1662
+ subUnitId: i,
1663
+ row: o,
1664
+ col: s,
1665
+ customRange: e.range,
1666
+ editPermission: c,
1667
+ copyPermission: d
2035
1668
  });
2036
1669
  } else
2037
- this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.ZEN_EDITOR);
1670
+ this._sheetsHyperLinkPopupService.hideCurrentPopup(f.ZEN_EDITOR);
2038
1671
  })
2039
1672
  );
2040
1673
  }
2041
1674
  _initTextSelectionListener() {
2042
1675
  this.disposeWithMe(
2043
- this._textSelectionManagerService.textSelection$.subscribe((selection) => {
2044
- selection && selection.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY && this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING);
1676
+ this._textSelectionManagerService.textSelection$.subscribe((t) => {
1677
+ t && t.unitId === yt && this._sheetsHyperLinkPopupService.endEditing(f.EDITING);
2045
1678
  })
2046
1679
  );
2047
1680
  }
2048
1681
  _initCommandListener() {
2049
- const HIDE_COMMAND_LIST = [ClearSelectionContentCommand.id, ClearSelectionAllCommand.id, ClearSelectionFormatCommand.id];
2050
- this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
2051
- HIDE_COMMAND_LIST.includes(command.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
1682
+ const t = [Ar.id, Fr.id, Wr.id];
1683
+ this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
1684
+ t.includes(e.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
2052
1685
  }));
2053
1686
  }
2054
- }, __name(_a6, "SheetsHyperLinkPopupController"), _a6);
2055
- SheetsHyperLinkPopupController = __decorateClass$7([
2056
- __decorateParam$7(0, Inject(HoverManagerService)),
2057
- __decorateParam$7(1, Inject(SheetsHyperLinkPopupService)),
2058
- __decorateParam$7(2, Inject(IRenderManagerService)),
2059
- __decorateParam$7(3, Inject(IPermissionService)),
2060
- __decorateParam$7(4, Inject(SheetPermissionInterceptorBaseController)),
2061
- __decorateParam$7(5, ICommandService),
2062
- __decorateParam$7(6, IEditorBridgeService),
2063
- __decorateParam$7(7, Inject(DocSelectionManagerService)),
2064
- __decorateParam$7(8, IUniverInstanceService),
2065
- __decorateParam$7(9, IZenZoneService)
2066
- ], SheetsHyperLinkPopupController);
2067
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2068
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2069
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2070
- return kind && result && __defProp$6(target, key, result), result;
2071
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a7;
2072
- let SheetsHyperLinkRemoveSheetController = (_a7 = class extends Disposable {
2073
- constructor(_sheetInterceptorService, _univerInstanceService, _hyperLinkModel) {
2074
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._hyperLinkModel = _hyperLinkModel, this._initSheetChange();
2075
- }
2076
- _initSheetChange() {
2077
- this.disposeWithMe(
2078
- this._sheetInterceptorService.interceptCommand({
2079
- getMutations: /* @__PURE__ */ __name((commandInfo) => {
2080
- var _a15;
2081
- if (commandInfo.id === RemoveSheetCommand.id) {
2082
- const params = commandInfo.params, workbook = params.unitId ? this._univerInstanceService.getUnit(params.unitId) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2083
- if (!workbook)
2084
- return { redos: [], undos: [] };
2085
- const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a15 = workbook.getActiveSheet()) == null ? void 0 : _a15.getSheetId());
2086
- if (!subUnitId)
2087
- return { redos: [], undos: [] };
2088
- const links = this._hyperLinkModel.getSubUnit(unitId, subUnitId), redos = links.map((link) => ({
2089
- id: RemoveHyperLinkMutation.id,
2090
- params: {
2091
- unitId,
2092
- subUnitId,
2093
- id: link.id
2094
- }
2095
- })), undos = links.map((link) => ({
2096
- id: AddHyperLinkMutation.id,
2097
- params: {
2098
- unitId,
2099
- subUnitId,
2100
- link
2101
- }
2102
- }));
2103
- return { redos, undos };
2104
- }
2105
- return { redos: [], undos: [] };
2106
- }, "getMutations")
2107
- })
2108
- );
2109
- }
2110
- }, __name(_a7, "SheetsHyperLinkRemoveSheetController"), _a7);
2111
- SheetsHyperLinkRemoveSheetController = __decorateClass$6([
2112
- __decorateParam$6(0, Inject(SheetInterceptorService)),
2113
- __decorateParam$6(1, IUniverInstanceService),
2114
- __decorateParam$6(2, Inject(HyperLinkModel))
2115
- ], SheetsHyperLinkRemoveSheetController);
2116
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2117
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2118
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2119
- return kind && result && __defProp$5(target, key, result), result;
2120
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a8;
2121
- let SheetsHyperLinkRenderController = (_a8 = class extends Disposable {
2122
- constructor(_context, _hyperLinkModel) {
2123
- super(), this._context = _context, this._hyperLinkModel = _hyperLinkModel, this._initSkeletonChange();
1687
+ };
1688
+ Qe = ms([
1689
+ Z(0, R(xr)),
1690
+ Z(1, R(G)),
1691
+ Z(2, R(ut)),
1692
+ Z(3, R(cr)),
1693
+ Z(4, R(En)),
1694
+ Z(5, re),
1695
+ Z(6, ne),
1696
+ Z(7, R(Ue)),
1697
+ Z(8, K),
1698
+ Z(9, ct)
1699
+ ], Qe);
1700
+ var fs = Object.defineProperty, vs = Object.getOwnPropertyDescriptor, Zn = (t, e, n, r) => {
1701
+ for (var i = r > 1 ? void 0 : r ? vs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1702
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
1703
+ return r && i && fs(e, n, i), i;
1704
+ }, Lt = (t, e) => (n, r) => e(n, r, t);
1705
+ let bt = class extends z {
1706
+ constructor(t, e) {
1707
+ super(), this._context = t, this._hyperLinkModel = e, this._initSkeletonChange();
2124
1708
  }
2125
1709
  _initSkeletonChange() {
2126
- const markSkeletonDirty = /* @__PURE__ */ __name(() => {
2127
- var _a15;
2128
- (_a15 = this._context.mainComponent) == null || _a15.makeForceDirty();
2129
- }, "markSkeletonDirty");
2130
- this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(debounceTime(16)).subscribe(() => {
2131
- markSkeletonDirty();
1710
+ const t = () => {
1711
+ var e;
1712
+ (e = this._context.mainComponent) == null || e.makeForceDirty();
1713
+ };
1714
+ this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(Be(16)).subscribe(() => {
1715
+ t();
2132
1716
  }));
2133
1717
  }
2134
- }, __name(_a8, "SheetsHyperLinkRenderController"), _a8);
2135
- SheetsHyperLinkRenderController = __decorateClass$5([
2136
- __decorateParam$5(1, Inject(HyperLinkModel))
2137
- ], SheetsHyperLinkRenderController);
2138
- var _a9;
2139
- let SheetsHyperLinkRenderManagerController = (_a9 = class extends Disposable {
2140
- constructor(_sheetInterceptorService, _hyperLinkModel) {
2141
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._hyperLinkModel = _hyperLinkModel, this._initViewModelIntercept();
1718
+ };
1719
+ bt = Zn([
1720
+ Lt(1, R(at))
1721
+ ], bt);
1722
+ let et = class extends z {
1723
+ constructor(t, e) {
1724
+ super(), this._sheetInterceptorService = t, this._hyperLinkModel = e, this._initViewModelIntercept();
2142
1725
  }
2143
1726
  _initViewModelIntercept() {
2144
1727
  this.disposeWithMe(
2145
1728
  this._sheetInterceptorService.intercept(
2146
- INTERCEPTOR_POINT.CELL_CONTENT,
1729
+ Gr.CELL_CONTENT,
2147
1730
  {
2148
- effect: InterceptorEffectEnum.Value,
1731
+ effect: lr.Value,
2149
1732
  priority: 100,
2150
- handler: /* @__PURE__ */ __name((cell, pos, next) => {
2151
- const { row, col, unitId, subUnitId } = pos, link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
2152
- return next(link ? {
2153
- ...cell,
2154
- linkUrl: link.payload,
2155
- linkId: link.id
2156
- } : cell);
2157
- }, "handler")
1733
+ handler: (t, e, n) => {
1734
+ const { row: r, col: i, unitId: o, subUnitId: s } = e, c = this._hyperLinkModel.getHyperLinkByLocation(o, s, r, i);
1735
+ return n(c ? {
1736
+ ...t,
1737
+ linkUrl: c.payload,
1738
+ linkId: c.id
1739
+ } : t);
1740
+ }
2158
1741
  }
2159
1742
  )
2160
1743
  );
2161
1744
  }
2162
- }, __name(_a9, "SheetsHyperLinkRenderManagerController"), _a9);
2163
- SheetsHyperLinkRenderManagerController = __decorateClass$5([
2164
- __decorateParam$5(0, Inject(SheetInterceptorService)),
2165
- __decorateParam$5(1, Inject(HyperLinkModel))
2166
- ], SheetsHyperLinkRenderManagerController);
2167
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2168
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2169
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2170
- return kind && result && __defProp$4(target, key, result), result;
2171
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a10;
2172
- let SheetsHyperLinkRichTextRefRangeController = (_a10 = class extends Disposable {
2173
- constructor(_commandService, _univerInstanceService, _refRangeService) {
2174
- super();
2175
- __publicField(this, "_refRangeMap", /* @__PURE__ */ new Map());
2176
- this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._refRangeService = _refRangeService, this._initWorkbookLoad(), this._initWorkbookUnload(), this._initSetRangesListener();
2177
- }
2178
- _enusreMap(unitId, subUnitId) {
2179
- let unitMap = this._refRangeMap.get(unitId);
2180
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._refRangeMap.set(unitId, unitMap));
2181
- let subUnitMap = unitMap.get(subUnitId);
2182
- return subUnitMap || (subUnitMap = new ObjectMatrix(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
2183
- }
2184
- _isLegalRangeUrl(unitId, payload) {
2185
- var _a15, _b, _c;
2186
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
2187
- if (!workbook)
2188
- return null;
2189
- if (payload && payload.startsWith("#")) {
2190
- const search = new URLSearchParams(payload.slice(1)), searchObj = {
2191
- gid: (_a15 = search.get("gid")) != null ? _a15 : "",
2192
- range: (_b = search.get("range")) != null ? _b : "",
2193
- rangeid: (_c = search.get("rangeid")) != null ? _c : ""
2194
- };
2195
- if (searchObj.range && searchObj.gid) {
2196
- const subUnitId = searchObj.gid, worksheet = workbook.getSheetBySheetId(subUnitId);
2197
- if (!worksheet)
2198
- return null;
2199
- const range = deserializeRangeWithSheet(searchObj.range).range;
2200
- if (isValidRange(range, worksheet) && searchObj.range !== ERROR_RANGE)
2201
- return range;
2202
- }
2203
- }
2204
- return null;
2205
- }
2206
- _registerRange(unitId, subUnitId, row, col, p2) {
2207
- var _a15, _b, _c, _d;
2208
- const map2 = this._enusreMap(unitId, subUnitId);
2209
- if ((_b = (_a15 = p2.body) == null ? void 0 : _a15.customRanges) != null && _b.some((customRange) => {
2210
- var _a16;
2211
- return customRange.rangeType === CustomRangeType.HYPERLINK && this._isLegalRangeUrl(unitId, (_a16 = customRange.properties) == null ? void 0 : _a16.url);
2212
- })) {
2213
- const disposableCollection = new DisposableCollection();
2214
- (_d = (_c = p2.body) == null ? void 0 : _c.customRanges) == null || _d.forEach((customRange) => {
2215
- var _a16;
2216
- if (customRange.rangeType === CustomRangeType.HYPERLINK) {
2217
- const payload = (_a16 = customRange.properties) == null ? void 0 : _a16.url, range = this._isLegalRangeUrl(unitId, payload);
2218
- range && disposableCollection.add(this._refRangeService.watchRange(unitId, subUnitId, range, (before, after) => {
2219
- customRange.properties.url = `#gid=${subUnitId}&range=${after ? serializeRange(after) : ERROR_RANGE}`;
2220
- }));
2221
- }
2222
- }), map2.setValue(row, col, disposableCollection);
2223
- }
2224
- }
2225
- _initWorkbookLoad() {
2226
- const handleWorkbook = /* @__PURE__ */ __name((workbook) => {
2227
- const unitId = workbook.getUnitId();
2228
- workbook.getSheets().forEach((sheet) => {
2229
- const subUnitId = sheet.getSheetId(), map2 = this._enusreMap(unitId, subUnitId);
2230
- sheet.getCellMatrix().forValue((row, col, cell) => {
2231
- const dispose = map2.getValue(row, col);
2232
- dispose && dispose.dispose(), cell && cell.p && this._registerRange(unitId, subUnitId, row, col, cell.p);
2233
- });
2234
- });
2235
- }, "handleWorkbook");
2236
- this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => {
2237
- handleWorkbook(workbook);
2238
- }), this.disposeWithMe(
2239
- this._univerInstanceService.unitAdded$.subscribe((unit) => {
2240
- unit.type === UniverInstanceType.UNIVER_SHEET && handleWorkbook(unit);
2241
- })
2242
- );
2243
- }
2244
- _initWorkbookUnload() {
2245
- this._univerInstanceService.unitDisposed$.subscribe((unit) => {
2246
- if (unit.type === UniverInstanceType.UNIVER_SHEET) {
2247
- const workbook = unit, unitId = workbook.getUnitId();
2248
- workbook.getSheets().forEach((sheet) => {
2249
- const subUnitId = sheet.getSheetId();
2250
- this._enusreMap(unitId, subUnitId).forValue((row, col, dispose) => {
2251
- dispose && dispose.dispose();
2252
- });
2253
- }), this._refRangeMap.delete(unitId);
2254
- }
2255
- });
2256
- }
2257
- _initSetRangesListener() {
2258
- this.disposeWithMe(
2259
- this._commandService.onCommandExecuted((commandInfo) => {
2260
- if (commandInfo.id === SetRangeValuesMutation.id) {
2261
- const params = commandInfo.params, { unitId, subUnitId, cellValue } = params, map2 = this._enusreMap(unitId, subUnitId);
2262
- cellValue && new ObjectMatrix(cellValue).forValue((row, col, cell) => {
2263
- const dispose = map2.getValue(row, col);
2264
- dispose && dispose.dispose(), cell && cell.p && this._registerRange(unitId, subUnitId, row, col, cell.p);
2265
- });
2266
- }
2267
- })
2268
- );
2269
- }
2270
- }, __name(_a10, "SheetsHyperLinkRichTextRefRangeController"), _a10);
2271
- SheetsHyperLinkRichTextRefRangeController = __decorateClass$4([
2272
- __decorateParam$4(0, ICommandService),
2273
- __decorateParam$4(1, IUniverInstanceService),
2274
- __decorateParam$4(2, Inject(RefRangeService))
2275
- ], SheetsHyperLinkRichTextRefRangeController);
2276
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2277
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2278
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2279
- return kind && result && __defProp$3(target, key, result), result;
2280
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a11;
2281
- let SheetHyperLinkSetRangeController = (_a11 = class extends Disposable {
2282
- constructor(_sheetInterceptorService, _hyperLinkModel, _selectionManagerService, _univerInstanceService, _editorBridgeService, _renderManagerService) {
2283
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._hyperLinkModel = _hyperLinkModel, this._selectionManagerService = _selectionManagerService, this._univerInstanceService = _univerInstanceService, this._editorBridgeService = _editorBridgeService, this._renderManagerService = _renderManagerService, this._initCommandInterceptor(), this._initAfterEditor();
2284
- }
2285
- _initCommandInterceptor() {
2286
- this._initSetRangeValuesCommandInterceptor(), this._initClearSelectionCommandInterceptor();
2287
- }
2288
- _initSetRangeValuesCommandInterceptor() {
2289
- this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
2290
- getMutations: /* @__PURE__ */ __name((command) => {
2291
- if (command.id === SetRangeValuesCommand.id) {
2292
- const params = command.params, { unitId, subUnitId } = params, redos = [], undos = [];
2293
- return params.cellValue && new ObjectMatrix(params.cellValue).forValue((row, col) => {
2294
- const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
2295
- link && (redos.push({
2296
- id: RemoveHyperLinkMutation.id,
2297
- params: {
2298
- unitId,
2299
- subUnitId,
2300
- id: link.id
2301
- }
2302
- }), undos.push({
2303
- id: AddHyperLinkMutation.id,
2304
- params: {
2305
- unitId,
2306
- subUnitId,
2307
- link
2308
- }
2309
- }));
2310
- }), {
2311
- undos,
2312
- redos
2313
- };
2314
- }
2315
- return {
2316
- redos: [],
2317
- undos: []
2318
- };
2319
- }, "getMutations")
2320
- }));
2321
- }
2322
- _initClearSelectionCommandInterceptor() {
2323
- this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
2324
- getMutations: /* @__PURE__ */ __name((command) => {
2325
- if (command.id === ClearSelectionContentCommand.id || command.id === ClearSelectionAllCommand.id || command.id === ClearSelectionFormatCommand.id) {
2326
- const redos = [], undos = [], selection = this._selectionManagerService.getCurrentLastSelection(), target = getSheetCommandTarget(this._univerInstanceService);
2327
- if (selection && target) {
2328
- const { unitId, subUnitId } = target;
2329
- Range.foreach(selection.range, (row, col) => {
2330
- const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
2331
- link && (redos.push({
2332
- id: RemoveHyperLinkMutation.id,
2333
- params: {
2334
- unitId,
2335
- subUnitId,
2336
- id: link.id
2337
- }
2338
- }), undos.push({
2339
- id: AddHyperLinkMutation.id,
2340
- params: {
2341
- unitId,
2342
- subUnitId,
2343
- link
2344
- }
2345
- }));
2346
- });
2347
- }
2348
- return {
2349
- redos,
2350
- undos
2351
- };
2352
- }
2353
- return {
2354
- redos: [],
2355
- undos: []
2356
- };
2357
- }, "getMutations")
2358
- }));
2359
- }
2360
- _initAfterEditor() {
2361
- this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT, {
2362
- handler: /* @__PURE__ */ __name((cell, context, next) => {
2363
- if (!cell || cell.p)
2364
- return next(cell);
2365
- if (typeof cell.v == "string" && Tools.isLegalUrl(cell.v) && cell.v[cell.v.length - 1] !== " ") {
2366
- const { unitId, subUnitId } = context, renderer = this._renderManagerService.getRenderById(unitId), skeleton = renderer == null ? void 0 : renderer.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
2367
- if (!skeleton)
2368
- return next(cell);
2369
- const doc = skeleton.skeleton.getBlankCellDocumentModel(cell);
2370
- if (!doc.documentModel)
2371
- return next(cell);
2372
- const textX = BuildTextUtils.selection.replace({
2373
- selection: {
2374
- startOffset: 0,
2375
- endOffset: cell.v.length,
2376
- collapsed: !1
2377
- },
2378
- body: {
2379
- dataStream: `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${cell.v}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`,
2380
- customRanges: [{
2381
- startIndex: 0,
2382
- endIndex: cell.v.length + 1,
2383
- rangeId: generateRandomId(),
2384
- rangeType: CustomRangeType.HYPERLINK,
2385
- properties: {
2386
- url: cell.v
2387
- }
2388
- }]
2389
- },
2390
- doc: doc.documentModel
2391
- });
2392
- if (!textX)
2393
- return next(cell);
2394
- const body = doc.documentModel.getBody();
2395
- return TextX.apply(body, textX.serialize()), next({
2396
- ...cell,
2397
- p: {
2398
- id: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
2399
- body,
2400
- documentStyle: {
2401
- pageSize: {
2402
- width: 1 / 0,
2403
- height: 1 / 0
2404
- }
2405
- }
2406
- }
2407
- });
2408
- }
2409
- return next(cell);
2410
- }, "handler")
2411
- }));
2412
- }
2413
- }, __name(_a11, "SheetHyperLinkSetRangeController"), _a11);
2414
- SheetHyperLinkSetRangeController = __decorateClass$3([
2415
- __decorateParam$3(0, Inject(SheetInterceptorService)),
2416
- __decorateParam$3(1, Inject(HyperLinkModel)),
2417
- __decorateParam$3(2, Inject(SheetsSelectionsService)),
2418
- __decorateParam$3(3, IUniverInstanceService),
2419
- __decorateParam$3(4, IEditorBridgeService),
2420
- __decorateParam$3(5, IRenderManagerService)
2421
- ], SheetHyperLinkSetRangeController);
2422
- const menuSchema = {
2423
- [RibbonStartGroup.OTHERS]: {
2424
- [InsertHyperLinkToolbarOperation.id]: {
1745
+ };
1746
+ et = Zn([
1747
+ Lt(0, R(Zr)),
1748
+ Lt(1, R(at))
1749
+ ], et);
1750
+ const _s = {
1751
+ [qr.OTHERS]: {
1752
+ [pe.id]: {
2425
1753
  order: 2,
2426
- menuItemFactory: insertLinkMenuToolbarFactory
1754
+ menuItemFactory: ss
2427
1755
  },
2428
- [genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]: {
1756
+ [Ye(pe.id)]: {
2429
1757
  order: 2,
2430
- menuItemFactory: zenEditorInsertLinkMenuToolbarFactory
1758
+ menuItemFactory: os
2431
1759
  }
2432
1760
  },
2433
- [ContextMenuPosition.MAIN_AREA]: {
2434
- [ContextMenuGroup.OTHERS]: {
1761
+ [Jr.MAIN_AREA]: {
1762
+ [Qr.OTHERS]: {
2435
1763
  order: 1,
2436
- [InsertHyperLinkToolbarOperation.id]: {
1764
+ [pe.id]: {
2437
1765
  order: 0,
2438
- menuItemFactory: insertLinkMenuFactory
1766
+ menuItemFactory: rs
2439
1767
  },
2440
- [genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]: {
1768
+ [Ye(pe.id)]: {
2441
1769
  order: 0,
2442
- menuItemFactory: zenEditorInsertLinkMenuFactory
1770
+ menuItemFactory: is
2443
1771
  }
2444
1772
  }
2445
1773
  }
2446
1774
  };
2447
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2448
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2449
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2450
- return kind && result && __defProp$2(target, key, result), result;
2451
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a12;
2452
- let SheetsHyperLinkUIController = (_a12 = class extends Disposable {
2453
- constructor(_componentManager, _commandService, _menuManagerService, _injector, _shortcutService) {
2454
- super(), this._componentManager = _componentManager, this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._injector = _injector, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
1775
+ var Ss = Object.defineProperty, Cs = Object.getOwnPropertyDescriptor, Is = (t, e, n, r) => {
1776
+ for (var i = r > 1 ? void 0 : r ? Cs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1777
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
1778
+ return r && i && Ss(e, n, i), i;
1779
+ }, Oe = (t, e) => (n, r) => e(n, r, t);
1780
+ let tt = class extends z {
1781
+ constructor(t, e, n, r, i) {
1782
+ super(), this._componentManager = t, this._commandService = e, this._menuManagerService = n, this._injector = r, this._shortcutService = i, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
2455
1783
  }
2456
1784
  _initComponents() {
2457
1785
  [
2458
- [CellLinkPopup, CellLinkPopup.componentKey],
2459
- [CellLinkEdit, CellLinkEdit.componentKey],
2460
- [LinkSingle, "LinkSingle"]
2461
- ].forEach(([comp, key]) => {
2462
- this._componentManager.register(key, comp);
1786
+ [Ge, Ge.componentKey],
1787
+ [Ze, Ze.componentKey],
1788
+ [Ut, "LinkSingle"]
1789
+ ].forEach(([t, e]) => {
1790
+ this._componentManager.register(e, t);
2463
1791
  });
2464
1792
  }
2465
1793
  _initCommands() {
2466
1794
  [
2467
- OpenHyperLinkEditPanelOperation,
2468
- CloseHyperLinkPopupOperation,
2469
- InsertHyperLinkOperation,
2470
- InsertHyperLinkToolbarOperation,
2471
- AddHyperLinkCommand,
2472
- UpdateHyperLinkCommand,
2473
- CancelHyperLinkCommand,
2474
- UpdateRichHyperLinkCommand,
2475
- CancelRichHyperLinkCommand,
2476
- AddRichHyperLinkCommand
2477
- ].forEach((command) => {
2478
- this._commandService.registerCommand(command);
1795
+ Dt,
1796
+ Ke,
1797
+ $t,
1798
+ pe
1799
+ ].forEach((t) => {
1800
+ this._commandService.registerCommand(t);
2479
1801
  });
2480
1802
  }
2481
1803
  _initMenus() {
2482
- this._menuManagerService.mergeMenu(menuSchema);
1804
+ this._menuManagerService.mergeMenu(_s);
2483
1805
  }
2484
1806
  _initShortCut() {
2485
- this._shortcutService.registerShortcut(InsertLinkShortcut);
2486
- }
2487
- }, __name(_a12, "SheetsHyperLinkUIController"), _a12);
2488
- SheetsHyperLinkUIController = __decorateClass$2([
2489
- __decorateParam$2(0, Inject(ComponentManager)),
2490
- __decorateParam$2(1, ICommandService),
2491
- __decorateParam$2(2, IMenuManagerService),
2492
- __decorateParam$2(3, Inject(Injector)),
2493
- __decorateParam$2(4, Inject(IShortcutService))
2494
- ], SheetsHyperLinkUIController);
2495
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2496
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2497
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2498
- return kind && result && __defProp$1(target, key, result), result;
2499
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a13;
2500
- let SheetHyperLinkUrlController = (_a13 = class extends Disposable {
2501
- constructor(_resolverService) {
2502
- super(), this._resolverService = _resolverService, this._handleInitUrl();
1807
+ this._shortcutService.registerShortcut(Wn);
1808
+ }
1809
+ };
1810
+ tt = Is([
1811
+ Oe(0, R(ei)),
1812
+ Oe(1, re),
1813
+ Oe(2, ni),
1814
+ Oe(3, R(st)),
1815
+ Oe(4, R(ti))
1816
+ ], tt);
1817
+ var ys = Object.defineProperty, Es = Object.getOwnPropertyDescriptor, Rs = (t, e, n, r) => {
1818
+ for (var i = r > 1 ? void 0 : r ? Es(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1819
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
1820
+ return r && i && ys(e, n, i), i;
1821
+ }, fn = (t, e) => (n, r) => e(n, r, t);
1822
+ let nt = class extends z {
1823
+ constructor(t, e) {
1824
+ super(), this._parserService = t, this._resolverService = e, this._handleInitUrl();
2503
1825
  }
2504
1826
  _handleInitUrl() {
2505
- const hash = location.hash;
2506
- hash && this._resolverService.parseHyperLink(hash).handler();
2507
- }
2508
- }, __name(_a13, "SheetHyperLinkUrlController"), _a13);
2509
- SheetHyperLinkUrlController = __decorateClass$1([
2510
- __decorateParam$1(0, Inject(SheetsHyperLinkResolverService))
2511
- ], SheetHyperLinkUrlController);
2512
- 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) => {
2513
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2514
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2515
- return kind && result && __defProp2(target, key, result), result;
2516
- }, "__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"), _a14;
2517
- let UniverSheetsHyperLinkUIPlugin = (_a14 = class extends Plugin {
2518
- constructor(_config = defaultPluginConfig, _injector, _configService) {
2519
- super(), this._config = _config, this._injector = _injector, this._configService = _configService;
2520
- const { menu, ...rest } = this._config;
2521
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
1827
+ const t = location.hash;
1828
+ if (t) {
1829
+ const e = this._parserService.parseHyperLink(t);
1830
+ this._resolverService.navigate(e);
1831
+ }
1832
+ }
1833
+ };
1834
+ nt = Rs([
1835
+ fn(0, R(wt)),
1836
+ fn(1, R(he))
1837
+ ], nt);
1838
+ var Gn = Object.defineProperty, Ps = Object.getOwnPropertyDescriptor, Ls = (t, e, n) => e in t ? Gn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, bs = (t, e, n, r) => {
1839
+ for (var i = r > 1 ? void 0 : r ? Ps(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1840
+ (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
1841
+ return r && i && Gn(e, n, i), i;
1842
+ }, vn = (t, e) => (n, r) => e(n, r, t), Kn = (t, e, n) => Ls(t, typeof e != "symbol" ? e + "" : e, n);
1843
+ let rt = class extends dr {
1844
+ constructor(t = vi, e, n) {
1845
+ super(), this._config = t, this._injector = e, this._configService = n;
1846
+ const { menu: r, ...i } = this._config;
1847
+ r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Nn, i);
2522
1848
  }
2523
1849
  onStarting() {
2524
1850
  [
2525
- [SheetsHyperLinkResolverService],
2526
- [SheetsHyperLinkPopupService],
2527
- [SheetsHyperLinkSidePanelService],
2528
- [SheetsHyperLinkRemoveSheetController],
2529
- [SheetsHyperLinkRenderManagerController],
2530
- [SheetHyperLinkSetRangeController],
2531
- [SheetsHyperLinkPopupController],
2532
- [SheetsHyperLinkUIController],
2533
- [SheetsHyperLinkAutoFillController],
2534
- [SheetsHyperLinkCopyPasteController],
2535
- [SheetsHyperLinkPermissionController],
2536
- [SheetHyperLinkUrlController],
2537
- [SheetsHyperLinkRichTextRefRangeController]
2538
- ].forEach((dep) => this._injector.add(dep)), this._injector.get(SheetsHyperLinkRenderManagerController), this._injector.get(SheetsHyperLinkRichTextRefRangeController), this._injector.get(SheetHyperLinkSetRangeController);
1851
+ [he],
1852
+ [G],
1853
+ [Hn],
1854
+ [et],
1855
+ [Qe],
1856
+ [tt],
1857
+ [qe],
1858
+ [We],
1859
+ [Je],
1860
+ [nt]
1861
+ ].forEach((e) => this._injector.add(e)), this._injector.get(et);
2539
1862
  }
2540
1863
  onReady() {
2541
- this._injector.get(IRenderManagerService).registerRenderModule(UniverInstanceType.UNIVER_SHEET, [SheetsHyperLinkRenderController]), this._injector.get(SheetsHyperLinkAutoFillController), this._injector.get(SheetsHyperLinkCopyPasteController), this._injector.get(SheetsHyperLinkRemoveSheetController), this._injector.get(SheetsHyperLinkUIController);
1864
+ this._injector.get(ut).registerRenderModule(O.UNIVER_SHEET, [bt]), this._injector.get(qe), this._injector.get(We), this._injector.get(tt);
2542
1865
  }
2543
1866
  onRendered() {
2544
- this._injector.get(SheetsHyperLinkPermissionController), this._injector.get(SheetHyperLinkUrlController), this._injector.get(SheetsHyperLinkPopupController);
2545
- }
2546
- }, __name(_a14, "UniverSheetsHyperLinkUIPlugin"), _a14);
2547
- __publicField2(UniverSheetsHyperLinkUIPlugin, "pluginName", SHEET_HYPER_LINK_UI_PLUGIN);
2548
- __publicField2(UniverSheetsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
2549
- UniverSheetsHyperLinkUIPlugin = __decorateClass([
2550
- DependentOn(UniverSheetsHyperLinkPlugin, UniverDocsUIPlugin),
2551
- __decorateParam(1, Inject(Injector)),
2552
- __decorateParam(2, IConfigService)
2553
- ], UniverSheetsHyperLinkUIPlugin);
1867
+ this._injector.get(Je), this._injector.get(nt), this._injector.get(Qe);
1868
+ }
1869
+ };
1870
+ Kn(rt, "pluginName", Mt);
1871
+ Kn(rt, "type", O.UNIVER_SHEET);
1872
+ rt = bs([
1873
+ ur(Sr, si),
1874
+ vn(1, R(st)),
1875
+ vn(2, Sn)
1876
+ ], rt);
2554
1877
  export {
2555
- AddHyperLinkCommand,
2556
- CancelHyperLinkCommand,
2557
- CloseHyperLinkPopupOperation,
2558
- InsertHyperLinkOperation,
2559
- InsertLinkShortcut,
2560
- OpenHyperLinkEditPanelOperation,
2561
- SheetsHyperLinkCopyPasteController,
2562
- SheetsHyperLinkPopupService,
2563
- SheetsHyperLinkResolverService,
2564
- SheetsHyperLinkSidePanelService,
2565
- UniverSheetsHyperLinkUIPlugin,
2566
- UpdateHyperLinkCommand
1878
+ Ke as CloseHyperLinkPopupOperation,
1879
+ $t as InsertHyperLinkOperation,
1880
+ Wn as InsertLinkShortcut,
1881
+ Dt as OpenHyperLinkEditPanelOperation,
1882
+ We as SheetsHyperLinkCopyPasteController,
1883
+ G as SheetsHyperLinkPopupService,
1884
+ he as SheetsHyperLinkResolverService,
1885
+ Hn as SheetsHyperLinkSidePanelService,
1886
+ rt as UniverSheetsHyperLinkUIPlugin
2567
1887
  };