@univerjs/sheets-hyper-link-ui 0.5.4 → 0.5.5-experimental.20250123-34738ff

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