@univerjs/sheets-hyper-link 0.4.2 → 0.5.0-beta.0
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/facade.js +1 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +101 -0
- package/lib/es/index.js +1056 -354
- package/lib/types/commands/commands/add-hyper-link.command.d.ts +19 -0
- package/lib/types/commands/commands/remove-hyper-link.command.d.ts +19 -0
- package/lib/types/commands/commands/update-hyper-link.command.d.ts +17 -0
- package/lib/types/controllers/remove-sheet.controller.d.ts +10 -0
- package/lib/types/controllers/rich-text-ref-range.controller.d.ts +15 -0
- package/lib/types/controllers/set-range.controller.d.ts +14 -0
- package/lib/types/facade/f-range.d.ts +50 -0
- package/lib/types/facade/f-workbook.d.ts +32 -0
- package/lib/types/facade/index.d.ts +18 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/services/parser.service.d.ts +24 -0
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +24 -13
package/lib/es/index.js
CHANGED
|
@@ -1,507 +1,1209 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
var
|
|
10
|
-
for (var
|
|
11
|
-
(
|
|
12
|
-
return
|
|
13
|
-
},
|
|
14
|
-
let
|
|
15
|
-
constructor(
|
|
1
|
+
var xe = Object.defineProperty;
|
|
2
|
+
var Te = (s, e, t) => e in s ? xe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var C = (s, e, t) => Te(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Disposable as V, ObjectMatrix as J, UniverInstanceType as R, IUniverInstanceService as E, CommandType as L, Inject as I, ICommandService as b, sequenceExecuteAsync as ye, isValidRange as ve, toDisposable as Ae, CustomRangeType as N, DisposableCollection as We, Range as Be, Tools as ie, BuildTextUtils as X, generateRandomId as ae, TextX as oe, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as je, IUndoRedoService as Se, CellValueType as Re, sequenceExecute as Fe, getBodySlice as be, IResourceManagerService as Ke, LocaleService as Ge, DependentOn as Ye, Injector as ze, Plugin as Je, registerDependencies as Xe, touchDependencies as qe, IConfigService as Ze } from "@univerjs/core";
|
|
5
|
+
import { Subject as Qe } from "rxjs";
|
|
6
|
+
import { RefRangeService as Pe, SheetsSelectionsService as Ne, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as et, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests as tt, SheetInterceptorService as de, RemoveSheetCommand as nt, SetRangeValuesMutation as H, SetRangeValuesCommand as rt, ClearSelectionContentCommand as st, ClearSelectionAllCommand as it, ClearSelectionFormatCommand as at, getSheetCommandTarget as ce, AFTER_CELL_EDIT as ot, SetRangeValuesUndoMutationFactory as Ie, UniverSheetsPlugin as dt } from "@univerjs/sheets";
|
|
7
|
+
import { deserializeRangeWithSheet as Me, serializeRange as B, serializeRangeWithSheet as ct, IDefinedNamesService as lt } from "@univerjs/engine-formula";
|
|
8
|
+
import { addCustomRangeBySelectionFactory as ut, deleteCustomRangeFactory as pt, replaceSelectionFactory as Oe } from "@univerjs/docs";
|
|
9
|
+
var ht = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, ft = (s, e, t, n) => {
|
|
10
|
+
for (var r = n > 1 ? void 0 : n ? gt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
11
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
12
|
+
return n && r && ht(e, t, r), r;
|
|
13
|
+
}, _t = (s, e) => (t, n) => e(t, n, s);
|
|
14
|
+
let v = class extends V {
|
|
15
|
+
constructor(e) {
|
|
16
16
|
super();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this._univerInstanceService =
|
|
22
|
-
dispose:
|
|
17
|
+
C(this, "_linkUpdate$", new Qe());
|
|
18
|
+
C(this, "linkUpdate$", this._linkUpdate$.asObservable());
|
|
19
|
+
C(this, "_linkMap", /* @__PURE__ */ new Map());
|
|
20
|
+
C(this, "_linkPositionMap", /* @__PURE__ */ new Map());
|
|
21
|
+
this._univerInstanceService = e, this.disposeWithMe({
|
|
22
|
+
dispose: () => {
|
|
23
23
|
this._linkUpdate$.complete();
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
_ensureMap(
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
return
|
|
36
|
-
matrix,
|
|
37
|
-
positionMap:
|
|
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 J(), n.set(t, r));
|
|
32
|
+
let i = this._linkPositionMap.get(e);
|
|
33
|
+
i || (i = /* @__PURE__ */ new Map(), this._linkPositionMap.set(e, i));
|
|
34
|
+
let a = i.get(t);
|
|
35
|
+
return a || (a = /* @__PURE__ */ new Map(), i.set(t, a)), {
|
|
36
|
+
matrix: r,
|
|
37
|
+
positionMap: a
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
addHyperLink(
|
|
41
|
-
const { matrix, positionMap } = this._ensureMap(
|
|
42
|
-
return
|
|
43
|
-
unitId,
|
|
44
|
-
subUnitId,
|
|
45
|
-
payload:
|
|
40
|
+
addHyperLink(e, t, n) {
|
|
41
|
+
const { matrix: r, positionMap: i } = this._ensureMap(e, t);
|
|
42
|
+
return r.setValue(n.row, n.column, n), i.set(n.id, { row: n.row, column: n.column, link: n }), this._linkUpdate$.next({
|
|
43
|
+
unitId: e,
|
|
44
|
+
subUnitId: t,
|
|
45
|
+
payload: n,
|
|
46
46
|
type: "add"
|
|
47
47
|
}), !0;
|
|
48
48
|
}
|
|
49
|
-
updateHyperLink(
|
|
50
|
-
const { matrix, positionMap } = this._ensureMap(
|
|
51
|
-
if (!
|
|
49
|
+
updateHyperLink(e, t, n, r, i = !1) {
|
|
50
|
+
const { matrix: a, positionMap: o } = this._ensureMap(e, t), c = o.get(n);
|
|
51
|
+
if (!c)
|
|
52
52
|
return !0;
|
|
53
|
-
const
|
|
54
|
-
return
|
|
55
|
-
unitId,
|
|
56
|
-
subUnitId,
|
|
53
|
+
const d = a.getValue(c.row, c.column);
|
|
54
|
+
return d && (Object.assign(d, r), this._linkUpdate$.next({
|
|
55
|
+
unitId: e,
|
|
56
|
+
subUnitId: t,
|
|
57
57
|
payload: {
|
|
58
|
-
display:
|
|
59
|
-
payload:
|
|
58
|
+
display: d.display,
|
|
59
|
+
payload: d.payload
|
|
60
60
|
},
|
|
61
|
-
id,
|
|
61
|
+
id: n,
|
|
62
62
|
type: "update",
|
|
63
|
-
silent
|
|
63
|
+
silent: i
|
|
64
64
|
})), !0;
|
|
65
65
|
}
|
|
66
|
-
updateHyperLinkRef(
|
|
67
|
-
const { matrix, positionMap } = this._ensureMap(
|
|
68
|
-
if (!
|
|
66
|
+
updateHyperLinkRef(e, t, n, r, i = !1) {
|
|
67
|
+
const { matrix: a, positionMap: o } = this._ensureMap(e, t), c = o.get(n);
|
|
68
|
+
if (!c)
|
|
69
69
|
return !0;
|
|
70
|
-
let
|
|
71
|
-
return !
|
|
72
|
-
unitId,
|
|
73
|
-
subUnitId,
|
|
74
|
-
payload,
|
|
75
|
-
id,
|
|
70
|
+
let d = a.getValue(c.row, c.column);
|
|
71
|
+
return !d || d.id !== n ? d = c.link : a.realDeleteValue(c.row, c.column), Object.assign(d, r), o.set(n, { ...r, link: d }), a.setValue(r.row, r.column, d), this._linkUpdate$.next({
|
|
72
|
+
unitId: e,
|
|
73
|
+
subUnitId: t,
|
|
74
|
+
payload: r,
|
|
75
|
+
id: n,
|
|
76
76
|
type: "updateRef",
|
|
77
|
-
silent
|
|
77
|
+
silent: i
|
|
78
78
|
}), !0;
|
|
79
79
|
}
|
|
80
|
-
removeHyperLink(
|
|
81
|
-
const { matrix, positionMap } = this._ensureMap(
|
|
82
|
-
if (!
|
|
80
|
+
removeHyperLink(e, t, n) {
|
|
81
|
+
const { matrix: r, positionMap: i } = this._ensureMap(e, t), a = i.get(n);
|
|
82
|
+
if (!a)
|
|
83
83
|
return !1;
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
return
|
|
87
|
-
unitId,
|
|
88
|
-
subUnitId,
|
|
89
|
-
payload:
|
|
84
|
+
i.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,
|
|
90
90
|
type: "remove"
|
|
91
91
|
}), !0;
|
|
92
92
|
}
|
|
93
|
-
getHyperLink(
|
|
94
|
-
const { matrix, positionMap } = this._ensureMap(
|
|
95
|
-
if (
|
|
96
|
-
return
|
|
93
|
+
getHyperLink(e, t, n) {
|
|
94
|
+
const { matrix: r, positionMap: i } = this._ensureMap(e, t), a = i.get(n);
|
|
95
|
+
if (a)
|
|
96
|
+
return r.getValue(a.row, a.column);
|
|
97
97
|
}
|
|
98
|
-
getHyperLinkByLocation(
|
|
99
|
-
const { matrix } = this._ensureMap(
|
|
100
|
-
return
|
|
98
|
+
getHyperLinkByLocation(e, t, n, r) {
|
|
99
|
+
const { matrix: i } = this._ensureMap(e, t);
|
|
100
|
+
return i.getValue(n, r);
|
|
101
101
|
}
|
|
102
|
-
getHyperLinkByLocationSync(
|
|
103
|
-
var
|
|
104
|
-
const { matrix } = this._ensureMap(
|
|
105
|
-
if (
|
|
102
|
+
getHyperLinkByLocationSync(e, t, n, r) {
|
|
103
|
+
var l, p, h, g, u;
|
|
104
|
+
const { matrix: i } = this._ensureMap(e, t), a = this._univerInstanceService.getUnit(e, R.UNIVER_SHEET), o = (l = a == null ? void 0 : a.getSheetBySheetId(t)) == null ? void 0 : l.getCellRaw(n, r), c = ((u = (g = o == null ? void 0 : o.v) != null ? g : (h = (p = o == null ? void 0 : o.p) == null ? void 0 : p.body) == null ? void 0 : h.dataStream.slice(0, -2)) != null ? u : "").toString(), d = i.getValue(n, r);
|
|
105
|
+
if (d)
|
|
106
106
|
return {
|
|
107
|
-
...
|
|
108
|
-
display:
|
|
107
|
+
...d,
|
|
108
|
+
display: c
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
getSubUnit(
|
|
112
|
-
const { matrix } = this._ensureMap(
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
}),
|
|
111
|
+
getSubUnit(e, t) {
|
|
112
|
+
const { matrix: n } = this._ensureMap(e, t), r = [];
|
|
113
|
+
return n.forValue((i, a, o) => {
|
|
114
|
+
o && r.push(o);
|
|
115
|
+
}), r;
|
|
116
116
|
}
|
|
117
|
-
getUnit(
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
const
|
|
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);
|
|
121
121
|
return {
|
|
122
|
-
unitId,
|
|
123
|
-
subUnitId,
|
|
124
|
-
links
|
|
122
|
+
unitId: e,
|
|
123
|
+
subUnitId: n,
|
|
124
|
+
links: r
|
|
125
125
|
};
|
|
126
126
|
}) : [];
|
|
127
127
|
}
|
|
128
|
-
deleteUnit(
|
|
129
|
-
const
|
|
130
|
-
this._linkMap.delete(
|
|
128
|
+
deleteUnit(e) {
|
|
129
|
+
const t = this.getUnit(e);
|
|
130
|
+
this._linkMap.delete(e), this._linkPositionMap.delete(e), this._linkUpdate$.next({
|
|
131
131
|
type: "unload",
|
|
132
|
-
unitId,
|
|
133
|
-
unitLinks:
|
|
132
|
+
unitId: e,
|
|
133
|
+
unitLinks: t
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
getAll() {
|
|
137
|
-
return Array.from(this._linkMap.keys()).map((
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
],
|
|
143
|
-
var
|
|
144
|
-
const
|
|
145
|
-
type:
|
|
137
|
+
return Array.from(this._linkMap.keys()).map((t) => this.getUnit(t));
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
v = ft([
|
|
141
|
+
_t(0, E)
|
|
142
|
+
], v);
|
|
143
|
+
var U = /* @__PURE__ */ ((s) => (s.SHEET = "gid", s.RANGE = "range", s.DEFINE_NAME = "rangeid", s.INVALID = "invalid", s.URL = "url", s))(U || {});
|
|
144
|
+
const mt = "sheets-hyper-link.config", yt = {}, O = {
|
|
145
|
+
type: L.MUTATION,
|
|
146
146
|
id: "sheets.mutation.add-hyper-link",
|
|
147
|
-
handler(
|
|
148
|
-
if (!
|
|
147
|
+
handler(s, e) {
|
|
148
|
+
if (!e)
|
|
149
149
|
return !1;
|
|
150
|
-
const
|
|
151
|
-
return
|
|
150
|
+
const t = s.get(v), { unitId: n, subUnitId: r, link: i } = e;
|
|
151
|
+
return t.addHyperLink(n, r, i);
|
|
152
152
|
}
|
|
153
|
-
},
|
|
154
|
-
type:
|
|
153
|
+
}, k = {
|
|
154
|
+
type: L.MUTATION,
|
|
155
155
|
id: "sheets.mutation.remove-hyper-link",
|
|
156
|
-
handler(
|
|
157
|
-
if (!
|
|
156
|
+
handler(s, e) {
|
|
157
|
+
if (!e)
|
|
158
158
|
return !1;
|
|
159
|
-
const
|
|
160
|
-
return
|
|
159
|
+
const t = s.get(v), { unitId: n, subUnitId: r, id: i } = e;
|
|
160
|
+
return t.removeHyperLink(n, r, i);
|
|
161
161
|
}
|
|
162
|
-
},
|
|
163
|
-
type:
|
|
162
|
+
}, fe = {
|
|
163
|
+
type: L.MUTATION,
|
|
164
164
|
id: "sheets.mutation.update-hyper-link",
|
|
165
|
-
handler(
|
|
166
|
-
if (!
|
|
165
|
+
handler(s, e) {
|
|
166
|
+
if (!e)
|
|
167
167
|
return !1;
|
|
168
|
-
const
|
|
169
|
-
return
|
|
168
|
+
const t = s.get(v), { unitId: n, subUnitId: r, payload: i, id: a } = e;
|
|
169
|
+
return t.updateHyperLink(n, r, a, i, !1);
|
|
170
170
|
}
|
|
171
|
-
},
|
|
172
|
-
type:
|
|
171
|
+
}, _e = {
|
|
172
|
+
type: L.MUTATION,
|
|
173
173
|
id: "sheets.mutation.update-hyper-link-ref",
|
|
174
|
-
handler(
|
|
175
|
-
if (!
|
|
174
|
+
handler(s, e) {
|
|
175
|
+
if (!e)
|
|
176
176
|
return !1;
|
|
177
|
-
const
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
var
|
|
182
|
-
for (var
|
|
183
|
-
(
|
|
184
|
-
return
|
|
185
|
-
},
|
|
186
|
-
let
|
|
187
|
-
constructor(
|
|
177
|
+
const t = s.get(v), { unitId: n, subUnitId: r, id: i, row: a, column: o, silent: c } = e;
|
|
178
|
+
return t.updateHyperLinkRef(n, r, i, { row: a, column: o }, c);
|
|
179
|
+
}
|
|
180
|
+
}, ke = "SHEET_HYPER_LINK_PLUGIN", q = "err";
|
|
181
|
+
var vt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, Rt = (s, e, t, n) => {
|
|
182
|
+
for (var r = n > 1 ? void 0 : n ? St(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
183
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
184
|
+
return n && r && vt(e, t, r), r;
|
|
185
|
+
}, Y = (s, e) => (t, n) => e(t, n, s);
|
|
186
|
+
let Z = class extends V {
|
|
187
|
+
constructor(e, t, n, r) {
|
|
188
188
|
super();
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
startColumn:
|
|
196
|
-
endColumn:
|
|
197
|
-
startRow:
|
|
198
|
-
endRow:
|
|
189
|
+
C(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
190
|
+
C(this, "_watchDisposableMap", /* @__PURE__ */ new Map());
|
|
191
|
+
C(this, "_rangeDisableMap", /* @__PURE__ */ new Map());
|
|
192
|
+
C(this, "_rangeWatcherMap", /* @__PURE__ */ new Map());
|
|
193
|
+
C(this, "_handlePositionChange", (e, t, n, r, i) => {
|
|
194
|
+
const a = {
|
|
195
|
+
startColumn: n.column,
|
|
196
|
+
endColumn: n.column,
|
|
197
|
+
startRow: n.row,
|
|
198
|
+
endRow: n.row
|
|
199
199
|
};
|
|
200
|
-
return
|
|
200
|
+
return r ? {
|
|
201
201
|
redos: [{
|
|
202
|
-
id:
|
|
202
|
+
id: _e.id,
|
|
203
203
|
params: {
|
|
204
|
-
unitId,
|
|
205
|
-
subUnitId,
|
|
206
|
-
id:
|
|
207
|
-
row:
|
|
208
|
-
column:
|
|
209
|
-
silent
|
|
204
|
+
unitId: e,
|
|
205
|
+
subUnitId: t,
|
|
206
|
+
id: n.id,
|
|
207
|
+
row: r.startRow,
|
|
208
|
+
column: r.startColumn,
|
|
209
|
+
silent: i
|
|
210
210
|
}
|
|
211
211
|
}],
|
|
212
212
|
undos: [{
|
|
213
|
-
id:
|
|
213
|
+
id: _e.id,
|
|
214
214
|
params: {
|
|
215
|
-
unitId,
|
|
216
|
-
subUnitId,
|
|
217
|
-
id:
|
|
218
|
-
row:
|
|
219
|
-
column:
|
|
220
|
-
silent
|
|
215
|
+
unitId: e,
|
|
216
|
+
subUnitId: t,
|
|
217
|
+
id: n.id,
|
|
218
|
+
row: a.startRow,
|
|
219
|
+
column: a.startColumn,
|
|
220
|
+
silent: i
|
|
221
221
|
}
|
|
222
222
|
}]
|
|
223
223
|
} : {
|
|
224
224
|
redos: [{
|
|
225
|
-
id:
|
|
225
|
+
id: k.id,
|
|
226
226
|
params: {
|
|
227
|
-
unitId,
|
|
228
|
-
subUnitId,
|
|
229
|
-
id:
|
|
227
|
+
unitId: e,
|
|
228
|
+
subUnitId: t,
|
|
229
|
+
id: n.id
|
|
230
230
|
}
|
|
231
231
|
}],
|
|
232
232
|
undos: [{
|
|
233
|
-
id:
|
|
233
|
+
id: O.id,
|
|
234
234
|
params: {
|
|
235
|
-
unitId,
|
|
236
|
-
subUnitId,
|
|
237
|
-
link
|
|
235
|
+
unitId: e,
|
|
236
|
+
subUnitId: t,
|
|
237
|
+
link: n
|
|
238
238
|
}
|
|
239
239
|
}]
|
|
240
240
|
};
|
|
241
|
-
}
|
|
242
|
-
this._refRangeService =
|
|
243
|
-
}
|
|
244
|
-
_registerPosition(
|
|
245
|
-
const
|
|
246
|
-
startColumn:
|
|
247
|
-
endColumn:
|
|
248
|
-
startRow:
|
|
249
|
-
endRow:
|
|
250
|
-
},
|
|
251
|
-
const
|
|
252
|
-
return
|
|
241
|
+
});
|
|
242
|
+
this._refRangeService = e, this._hyperLinkModel = t, this._selectionManagerService = n, this._commandService = r, this._initData(), this._initRefRange();
|
|
243
|
+
}
|
|
244
|
+
_registerPosition(e, t, n) {
|
|
245
|
+
const r = n.id, i = {
|
|
246
|
+
startColumn: n.column,
|
|
247
|
+
endColumn: n.column,
|
|
248
|
+
startRow: n.row,
|
|
249
|
+
endRow: n.row
|
|
250
|
+
}, a = (o) => {
|
|
251
|
+
const c = et(i, o, { selectionManagerService: this._selectionManagerService }), d = Array.isArray(c) ? c[0] : c;
|
|
252
|
+
return d && d.startColumn === i.startColumn && d.startRow === i.startRow ? {
|
|
253
253
|
undos: [],
|
|
254
254
|
redos: []
|
|
255
|
-
} : this._handlePositionChange(
|
|
256
|
-
}
|
|
257
|
-
this._disposableMap.set(
|
|
258
|
-
}
|
|
259
|
-
_watchPosition(
|
|
260
|
-
const
|
|
261
|
-
startColumn:
|
|
262
|
-
endColumn:
|
|
263
|
-
startRow:
|
|
264
|
-
endRow:
|
|
255
|
+
} : this._handlePositionChange(e, t, n, d, !1);
|
|
256
|
+
};
|
|
257
|
+
this._disposableMap.set(r, this._refRangeService.registerRefRange(i, a, e, t));
|
|
258
|
+
}
|
|
259
|
+
_watchPosition(e, t, n) {
|
|
260
|
+
const r = n.id, i = {
|
|
261
|
+
startColumn: n.column,
|
|
262
|
+
endColumn: n.column,
|
|
263
|
+
startRow: n.row,
|
|
264
|
+
endRow: n.row
|
|
265
265
|
};
|
|
266
266
|
this._watchDisposableMap.set(
|
|
267
|
-
|
|
268
|
-
this._refRangeService.watchRange(
|
|
269
|
-
const { redos } = this._handlePositionChange(
|
|
270
|
-
|
|
267
|
+
r,
|
|
268
|
+
this._refRangeService.watchRange(e, t, i, (a, o) => {
|
|
269
|
+
const { redos: c } = this._handlePositionChange(e, t, n, o, !0);
|
|
270
|
+
ye(c, this._commandService, { onlyLocal: !0 });
|
|
271
271
|
}, !0)
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
|
-
_unregisterPosition(
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
_unwatchPosition(
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
_registerRange(
|
|
283
|
-
var
|
|
284
|
-
if (
|
|
285
|
-
const
|
|
286
|
-
gid: (
|
|
287
|
-
range: (
|
|
288
|
-
rangeid: (
|
|
274
|
+
_unregisterPosition(e) {
|
|
275
|
+
const t = this._disposableMap.get(e);
|
|
276
|
+
t == null || t.dispose(), this._disposableMap.delete(e);
|
|
277
|
+
}
|
|
278
|
+
_unwatchPosition(e) {
|
|
279
|
+
const t = this._watchDisposableMap.get(e);
|
|
280
|
+
t == null || t.dispose(), this._watchDisposableMap.delete(e);
|
|
281
|
+
}
|
|
282
|
+
_registerRange(e, t, n, r = !1) {
|
|
283
|
+
var i, a, o;
|
|
284
|
+
if (n.startsWith("#")) {
|
|
285
|
+
const c = new URLSearchParams(n.slice(1)), d = {
|
|
286
|
+
gid: (i = c.get("gid")) != null ? i : "",
|
|
287
|
+
range: (a = c.get("range")) != null ? a : "",
|
|
288
|
+
rangeid: (o = c.get("rangeid")) != null ? o : ""
|
|
289
289
|
};
|
|
290
|
-
if (
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
294
|
-
const
|
|
295
|
-
return
|
|
290
|
+
if (d.range && d.gid) {
|
|
291
|
+
const l = d.gid, p = Me(d.range).range;
|
|
292
|
+
if (ve(p) && d.range !== q) {
|
|
293
|
+
const h = (g) => {
|
|
294
|
+
const u = tt(p, g, { selectionManagerService: this._selectionManagerService });
|
|
295
|
+
return u && B(u) === B(p) ? {
|
|
296
296
|
redos: [],
|
|
297
297
|
undos: []
|
|
298
298
|
} : {
|
|
299
299
|
redos: [{
|
|
300
|
-
id:
|
|
300
|
+
id: fe.id,
|
|
301
301
|
params: {
|
|
302
|
-
unitId,
|
|
303
|
-
subUnitId,
|
|
304
|
-
id,
|
|
302
|
+
unitId: e,
|
|
303
|
+
subUnitId: l,
|
|
304
|
+
id: t,
|
|
305
305
|
payload: {
|
|
306
|
-
payload: `#gid=${
|
|
306
|
+
payload: `#gid=${l}&range=${u ? B(u) : "err"}`
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
}],
|
|
310
310
|
undos: [{
|
|
311
|
-
id:
|
|
311
|
+
id: fe.id,
|
|
312
312
|
params: {
|
|
313
|
-
unitId,
|
|
314
|
-
subUnitId,
|
|
315
|
-
id,
|
|
313
|
+
unitId: e,
|
|
314
|
+
subUnitId: l,
|
|
315
|
+
id: t,
|
|
316
316
|
payload: {
|
|
317
|
-
payload
|
|
317
|
+
payload: n
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
}]
|
|
321
321
|
};
|
|
322
|
-
}
|
|
323
|
-
this._rangeDisableMap.set(
|
|
324
|
-
this._hyperLinkModel.updateHyperLink(
|
|
325
|
-
payload: `#gid=${
|
|
322
|
+
};
|
|
323
|
+
this._rangeDisableMap.set(t, this._refRangeService.registerRefRange(p, h, e, l)), r || this._rangeWatcherMap.set(t, this._refRangeService.watchRange(e, l, p, (g, u) => {
|
|
324
|
+
this._hyperLinkModel.updateHyperLink(e, l, t, {
|
|
325
|
+
payload: `#gid=${l}&range=${u ? B(u) : "err"}`
|
|
326
326
|
}, !0);
|
|
327
327
|
}, !0));
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
_unregisterRange(
|
|
333
|
-
const
|
|
334
|
-
|
|
332
|
+
_unregisterRange(e) {
|
|
333
|
+
const t = this._rangeDisableMap.get(e);
|
|
334
|
+
t == null || t.dispose(), this._rangeDisableMap.delete(e);
|
|
335
335
|
}
|
|
336
|
-
_unwatchRange(
|
|
337
|
-
const
|
|
338
|
-
|
|
336
|
+
_unwatchRange(e) {
|
|
337
|
+
const t = this._rangeWatcherMap.get(e);
|
|
338
|
+
t == null || t.dispose(), this._rangeWatcherMap.delete(e);
|
|
339
339
|
}
|
|
340
340
|
_initData() {
|
|
341
|
-
this._hyperLinkModel.getAll().forEach((
|
|
342
|
-
|
|
343
|
-
const { unitId, subUnitId, links } =
|
|
344
|
-
|
|
345
|
-
this._registerPosition(
|
|
341
|
+
this._hyperLinkModel.getAll().forEach((t) => {
|
|
342
|
+
t.forEach((n) => {
|
|
343
|
+
const { unitId: r, subUnitId: i, links: a } = n;
|
|
344
|
+
a.forEach((o) => {
|
|
345
|
+
this._registerPosition(r, i, o), this._watchPosition(r, i, o), this._registerRange(r, o.id, o.payload);
|
|
346
346
|
});
|
|
347
347
|
});
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
350
|
_initRefRange() {
|
|
351
351
|
this.disposeWithMe(
|
|
352
|
-
this._hyperLinkModel.linkUpdate$.subscribe((
|
|
353
|
-
switch (
|
|
352
|
+
this._hyperLinkModel.linkUpdate$.subscribe((e) => {
|
|
353
|
+
switch (e.type) {
|
|
354
354
|
case "add": {
|
|
355
|
-
this._registerPosition(
|
|
355
|
+
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);
|
|
356
356
|
break;
|
|
357
357
|
}
|
|
358
358
|
case "remove": {
|
|
359
|
-
this._unregisterPosition(
|
|
359
|
+
this._unregisterPosition(e.payload.id), this._unwatchPosition(e.payload.id), this._unregisterRange(e.payload.id), this._unwatchRange(e.payload.id);
|
|
360
360
|
break;
|
|
361
361
|
}
|
|
362
362
|
case "updateRef": {
|
|
363
|
-
const { unitId, subUnitId, id, silent } =
|
|
364
|
-
if (!
|
|
363
|
+
const { unitId: t, subUnitId: n, id: r, silent: i } = e, a = this._hyperLinkModel.getHyperLink(t, n, r);
|
|
364
|
+
if (!a)
|
|
365
365
|
return;
|
|
366
|
-
this._unregisterPosition(
|
|
366
|
+
this._unregisterPosition(r), this._registerPosition(t, n, a), i || (this._unwatchPosition(r), this._watchPosition(t, n, a));
|
|
367
367
|
break;
|
|
368
368
|
}
|
|
369
369
|
case "unload": {
|
|
370
|
-
const { unitLinks } =
|
|
371
|
-
|
|
372
|
-
const { links } =
|
|
373
|
-
|
|
374
|
-
this._unregisterPosition(
|
|
370
|
+
const { unitLinks: t } = e;
|
|
371
|
+
t.forEach((n) => {
|
|
372
|
+
const { links: r } = n;
|
|
373
|
+
r.forEach((i) => {
|
|
374
|
+
this._unregisterPosition(i.id), this._unwatchPosition(i.id), this._unregisterRange(i.id), this._unwatchRange(i.id);
|
|
375
375
|
});
|
|
376
376
|
});
|
|
377
377
|
break;
|
|
378
378
|
}
|
|
379
379
|
case "update": {
|
|
380
|
-
|
|
380
|
+
e.silent || this._unwatchRange(e.id), this._unregisterRange(e.id), this._registerRange(e.unitId, e.id, e.payload.payload, e.silent);
|
|
381
381
|
break;
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
384
|
})
|
|
385
|
-
), this.disposeWithMe(
|
|
386
|
-
this._disposableMap.forEach((
|
|
387
|
-
|
|
385
|
+
), this.disposeWithMe(Ae(() => {
|
|
386
|
+
this._disposableMap.forEach((e) => {
|
|
387
|
+
e.dispose();
|
|
388
388
|
}), this._disposableMap.clear();
|
|
389
389
|
}));
|
|
390
390
|
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
],
|
|
398
|
-
var
|
|
399
|
-
for (var
|
|
400
|
-
(
|
|
401
|
-
return
|
|
402
|
-
},
|
|
403
|
-
let
|
|
404
|
-
constructor(
|
|
405
|
-
super(), this.
|
|
391
|
+
};
|
|
392
|
+
Z = Rt([
|
|
393
|
+
Y(0, I(Pe)),
|
|
394
|
+
Y(1, I(v)),
|
|
395
|
+
Y(2, I(Ne)),
|
|
396
|
+
Y(3, b)
|
|
397
|
+
], Z);
|
|
398
|
+
var It = Object.defineProperty, Mt = Object.getOwnPropertyDescriptor, Ct = (s, e, t, n) => {
|
|
399
|
+
for (var r = n > 1 ? void 0 : n ? Mt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
400
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
401
|
+
return n && r && It(e, t, r), r;
|
|
402
|
+
}, pe = (s, e) => (t, n) => e(t, n, s);
|
|
403
|
+
let Q = class extends V {
|
|
404
|
+
constructor(s, e, t) {
|
|
405
|
+
super(), this._sheetInterceptorService = s, this._univerInstanceService = e, this._hyperLinkModel = t, this._initSheetChange();
|
|
406
|
+
}
|
|
407
|
+
_initSheetChange() {
|
|
408
|
+
this.disposeWithMe(
|
|
409
|
+
this._sheetInterceptorService.interceptCommand({
|
|
410
|
+
getMutations: (s) => {
|
|
411
|
+
var e;
|
|
412
|
+
if (s.id === nt.id) {
|
|
413
|
+
const t = s.params, n = t.unitId ? this._univerInstanceService.getUnit(t.unitId) : this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET);
|
|
414
|
+
if (!n)
|
|
415
|
+
return { redos: [], undos: [] };
|
|
416
|
+
const r = n.getUnitId(), i = t.subUnitId || ((e = n.getActiveSheet()) == null ? void 0 : e.getSheetId());
|
|
417
|
+
if (!i)
|
|
418
|
+
return { redos: [], undos: [] };
|
|
419
|
+
const a = this._hyperLinkModel.getSubUnit(r, i), o = a.map((d) => ({
|
|
420
|
+
id: k.id,
|
|
421
|
+
params: {
|
|
422
|
+
unitId: r,
|
|
423
|
+
subUnitId: i,
|
|
424
|
+
id: d.id
|
|
425
|
+
}
|
|
426
|
+
})), c = a.map((d) => ({
|
|
427
|
+
id: O.id,
|
|
428
|
+
params: {
|
|
429
|
+
unitId: r,
|
|
430
|
+
subUnitId: i,
|
|
431
|
+
link: d
|
|
432
|
+
}
|
|
433
|
+
}));
|
|
434
|
+
return { redos: o, undos: c };
|
|
435
|
+
}
|
|
436
|
+
return { redos: [], undos: [] };
|
|
437
|
+
}
|
|
438
|
+
})
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
Q = Ct([
|
|
443
|
+
pe(0, I(de)),
|
|
444
|
+
pe(1, E),
|
|
445
|
+
pe(2, I(v))
|
|
446
|
+
], Q);
|
|
447
|
+
var wt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, Lt = (s, e, t, n) => {
|
|
448
|
+
for (var r = n > 1 ? void 0 : n ? Et(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
449
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
450
|
+
return n && r && wt(e, t, r), r;
|
|
451
|
+
}, he = (s, e) => (t, n) => e(t, n, s);
|
|
452
|
+
let ee = class extends V {
|
|
453
|
+
constructor(e, t, n) {
|
|
454
|
+
super();
|
|
455
|
+
C(this, "_refRangeMap", /* @__PURE__ */ new Map());
|
|
456
|
+
this._commandService = e, this._univerInstanceService = t, this._refRangeService = n, this._initWorkbookLoad(), this._initWorkbookUnload(), this._initSetRangesListener();
|
|
457
|
+
}
|
|
458
|
+
_enusreMap(e, t) {
|
|
459
|
+
let n = this._refRangeMap.get(e);
|
|
460
|
+
n || (n = /* @__PURE__ */ new Map(), this._refRangeMap.set(e, n));
|
|
461
|
+
let r = n.get(t);
|
|
462
|
+
return r || (r = new J(), n.set(t, r)), r;
|
|
463
|
+
}
|
|
464
|
+
_isLegalRangeUrl(e, t) {
|
|
465
|
+
var r, i, a;
|
|
466
|
+
const n = this._univerInstanceService.getUnit(e, R.UNIVER_SHEET);
|
|
467
|
+
if (!n)
|
|
468
|
+
return null;
|
|
469
|
+
if (t && t.startsWith("#")) {
|
|
470
|
+
const o = new URLSearchParams(t.slice(1)), c = {
|
|
471
|
+
gid: (r = o.get("gid")) != null ? r : "",
|
|
472
|
+
range: (i = o.get("range")) != null ? i : "",
|
|
473
|
+
rangeid: (a = o.get("rangeid")) != null ? a : ""
|
|
474
|
+
};
|
|
475
|
+
if (c.range && c.gid) {
|
|
476
|
+
const d = c.gid, l = n.getSheetBySheetId(d);
|
|
477
|
+
if (!l)
|
|
478
|
+
return null;
|
|
479
|
+
const p = Me(c.range).range;
|
|
480
|
+
if (ve(p, l) && c.range !== q)
|
|
481
|
+
return p;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
_registerRange(e, t, n, r, i) {
|
|
487
|
+
var o, c, d, l;
|
|
488
|
+
const a = this._enusreMap(e, t);
|
|
489
|
+
if ((c = (o = i.body) == null ? void 0 : o.customRanges) != null && c.some((p) => {
|
|
490
|
+
var h;
|
|
491
|
+
return p.rangeType === N.HYPERLINK && this._isLegalRangeUrl(e, (h = p.properties) == null ? void 0 : h.url);
|
|
492
|
+
})) {
|
|
493
|
+
const p = new We();
|
|
494
|
+
let h = !1;
|
|
495
|
+
(l = (d = i.body) == null ? void 0 : d.customRanges) == null || l.forEach((g) => {
|
|
496
|
+
var u;
|
|
497
|
+
if (g.rangeType === N.HYPERLINK) {
|
|
498
|
+
const f = (u = g.properties) == null ? void 0 : u.url, S = this._isLegalRangeUrl(e, f);
|
|
499
|
+
S && (h = !0, p.add(this._refRangeService.watchRange(e, t, S, (_, M) => {
|
|
500
|
+
g.properties.url = `#gid=${t}&range=${M ? B(M) : q}`;
|
|
501
|
+
})));
|
|
502
|
+
}
|
|
503
|
+
}), h && a.setValue(n, r, p);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
_initWorkbookLoad() {
|
|
507
|
+
const e = (t) => {
|
|
508
|
+
const n = t.getUnitId();
|
|
509
|
+
t.getSheets().forEach((r) => {
|
|
510
|
+
const i = r.getSheetId(), a = this._enusreMap(n, i);
|
|
511
|
+
r.getCellMatrix().forValue((o, c, d) => {
|
|
512
|
+
const l = a.getValue(o, c);
|
|
513
|
+
l && l.dispose(), d && d.p && this._registerRange(n, i, o, c, d.p);
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
this._univerInstanceService.getAllUnitsForType(R.UNIVER_SHEET).forEach((t) => {
|
|
518
|
+
e(t);
|
|
519
|
+
}), this.disposeWithMe(
|
|
520
|
+
this._univerInstanceService.unitAdded$.subscribe((t) => {
|
|
521
|
+
t.type === R.UNIVER_SHEET && e(t);
|
|
522
|
+
})
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
_initWorkbookUnload() {
|
|
526
|
+
this._univerInstanceService.unitDisposed$.subscribe((e) => {
|
|
527
|
+
if (e.type === R.UNIVER_SHEET) {
|
|
528
|
+
const t = e, n = t.getUnitId();
|
|
529
|
+
t.getSheets().forEach((r) => {
|
|
530
|
+
const i = r.getSheetId();
|
|
531
|
+
this._enusreMap(n, i).forValue((o, c, d) => {
|
|
532
|
+
d && d.dispose();
|
|
533
|
+
});
|
|
534
|
+
}), this._refRangeMap.delete(n);
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
_initSetRangesListener() {
|
|
539
|
+
this.disposeWithMe(
|
|
540
|
+
this._commandService.onCommandExecuted((e) => {
|
|
541
|
+
if (e.id === H.id) {
|
|
542
|
+
const t = e.params, { unitId: n, subUnitId: r, cellValue: i } = t, a = this._enusreMap(n, r);
|
|
543
|
+
i && new J(i).forValue((o, c, d) => {
|
|
544
|
+
const l = a.getValue(o, c);
|
|
545
|
+
l && l.dispose(), d && d.p && this._registerRange(n, r, o, c, d.p);
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
})
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
ee = Lt([
|
|
553
|
+
he(0, b),
|
|
554
|
+
he(1, E),
|
|
555
|
+
he(2, I(Pe))
|
|
556
|
+
], ee);
|
|
557
|
+
var Ut = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, Pt = (s, e, t, n) => {
|
|
558
|
+
for (var r = n > 1 ? void 0 : n ? bt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
559
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
560
|
+
return n && r && Ut(e, t, r), r;
|
|
561
|
+
}, z = (s, e) => (t, n) => e(t, n, s);
|
|
562
|
+
let te = class extends V {
|
|
563
|
+
constructor(s, e, t, n) {
|
|
564
|
+
super(), this._sheetInterceptorService = s, this._hyperLinkModel = e, this._selectionManagerService = t, this._univerInstanceService = n, this._initCommandInterceptor(), this._initAfterEditor();
|
|
565
|
+
}
|
|
566
|
+
_initCommandInterceptor() {
|
|
567
|
+
this._initSetRangeValuesCommandInterceptor(), this._initClearSelectionCommandInterceptor();
|
|
568
|
+
}
|
|
569
|
+
_initSetRangeValuesCommandInterceptor() {
|
|
570
|
+
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
571
|
+
getMutations: (s) => {
|
|
572
|
+
if (s.id === rt.id) {
|
|
573
|
+
const e = s.params, { unitId: t, subUnitId: n } = e, r = [], i = [];
|
|
574
|
+
return e.cellValue && new J(e.cellValue).forValue((a, o) => {
|
|
575
|
+
const c = this._hyperLinkModel.getHyperLinkByLocation(t, n, a, o);
|
|
576
|
+
c && (r.push({
|
|
577
|
+
id: k.id,
|
|
578
|
+
params: {
|
|
579
|
+
unitId: t,
|
|
580
|
+
subUnitId: n,
|
|
581
|
+
id: c.id
|
|
582
|
+
}
|
|
583
|
+
}), i.push({
|
|
584
|
+
id: O.id,
|
|
585
|
+
params: {
|
|
586
|
+
unitId: t,
|
|
587
|
+
subUnitId: n,
|
|
588
|
+
link: c
|
|
589
|
+
}
|
|
590
|
+
}));
|
|
591
|
+
}), {
|
|
592
|
+
undos: i,
|
|
593
|
+
redos: r
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
return {
|
|
597
|
+
redos: [],
|
|
598
|
+
undos: []
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
}));
|
|
602
|
+
}
|
|
603
|
+
_initClearSelectionCommandInterceptor() {
|
|
604
|
+
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
605
|
+
getMutations: (s) => {
|
|
606
|
+
if (s.id === st.id || s.id === it.id || s.id === at.id) {
|
|
607
|
+
const e = [], t = [], n = this._selectionManagerService.getCurrentLastSelection(), r = ce(this._univerInstanceService);
|
|
608
|
+
if (n && r) {
|
|
609
|
+
const { unitId: i, subUnitId: a } = r;
|
|
610
|
+
Be.foreach(n.range, (o, c) => {
|
|
611
|
+
const d = this._hyperLinkModel.getHyperLinkByLocation(i, a, o, c);
|
|
612
|
+
d && (e.push({
|
|
613
|
+
id: k.id,
|
|
614
|
+
params: {
|
|
615
|
+
unitId: i,
|
|
616
|
+
subUnitId: a,
|
|
617
|
+
id: d.id
|
|
618
|
+
}
|
|
619
|
+
}), t.push({
|
|
620
|
+
id: O.id,
|
|
621
|
+
params: {
|
|
622
|
+
unitId: i,
|
|
623
|
+
subUnitId: a,
|
|
624
|
+
link: d
|
|
625
|
+
}
|
|
626
|
+
}));
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
return {
|
|
630
|
+
redos: e,
|
|
631
|
+
undos: t
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
return {
|
|
635
|
+
redos: [],
|
|
636
|
+
undos: []
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
}));
|
|
640
|
+
}
|
|
641
|
+
_initAfterEditor() {
|
|
642
|
+
this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(ot, {
|
|
643
|
+
handler: (s, e, t) => {
|
|
644
|
+
if (!s || s.p)
|
|
645
|
+
return t(s);
|
|
646
|
+
if (typeof s.v == "string" && ie.isLegalUrl(s.v) && s.v[s.v.length - 1] !== " ") {
|
|
647
|
+
const { unitId: n, subUnitId: r } = e, i = this._univerInstanceService.getUnit(n, R.UNIVER_SHEET), a = i == null ? void 0 : i.getSheetBySheetId(r);
|
|
648
|
+
if (!a)
|
|
649
|
+
return t(s);
|
|
650
|
+
const o = a.getBlankCellDocumentModel(s);
|
|
651
|
+
if (!o.documentModel)
|
|
652
|
+
return t(s);
|
|
653
|
+
const c = X.selection.replace({
|
|
654
|
+
selection: {
|
|
655
|
+
startOffset: 0,
|
|
656
|
+
endOffset: s.v.length,
|
|
657
|
+
collapsed: !1
|
|
658
|
+
},
|
|
659
|
+
body: {
|
|
660
|
+
dataStream: `${s.v}`,
|
|
661
|
+
customRanges: [{
|
|
662
|
+
startIndex: 0,
|
|
663
|
+
endIndex: s.v.length - 1,
|
|
664
|
+
rangeId: ae(),
|
|
665
|
+
rangeType: N.HYPERLINK,
|
|
666
|
+
properties: {
|
|
667
|
+
url: s.v
|
|
668
|
+
}
|
|
669
|
+
}]
|
|
670
|
+
},
|
|
671
|
+
doc: o.documentModel
|
|
672
|
+
});
|
|
673
|
+
if (!c)
|
|
674
|
+
return t(s);
|
|
675
|
+
const d = o.documentModel.getBody();
|
|
676
|
+
return oe.apply(d, c.serialize()), t({
|
|
677
|
+
...s,
|
|
678
|
+
p: {
|
|
679
|
+
id: je,
|
|
680
|
+
body: d,
|
|
681
|
+
documentStyle: {
|
|
682
|
+
pageSize: {
|
|
683
|
+
width: 1 / 0,
|
|
684
|
+
height: 1 / 0
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
return t(s);
|
|
691
|
+
}
|
|
692
|
+
}));
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
te = Pt([
|
|
696
|
+
z(0, I(de)),
|
|
697
|
+
z(1, I(v)),
|
|
698
|
+
z(2, I(Ne)),
|
|
699
|
+
z(3, E)
|
|
700
|
+
], te);
|
|
701
|
+
const Nt = {
|
|
702
|
+
type: L.COMMAND,
|
|
703
|
+
id: "sheets.command.add-hyper-link",
|
|
704
|
+
// eslint-disable-next-line max-lines-per-function
|
|
705
|
+
async handler(s, e) {
|
|
706
|
+
if (!e) return !1;
|
|
707
|
+
const t = s.get(b), n = s.get(Se), r = s.get(E), i = s.get(v), a = s.get(de), o = ce(r, e);
|
|
708
|
+
if (!o) return !1;
|
|
709
|
+
const { unitId: c, subUnitId: d, workbook: l, worksheet: p } = o, { link: h } = e, { payload: g, display: u, row: f, column: S, id: _ } = h, M = p.getCell(f, S), m = p.getBlankCellDocumentModel(M), w = m.documentModel.getSnapshot(), y = ie.deepClone(w.body);
|
|
710
|
+
if (!y) return !1;
|
|
711
|
+
let P;
|
|
712
|
+
if (u ? P = X.selection.replace({
|
|
713
|
+
selection: {
|
|
714
|
+
startOffset: 0,
|
|
715
|
+
endOffset: y.dataStream.length - 2,
|
|
716
|
+
collapsed: !0
|
|
717
|
+
},
|
|
718
|
+
body: {
|
|
719
|
+
dataStream: `${u}`,
|
|
720
|
+
customRanges: [{
|
|
721
|
+
startIndex: 0,
|
|
722
|
+
endIndex: u.length - 1,
|
|
723
|
+
rangeType: N.HYPERLINK,
|
|
724
|
+
rangeId: _,
|
|
725
|
+
properties: {
|
|
726
|
+
url: g
|
|
727
|
+
// refId: id,
|
|
728
|
+
}
|
|
729
|
+
}]
|
|
730
|
+
},
|
|
731
|
+
doc: m.documentModel
|
|
732
|
+
}) : P = X.customRange.add({
|
|
733
|
+
body: y,
|
|
734
|
+
range: { startOffset: 0, endOffset: y.dataStream.length - 2, collapsed: !1 },
|
|
735
|
+
rangeId: _,
|
|
736
|
+
rangeType: N.HYPERLINK,
|
|
737
|
+
properties: {
|
|
738
|
+
url: g,
|
|
739
|
+
refId: _
|
|
740
|
+
}
|
|
741
|
+
}), !P) return !1;
|
|
742
|
+
const j = oe.apply(y, P.serialize()), D = {
|
|
743
|
+
p: {
|
|
744
|
+
...w,
|
|
745
|
+
body: j
|
|
746
|
+
},
|
|
747
|
+
t: Re.STRING
|
|
748
|
+
}, x = await a.onWriteCell(l, p, f, S, D), T = {
|
|
749
|
+
unitId: c,
|
|
750
|
+
subUnitId: d,
|
|
751
|
+
cellValue: {
|
|
752
|
+
[h.row]: {
|
|
753
|
+
[h.column]: x
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}, le = {
|
|
757
|
+
id: H.id,
|
|
758
|
+
params: T
|
|
759
|
+
}, K = Ie(s, T), ue = {
|
|
760
|
+
id: H.id,
|
|
761
|
+
params: K
|
|
762
|
+
}, F = [le], A = [ue], W = i.getHyperLinkByLocation(c, d, f, S);
|
|
763
|
+
return W && (F.push({
|
|
764
|
+
id: k.id,
|
|
765
|
+
params: {
|
|
766
|
+
unitId: c,
|
|
767
|
+
subUnitId: d,
|
|
768
|
+
id: W.id
|
|
769
|
+
}
|
|
770
|
+
}), A.push({
|
|
771
|
+
id: O.id,
|
|
772
|
+
params: {
|
|
773
|
+
unitId: c,
|
|
774
|
+
subUnitId: d,
|
|
775
|
+
link: W
|
|
776
|
+
}
|
|
777
|
+
})), await ye(F, t) ? (n.pushUndoRedo({
|
|
778
|
+
redoMutations: F,
|
|
779
|
+
undoMutations: A,
|
|
780
|
+
unitID: c
|
|
781
|
+
}), !0) : !1;
|
|
782
|
+
}
|
|
783
|
+
}, Ot = {
|
|
784
|
+
id: "sheets.command.add-rich-hyper-link",
|
|
785
|
+
type: L.COMMAND,
|
|
786
|
+
handler: async (s, e) => {
|
|
787
|
+
if (!e)
|
|
788
|
+
return !1;
|
|
789
|
+
const { documentId: t, link: n } = e, r = s.get(b), i = ae(), { payload: a } = n, o = ut(s, {
|
|
790
|
+
unitId: t,
|
|
791
|
+
rangeId: i,
|
|
792
|
+
rangeType: N.HYPERLINK,
|
|
793
|
+
properties: {
|
|
794
|
+
url: a,
|
|
795
|
+
refId: i
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
return o ? r.syncExecuteCommand(o.id, o.params) : !1;
|
|
799
|
+
}
|
|
800
|
+
}, kt = {
|
|
801
|
+
type: L.COMMAND,
|
|
802
|
+
id: "sheets.command.cancel-hyper-link",
|
|
803
|
+
// eslint-disable-next-line max-lines-per-function
|
|
804
|
+
handler(s, e) {
|
|
805
|
+
var D, x;
|
|
806
|
+
if (!e) return !1;
|
|
807
|
+
const t = s.get(b), n = s.get(Se), r = s.get(E), i = s.get(v), a = ce(r, e);
|
|
808
|
+
if (!a) return !1;
|
|
809
|
+
const { row: o, column: c, id: d } = e, { unitId: l, subUnitId: p, worksheet: h } = a, g = h.getCell(o, c);
|
|
810
|
+
if (!g) return !1;
|
|
811
|
+
const u = h.getCellDocumentModelWithFormula(g);
|
|
812
|
+
if (!(u != null && u.documentModel)) return !1;
|
|
813
|
+
const f = ie.deepClone(u.documentModel.getSnapshot());
|
|
814
|
+
if (!((x = (D = f.body) == null ? void 0 : D.customRanges) == null ? void 0 : x.find((T) => T.rangeId === d))) return !1;
|
|
815
|
+
const _ = X.customRange.delete(s, { documentDataModel: u.documentModel, rangeId: d });
|
|
816
|
+
if (!_) return !1;
|
|
817
|
+
const M = oe.apply(f.body, _.serialize()), m = [], w = [], y = {
|
|
818
|
+
unitId: l,
|
|
819
|
+
subUnitId: p,
|
|
820
|
+
cellValue: {
|
|
821
|
+
[o]: {
|
|
822
|
+
[c]: {
|
|
823
|
+
p: {
|
|
824
|
+
...f,
|
|
825
|
+
body: M
|
|
826
|
+
},
|
|
827
|
+
t: Re.STRING
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
m.push({
|
|
833
|
+
id: H.id,
|
|
834
|
+
params: y
|
|
835
|
+
});
|
|
836
|
+
const P = Ie(s, y);
|
|
837
|
+
w.push({
|
|
838
|
+
id: H.id,
|
|
839
|
+
params: P
|
|
840
|
+
});
|
|
841
|
+
const j = i.getHyperLinkByLocation(l, p, o, c);
|
|
842
|
+
return j && (m.push({
|
|
843
|
+
id: k.id,
|
|
844
|
+
params: {
|
|
845
|
+
unitId: l,
|
|
846
|
+
subUnitId: p,
|
|
847
|
+
id: d
|
|
848
|
+
}
|
|
849
|
+
}), w.push({
|
|
850
|
+
id: O.id,
|
|
851
|
+
params: {
|
|
852
|
+
unitId: l,
|
|
853
|
+
subUnitId: p,
|
|
854
|
+
link: {
|
|
855
|
+
...j
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
})), Fe(m, t).result ? (n.pushUndoRedo({
|
|
859
|
+
redoMutations: m,
|
|
860
|
+
undoMutations: w,
|
|
861
|
+
unitID: l
|
|
862
|
+
}), !0) : !1;
|
|
863
|
+
}
|
|
864
|
+
}, Dt = {
|
|
865
|
+
type: L.COMMAND,
|
|
866
|
+
id: "sheets.command.cancel-rich-hyper-link",
|
|
867
|
+
handler(s, e) {
|
|
868
|
+
var l, p;
|
|
869
|
+
if (!e)
|
|
870
|
+
return !1;
|
|
871
|
+
const { id: t, documentId: n } = e, r = s.get(b), a = s.get(E).getUnit(n, R.UNIVER_DOC), o = (p = (l = a == null ? void 0 : a.getBody()) == null ? void 0 : l.customRanges) == null ? void 0 : p.find((h) => h.rangeId === t);
|
|
872
|
+
let c = null;
|
|
873
|
+
o && o.endIndex === a.getBody().dataStream.length - 3 && (c = {
|
|
874
|
+
dataStream: " "
|
|
875
|
+
});
|
|
876
|
+
const d = pt(s, { unitId: n, rangeId: t, insert: c });
|
|
877
|
+
return d ? r.syncExecuteCommand(d.id, d.params) : !1;
|
|
878
|
+
}
|
|
879
|
+
}, Ht = {
|
|
880
|
+
type: L.COMMAND,
|
|
881
|
+
id: "sheets.command.update-hyper-link",
|
|
882
|
+
// eslint-disable-next-line max-lines-per-function
|
|
883
|
+
async handler(s, e) {
|
|
884
|
+
var Ce, we, Ee;
|
|
885
|
+
if (!e) return !1;
|
|
886
|
+
const t = s.get(b), n = s.get(Se), r = s.get(E), i = s.get(v), a = s.get(de), o = ce(r, {
|
|
887
|
+
unitId: e.unitId,
|
|
888
|
+
subUnitId: e.subUnitId
|
|
889
|
+
});
|
|
890
|
+
if (!o) return !1;
|
|
891
|
+
const { payload: c, row: d, column: l, id: p } = e, { workbook: h, worksheet: g, unitId: u, subUnitId: f } = o, { payload: S, display: _ = "" } = c, M = g.getCell(d, l);
|
|
892
|
+
if (!M) return !1;
|
|
893
|
+
const m = g.getCellDocumentModelWithFormula(M);
|
|
894
|
+
if (!(m != null && m.documentModel)) return !1;
|
|
895
|
+
const w = m.documentModel.getSnapshot(), y = (we = (Ce = w.body) == null ? void 0 : Ce.customRanges) == null ? void 0 : we.find(($e) => $e.rangeId === p);
|
|
896
|
+
if (!y) return !1;
|
|
897
|
+
const P = ae(), $ = (Ee = be(m.documentModel.getBody(), y.startIndex, y.endIndex + 1).textRuns) == null ? void 0 : Ee[0];
|
|
898
|
+
$ && ($.ed = _.length + 1);
|
|
899
|
+
const D = Oe(s, {
|
|
900
|
+
unitId: u,
|
|
901
|
+
body: {
|
|
902
|
+
dataStream: `${_}`,
|
|
903
|
+
customRanges: [{
|
|
904
|
+
rangeId: P,
|
|
905
|
+
rangeType: N.HYPERLINK,
|
|
906
|
+
startIndex: 0,
|
|
907
|
+
endIndex: _.length - 1,
|
|
908
|
+
properties: {
|
|
909
|
+
url: S
|
|
910
|
+
}
|
|
911
|
+
}],
|
|
912
|
+
textRuns: $ ? [$] : void 0
|
|
913
|
+
},
|
|
914
|
+
selection: {
|
|
915
|
+
startOffset: y.startIndex,
|
|
916
|
+
endOffset: y.endIndex + 1,
|
|
917
|
+
collapsed: !1
|
|
918
|
+
},
|
|
919
|
+
doc: m.documentModel
|
|
920
|
+
});
|
|
921
|
+
if (!D)
|
|
922
|
+
return !1;
|
|
923
|
+
const x = oe.apply(ie.deepClone(w.body), D.textX.serialize()), T = {
|
|
924
|
+
p: {
|
|
925
|
+
...w,
|
|
926
|
+
body: x
|
|
927
|
+
},
|
|
928
|
+
t: Re.STRING
|
|
929
|
+
}, le = await a.onWriteCell(h, g, d, l, T), K = {
|
|
930
|
+
id: H.id,
|
|
931
|
+
params: {
|
|
932
|
+
unitId: u,
|
|
933
|
+
subUnitId: f,
|
|
934
|
+
cellValue: {
|
|
935
|
+
[d]: {
|
|
936
|
+
[l]: le
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}, ue = Ie(s, K.params), F = {
|
|
941
|
+
id: H.id,
|
|
942
|
+
params: ue
|
|
943
|
+
}, A = [K], W = [F], G = i.getHyperLinkByLocation(u, f, d, l);
|
|
944
|
+
return G && (A.push({
|
|
945
|
+
id: k.id,
|
|
946
|
+
params: {
|
|
947
|
+
unitId: u,
|
|
948
|
+
subUnitId: f,
|
|
949
|
+
id: G.id
|
|
950
|
+
}
|
|
951
|
+
}), W.push({
|
|
952
|
+
id: O.id,
|
|
953
|
+
params: {
|
|
954
|
+
unitId: u,
|
|
955
|
+
subUnitId: f,
|
|
956
|
+
link: G
|
|
957
|
+
}
|
|
958
|
+
})), await ye(A, t) ? (n.pushUndoRedo({
|
|
959
|
+
redoMutations: A,
|
|
960
|
+
undoMutations: W,
|
|
961
|
+
unitID: u
|
|
962
|
+
}), !0) : !1;
|
|
963
|
+
}
|
|
964
|
+
}, Vt = {
|
|
965
|
+
type: L.COMMAND,
|
|
966
|
+
id: "sheets.command.update-rich-hyper-link",
|
|
967
|
+
handler: (s, e) => {
|
|
968
|
+
var u, f, S, _;
|
|
969
|
+
if (!e)
|
|
970
|
+
return !1;
|
|
971
|
+
const { documentId: t, payload: n, id: r } = e, i = s.get(E), a = s.get(b), o = i.getUnit(t, R.UNIVER_DOC);
|
|
972
|
+
if (!o)
|
|
973
|
+
return !1;
|
|
974
|
+
const c = (f = (u = o.getBody()) == null ? void 0 : u.customRanges) == null ? void 0 : f.find((M) => M.rangeId === r);
|
|
975
|
+
if (!c)
|
|
976
|
+
return !1;
|
|
977
|
+
const d = (S = e.payload.display) != null ? S : "", l = ae(), h = (_ = be(o.getBody(), c.startIndex, c.endIndex + 1).textRuns) == null ? void 0 : _[0];
|
|
978
|
+
h && (h.ed = d.length + 1);
|
|
979
|
+
const g = Oe(s, {
|
|
980
|
+
unitId: t,
|
|
981
|
+
body: {
|
|
982
|
+
dataStream: `${d}`,
|
|
983
|
+
customRanges: [{
|
|
984
|
+
rangeId: l,
|
|
985
|
+
rangeType: N.HYPERLINK,
|
|
986
|
+
startIndex: 0,
|
|
987
|
+
endIndex: d.length - 1,
|
|
988
|
+
properties: {
|
|
989
|
+
url: n.payload
|
|
990
|
+
}
|
|
991
|
+
}],
|
|
992
|
+
textRuns: h ? [h] : void 0
|
|
993
|
+
},
|
|
994
|
+
selection: {
|
|
995
|
+
startOffset: c.startIndex,
|
|
996
|
+
endOffset: c.endIndex + 1,
|
|
997
|
+
collapsed: !1
|
|
998
|
+
},
|
|
999
|
+
doc: o
|
|
1000
|
+
});
|
|
1001
|
+
return g ? a.syncExecuteCommand(g.id, g.params) : !1;
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
var $t = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, Tt = (s, e, t, n) => {
|
|
1005
|
+
for (var r = n > 1 ? void 0 : n ? xt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
1006
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
1007
|
+
return n && r && $t(e, t, r), r;
|
|
1008
|
+
}, At = (s, e) => (t, n) => e(t, n, s);
|
|
1009
|
+
let ne = class extends V {
|
|
1010
|
+
constructor(s) {
|
|
1011
|
+
super(), this._commandService = s, this._registerCommands();
|
|
406
1012
|
}
|
|
407
1013
|
_registerCommands() {
|
|
408
1014
|
[
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
1015
|
+
Nt,
|
|
1016
|
+
Ht,
|
|
1017
|
+
kt,
|
|
1018
|
+
Vt,
|
|
1019
|
+
Dt,
|
|
1020
|
+
Ot,
|
|
1021
|
+
O,
|
|
1022
|
+
fe,
|
|
1023
|
+
k,
|
|
1024
|
+
_e
|
|
1025
|
+
].forEach((s) => {
|
|
1026
|
+
this._commandService.registerCommand(s);
|
|
415
1027
|
});
|
|
416
1028
|
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
],
|
|
421
|
-
var
|
|
422
|
-
for (var
|
|
423
|
-
(
|
|
424
|
-
return
|
|
425
|
-
},
|
|
426
|
-
let
|
|
427
|
-
constructor(
|
|
428
|
-
super(), this._resourceManagerService =
|
|
1029
|
+
};
|
|
1030
|
+
ne = Tt([
|
|
1031
|
+
At(0, b)
|
|
1032
|
+
], ne);
|
|
1033
|
+
var De = /* @__PURE__ */ ((s) => (s[s.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", s[s.UNIVER_DOC = 1] = "UNIVER_DOC", s[s.UNIVER_SHEET = 2] = "UNIVER_SHEET", s[s.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", s[s.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", s[s.UNRECOGNIZED = -1] = "UNRECOGNIZED", s))(De || {}), Wt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, jt = (s, e, t, n) => {
|
|
1034
|
+
for (var r = n > 1 ? void 0 : n ? Bt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
1035
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
1036
|
+
return n && r && Wt(e, t, r), r;
|
|
1037
|
+
}, Le = (s, e) => (t, n) => e(t, n, s);
|
|
1038
|
+
let re = class extends V {
|
|
1039
|
+
constructor(s, e) {
|
|
1040
|
+
super(), this._resourceManagerService = s, this._hyperLinkModel = e, this._initSnapshot();
|
|
429
1041
|
}
|
|
430
1042
|
_initSnapshot() {
|
|
431
|
-
const
|
|
432
|
-
const
|
|
433
|
-
return
|
|
434
|
-
|
|
435
|
-
}), JSON.stringify(
|
|
436
|
-
},
|
|
437
|
-
if (!
|
|
1043
|
+
const s = (t) => {
|
|
1044
|
+
const n = this._hyperLinkModel.getUnit(t), r = {};
|
|
1045
|
+
return n ? (n.forEach((i) => {
|
|
1046
|
+
r[i.subUnitId] = i.links.map(({ display: a, ...o }) => o);
|
|
1047
|
+
}), JSON.stringify(r)) : "";
|
|
1048
|
+
}, e = (t) => {
|
|
1049
|
+
if (!t)
|
|
438
1050
|
return {};
|
|
439
1051
|
try {
|
|
440
|
-
return JSON.parse(
|
|
1052
|
+
return JSON.parse(t);
|
|
441
1053
|
} catch {
|
|
442
1054
|
return {};
|
|
443
1055
|
}
|
|
444
|
-
}
|
|
1056
|
+
};
|
|
445
1057
|
this.disposeWithMe(
|
|
446
1058
|
this._resourceManagerService.registerPluginResource({
|
|
447
|
-
pluginName:
|
|
448
|
-
businesses: [
|
|
449
|
-
toJson:
|
|
450
|
-
parseJson:
|
|
451
|
-
onUnLoad:
|
|
452
|
-
this._hyperLinkModel.deleteUnit(
|
|
453
|
-
},
|
|
454
|
-
onLoad:
|
|
455
|
-
Object.keys(
|
|
456
|
-
|
|
457
|
-
this._hyperLinkModel.addHyperLink(
|
|
1059
|
+
pluginName: ke,
|
|
1060
|
+
businesses: [De.UNIVER_SHEET],
|
|
1061
|
+
toJson: (t) => s(t),
|
|
1062
|
+
parseJson: (t) => e(t),
|
|
1063
|
+
onUnLoad: (t) => {
|
|
1064
|
+
this._hyperLinkModel.deleteUnit(t);
|
|
1065
|
+
},
|
|
1066
|
+
onLoad: async (t, n) => {
|
|
1067
|
+
Object.keys(n).forEach((r) => {
|
|
1068
|
+
n[r].forEach((a) => {
|
|
1069
|
+
this._hyperLinkModel.addHyperLink(t, r, a);
|
|
458
1070
|
});
|
|
459
1071
|
});
|
|
460
|
-
}
|
|
1072
|
+
}
|
|
461
1073
|
})
|
|
462
1074
|
);
|
|
463
1075
|
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
],
|
|
469
|
-
var
|
|
470
|
-
for (var
|
|
471
|
-
(
|
|
472
|
-
return
|
|
473
|
-
},
|
|
474
|
-
let
|
|
475
|
-
constructor(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
1076
|
+
};
|
|
1077
|
+
re = jt([
|
|
1078
|
+
Le(0, Ke),
|
|
1079
|
+
Le(1, I(v))
|
|
1080
|
+
], re);
|
|
1081
|
+
var Ft = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Gt = (s, e, t, n) => {
|
|
1082
|
+
for (var r = n > 1 ? void 0 : n ? Kt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
1083
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
1084
|
+
return n && r && Ft(e, t, r), r;
|
|
1085
|
+
}, ge = (s, e) => (t, n) => e(t, n, s);
|
|
1086
|
+
let me = class {
|
|
1087
|
+
constructor(s, e, t) {
|
|
1088
|
+
this._univerInstanceService = s, this._localeService = e, this._definedNamesService = t;
|
|
1089
|
+
}
|
|
1090
|
+
buildHyperLink(s, e, t) {
|
|
1091
|
+
return `#${U.SHEET}=${e}${t ? `&${typeof t == "string" ? U.DEFINE_NAME : U.RANGE}=${typeof t == "string" ? t : B(t)}` : ""}`;
|
|
1092
|
+
}
|
|
1093
|
+
parseHyperLink(s) {
|
|
1094
|
+
var e, t, n, r;
|
|
1095
|
+
if (s.startsWith("#")) {
|
|
1096
|
+
const i = new URLSearchParams(s.slice(1)), a = {
|
|
1097
|
+
gid: (e = i.get("gid")) != null ? e : "",
|
|
1098
|
+
range: (t = i.get("range")) != null ? t : "",
|
|
1099
|
+
rangeid: (n = i.get("rangeid")) != null ? n : "",
|
|
1100
|
+
unitid: (r = i.get("unitid")) != null ? r : ""
|
|
1101
|
+
}, o = this._getURLName(a);
|
|
1102
|
+
return {
|
|
1103
|
+
type: o.type,
|
|
1104
|
+
name: o.name,
|
|
1105
|
+
url: s,
|
|
1106
|
+
searchObj: a
|
|
1107
|
+
};
|
|
1108
|
+
} else
|
|
1109
|
+
return {
|
|
1110
|
+
type: U.URL,
|
|
1111
|
+
name: s,
|
|
1112
|
+
url: s,
|
|
1113
|
+
searchObj: null
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
_getURLName(s) {
|
|
1117
|
+
var d;
|
|
1118
|
+
const { gid: e, range: t, rangeid: n, unitid: r } = s, i = r ? this._univerInstanceService.getUnit(r, R.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET), a = {
|
|
1119
|
+
type: U.INVALID,
|
|
1120
|
+
name: this._localeService.t("hyperLink.message.refError")
|
|
1121
|
+
};
|
|
1122
|
+
if (!i)
|
|
1123
|
+
return a;
|
|
1124
|
+
const o = e ? i.getSheetBySheetId(e) : i.getActiveSheet(), c = (d = o == null ? void 0 : o.getName()) != null ? d : "";
|
|
1125
|
+
if (t) {
|
|
1126
|
+
if (!o) return a;
|
|
1127
|
+
const l = Me(t).range;
|
|
1128
|
+
return ve(l, o) && t !== q ? {
|
|
1129
|
+
type: U.RANGE,
|
|
1130
|
+
name: ct(c, l)
|
|
1131
|
+
} : a;
|
|
1132
|
+
}
|
|
1133
|
+
if (n) {
|
|
1134
|
+
const l = this._definedNamesService.getValueById(i.getUnitId(), n);
|
|
1135
|
+
return l ? {
|
|
1136
|
+
type: U.DEFINE_NAME,
|
|
1137
|
+
name: l.formulaOrRefString
|
|
1138
|
+
} : a;
|
|
1139
|
+
}
|
|
1140
|
+
if (e) {
|
|
1141
|
+
const l = i.getSheetBySheetId(e);
|
|
1142
|
+
return l ? {
|
|
1143
|
+
type: U.SHEET,
|
|
1144
|
+
name: l.getName()
|
|
1145
|
+
} : a;
|
|
1146
|
+
}
|
|
1147
|
+
return a;
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
me = Gt([
|
|
1151
|
+
ge(0, E),
|
|
1152
|
+
ge(1, I(Ge)),
|
|
1153
|
+
ge(2, lt)
|
|
1154
|
+
], me);
|
|
1155
|
+
var He = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, zt = (s, e, t) => e in s ? He(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, Jt = (s, e, t, n) => {
|
|
1156
|
+
for (var r = n > 1 ? void 0 : n ? Yt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
1157
|
+
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
1158
|
+
return n && r && He(e, t, r), r;
|
|
1159
|
+
}, Ue = (s, e) => (t, n) => e(t, n, s), Ve = (s, e, t) => zt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
1160
|
+
let se = class extends Je {
|
|
1161
|
+
constructor(s = yt, e, t) {
|
|
1162
|
+
super(), this._config = s, this._injector = e, this._configService = t;
|
|
1163
|
+
const { ...n } = this._config;
|
|
1164
|
+
this._configService.setConfig(mt, n);
|
|
479
1165
|
}
|
|
480
1166
|
onStarting() {
|
|
481
|
-
[
|
|
482
|
-
[
|
|
483
|
-
[
|
|
484
|
-
[
|
|
485
|
-
[
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
]
|
|
1167
|
+
Xe(this._injector, [
|
|
1168
|
+
[v],
|
|
1169
|
+
[me],
|
|
1170
|
+
[re],
|
|
1171
|
+
[ne],
|
|
1172
|
+
[Z],
|
|
1173
|
+
[te],
|
|
1174
|
+
[Q],
|
|
1175
|
+
[ee]
|
|
1176
|
+
]), qe(this._injector, [
|
|
1177
|
+
[Z],
|
|
1178
|
+
[re],
|
|
1179
|
+
[ne],
|
|
1180
|
+
[te],
|
|
1181
|
+
[Q],
|
|
1182
|
+
[ee]
|
|
1183
|
+
]);
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
Ve(se, "pluginName", ke);
|
|
1187
|
+
Ve(se, "type", R.UNIVER_SHEET);
|
|
1188
|
+
se = Jt([
|
|
1189
|
+
Ye(dt),
|
|
1190
|
+
Ue(1, I(ze)),
|
|
1191
|
+
Ue(2, Ze)
|
|
1192
|
+
], se);
|
|
498
1193
|
export {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
1194
|
+
Nt as AddHyperLinkCommand,
|
|
1195
|
+
O as AddHyperLinkMutation,
|
|
1196
|
+
Ot as AddRichHyperLinkCommand,
|
|
1197
|
+
kt as CancelHyperLinkCommand,
|
|
1198
|
+
Dt as CancelRichHyperLinkCommand,
|
|
1199
|
+
q as ERROR_RANGE,
|
|
1200
|
+
v as HyperLinkModel,
|
|
1201
|
+
k as RemoveHyperLinkMutation,
|
|
1202
|
+
U as SheetHyperLinkType,
|
|
1203
|
+
me as SheetsHyperLinkParserService,
|
|
1204
|
+
se as UniverSheetsHyperLinkPlugin,
|
|
1205
|
+
Ht as UpdateHyperLinkCommand,
|
|
1206
|
+
fe as UpdateHyperLinkMutation,
|
|
1207
|
+
_e as UpdateHyperLinkRefMutation,
|
|
1208
|
+
Vt as UpdateRichHyperLinkCommand
|
|
507
1209
|
};
|