@univerjs/sheets-hyper-link-ui 0.2.5 → 0.2.7

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,135 +1,168 @@
1
- var Gt = Object.defineProperty;
2
- var qt = (e, t, n) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var W = (e, t, n) => qt(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { Disposable as O, UniverInstanceType as E, OnLifecycle as B, LifecycleStages as D, Inject as h, IUniverInstanceService as ue, BooleanNumber as Xt, ThemeService as Jt, isValidRange as ze, LocaleService as pe, RANGE_TYPE as lt, Rectangle as ne, ICommandService as K, Tools as re, DEFAULT_EMPTY_DOCUMENT_VALUE as Qt, useDependency as k, createInternalEditorID as en, CommandType as je, CellValueType as dt, ObjectMatrix as _t, Range as Qe, CustomRangeType as tn, Injector as Ne, IPermissionService as nn, Plugin as rn, DependentOn as on } from "@univerjs/core";
5
- import { RemoveSheetCommand as sn, SheetInterceptorService as et, INTERCEPTOR_POINT as an, SetSelectionsOperation as cn, SetWorksheetActiveOperation as Ee, getSheetCommandTarget as Ct, SheetsSelectionsService as yt, SetRangeValuesMutation as fe, SetRangeValuesUndoMutationFactory as ut, SetRangeValuesCommand as ln, ClearSelectionContentCommand as dn, ClearSelectionAllCommand as un, ClearSelectionFormatCommand as pn, WorkbookViewPermission as hn, WorksheetViewPermission as mn, RangeProtectionPermissionViewPoint as gn, WorkbookEditablePermission as $e, WorksheetEditPermission as Be, WorksheetInsertHyperlinkPermission as De, RangeProtectionPermissionEditPoint as Ve, WorkbookCopyPermission as fn, WorksheetCopyPermission as vn, WorksheetSetCellValuePermission as tt } from "@univerjs/sheets";
6
- import { RemoveHyperLinkMutation as T, AddHyperLinkMutation as U, HyperLinkModel as H, ERROR_RANGE as Ge, UpdateHyperLinkCommand as St, AddHyperLinkCommand as Lt, CancelHyperLinkCommand as _n, UniverSheetsHyperLinkPlugin as Cn } from "@univerjs/sheets-hyper-link";
7
- import { SheetSkeletonManagerService as It, ScrollToRangeOperation as kt, SheetCanvasPopManagerService as yn, IEditorBridgeService as Sn, HoverManagerService as Ln, SheetPermissionInterceptorBaseController as Pt, whenSheetEditorFocused as In, getCurrentRangeDisable$ as bt, APPLY_TYPE as oe, IAutoFillService as kn, virtualizeDiscreteRanges as qe, getAutoFillRepeatRange as Pn, COPY_TYPE as bn, rangeToDiscreteRange as Rn, PREDEFINED_HOOK_NAME as ve, getRepeatRange as wn, ISheetClipboardService as En } from "@univerjs/sheets-ui";
8
- import { IRenderManagerService as nt } from "@univerjs/engine-render";
9
- import { debounceTime as Rt, Subject as On, BehaviorSubject as Mn } from "rxjs";
10
- import xn, { forwardRef as Y, useRef as wt, createElement as Z, useState as ee, useEffect as Et, useMemo as Tn } from "react";
11
- import pt from "clsx";
12
- import { MessageType as ce, FormLayout as X, Input as ht, Select as Ke, Button as mt, Tooltip as _e } from "@univerjs/design";
13
- import { IMessageService as Ot, useObservable as Un, useEvent as Hn, RangeSelector as jn, ISidebarService as Mt, KeyCode as Nn, MetaKeys as $n, MenuItemType as xt, MenuPosition as Tt, getMenuHiddenObservable as Ut, MenuGroup as Bn, ComponentManager as Dn, IShortcutService as Vn, IMenuService as An } from "@univerjs/ui";
14
- import { deserializeRangeWithSheet as Oe, serializeRangeWithSheet as Ht, IDefinedNamesService as jt, serializeRangeToRefString as Wn, serializeRange as Fn } from "@univerjs/engine-formula";
15
- import { DOC_HYPER_LINK_PLUGIN as Kn } from "@univerjs/docs-hyper-link";
16
- import { getPlainTextFormDocument as Yn } from "@univerjs/docs";
17
- var Zn = Object.defineProperty, zn = Object.getOwnPropertyDescriptor, Gn = (e, t, n, r) => {
18
- for (var i = r > 1 ? void 0 : r ? zn(t, n) : t, o = e.length - 1, s; o >= 0; o--)
19
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
20
- return r && i && Zn(t, n, i), i;
21
- }, Ye = (e, t) => (n, r) => t(n, r, e);
22
- let ye = class extends O {
23
- constructor(e, t, n) {
24
- super(), this._sheetInterceptorService = e, this._univerInstanceService = t, this._hyperLinkModel = n, this._initSheetChange();
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 { Disposable, UniverInstanceType, OnLifecycle, LifecycleStages, Inject, IUniverInstanceService, BooleanNumber, ThemeService, isValidRange, LocaleService, RANGE_TYPE, Rectangle, ICommandService, Tools, DEFAULT_EMPTY_DOCUMENT_VALUE, useDependency, createInternalEditorID, CommandType, CellValueType, ObjectMatrix, Range, CustomRangeType, Injector, IPermissionService, Plugin, DependentOn } from "@univerjs/core";
6
+ import { RemoveSheetCommand, SheetInterceptorService, INTERCEPTOR_POINT, SetSelectionsOperation, SetWorksheetActiveOperation, getSheetCommandTarget, SheetsSelectionsService, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetRangeValuesCommand, ClearSelectionContentCommand, ClearSelectionAllCommand, ClearSelectionFormatCommand, WorkbookViewPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetInsertHyperlinkPermission, RangeProtectionPermissionEditPoint, WorkbookCopyPermission, WorksheetCopyPermission, WorksheetSetCellValuePermission } from "@univerjs/sheets";
7
+ import { RemoveHyperLinkMutation, AddHyperLinkMutation, HyperLinkModel, ERROR_RANGE, UpdateHyperLinkCommand, AddHyperLinkCommand, CancelHyperLinkCommand, UniverSheetsHyperLinkPlugin } from "@univerjs/sheets-hyper-link";
8
+ import { SheetSkeletonManagerService, ScrollToRangeOperation, SheetCanvasPopManagerService, IEditorBridgeService, HoverManagerService, SheetPermissionInterceptorBaseController, whenSheetEditorFocused, getCurrentRangeDisable$, APPLY_TYPE, IAutoFillService, virtualizeDiscreteRanges, getAutoFillRepeatRange, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService } from "@univerjs/sheets-ui";
9
+ import { IRenderManagerService } from "@univerjs/engine-render";
10
+ import { debounceTime, Subject, BehaviorSubject } from "rxjs";
11
+ import require$$0, { forwardRef, useRef, createElement, useState, useMemo, useEffect } from "react";
12
+ import cs from "clsx";
13
+ import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
14
+ import { IMessageService, useObservable, useEvent, RangeSelector, ISidebarService, KeyCode, MetaKeys, MenuItemType, MenuPosition, getMenuHiddenObservable, MenuGroup, ComponentManager, IShortcutService, IMenuService } from "@univerjs/ui";
15
+ import { deserializeRangeWithSheet, serializeRangeWithSheet, IDefinedNamesService, serializeRangeToRefString, serializeRange } from "@univerjs/engine-formula";
16
+ import { DOC_HYPER_LINK_PLUGIN } from "@univerjs/docs-hyper-link";
17
+ import { getPlainTextFormDocument } from "@univerjs/docs";
18
+ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
19
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
20
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
21
+ return kind && result && __defProp$b(target, key, result), result;
22
+ }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a;
23
+ let SheetsHyperLinkRemoveSheetController = (_a = class extends Disposable {
24
+ constructor(_sheetInterceptorService, _univerInstanceService, _hyperLinkModel) {
25
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._hyperLinkModel = _hyperLinkModel, this._initSheetChange();
25
26
  }
26
27
  _initSheetChange() {
27
28
  this.disposeWithMe(
28
29
  this._sheetInterceptorService.interceptCommand({
29
- getMutations: (e) => {
30
- var t;
31
- if (e.id === sn.id) {
32
- const n = e.params, r = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(E.UNIVER_SHEET);
33
- if (!r)
30
+ getMutations: /* @__PURE__ */ __name((commandInfo) => {
31
+ var _a14;
32
+ if (commandInfo.id === RemoveSheetCommand.id) {
33
+ const params = commandInfo.params, workbook = params.unitId ? this._univerInstanceService.getUnit(params.unitId) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
34
+ if (!workbook)
34
35
  return { redos: [], undos: [] };
35
- const i = r.getUnitId(), o = n.subUnitId || ((t = r.getActiveSheet()) == null ? void 0 : t.getSheetId());
36
- if (!o)
36
+ const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a14 = workbook.getActiveSheet()) == null ? void 0 : _a14.getSheetId());
37
+ if (!subUnitId)
37
38
  return { redos: [], undos: [] };
38
- const s = this._hyperLinkModel.getSubUnit(i, o), c = s.map((u) => ({
39
- id: T.id,
39
+ const links = this._hyperLinkModel.getSubUnit(unitId, subUnitId), redos = links.map((link) => ({
40
+ id: RemoveHyperLinkMutation.id,
40
41
  params: {
41
- unitId: i,
42
- subUnitId: o,
43
- id: u.id
42
+ unitId,
43
+ subUnitId,
44
+ id: link.id
44
45
  }
45
- })), a = s.map((u) => ({
46
- id: U.id,
46
+ })), undos = links.map((link) => ({
47
+ id: AddHyperLinkMutation.id,
47
48
  params: {
48
- unitId: i,
49
- subUnitId: o,
50
- link: u
49
+ unitId,
50
+ subUnitId,
51
+ link
51
52
  }
52
53
  }));
53
- return { redos: c, undos: a };
54
+ return { redos, undos };
54
55
  }
55
56
  return { redos: [], undos: [] };
56
- }
57
+ }, "getMutations")
57
58
  })
58
59
  );
59
60
  }
60
- };
61
- ye = Gn([
62
- B(D.Ready, ye),
63
- Ye(0, h(et)),
64
- Ye(1, ue),
65
- Ye(2, h(H))
66
- ], ye);
67
- var qn = Object.defineProperty, Xn = Object.getOwnPropertyDescriptor, Nt = (e, t, n, r) => {
68
- for (var i = r > 1 ? void 0 : r ? Xn(t, n) : t, o = e.length - 1, s; o >= 0; o--)
69
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
70
- return r && i && qn(t, n, i), i;
71
- }, te = (e, t) => (n, r) => t(n, r, e);
72
- let Xe = class extends O {
73
- constructor(e, t, n, r) {
74
- super(), this._context = e, this._hyperLinkModel = t, this._sheetSkeletonManagerService = n, this._renderManagerService = r, this._initSkeletonChange();
61
+ }, __name(_a, "SheetsHyperLinkRemoveSheetController"), _a);
62
+ SheetsHyperLinkRemoveSheetController = __decorateClass$b([
63
+ OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkRemoveSheetController),
64
+ __decorateParam$b(0, Inject(SheetInterceptorService)),
65
+ __decorateParam$b(1, IUniverInstanceService),
66
+ __decorateParam$b(2, Inject(HyperLinkModel))
67
+ ], SheetsHyperLinkRemoveSheetController);
68
+ var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
69
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
70
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
71
+ return kind && result && __defProp$a(target, key, result), result;
72
+ }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a2;
73
+ let SheetsHyperLinkRenderController = (_a2 = class extends Disposable {
74
+ constructor(_context, _hyperLinkModel, _sheetSkeletonManagerService, _renderManagerService) {
75
+ super(), this._context = _context, this._hyperLinkModel = _hyperLinkModel, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._renderManagerService = _renderManagerService, this._initSkeletonChange();
75
76
  }
76
77
  _initSkeletonChange() {
77
- const e = () => {
78
- var s;
79
- const t = this._context.unit, n = t.getUnitId(), r = (s = t.getActiveSheet()) == null ? void 0 : s.getSheetId();
80
- if (!r) {
78
+ const markSkeletonDirty = /* @__PURE__ */ __name(() => {
79
+ var _a14;
80
+ const workbook = this._context.unit, unitId = workbook.getUnitId(), subUnitId = (_a14 = workbook.getActiveSheet()) == null ? void 0 : _a14.getSheetId();
81
+ if (!subUnitId) {
81
82
  console.warn("No active sheet found");
82
83
  return;
83
84
  }
84
- const i = this._sheetSkeletonManagerService.getOrCreateSkeleton({ sheetId: r }), o = this._renderManagerService.getRenderById(n);
85
- i == null || i.makeDirty(!0), i == null || i.calculate(), o && o.mainComponent.makeForceDirty();
86
- };
87
- this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(Rt(16)).subscribe(() => {
88
- e();
85
+ const skeleton = this._sheetSkeletonManagerService.getOrCreateSkeleton({ sheetId: subUnitId }), currentRender = this._renderManagerService.getRenderById(unitId);
86
+ skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
87
+ }, "markSkeletonDirty");
88
+ this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(debounceTime(16)).subscribe(() => {
89
+ markSkeletonDirty();
89
90
  }));
90
91
  }
91
- };
92
- Xe = Nt([
93
- te(1, h(H)),
94
- te(2, h(It)),
95
- te(3, nt)
96
- ], Xe);
97
- let Se = class extends O {
98
- constructor(e, t, n) {
99
- super(), this._sheetInterceptorService = e, this._hyperLinkModel = t, this._themeService = n, this._initViewModelIntercept();
92
+ }, __name(_a2, "SheetsHyperLinkRenderController"), _a2);
93
+ SheetsHyperLinkRenderController = __decorateClass$a([
94
+ __decorateParam$a(1, Inject(HyperLinkModel)),
95
+ __decorateParam$a(2, Inject(SheetSkeletonManagerService)),
96
+ __decorateParam$a(3, IRenderManagerService)
97
+ ], SheetsHyperLinkRenderController);
98
+ var _a3;
99
+ let SheetsHyperLinkRenderManagerController = (_a3 = class extends Disposable {
100
+ constructor(_sheetInterceptorService, _hyperLinkModel, _themeService) {
101
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._hyperLinkModel = _hyperLinkModel, this._themeService = _themeService, this._initViewModelIntercept();
100
102
  }
101
103
  _initViewModelIntercept() {
102
104
  this.disposeWithMe(
103
105
  this._sheetInterceptorService.intercept(
104
- an.CELL_CONTENT,
106
+ INTERCEPTOR_POINT.CELL_CONTENT,
105
107
  {
106
- handler: (e, t, n) => {
107
- const { row: r, col: i, unitId: o, subUnitId: s } = t, c = this._hyperLinkModel.getHyperLinkByLocation(o, s, r, i), a = this._themeService.getCurrentTheme();
108
- return n(c ? {
109
- ...e,
108
+ handler: /* @__PURE__ */ __name((cell, pos, next) => {
109
+ const { row, col, unitId, subUnitId } = pos, link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col), styleSheet = this._themeService.getCurrentTheme();
110
+ return next(link ? {
111
+ ...cell,
110
112
  interceptorStyle: {
111
113
  ul: {
112
- s: Xt.TRUE
114
+ s: BooleanNumber.TRUE
113
115
  },
114
116
  cl: {
115
- rgb: a.blue500
117
+ rgb: styleSheet.blue500
116
118
  }
117
119
  }
118
- } : e);
119
- },
120
+ } : cell);
121
+ }, "handler"),
120
122
  priority: 100
121
123
  }
122
124
  )
123
125
  );
124
126
  }
127
+ }, __name(_a3, "SheetsHyperLinkRenderManagerController"), _a3);
128
+ SheetsHyperLinkRenderManagerController = __decorateClass$a([
129
+ OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkRenderManagerController),
130
+ __decorateParam$a(0, Inject(SheetInterceptorService)),
131
+ __decorateParam$a(1, Inject(HyperLinkModel)),
132
+ __decorateParam$a(2, Inject(ThemeService))
133
+ ], SheetsHyperLinkRenderManagerController);
134
+ var LinkType = /* @__PURE__ */ ((LinkType2) => (LinkType2.link = "link", LinkType2.range = "range", LinkType2.sheet = "gid", LinkType2.definedName = "rangeid", LinkType2))(LinkType || {});
135
+ const _SheetsHyperLinkSidePanelService = class _SheetsHyperLinkSidePanelService extends Disposable {
136
+ constructor() {
137
+ super(...arguments);
138
+ __publicField(this, "_customHyperLinks", /* @__PURE__ */ new Map());
139
+ }
140
+ isBuiltInLinkType(type) {
141
+ return !!LinkType[type];
142
+ }
143
+ getOptions() {
144
+ return Array.from(this._customHyperLinks.values()).map(({ option }) => option);
145
+ }
146
+ findCustomHyperLink(link) {
147
+ return Array.from(this._customHyperLinks.values()).find((item) => item.match(link));
148
+ }
149
+ registerCustomHyperLink(customHyperLink) {
150
+ this._customHyperLinks.set(customHyperLink.type, customHyperLink);
151
+ }
152
+ getCustomHyperLink(type) {
153
+ return this._customHyperLinks.get(type);
154
+ }
155
+ removeCustomHyperLink(type) {
156
+ const { _customHyperLinks } = this;
157
+ _customHyperLinks.delete(type);
158
+ }
159
+ dispose() {
160
+ super.dispose(), this._customHyperLinks.clear();
161
+ }
125
162
  };
126
- Se = Nt([
127
- B(D.Ready, Se),
128
- te(0, h(et)),
129
- te(1, h(H)),
130
- te(2, h(Jt))
131
- ], Se);
132
- var $t = { exports: {} }, Ae = {};
163
+ __name(_SheetsHyperLinkSidePanelService, "SheetsHyperLinkSidePanelService");
164
+ let SheetsHyperLinkSidePanelService = _SheetsHyperLinkSidePanelService;
165
+ var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
133
166
  /**
134
167
  * @license React
135
168
  * react-jsx-runtime.production.min.js
@@ -139,158 +172,165 @@ var $t = { exports: {} }, Ae = {};
139
172
  * This source code is licensed under the MIT license found in the
140
173
  * LICENSE file in the root directory of this source tree.
141
174
  */
142
- var Jn = xn, Qn = Symbol.for("react.element"), er = Symbol.for("react.fragment"), tr = Object.prototype.hasOwnProperty, nr = Jn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, rr = { key: !0, ref: !0, __self: !0, __source: !0 };
143
- function Bt(e, t, n) {
144
- var r, i = {}, o = null, s = null;
145
- n !== void 0 && (o = "" + n), t.key !== void 0 && (o = "" + t.key), t.ref !== void 0 && (s = t.ref);
146
- for (r in t) tr.call(t, r) && !rr.hasOwnProperty(r) && (i[r] = t[r]);
147
- if (e && e.defaultProps) for (r in t = e.defaultProps, t) i[r] === void 0 && (i[r] = t[r]);
148
- return { $$typeof: Qn, type: e, key: o, ref: s, props: i, _owner: nr.current };
175
+ var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
176
+ function q(c, a, g) {
177
+ var b, d = {}, e = null, h = null;
178
+ g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
179
+ for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
180
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
181
+ return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
149
182
  }
150
- Ae.Fragment = er;
151
- Ae.jsx = Bt;
152
- Ae.jsxs = Bt;
153
- $t.exports = Ae;
154
- var d = $t.exports, b = function() {
155
- return b = Object.assign || function(e) {
156
- for (var t, n = 1, r = arguments.length; n < r; n++) {
157
- t = arguments[n];
158
- for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
183
+ __name(q, "q");
184
+ reactJsxRuntime_production_min.Fragment = l;
185
+ reactJsxRuntime_production_min.jsx = q;
186
+ reactJsxRuntime_production_min.jsxs = q;
187
+ jsxRuntime.exports = reactJsxRuntime_production_min;
188
+ var jsxRuntimeExports = jsxRuntime.exports, __assign = function() {
189
+ return __assign = Object.assign || function(t) {
190
+ for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
191
+ s = arguments[i];
192
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
159
193
  }
160
- return e;
161
- }, b.apply(this, arguments);
162
- }, ir = function(e, t) {
163
- var n = {};
164
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
165
- if (e != null && typeof Object.getOwnPropertySymbols == "function")
166
- for (var i = 0, r = Object.getOwnPropertySymbols(e); i < r.length; i++)
167
- t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]);
168
- return n;
169
- }, z = Y(function(e, t) {
170
- var n = e.icon, r = e.id, i = e.className, o = e.extend, s = ir(e, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), a = wt("_".concat(ar()));
171
- return Dt(n, "".concat(r), { defIds: n.defIds, idSuffix: a.current }, b({ ref: t, className: c }, s), o);
194
+ return t;
195
+ }, __assign.apply(this, arguments);
196
+ }, __rest = function(s, e) {
197
+ var t = {};
198
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
199
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
200
+ for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
201
+ e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
202
+ return t;
203
+ }, IconBase = forwardRef(function(props, ref) {
204
+ 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()));
205
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
172
206
  });
173
- function Dt(e, t, n, r, i) {
174
- return Z(e.tag, b(b({ key: t }, or(e, n, i)), r), (sr(e, n).children || []).map(function(o, s) {
175
- return Dt(o, "".concat(t, "-").concat(e.tag, "-").concat(s), n, void 0, i);
207
+ function render(node, id, runtimeProps, rootProps, extend) {
208
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
209
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
176
210
  }));
177
211
  }
178
- function or(e, t, n) {
179
- var r = b({}, e.attrs);
180
- n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1);
181
- var i = t.defIds;
182
- return !i || i.length === 0 || (e.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + t.idSuffix), Object.entries(r).forEach(function(o) {
183
- var s = o[0], c = o[1];
184
- typeof c == "string" && (r[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
185
- })), r;
212
+ __name(render, "render");
213
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
214
+ var attrs = __assign({}, node.attrs);
215
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
216
+ var defIds = runtimeProps.defIds;
217
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a14) {
218
+ var key = _a14[0], value = _a14[1];
219
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
220
+ })), attrs;
186
221
  }
187
- function sr(e, t) {
188
- var n, r = t.defIds;
189
- return !r || r.length === 0 ? e : e.tag === "defs" && (!((n = e.children) === null || n === void 0) && n.length) ? b(b({}, e), { children: e.children.map(function(i) {
190
- return typeof i.attrs.id == "string" && r && r.indexOf(i.attrs.id) > -1 ? b(b({}, i), { attrs: b(b({}, i.attrs), { id: i.attrs.id + t.idSuffix }) }) : i;
191
- }) }) : e;
222
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
223
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
224
+ var _a14, defIds = runtimeProps.defIds;
225
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a14 = node.children) === null || _a14 === void 0) && _a14.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
226
+ 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;
227
+ }) }) : node;
192
228
  }
