@univerjs/sheets-hyper-link 0.2.4 → 0.2.6

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,629 +1,630 @@
1
- var z = Object.defineProperty;
2
- var Y = (i, e, t) => e in i ? z(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var _ = (i, e, t) => Y(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { Subject as Z } from "rxjs";
5
- import { Disposable as C, ObjectMatrix as q, UniverInstanceType as A, IUniverInstanceService as F, CommandType as m, ICommandService as M, IUndoRedoService as k, sequenceExecuteAsync as R, OnLifecycle as E, LifecycleStages as D, IResourceManagerService as Q, isValidRange as X, toDisposable as ee, DependentOn as te, Plugin as ne } from "@univerjs/core";
6
- import { SheetInterceptorService as N, RefRangeService as re, SheetsSelectionsService as ie, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests as I, UniverSheetsPlugin as se } from "@univerjs/sheets";
7
- import { Inject as y, Injector as ae } from "@wendellhu/redi";
8
- import { HyperLinkModel as oe, RemoveHyperLinkMutation as de, AddHyperLinkMutation as ce, UpdateHyperLinkRefMutation as $, UpdateHyperLinkMutation as x } from "@univerjs/sheets-hyper-link";
9
- import { deserializeRangeWithSheet as ue, serializeRange as v } from "@univerjs/engine-formula";
10
- var le = Object.defineProperty, pe = Object.getOwnPropertyDescriptor, he = (i, e, t, n) => {
11
- for (var r = n > 1 ? void 0 : n ? pe(e, t) : e, s = i.length - 1, a; s >= 0; s--)
12
- (a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
13
- return n && r && le(e, t, r), r;
14
- }, ge = (i, e) => (t, n) => e(t, n, i);
15
- let g = class extends C {
16
- constructor(e) {
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 { Subject } from "rxjs";
6
+ import { Disposable, ObjectMatrix, UniverInstanceType, IUniverInstanceService, CommandType, ICommandService, IUndoRedoService, sequenceExecuteAsync, OnLifecycle, LifecycleStages, Inject, IResourceManagerService, isValidRange, toDisposable, DependentOn, Injector, Plugin } from "@univerjs/core";
7
+ import { SheetInterceptorService, RefRangeService, SheetsSelectionsService, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests, UniverSheetsPlugin } from "@univerjs/sheets";
8
+ import { HyperLinkModel as HyperLinkModel$1, RemoveHyperLinkMutation as RemoveHyperLinkMutation$1, AddHyperLinkMutation as AddHyperLinkMutation$1, UpdateHyperLinkRefMutation as UpdateHyperLinkRefMutation$1, UpdateHyperLinkMutation as UpdateHyperLinkMutation$1 } from "@univerjs/sheets-hyper-link";
9
+ import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
10
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
11
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
12
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
13
+ return kind && result && __defProp$4(target, key, result), result;
14
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a;
15
+ let HyperLinkModel = (_a = class extends Disposable {
16
+ constructor(_univerInstanceService) {
17
17
  super();
18
- _(this, "_linkUpdate$", new Z());
19
- _(this, "linkUpdate$", this._linkUpdate$.asObservable());
20
- _(this, "_linkMap", /* @__PURE__ */ new Map());
21
- _(this, "_linkPositionMap", /* @__PURE__ */ new Map());
22
- this._univerInstanceService = e, this.disposeWithMe({
23
- dispose: () => {
18
+ __publicField(this, "_linkUpdate$", new Subject());
19
+ __publicField(this, "linkUpdate$", this._linkUpdate$.asObservable());
20
+ __publicField(this, "_linkMap", /* @__PURE__ */ new Map());
21
+ __publicField(this, "_linkPositionMap", /* @__PURE__ */ new Map());
22
+ this._univerInstanceService = _univerInstanceService, this.disposeWithMe({
23
+ dispose: /* @__PURE__ */ __name(() => {
24
24
  this._linkUpdate$.complete();
25
- }
25
+ }, "dispose")
26
26
  });
27
27
  }
28
- _ensureMap(e, t) {
29
- let n = this._linkMap.get(e);
30
- n || (n = /* @__PURE__ */ new Map(), this._linkMap.set(e, n));
31
- let r = n.get(t);
32
- r || (r = new q(), n.set(t, r));
33
- let s = this._linkPositionMap.get(e);
34
- s || (s = /* @__PURE__ */ new Map(), this._linkPositionMap.set(e, s));
35
- let a = s.get(t);
36
- return a || (a = /* @__PURE__ */ new Map(), s.set(t, a)), {
37
- matrix: r,
38
- positionMap: a
28
+ _ensureMap(unitId, subUnitId) {
29
+ let unitMap = this._linkMap.get(unitId);
30
+ unitMap || (unitMap = /* @__PURE__ */ new Map(), this._linkMap.set(unitId, unitMap));
31
+ let matrix = unitMap.get(subUnitId);
32
+ matrix || (matrix = new ObjectMatrix(), unitMap.set(subUnitId, matrix));
33
+ let positionUnitMap = this._linkPositionMap.get(unitId);
34
+ positionUnitMap || (positionUnitMap = /* @__PURE__ */ new Map(), this._linkPositionMap.set(unitId, positionUnitMap));
35
+ let positionSubUnitMap = positionUnitMap.get(subUnitId);
36
+ return positionSubUnitMap || (positionSubUnitMap = /* @__PURE__ */ new Map(), positionUnitMap.set(subUnitId, positionSubUnitMap)), {
37
+ matrix,
38
+ positionMap: positionSubUnitMap
39
39
  };
40
40
  }
41
- addHyperLink(e, t, n) {
42
- const { matrix: r, positionMap: s } = this._ensureMap(e, t);
43
- return r.setValue(n.row, n.column, n), s.set(n.id, { row: n.row, column: n.column, link: n }), this._linkUpdate$.next({
44
- unitId: e,
45
- subUnitId: t,
46
- payload: n,
41
+ addHyperLink(unitId, subUnitId, link) {
42
+ const { matrix, positionMap } = this._ensureMap(unitId, subUnitId);
43
+ return matrix.setValue(link.row, link.column, link), positionMap.set(link.id, { row: link.row, column: link.column, link }), this._linkUpdate$.next({
44
+ unitId,
45
+ subUnitId,
46
+ payload: link,
47
47
  type: "add"
48
48
  }), !0;
49
49
  }
50
- updateHyperLink(e, t, n, r, s = !1) {
51
- const { matrix: a, positionMap: o } = this._ensureMap(e, t), d = o.get(n);
52
- if (!d)
50
+ updateHyperLink(unitId, subUnitId, id, payload, silent = !1) {
51
+ const { matrix, positionMap } = this._ensureMap(unitId, subUnitId), position = positionMap.get(id);
52
+ if (!position)
53
53
  return !0;
54
- const c = a.getValue(d.row, d.column);
55
- return c && (Object.assign(c, r), this._linkUpdate$.next({
56
- unitId: e,
57
- subUnitId: t,
54
+ const link = matrix.getValue(position.row, position.column);
55
+ return link && (Object.assign(link, payload), this._linkUpdate$.next({
56
+ unitId,
57
+ subUnitId,
58
58
  payload: {
59
- display: c.display,
60
- payload: c.payload
59
+ display: link.display,
60
+ payload: link.payload
61
61
  },
62
- id: n,
62
+ id,
63
63
  type: "update",
64
- silent: s
64
+ silent
65
65
  })), !0;
66
66
  }
67
- updateHyperLinkRef(e, t, n, r, s = !1) {
68
- const { matrix: a, positionMap: o } = this._ensureMap(e, t), d = o.get(n);
69
- if (!d)
67
+ updateHyperLinkRef(unitId, subUnitId, id, payload, silent = !1) {
68
+ const { matrix, positionMap } = this._ensureMap(unitId, subUnitId), position = positionMap.get(id);
69
+ if (!position)
70
70
  return !0;
71
- let c = a.getValue(d.row, d.column);
72
- return !c || c.id !== n ? c = d.link : a.realDeleteValue(d.row, d.column), Object.assign(c, r), o.set(n, { ...r, link: c }), a.setValue(r.row, r.column, c), this._linkUpdate$.next({
73
- unitId: e,
74
- subUnitId: t,
75
- payload: r,
76
- id: n,
71
+ let link = matrix.getValue(position.row, position.column);
72
+ return !link || link.id !== id ? link = position.link : matrix.realDeleteValue(position.row, position.column), Object.assign(link, payload), positionMap.set(id, { ...payload, link }), matrix.setValue(payload.row, payload.column, link), this._linkUpdate$.next({
73
+ unitId,
74
+ subUnitId,
75
+ payload,
76
+ id,
77
77
  type: "updateRef",
78
- silent: s
78
+ silent
79
79
  }), !0;
80
80
  }
81
- removeHyperLink(e, t, n) {
82
- const { matrix: r, positionMap: s } = this._ensureMap(e, t), a = s.get(n);
83
- if (!a)
81
+ removeHyperLink(unitId, subUnitId, id) {
82
+ const { matrix, positionMap } = this._ensureMap(unitId, subUnitId), position = positionMap.get(id);
83
+ if (!position)
84
84
  return !1;
85
- s.delete(n);
86
- const o = r.getValue(a.row, a.column);
87
- return o && o.id === n && r.realDeleteValue(a.row, a.column), this._linkUpdate$.next({
88
- unitId: e,
89
- subUnitId: t,
90
- payload: a.link,
85
+ positionMap.delete(id);
86
+ const link = matrix.getValue(position.row, position.column);
87
+ return link && link.id === id && matrix.realDeleteValue(position.row, position.column), this._linkUpdate$.next({
88
+ unitId,
89
+ subUnitId,
90
+ payload: position.link,
91
91
  type: "remove"
92
92
  }), !0;
93
93
  }
94
- getHyperLink(e, t, n) {
95
- const { matrix: r, positionMap: s } = this._ensureMap(e, t), a = s.get(n);
96
- if (a)
97
- return r.getValue(a.row, a.column);
94
+ getHyperLink(unitId, subUnitId, id) {
95
+ const { matrix, positionMap } = this._ensureMap(unitId, subUnitId), position = positionMap.get(id);
96
+ if (position)
97
+ return matrix.getValue(position.row, position.column);
98
98
  }
99
- getHyperLinkByLocation(e, t, n, r) {
100
- const { matrix: s } = this._ensureMap(e, t);
101
- return s.getValue(n, r);
99
+ getHyperLinkByLocation(unitId, subUnitId, row, column) {
100
+ const { matrix } = this._ensureMap(unitId, subUnitId);
101
+ return matrix.getValue(row, column);
102
102
  }
103
- getHyperLinkByLocationSync(e, t, n, r) {
104
- var u, l, h, f, p;
105
- const { matrix: s } = this._ensureMap(e, t), a = this._univerInstanceService.getUnit(e, A.UNIVER_SHEET), o = (u = a == null ? void 0 : a.getSheetBySheetId(t)) == null ? void 0 : u.getCellRaw(n, r), d = ((p = (f = o == null ? void 0 : o.v) != null ? f : (h = (l = o == null ? void 0 : o.p) == null ? void 0 : l.body) == null ? void 0 : h.dataStream.slice(0, -2)) != null ? p : "").toString(), c = s.getValue(n, r);
106
- if (c)
103
+ getHyperLinkByLocationSync(unitId, subUnitId, row, column) {
104
+ var _a6, _b, _c, _d, _e;
105
+ const { matrix } = this._ensureMap(unitId, subUnitId), workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), cell = (_a6 = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId)) == null ? void 0 : _a6.getCellRaw(row, column), cellValueStr = ((_e = (_d = cell == null ? void 0 : cell.v) != null ? _d : (_c = (_b = cell == null ? void 0 : cell.p) == null ? void 0 : _b.body) == null ? void 0 : _c.dataStream.slice(0, -2)) != null ? _e : "").toString(), link = matrix.getValue(row, column);
106
+ if (link)
107
107
  return {
108
- ...c,
109
- display: d
108
+ ...link,
109
+ display: cellValueStr
110
110
  };
111
111
  }
112
- getSubUnit(e, t) {
113
- const { matrix: n } = this._ensureMap(e, t), r = [];
114
- return n.forValue((s, a, o) => {
115
- o && r.push(o);
116
- }), r;
112
+ getSubUnit(unitId, subUnitId) {
113
+ const { matrix } = this._ensureMap(unitId, subUnitId), links = [];
114
+ return matrix.forValue((row, col, value) => {
115
+ value && links.push(value);
116
+ }), links;
117
117
  }
118
- getUnit(e) {
119
- const t = this._linkMap.get(e);
120
- return t ? Array.from(t.keys()).map((n) => {
121
- const r = this.getSubUnit(e, n);
118
+ getUnit(unitId) {
119
+ const unitMap = this._linkMap.get(unitId);
120
+ return unitMap ? Array.from(unitMap.keys()).map((subUnitId) => {
121
+ const links = this.getSubUnit(unitId, subUnitId);
122
122
  return {
123
- unitId: e,
124
- subUnitId: n,
125
- links: r
123
+ unitId,
124
+ subUnitId,
125
+ links
126
126
  };
127
127
  }) : [];
128
128
  }
129
- deleteUnit(e) {
130
- const t = this.getUnit(e);
131
- this._linkMap.delete(e), this._linkPositionMap.delete(e), this._linkUpdate$.next({
129
+ deleteUnit(unitId) {
130
+ const links = this.getUnit(unitId);
131
+ this._linkMap.delete(unitId), this._linkPositionMap.delete(unitId), this._linkUpdate$.next({
132
132
  type: "unload",
133
- unitId: e,
134
- unitLinks: t
133
+ unitId,
134
+ unitLinks: links
135
135
  });
136
136
  }
137
137
  getAll() {
138
- return Array.from(this._linkMap.keys()).map((t) => this.getUnit(t));
139
- }
140
- };
141
- g = he([
142
- ge(0, F)
143
- ], g);
144
- const H = {
145
- type: m.MUTATION,
138
+ return Array.from(this._linkMap.keys()).map((unitId) => this.getUnit(unitId));
139
+ }
140
+ }, __name(_a, "HyperLinkModel"), _a);
141
+ HyperLinkModel = __decorateClass$4([
142
+ __decorateParam$4(0, IUniverInstanceService)
143
+ ], HyperLinkModel);
144
+ const AddHyperLinkMutation = {
145
+ type: CommandType.MUTATION,
146
146
  id: "sheets.mutation.add-hyper-link",
147
- handler(i, e) {
148
- if (!e)
147
+ handler(accessor, params) {
148
+ if (!params)
149
149
  return !1;
150
- const t = i.get(g), { unitId: n, subUnitId: r, link: s } = e;
151
- return t.addHyperLink(n, r, s);
150
+ const model = accessor.get(HyperLinkModel), { unitId, subUnitId, link } = params;
151
+ return model.addHyperLink(unitId, subUnitId, link);
152
152
  }
153
- }, O = {
154
- type: m.MUTATION,
153
+ }, UpdateHyperLinkMutation = {
154
+ type: CommandType.MUTATION,
155
155
  id: "sheets.mutation.update-hyper-link",
156
- handler(i, e) {
157
- if (!e)
156
+ handler(accessor, params) {
157
+ if (!params)
158
158
  return !1;
159
- const t = i.get(g), { unitId: n, subUnitId: r, payload: s, id: a } = e;
160
- return t.updateHyperLink(n, r, a, s, !1);
159
+ const model = accessor.get(HyperLinkModel), { unitId, subUnitId, payload, id } = params;
160
+ return model.updateHyperLink(unitId, subUnitId, id, payload, !1);
161
161
  }
162
- }, _e = {
163
- type: m.MUTATION,
162
+ }, UpdateHyperLinkRefMutation = {
163
+ type: CommandType.MUTATION,
164
164
  id: "sheets.mutation.update-hyper-link-ref",
165
- handler(i, e) {
166
- if (!e)
165
+ handler(accessor, params) {
166
+ if (!params)
167
167
  return !1;
168
- const t = i.get(g), { unitId: n, subUnitId: r, id: s, row: a, column: o, silent: d } = e;
169
- return t.updateHyperLinkRef(n, r, s, { row: a, column: o }, d);
168
+ const model = accessor.get(HyperLinkModel), { unitId, subUnitId, id, row, column, silent } = params;
169
+ return model.updateHyperLinkRef(unitId, subUnitId, id, { row, column }, silent);
170
170
  }
171
- }, b = {
172
- type: m.MUTATION,
171
+ }, RemoveHyperLinkMutation = {
172
+ type: CommandType.MUTATION,
173
173
  id: "sheets.mutation.remove-hyper-link",
174
- handler(i, e) {
175
- if (!e)
174
+ handler(accessor, params) {
175
+ if (!params)
176
176
  return !1;
177
- const t = i.get(g), { unitId: n, subUnitId: r, id: s } = e;
178
- return t.removeHyperLink(n, r, s);
177
+ const model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params;
178
+ return model.removeHyperLink(unitId, subUnitId, id);
179
179
  }
180
- }, j = {
181
- type: m.COMMAND,
180
+ }, AddHyperLinkCommand = {
181
+ type: CommandType.COMMAND,
182
182
  id: "sheets.command.add-hyper-link",
183
- async handler(i, e) {
184
- if (!e)
183
+ async handler(accessor, params) {
184
+ if (!params)
185
185
  return !1;
186
- const t = i.get(N), n = i.get(M), r = i.get(k), { unitId: s, subUnitId: a, link: o } = e, { redos: d, undos: c } = t.onCommandExecute({
187
- id: j.id,
188
- params: e
189
- }), u = {
190
- id: H.id,
191
- params: e
192
- }, l = {
193
- id: b.id,
186
+ const sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), { unitId, subUnitId, link } = params, { redos, undos } = sheetInterceptorService.onCommandExecute({
187
+ id: AddHyperLinkCommand.id,
188
+ params
189
+ }), redo = {
190
+ id: AddHyperLinkMutation.id,
191
+ params
192
+ }, undo = {
193
+ id: RemoveHyperLinkMutation.id,
194
194
  params: {
195
- unitId: s,
196
- subUnitId: a,
197
- id: o.id
195
+ unitId,
196
+ subUnitId,
197
+ id: link.id
198
198
  }
199
199
  };
200
- return (await R([u, ...d], n)).result ? (r.pushUndoRedo({
201
- redoMutations: [u, ...d],
202
- undoMutations: [l, ...c],
203
- unitID: s
200
+ return (await sequenceExecuteAsync([redo, ...redos], commandService)).result ? (undoRedoService.pushUndoRedo({
201
+ redoMutations: [redo, ...redos],
202
+ undoMutations: [undo, ...undos],
203
+ unitID: unitId
204
204
  }), !0) : !1;
205
205
  }
206
206
  };
207
- function fe(i) {
208
- const { row: e, column: t, id: n, ...r } = i;
209
- return r;
207
+ function getHyperLinkContent(link) {
208
+ const { row, column, id, ...content } = link;
209
+ return content;
210
210
  }
211
- const T = {
212
- type: m.COMMAND,
211
+ __name(getHyperLinkContent, "getHyperLinkContent");
212
+ const UpdateHyperLinkCommand = {
213
+ type: CommandType.COMMAND,
213
214
  id: "sheets.command.update-hyper-link",
214
- async handler(i, e) {
215
- if (!e)
215
+ async handler(accessor, params) {
216
+ if (!params)
216
217
  return !1;
217
- const t = i.get(N), n = i.get(M), r = i.get(k), s = i.get(g), { unitId: a, subUnitId: o, id: d } = e, c = s.getHyperLink(a, o, d);
218
- if (!c)
218
+ const sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params, link = model.getHyperLink(unitId, subUnitId, id);
219
+ if (!link)
219
220
  return !1;
220
- const { redos: u, undos: l } = t.onCommandExecute({
221
- id: T.id,
222
- params: e
223
- }), h = {
224
- id: O.id,
225
- params: e
226
- }, f = {
227
- id: O.id,
221
+ const { redos, undos } = sheetInterceptorService.onCommandExecute({
222
+ id: UpdateHyperLinkCommand.id,
223
+ params
224
+ }), redo = {
225
+ id: UpdateHyperLinkMutation.id,
226
+ params
227
+ }, undo = {
228
+ id: UpdateHyperLinkMutation.id,
228
229
  params: {
229
- unitId: a,
230
- subUnitId: o,
231
- id: d,
232
- payload: fe(c)
230
+ unitId,
231
+ subUnitId,
232
+ id,
233
+ payload: getHyperLinkContent(link)
233
234
  }
234
235
  };
235
- return (await R([h, ...u], n)).result ? (r.pushUndoRedo({
236
- redoMutations: [h, ...u],
237
- undoMutations: [f, ...l],
238
- unitID: a
236
+ return (await sequenceExecuteAsync([redo, ...redos], commandService)).result ? (undoRedoService.pushUndoRedo({
237
+ redoMutations: [redo, ...redos],
238
+ undoMutations: [undo, ...undos],
239
+ unitID: unitId
239
240
  }), !0) : !1;
240
241
  }
241
- }, W = {
242
- type: m.COMMAND,
242
+ }, RemoveHyperLinkCommand = {
243
+ type: CommandType.COMMAND,
243
244
  id: "sheets.command.remove-hyper-link",
244
- async handler(i, e) {
245
- if (!e)
245
+ async handler(accessor, params) {
246
+ if (!params)
246
247
  return !1;
247
- const t = i.get(N), n = i.get(M), r = i.get(k), s = i.get(g), { unitId: a, subUnitId: o, id: d } = e, c = s.getHyperLink(a, o, d), { redos: u, undos: l } = t.onCommandExecute({
248
- id: W.id,
249
- params: e
250
- }), h = {
251
- id: b.id,
252
- params: e
253
- }, f = {
254
- id: H.id,
248
+ const sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params, link = model.getHyperLink(unitId, subUnitId, id), { redos, undos } = sheetInterceptorService.onCommandExecute({
249
+ id: RemoveHyperLinkCommand.id,
250
+ params
251
+ }), redo = {
252
+ id: RemoveHyperLinkMutation.id,
253
+ params
254
+ }, undo = {
255
+ id: AddHyperLinkMutation.id,
255
256
  params: {
256
- unitId: a,
257
- subUnitId: o,
258
- link: c
257
+ unitId,
258
+ subUnitId,
259
+ link
259
260
  }
260
261
  };
261
- return (await R([h, ...u], n)).result ? (r.pushUndoRedo({
262
- redoMutations: [h, ...u],
263
- undoMutations: [f, ...l],
264
- unitID: a
262
+ return (await sequenceExecuteAsync([redo, ...redos], commandService)).result ? (undoRedoService.pushUndoRedo({
263
+ redoMutations: [redo, ...redos],
264
+ undoMutations: [undo, ...undos],
265
+ unitID: unitId
265
266
  }), !0) : !1;
266
267
  }
267
- }, me = {
268
- type: m.COMMAND,
268
+ }, CancelHyperLinkCommand = {
269
+ type: CommandType.COMMAND,
269
270
  id: "sheets.command.cancel-hyper-link",
270
- async handler(i, e) {
271
- if (!e)
271
+ async handler(accessor, params) {
272
+ if (!params)
272
273
  return !1;
273
- const t = i.get(M), n = i.get(k), r = i.get(g), { unitId: s, subUnitId: a, id: o } = e, d = r.getHyperLink(s, a, o), c = {
274
- id: b.id,
275
- params: e
276
- }, u = {
277
- id: H.id,
274
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params, link = model.getHyperLink(unitId, subUnitId, id), redo = {
275
+ id: RemoveHyperLinkMutation.id,
276
+ params
277
+ }, undo = {
278
+ id: AddHyperLinkMutation.id,
278
279
  params: {
279
- unitId: s,
280
- subUnitId: a,
281
- link: d
280
+ unitId,
281
+ subUnitId,
282
+ link
282
283
  }
283
284
  };
284
- return (await R([c], t)).result ? (n.pushUndoRedo({
285
- redoMutations: [c],
286
- undoMutations: [u],
287
- unitID: s
285
+ return (await sequenceExecuteAsync([redo], commandService)).result ? (undoRedoService.pushUndoRedo({
286
+ redoMutations: [redo],
287
+ undoMutations: [undo],
288
+ unitID: unitId
288
289
  }), !0) : !1;
289
290
  }
290
291
  };
291
- var Me = Object.defineProperty, ye = Object.getOwnPropertyDescriptor, Re = (i, e, t, n) => {
292
- for (var r = n > 1 ? void 0 : n ? ye(e, t) : e, s = i.length - 1, a; s >= 0; s--)
293
- (a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
294
- return n && r && Me(e, t, r), r;
295
- }, ve = (i, e) => (t, n) => e(t, n, i);
296
- let S = class extends C {
297
- constructor(i) {
298
- super(), this._commandService = i, this._registerCommands();
292
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
293
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
294
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
295
+ return kind && result && __defProp$3(target, key, result), result;
296
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a2;
297
+ let SheetsHyperLinkController = (_a2 = class extends Disposable {
298
+ constructor(_commandService) {
299
+ super(), this._commandService = _commandService, this._registerCommands();
299
300
  }
300
301
  _registerCommands() {
301
302
  [
302
- H,
303
- O,
304
- b,
305
- _e,
306
- j,
307
- T,
308
- W,
309
- me
310
- ].forEach((i) => {
311
- this._commandService.registerCommand(i);
303
+ AddHyperLinkMutation,
304
+ UpdateHyperLinkMutation,
305
+ RemoveHyperLinkMutation,
306
+ UpdateHyperLinkRefMutation,
307
+ AddHyperLinkCommand,
308
+ UpdateHyperLinkCommand,
309
+ RemoveHyperLinkCommand,
310
+ CancelHyperLinkCommand
311
+ ].forEach((command) => {
312
+ this._commandService.registerCommand(command);
312
313
  });
313
314
  }
314
- };
315
- S = Re([
316
- E(D.Starting, S),
317
- ve(0, M)
318
- ], S);
319
- var we = /* @__PURE__ */ ((i) => (i[i.range = 0] = "range", i[i.link = 1] = "link", i))(we || {});
320
- const J = "SHEET_HYPER_LINK_PLUGIN", Se = "err";
321
- var G = /* @__PURE__ */ ((i) => (i[i.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", i[i.UNIVER_DOC = 1] = "UNIVER_DOC", i[i.UNIVER_SHEET = 2] = "UNIVER_SHEET", i[i.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", i[i.UNRECOGNIZED = -1] = "UNRECOGNIZED", i))(G || {}), Le = Object.defineProperty, Ue = Object.getOwnPropertyDescriptor, Pe = (i, e, t, n) => {
322
- for (var r = n > 1 ? void 0 : n ? Ue(e, t) : e, s = i.length - 1, a; s >= 0; s--)
323
- (a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
324
- return n && r && Le(e, t, r), r;
325
- }, V = (i, e) => (t, n) => e(t, n, i);
326
- let L = class extends C {
327
- constructor(i, e) {
328
- super(), this._resourceManagerService = i, this._hyperLinkModel = e, this._initSnapshot();
315
+ }, __name(_a2, "SheetsHyperLinkController"), _a2);
316
+ SheetsHyperLinkController = __decorateClass$3([
317
+ OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkController),
318
+ __decorateParam$3(0, ICommandService)
319
+ ], SheetsHyperLinkController);
320
+ var HyperLinkType = /* @__PURE__ */ ((HyperLinkType2) => (HyperLinkType2[HyperLinkType2.range = 0] = "range", HyperLinkType2[HyperLinkType2.link = 1] = "link", HyperLinkType2))(HyperLinkType || {});
321
+ const SHEET_HYPER_LINK_PLUGIN = "SHEET_HYPER_LINK_PLUGIN", ERROR_RANGE = "err";
322
+ var I = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(I || {}), __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
323
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
324
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
325
+ return kind && result && __defProp$2(target, key, result), result;
326
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a3;
327
+ let SheetsHyperLinkResourceController = (_a3 = class extends Disposable {
328
+ constructor(_resourceManagerService, _hyperLinkModel) {
329
+ super(), this._resourceManagerService = _resourceManagerService, this._hyperLinkModel = _hyperLinkModel, this._initSnapshot();
329
330
  }
330
331
  _initSnapshot() {
331
- const i = (t) => {
332
- const n = this._hyperLinkModel.getUnit(t), r = {};
333
- return n ? (n.forEach((s) => {
334
- r[s.subUnitId] = s.links.map(({ display: a, ...o }) => o);
335
- }), JSON.stringify(r)) : "";
336
- }, e = (t) => {
337
- if (!t)
332
+ const toJson = /* @__PURE__ */ __name((unitID) => {
333
+ const map = this._hyperLinkModel.getUnit(unitID), resultMap = {};
334
+ return map ? (map.forEach((info) => {
335
+ resultMap[info.subUnitId] = info.links.map(({ display, ...link }) => link);
336
+ }), JSON.stringify(resultMap)) : "";
337
+ }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
338
+ if (!json)
338
339
  return {};
339
340
  try {
340
- return JSON.parse(t);
341
+ return JSON.parse(json);
341
342
  } catch {
342
343
  return {};
343
344
  }
344
- };
345
+ }, "parseJson");
345
346
  this.disposeWithMe(
346
347
  this._resourceManagerService.registerPluginResource({
347
- pluginName: J,
348
- businesses: [G.UNIVER_SHEET],
349
- toJson: (t) => i(t),
350
- parseJson: (t) => e(t),
351
- onUnLoad: (t) => {
352
- this._hyperLinkModel.deleteUnit(t);
353
- },
354
- onLoad: async (t, n) => {
355
- Object.keys(n).forEach((r) => {
356
- n[r].forEach((a) => {
357
- this._hyperLinkModel.addHyperLink(t, r, a);
348
+ pluginName: SHEET_HYPER_LINK_PLUGIN,
349
+ businesses: [I.UNIVER_SHEET],
350
+ toJson: /* @__PURE__ */ __name((unitID) => toJson(unitID), "toJson"),
351
+ parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
352
+ onUnLoad: /* @__PURE__ */ __name((unitID) => {
353
+ this._hyperLinkModel.deleteUnit(unitID);
354
+ }, "onUnLoad"),
355
+ onLoad: /* @__PURE__ */ __name(async (unitID, value) => {
356
+ Object.keys(value).forEach((subunitId) => {
357
+ value[subunitId].forEach((link) => {
358
+ this._hyperLinkModel.addHyperLink(unitID, subunitId, link);
358
359
  });
359
360
  });
360
- }
361
+ }, "onLoad")
361
362
  })
362
363
  );
363
364
  }
364
- };
365
- L = Pe([
366
- E(D.Starting, L),
367
- V(0, Q),
368
- V(1, y(g))
369
- ], L);
370
- var Ce = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, He = (i, e, t, n) => {
371
- for (var r = n > 1 ? void 0 : n ? ke(e, t) : e, s = i.length - 1, a; s >= 0; s--)
372
- (a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
373
- return n && r && Ce(e, t, r), r;
374
- }, w = (i, e) => (t, n) => e(t, n, i);
375
- let U = class extends C {
376
- constructor(e, t, n, r) {
365
+ }, __name(_a3, "SheetsHyperLinkResourceController"), _a3);
366
+ SheetsHyperLinkResourceController = __decorateClass$2([
367
+ OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkResourceController),
368
+ __decorateParam$2(0, IResourceManagerService),
369
+ __decorateParam$2(1, Inject(HyperLinkModel))
370
+ ], SheetsHyperLinkResourceController);
371
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
372
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
373
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
374
+ return kind && result && __defProp$1(target, key, result), result;
375
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a4;
376
+ let SheetsHyperLinkRefRangeController = (_a4 = class extends Disposable {
377
+ constructor(_refRangeService, _hyperLinkModel, _selectionManagerService, _commandService) {
377
378
  super();
378
- _(this, "_disposableMap", /* @__PURE__ */ new Map());
379
- _(this, "_watchDisposableMap", /* @__PURE__ */ new Map());
380
- _(this, "_rangeDisableMap", /* @__PURE__ */ new Map());
381
- _(this, "_rangeWatcherMap", /* @__PURE__ */ new Map());
382
- _(this, "_handlePositionChange", (e, t, n, r, s) => {
383
- const a = {
384
- startColumn: n.column,
385
- endColumn: n.column,
386
- startRow: n.row,
387
- endRow: n.row
379
+ __publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
380
+ __publicField(this, "_watchDisposableMap", /* @__PURE__ */ new Map());
381
+ __publicField(this, "_rangeDisableMap", /* @__PURE__ */ new Map());
382
+ __publicField(this, "_rangeWatcherMap", /* @__PURE__ */ new Map());
383
+ __publicField(this, "_handlePositionChange", /* @__PURE__ */ __name((unitId, subUnitId, link, resultRange, silent) => {
384
+ const oldRange = {
385
+ startColumn: link.column,
386
+ endColumn: link.column,
387
+ startRow: link.row,
388
+ endRow: link.row
388
389
  };
389
- return r ? {
390
+ return resultRange ? {
390
391
  redos: [{
391
- id: $.id,
392
+ id: UpdateHyperLinkRefMutation$1.id,
392
393
  params: {
393
- unitId: e,
394
- subUnitId: t,
395
- id: n.id,
396
- row: r.startRow,
397
- column: r.startColumn,
398
- silent: s
394
+ unitId,
395
+ subUnitId,
396
+ id: link.id,
397
+ row: resultRange.startRow,
398
+ column: resultRange.startColumn,
399
+ silent
399
400
  }
400
401
  }],
401
402
  undos: [{
402
- id: $.id,
403
+ id: UpdateHyperLinkRefMutation$1.id,
403
404
  params: {
404
- unitId: e,
405
- subUnitId: t,
406
- id: n.id,
407
- row: a.startRow,
408
- column: a.startColumn,
409
- silent: s
405
+ unitId,
406
+ subUnitId,
407
+ id: link.id,
408
+ row: oldRange.startRow,
409
+ column: oldRange.startColumn,
410
+ silent
410
411
  }
411
412
  }]
412
413
  } : {
413
414
  redos: [{
414
- id: de.id,
415
+ id: RemoveHyperLinkMutation$1.id,
415
416
  params: {
416
- unitId: e,
417
- subUnitId: t,
418
- id: n.id
417
+ unitId,
418
+ subUnitId,
419
+ id: link.id
419
420
  }
420
421
  }],
421
422
  undos: [{
422
- id: ce.id,
423
+ id: AddHyperLinkMutation$1.id,
423
424
  params: {
424
- unitId: e,
425
- subUnitId: t,
426
- link: n
425
+ unitId,
426
+ subUnitId,
427
+ link
427
428
  }
428
429
  }]
429
430
  };
430
- });
431
- this._refRangeService = e, this._hyperLinkModel = t, this._selectionManagerService = n, this._commandService = r, this._initData(), this._initRefRange();
432
- }
433
- _registerPosition(e, t, n) {
434
- const r = n.id, s = {
435
- startColumn: n.column,
436
- endColumn: n.column,
437
- startRow: n.row,
438
- endRow: n.row
439
- }, a = (o) => {
440
- const d = I(s, o, { selectionManagerService: this._selectionManagerService });
441
- return d && d.startColumn === s.startColumn && d.startRow === s.startRow ? {
431
+ }, "_handlePositionChange"));
432
+ this._refRangeService = _refRangeService, this._hyperLinkModel = _hyperLinkModel, this._selectionManagerService = _selectionManagerService, this._commandService = _commandService, this._initData(), this._initRefRange();
433
+ }
434
+ _registerPosition(unitId, subUnitId, link) {
435
+ const id = link.id, oldRange = {
436
+ startColumn: link.column,
437
+ endColumn: link.column,
438
+ startRow: link.row,
439
+ endRow: link.row
440
+ }, handleRefRangeChange = /* @__PURE__ */ __name((commandInfo) => {
441
+ const resultRange = handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(oldRange, commandInfo, { selectionManagerService: this._selectionManagerService });
442
+ return resultRange && resultRange.startColumn === oldRange.startColumn && resultRange.startRow === oldRange.startRow ? {
442
443
  undos: [],
443
444
  redos: []
444
- } : this._handlePositionChange(e, t, n, d, !1);
445
- };
446
- this._disposableMap.set(r, this._refRangeService.registerRefRange(s, a, e, t));
447
- }
448
- _watchPosition(e, t, n) {
449
- const r = n.id, s = {
450
- startColumn: n.column,
451
- endColumn: n.column,
452
- startRow: n.row,
453
- endRow: n.row
445
+ } : this._handlePositionChange(unitId, subUnitId, link, resultRange, !1);
446
+ }, "handleRefRangeChange");
447
+ this._disposableMap.set(id, this._refRangeService.registerRefRange(oldRange, handleRefRangeChange, unitId, subUnitId));
448
+ }
449
+ _watchPosition(unitId, subUnitId, link) {
450
+ const id = link.id, oldRange = {
451
+ startColumn: link.column,
452
+ endColumn: link.column,
453
+ startRow: link.row,
454
+ endRow: link.row
454
455
  };
455
456
  this._watchDisposableMap.set(
456
- r,
457
- this._refRangeService.watchRange(e, t, s, (a, o) => {
458
- const { redos: d } = this._handlePositionChange(e, t, n, o, !0);
459
- R(d, this._commandService, { onlyLocal: !0 });
457
+ id,
458
+ this._refRangeService.watchRange(unitId, subUnitId, oldRange, (before, after) => {
459
+ const { redos } = this._handlePositionChange(unitId, subUnitId, link, after, !0);
460
+ sequenceExecuteAsync(redos, this._commandService, { onlyLocal: !0 });
460
461
  }, !0)
461
462
  );
462
463
  }
463
- _unregisterPosition(e) {
464
- const t = this._disposableMap.get(e);
465
- t == null || t.dispose(), this._disposableMap.delete(e);
466
- }
467
- _unwatchPosition(e) {
468
- const t = this._watchDisposableMap.get(e);
469
- t == null || t.dispose(), this._watchDisposableMap.delete(e);
470
- }
471
- _registerRange(e, t, n, r = !1) {
472
- var s, a, o;
473
- if (n.startsWith("#")) {
474
- const d = new URLSearchParams(n.slice(1)), c = {
475
- gid: (s = d.get("gid")) != null ? s : "",
476
- range: (a = d.get("range")) != null ? a : "",
477
- rangeid: (o = d.get("rangeid")) != null ? o : ""
464
+ _unregisterPosition(id) {
465
+ const disposable = this._disposableMap.get(id);
466
+ disposable == null || disposable.dispose(), this._disposableMap.delete(id);
467
+ }
468
+ _unwatchPosition(id) {
469
+ const disposable = this._watchDisposableMap.get(id);
470
+ disposable == null || disposable.dispose(), this._watchDisposableMap.delete(id);
471
+ }
472
+ _registerRange(unitId, id, payload, silent = !1) {
473
+ var _a6, _b, _c;
474
+ if (payload.startsWith("#")) {
475
+ const search = new URLSearchParams(payload.slice(1)), searchObj = {
476
+ gid: (_a6 = search.get("gid")) != null ? _a6 : "",
477
+ range: (_b = search.get("range")) != null ? _b : "",
478
+ rangeid: (_c = search.get("rangeid")) != null ? _c : ""
478
479
  };
479
- if (c.range && c.gid) {
480
- const u = c.gid, l = ue(c.range).range;
481
- if (X(l) && c.range !== Se) {
482
- const h = (f) => {
483
- const p = I(l, f, { selectionManagerService: this._selectionManagerService });
484
- return p && v(p) === v(l) ? {
480
+ if (searchObj.range && searchObj.gid) {
481
+ const subUnitId = searchObj.gid, range = deserializeRangeWithSheet(searchObj.range).range;
482
+ if (isValidRange(range) && searchObj.range !== ERROR_RANGE) {
483
+ const handleRangeChange = /* @__PURE__ */ __name((commandInfo) => {
484
+ const resultRange = handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(range, commandInfo, { selectionManagerService: this._selectionManagerService });
485
+ return resultRange && serializeRange(resultRange) === serializeRange(range) ? {
485
486
  redos: [],
486
487
  undos: []
487
488
  } : {
488
489
  redos: [{
489
- id: x.id,
490
+ id: UpdateHyperLinkMutation$1.id,
490
491
  params: {
491
- unitId: e,
492
- subUnitId: u,
493
- id: t,
492
+ unitId,
493
+ subUnitId,
494
+ id,
494
495
  payload: {
495
- payload: `#gid=${u}&range=${p ? v(p) : "err"}`
496
+ payload: `#gid=${subUnitId}&range=${resultRange ? serializeRange(resultRange) : "err"}`
496
497
  }
497
498
  }
498
499
  }],
499
500
  undos: [{
500
- id: x.id,
501
+ id: UpdateHyperLinkMutation$1.id,
501
502
  params: {
502
- unitId: e,
503
- subUnitId: u,
504
- id: t,
503
+ unitId,
504
+ subUnitId,
505
+ id,
505
506
  payload: {
506
- payload: n
507
+ payload
507
508
  }
508
509
  }
509
510
  }]
510
511
  };
511
- };
512
- this._rangeDisableMap.set(t, this._refRangeService.registerRefRange(l, h, e, u)), r || this._rangeWatcherMap.set(t, this._refRangeService.watchRange(e, u, l, (f, p) => {
513
- this._hyperLinkModel.updateHyperLink(e, u, t, {
514
- payload: `#gid=${u}&range=${p ? v(p) : "err"}`
512
+ }, "handleRangeChange");
513
+ this._rangeDisableMap.set(id, this._refRangeService.registerRefRange(range, handleRangeChange, unitId, subUnitId)), silent || this._rangeWatcherMap.set(id, this._refRangeService.watchRange(unitId, subUnitId, range, (before, after) => {
514
+ this._hyperLinkModel.updateHyperLink(unitId, subUnitId, id, {
515
+ payload: `#gid=${subUnitId}&range=${after ? serializeRange(after) : "err"}`
515
516
  }, !0);
516
517
  }, !0));
517
518
  }
518
519
  }
519
520
  }
520
521
  }
521
- _unregisterRange(e) {
522
- const t = this._rangeDisableMap.get(e);
523
- t == null || t.dispose(), this._rangeDisableMap.delete(e);
522
+ _unregisterRange(id) {
523
+ const disposable = this._rangeDisableMap.get(id);
524
+ disposable == null || disposable.dispose(), this._rangeDisableMap.delete(id);
524
525
  }
525
- _unwatchRange(e) {
526
- const t = this._rangeWatcherMap.get(e);
527
- t == null || t.dispose(), this._rangeWatcherMap.delete(e);
526
+ _unwatchRange(id) {
527
+ const disposable = this._rangeWatcherMap.get(id);
528
+ disposable == null || disposable.dispose(), this._rangeWatcherMap.delete(id);
528
529
  }
529
530
  _initData() {
530
- this._hyperLinkModel.getAll().forEach((t) => {
531
- t.forEach((n) => {
532
- const { unitId: r, subUnitId: s, links: a } = n;
533
- a.forEach((o) => {
534
- this._registerPosition(r, s, o), this._watchPosition(r, s, o), this._registerRange(r, o.id, o.payload);
531
+ this._hyperLinkModel.getAll().forEach((unitData) => {
532
+ unitData.forEach((subUnitData) => {
533
+ const { unitId, subUnitId, links } = subUnitData;
534
+ links.forEach((link) => {
535
+ this._registerPosition(unitId, subUnitId, link), this._watchPosition(unitId, subUnitId, link), this._registerRange(unitId, link.id, link.payload);
535
536
  });
536
537
  });
537
538
  });
538
539
  }
539
540
  _initRefRange() {
540
541
  this.disposeWithMe(
541
- this._hyperLinkModel.linkUpdate$.subscribe((e) => {
542
- switch (e.type) {
542
+ this._hyperLinkModel.linkUpdate$.subscribe((option) => {
543
+ switch (option.type) {
543
544
  case "add": {
544
- this._registerPosition(e.unitId, e.subUnitId, e.payload), this._watchPosition(e.unitId, e.subUnitId, e.payload), this._registerRange(e.unitId, e.payload.id, e.payload.payload);
545
+ this._registerPosition(option.unitId, option.subUnitId, option.payload), this._watchPosition(option.unitId, option.subUnitId, option.payload), this._registerRange(option.unitId, option.payload.id, option.payload.payload);
545
546
  break;
546
547
  }
547
548
  case "remove": {
548
- this._unregisterPosition(e.payload.id), this._unwatchPosition(e.payload.id), this._unregisterRange(e.payload.id), this._unwatchRange(e.payload.id);
549
+ this._unregisterPosition(option.payload.id), this._unwatchPosition(option.payload.id), this._unregisterRange(option.payload.id), this._unwatchRange(option.payload.id);
549
550
  break;
550
551
  }
551
552
  case "updateRef": {
552
- const { unitId: t, subUnitId: n, id: r, silent: s } = e, a = this._hyperLinkModel.getHyperLink(t, n, r);
553
- if (!a)
553
+ const { unitId, subUnitId, id, silent } = option, link = this._hyperLinkModel.getHyperLink(unitId, subUnitId, id);
554
+ if (!link)
554
555
  return;
555
- this._unregisterPosition(r), this._registerPosition(t, n, a), s || (this._unwatchPosition(r), this._watchPosition(t, n, a));
556
+ this._unregisterPosition(id), this._registerPosition(unitId, subUnitId, link), silent || (this._unwatchPosition(id), this._watchPosition(unitId, subUnitId, link));
556
557
  break;
557
558
  }
558
559
  case "unload": {
559
- const { unitLinks: t } = e;
560
- t.forEach((n) => {
561
- const { links: r } = n;
562
- r.forEach((s) => {
563
- this._unregisterPosition(s.id), this._unwatchPosition(s.id), this._unregisterRange(s.id), this._unwatchRange(s.id);
560
+ const { unitLinks } = option;
561
+ unitLinks.forEach((subUnitData) => {
562
+ const { links } = subUnitData;
563
+ links.forEach((link) => {
564
+ this._unregisterPosition(link.id), this._unwatchPosition(link.id), this._unregisterRange(link.id), this._unwatchRange(link.id);
564
565
  });
565
566
  });
566
567
  break;
567
568
  }
568
569
  case "update": {
569
- e.silent || this._unwatchRange(e.id), this._unregisterRange(e.id), this._registerRange(e.unitId, e.id, e.payload.payload, e.silent);
570
+ option.silent || this._unwatchRange(option.id), this._unregisterRange(option.id), this._registerRange(option.unitId, option.id, option.payload.payload, option.silent);
570
571
  break;
571
572
  }
572
573
  }
573
574
  })
574
- ), this.disposeWithMe(ee(() => {
575
- this._disposableMap.forEach((e) => {
576
- e.dispose();
575
+ ), this.disposeWithMe(toDisposable(() => {
576
+ this._disposableMap.forEach((item) => {
577
+ item.dispose();
577
578
  }), this._disposableMap.clear();
578
579
  }));
579
580
  }
580
- };
581
- U = He([
582
- E(D.Starting, U),
583
- w(0, y(re)),
584
- w(1, y(oe)),
585
- w(2, y(ie)),
586
- w(3, M)
587
- ], U);
588
- var K = Object.defineProperty, be = Object.getOwnPropertyDescriptor, Oe = (i, e, t) => e in i ? K(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Ee = (i, e, t, n) => {
589
- for (var r = n > 1 ? void 0 : n ? be(e, t) : e, s = i.length - 1, a; s >= 0; s--)
590
- (a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
591
- return n && r && K(e, t, r), r;
592
- }, De = (i, e) => (t, n) => e(t, n, i), B = (i, e, t) => Oe(i, typeof e != "symbol" ? e + "" : e, t);
593
- let P = class extends ne {
594
- constructor(i, e) {
595
- super(), this._injector = e;
596
- }
597
- onStarting(i) {
581
+ }, __name(_a4, "SheetsHyperLinkRefRangeController"), _a4);
582
+ SheetsHyperLinkRefRangeController = __decorateClass$1([
583
+ OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkRefRangeController),
584
+ __decorateParam$1(0, Inject(RefRangeService)),
585
+ __decorateParam$1(1, Inject(HyperLinkModel$1)),
586
+ __decorateParam$1(2, Inject(SheetsSelectionsService)),
587
+ __decorateParam$1(3, ICommandService)
588
+ ], SheetsHyperLinkRefRangeController);
589
+ 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) => {
590
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
591
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
592
+ return kind && result && __defProp2(target, key, result), result;
593
+ }, "__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"), _a5;
594
+ let UniverSheetsHyperLinkPlugin = (_a5 = class extends Plugin {
595
+ constructor(config, _injector) {
596
+ super(), this._injector = _injector;
597
+ }
598
+ onStarting() {
598
599
  [
599
- [L],
600
- [S],
601
- [U],
602
- [g]
603
- ].forEach((e) => {
604
- i.add(e);
600
+ [SheetsHyperLinkResourceController],
601
+ [SheetsHyperLinkController],
602
+ [SheetsHyperLinkRefRangeController],
603
+ [HyperLinkModel]
604
+ ].forEach((dep) => {
605
+ this._injector.add(dep);
605
606
  });
606
607
  }
607
- };
608
- B(P, "pluginName", J);
609
- B(P, "type", A.UNIVER_SHEET);
610
- P = Ee([
611
- te(se),
612
- De(1, y(ae))
613
- ], P);
608
+ }, __name(_a5, "UniverSheetsHyperLinkPlugin"), _a5);
609
+ __publicField2(UniverSheetsHyperLinkPlugin, "pluginName", SHEET_HYPER_LINK_PLUGIN);
610
+ __publicField2(UniverSheetsHyperLinkPlugin, "type", UniverInstanceType.UNIVER_SHEET);
611
+ UniverSheetsHyperLinkPlugin = __decorateClass([
612
+ DependentOn(UniverSheetsPlugin),
613
+ __decorateParam(1, Inject(Injector))
614
+ ], UniverSheetsHyperLinkPlugin);
614
615
  export {
615
- j as AddHyperLinkCommand,
616
- H as AddHyperLinkMutation,
617
- me as CancelHyperLinkCommand,
618
- Se as ERROR_RANGE,
619
- g as HyperLinkModel,
620
- we as HyperLinkType,
621
- W as RemoveHyperLinkCommand,
622
- b as RemoveHyperLinkMutation,
623
- S as SheetsHyperLinkController,
624
- U as SheetsHyperLinkRefRangeController,
625
- P as UniverSheetsHyperLinkPlugin,
626
- T as UpdateHyperLinkCommand,
627
- O as UpdateHyperLinkMutation,
628
- _e as UpdateHyperLinkRefMutation
616
+ AddHyperLinkCommand,
617
+ AddHyperLinkMutation,
618
+ CancelHyperLinkCommand,
619
+ ERROR_RANGE,
620
+ HyperLinkModel,
621
+ HyperLinkType,
622
+ RemoveHyperLinkCommand,
623
+ RemoveHyperLinkMutation,
624
+ SheetsHyperLinkController,
625
+ SheetsHyperLinkRefRangeController,
626
+ UniverSheetsHyperLinkPlugin,
627
+ UpdateHyperLinkCommand,
628
+ UpdateHyperLinkMutation,
629
+ UpdateHyperLinkRefMutation
629
630
  };