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