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