193
- function ar() {
229
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
230
+ function generateShortUuid() {
194
231
  return Math.random().toString(36).substring(2, 8);
195
232
  }
196
- z.displayName = "UniverIcon";
197
- var cr = { 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" } }] }, Le = Y(function(e, t) {
198
- return Z(z, Object.assign({}, e, {
233
+ __name(generateShortUuid, "generateShortUuid");
234
+ IconBase.displayName = "UniverIcon";
235
+ 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) {
236
+ return createElement(IconBase, Object.assign({}, props, {
199
237
  id: "all-border-single",
200
- ref: t,
201
- icon: cr
238
+ ref,
239
+ icon: element$5
202
240
  }));
203
241
  });
204
- Le.displayName = "AllBorderSingle";
205
- var lr = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Vt = Y(function(e, t) {
206
- return Z(z, Object.assign({}, e, {
242
+ AllBorderSingle.displayName = "AllBorderSingle";
243
+ 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) {
244
+ return createElement(IconBase, Object.assign({}, props, {
207
245
  id: "copy-single",
208
- ref: t,
209
- icon: lr
246
+ ref,
247
+ icon: element$4
210
248
  }));
211
249
  });
212
- Vt.displayName = "CopySingle";
213
- var dr = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332", fillRule: "evenodd", clipRule: "evenodd" } }] }, Me = Y(function(e, t) {
214
- return Z(z, Object.assign({}, e, {
250
+ CopySingle.displayName = "CopySingle";
251
+ var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332", fillRule: "evenodd", clipRule: "evenodd" } }] }, LinkSingle = forwardRef(function(props, ref) {
252
+ return createElement(IconBase, Object.assign({}, props, {
215
253
  id: "link-single",
216
- ref: t,
217
- icon: dr
254
+ ref,
255
+ icon: element$3
218
256
  }));
219
257
  });
220
- Me.displayName = "LinkSingle";
221
- var ur = { 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" } }] }, At = Y(function(e, t) {
222
- return Z(z, Object.assign({}, e, {
258
+ LinkSingle.displayName = "LinkSingle";
259
+ 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) {
260
+ return createElement(IconBase, Object.assign({}, props, {
223
261
  id: "unlink-single",
224
- ref: t,
225
- icon: ur
262
+ ref,
263
+ icon: element$2
226
264
  }));
227
265
  });
228
- At.displayName = "UnlinkSingle";
229
- var pr = { 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" } }] }, Wt = Y(function(e, t) {
230
- return Z(z, Object.assign({}, e, {
266
+ UnlinkSingle.displayName = "UnlinkSingle";
267
+ 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) {
268
+ return createElement(IconBase, Object.assign({}, props, {
231
269
  id: "write-single",
232
- ref: t,
233
- icon: pr
270
+ ref,
271
+ icon: element$1
234
272
  }));
235
273
  });
236
- Wt.displayName = "WriteSingle";
237
- var hr = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#35BD4B", d: "M3.36396 1.12549C2.61066 1.12549 2 1.73615 2 2.48945V13.5104C2 14.2637 2.61066 14.8744 3.36396 14.8744H12.457C13.2103 14.8744 13.821 14.2637 13.821 13.5104V5.0992L9.91954 1.12549H3.36396Z" } }, { tag: "path", attrs: { fill: "#32A846", d: "M9.91797 1.12549L13.8209 5.09842H10.5846C10.2164 5.09842 9.91797 4.79994 9.91797 4.43175V1.12549Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M7.71926 10.2949L6.28687 12.403C6.17306 12.5705 5.94501 12.614 5.77751 12.5002C5.61002 12.3864 5.56649 12.1584 5.6803 11.9909L7.27596 9.64252L5.85088 7.54519C5.73707 7.37769 5.78059 7.14964 5.94809 7.03583C6.11558 6.92202 6.34363 6.96555 6.45744 7.13304L7.71926 8.9901L8.98108 7.13304C9.09489 6.96555 9.32294 6.92202 9.49044 7.03583C9.65793 7.14964 9.70146 7.37769 9.58765 7.54519L8.16256 9.64252L9.75822 11.9909C9.87203 12.1584 9.82851 12.3864 9.66101 12.5002C9.49351 12.614 9.26547 12.5705 9.15166 12.403L7.71926 10.2949Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Je = Y(function(e, t) {
238
- return Z(z, Object.assign({}, e, {
274
+ WriteSingle.displayName = "WriteSingle";
275
+ 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) {
276
+ return createElement(IconBase, Object.assign({}, props, {
239
277
  id: "xlsx",
240
- ref: t,
241
- icon: hr
278
+ ref,
279
+ icon: element
242
280
  }));
243
281
  });
244
- Je.displayName = "Xlsx";
245
- var mr = Object.defineProperty, gr = Object.getOwnPropertyDescriptor, fr = (e, t, n, r) => {
246
- for (var i = r > 1 ? void 0 : r ? gr(t, n) : t, o = e.length - 1, s; o >= 0; o--)
247
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
248
- return r && i && mr(t, n, i), i;
249
- }, se = (e, t) => (n, r) => t(n, r, e);
250
- function vr(e, t) {
251
- const n = t.getMergeData(), r = t.getMaxColumns() - 1, i = t.getMaxRows() - 1;
252
- if (r < e.endColumn && (e.endColumn = r), i < e.endRow && (e.endRow = i), e.rangeType === lt.COLUMN || lt.ROW)
253
- return e;
254
- const o = [];
255
- return n.forEach((s) => {
256
- ne.intersects(e, s) && o.push(s);
257
- }), ne.realUnion(e, ...o);
282
+ Xlsx.displayName = "Xlsx";
283
+ var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
284
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
285
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
286
+ return kind && result && __defProp$9(target, key, result), result;
287
+ }, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
288
+ function getContainRange(range, worksheet) {
289
+ const mergedCells = worksheet.getMergeData(), maxCol = worksheet.getMaxColumns() - 1, maxRow = worksheet.getMaxRows() - 1;
290
+ if (maxCol < range.endColumn && (range.endColumn = maxCol), maxRow < range.endRow && (range.endRow = maxRow), range.rangeType === RANGE_TYPE.COLUMN || RANGE_TYPE.ROW)
291
+ return range;
292
+ const relativeCells = [];
293
+ return mergedCells.forEach((cell) => {
294
+ Rectangle.intersects(range, cell) && relativeCells.push(cell);
295
+ }), Rectangle.realUnion(range, ...relativeCells);
258
296
  }
259
- let F = class {
260
- constructor(e, t, n, r, i) {
261
- this._univerInstanceService = e, this._commandService = t, this._definedNamesService = n, this._messageService = r, this._localeService = i;
262
- }
263
- _getURLName(e) {
264
- var c;
265
- const { gid: t, range: n, rangeid: r } = e, i = this._univerInstanceService.getCurrentUnitForType(E.UNIVER_SHEET);
266
- if (!i)
297
+ __name(getContainRange, "getContainRange");
298
+ var _a4;
299
+ let SheetsHyperLinkResolverService = (_a4 = class {
300
+ constructor(_urlHandler, _univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService) {
301
+ this._urlHandler = _urlHandler, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService;
302
+ }
303
+ _getURLName(params) {
304
+ var _a14;
305
+ const { gid, range, rangeid } = params, workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
306
+ if (!workbook)
267
307
  return null;
268
- const o = t ? i.getSheetBySheetId(t) : i.getActiveSheet(), s = (c = o == null ? void 0 : o.getName()) != null ? c : "";
269
- if (n) {
270
- const a = Oe(n).range;
271
- return ze(a) && n !== Ge ? {
308
+ const sheet = gid ? workbook.getSheetBySheetId(gid) : workbook.getActiveSheet(), sheetName = (_a14 = sheet == null ? void 0 : sheet.getName()) != null ? _a14 : "";
309
+ if (range) {
310
+ const rangeObj = deserializeRangeWithSheet(range).range;
311
+ return isValidRange(rangeObj) && range !== ERROR_RANGE ? {
272
312
  type: "range",
273
- name: Ht(s, a)
313
+ name: serializeRangeWithSheet(sheetName, rangeObj)
274
314
  } : {
275
315
  type: "range-error",
276
316
  name: this._localeService.t("hyperLink.message.refError")
277
317
  };
278
318
  }
279
- if (r) {
280
- const a = this._definedNamesService.getValueById(i.getUnitId(), r);
281
- return a ? {
319
+ if (rangeid) {
320
+ const range2 = this._definedNamesService.getValueById(workbook.getUnitId(), rangeid);
321
+ return range2 ? {
282
322
  type: "defineName",
283
- name: a.formulaOrRefString
323
+ name: range2.formulaOrRefString
284
324
  } : {
285
325
  type: "range-error",
286
326
  name: this._localeService.t("hyperLink.message.refError")
287
327
  };
288
328
  }
289
- if (t) {
290
- const a = i.getSheetBySheetId(t);
291
- return a ? {
329
+ if (gid) {
330
+ const worksheet = workbook.getSheetBySheetId(gid);
331
+ return worksheet ? {
292
332
  type: "sheet",
293
- name: a.getName()
333
+ name: worksheet.getName()
294
334
  } : {
295
335
  type: "sheet-error",
296
336
  name: this._localeService.t("hyperLink.message.refError")
@@ -298,558 +338,574 @@ let F = class {
298
338
  }
299
339
  return null;
300
340
  }
301
- navigateTo(e) {
302
- const { gid: t, range: n, rangeid: r } = e, i = this._univerInstanceService.getCurrentUnitForType(E.UNIVER_SHEET);
303
- if (!i)
341
+ navigateTo(params) {
342
+ const { gid, range, rangeid } = params, workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
343
+ if (!workbook)
304
344
  return;
305
- const o = i.getUnitId();
306
- if (r && this.navigateToDefineName(o, r), !!t) {
307
- if (n) {
308
- const s = Oe(n);
309
- ze(s.range) && n !== Ge && this.navigateToRange(o, t, s.range);
345
+ const unitId = workbook.getUnitId();
346
+ if (rangeid && this.navigateToDefineName(unitId, rangeid), !!gid) {
347
+ if (range) {
348
+ const rangeInfo = deserializeRangeWithSheet(range);
349
+ isValidRange(rangeInfo.range) && range !== ERROR_RANGE && this.navigateToRange(unitId, gid, rangeInfo.range);
310
350
  return;
311
351
  }
312
- this.navigateToSheetById(o, t);
352
+ this.navigateToSheetById(unitId, gid);
313
353
  }
314
354
  }
315
- parseHyperLink(e) {
316
- var t, n, r;
317
- if (e != null && e.startsWith("#")) {
318
- const i = new URLSearchParams(e.slice(1)), o = {
319
- gid: (t = i.get("gid")) != null ? t : "",
320
- range: (n = i.get("range")) != null ? n : "",
321
- rangeid: (r = i.get("rangeid")) != null ? r : ""
322
- }, s = this._getURLName(o);
355
+ parseHyperLink(urlStr) {
356
+ var _a14, _b, _c;
357
+ if (urlStr != null && urlStr.startsWith("#")) {
358
+ const search = new URLSearchParams(urlStr.slice(1)), searchObj = {
359
+ gid: (_a14 = search.get("gid")) != null ? _a14 : "",
360
+ range: (_b = search.get("range")) != null ? _b : "",
361
+ rangeid: (_c = search.get("rangeid")) != null ? _c : ""
362
+ }, urlInfo = this._getURLName(searchObj);
323
363
  return {
324
- type: (s == null ? void 0 : s.type) || "link",
325
- name: (s == null ? void 0 : s.name) || e,
326
- url: e,
327
- searchObj: o,
328
- handler: () => {
329
- this.navigateTo(o);
330
- }
364
+ type: (urlInfo == null ? void 0 : urlInfo.type) || "link",
365
+ name: (urlInfo == null ? void 0 : urlInfo.name) || urlStr,
366
+ url: urlStr,
367
+ searchObj,
368
+ handler: /* @__PURE__ */ __name(() => {
369
+ this.navigateTo(searchObj);
370
+ }, "handler")
331
371
  };
332
372
  } else
333
373
  return {
334
374
  type: "outer",
335
- name: e,
336
- url: e,
337
- handler: () => {
338
- this.navigateToOtherWebsite(e);
339
- }
375
+ name: urlStr,
376
+ url: urlStr,
377
+ handler: /* @__PURE__ */ __name(() => {
378
+ this.navigateToOtherWebsite(urlStr);
379
+ }, "handler")
340
380
  };
341
381
  }
342
- async navigateToRange(e, t, n) {
343
- const r = await this.navigateToSheetById(e, t);
344
- if (r) {
345
- const i = vr(n, r);
382
+ async navigateToRange(unitId, subUnitId, range) {
383
+ const worksheet = await this.navigateToSheetById(unitId, subUnitId);
384
+ if (worksheet) {
385
+ const realRange = getContainRange(range, worksheet);
346
386
  await this._commandService.executeCommand(
347
- cn.id,
387
+ SetSelectionsOperation.id,
348
388
  {
349
- unitId: e,
350
- subUnitId: t,
389
+ unitId,
390
+ subUnitId,
351
391
  selections: [{
352
- range: i
392
+ range: realRange
353
393
  }]
354
394
  }
355
- ), await this._commandService.executeCommand(kt.id, {
356
- range: i
395
+ ), await this._commandService.executeCommand(ScrollToRangeOperation.id, {
396
+ range: realRange
357
397
  });
358
398
  }
359
399
  }
360
- async navigateToSheet(e, t) {
361
- const n = this._univerInstanceService.getUnit(e, E.UNIVER_SHEET);
362
- if (!n)
400
+ async navigateToSheet(unitId, sheetName) {
401
+ const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
402
+ if (!workbook)
363
403
  return !1;
364
- const r = n.getActiveSheet();
365
- if ((r == null ? void 0 : r.getName()) === t)
404
+ const worksheet = workbook.getActiveSheet();
405
+ if ((worksheet == null ? void 0 : worksheet.getName()) === sheetName)
366
406
  return !0;
367
- const i = n.getSheetBySheetName(t);
368
- if (!i) {
407
+ const targetSheet = workbook.getSheetBySheetName(sheetName);
408
+ if (!targetSheet) {
369
409
  this._messageService.show({
370
410
  content: this._localeService.t("hyperLink.message.noSheet"),
371
- type: ce.Error
411
+ type: MessageType.Error
372
412
  });
373
413
  return;
374
414
  }
375
- const o = i.getSheetId();
376
- return n.getHiddenWorksheets().indexOf(o) > -1 && this._messageService.show({
415
+ const sheetId = targetSheet.getSheetId();
416
+ return workbook.getHiddenWorksheets().indexOf(sheetId) > -1 && this._messageService.show({
377
417
  content: this._localeService.t("hyperLink.message.hiddenSheet"),
378
- type: ce.Error
379
- }), await this._commandService.executeCommand(Ee.id, { unitId: e, subUnitId: o });
418
+ type: MessageType.Error
419
+ }), await this._commandService.executeCommand(SetWorksheetActiveOperation.id, { unitId, subUnitId: sheetId });
380
420
  }
381
- async navigateToSheetById(e, t) {
382
- const n = this._univerInstanceService.getUnit(e, E.UNIVER_SHEET);
383
- if (!n)
421
+ async navigateToSheetById(unitId, subUnitId) {
422
+ const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
423
+ if (!workbook)
384
424
  return !1;
385
- const r = n.getActiveSheet();
386
- if (!r)
425
+ const worksheet = workbook.getActiveSheet();
426
+ if (!worksheet)
387
427
  return !1;
388
- if (r.getSheetId() === t)
389
- return r;
390
- const i = n.getSheetBySheetId(t);
391
- return i ? n.getHiddenWorksheets().indexOf(t) > -1 ? (this._messageService.show({
428
+ if (worksheet.getSheetId() === subUnitId)
429
+ return worksheet;
430
+ const targetSheet = workbook.getSheetBySheetId(subUnitId);
431
+ return targetSheet ? workbook.getHiddenWorksheets().indexOf(subUnitId) > -1 ? (this._messageService.show({
392
432
  content: this._localeService.t("hyperLink.message.hiddenSheet"),
393
- type: ce.Error
394
- }), !1) : await this._commandService.executeCommand(Ee.id, { unitId: e, subUnitId: t }) ? i : !1 : (this._messageService.show({
433
+ type: MessageType.Error
434
+ }), !1) : await this._commandService.executeCommand(SetWorksheetActiveOperation.id, { unitId, subUnitId }) ? targetSheet : !1 : (this._messageService.show({
395
435
  content: this._localeService.t("hyperLink.message.noSheet"),
396
- type: ce.Error
436
+ type: MessageType.Error
397
437
  }), !1);
398
438
  }
399
- async navigateToDefineName(e, t) {
400
- return this._definedNamesService.focusRange(e, t), !0;
439
+ async navigateToDefineName(unitId, rangeid) {
440
+ return this._definedNamesService.focusRange(unitId, rangeid), !0;
401
441
  }
402
- async navigateToOtherWebsite(e) {
403
- window.open(e, "_blank", "noopener noreferrer");
442
+ async navigateToOtherWebsite(url) {
443
+ var _a14;
444
+ if ((_a14 = this._urlHandler) != null && _a14.navigateToOtherWebsite)
445
+ return this._urlHandler.navigateToOtherWebsite(url);
446
+ window.open(url, "_blank", "noopener noreferrer");
404
447
  }
405
- };
406
- F = fr([
407
- se(0, ue),
408
- se(1, K),
409
- se(2, jt),
410
- se(3, Ot),
411
- se(4, h(pe))
412
- ], F);
413
- function de(e) {
414
- return re.isLegalUrl(e);
448
+ }, __name(_a4, "SheetsHyperLinkResolverService"), _a4);
449
+ SheetsHyperLinkResolverService = __decorateClass$9([
450
+ __decorateParam$9(1, IUniverInstanceService),
451
+ __decorateParam$9(2, ICommandService),
452
+ __decorateParam$9(3, IDefinedNamesService),
453
+ __decorateParam$9(4, IMessageService),
454
+ __decorateParam$9(5, Inject(LocaleService))
455
+ ], SheetsHyperLinkResolverService);
456
+ function isLegalLink(link) {
457
+ return Tools.isLegalUrl(link);
415
458
  }
416
- function _r(e) {
417
- return /^[a-zA-Z]+:\/\//.test(e);
459
+ __name(isLegalLink, "isLegalLink");
460
+ function hasProtocol(urlString) {
461
+ return /^[a-zA-Z]+:\/\//.test(urlString);
418
462
  }
419
- function Cr(e) {
420
- return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e);
463
+ __name(hasProtocol, "hasProtocol");
464
+ function isEmail(url) {
465
+ return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
421
466
  }
422
- function rt(e) {
423
- if (de(e)) {
424
- const t = _r(e) ? e : Cr(e) ? `mailto://${e}` : `http://${e}`, n = new URL(t);
425
- return n.hostname === location.hostname && n.port === location.port && n.protocol === location.protocol && n.pathname === location.pathname && n.hash && !n.search ? n.hash : t;
467
+ __name(isEmail, "isEmail");
468
+ function serializeUrl(urlStr) {
469
+ if (isLegalLink(urlStr)) {
470
+ const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`;
471
+ let url;
472
+ try {
473
+ url = new URL(transformedUrl);
474
+ } catch {
475
+ return urlStr;
476
+ }
477
+ return url.hostname === location.hostname && url.port === location.port && url.protocol === location.protocol && url.pathname === location.pathname && url.hash && !url.search ? url.hash : transformedUrl;
426
478
  }
427
- return e;
479
+ return urlStr;
428
480
  }
429
- function yr(e) {
430
- if (e === null)
481
+ __name(serializeUrl, "serializeUrl");
482
+ function getCellValueOrigin(cell) {
483
+ if (cell === null)
431
484
  return "";
432
- if (e != null && e.p) {
433
- const t = e == null ? void 0 : e.p.body;
434
- if (t == null)
485
+ if (cell != null && cell.p) {
486
+ const body = cell == null ? void 0 : cell.p.body;
487
+ if (body == null)
435
488
  return "";
436
- const n = t.dataStream;
437
- return n.substring(n.length - 2, n.length) === Qt ? n.substring(0, n.length - 2) : n;
489
+ const data = body.dataStream;
490
+ return data.substring(data.length - 2, data.length) === DEFAULT_EMPTY_DOCUMENT_VALUE ? data.substring(0, data.length - 2) : data;
438
491
  }
439
- return e == null ? void 0 : e.v;
492
+ return cell == null ? void 0 : cell.v;
440
493
  }
441
- const Sr = "univer-cell-link-edit-buttons", Lr = {
442
- cellLinkEditButtons: Sr
443
- }, xe = () => {
444
- var ie;
445
- const [e, t] = ee(""), [n, r] = ee(""), [i, o] = ee(
446
- "link"
447
- /* link */
448
- ), [s, c] = ee(""), a = k(pe), u = k(jt), g = k(ue), f = k($), l = Un(f.currentEditing$), m = k(H), _ = k(F), v = k(K), [L, M] = ee(!1), y = wt(!1);
449
- Et(() => {
450
- var p, S, I;
451
- if ((l == null ? void 0 : l.row) !== void 0 && l.column !== void 0) {
452
- const C = m.getHyperLinkByLocationSync(l.unitId, l.subUnitId, l.row, l.column);
453
- if (C) {
454
- const ge = _.parseHyperLink(C.payload);
455
- if (t(C.id), r(C.display), ge.type === "outer") {
456
- o(
457
- "link"
458
- /* link */
459
- ), c(ge.url), ge.url === C.display && (y.current = !0);
494
+ __name(getCellValueOrigin, "getCellValueOrigin");
495
+ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
496
+ cellLinkEditButtons
497
+ }, CellLinkEdit = /* @__PURE__ */ __name(() => {
498
+ var _a14;
499
+ const [id, setId] = useState(""), [display, setDisplay] = useState(""), [type, setType] = useState(LinkType.link), [payload, setPayload] = useState(""), localeService = useDependency(LocaleService), definedNameService = useDependency(IDefinedNamesService), univerInstanceService = useDependency(IUniverInstanceService), popupService = useDependency(SheetsHyperLinkPopupService), editing = useObservable(popupService.currentEditing$), hyperLinkModel = useDependency(HyperLinkModel), resolverService = useDependency(SheetsHyperLinkResolverService), commandService = useDependency(ICommandService), sidePanelService = useDependency(SheetsHyperLinkSidePanelService), sidePanelOptions = useMemo(() => sidePanelService.getOptions(), [sidePanelService]), customHyperLinkSidePanel = useMemo(() => {
500
+ if (!sidePanelService.isBuiltInLinkType(type))
501
+ return sidePanelService.getCustomHyperLink(type);
502
+ }, [sidePanelService, type]), [showError, setShowError] = useState(!1), setByPayload = useRef(!1);
503
+ useEffect(() => {
504
+ var _a15, _b, _c;
505
+ if ((editing == null ? void 0 : editing.row) !== void 0 && editing.column !== void 0) {
506
+ const link = hyperLinkModel.getHyperLinkByLocationSync(editing.unitId, editing.subUnitId, editing.row, editing.column);
507
+ if (link) {
508
+ setId(link.id);
509
+ const customLink = sidePanelService.findCustomHyperLink(link);
510
+ if (customLink) {
511
+ const customLinkInfo = customLink.convert(link);
512
+ setType(customLinkInfo.type), setPayload(customLinkInfo.payload), setDisplay(customLinkInfo.display);
513
+ return;
514
+ }
515
+ setDisplay(link.display);
516
+ const linkInfo = resolverService.parseHyperLink(link.payload);
517
+ if (linkInfo.type === "outer") {
518
+ setType(LinkType.link), setPayload(linkInfo.url), linkInfo.url === link.display && (setByPayload.current = !0);
460
519
  return;
461
520
  } else {
462
- const N = ge.searchObj;
463
- if (N.rangeid) {
464
- o(
465
- "rangeid"
466
- /* definedName */
467
- ), c(N.rangeid);
521
+ const params = linkInfo.searchObj;
522
+ if (params.rangeid) {
523
+ setType(LinkType.definedName), setPayload(params.rangeid);
468
524
  return;
469
525
  }
470
- if (N.range) {
471
- const zt = N.gid && (I = (S = (p = g.getUnit(l.unitId)) == null ? void 0 : p.getSheetBySheetId(N.gid)) == null ? void 0 : S.getName()) != null ? I : "";
472
- if (o(
473
- "range"
474
- /* range */
475
- ), N.range === Ge)
476
- c("");
526
+ if (params.range) {
527
+ const sheetName = params.gid && (_c = (_b = (_a15 = univerInstanceService.getUnit(editing.unitId)) == null ? void 0 : _a15.getSheetBySheetId(params.gid)) == null ? void 0 : _b.getName()) != null ? _c : "";
528
+ if (setType(LinkType.range), params.range === ERROR_RANGE)
529
+ setPayload("");
477
530
  else {
478
- const ct = Ht(zt, Oe(N.range).range);
479
- c(ct), ct === C.display && (y.current = !0);
531
+ const payload2 = serializeRangeWithSheet(sheetName, deserializeRangeWithSheet(params.range).range);
532
+ setPayload(payload2), payload2 === link.display && (setByPayload.current = !0);
480
533
  }
481
534
  return;
482
535
  }
483
- if (N.gid) {
484
- o(
485
- "gid"
486
- /* sheet */
487
- ), c(N.gid);
536
+ if (params.gid) {
537
+ setType(LinkType.sheet), setPayload(params.gid);
488
538
  return;
489
539
  }
490
540
  }
491
541
  }
492
- const j = g.getUnit(l.unitId), w = j == null ? void 0 : j.getSheetBySheetId(l.subUnitId), Zt = w == null ? void 0 : w.getCellRaw(l.row, l.column), Fe = yr(Zt);
493
- o(
494
- "link"
495
- /* link */
496
- ), c(""), r((Fe != null ? Fe : "").toString()), t("");
542
+ const workbook2 = univerInstanceService.getUnit(editing.unitId), worksheet = workbook2 == null ? void 0 : workbook2.getSheetBySheetId(editing.subUnitId), cell = worksheet == null ? void 0 : worksheet.getCellRaw(editing.row, editing.column), cellValue = getCellValueOrigin(cell);
543
+ setType(LinkType.link), setPayload(""), setDisplay((cellValue != null ? cellValue : "").toString()), setId("");
497
544
  return;
498
545
  }
499
- o(
500
- "link"
501
- /* link */
502
- ), c(""), r(""), t("");
503
- }, [l, m, _, g]);
504
- const V = Tn(() => s, [i]), R = [
546
+ setType(LinkType.link), setPayload(""), setDisplay(""), setId("");
547
+ }, [editing, hyperLinkModel, resolverService, univerInstanceService]);
548
+ const payloadInitial = useMemo(() => payload, [type]), linkTypeOptions = [
505
549
  {
506
- label: a.t("hyperLink.form.link"),
507
- value: "link"
508
- /* link */
550
+ label: localeService.t("hyperLink.form.link"),
551
+ value: LinkType.link
509
552
  },
510
553
  {
511
- label: a.t("hyperLink.form.range"),
512
- value: "range"
513
- /* range */
554
+ label: localeService.t("hyperLink.form.range"),
555
+ value: LinkType.range
514
556
  },
515
557
  {
516
- label: a.t("hyperLink.form.worksheet"),
517
- value: "gid"
518
- /* sheet */
558
+ label: localeService.t("hyperLink.form.worksheet"),
559
+ value: LinkType.sheet
519
560
  },
520
561
  {
521
- label: a.t("hyperLink.form.definedName"),
522
- value: "rangeid"
523
- /* definedName */
524
- }
525
- ], P = g.getCurrentUnitForType(E.UNIVER_SHEET);
526
- if (!P)
562
+ label: localeService.t("hyperLink.form.definedName"),
563
+ value: LinkType.definedName
564
+ },
565
+ ...sidePanelOptions
566
+ ], workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
567
+ if (!workbook)
527
568
  return;
528
- const G = P.getHiddenWorksheets(), A = P.getSheets().map((p) => ({ label: p.getName(), value: p.getSheetId() })).filter((p) => G.indexOf(p.value) === -1), q = Object.values((ie = u.getDefinedNameMap(P.getUnitId())) != null ? ie : {}).map((p) => ({
529
- label: p.name,
530
- value: p.id
531
- })), he = (p, S) => {
532
- if (p === "link")
533
- return rt(S);
534
- if (p === "range") {
535
- const I = Oe(S), C = P.getSheetBySheetName(I.sheetName);
536
- if (C)
537
- return `#gid=${C.getSheetId()}&range=${Fn(I.range)}`;
569
+ 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((_a14 = definedNameService.getDefinedNameMap(workbook.getUnitId())) != null ? _a14 : {}).map((value) => ({
570
+ label: value.name,
571
+ value: value.id
572
+ })), formatUrl = /* @__PURE__ */ __name((type2, payload2) => {
573
+ if (type2 === LinkType.link)
574
+ return serializeUrl(payload2);
575
+ if (type2 === LinkType.range) {
576
+ const info = deserializeRangeWithSheet(payload2), worksheet = workbook.getSheetBySheetName(info.sheetName);
577
+ if (worksheet)
578
+ return `#gid=${worksheet.getSheetId()}&range=${serializeRange(info.range)}`;
538
579
  }
539
- return `#${p}=${S}`;
540
- }, We = Hn((p) => {
541
- var C;
542
- const S = p[0];
543
- if (!S || !ze(S.range))
580
+ return `#${type2}=${payload2}`;
581
+ }, "formatUrl"), handleRangeChange = useEvent((newValue) => {
582
+ var _a15;
583
+ const range = newValue[0];
584
+ if (!range || !isValidRange(range.range))
544
585
  return;
545
- S.sheetName || (S.sheetName = ((C = P.getActiveSheet()) == null ? void 0 : C.getName()) || "");
546
- const I = Wn(S);
547
- c(I), I && (y.current || !n) && (r(I), y.current = !0);
548
- }), me = async () => {
549
- if (l && (e ? await v.executeCommand(St.id, {
550
- unitId: l.unitId,
551
- subUnitId: l.subUnitId,
552
- id: e,
586
+ range.sheetName || (range.sheetName = ((_a15 = workbook.getActiveSheet()) == null ? void 0 : _a15.getName()) || "");
587
+ const newPayload = serializeRangeToRefString(range);
588
+ setPayload(newPayload), newPayload && (setByPayload.current || !display) && (setDisplay(newPayload), setByPayload.current = !0);
589
+ }), handleSubmit = /* @__PURE__ */ __name(async () => {
590
+ if (editing && (id ? await commandService.executeCommand(UpdateHyperLinkCommand.id, {
591
+ unitId: editing.unitId,
592
+ subUnitId: editing.subUnitId,
593
+ id,
553
594
  payload: {
554
- display: n,
555
- payload: he(i, s)
595
+ display,
596
+ payload: formatUrl(type, payload)
556
597
  }
557
- }) : await v.executeCommand(Lt.id, {
558
- unitId: l.unitId,
559
- subUnitId: l.subUnitId,
598
+ }) : await commandService.executeCommand(AddHyperLinkCommand.id, {
599
+ unitId: editing.unitId,
600
+ subUnitId: editing.subUnitId,
560
601
  link: {
561
- id: re.generateRandomId(),
562
- row: l.row,
563
- column: l.column,
564
- payload: he(i, s),
565
- display: n
602
+ id: Tools.generateRandomId(),
603
+ row: editing.row,
604
+ column: editing.column,
605
+ payload: formatUrl(type, payload),
606
+ display
566
607
  }
567
- })), l) {
568
- await v.executeCommand(Ee.id, {
569
- unitId: l.unitId,
570
- subUnitId: l.subUnitId
608
+ })), editing) {
609
+ await commandService.executeCommand(SetWorksheetActiveOperation.id, {
610
+ unitId: editing.unitId,
611
+ subUnitId: editing.subUnitId
571
612
  });
572
- const p = 1;
573
- await v.executeCommand(kt.id, {
613
+ const GAP = 1;
614
+ await commandService.executeCommand(ScrollToRangeOperation.id, {
574
615
  range: {
575
- startRow: Math.max(l.row - p, 0),
576
- endRow: l.row + p,
577
- startColumn: Math.max(l.column - p, 0),
578
- endColumn: l.column + p
616
+ startRow: Math.max(editing.row - GAP, 0),
617
+ endRow: editing.row + GAP,
618
+ startColumn: Math.max(editing.column - GAP, 0),
619
+ endColumn: editing.column + GAP
579
620
  }
580
621
  });
581
622
  }
582
- v.executeCommand(Te.id);
583
- };
584
- return /* @__PURE__ */ d.jsxs("div", { children: [
585
- /* @__PURE__ */ d.jsx(
586
- X,
623
+ commandService.executeCommand(CloseHyperLinkSidebarOperation.id);
624
+ }, "handleSubmit");
625
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
626
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
627
+ FormLayout,
587
628
  {
588
- label: a.t("hyperLink.form.label"),
589
- error: L && !n ? a.t("hyperLink.form.inputError") : "",
590
- children: /* @__PURE__ */ d.jsx(
591
- ht,
629
+ label: localeService.t("hyperLink.form.label"),
630
+ error: showError && !display ? localeService.t("hyperLink.form.inputError") : "",
631
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
632
+ Input,
592
633
  {
593
- value: n,
594
- onChange: (p) => {
595
- r(p), y.current = !1;
596
- },
597
- placeholder: a.t("hyperLink.form.labelPlaceholder")
634
+ value: display,
635
+ onChange: /* @__PURE__ */ __name((v) => {
636
+ setDisplay(v), setByPayload.current = !1;
637
+ }, "onChange"),
638
+ placeholder: localeService.t("hyperLink.form.labelPlaceholder")
598
639
  }
599
640
  )
600
641
  }
601
642
  ),
602
- /* @__PURE__ */ d.jsx(X, { label: a.t("hyperLink.form.type"), children: /* @__PURE__ */ d.jsx(
603
- Ke,
643
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("hyperLink.form.type"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
644
+ Select,
604
645
  {
605
- options: R,
606
- value: i,
607
- onChange: (p) => {
608
- o(p), c("");
609
- }
646
+ options: linkTypeOptions,
647
+ value: type,
648
+ onChange: /* @__PURE__ */ __name((newType) => {
649
+ setType(newType), setPayload("");
650
+ }, "onChange")
610
651
  }
611
652
  ) }),
612
- i === "link" && /* @__PURE__ */ d.jsx(
613
- X,
653
+ type === LinkType.link && /* @__PURE__ */ jsxRuntimeExports.jsx(
654
+ FormLayout,
614
655
  {
615
- error: L ? s ? de(s) ? "" : a.t("hyperLink.form.linkError") : a.t("hyperLink.form.inputError") : "",
616
- children: /* @__PURE__ */ d.jsx(
617
- ht,
656
+ error: showError ? payload ? isLegalLink(payload) ? "" : localeService.t("hyperLink.form.linkError") : localeService.t("hyperLink.form.inputError") : "",
657
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
658
+ Input,
618
659
  {
619
- value: s,
620
- onChange: (p) => {
621
- c(p), p && (y.current || !n || n === s) && (r(p), y.current = !0);
622
- },
623
- placeholder: a.t("hyperLink.form.linkPlaceholder")
660
+ value: payload,
661
+ onChange: /* @__PURE__ */ __name((newLink) => {
662
+ setPayload(newLink), newLink && (setByPayload.current || !display || display === payload) && (setDisplay(newLink), setByPayload.current = !0);
663
+ }, "onChange"),
664
+ placeholder: localeService.t("hyperLink.form.linkPlaceholder")
624
665
  }
625
666
  )
626
667
  }
627
668
  ),
628
- i === "range" && /* @__PURE__ */ d.jsx(X, { error: L && !s ? a.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ d.jsx(
629
- jn,
669
+ type === LinkType.range && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
670
+ RangeSelector,
630
671
  {
631
- openForSheetUnitId: P.getUnitId(),
632
- id: en("hyper-link-edit"),
672
+ openForSheetUnitId: workbook.getUnitId(),
673
+ id: createInternalEditorID("hyper-link-edit"),
633
674
  isSingleChoice: !0,
634
- value: V,
635
- onChange: We
675
+ value: payloadInitial,
676
+ onChange: handleRangeChange
636
677
  }
637
678
  ) }),
638
- i === "gid" && /* @__PURE__ */ d.jsx(X, { error: L && !s ? a.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ d.jsx(
639
- Ke,
679
+ type === LinkType.sheet && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
680
+ Select,
640
681
  {
641
- options: A,
642
- value: s,
643
- onChange: (p) => {
644
- var C, j;
645
- c(p);
646
- const S = (C = A.find((w) => w.value === p)) == null ? void 0 : C.label, I = (j = A.find((w) => w.value === s)) == null ? void 0 : j.label;
647
- S && (y.current || !n || n === I) && (r(S), y.current = !0);
648
- }
682
+ options: sheetsOption,
683
+ value: payload,
684
+ onChange: /* @__PURE__ */ __name((newPayload) => {
685
+ var _a15, _b;
686
+ setPayload(newPayload);
687
+ const label = (_a15 = sheetsOption.find((i) => i.value === newPayload)) == null ? void 0 : _a15.label, oldLabel = (_b = sheetsOption.find((i) => i.value === payload)) == null ? void 0 : _b.label;
688
+ label && (setByPayload.current || !display || display === oldLabel) && (setDisplay(label), setByPayload.current = !0);
689
+ }, "onChange")
649
690
  }
650
691
  ) }),
651
- i === "rangeid" && /* @__PURE__ */ d.jsx(X, { error: L && !s ? a.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ d.jsx(
652
- Ke,
692
+ type === LinkType.definedName && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
693
+ Select,
653
694
  {
654
- options: q,
655
- value: s,
656
- onChange: (p) => {
657
- var C, j;
658
- c(p);
659
- const S = (C = q.find((w) => w.value === p)) == null ? void 0 : C.label, I = (j = q.find((w) => w.value === s)) == null ? void 0 : j.label;
660
- S && (y.current || !n || n === I) && (r(S), y.current = !0);
661
- }
695
+ options: definedNames,
696
+ value: payload,
697
+ onChange: /* @__PURE__ */ __name((newValue) => {
698
+ var _a15, _b;
699
+ setPayload(newValue);
700
+ const label = (_a15 = definedNames.find((i) => i.value === newValue)) == null ? void 0 : _a15.label, oldLabel = (_b = definedNames.find((i) => i.value === payload)) == null ? void 0 : _b.label;
701
+ label && (setByPayload.current || !display || display === oldLabel) && (setDisplay(label), setByPayload.current = !0);
702
+ }, "onChange")
662
703
  }
663
704
  ) }),
664
- /* @__PURE__ */ d.jsxs("div", { className: Lr.cellLinkEditButtons, children: [
665
- /* @__PURE__ */ d.jsx(
666
- mt,
705
+ (customHyperLinkSidePanel == null ? void 0 : customHyperLinkSidePanel.Form) && /* @__PURE__ */ jsxRuntimeExports.jsx(
706
+ customHyperLinkSidePanel.Form,
707
+ {
708
+ linkId: id,
709
+ payload,
710
+ display,
711
+ showError,
712
+ setByPayload,
713
+ setDisplay: /* @__PURE__ */ __name((newLink) => {
714
+ setDisplay(newLink), setByPayload.current = !0;
715
+ }, "setDisplay"),
716
+ setPayload
717
+ }
718
+ ),
719
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkEditButtons, children: [
720
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
721
+ Button,
667
722
  {
668
- onClick: () => {
669
- l && v.executeCommand(Ee.id, {
670
- unitId: l.unitId,
671
- subUnitId: l.subUnitId
672
- }), v.executeCommand(Te.id);
673
- },
674
- children: a.t("hyperLink.form.cancel")
723
+ onClick: /* @__PURE__ */ __name(() => {
724
+ editing && commandService.executeCommand(SetWorksheetActiveOperation.id, {
725
+ unitId: editing.unitId,
726
+ subUnitId: editing.subUnitId
727
+ }), commandService.executeCommand(CloseHyperLinkSidebarOperation.id);
728
+ }, "onClick"),
729
+ children: localeService.t("hyperLink.form.cancel")
675
730
  }
676
731
  ),
677
- /* @__PURE__ */ d.jsx(
678
- mt,
732
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
733
+ Button,
679
734
  {
680
735
  type: "primary",
681
736
  style: { marginLeft: 8 },
682
- onClick: async () => {
683
- if (!n || !s || i === "link" && !de(s)) {
684
- M(!0);
737
+ onClick: /* @__PURE__ */ __name(async () => {
738
+ if (!display || !payload || type === LinkType.link && !isLegalLink(payload)) {
739
+ setShowError(!0);
685
740
  return;
686
741
  }
687
- me();
688
- },
689
- children: a.t("hyperLink.form.ok")
742
+ handleSubmit();
743
+ }, "onClick"),
744
+ children: localeService.t("hyperLink.form.ok")
690
745
  }
691
746
  )
692
747
  ] })
693
748
  ] });
694
- };
695
- xe.componentKey = "univer.sheet.cell-link-edit";
696
- const it = {
697
- type: je.OPERATION,
749
+ }, "CellLinkEdit");
750
+ CellLinkEdit.componentKey = "univer.sheet.cell-link-edit";
751
+ const OpenHyperLinkSidebarOperation = {
752
+ type: CommandType.OPERATION,
698
753
  id: "sheet.operation.open-hyper-link-sidebar",
699
- handler(e, t) {
700
- if (!t)
754
+ handler(accessor, params) {
755
+ if (!params)
701
756
  return !1;
702
- const { unitId: n, subUnitId: r, row: i, column: o } = t, s = e.get(H), c = e.get(Mt), a = e.get($), u = s.getHyperLinkByLocation(n, r, i, o);
703
- return a.startEditing(t), c.open({
757
+ const { unitId, subUnitId, row, column } = params, hyperLinkModel = accessor.get(HyperLinkModel), sidebarService = accessor.get(ISidebarService), popupService = accessor.get(SheetsHyperLinkPopupService), currentLink = hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
758
+ return popupService.startEditing(params), sidebarService.open({
704
759
  header: {
705
- title: u ? "hyperLink.form.editTitle" : "hyperLink.form.addTitle"
760
+ title: currentLink ? "hyperLink.form.editTitle" : "hyperLink.form.addTitle"
706
761
  },
707
762
  children: {
708
- label: xe.componentKey
763
+ label: CellLinkEdit.componentKey
709
764
  }
710
765
  }), !0;
711
766
  }
712
- }, Te = {
713
- type: je.OPERATION,
767
+ }, CloseHyperLinkSidebarOperation = {
768
+ type: CommandType.OPERATION,
714
769
  id: "sheet.operation.close-hyper-link-sidebar",
715
- handler(e) {
716
- const t = e.get(Mt), n = e.get($);
717
- return t.close(), n.endEditing(), !0;
770
+ handler(accessor) {
771
+ const sidebarService = accessor.get(ISidebarService), popupService = accessor.get(SheetsHyperLinkPopupService);
772
+ return sidebarService.close(), popupService.endEditing(), !0;
718
773
  }
719
- }, ot = {
720
- type: je.OPERATION,
774
+ }, InsertHyperLinkOperation = {
775
+ type: CommandType.OPERATION,
721
776
  id: "sheet.operation.insert-hyper-link",
722
- handler(e) {
723
- const t = e.get(ue), n = Ct(t);
724
- if (!n)
777
+ handler(accessor) {
778
+ const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
779
+ if (!target)
725
780
  return !1;
726
- const r = e.get(K), o = e.get(yt).getCurrentLastSelection();
727
- if (!o)
781
+ const commandService = accessor.get(ICommandService), selection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
782
+ if (!selection)
728
783
  return !1;
729
- const s = o.primary.startRow, c = o.primary.startColumn;
730
- return r.executeCommand(it.id, {
731
- unitId: n.unitId,
732
- subUnitId: n.subUnitId,
733
- row: s,
734
- column: c
784
+ const row = selection.primary.startRow, column = selection.primary.startColumn;
785
+ return commandService.executeCommand(OpenHyperLinkSidebarOperation.id, {
786
+ unitId: target.unitId,
787
+ subUnitId: target.subUnitId,
788
+ row,
789
+ column
735
790
  });
736
791
  }
737
- }, st = {
738
- type: je.OPERATION,
792
+ }, InsertHyperLinkToolbarOperation = {
793
+ type: CommandType.OPERATION,
739
794
  id: "sheet.operation.insert-hyper-link-toolbar",
740
- handler(e) {
741
- const t = e.get(K);
742
- return e.get($).currentEditing ? t.executeCommand(Te.id) : t.executeCommand(ot.id);
743
- }
744
- }, Ir = "univer-cell-link", kr = "univer-cell-link-type", Pr = "univer-cell-link-content", br = "univer-cell-link-content-error", Rr = "univer-cell-link-url", wr = "univer-cell-link-operations", Er = "univer-cell-link-operation", Or = "univer-cell-link-operation-error", x = {
745
- cellLink: Ir,
746
- cellLinkType: kr,
747
- cellLinkContent: Pr,
748
- cellLinkContentError: br,
749
- cellLinkUrl: Rr,
750
- cellLinkOperations: wr,
751
- cellLinkOperation: Er,
752
- cellLinkOperationError: Or
753
- }, Mr = {
754
- outer: /* @__PURE__ */ d.jsx(Me, {}),
755
- link: /* @__PURE__ */ d.jsx(Me, {}),
756
- sheet: /* @__PURE__ */ d.jsx(Je, {}),
757
- range: /* @__PURE__ */ d.jsx(Le, {}),
758
- defineName: /* @__PURE__ */ d.jsx(Le, {}),
759
- "range-error": /* @__PURE__ */ d.jsx(Le, {}),
760
- "sheet-error": /* @__PURE__ */ d.jsx(Je, {})
761
- }, Ue = () => {
762
- const e = k($), t = k(H), n = k(K), r = k(Ot), i = k(pe), [o, s] = ee(null), c = k(F);
763
- if (Et(() => {
764
- s(e.currentPopup);
765
- const _ = e.currentPopup$.subscribe((v) => {
766
- s(v);
795
+ handler(accessor) {
796
+ const commandService = accessor.get(ICommandService);
797
+ return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkSidebarOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
798
+ }
799
+ }, cellLink = "univer-cell-link", cellLinkType = "univer-cell-link-type", cellLinkContent = "univer-cell-link-content", cellLinkContentError = "univer-cell-link-content-error", cellLinkUrl = "univer-cell-link-url", cellLinkOperations = "univer-cell-link-operations", cellLinkOperation = "univer-cell-link-operation", cellLinkOperationError = "univer-cell-link-operation-error", styles = {
800
+ cellLink,
801
+ cellLinkType,
802
+ cellLinkContent,
803
+ cellLinkContentError,
804
+ cellLinkUrl,
805
+ cellLinkOperations,
806
+ cellLinkOperation,
807
+ cellLinkOperationError
808
+ }, iconsMap = {
809
+ outer: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkSingle, {}),
810
+ link: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkSingle, {}),
811
+ sheet: /* @__PURE__ */ jsxRuntimeExports.jsx(Xlsx, {}),
812
+ range: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
813
+ defineName: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
814
+ "range-error": /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
815
+ "sheet-error": /* @__PURE__ */ jsxRuntimeExports.jsx(Xlsx, {})
816
+ }, CellLinkPopup = /* @__PURE__ */ __name(() => {
817
+ const popupService = useDependency(SheetsHyperLinkPopupService), hyperLinkModel = useDependency(HyperLinkModel), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), [currentPopup, setCurrentPopup] = useState(null), resolverService = useDependency(SheetsHyperLinkResolverService);
818
+ if (useEffect(() => {
819
+ setCurrentPopup(popupService.currentPopup);
820
+ const ob = popupService.currentPopup$.subscribe((popup) => {
821
+ setCurrentPopup(popup);
767
822
  });
768
823
  return () => {
769
- _.unsubscribe();
824
+ ob.unsubscribe();
770
825
  };
771
- }, [e.currentPopup, e.currentPopup$]), !o)
826
+ }, [popupService.currentPopup, popupService.currentPopup$]), !currentPopup)
772
827
  return null;
773
- const { unitId: a, subUnitId: u, id: g } = o, f = t.getHyperLink(a, u, g);
774
- if (!f)
828
+ const { unitId, subUnitId, id } = currentPopup, link = hyperLinkModel.getHyperLink(unitId, subUnitId, id);
829
+ if (!link)
775
830
  return null;
776
- const l = c.parseHyperLink(f.payload), m = l.type.indexOf("error") > -1;
777
- return /* @__PURE__ */ d.jsxs("div", { className: x.cellLink, onClick: () => e.hideCurrentPopup(), children: [
778
- /* @__PURE__ */ d.jsxs("div", { className: pt(x.cellLinkContent, { [x.cellLinkContentError]: m }), onClick: l.handler, children: [
779
- /* @__PURE__ */ d.jsx("div", { className: x.cellLinkType, children: Mr[l.type] }),
780
- /* @__PURE__ */ d.jsx(_e, { showIfEllipsis: !0, title: l.name, children: /* @__PURE__ */ d.jsx("span", { className: x.cellLinkUrl, children: l.name }) })
831
+ const linkObj = resolverService.parseHyperLink(link.payload), isError = linkObj.type.indexOf("error") > -1;
832
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLink, onClick: /* @__PURE__ */ __name(() => popupService.hideCurrentPopup(), "onClick"), children: [
833
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cs(styles.cellLinkContent, { [styles.cellLinkContentError]: isError }), onClick: linkObj.handler, children: [
834
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.cellLinkType, children: iconsMap[linkObj.type] }),
835
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { showIfEllipsis: !0, title: linkObj.name, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles.cellLinkUrl, children: linkObj.name }) })
781
836
  ] }),
782
- /* @__PURE__ */ d.jsxs("div", { className: x.cellLinkOperations, children: [
783
- o.copyPermission && /* @__PURE__ */ d.jsx(
837
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLinkOperations, children: [
838
+ currentPopup.copyPermission && /* @__PURE__ */ jsxRuntimeExports.jsx(
784
839
  "div",
785
840
  {
786
- className: pt(x.cellLinkOperation, { [x.cellLinkOperationError]: m }),
787
- onClick: () => {
788
- if (!m) {
789
- if (l.type !== "outer") {
790
- const _ = new URL(window.location.href);
791
- _.hash = l.url.slice(1), navigator.clipboard.writeText(_.href);
841
+ className: cs(styles.cellLinkOperation, { [styles.cellLinkOperationError]: isError }),
842
+ onClick: /* @__PURE__ */ __name(() => {
843
+ if (!isError) {
844
+ if (linkObj.type !== "outer") {
845
+ const url = new URL(window.location.href);
846
+ url.hash = linkObj.url.slice(1), navigator.clipboard.writeText(url.href);
792
847
  } else
793
- navigator.clipboard.writeText(l.url);
794
- r.show({
795
- content: i.t("hyperLink.message.coped"),
796
- type: ce.Info
848
+ navigator.clipboard.writeText(linkObj.url);
849
+ messageService.show({
850
+ content: localeService.t("hyperLink.message.coped"),
851
+ type: MessageType.Info
797
852
  });
798
853
  }
799
- },
800
- children: /* @__PURE__ */ d.jsx(_e, { placement: "bottom", title: i.t("hyperLink.popup.copy"), children: /* @__PURE__ */ d.jsx(Vt, {}) })
854
+ }, "onClick"),
855
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.copy"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopySingle, {}) })
801
856
  }
802
857
  ),
803
- o.editPermission && /* @__PURE__ */ d.jsxs(d.Fragment, { children: [
804
- /* @__PURE__ */ d.jsx(
858
+ currentPopup.editPermission && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
859
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
805
860
  "div",
806
861
  {
807
- className: x.cellLinkOperation,
808
- onClick: () => {
809
- n.executeCommand(it.id, {
810
- unitId: a,
811
- subUnitId: u,
812
- row: f.row,
813
- column: f.column
862
+ className: styles.cellLinkOperation,
863
+ onClick: /* @__PURE__ */ __name(() => {
864
+ commandService.executeCommand(OpenHyperLinkSidebarOperation.id, {
865
+ unitId,
866
+ subUnitId,
867
+ row: link.row,
868
+ column: link.column
814
869
  });
815
- },
816
- children: /* @__PURE__ */ d.jsx(_e, { placement: "bottom", title: i.t("hyperLink.popup.edit"), children: /* @__PURE__ */ d.jsx(Wt, {}) })
870
+ }, "onClick"),
871
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.edit"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(WriteSingle, {}) })
817
872
  }
818
873
  ),
819
- /* @__PURE__ */ d.jsx(
874
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
820
875
  "div",
821
876
  {
822
- className: x.cellLinkOperation,
823
- onClick: () => {
824
- n.executeCommand(_n.id, {
825
- unitId: a,
826
- subUnitId: u,
827
- id: f.id
877
+ className: styles.cellLinkOperation,
878
+ onClick: /* @__PURE__ */ __name(() => {
879
+ commandService.executeCommand(CancelHyperLinkCommand.id, {
880
+ unitId,
881
+ subUnitId,
882
+ id: link.id
828
883
  });
829
- },
830
- children: /* @__PURE__ */ d.jsx(_e, { placement: "bottom", title: i.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ d.jsx(At, {}) })
884
+ }, "onClick"),
885
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(UnlinkSingle, {}) })
831
886
  }
832
887
  )
833
888
  ] })
834
889
  ] })
835
890
  ] });
836
- };
837
- Ue.componentKey = "univer.sheet.cell-link-popup";
838
- var xr = Object.defineProperty, Tr = Object.getOwnPropertyDescriptor, Ur = (e, t, n, r) => {
839
- for (var i = r > 1 ? void 0 : r ? Tr(t, n) : t, o = e.length - 1, s; o >= 0; o--)
840
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
841
- return r && i && xr(t, n, i), i;
842
- }, gt = (e, t) => (n, r) => t(n, r, e);
843
- const Hr = (e, t) => e.unitId === t.unitId && e.subUnitId === t.subUnitId && e.row === t.row && e.col === t.col;
844
- let $ = class extends O {
845
- constructor(t, n) {
891
+ }, "CellLinkPopup");
892
+ CellLinkPopup.componentKey = "univer.sheet.cell-link-popup";
893
+ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
894
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
895
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
896
+ return kind && result && __defProp$8(target, key, result), result;
897
+ }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8");
898
+ const isEqualLink = /* @__PURE__ */ __name((a, b) => a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.row === b.row && a.col === b.col, "isEqualLink");
899
+ var _a5;
900
+ let SheetsHyperLinkPopupService = (_a5 = class extends Disposable {
901
+ constructor(_hyperLinkModel, _sheetCanvasPopManagerService) {
846
902
  super();
847
- W(this, "_currentPopup", null);
848
- W(this, "_currentPopup$", new On());
849
- W(this, "currentPopup$", this._currentPopup$.asObservable());
850
- W(this, "_currentEditing$", new Mn(null));
851
- W(this, "currentEditing$", this._currentEditing$.asObservable());
852
- this._hyperLinkModel = t, this._sheetCanvasPopManagerService = n, this.disposeWithMe(() => {
903
+ __publicField(this, "_currentPopup", null);
904
+ __publicField(this, "_currentPopup$", new Subject());
905
+ __publicField(this, "currentPopup$", this._currentPopup$.asObservable());
906
+ __publicField(this, "_currentEditing$", new BehaviorSubject(null));
907
+ __publicField(this, "currentEditing$", this._currentEditing$.asObservable());
908
+ this._hyperLinkModel = _hyperLinkModel, this._sheetCanvasPopManagerService = _sheetCanvasPopManagerService, this.disposeWithMe(() => {
853
909
  this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete();
854
910
  });
855
911
  }
@@ -859,78 +915,78 @@ let $ = class extends O {
859
915
  get currentEditing() {
860
916
  return this._currentEditing$.getValue();
861
917
  }
862
- showPopup(t) {
863
- if (this._currentPopup && Hr(t, this._currentPopup))
918
+ showPopup(location2) {
919
+ if (this._currentPopup && isEqualLink(location2, this._currentPopup))
864
920
  return;
865
921
  this.hideCurrentPopup();
866
- const { unitId: n, subUnitId: r, row: i, col: o } = t, s = this._hyperLinkModel.getHyperLinkByLocation(n, r, i, o);
867
- if (!s)
922
+ const { unitId, subUnitId, row, col } = location2, link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
923
+ if (!link)
868
924
  return;
869
- const c = this._sheetCanvasPopManagerService.attachPopupToCell(i, o, {
870
- componentKey: Ue.componentKey,
925
+ const disposable = this._sheetCanvasPopManagerService.attachPopupToCell(row, col, {
926
+ componentKey: CellLinkPopup.componentKey,
871
927
  direction: "bottom",
872
928
  closeOnSelfTarget: !0,
873
- onClickOutside: () => {
929
+ onClickOutside: /* @__PURE__ */ __name(() => {
874
930
  this.hideCurrentPopup();
875
- }
931
+ }, "onClickOutside")
876
932
  });
877
- c && (this._currentPopup = {
878
- unitId: n,
879
- subUnitId: r,
880
- id: s.id,
881
- disposable: c,
882
- row: i,
883
- col: o,
884
- editPermission: !!t.editPermission,
885
- copyPermission: !!t.copyPermission
933
+ disposable && (this._currentPopup = {
934
+ unitId,
935
+ subUnitId,
936
+ id: link.id,
937
+ disposable,
938
+ row,
939
+ col,
940
+ editPermission: !!location2.editPermission,
941
+ copyPermission: !!location2.copyPermission
886
942
  }, this._currentPopup$.next(this._currentPopup));
887
943
  }
888
944
  hideCurrentPopup() {
889
- var t;
890
- this._currentPopup && ((t = this._currentPopup.disposable) == null || t.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
945
+ var _a14;
946
+ this._currentPopup && ((_a14 = this._currentPopup.disposable) == null || _a14.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
891
947
  }
892
- startEditing(t) {
893
- this._currentEditing$.next(t);
948
+ startEditing(link) {
949
+ this._currentEditing$.next(link);
894
950
  }
895
951
  endEditing() {
896
952
  this._currentEditing$.next(null);
897
953
  }
898
- };
899
- $ = Ur([
900
- gt(0, h(H)),
901
- gt(1, h(yn))
902
- ], $);
903
- var jr = Object.defineProperty, Nr = Object.getOwnPropertyDescriptor, $r = (e, t, n, r) => {
904
- for (var i = r > 1 ? void 0 : r ? Nr(t, n) : t, o = e.length - 1, s; o >= 0; o--)
905
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
906
- return r && i && jr(t, n, i), i;
907
- }, J = (e, t) => (n, r) => t(n, r, e);
908
- let Ie = class extends O {
909
- constructor(e, t, n, r, i, o) {
910
- super(), this._sheetInterceptorService = e, this._injector = t, this._hyperLinkModel = n, this._selectionManagerService = r, this._univerInstanceService = i, this._editorBridgeService = o, this._initCommandInterceptor();
954
+ }, __name(_a5, "SheetsHyperLinkPopupService"), _a5);
955
+ SheetsHyperLinkPopupService = __decorateClass$8([
956
+ __decorateParam$8(0, Inject(HyperLinkModel)),
957
+ __decorateParam$8(1, Inject(SheetCanvasPopManagerService))
958
+ ], SheetsHyperLinkPopupService);
959
+ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
960
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
961
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
962
+ return kind && result && __defProp$7(target, key, result), result;
963
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a6;
964
+ let SheetHyperLinkSetRangeController = (_a6 = class extends Disposable {
965
+ constructor(_sheetInterceptorService, _injector, _hyperLinkModel, _selectionManagerService, _univerInstanceService, _editorBridgeService) {
966
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._injector = _injector, this._hyperLinkModel = _hyperLinkModel, this._selectionManagerService = _selectionManagerService, this._univerInstanceService = _univerInstanceService, this._editorBridgeService = _editorBridgeService, this._initCommandInterceptor();
911
967
  }
912
968
  _initCommandInterceptor() {
913
969
  this._initAddHyperLinkCommandInterceptor(), this._initSetRangeValuesCommandInterceptor(), this._initUpdateHyperLinkCommandInterceptor(), this._initClearSelectionCommandInterceptor(), this._initRichTextEditorInterceptor();
914
970
  }
915
- _getCurrentCell(e, t, n, r) {
916
- var i, o;
917
- return (o = (i = this._univerInstanceService.getUnit(e, E.UNIVER_SHEET)) == null ? void 0 : i.getSheetBySheetId(t)) == null ? void 0 : o.getCell(n, r);
971
+ _getCurrentCell(unitId, subUnitId, row, col) {
972
+ var _a14, _b;
973
+ return (_b = (_a14 = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a14.getSheetBySheetId(subUnitId)) == null ? void 0 : _b.getCell(row, col);
918
974
  }
919
975
  _initAddHyperLinkCommandInterceptor() {
920
976
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
921
- getMutations: (e) => {
922
- var t;
923
- if (e.id === Lt.id) {
924
- const n = e.params, { unitId: r, subUnitId: i, link: o } = n, s = this._getCurrentCell(r, i, o.row, o.column), c = {
925
- unitId: r,
926
- subUnitId: i,
977
+ getMutations: /* @__PURE__ */ __name((command) => {
978
+ var _a14;
979
+ if (command.id === AddHyperLinkCommand.id) {
980
+ const params = command.params, { unitId, subUnitId, link } = params, currentCell = this._getCurrentCell(unitId, subUnitId, link.row, link.column), redoParams = {
981
+ unitId,
982
+ subUnitId,
927
983
  cellValue: {
928
- [o.row]: {
929
- [o.column]: {
930
- v: o.display,
984
+ [link.row]: {
985
+ [link.column]: {
986
+ v: link.display,
931
987
  // t: CellValueType.STRING, // Setting a link to a number is still a number
932
988
  p: null,
933
- t: (t = s == null ? void 0 : s.t) != null ? t : void 0
989
+ t: (_a14 = currentCell == null ? void 0 : currentCell.t) != null ? _a14 : void 0
934
990
  // Keep force string type
935
991
  }
936
992
  }
@@ -938,12 +994,12 @@ let Ie = class extends O {
938
994
  };
939
995
  return {
940
996
  redos: [{
941
- id: fe.id,
942
- params: c
997
+ id: SetRangeValuesMutation.id,
998
+ params: redoParams
943
999
  }],
944
1000
  undos: [{
945
- id: fe.id,
946
- params: ut(this._injector, c)
1001
+ id: SetRangeValuesMutation.id,
1002
+ params: SetRangeValuesUndoMutationFactory(this._injector, redoParams)
947
1003
  }]
948
1004
  };
949
1005
  }
@@ -951,23 +1007,23 @@ let Ie = class extends O {
951
1007
  redos: [],
952
1008
  undos: []
953
1009
  };
954
- }
1010
+ }, "getMutations")
955
1011
  }));
956
1012
  }
957
1013
  _initUpdateHyperLinkCommandInterceptor() {
958
1014
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
959
- getMutations: (e) => {
960
- if (e.id === St.id) {
961
- const t = e.params, { unitId: n, subUnitId: r, id: i, payload: o } = t, s = this._hyperLinkModel.getHyperLink(n, r, i);
962
- if (s && s.display !== o.display) {
963
- const c = {
964
- unitId: n,
965
- subUnitId: r,
1015
+ getMutations: /* @__PURE__ */ __name((command) => {
1016
+ if (command.id === UpdateHyperLinkCommand.id) {
1017
+ const params = command.params, { unitId, subUnitId, id, payload } = params, current = this._hyperLinkModel.getHyperLink(unitId, subUnitId, id);
1018
+ if (current && current.display !== payload.display) {
1019
+ const redoParams = {
1020
+ unitId,
1021
+ subUnitId,
966
1022
  cellValue: {
967
- [s.row]: {
968
- [s.column]: {
969
- v: o.display,
970
- t: dt.STRING,
1023
+ [current.row]: {
1024
+ [current.column]: {
1025
+ v: payload.display,
1026
+ t: CellValueType.STRING,
971
1027
  p: null
972
1028
  }
973
1029
  }
@@ -975,12 +1031,12 @@ let Ie = class extends O {
975
1031
  };
976
1032
  return {
977
1033
  redos: [{
978
- id: fe.id,
979
- params: c
1034
+ id: SetRangeValuesMutation.id,
1035
+ params: redoParams
980
1036
  }],
981
1037
  undos: [{
982
- id: fe.id,
983
- params: ut(this._injector, c)
1038
+ id: SetRangeValuesMutation.id,
1039
+ params: SetRangeValuesUndoMutationFactory(this._injector, redoParams)
984
1040
  }]
985
1041
  };
986
1042
  }
@@ -989,107 +1045,107 @@ let Ie = class extends O {
989
1045
  redos: [],
990
1046
  undos: []
991
1047
  };
992
- }
1048
+ }, "getMutations")
993
1049
  }));
994
1050
  }
995
1051
  _initSetRangeValuesCommandInterceptor() {
996
1052
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
997
- getMutations: (e) => {
998
- if (e.id === ln.id) {
999
- const t = e.params, { unitId: n, subUnitId: r } = t, i = [], o = [];
1000
- return t.cellValue && new _t(t.cellValue).forValue((s, c, a) => {
1001
- var l, m, _, v, L, M, y;
1002
- const u = (_ = a == null ? void 0 : a.v) != null ? _ : (m = (l = a == null ? void 0 : a.p) == null ? void 0 : l.body) == null ? void 0 : m.dataStream.slice(0, -2), g = (u != null ? u : "").toString(), f = this._hyperLinkModel.getHyperLinkByLocation(n, r, s, c);
1003
- if (!f) {
1004
- if (de(g) || (v = a == null ? void 0 : a.custom) != null && v.__link_url) {
1005
- const V = (M = (L = a == null ? void 0 : a.custom) == null ? void 0 : L.__link_url) != null ? M : g, R = re.generateRandomId();
1006
- o.push({
1007
- id: T.id,
1053
+ getMutations: /* @__PURE__ */ __name((command) => {
1054
+ if (command.id === SetRangeValuesCommand.id) {
1055
+ const params = command.params, { unitId, subUnitId } = params, redos = [], undos = [];
1056
+ return params.cellValue && new ObjectMatrix(params.cellValue).forValue((row, col, cell) => {
1057
+ var _a14, _b, _c, _d, _e, _f, _g;
1058
+ const cellValueRaw = (_c = cell == null ? void 0 : cell.v) != null ? _c : (_b = (_a14 = cell == null ? void 0 : cell.p) == null ? void 0 : _a14.body) == null ? void 0 : _b.dataStream.slice(0, -2), cellValue = (cellValueRaw != null ? cellValueRaw : "").toString(), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
1059
+ if (!link) {
1060
+ if (isLegalLink(cellValue) || (_d = cell == null ? void 0 : cell.custom) != null && _d.__link_url) {
1061
+ const url = (_f = (_e = cell == null ? void 0 : cell.custom) == null ? void 0 : _e.__link_url) != null ? _f : cellValue, id = Tools.generateRandomId();
1062
+ undos.push({
1063
+ id: RemoveHyperLinkMutation.id,
1008
1064
  params: {
1009
- unitId: n,
1010
- subUnitId: r,
1011
- id: R
1065
+ unitId,
1066
+ subUnitId,
1067
+ id
1012
1068
  }
1013
- }), i.push({
1014
- id: U.id,
1069
+ }), redos.push({
1070
+ id: AddHyperLinkMutation.id,
1015
1071
  params: {
1016
- unitId: n,
1017
- subUnitId: r,
1072
+ unitId,
1073
+ subUnitId,
1018
1074
  link: {
1019
- id: R,
1020
- row: s,
1021
- column: c,
1022
- display: g,
1023
- payload: rt(V)
1075
+ id,
1076
+ row,
1077
+ column: col,
1078
+ display: cellValue,
1079
+ payload: serializeUrl(url)
1024
1080
  }
1025
1081
  }
1026
1082
  });
1027
1083
  }
1028
1084
  return;
1029
1085
  }
1030
- (u === "" || ((y = a == null ? void 0 : a.custom) == null ? void 0 : y.__link_url) === "") && (i.push({
1031
- id: T.id,
1086
+ (cellValueRaw === "" || ((_g = cell == null ? void 0 : cell.custom) == null ? void 0 : _g.__link_url) === "") && (redos.push({
1087
+ id: RemoveHyperLinkMutation.id,
1032
1088
  params: {
1033
- unitId: n,
1034
- subUnitId: r,
1035
- id: f.id
1089
+ unitId,
1090
+ subUnitId,
1091
+ id: link.id
1036
1092
  }
1037
- }), o.push({
1038
- id: U.id,
1093
+ }), undos.push({
1094
+ id: AddHyperLinkMutation.id,
1039
1095
  params: {
1040
- unitId: n,
1041
- subUnitId: r,
1042
- link: f
1096
+ unitId,
1097
+ subUnitId,
1098
+ link
1043
1099
  }
1044
1100
  }));
1045
1101
  }), {
1046
- undos: o,
1047
- redos: i
1102
+ undos,
1103
+ redos
1048
1104
  };
1049
1105
  }
1050
1106
  return {
1051
1107
  redos: [],
1052
1108
  undos: []
1053
1109
  };
1054
- }
1110
+ }, "getMutations")
1055
1111
  }));
1056
1112
  }
1057
1113
  _initClearSelectionCommandInterceptor() {
1058
1114
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
1059
- getMutations: (e) => {
1060
- if (e.id === dn.id || e.id === un.id || e.id === pn.id) {
1061
- const t = [], n = [], r = this._selectionManagerService.getCurrentLastSelection(), i = Ct(this._univerInstanceService);
1062
- if (r && i) {
1063
- const { unitId: o, subUnitId: s } = i;
1064
- Qe.foreach(r.range, (c, a) => {
1065
- const u = this._hyperLinkModel.getHyperLinkByLocation(o, s, c, a);
1066
- u && (t.push({
1067
- id: T.id,
1115
+ getMutations: /* @__PURE__ */ __name((command) => {
1116
+ if (command.id === ClearSelectionContentCommand.id || command.id === ClearSelectionAllCommand.id || command.id === ClearSelectionFormatCommand.id) {
1117
+ const redos = [], undos = [], selection = this._selectionManagerService.getCurrentLastSelection(), target = getSheetCommandTarget(this._univerInstanceService);
1118
+ if (selection && target) {
1119
+ const { unitId, subUnitId } = target;
1120
+ Range.foreach(selection.range, (row, col) => {
1121
+ const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
1122
+ link && (redos.push({
1123
+ id: RemoveHyperLinkMutation.id,
1068
1124
  params: {
1069
- unitId: o,
1070
- subUnitId: s,
1071
- id: u.id
1125
+ unitId,
1126
+ subUnitId,
1127
+ id: link.id
1072
1128
  }
1073
- }), n.push({
1074
- id: U.id,
1129
+ }), undos.push({
1130
+ id: AddHyperLinkMutation.id,
1075
1131
  params: {
1076
- unitId: o,
1077
- subUnitId: s,
1078
- link: u
1132
+ unitId,
1133
+ subUnitId,
1134
+ link
1079
1135
  }
1080
1136
  }));
1081
1137
  });
1082
1138
  }
1083
1139
  return {
1084
- redos: t,
1085
- undos: n
1140
+ redos,
1141
+ undos
1086
1142
  };
1087
1143
  }
1088
1144
  return {
1089
1145
  redos: [],
1090
1146
  undos: []
1091
1147
  };
1092
- }
1148
+ }, "getMutations")
1093
1149
  }));
1094
1150
  }
1095
1151
  _initRichTextEditorInterceptor() {
@@ -1097,522 +1153,544 @@ let Ie = class extends O {
1097
1153
  this._editorBridgeService.interceptor.intercept(
1098
1154
  this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,
1099
1155
  {
1100
- handler: (e, t, n) => {
1101
- var r, i, o, s, c, a;
1102
- if (e != null && e.p) {
1103
- const u = (i = (r = e.p.body) == null ? void 0 : r.customRanges) == null ? void 0 : i.find((f) => f.rangeType === tn.HYPERLINK), g = (o = e.p.resources) == null ? void 0 : o.find((f) => f.name === Kn);
1104
- if (u && g) {
1105
- const f = u.rangeId, l = (a = (c = (s = JSON.parse(g.data)) == null ? void 0 : s.links) == null ? void 0 : c.find((m) => m.id === f)) == null ? void 0 : a.payload;
1106
- return n({
1107
- ...e,
1156
+ handler: /* @__PURE__ */ __name((data, context, next) => {
1157
+ var _a14, _b, _c, _d, _e, _f;
1158
+ if (data != null && data.p) {
1159
+ const range = (_b = (_a14 = data.p.body) == null ? void 0 : _a14.customRanges) == null ? void 0 : _b.find((i) => i.rangeType === CustomRangeType.HYPERLINK), resource = (_c = data.p.resources) == null ? void 0 : _c.find((i) => i.name === DOC_HYPER_LINK_PLUGIN);
1160
+ if (range && resource) {
1161
+ const rangeId = range.rangeId, url = (_f = (_e = (_d = JSON.parse(resource.data)) == null ? void 0 : _d.links) == null ? void 0 : _e.find((i) => i.id === rangeId)) == null ? void 0 : _f.payload;
1162
+ return next({
1163
+ ...data,
1108
1164
  p: null,
1109
- v: Yn(e.p),
1110
- t: dt.STRING,
1165
+ v: getPlainTextFormDocument(data.p),
1166
+ t: CellValueType.STRING,
1111
1167
  custom: {
1112
- __link_url: l
1168
+ __link_url: url
1113
1169
  }
1114
1170
  });
1115
1171
  }
1116
1172
  }
1117
- return n(e);
1118
- }
1173
+ return next(data);
1174
+ }, "handler")
1119
1175
  }
1120
1176
  )
1121
1177
  );
1122
1178
  }
1123
- };
1124
- Ie = $r([
1125
- B(D.Starting, Ie),
1126
- J(0, h(et)),
1127
- J(1, h(Ne)),
1128
- J(2, h(H)),
1129
- J(3, h(yt)),
1130
- J(4, ue),
1131
- J(5, Sn)
1132
- ], Ie);
1133
- var Br = Object.defineProperty, Dr = Object.getOwnPropertyDescriptor, Vr = (e, t, n, r) => {
1134
- for (var i = r > 1 ? void 0 : r ? Dr(t, n) : t, o = e.length - 1, s; o >= 0; o--)
1135
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
1136
- return r && i && Br(t, n, i), i;
1137
- }, ae = (e, t) => (n, r) => t(n, r, e);
1138
- let ke = class extends O {
1139
- constructor(e, t, n, r, i) {
1140
- super(), this._hoverManagerService = e, this._sheetsHyperLinkPopupService = t, this._renderManagerService = n, this._permissionService = r, this._sheetPermissionInterceptorBaseController = i, this._initHoverListener();
1179
+ }, __name(_a6, "SheetHyperLinkSetRangeController"), _a6);
1180
+ SheetHyperLinkSetRangeController = __decorateClass$7([
1181
+ OnLifecycle(LifecycleStages.Starting, SheetHyperLinkSetRangeController),
1182
+ __decorateParam$7(0, Inject(SheetInterceptorService)),
1183
+ __decorateParam$7(1, Inject(Injector)),
1184
+ __decorateParam$7(2, Inject(HyperLinkModel)),
1185
+ __decorateParam$7(3, Inject(SheetsSelectionsService)),
1186
+ __decorateParam$7(4, IUniverInstanceService),
1187
+ __decorateParam$7(5, IEditorBridgeService)
1188
+ ], SheetHyperLinkSetRangeController);
1189
+ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1190
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1191
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1192
+ return kind && result && __defProp$6(target, key, result), result;
1193
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a7;
1194
+ let SheetsHyperLinkPopupController = (_a7 = class extends Disposable {
1195
+ constructor(_hoverManagerService, _sheetsHyperLinkPopupService, _renderManagerService, _permissionService, _sheetPermissionInterceptorBaseController) {
1196
+ super(), this._hoverManagerService = _hoverManagerService, this._sheetsHyperLinkPopupService = _sheetsHyperLinkPopupService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._initHoverListener();
1141
1197
  }
1142
1198
  _initHoverListener() {
1143
1199
  this.disposeWithMe(
1144
- this._hoverManagerService.currentCell$.pipe(Rt(200)).subscribe((e) => {
1145
- var f, l;
1146
- if (!e) {
1200
+ this._hoverManagerService.currentCell$.pipe(debounceTime(200)).subscribe((currentCell) => {
1201
+ var _a14, _b;
1202
+ if (!currentCell) {
1147
1203
  this._sheetsHyperLinkPopupService.hideCurrentPopup();
1148
1204
  return;
1149
1205
  }
1150
- const t = (l = (f = this._renderManagerService.getRenderById(e.location.unitId)) == null ? void 0 : f.with(It).getWorksheetSkeleton(e.location.subUnitId)) == null ? void 0 : l.skeleton, n = e.location.col, r = e.location.row;
1151
- let i = r, o = n;
1152
- if (t && t.overflowCache.forValue((m, _, v) => {
1153
- ne.contains(v, { startColumn: n, endColumn: n, startRow: r, endRow: r }) && (i = m, o = _);
1206
+ const skeleton = (_b = (_a14 = this._renderManagerService.getRenderById(currentCell.location.unitId)) == null ? void 0 : _a14.with(SheetSkeletonManagerService).getWorksheetSkeleton(currentCell.location.subUnitId)) == null ? void 0 : _b.skeleton, currentCol = currentCell.location.col, currentRow = currentCell.location.row;
1207
+ let targetRow = currentRow, targetCol = currentCol;
1208
+ if (skeleton && skeleton.overflowCache.forValue((row, col, value) => {
1209
+ Rectangle.contains(value, { startColumn: currentCol, endColumn: currentCol, startRow: currentRow, endRow: currentRow }) && (targetRow = row, targetCol = col);
1154
1210
  }), !this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1155
- workbookTypes: [hn],
1156
- worksheetTypes: [mn],
1157
- rangeTypes: [gn]
1158
- }, [{ startRow: r, startColumn: n, endRow: r, endColumn: n }])) {
1211
+ workbookTypes: [WorkbookViewPermission],
1212
+ worksheetTypes: [WorksheetViewPermission],
1213
+ rangeTypes: [RangeProtectionPermissionViewPoint]
1214
+ }, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }])) {
1159
1215
  this._sheetsHyperLinkPopupService.hideCurrentPopup();
1160
1216
  return;
1161
1217
  }
1162
- const c = this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1163
- workbookTypes: [$e],
1164
- worksheetTypes: [Be, De],
1165
- rangeTypes: [Ve]
1166
- }, [{ startRow: r, startColumn: n, endRow: r, endColumn: n }]), a = e.location.unitId, u = e.location.subUnitId, g = this._permissionService.composePermission([new fn(a).id, new vn(a, u).id]).every((m) => m.value);
1218
+ const editPermission = this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1219
+ workbookTypes: [WorkbookEditablePermission],
1220
+ worksheetTypes: [WorksheetEditPermission, WorksheetInsertHyperlinkPermission],
1221
+ rangeTypes: [RangeProtectionPermissionEditPoint]
1222
+ }, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }]), unitId = currentCell.location.unitId, subUnitId = currentCell.location.subUnitId, copyPermission = this._permissionService.composePermission([new WorkbookCopyPermission(unitId).id, new WorksheetCopyPermission(unitId, subUnitId).id]).every((permission) => permission.value);
1167
1223
  this._sheetsHyperLinkPopupService.showPopup({
1168
- ...e.location,
1169
- row: i,
1170
- col: o,
1171
- editPermission: c,
1172
- copyPermission: g
1224
+ ...currentCell.location,
1225
+ row: targetRow,
1226
+ col: targetCol,
1227
+ editPermission,
1228
+ copyPermission
1173
1229
  });
1174
1230
  })
1175
1231
  );
1176
1232
  }
1177
- };
1178
- ke = Vr([
1179
- B(D.Rendered, ke),
1180
- ae(0, h(Ln)),
1181
- ae(1, h($)),
1182
- ae(2, h(nt)),
1183
- ae(3, h(nn)),
1184
- ae(4, h(Pt))
1185
- ], ke);
1186
- const Ar = (e) => ({
1187
- id: ot.id,
1188
- type: xt.BUTTON,
1189
- positions: [Tt.CONTEXT_MENU],
1233
+ }, __name(_a7, "SheetsHyperLinkPopupController"), _a7);
1234
+ SheetsHyperLinkPopupController = __decorateClass$6([
1235
+ OnLifecycle(LifecycleStages.Rendered, SheetsHyperLinkPopupController),
1236
+ __decorateParam$6(0, Inject(HoverManagerService)),
1237
+ __decorateParam$6(1, Inject(SheetsHyperLinkPopupService)),
1238
+ __decorateParam$6(2, Inject(IRenderManagerService)),
1239
+ __decorateParam$6(3, Inject(IPermissionService)),
1240
+ __decorateParam$6(4, Inject(SheetPermissionInterceptorBaseController))
1241
+ ], SheetsHyperLinkPopupController);
1242
+ const insertLinkMenuFactory = /* @__PURE__ */ __name((accessor) => ({
1243
+ id: InsertHyperLinkOperation.id,
1244
+ type: MenuItemType.BUTTON,
1245
+ positions: [MenuPosition.CONTEXT_MENU],
1190
1246
  title: "hyperLink.menu.add",
1191
- hidden$: Ut(e, E.UNIVER_SHEET),
1247
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1192
1248
  icon: "LinkSingle",
1193
- disabled$: bt(e, { workbookTypes: [$e], worksheetTypes: [Be, tt, De], rangeTypes: [Ve] })
1194
- }), Wr = (e) => ({
1249
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
1250
+ }), "insertLinkMenuFactory"), insertLinkMenuToolbarFactory = /* @__PURE__ */ __name((accessor) => ({
1195
1251
  tooltip: "hyperLink.form.addTitle",
1196
- positions: Tt.TOOLBAR_START,
1197
- group: Bn.TOOLBAR_OTHERS,
1198
- id: st.id,
1199
- type: xt.BUTTON,
1252
+ positions: MenuPosition.TOOLBAR_START,
1253
+ group: MenuGroup.TOOLBAR_OTHERS,
1254
+ id: InsertHyperLinkToolbarOperation.id,
1255
+ type: MenuItemType.BUTTON,
1200
1256
  icon: "LinkSingle",
1201
- hidden$: Ut(e, E.UNIVER_SHEET),
1202
- disabled$: bt(e, { workbookTypes: [$e], worksheetTypes: [Be, tt, De], rangeTypes: [Ve] })
1203
- }), Ft = {
1204
- id: st.id,
1205
- binding: Nn.K | $n.CTRL_COMMAND,
1206
- preconditions: In
1257
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1258
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
1259
+ }), "insertLinkMenuToolbarFactory"), InsertLinkShortcut = {
1260
+ id: InsertHyperLinkToolbarOperation.id,
1261
+ binding: KeyCode.K | MetaKeys.CTRL_COMMAND,
1262
+ preconditions: whenSheetEditorFocused
1207
1263
  };
1208
- var Fr = Object.defineProperty, Kr = Object.getOwnPropertyDescriptor, Yr = (e, t, n, r) => {
1209
- for (var i = r > 1 ? void 0 : r ? Kr(t, n) : t, o = e.length - 1, s; o >= 0; o--)
1210
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
1211
- return r && i && Fr(t, n, i), i;
1212
- }, Q = (e, t) => (n, r) => t(n, r, e);
1213
- let le = class extends O {
1214
- constructor(e, t, n, r, i, o, s) {
1215
- super(), this._config = e, this._componentManager = t, this._commandService = n, this._localeService = r, this._menuService = i, this._injector = o, this._shortcutService = s, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
1264
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1265
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1266
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1267
+ return kind && result && __defProp$5(target, key, result), result;
1268
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a8;
1269
+ let SheetsHyperLinkUIController = (_a8 = class extends Disposable {
1270
+ constructor(_config, _componentManager, _commandService, _localeService, _menuService, _injector, _shortcutService) {
1271
+ super(), this._config = _config, this._componentManager = _componentManager, this._commandService = _commandService, this._localeService = _localeService, this._menuService = _menuService, this._injector = _injector, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
1216
1272
  }
1217
1273
  _initComponents() {
1218
1274
  [
1219
- [Ue, Ue.componentKey],
1220
- [xe, xe.componentKey],
1221
- [Me, "LinkSingle"]
1222
- ].forEach(([e, t]) => {
1223
- this._componentManager.register(t, e);
1275
+ [CellLinkPopup, CellLinkPopup.componentKey],
1276
+ [CellLinkEdit, CellLinkEdit.componentKey],
1277
+ [LinkSingle, "LinkSingle"]
1278
+ ].forEach(([comp, key]) => {
1279
+ this._componentManager.register(key, comp);
1224
1280
  });
1225
1281
  }
1226
1282
  _initCommands() {
1227
1283
  [
1228
- it,
1229
- Te,
1230
- ot,
1231
- st
1232
- ].forEach((e) => {
1233
- this._commandService.registerCommand(e);
1284
+ OpenHyperLinkSidebarOperation,
1285
+ CloseHyperLinkSidebarOperation,
1286
+ InsertHyperLinkOperation,
1287
+ InsertHyperLinkToolbarOperation
1288
+ ].forEach((command) => {
1289
+ this._commandService.registerCommand(command);
1234
1290
  });
1235
1291
  }
1236
1292
  _initMenus() {
1237
- var e, t, n, r;
1238
- this._menuService.addMenuItem(Ar(this._injector), (t = (e = this._config) == null ? void 0 : e.menu) != null ? t : {}), this._menuService.addMenuItem(Wr(this._injector), (r = (n = this._config) == null ? void 0 : n.menu) != null ? r : {});
1293
+ var _a14, _b, _c, _d;
1294
+ this._menuService.addMenuItem(insertLinkMenuFactory(this._injector), (_b = (_a14 = this._config) == null ? void 0 : _a14.menu) != null ? _b : {}), this._menuService.addMenuItem(insertLinkMenuToolbarFactory(this._injector), (_d = (_c = this._config) == null ? void 0 : _c.menu) != null ? _d : {});
1239
1295
  }
1240
1296
  _initShortCut() {
1241
- this._shortcutService.registerShortcut(Ft);
1297
+ this._shortcutService.registerShortcut(InsertLinkShortcut);
1242
1298
  }
1243
- };
1244
- le = Yr([
1245
- B(D.Ready, le),
1246
- Q(1, h(Dn)),
1247
- Q(2, K),
1248
- Q(3, h(pe)),
1249
- Q(4, An),
1250
- Q(5, h(Ne)),
1251
- Q(6, h(Vn))
1252
- ], le);
1253
- const at = "SHEET_HYPER_LINK_UI_PLUGIN";
1254
- var Zr = Object.defineProperty, zr = Object.getOwnPropertyDescriptor, Gr = (e, t, n, r) => {
1255
- for (var i = r > 1 ? void 0 : r ? zr(t, n) : t, o = e.length - 1, s; o >= 0; o--)
1256
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
1257
- return r && i && Zr(t, n, i), i;
1258
- }, ft = (e, t) => (n, r) => t(n, r, e);
1259
- let Pe = class extends O {
1260
- constructor(e, t) {
1261
- super(), this._autoFillService = e, this._hyperLinkModel = t, this._initAutoFill();
1299
+ }, __name(_a8, "SheetsHyperLinkUIController"), _a8);
1300
+ SheetsHyperLinkUIController = __decorateClass$5([
1301
+ OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkUIController),
1302
+ __decorateParam$5(1, Inject(ComponentManager)),
1303
+ __decorateParam$5(2, ICommandService),
1304
+ __decorateParam$5(3, Inject(LocaleService)),
1305
+ __decorateParam$5(4, IMenuService),
1306
+ __decorateParam$5(5, Inject(Injector)),
1307
+ __decorateParam$5(6, Inject(IShortcutService))
1308
+ ], SheetsHyperLinkUIController);
1309
+ const SHEET_HYPER_LINK_UI_PLUGIN = "SHEET_HYPER_LINK_UI_PLUGIN";
1310
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1311
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1312
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1313
+ return kind && result && __defProp$4(target, key, result), result;
1314
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a9;
1315
+ let SheetsHyperLinkAutoFillController = (_a9 = class extends Disposable {
1316
+ constructor(_autoFillService, _hyperLinkModel) {
1317
+ super(), this._autoFillService = _autoFillService, this._hyperLinkModel = _hyperLinkModel, this._initAutoFill();
1262
1318
  }
1263
1319
  // eslint-disable-next-line max-lines-per-function
1264
1320
  _initAutoFill() {
1265
- const e = () => ({ redos: [], undos: [] }), t = (r, i) => {
1266
- const { source: o, target: s, unitId: c, subUnitId: a } = r, u = qe([o, s]), [g, f] = u.ranges, { mapFunc: l } = u, m = {
1267
- row: g.startRow,
1268
- col: g.startColumn
1269
- }, _ = Pn(g, f), v = [], L = [];
1270
- return _.forEach((M) => {
1271
- const y = M.repeatStartCell, V = M.relativeRange, R = {
1272
- startRow: m.row,
1273
- startColumn: m.col,
1274
- endColumn: m.col,
1275
- endRow: m.row
1276
- }, P = {
1277
- startRow: y.row,
1278
- startColumn: y.col,
1279
- endColumn: y.col,
1280
- endRow: y.row
1321
+ const noopReturnFunc = /* @__PURE__ */ __name(() => ({ redos: [], undos: [] }), "noopReturnFunc"), generalApplyFunc = /* @__PURE__ */ __name((location2, applyType) => {
1322
+ const { source: sourceRange, target: targetRange, unitId, subUnitId } = location2, virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]), [vSourceRange, vTargetRange] = virtualRange.ranges, { mapFunc } = virtualRange, sourceStartCell = {
1323
+ row: vSourceRange.startRow,
1324
+ col: vSourceRange.startColumn
1325
+ }, repeats = getAutoFillRepeatRange(vSourceRange, vTargetRange), redos = [], undos = [];
1326
+ return repeats.forEach((repeat) => {
1327
+ const targetStartCell = repeat.repeatStartCell, relativeRange = repeat.relativeRange, sourceRange2 = {
1328
+ startRow: sourceStartCell.row,
1329
+ startColumn: sourceStartCell.col,
1330
+ endColumn: sourceStartCell.col,
1331
+ endRow: sourceStartCell.row
1332
+ }, targetRange2 = {
1333
+ startRow: targetStartCell.row,
1334
+ startColumn: targetStartCell.col,
1335
+ endColumn: targetStartCell.col,
1336
+ endRow: targetStartCell.row
1281
1337
  };
1282
- Qe.foreach(V, (G, A) => {
1283
- const q = ne.getPositionRange(
1338
+ Range.foreach(relativeRange, (row, col) => {
1339
+ const sourcePositionRange = Rectangle.getPositionRange(
1284
1340
  {
1285
- startRow: G,
1286
- startColumn: A,
1287
- endColumn: A,
1288
- endRow: G
1341
+ startRow: row,
1342
+ startColumn: col,
1343
+ endColumn: col,
1344
+ endRow: row
1289
1345
  },
1290
- R
1291
- ), { row: he, col: We } = l(q.startRow, q.startColumn), me = this._hyperLinkModel.getHyperLinkByLocation(c, a, he, We);
1292
- if (me) {
1293
- const ie = ne.getPositionRange(
1294
- {
1295
- startRow: G,
1296
- startColumn: A,
1297
- endColumn: A,
1298
- endRow: G
1299
- },
1300
- P
1301
- ), { row: p, col: S } = l(ie.startRow, ie.startColumn), I = re.generateRandomId(), C = this._hyperLinkModel.getHyperLinkByLocation(c, a, p, S);
1302
- C && v.push({
1303
- id: T.id,
1304
- params: {
1305
- unitId: c,
1306
- subUnitId: a,
1307
- id: C.id
1308
- }
1309
- }), (oe.COPY === i || oe.SERIES === i) && (v.push({
1310
- id: U.id,
1311
- params: {
1312
- unitId: c,
1313
- subUnitId: a,
1314
- link: {
1315
- ...me,
1316
- id: I,
1317
- row: p,
1318
- column: S
1319
- }
1320
- }
1321
- }), L.push({
1322
- id: T.id,
1323
- params: {
1324
- unitId: c,
1325
- subUnitId: a,
1326
- id: I
1327
- }
1328
- })), C && L.push({
1329
- id: U.id,
1330
- params: {
1331
- unitId: c,
1332
- subUnitId: a,
1333
- link: C
1346
+ sourceRange2
1347
+ ), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol), targetPositionRange = Rectangle.getPositionRange(
1348
+ {
1349
+ startRow: row,
1350
+ startColumn: col,
1351
+ endColumn: col,
1352
+ endRow: row
1353
+ },
1354
+ targetRange2
1355
+ ), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn), id = Tools.generateRandomId(), currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
1356
+ currentLink && redos.push({
1357
+ id: RemoveHyperLinkMutation.id,
1358
+ params: {
1359
+ unitId,
1360
+ subUnitId,
1361
+ id: currentLink.id
1362
+ }
1363
+ }), (APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) && link && (redos.push({
1364
+ id: AddHyperLinkMutation.id,
1365
+ params: {
1366
+ unitId,
1367
+ subUnitId,
1368
+ link: {
1369
+ ...link,
1370
+ id,
1371
+ row: targetRow,
1372
+ column: targetCol
1334
1373
  }
1335
- });
1336
- }
1374
+ }
1375
+ }), undos.push({
1376
+ id: RemoveHyperLinkMutation.id,
1377
+ params: {
1378
+ unitId,
1379
+ subUnitId,
1380
+ id
1381
+ }
1382
+ })), currentLink && undos.push({
1383
+ id: AddHyperLinkMutation.id,
1384
+ params: {
1385
+ unitId,
1386
+ subUnitId,
1387
+ link: currentLink
1388
+ }
1389
+ });
1337
1390
  });
1338
1391
  }), {
1339
- undos: L,
1340
- redos: v
1392
+ undos,
1393
+ redos
1341
1394
  };
1342
- }, n = {
1343
- id: at,
1344
- onFillData: (r, i, o) => o === oe.COPY || o === oe.ONLY_FORMAT || o === oe.SERIES ? t(r, o) : e()
1395
+ }, "generalApplyFunc"), hook = {
1396
+ id: SHEET_HYPER_LINK_UI_PLUGIN,
1397
+ onFillData: /* @__PURE__ */ __name((location2, direction, applyType) => applyType === APPLY_TYPE.COPY || applyType === APPLY_TYPE.ONLY_FORMAT || applyType === APPLY_TYPE.SERIES ? generalApplyFunc(location2, applyType) : noopReturnFunc(), "onFillData")
1345
1398
  };
1346
- this.disposeWithMe(this._autoFillService.addHook(n));
1399
+ this.disposeWithMe(this._autoFillService.addHook(hook));
1347
1400
  }
1348
- };
1349
- Pe = Gr([
1350
- B(D.Ready, Pe),
1351
- ft(0, kn),
1352
- ft(1, h(H))
1353
- ], Pe);
1354
- var qr = Object.defineProperty, Xr = Object.getOwnPropertyDescriptor, Jr = (e, t, n, r) => {
1355
- for (var i = r > 1 ? void 0 : r ? Xr(t, n) : t, o = e.length - 1, s; o >= 0; o--)
1356
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
1357
- return r && i && qr(t, n, i), i;
1358
- }, Ce = (e, t) => (n, r) => t(n, r, e);
1359
- let be = class extends O {
1360
- constructor(t, n, r, i) {
1401
+ }, __name(_a9, "SheetsHyperLinkAutoFillController"), _a9);
1402
+ SheetsHyperLinkAutoFillController = __decorateClass$4([
1403
+ OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkAutoFillController),
1404
+ __decorateParam$4(0, IAutoFillService),
1405
+ __decorateParam$4(1, Inject(HyperLinkModel))
1406
+ ], SheetsHyperLinkAutoFillController);
1407
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1408
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1409
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1410
+ return kind && result && __defProp$3(target, key, result), result;
1411
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a10;
1412
+ let SheetsHyperLinkCopyPasteController = (_a10 = class extends Disposable {
1413
+ constructor(_sheetClipboardService, _hyperLinkModel, _injector, _resolverService) {
1361
1414
  super();
1362
- W(this, "_copyInfo");
1363
- this._sheetClipboardService = t, this._hyperLinkModel = n, this._injector = r, this._resolverService = i, this._initCopyPaste();
1415
+ __publicField(this, "_plainTextFilter", /* @__PURE__ */ new Set());
1416
+ __publicField(this, "_copyInfo");
1417
+ this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste(), this.disposeWithMe(() => {
1418
+ this._plainTextFilter.clear();
1419
+ });
1420
+ }
1421
+ registerPlainTextFilter(filter) {
1422
+ this._plainTextFilter.add(filter);
1423
+ }
1424
+ removePlainTextFilter(filter) {
1425
+ this._plainTextFilter.delete(filter);
1426
+ }
1427
+ /* If return false the process of paste text will be stop */
1428
+ _filterPlainText(text) {
1429
+ return Array.from(this._plainTextFilter).every((filter) => filter(text));
1364
1430
  }
1365
1431
  _initCopyPaste() {
1366
1432
  this._sheetClipboardService.addClipboardHook({
1367
- id: at,
1368
- onBeforeCopy: (t, n, r) => this._collect(t, n, r),
1369
- onPasteCells: (t, n, r, i) => {
1370
- const { copyType: o = bn.COPY, pasteType: s } = i, { range: c } = t || {}, { range: a, unitId: u, subUnitId: g } = n;
1371
- return this._generateMutations(a, { copyType: o, pasteType: s, copyRange: c, unitId: u, subUnitId: g });
1372
- },
1373
- onPastePlainText: (t, n) => {
1374
- if (de(n)) {
1375
- const r = rt(n), { range: i, unitId: o, subUnitId: s } = t, { ranges: [c], mapFunc: a } = qe([i]), u = [], g = [];
1376
- return Qe.foreach(c, (f, l) => {
1377
- const { row: m, col: _ } = a(f, l), v = this._hyperLinkModel.getHyperLinkByLocation(o, s, m, _);
1378
- v && u.push({
1379
- id: T.id,
1433
+ id: SHEET_HYPER_LINK_UI_PLUGIN,
1434
+ onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
1435
+ onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
1436
+ const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
1437
+ return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
1438
+ }, "onPasteCells"),
1439
+ onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => {
1440
+ const filterResult = this._filterPlainText(clipText);
1441
+ if (isLegalLink(clipText) && filterResult) {
1442
+ const text = serializeUrl(clipText), { range, unitId, subUnitId } = pasteTo, { ranges: [pasteToRange], mapFunc } = virtualizeDiscreteRanges([range]), redos = [], undos = [];
1443
+ return Range.foreach(pasteToRange, (originRow, originCol) => {
1444
+ const { row, col: column } = mapFunc(originRow, originCol), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
1445
+ link && redos.push({
1446
+ id: RemoveHyperLinkMutation.id,
1380
1447
  params: {
1381
- unitId: o,
1382
- subUnitId: s,
1383
- id: v.id
1448
+ unitId,
1449
+ subUnitId,
1450
+ id: link.id
1384
1451
  }
1385
1452
  });
1386
- const L = re.generateRandomId();
1387
- u.push({
1388
- id: U.id,
1453
+ const newId = Tools.generateRandomId();
1454
+ redos.push({
1455
+ id: AddHyperLinkMutation.id,
1389
1456
  params: {
1390
- unitId: o,
1391
- subUnitId: s,
1457
+ unitId,
1458
+ subUnitId,
1392
1459
  link: {
1393
- id: L,
1394
- row: m,
1395
- column: _,
1396
- payload: r
1460
+ id: newId,
1461
+ row,
1462
+ column,
1463
+ payload: text
1397
1464
  }
1398
1465
  }
1399
- }), g.push({
1400
- id: T.id,
1466
+ }), undos.push({
1467
+ id: RemoveHyperLinkMutation.id,
1401
1468
  params: {
1402
- unitId: o,
1403
- subUnitId: s,
1404
- id: L
1469
+ unitId,
1470
+ subUnitId,
1471
+ id: newId
1405
1472
  }
1406
- }), v && g.push({
1407
- id: U.id,
1473
+ }), link && undos.push({
1474
+ id: AddHyperLinkMutation.id,
1408
1475
  params: {
1409
- unitId: o,
1410
- subUnitId: s,
1411
- link: v
1476
+ unitId,
1477
+ subUnitId,
1478
+ link
1412
1479
  }
1413
1480
  });
1414
- }), { redos: u, undos: g };
1481
+ }), { redos, undos };
1415
1482
  }
1416
1483
  return { undos: [], redos: [] };
1417
- }
1484
+ }, "onPastePlainText"),
1485
+ priority: 99
1418
1486
  });
1419
1487
  }
1420
- _collect(t, n, r) {
1421
- const i = new _t();
1488
+ _collect(unitId, subUnitId, range) {
1489
+ const matrix = new ObjectMatrix();
1422
1490
  this._copyInfo = {
1423
- unitId: t,
1424
- subUnitId: n,
1425
- matrix: i
1491
+ unitId,
1492
+ subUnitId,
1493
+ matrix
1426
1494
  };
1427
- const o = {
1495
+ const accessor = {
1428
1496
  get: this._injector.get.bind(this._injector)
1429
- }, s = Rn(r, o, t, n);
1430
- if (!s)
1497
+ }, discreteRange = rangeToDiscreteRange(range, accessor, unitId, subUnitId);
1498
+ if (!discreteRange)
1431
1499
  return;
1432
- const { rows: c, cols: a } = s;
1433
- c.forEach((u, g) => {
1434
- a.forEach((f, l) => {
1435
- var _;
1436
- const m = this._hyperLinkModel.getHyperLinkByLocation(t, n, u, f);
1437
- i.setValue(g, l, (_ = m == null ? void 0 : m.id) != null ? _ : "");
1500
+ const { rows, cols } = discreteRange;
1501
+ rows.forEach((row, rowIndex) => {
1502
+ cols.forEach((col, colIndex) => {
1503
+ var _a14;
1504
+ const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
1505
+ matrix.setValue(rowIndex, colIndex, (_a14 = link == null ? void 0 : link.id) != null ? _a14 : "");
1438
1506
  });
1439
1507
  });
1440
1508
  }
1441
1509
  // eslint-disable-next-line max-lines-per-function
1442
- _generateMutations(t, n) {
1510
+ _generateMutations(pastedRange, copyInfo) {
1443
1511
  if (!this._copyInfo)
1444
1512
  return { redos: [], undos: [] };
1445
- if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !n.copyRange)
1513
+ if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange)
1446
1514
  return { redos: [], undos: [] };
1447
1515
  if ([
1448
- ve.SPECIAL_PASTE_COL_WIDTH,
1449
- ve.SPECIAL_PASTE_VALUE,
1450
- ve.SPECIAL_PASTE_FORMAT,
1451
- ve.SPECIAL_PASTE_FORMULA
1516
+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
1517
+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
1518
+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
1519
+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
1452
1520
  ].includes(
1453
- n.pasteType
1521
+ copyInfo.pasteType
1454
1522
  ))
1455
1523
  return { redos: [], undos: [] };
1456
- const { unitId: r, subUnitId: i } = this._copyInfo, o = [], s = [], { ranges: [c, a], mapFunc: u } = qe([n.copyRange, t]);
1457
- return wn(c, a, !0).forEach(({ startRange: f }) => {
1458
- var l;
1459
- (l = this._copyInfo) == null || l.matrix.forValue((m, _, v) => {
1460
- const L = ne.getPositionRange(
1524
+ const { unitId, subUnitId } = this._copyInfo, redos = [], undos = [], { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
1525
+ return getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
1526
+ var _a14;
1527
+ (_a14 = this._copyInfo) == null || _a14.matrix.forValue((row, col, ruleId) => {
1528
+ const range = Rectangle.getPositionRange(
1461
1529
  {
1462
- startRow: m,
1463
- endRow: m,
1464
- startColumn: _,
1465
- endColumn: _
1530
+ startRow: row,
1531
+ endRow: row,
1532
+ startColumn: col,
1533
+ endColumn: col
1466
1534
  },
1467
- f
1468
- ), M = this._hyperLinkModel.getHyperLink(r, i, v), { row: y, col: V } = u(L.startRow, L.startColumn), R = this._hyperLinkModel.getHyperLinkByLocation(n.unitId, n.subUnitId, y, V), P = re.generateRandomId();
1469
- R && o.push({
1470
- id: T.id,
1535
+ startRange
1536
+ ), oldLink = this._hyperLinkModel.getHyperLink(unitId, subUnitId, ruleId), { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn), currentLink = this._hyperLinkModel.getHyperLinkByLocation(copyInfo.unitId, copyInfo.subUnitId, startRow, startColumn), id = Tools.generateRandomId();
1537
+ currentLink && redos.push({
1538
+ id: RemoveHyperLinkMutation.id,
1471
1539
  params: {
1472
- unitId: n.unitId,
1473
- subUnitId: n.subUnitId,
1474
- id: R.id
1540
+ unitId: copyInfo.unitId,
1541
+ subUnitId: copyInfo.subUnitId,
1542
+ id: currentLink.id
1475
1543
  }
1476
- }), M && (o.push({
1477
- id: U.id,
1544
+ }), oldLink && (redos.push({
1545
+ id: AddHyperLinkMutation.id,
1478
1546
  params: {
1479
- unitId: n.unitId,
1480
- subUnitId: n.subUnitId,
1547
+ unitId: copyInfo.unitId,
1548
+ subUnitId: copyInfo.subUnitId,
1481
1549
  link: {
1482
- ...M,
1483
- id: P,
1484
- row: y,
1485
- column: V
1550
+ ...oldLink,
1551
+ id,
1552
+ row: startRow,
1553
+ column: startColumn
1486
1554
  }
1487
1555
  }
1488
- }), s.push({
1489
- id: T.id,
1556
+ }), undos.push({
1557
+ id: RemoveHyperLinkMutation.id,
1490
1558
  params: {
1491
- unitId: n.unitId,
1492
- subUnitId: n.subUnitId,
1493
- id: P
1559
+ unitId: copyInfo.unitId,
1560
+ subUnitId: copyInfo.subUnitId,
1561
+ id
1494
1562
  }
1495
- })), R && s.push({
1496
- id: U.id,
1563
+ })), currentLink && undos.push({
1564
+ id: AddHyperLinkMutation.id,
1497
1565
  params: {
1498
- unitId: n.unitId,
1499
- subUnitId: n.subUnitId,
1500
- link: R
1566
+ unitId: copyInfo.unitId,
1567
+ subUnitId: copyInfo.subUnitId,
1568
+ link: currentLink
1501
1569
  }
1502
1570
  });
1503
1571
  });
1504
- }), { redos: o, undos: s };
1572
+ }), { redos, undos };
1505
1573
  }
1506
- };
1507
- be = Jr([
1508
- B(D.Ready, be),
1509
- Ce(0, En),
1510
- Ce(1, h(H)),
1511
- Ce(2, h(Ne)),
1512
- Ce(3, h(F))
1513
- ], be);
1514
- var Qr = Object.defineProperty, ei = Object.getOwnPropertyDescriptor, ti = (e, t, n, r) => {
1515
- for (var i = r > 1 ? void 0 : r ? ei(t, n) : t, o = e.length - 1, s; o >= 0; o--)
1516
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
1517
- return r && i && Qr(t, n, i), i;
1518
- }, ni = (e, t) => (n, r) => t(n, r, e);
1519
- let Re = class extends O {
1520
- constructor(e) {
1521
- super(), this._resolverService = e, this._handleInitUrl();
1574
+ }, __name(_a10, "SheetsHyperLinkCopyPasteController"), _a10);
1575
+ SheetsHyperLinkCopyPasteController = __decorateClass$3([
1576
+ OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkCopyPasteController),
1577
+ __decorateParam$3(0, ISheetClipboardService),
1578
+ __decorateParam$3(1, Inject(HyperLinkModel)),
1579
+ __decorateParam$3(2, Inject(Injector)),
1580
+ __decorateParam$3(3, Inject(SheetsHyperLinkResolverService))
1581
+ ], SheetsHyperLinkCopyPasteController);
1582
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1583
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1584
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1585
+ return kind && result && __defProp$2(target, key, result), result;
1586
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a11;
1587
+ let SheetHyperLinkUrlController = (_a11 = class extends Disposable {
1588
+ constructor(_resolverService) {
1589
+ super(), this._resolverService = _resolverService, this._handleInitUrl();
1522
1590
  }
1523
1591
  _handleInitUrl() {
1524
- const e = location.hash;
1525
- e && this._resolverService.parseHyperLink(e).handler();
1592
+ const hash = location.hash;
1593
+ hash && this._resolverService.parseHyperLink(hash).handler();
1526
1594
  }
1527
- };
1528
- Re = ti([
1529
- B(D.Rendered, Re),
1530
- ni(0, h(F))
1531
- ], Re);
1532
- var ri = Object.defineProperty, ii = Object.getOwnPropertyDescriptor, oi = (e, t, n, r) => {
1533
- for (var i = r > 1 ? void 0 : r ? ii(t, n) : t, o = e.length - 1, s; o >= 0; o--)
1534
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
1535
- return r && i && ri(t, n, i), i;
1536
- }, Ze = (e, t) => (n, r) => t(n, r, e);
1537
- let we = class extends O {
1538
- constructor(e, t, n) {
1539
- super(), this._localeService = e, this._commandService = t, this._sheetPermissionInterceptorBaseController = n, this._commandExecutedListener();
1595
+ }, __name(_a11, "SheetHyperLinkUrlController"), _a11);
1596
+ SheetHyperLinkUrlController = __decorateClass$2([
1597
+ OnLifecycle(LifecycleStages.Rendered, SheetHyperLinkUrlController),
1598
+ __decorateParam$2(0, Inject(SheetsHyperLinkResolverService))
1599
+ ], SheetHyperLinkUrlController);
1600
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1601
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1602
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1603
+ return kind && result && __defProp$1(target, key, result), result;
1604
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a12;
1605
+ let SheetsHyperLinkPermissionController = (_a12 = class extends Disposable {
1606
+ constructor(_localeService, _commandService, _sheetPermissionInterceptorBaseController) {
1607
+ super(), this._localeService = _localeService, this._commandService = _commandService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._commandExecutedListener();
1540
1608
  }
1541
1609
  _commandExecutedListener() {
1542
1610
  this.disposeWithMe(
1543
- this._commandService.beforeCommandExecuted((e) => {
1544
- e.id === Ft.id && (this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1545
- workbookTypes: [$e],
1546
- rangeTypes: [Ve],
1547
- worksheetTypes: [Be, tt, De]
1611
+ this._commandService.beforeCommandExecuted((command) => {
1612
+ command.id === InsertLinkShortcut.id && (this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
1613
+ workbookTypes: [WorkbookEditablePermission],
1614
+ rangeTypes: [RangeProtectionPermissionEditPoint],
1615
+ worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission]
1548
1616
  }) || this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")));
1549
1617
  })
1550
1618
  );
1551
1619
  }
1552
- };
1553
- we = oi([
1554
- B(D.Rendered, we),
1555
- Ze(0, h(pe)),
1556
- Ze(1, K),
1557
- Ze(2, h(Pt))
1558
- ], we);
1559
- var Kt = Object.defineProperty, si = Object.getOwnPropertyDescriptor, ai = (e, t, n) => t in e ? Kt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, ci = (e, t, n, r) => {
1560
- for (var i = r > 1 ? void 0 : r ? si(t, n) : t, o = e.length - 1, s; o >= 0; o--)
1561
- (s = e[o]) && (i = (r ? s(t, n, i) : s(i)) || i);
1562
- return r && i && Kt(t, n, i), i;
1563
- }, vt = (e, t) => (n, r) => t(n, r, e), Yt = (e, t, n) => ai(e, typeof t != "symbol" ? t + "" : t, n);
1564
- let He = class extends rn {
1565
- constructor(e, t, n) {
1566
- super(), this._config = e, this._injector = t, this._renderManagerService = n;
1567
- }
1568
- onStarting(e) {
1620
+ }, __name(_a12, "SheetsHyperLinkPermissionController"), _a12);
1621
+ SheetsHyperLinkPermissionController = __decorateClass$1([
1622
+ OnLifecycle(LifecycleStages.Rendered, SheetsHyperLinkPermissionController),
1623
+ __decorateParam$1(0, Inject(LocaleService)),
1624
+ __decorateParam$1(1, ICommandService),
1625
+ __decorateParam$1(2, Inject(SheetPermissionInterceptorBaseController))
1626
+ ], SheetsHyperLinkPermissionController);
1627
+ 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) => {
1628
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1629
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1630
+ return kind && result && __defProp2(target, key, result), result;
1631
+ }, "__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"), _a13;
1632
+ let UniverSheetsHyperLinkUIPlugin = (_a13 = class extends Plugin {
1633
+ constructor(_config, _injector, _renderManagerService) {
1634
+ super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService;
1635
+ }
1636
+ onStarting() {
1569
1637
  [
1570
- [F],
1571
- [$],
1572
- [ye],
1573
- [Se],
1574
- [Ie],
1575
- [ke],
1576
1638
  [
1577
- le,
1639
+ SheetsHyperLinkResolverService,
1578
1640
  {
1579
- useFactory: () => this._injector.createInstance(le, this._config)
1641
+ useFactory: /* @__PURE__ */ __name(() => {
1642
+ var _a14;
1643
+ return this._injector.createInstance(SheetsHyperLinkResolverService, (_a14 = this._config) == null ? void 0 : _a14.urlHandler);
1644
+ }, "useFactory")
1580
1645
  }
1581
1646
  ],
1582
- [Pe],
1583
- [be],
1584
- [we],
1585
- [Re]
1586
- ].forEach((n) => e.add(n));
1647
+ [SheetsHyperLinkPopupService],
1648
+ [SheetsHyperLinkSidePanelService],
1649
+ [SheetsHyperLinkRemoveSheetController],
1650
+ [SheetsHyperLinkRenderManagerController],
1651
+ [SheetHyperLinkSetRangeController],
1652
+ [SheetsHyperLinkPopupController],
1653
+ [
1654
+ SheetsHyperLinkUIController,
1655
+ {
1656
+ useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetsHyperLinkUIController, this._config), "useFactory")
1657
+ }
1658
+ ],
1659
+ [SheetsHyperLinkAutoFillController],
1660
+ [SheetsHyperLinkCopyPasteController],
1661
+ [SheetsHyperLinkPermissionController],
1662
+ [SheetHyperLinkUrlController]
1663
+ ].forEach((dep) => this._injector.add(dep));
1587
1664
  }
1588
1665
  onReady() {
1589
1666
  [
1590
- [Xe]
1591
- ].forEach((t) => this._renderManagerService.registerRenderModule(E.UNIVER_SHEET, t));
1667
+ [SheetsHyperLinkRenderController]
1668
+ ].forEach((d) => this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, d));
1592
1669
  }
1593
- };
1594
- Yt(He, "pluginName", at);
1595
- Yt(He, "type", E.UNIVER_SHEET);
1596
- He = ci([
1597
- on(Cn),
1598
- vt(1, h(Ne)),
1599
- vt(2, nt)
1600
- ], He);
1670
+ }, __name(_a13, "UniverSheetsHyperLinkUIPlugin"), _a13);
1671
+ __publicField2(UniverSheetsHyperLinkUIPlugin, "pluginName", SHEET_HYPER_LINK_UI_PLUGIN);
1672
+ __publicField2(UniverSheetsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
1673
+ UniverSheetsHyperLinkUIPlugin = __decorateClass([
1674
+ DependentOn(UniverSheetsHyperLinkPlugin),
1675
+ __decorateParam(1, Inject(Injector)),
1676
+ __decorateParam(2, IRenderManagerService)
1677
+ ], UniverSheetsHyperLinkUIPlugin);
1601
1678
  export {
1602
- Te as CloseHyperLinkSidebarOperation,
1603
- ot as InsertHyperLinkOperation,
1604
- Ft as InsertLinkShortcut,
1605
- it as OpenHyperLinkSidebarOperation,
1606
- Ie as SheetHyperLinkSetRangeController,
1607
- Re as SheetHyperLinkUrlController,
1608
- Pe as SheetsHyperLinkAutoFillController,
1609
- be as SheetsHyperLinkCopyPasteController,
1610
- ke as SheetsHyperLinkPopupController,
1611
- $ as SheetsHyperLinkPopupService,
1612
- ye as SheetsHyperLinkRemoveSheetController,
1613
- Xe as SheetsHyperLinkRenderController,
1614
- Se as SheetsHyperLinkRenderManagerController,
1615
- F as SheetsHyperLinkResolverService,
1616
- le as SheetsHyperLinkUIController,
1617
- He as UniverSheetsHyperLinkUIPlugin
1679
+ CloseHyperLinkSidebarOperation,
1680
+ InsertHyperLinkOperation,
1681
+ InsertLinkShortcut,
1682
+ OpenHyperLinkSidebarOperation,
1683
+ SheetHyperLinkSetRangeController,
1684
+ SheetHyperLinkUrlController,
1685
+ SheetsHyperLinkAutoFillController,
1686
+ SheetsHyperLinkCopyPasteController,
1687
+ SheetsHyperLinkPopupController,
1688
+ SheetsHyperLinkPopupService,
1689
+ SheetsHyperLinkRemoveSheetController,
1690
+ SheetsHyperLinkRenderController,
1691
+ SheetsHyperLinkRenderManagerController,
1692
+ SheetsHyperLinkResolverService,
1693
+ SheetsHyperLinkSidePanelService,
1694
+ SheetsHyperLinkUIController,
1695
+ UniverSheetsHyperLinkUIPlugin
1618
1696
  };