@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/cjs/index.js +1 -1
- package/lib/es/index.js +443 -442
- package/lib/types/plugin.d.ts +2 -3
- package/lib/umd/index.js +1 -1
- package/package.json +12 -14
package/lib/es/index.js
CHANGED
|
@@ -1,629 +1,630 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { HyperLinkModel as
|
|
9
|
-
import { deserializeRangeWithSheet
|
|
10
|
-
var
|
|
11
|
-
for (var
|
|
12
|
-
(
|
|
13
|
-
return
|
|
14
|
-
},
|
|
15
|
-
let
|
|
16
|
-
constructor(
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this._univerInstanceService =
|
|
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(
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
return
|
|
37
|
-
matrix
|
|
38
|
-
positionMap:
|
|
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(
|
|
42
|
-
const { matrix
|
|
43
|
-
return
|
|
44
|
-
unitId
|
|
45
|
-
subUnitId
|
|
46
|
-
payload:
|
|
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(
|
|
51
|
-
const { matrix
|
|
52
|
-
if (!
|
|
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
|
|
55
|
-
return
|
|
56
|
-
unitId
|
|
57
|
-
subUnitId
|
|
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:
|
|
60
|
-
payload:
|
|
59
|
+
display: link.display,
|
|
60
|
+
payload: link.payload
|
|
61
61
|
},
|
|
62
|
-
id
|
|
62
|
+
id,
|
|
63
63
|
type: "update",
|
|
64
|
-
silent
|
|
64
|
+
silent
|
|
65
65
|
})), !0;
|
|
66
66
|
}
|
|
67
|
-
updateHyperLinkRef(
|
|
68
|
-
const { matrix
|
|
69
|
-
if (!
|
|
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
|
|
72
|
-
return !
|
|
73
|
-
unitId
|
|
74
|
-
subUnitId
|
|
75
|
-
payload
|
|
76
|
-
id
|
|
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
|
|
78
|
+
silent
|
|
79
79
|
}), !0;
|
|
80
80
|
}
|
|
81
|
-
removeHyperLink(
|
|
82
|
-
const { matrix
|
|
83
|
-
if (!
|
|
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
|
-
|
|
86
|
-
const
|
|
87
|
-
return
|
|
88
|
-
unitId
|
|
89
|
-
subUnitId
|
|
90
|
-
payload:
|
|
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(
|
|
95
|
-
const { matrix
|
|
96
|
-
if (
|
|
97
|
-
return
|
|
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(
|
|
100
|
-
const { matrix
|
|
101
|
-
return
|
|
99
|
+
getHyperLinkByLocation(unitId, subUnitId, row, column) {
|
|
100
|
+
const { matrix } = this._ensureMap(unitId, subUnitId);
|
|
101
|
+
return matrix.getValue(row, column);
|
|
102
102
|
}
|
|
103
|
-
getHyperLinkByLocationSync(
|
|
104
|
-
var
|
|
105
|
-
const { matrix
|
|
106
|
-
if (
|
|
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
|
-
...
|
|
109
|
-
display:
|
|
108
|
+
...link,
|
|
109
|
+
display: cellValueStr
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
getSubUnit(
|
|
113
|
-
const { matrix
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
}),
|
|
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(
|
|
119
|
-
const
|
|
120
|
-
return
|
|
121
|
-
const
|
|
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
|
|
124
|
-
subUnitId
|
|
125
|
-
links
|
|
123
|
+
unitId,
|
|
124
|
+
subUnitId,
|
|
125
|
+
links
|
|
126
126
|
};
|
|
127
127
|
}) : [];
|
|
128
128
|
}
|
|
129
|
-
deleteUnit(
|
|
130
|
-
const
|
|
131
|
-
this._linkMap.delete(
|
|
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
|
|
134
|
-
unitLinks:
|
|
133
|
+
unitId,
|
|
134
|
+
unitLinks: links
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
getAll() {
|
|
138
|
-
return Array.from(this._linkMap.keys()).map((
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
],
|
|
144
|
-
const
|
|
145
|
-
type:
|
|
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(
|
|
148
|
-
if (!
|
|
147
|
+
handler(accessor, params) {
|
|
148
|
+
if (!params)
|
|
149
149
|
return !1;
|
|
150
|
-
const
|
|
151
|
-
return
|
|
150
|
+
const model = accessor.get(HyperLinkModel), { unitId, subUnitId, link } = params;
|
|
151
|
+
return model.addHyperLink(unitId, subUnitId, link);
|
|
152
152
|
}
|
|
153
|
-
},
|
|
154
|
-
type:
|
|
153
|
+
}, UpdateHyperLinkMutation = {
|
|
154
|
+
type: CommandType.MUTATION,
|
|
155
155
|
id: "sheets.mutation.update-hyper-link",
|
|
156
|
-
handler(
|
|
157
|
-
if (!
|
|
156
|
+
handler(accessor, params) {
|
|
157
|
+
if (!params)
|
|
158
158
|
return !1;
|
|
159
|
-
const
|
|
160
|
-
return
|
|
159
|
+
const model = accessor.get(HyperLinkModel), { unitId, subUnitId, payload, id } = params;
|
|
160
|
+
return model.updateHyperLink(unitId, subUnitId, id, payload, !1);
|
|
161
161
|
}
|
|
162
|
-
},
|
|
163
|
-
type:
|
|
162
|
+
}, UpdateHyperLinkRefMutation = {
|
|
163
|
+
type: CommandType.MUTATION,
|
|
164
164
|
id: "sheets.mutation.update-hyper-link-ref",
|
|
165
|
-
handler(
|
|
166
|
-
if (!
|
|
165
|
+
handler(accessor, params) {
|
|
166
|
+
if (!params)
|
|
167
167
|
return !1;
|
|
168
|
-
const
|
|
169
|
-
return
|
|
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
|
-
},
|
|
172
|
-
type:
|
|
171
|
+
}, RemoveHyperLinkMutation = {
|
|
172
|
+
type: CommandType.MUTATION,
|
|
173
173
|
id: "sheets.mutation.remove-hyper-link",
|
|
174
|
-
handler(
|
|
175
|
-
if (!
|
|
174
|
+
handler(accessor, params) {
|
|
175
|
+
if (!params)
|
|
176
176
|
return !1;
|
|
177
|
-
const
|
|
178
|
-
return
|
|
177
|
+
const model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params;
|
|
178
|
+
return model.removeHyperLink(unitId, subUnitId, id);
|
|
179
179
|
}
|
|
180
|
-
},
|
|
181
|
-
type:
|
|
180
|
+
}, AddHyperLinkCommand = {
|
|
181
|
+
type: CommandType.COMMAND,
|
|
182
182
|
id: "sheets.command.add-hyper-link",
|
|
183
|
-
async handler(
|
|
184
|
-
if (!
|
|
183
|
+
async handler(accessor, params) {
|
|
184
|
+
if (!params)
|
|
185
185
|
return !1;
|
|
186
|
-
const
|
|
187
|
-
id:
|
|
188
|
-
params
|
|
189
|
-
}),
|
|
190
|
-
id:
|
|
191
|
-
params
|
|
192
|
-
},
|
|
193
|
-
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
|
|
196
|
-
subUnitId
|
|
197
|
-
id:
|
|
195
|
+
unitId,
|
|
196
|
+
subUnitId,
|
|
197
|
+
id: link.id
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
-
return (await
|
|
201
|
-
redoMutations: [
|
|
202
|
-
undoMutations: [
|
|
203
|
-
unitID:
|
|
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
|
|
208
|
-
const { row
|
|
209
|
-
return
|
|
207
|
+
function getHyperLinkContent(link) {
|
|
208
|
+
const { row, column, id, ...content } = link;
|
|
209
|
+
return content;
|
|
210
210
|
}
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
__name(getHyperLinkContent, "getHyperLinkContent");
|
|
212
|
+
const UpdateHyperLinkCommand = {
|
|
213
|
+
type: CommandType.COMMAND,
|
|
213
214
|
id: "sheets.command.update-hyper-link",
|
|
214
|
-
async handler(
|
|
215
|
-
if (!
|
|
215
|
+
async handler(accessor, params) {
|
|
216
|
+
if (!params)
|
|
216
217
|
return !1;
|
|
217
|
-
const
|
|
218
|
-
if (!
|
|
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
|
|
221
|
-
id:
|
|
222
|
-
params
|
|
223
|
-
}),
|
|
224
|
-
id:
|
|
225
|
-
params
|
|
226
|
-
},
|
|
227
|
-
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
|
|
230
|
-
subUnitId
|
|
231
|
-
id
|
|
232
|
-
payload:
|
|
230
|
+
unitId,
|
|
231
|
+
subUnitId,
|
|
232
|
+
id,
|
|
233
|
+
payload: getHyperLinkContent(link)
|
|
233
234
|
}
|
|
234
235
|
};
|
|
235
|
-
return (await
|
|
236
|
-
redoMutations: [
|
|
237
|
-
undoMutations: [
|
|
238
|
-
unitID:
|
|
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
|
-
},
|
|
242
|
-
type:
|
|
242
|
+
}, RemoveHyperLinkCommand = {
|
|
243
|
+
type: CommandType.COMMAND,
|
|
243
244
|
id: "sheets.command.remove-hyper-link",
|
|
244
|
-
async handler(
|
|
245
|
-
if (!
|
|
245
|
+
async handler(accessor, params) {
|
|
246
|
+
if (!params)
|
|
246
247
|
return !1;
|
|
247
|
-
const
|
|
248
|
-
id:
|
|
249
|
-
params
|
|
250
|
-
}),
|
|
251
|
-
id:
|
|
252
|
-
params
|
|
253
|
-
},
|
|
254
|
-
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
|
|
257
|
-
subUnitId
|
|
258
|
-
link
|
|
257
|
+
unitId,
|
|
258
|
+
subUnitId,
|
|
259
|
+
link
|
|
259
260
|
}
|
|
260
261
|
};
|
|
261
|
-
return (await
|
|
262
|
-
redoMutations: [
|
|
263
|
-
undoMutations: [
|
|
264
|
-
unitID:
|
|
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
|
-
},
|
|
268
|
-
type:
|
|
268
|
+
}, CancelHyperLinkCommand = {
|
|
269
|
+
type: CommandType.COMMAND,
|
|
269
270
|
id: "sheets.command.cancel-hyper-link",
|
|
270
|
-
async handler(
|
|
271
|
-
if (!
|
|
271
|
+
async handler(accessor, params) {
|
|
272
|
+
if (!params)
|
|
272
273
|
return !1;
|
|
273
|
-
const
|
|
274
|
-
id:
|
|
275
|
-
params
|
|
276
|
-
},
|
|
277
|
-
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
|
|
280
|
-
subUnitId
|
|
281
|
-
link
|
|
280
|
+
unitId,
|
|
281
|
+
subUnitId,
|
|
282
|
+
link
|
|
282
283
|
}
|
|
283
284
|
};
|
|
284
|
-
return (await
|
|
285
|
-
redoMutations: [
|
|
286
|
-
undoMutations: [
|
|
287
|
-
unitID:
|
|
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
|
|
292
|
-
for (var
|
|
293
|
-
(
|
|
294
|
-
return
|
|
295
|
-
},
|
|
296
|
-
let
|
|
297
|
-
constructor(
|
|
298
|
-
super(), this._commandService =
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
].forEach((
|
|
311
|
-
this._commandService.registerCommand(
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
],
|
|
319
|
-
var
|
|
320
|
-
const
|
|
321
|
-
var
|
|
322
|
-
for (var
|
|
323
|
-
(
|
|
324
|
-
return
|
|
325
|
-
},
|
|
326
|
-
let
|
|
327
|
-
constructor(
|
|
328
|
-
super(), this._resourceManagerService =
|
|
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
|
|
332
|
-
const
|
|
333
|
-
return
|
|
334
|
-
|
|
335
|
-
}), JSON.stringify(
|
|
336
|
-
},
|
|
337
|
-
if (!
|
|
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(
|
|
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:
|
|
348
|
-
businesses: [
|
|
349
|
-
toJson: (
|
|
350
|
-
parseJson: (
|
|
351
|
-
onUnLoad: (
|
|
352
|
-
this._hyperLinkModel.deleteUnit(
|
|
353
|
-
},
|
|
354
|
-
onLoad: async (
|
|
355
|
-
Object.keys(
|
|
356
|
-
|
|
357
|
-
this._hyperLinkModel.addHyperLink(
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
],
|
|
370
|
-
var
|
|
371
|
-
for (var
|
|
372
|
-
(
|
|
373
|
-
return
|
|
374
|
-
},
|
|
375
|
-
let
|
|
376
|
-
constructor(
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
startColumn:
|
|
385
|
-
endColumn:
|
|
386
|
-
startRow:
|
|
387
|
-
endRow:
|
|
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
|
|
390
|
+
return resultRange ? {
|
|
390
391
|
redos: [{
|
|
391
|
-
id:
|
|
392
|
+
id: UpdateHyperLinkRefMutation$1.id,
|
|
392
393
|
params: {
|
|
393
|
-
unitId
|
|
394
|
-
subUnitId
|
|
395
|
-
id:
|
|
396
|
-
row:
|
|
397
|
-
column:
|
|
398
|
-
silent
|
|
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:
|
|
403
|
+
id: UpdateHyperLinkRefMutation$1.id,
|
|
403
404
|
params: {
|
|
404
|
-
unitId
|
|
405
|
-
subUnitId
|
|
406
|
-
id:
|
|
407
|
-
row:
|
|
408
|
-
column:
|
|
409
|
-
silent
|
|
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:
|
|
415
|
+
id: RemoveHyperLinkMutation$1.id,
|
|
415
416
|
params: {
|
|
416
|
-
unitId
|
|
417
|
-
subUnitId
|
|
418
|
-
id:
|
|
417
|
+
unitId,
|
|
418
|
+
subUnitId,
|
|
419
|
+
id: link.id
|
|
419
420
|
}
|
|
420
421
|
}],
|
|
421
422
|
undos: [{
|
|
422
|
-
id:
|
|
423
|
+
id: AddHyperLinkMutation$1.id,
|
|
423
424
|
params: {
|
|
424
|
-
unitId
|
|
425
|
-
subUnitId
|
|
426
|
-
link
|
|
425
|
+
unitId,
|
|
426
|
+
subUnitId,
|
|
427
|
+
link
|
|
427
428
|
}
|
|
428
429
|
}]
|
|
429
430
|
};
|
|
430
|
-
});
|
|
431
|
-
this._refRangeService =
|
|
432
|
-
}
|
|
433
|
-
_registerPosition(
|
|
434
|
-
const
|
|
435
|
-
startColumn:
|
|
436
|
-
endColumn:
|
|
437
|
-
startRow:
|
|
438
|
-
endRow:
|
|
439
|
-
},
|
|
440
|
-
const
|
|
441
|
-
return
|
|
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(
|
|
445
|
-
};
|
|
446
|
-
this._disposableMap.set(
|
|
447
|
-
}
|
|
448
|
-
_watchPosition(
|
|
449
|
-
const
|
|
450
|
-
startColumn:
|
|
451
|
-
endColumn:
|
|
452
|
-
startRow:
|
|
453
|
-
endRow:
|
|
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
|
-
|
|
457
|
-
this._refRangeService.watchRange(
|
|
458
|
-
const { redos
|
|
459
|
-
|
|
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(
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
_unwatchPosition(
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
_registerRange(
|
|
472
|
-
var
|
|
473
|
-
if (
|
|
474
|
-
const
|
|
475
|
-
gid: (
|
|
476
|
-
range: (
|
|
477
|
-
rangeid: (
|
|
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 (
|
|
480
|
-
const
|
|
481
|
-
if (
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
return
|
|
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:
|
|
490
|
+
id: UpdateHyperLinkMutation$1.id,
|
|
490
491
|
params: {
|
|
491
|
-
unitId
|
|
492
|
-
subUnitId
|
|
493
|
-
id
|
|
492
|
+
unitId,
|
|
493
|
+
subUnitId,
|
|
494
|
+
id,
|
|
494
495
|
payload: {
|
|
495
|
-
payload: `#gid=${
|
|
496
|
+
payload: `#gid=${subUnitId}&range=${resultRange ? serializeRange(resultRange) : "err"}`
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
}],
|
|
499
500
|
undos: [{
|
|
500
|
-
id:
|
|
501
|
+
id: UpdateHyperLinkMutation$1.id,
|
|
501
502
|
params: {
|
|
502
|
-
unitId
|
|
503
|
-
subUnitId
|
|
504
|
-
id
|
|
503
|
+
unitId,
|
|
504
|
+
subUnitId,
|
|
505
|
+
id,
|
|
505
506
|
payload: {
|
|
506
|
-
payload
|
|
507
|
+
payload
|
|
507
508
|
}
|
|
508
509
|
}
|
|
509
510
|
}]
|
|
510
511
|
};
|
|
511
|
-
};
|
|
512
|
-
this._rangeDisableMap.set(
|
|
513
|
-
this._hyperLinkModel.updateHyperLink(
|
|
514
|
-
payload: `#gid=${
|
|
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(
|
|
522
|
-
const
|
|
523
|
-
|
|
522
|
+
_unregisterRange(id) {
|
|
523
|
+
const disposable = this._rangeDisableMap.get(id);
|
|
524
|
+
disposable == null || disposable.dispose(), this._rangeDisableMap.delete(id);
|
|
524
525
|
}
|
|
525
|
-
_unwatchRange(
|
|
526
|
-
const
|
|
527
|
-
|
|
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((
|
|
531
|
-
|
|
532
|
-
const { unitId
|
|
533
|
-
|
|
534
|
-
this._registerPosition(
|
|
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((
|
|
542
|
-
switch (
|
|
542
|
+
this._hyperLinkModel.linkUpdate$.subscribe((option) => {
|
|
543
|
+
switch (option.type) {
|
|
543
544
|
case "add": {
|
|
544
|
-
this._registerPosition(
|
|
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(
|
|
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
|
|
553
|
-
if (!
|
|
553
|
+
const { unitId, subUnitId, id, silent } = option, link = this._hyperLinkModel.getHyperLink(unitId, subUnitId, id);
|
|
554
|
+
if (!link)
|
|
554
555
|
return;
|
|
555
|
-
this._unregisterPosition(
|
|
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
|
|
560
|
-
|
|
561
|
-
const { links
|
|
562
|
-
|
|
563
|
-
this._unregisterPosition(
|
|
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
|
-
|
|
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(
|
|
575
|
-
this._disposableMap.forEach((
|
|
576
|
-
|
|
575
|
+
), this.disposeWithMe(toDisposable(() => {
|
|
576
|
+
this._disposableMap.forEach((item) => {
|
|
577
|
+
item.dispose();
|
|
577
578
|
}), this._disposableMap.clear();
|
|
578
579
|
}));
|
|
579
580
|
}
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
],
|
|
588
|
-
var
|
|
589
|
-
for (var
|
|
590
|
-
(
|
|
591
|
-
return
|
|
592
|
-
},
|
|
593
|
-
let
|
|
594
|
-
constructor(
|
|
595
|
-
super(), this._injector =
|
|
596
|
-
}
|
|
597
|
-
onStarting(
|
|
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
|
-
[
|
|
600
|
-
[
|
|
601
|
-
[
|
|
602
|
-
[
|
|
603
|
-
].forEach((
|
|
604
|
-
|
|
600
|
+
[SheetsHyperLinkResourceController],
|
|
601
|
+
[SheetsHyperLinkController],
|
|
602
|
+
[SheetsHyperLinkRefRangeController],
|
|
603
|
+
[HyperLinkModel]
|
|
604
|
+
].forEach((dep) => {
|
|
605
|
+
this._injector.add(dep);
|
|
605
606
|
});
|
|
606
607
|
}
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
],
|
|
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
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
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
|
};
|