@univerjs/docs 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UniverInstanceType as Z, CommandType as
|
|
5
|
-
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as
|
|
1
|
+
var Tt = Object.defineProperty;
|
|
2
|
+
var Et = (o, e, t) => e in o ? Tt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var R = (o, e, t) => Et(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { UniverInstanceType as Z, CommandType as v, RxDisposable as fe, ICommandService as I, TextXActionType as y, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Dt, IUniverInstanceService as D, IUndoRedoService as Te, UndoCommandId as Ze, RedoCommandId as Je, JSONX as N, TextX as F, DataStreamTreeTokenType as xe, Tools as ee, LocaleService as At, MemoryCursor as re, getDocsUpdateBody as Nt, UpdateDocsAttributeType as Ee, BooleanNumber as j, BaselineOffset as G, PRESET_LIST_TYPE as bt, PresetListType as ht, HorizontalAlign as ie, OnLifecycle as De, LifecycleStages as Ae, Disposable as Ne, Direction as P, Plugin as Pt } from "@univerjs/core";
|
|
5
|
+
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as Ut, ITextSelectionRenderManager as pe, DocumentViewModel as wt, DocumentSkeleton as Lt, hasListGlyph as Bt, isIndentByGlyph as Ft, isFirstGlyph as $t, getParagraphByGlyph as Vt, getCharSpaceApply as kt, getNumberUnitValue as Me, RANGE_DIRECTION as Ke, NodePositionConvertToCursor as qe, IRenderManagerService as ft, TextSelectionRenderManager as zt } from "@univerjs/engine-render";
|
|
6
6
|
import { BehaviorSubject as te, takeUntil as ne } from "rxjs";
|
|
7
|
-
import { Inject as k, Injector as
|
|
8
|
-
var be = /* @__PURE__ */ ((
|
|
7
|
+
import { Inject as k, Injector as jt } from "@wendellhu/redi";
|
|
8
|
+
var be = /* @__PURE__ */ ((o) => (o.MAIN = "__Document_Render_Main__", o.BACKGROUND = "__Document_Render_Background__", o))(be || {}), Gt = /* @__PURE__ */ ((o) => (o.VIEW_MAIN = "viewMain", o.VIEW_TOP = "viewTop", o.VIEW_LEFT = "viewLeft", o.VIEW_LEFT_TOP = "viewLeftTop", o))(Gt || {});
|
|
9
9
|
const Xn = 0, Hn = 2, Yn = 4, Wn = 10, Zn = "normalTextSelectionPluginName";
|
|
10
|
-
function
|
|
11
|
-
const t =
|
|
10
|
+
function Xt(o, e) {
|
|
11
|
+
const t = o.getCurrentUnitForType(Z.UNIVER_DOC);
|
|
12
12
|
if (!t)
|
|
13
13
|
return null;
|
|
14
|
-
const n = t.getUnitId(),
|
|
15
|
-
if (
|
|
14
|
+
const n = t.getUnitId(), s = e.getRenderById(n);
|
|
15
|
+
if (s == null)
|
|
16
16
|
return;
|
|
17
|
-
const { mainComponent: r, scene: i, engine: a, components: c } =
|
|
17
|
+
const { mainComponent: r, scene: i, engine: a, components: c } = s, l = r, d = c.get(be.BACKGROUND);
|
|
18
18
|
return {
|
|
19
|
-
document:
|
|
20
|
-
docBackground:
|
|
19
|
+
document: l,
|
|
20
|
+
docBackground: d,
|
|
21
21
|
scene: i,
|
|
22
22
|
engine: a
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function Jn(
|
|
26
|
-
const t = e.getRenderById(
|
|
25
|
+
function Jn(o, e) {
|
|
26
|
+
const t = e.getRenderById(o);
|
|
27
27
|
if (t == null)
|
|
28
28
|
return;
|
|
29
|
-
const { mainComponent: n, scene:
|
|
29
|
+
const { mainComponent: n, scene: s, engine: r, components: i } = t, a = n, c = i.get(be.BACKGROUND);
|
|
30
30
|
return {
|
|
31
31
|
document: a,
|
|
32
32
|
docBackground: c,
|
|
33
|
-
scene:
|
|
33
|
+
scene: s,
|
|
34
34
|
engine: r
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
const pt = {
|
|
38
38
|
id: "doc.operation.set-selections",
|
|
39
|
-
type:
|
|
40
|
-
handler: (
|
|
39
|
+
type: v.OPERATION,
|
|
40
|
+
handler: (o, e) => !0
|
|
41
41
|
};
|
|
42
|
-
var
|
|
43
|
-
for (var
|
|
44
|
-
(i =
|
|
45
|
-
return n &&
|
|
46
|
-
}, Qe = (
|
|
47
|
-
function J(
|
|
48
|
-
const { startOffset: e, endOffset: t, collapsed: n } =
|
|
42
|
+
var Ht = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Wt = (o, e, t, n) => {
|
|
43
|
+
for (var s = n > 1 ? void 0 : n ? Yt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
44
|
+
(i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
|
|
45
|
+
return n && s && Ht(e, t, s), s;
|
|
46
|
+
}, Qe = (o, e) => (t, n) => e(t, n, o);
|
|
47
|
+
function J(o) {
|
|
48
|
+
const { startOffset: e, endOffset: t, collapsed: n } = o, s = {
|
|
49
49
|
startOffset: e,
|
|
50
50
|
endOffset: t,
|
|
51
51
|
collapsed: n
|
|
52
52
|
};
|
|
53
|
-
return typeof
|
|
53
|
+
return typeof o.isActive == "function" && (s.isActive = o.isActive()), s;
|
|
54
54
|
}
|
|
55
55
|
let T = class extends fe {
|
|
56
56
|
constructor(e, t) {
|
|
57
57
|
super();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
R(this, "_currentSelection", null);
|
|
59
|
+
R(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
|
|
60
|
+
R(this, "_textSelection$", new te(null));
|
|
61
|
+
R(this, "textSelection$", this._textSelection$.asObservable());
|
|
62
62
|
this._textSelectionRenderManager = e, this._commandService = t, this._syncSelectionFromRenderService();
|
|
63
63
|
}
|
|
64
64
|
getCurrentSelection() {
|
|
@@ -96,19 +96,19 @@ let T = class extends fe {
|
|
|
96
96
|
const e = this._getTextRanges(this._currentSelection);
|
|
97
97
|
if (e == null)
|
|
98
98
|
return;
|
|
99
|
-
const { textRanges: t, segmentId: n, style:
|
|
99
|
+
const { textRanges: t, segmentId: n, style: s } = e, r = t.find((g) => g.isActive());
|
|
100
100
|
if (r == null)
|
|
101
101
|
return null;
|
|
102
|
-
const { startOffset: i, endOffset: a, collapsed: c, startNodePosition:
|
|
102
|
+
const { startOffset: i, endOffset: a, collapsed: c, startNodePosition: l, endNodePosition: d, direction: u } = r;
|
|
103
103
|
return i == null || a == null ? null : {
|
|
104
104
|
startOffset: i,
|
|
105
105
|
endOffset: a,
|
|
106
106
|
collapsed: c,
|
|
107
|
-
startNodePosition:
|
|
108
|
-
endNodePosition:
|
|
107
|
+
startNodePosition: l,
|
|
108
|
+
endNodePosition: d,
|
|
109
109
|
direction: u,
|
|
110
110
|
segmentId: n,
|
|
111
|
-
style:
|
|
111
|
+
style: s
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
// **Only used in test case** because this does not go through the render layer.
|
|
@@ -118,7 +118,7 @@ let T = class extends fe {
|
|
|
118
118
|
textRanges: e,
|
|
119
119
|
segmentId: "",
|
|
120
120
|
isEditing: t,
|
|
121
|
-
style:
|
|
121
|
+
style: Ut
|
|
122
122
|
// mock style.
|
|
123
123
|
});
|
|
124
124
|
}
|
|
@@ -139,10 +139,10 @@ let T = class extends fe {
|
|
|
139
139
|
...e
|
|
140
140
|
};
|
|
141
141
|
this._replaceByParam(t), this._textSelection$.next(t);
|
|
142
|
-
const { unitId: n, subUnitId:
|
|
142
|
+
const { unitId: n, subUnitId: s, segmentId: r, style: i, textRanges: a, isEditing: c } = t;
|
|
143
143
|
this._commandService.executeCommand(pt.id, {
|
|
144
144
|
unitId: n,
|
|
145
|
-
subUnitId:
|
|
145
|
+
subUnitId: s,
|
|
146
146
|
segmentId: r,
|
|
147
147
|
style: i,
|
|
148
148
|
isEditing: c,
|
|
@@ -150,55 +150,55 @@ let T = class extends fe {
|
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
_getTextRanges(e) {
|
|
153
|
-
var
|
|
153
|
+
var s;
|
|
154
154
|
if (e == null)
|
|
155
155
|
return;
|
|
156
156
|
const { unitId: t, subUnitId: n = "" } = e;
|
|
157
|
-
return (
|
|
157
|
+
return (s = this._textSelectionInfo.get(t)) == null ? void 0 : s.get(n);
|
|
158
158
|
}
|
|
159
159
|
_refresh(e) {
|
|
160
160
|
const t = this._getTextRanges(e);
|
|
161
161
|
this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(J));
|
|
162
162
|
}
|
|
163
163
|
_replaceByParam(e) {
|
|
164
|
-
const { unitId: t, subUnitId: n, style:
|
|
165
|
-
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map()), this._textSelectionInfo.get(t).set(n, { textRanges: i, style:
|
|
164
|
+
const { unitId: t, subUnitId: n, style: s, segmentId: r, textRanges: i, isEditing: a } = e;
|
|
165
|
+
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map()), this._textSelectionInfo.get(t).set(n, { textRanges: i, style: s, segmentId: r, isEditing: a });
|
|
166
166
|
}
|
|
167
167
|
_addByParam(e) {
|
|
168
|
-
const { unitId: t, subUnitId: n, textRanges:
|
|
168
|
+
const { unitId: t, subUnitId: n, textRanges: s, style: r, segmentId: i, isEditing: a } = e;
|
|
169
169
|
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map());
|
|
170
170
|
const c = this._textSelectionInfo.get(t);
|
|
171
|
-
c.has(n) ? c.get(n).textRanges.push(...
|
|
171
|
+
c.has(n) ? c.get(n).textRanges.push(...s) : c.set(n, { textRanges: s, style: r, segmentId: i, isEditing: a });
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
|
-
T =
|
|
174
|
+
T = Wt([
|
|
175
175
|
Qe(0, pe),
|
|
176
|
-
Qe(1,
|
|
176
|
+
Qe(1, I)
|
|
177
177
|
], T);
|
|
178
|
-
function
|
|
179
|
-
const { startOffset: n, endOffset:
|
|
178
|
+
function Pe(o, e = "", t = 0) {
|
|
179
|
+
const { startOffset: n, endOffset: s } = o, r = [], i = n - t, a = s - t;
|
|
180
180
|
return i > 0 && r.push({
|
|
181
|
-
t:
|
|
181
|
+
t: y.RETAIN,
|
|
182
182
|
len: i,
|
|
183
183
|
segmentId: e
|
|
184
184
|
}), r.push({
|
|
185
|
-
t:
|
|
185
|
+
t: y.DELETE,
|
|
186
186
|
len: a - i,
|
|
187
187
|
line: 0,
|
|
188
188
|
segmentId: e
|
|
189
189
|
}), r;
|
|
190
190
|
}
|
|
191
|
-
var
|
|
192
|
-
for (var
|
|
193
|
-
(i =
|
|
194
|
-
return n &&
|
|
195
|
-
},
|
|
196
|
-
let
|
|
191
|
+
var Zt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, Kt = (o, e, t, n) => {
|
|
192
|
+
for (var s = n > 1 ? void 0 : n ? Jt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
193
|
+
(i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
|
|
194
|
+
return n && s && Zt(e, t, s), s;
|
|
195
|
+
}, qt = (o, e) => (t, n) => e(t, n, o);
|
|
196
|
+
let oe = class extends fe {
|
|
197
197
|
constructor(e) {
|
|
198
198
|
super();
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
R(this, "_docViewModelMap", /* @__PURE__ */ new Map());
|
|
200
|
+
R(this, "_currentDocViewModel$", new te(null));
|
|
201
|
+
R(this, "currentDocViewModel$", this._currentDocViewModel$.asObservable());
|
|
202
202
|
this._univerInstanceService = e, this._initialize();
|
|
203
203
|
}
|
|
204
204
|
_initialize() {
|
|
@@ -236,46 +236,49 @@ let se = class extends fe {
|
|
|
236
236
|
throw new Error(`Document data model with id ${e} not found when build view model.`);
|
|
237
237
|
if (t.getBody() != null) {
|
|
238
238
|
if (!this._docViewModelMap.has(e)) {
|
|
239
|
-
const
|
|
239
|
+
const s = this._buildDocViewModel(t);
|
|
240
240
|
this._docViewModelMap.set(e, {
|
|
241
241
|
unitId: e,
|
|
242
|
-
docViewModel:
|
|
242
|
+
docViewModel: s
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
if (e ===
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
245
|
+
if (e === Dt) {
|
|
246
|
+
const s = (n = this._docViewModelMap.get(e)) == null ? void 0 : n.docViewModel;
|
|
247
|
+
if (s == null)
|
|
248
248
|
return;
|
|
249
|
-
|
|
249
|
+
s.reset(t);
|
|
250
250
|
}
|
|
251
251
|
this._currentDocViewModel$.next(this._docViewModelMap.get(e));
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
_buildDocViewModel(e) {
|
|
255
|
-
return new
|
|
255
|
+
return new wt(e);
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
],
|
|
261
|
-
var
|
|
262
|
-
for (var
|
|
263
|
-
(i =
|
|
264
|
-
return n &&
|
|
265
|
-
},
|
|
266
|
-
const
|
|
267
|
-
let
|
|
258
|
+
oe = Kt([
|
|
259
|
+
qt(0, D)
|
|
260
|
+
], oe);
|
|
261
|
+
var Qt = Object.defineProperty, en = Object.getOwnPropertyDescriptor, tn = (o, e, t, n) => {
|
|
262
|
+
for (var s = n > 1 ? void 0 : n ? en(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
263
|
+
(i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
|
|
264
|
+
return n && s && Qt(e, t, s), s;
|
|
265
|
+
}, Ce = (o, e) => (t, n) => e(t, n, o);
|
|
266
|
+
const et = 300;
|
|
267
|
+
let he = class extends fe {
|
|
268
268
|
constructor(e, t, n) {
|
|
269
269
|
super();
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
R(this, "_docStateChange$", new te(null));
|
|
271
|
+
R(this, "docStateChange$", this._docStateChange$.asObservable());
|
|
272
|
+
// This cache used for history compose.
|
|
273
|
+
R(this, "_historyStateCache", /* @__PURE__ */ new Map());
|
|
274
|
+
// This cache used for collaboration state compose.
|
|
275
|
+
R(this, "_changeStateCache", /* @__PURE__ */ new Map());
|
|
276
|
+
R(this, "_historyTimer", null);
|
|
277
|
+
R(this, "_changeStateCacheTimer", null);
|
|
274
278
|
this._undoRedoService = e, this._commandService = t, this._univerInstanceService = n, this._initialize();
|
|
275
279
|
}
|
|
276
280
|
setChangeState(e) {
|
|
277
|
-
|
|
278
|
-
t != null && (this._cacheChangeState(e), n || this._docStateChange$.next(e));
|
|
281
|
+
this._cacheChangeState(e, "history"), this._cacheChangeState(e, "collaboration");
|
|
279
282
|
}
|
|
280
283
|
_initialize() {
|
|
281
284
|
this.disposeWithMe(
|
|
@@ -285,55 +288,83 @@ let me = class extends fe {
|
|
|
285
288
|
if (t == null)
|
|
286
289
|
return;
|
|
287
290
|
const n = t.getUnitId();
|
|
288
|
-
this._pushHistory(n);
|
|
291
|
+
this._pushHistory(n), this._emitChangeState(n);
|
|
289
292
|
}
|
|
290
293
|
})
|
|
291
294
|
);
|
|
292
295
|
}
|
|
293
|
-
_cacheChangeState(e) {
|
|
294
|
-
const { trigger:
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
_cacheChangeState(e, t = "history") {
|
|
297
|
+
const { trigger: n, unitId: s, noHistory: r, debounce: i = !1 } = e;
|
|
298
|
+
if (r || t === "history" && (n === Je || n === Ze))
|
|
299
|
+
return;
|
|
300
|
+
const a = t === "history" ? this._historyStateCache : this._changeStateCache, c = t === "history" ? this._pushHistory.bind(this) : this._emitChangeState.bind(this);
|
|
301
|
+
if (a.has(s)) {
|
|
302
|
+
const l = a.get(s);
|
|
303
|
+
l == null || l.push(e);
|
|
304
|
+
} else
|
|
305
|
+
a.set(s, [e]);
|
|
306
|
+
i ? t === "history" ? (this._historyTimer && clearTimeout(this._historyTimer), this._historyTimer = setTimeout(() => {
|
|
307
|
+
c(s);
|
|
308
|
+
}, et)) : (this._changeStateCacheTimer && clearTimeout(this._changeStateCacheTimer), this._changeStateCacheTimer = setTimeout(() => {
|
|
309
|
+
c(s);
|
|
310
|
+
}, et)) : c(s);
|
|
305
311
|
}
|
|
306
312
|
_pushHistory(e) {
|
|
307
|
-
const t = this._undoRedoService, n = this.
|
|
313
|
+
const t = this._undoRedoService, n = this._historyStateCache.get(e);
|
|
308
314
|
if (!Array.isArray(n) || n.length === 0)
|
|
309
315
|
return;
|
|
310
|
-
const
|
|
316
|
+
const s = n.length, r = n[0].commandId, i = n[0], a = n[s - 1], c = {
|
|
311
317
|
unitId: e,
|
|
312
|
-
actions: n.reduce((
|
|
318
|
+
actions: n.reduce((d, u) => N.compose(d, u.redoState.actions), null),
|
|
313
319
|
textRanges: a.redoState.textRanges
|
|
314
|
-
},
|
|
320
|
+
}, l = {
|
|
315
321
|
unitId: e,
|
|
316
322
|
// Always need to put undoParams after redoParams, because `reverse` will change the `cacheStates` order.
|
|
317
|
-
actions: n.reverse().reduce((
|
|
323
|
+
actions: n.reverse().reduce((d, u) => N.compose(d, u.undoState.actions), null),
|
|
318
324
|
textRanges: i.undoState.textRanges
|
|
319
325
|
};
|
|
320
326
|
t.pushUndoRedo({
|
|
321
327
|
unitID: e,
|
|
322
|
-
undoMutations: [{ id: r, params:
|
|
328
|
+
undoMutations: [{ id: r, params: l }],
|
|
323
329
|
redoMutations: [{ id: r, params: c }]
|
|
324
330
|
}), n.length = 0;
|
|
325
331
|
}
|
|
332
|
+
_emitChangeState(e) {
|
|
333
|
+
const t = this._changeStateCache.get(e);
|
|
334
|
+
if (!Array.isArray(t) || t.length === 0)
|
|
335
|
+
return;
|
|
336
|
+
const n = t.length, { commandId: s, trigger: r, segmentId: i, noHistory: a, debounce: c } = t[0], l = t[0], d = t[n - 1], u = {
|
|
337
|
+
unitId: e,
|
|
338
|
+
actions: t.reduce((S, h) => N.compose(S, h.redoState.actions), null),
|
|
339
|
+
textRanges: d.redoState.textRanges
|
|
340
|
+
}, g = {
|
|
341
|
+
unitId: e,
|
|
342
|
+
// Always need to put undoParams after redoParams, because `reverse` will change the `cacheStates` order.
|
|
343
|
+
actions: t.reverse().reduce((S, h) => N.compose(S, h.undoState.actions), null),
|
|
344
|
+
textRanges: l.undoState.textRanges
|
|
345
|
+
}, m = {
|
|
346
|
+
commandId: s,
|
|
347
|
+
unitId: e,
|
|
348
|
+
trigger: r,
|
|
349
|
+
redoState: u,
|
|
350
|
+
undoState: g,
|
|
351
|
+
segmentId: i,
|
|
352
|
+
noHistory: a,
|
|
353
|
+
debounce: c
|
|
354
|
+
};
|
|
355
|
+
t.length = 0, this._docStateChange$.next(m);
|
|
356
|
+
}
|
|
326
357
|
};
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
],
|
|
332
|
-
class
|
|
358
|
+
he = tn([
|
|
359
|
+
Ce(0, k(Te)),
|
|
360
|
+
Ce(1, I),
|
|
361
|
+
Ce(2, D)
|
|
362
|
+
], he);
|
|
363
|
+
class Se {
|
|
333
364
|
constructor() {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
365
|
+
R(this, "_previousActiveRange", null);
|
|
366
|
+
R(this, "_undoMutationParamsCache", []);
|
|
367
|
+
R(this, "_redoMutationParamsCache", []);
|
|
337
368
|
}
|
|
338
369
|
clearUndoRedoMutationParamsCache() {
|
|
339
370
|
this._undoMutationParamsCache = [], this._redoMutationParamsCache = [];
|
|
@@ -361,13 +392,13 @@ class he {
|
|
|
361
392
|
return null;
|
|
362
393
|
const { unitId: e } = this._undoMutationParamsCache[0], t = {
|
|
363
394
|
unitId: e,
|
|
364
|
-
actions: this._undoMutationParamsCache.reverse().reduce((
|
|
395
|
+
actions: this._undoMutationParamsCache.reverse().reduce((s, r) => N.compose(s, r.actions), null),
|
|
365
396
|
textRanges: []
|
|
366
397
|
// Add empty array, will never use, just fix type error
|
|
367
398
|
};
|
|
368
399
|
return { redoMutationParams: {
|
|
369
400
|
unitId: e,
|
|
370
|
-
actions: this._redoMutationParamsCache.reduce((
|
|
401
|
+
actions: this._redoMutationParamsCache.reduce((s, r) => N.compose(s, r.actions), null),
|
|
371
402
|
textRanges: []
|
|
372
403
|
// Add empty array, will never use, just fix type error
|
|
373
404
|
}, undoMutationParams: t, previousActiveRange: this._previousActiveRange };
|
|
@@ -376,144 +407,148 @@ class he {
|
|
|
376
407
|
this._undoMutationParamsCache = [], this._redoMutationParamsCache = [], this._previousActiveRange = null;
|
|
377
408
|
}
|
|
378
409
|
}
|
|
379
|
-
const
|
|
380
|
-
id:
|
|
381
|
-
type:
|
|
410
|
+
const tt = "doc.mutation.rich-text-editing", B = {
|
|
411
|
+
id: tt,
|
|
412
|
+
type: v.MUTATION,
|
|
382
413
|
// eslint-disable-next-line max-lines-per-function
|
|
383
|
-
handler: (
|
|
384
|
-
var
|
|
414
|
+
handler: (o, e) => {
|
|
415
|
+
var O;
|
|
385
416
|
const {
|
|
386
417
|
unitId: t,
|
|
387
418
|
segmentId: n = "",
|
|
388
|
-
actions:
|
|
419
|
+
actions: s,
|
|
389
420
|
textRanges: r,
|
|
390
421
|
prevTextRanges: i,
|
|
391
422
|
trigger: a,
|
|
392
423
|
noHistory: c,
|
|
393
|
-
isCompositionEnd:
|
|
394
|
-
noNeedSetTextRange:
|
|
395
|
-
|
|
396
|
-
|
|
424
|
+
isCompositionEnd: l,
|
|
425
|
+
noNeedSetTextRange: d,
|
|
426
|
+
debounce: u
|
|
427
|
+
} = e, m = o.get(D).getUniverDocInstance(t), h = o.get(oe).getViewModel(t), f = o.get(T), p = ((O = f.getSelections()) != null ? O : []).map(J), x = o.get(he), M = o.get(Se);
|
|
428
|
+
if (m == null || h == null)
|
|
397
429
|
throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${t}`);
|
|
398
|
-
const C = !!
|
|
399
|
-
if (
|
|
430
|
+
const C = !!m.getSnapshot().disabled;
|
|
431
|
+
if (N.isNoop(s) || s && s.length === 0 || C)
|
|
400
432
|
return {
|
|
401
433
|
unitId: t,
|
|
402
434
|
actions: [],
|
|
403
|
-
textRanges:
|
|
435
|
+
textRanges: p
|
|
404
436
|
};
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
const
|
|
408
|
-
|
|
437
|
+
const A = N.invertWithDoc(s, m.getSnapshot());
|
|
438
|
+
m.apply(s);
|
|
439
|
+
const E = m.getSelfOrHeaderFooterModel(n);
|
|
440
|
+
h.getSelfOrHeaderFooterViewModel(n).reset(E), !d && r && a != null && queueMicrotask(() => {
|
|
409
441
|
f.replaceTextRanges(r);
|
|
410
442
|
});
|
|
411
|
-
const
|
|
412
|
-
commandId:
|
|
443
|
+
const U = {
|
|
444
|
+
commandId: tt,
|
|
413
445
|
unitId: t,
|
|
414
446
|
segmentId: n,
|
|
415
447
|
trigger: a,
|
|
416
448
|
noHistory: c,
|
|
449
|
+
debounce: u,
|
|
417
450
|
redoState: {
|
|
418
|
-
actions:
|
|
451
|
+
actions: s,
|
|
419
452
|
textRanges: r
|
|
420
453
|
},
|
|
421
454
|
undoState: {
|
|
422
|
-
actions:
|
|
423
|
-
textRanges: i != null ? i :
|
|
455
|
+
actions: A,
|
|
456
|
+
textRanges: i != null ? i : p
|
|
424
457
|
}
|
|
425
458
|
};
|
|
426
|
-
if (
|
|
427
|
-
const
|
|
428
|
-
if (
|
|
459
|
+
if (l) {
|
|
460
|
+
const b = M.fetchComposedUndoRedoMutationParams();
|
|
461
|
+
if (b == null)
|
|
429
462
|
throw new Error("historyParams is null in RichTextEditingMutation");
|
|
430
|
-
const { undoMutationParams:
|
|
431
|
-
|
|
463
|
+
const { undoMutationParams: L, redoMutationParams: Y, previousActiveRange: ce } = b;
|
|
464
|
+
U.redoState.actions = Y.actions, U.undoState.actions = L.actions, U.undoState.textRanges = [ce];
|
|
432
465
|
}
|
|
433
|
-
return
|
|
466
|
+
return x.setChangeState(U), {
|
|
434
467
|
unitId: t,
|
|
435
|
-
actions:
|
|
436
|
-
textRanges:
|
|
468
|
+
actions: A,
|
|
469
|
+
textRanges: p
|
|
437
470
|
};
|
|
438
471
|
}
|
|
439
|
-
}, nn = "doc.command.insert-text",
|
|
472
|
+
}, nn = "doc.command.insert-text", Ue = {
|
|
440
473
|
id: nn,
|
|
441
|
-
type:
|
|
442
|
-
handler: async (
|
|
443
|
-
const t =
|
|
474
|
+
type: v.COMMAND,
|
|
475
|
+
handler: async (o, e) => {
|
|
476
|
+
const t = o.get(I), { range: n, segmentId: s, body: r, unitId: i, textRanges: a } = e, { startOffset: c, collapsed: l } = n, d = {
|
|
444
477
|
id: B.id,
|
|
445
478
|
params: {
|
|
446
479
|
unitId: i,
|
|
447
480
|
actions: [],
|
|
448
|
-
textRanges: a
|
|
481
|
+
textRanges: a,
|
|
482
|
+
debounce: !0
|
|
449
483
|
}
|
|
450
|
-
}, u = new F(), g =
|
|
451
|
-
return
|
|
452
|
-
t:
|
|
484
|
+
}, u = new F(), g = N.getInstance();
|
|
485
|
+
return l ? c > 0 && u.push({
|
|
486
|
+
t: y.RETAIN,
|
|
453
487
|
len: c,
|
|
454
|
-
segmentId:
|
|
455
|
-
}) : u.push(...
|
|
456
|
-
t:
|
|
488
|
+
segmentId: s
|
|
489
|
+
}) : u.push(...Pe(n, s)), u.push({
|
|
490
|
+
t: y.INSERT,
|
|
457
491
|
body: r,
|
|
458
492
|
len: r.dataStream.length,
|
|
459
493
|
line: 0,
|
|
460
|
-
segmentId:
|
|
461
|
-
}),
|
|
494
|
+
segmentId: s
|
|
495
|
+
}), d.params.actions = g.editOp(u.serialize()), !!t.syncExecuteCommand(d.id, d.params);
|
|
462
496
|
}
|
|
463
497
|
};
|
|
464
|
-
var X = /* @__PURE__ */ ((
|
|
465
|
-
const
|
|
498
|
+
var X = /* @__PURE__ */ ((o) => (o[o.LEFT = 0] = "LEFT", o[o.RIGHT = 1] = "RIGHT", o))(X || {});
|
|
499
|
+
const we = {
|
|
466
500
|
id: "doc.command.delete-text",
|
|
467
|
-
type:
|
|
468
|
-
handler: async (
|
|
469
|
-
const t =
|
|
501
|
+
type: v.COMMAND,
|
|
502
|
+
handler: async (o, e) => {
|
|
503
|
+
const t = o.get(I), { range: n, segmentId: s, unitId: r, direction: i, textRanges: a, len: c = 1 } = e, { startOffset: l } = n, d = {
|
|
470
504
|
id: B.id,
|
|
471
505
|
params: {
|
|
472
506
|
unitId: r,
|
|
473
507
|
actions: [],
|
|
474
|
-
textRanges: a
|
|
508
|
+
textRanges: a,
|
|
509
|
+
debounce: !0
|
|
475
510
|
}
|
|
476
|
-
}, u = new F(), g =
|
|
477
|
-
return
|
|
478
|
-
t:
|
|
479
|
-
len: i === 0 ?
|
|
480
|
-
segmentId:
|
|
511
|
+
}, u = new F(), g = N.getInstance();
|
|
512
|
+
return l > 0 && u.push({
|
|
513
|
+
t: y.RETAIN,
|
|
514
|
+
len: i === 0 ? l - c : l,
|
|
515
|
+
segmentId: s
|
|
481
516
|
}), u.push({
|
|
482
|
-
t:
|
|
517
|
+
t: y.DELETE,
|
|
483
518
|
len: c,
|
|
484
519
|
line: 0,
|
|
485
|
-
segmentId:
|
|
486
|
-
}),
|
|
520
|
+
segmentId: s
|
|
521
|
+
}), d.params.actions = g.editOp(u.serialize()), !!t.syncExecuteCommand(d.id, d.params);
|
|
487
522
|
}
|
|
488
|
-
},
|
|
523
|
+
}, St = {
|
|
489
524
|
id: "doc.command.update-text",
|
|
490
|
-
type:
|
|
491
|
-
handler: async (
|
|
492
|
-
const { range: t, segmentId: n, updateBody:
|
|
525
|
+
type: v.COMMAND,
|
|
526
|
+
handler: async (o, e) => {
|
|
527
|
+
const { range: t, segmentId: n, updateBody: s, coverType: r, unitId: i, textRanges: a } = e, c = o.get(I), l = {
|
|
493
528
|
id: B.id,
|
|
494
529
|
params: {
|
|
495
530
|
unitId: i,
|
|
496
531
|
actions: [],
|
|
497
532
|
textRanges: a
|
|
498
533
|
}
|
|
499
|
-
},
|
|
500
|
-
return
|
|
501
|
-
t:
|
|
534
|
+
}, d = new F(), u = N.getInstance(), { startOffset: g, endOffset: m } = t;
|
|
535
|
+
return d.push({
|
|
536
|
+
t: y.RETAIN,
|
|
502
537
|
len: g,
|
|
503
538
|
segmentId: n
|
|
504
|
-
}),
|
|
505
|
-
t:
|
|
506
|
-
body:
|
|
539
|
+
}), d.push({
|
|
540
|
+
t: y.RETAIN,
|
|
541
|
+
body: s,
|
|
507
542
|
len: m - g,
|
|
508
543
|
segmentId: n,
|
|
509
544
|
coverType: r
|
|
510
|
-
}),
|
|
545
|
+
}), l.params.actions = u.editOp(d.serialize()), !!c.syncExecuteCommand(l.id, l.params);
|
|
511
546
|
}
|
|
512
547
|
};
|
|
513
|
-
function
|
|
548
|
+
function on(o, e) {
|
|
514
549
|
const t = [];
|
|
515
|
-
for (let n = 0,
|
|
516
|
-
|
|
550
|
+
for (let n = 0, s = o.length; n < s; n++)
|
|
551
|
+
o[n] === xe.PARAGRAPH && t.push({
|
|
517
552
|
startIndex: n
|
|
518
553
|
});
|
|
519
554
|
if (e)
|
|
@@ -521,51 +556,51 @@ function sn(s, e) {
|
|
|
521
556
|
e.bullet && (n.bullet = ee.deepClone(e.bullet)), e.paragraphStyle && (n.paragraphStyle = ee.deepClone(e.paragraphStyle));
|
|
522
557
|
return t;
|
|
523
558
|
}
|
|
524
|
-
const
|
|
559
|
+
const sn = {
|
|
525
560
|
id: "doc.command.break-line",
|
|
526
|
-
type:
|
|
527
|
-
handler: async (
|
|
528
|
-
var S,
|
|
529
|
-
const e =
|
|
530
|
-
if (
|
|
561
|
+
type: v.COMMAND,
|
|
562
|
+
handler: async (o) => {
|
|
563
|
+
var S, h;
|
|
564
|
+
const e = o.get(T), t = o.get(D), n = o.get(I), s = e.getActiveRange();
|
|
565
|
+
if (s == null)
|
|
531
566
|
return !1;
|
|
532
567
|
const r = t.getCurrentUniverDocInstance();
|
|
533
568
|
if (!r)
|
|
534
569
|
return !1;
|
|
535
|
-
const i = r.getUnitId(), { startOffset: a, segmentId: c, style:
|
|
570
|
+
const i = r.getUnitId(), { startOffset: a, segmentId: c, style: l } = s, d = [
|
|
536
571
|
{
|
|
537
572
|
startOffset: a + 1,
|
|
538
573
|
endOffset: a + 1,
|
|
539
|
-
style:
|
|
574
|
+
style: l
|
|
540
575
|
}
|
|
541
|
-
], g = ((
|
|
542
|
-
return await n.executeCommand(
|
|
576
|
+
], g = ((h = (S = r.getBody()) == null ? void 0 : S.paragraphs) != null ? h : []).find((f) => f.startIndex >= a);
|
|
577
|
+
return await n.executeCommand(Ue.id, {
|
|
543
578
|
unitId: i,
|
|
544
579
|
body: {
|
|
545
|
-
dataStream:
|
|
546
|
-
paragraphs:
|
|
580
|
+
dataStream: xe.PARAGRAPH,
|
|
581
|
+
paragraphs: on(xe.PARAGRAPH, g)
|
|
547
582
|
},
|
|
548
|
-
range:
|
|
549
|
-
textRanges:
|
|
583
|
+
range: s,
|
|
584
|
+
textRanges: d,
|
|
550
585
|
segmentId: c
|
|
551
586
|
});
|
|
552
587
|
}
|
|
553
588
|
};
|
|
554
|
-
var rn = Object.defineProperty, an = Object.getOwnPropertyDescriptor, cn = (
|
|
555
|
-
for (var
|
|
556
|
-
(i =
|
|
557
|
-
return n &&
|
|
558
|
-
},
|
|
589
|
+
var rn = Object.defineProperty, an = Object.getOwnPropertyDescriptor, cn = (o, e, t, n) => {
|
|
590
|
+
for (var s = n > 1 ? void 0 : n ? an(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
591
|
+
(i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
|
|
592
|
+
return n && s && rn(e, t, s), s;
|
|
593
|
+
}, Re = (o, e) => (t, n) => e(t, n, o);
|
|
559
594
|
let H = class extends fe {
|
|
560
595
|
constructor(e, t, n) {
|
|
561
596
|
super();
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
597
|
+
R(this, "_currentSkeletonUnitId", "");
|
|
598
|
+
R(this, "_docSkeletonMap", /* @__PURE__ */ new Map());
|
|
599
|
+
R(this, "_currentSkeleton$", new te(null));
|
|
600
|
+
R(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
|
|
566
601
|
// CurrentSkeletonBefore for pre-triggered logic during registration
|
|
567
|
-
|
|
568
|
-
|
|
602
|
+
R(this, "_currentSkeletonBefore$", new te(null));
|
|
603
|
+
R(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
|
|
569
604
|
this._localeService = e, this._docViewModelManagerService = t, this._univerInstanceService = n, this._initialize();
|
|
570
605
|
}
|
|
571
606
|
_initialize() {
|
|
@@ -613,63 +648,63 @@ let H = class extends fe {
|
|
|
613
648
|
return this._currentSkeletonUnitId = t, this._currentSkeletonBefore$.next(this.getCurrent()), this._currentSkeleton$.next(this.getCurrent()), this.getCurrent();
|
|
614
649
|
}
|
|
615
650
|
_buildSkeleton(e) {
|
|
616
|
-
return
|
|
651
|
+
return Lt.create(e, this._localeService);
|
|
617
652
|
}
|
|
618
653
|
};
|
|
619
654
|
H = cn([
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
655
|
+
Re(0, k(At)),
|
|
656
|
+
Re(1, k(oe)),
|
|
657
|
+
Re(2, D)
|
|
623
658
|
], H);
|
|
624
659
|
const Kn = {
|
|
625
660
|
id: "doc.command.inner-paste",
|
|
626
|
-
type:
|
|
627
|
-
handler: async (
|
|
628
|
-
const { segmentId: t, body: n, textRanges:
|
|
661
|
+
type: v.COMMAND,
|
|
662
|
+
handler: async (o, e) => {
|
|
663
|
+
const { segmentId: t, body: n, textRanges: s } = e, r = o.get(I), i = o.get(T), a = o.get(D), c = i.getSelections();
|
|
629
664
|
if (!Array.isArray(c) || c.length === 0)
|
|
630
665
|
return !1;
|
|
631
|
-
const
|
|
632
|
-
if (!
|
|
666
|
+
const l = a.getCurrentUniverDocInstance();
|
|
667
|
+
if (!l)
|
|
633
668
|
return !1;
|
|
634
|
-
const
|
|
669
|
+
const d = l.getUnitId(), u = {
|
|
635
670
|
id: B.id,
|
|
636
671
|
params: {
|
|
637
|
-
unitId:
|
|
672
|
+
unitId: d,
|
|
638
673
|
actions: [],
|
|
639
|
-
textRanges:
|
|
674
|
+
textRanges: s
|
|
640
675
|
}
|
|
641
676
|
}, g = new re();
|
|
642
677
|
g.reset();
|
|
643
|
-
const m = new F(), S =
|
|
644
|
-
for (const
|
|
645
|
-
const { startOffset: _, endOffset:
|
|
646
|
-
|
|
647
|
-
t:
|
|
648
|
-
len:
|
|
678
|
+
const m = new F(), S = N.getInstance();
|
|
679
|
+
for (const f of c) {
|
|
680
|
+
const { startOffset: _, endOffset: p, collapsed: x } = f, M = _ - g.cursor;
|
|
681
|
+
x ? m.push({
|
|
682
|
+
t: y.RETAIN,
|
|
683
|
+
len: M,
|
|
649
684
|
segmentId: t
|
|
650
|
-
}) : m.push(...
|
|
651
|
-
t:
|
|
685
|
+
}) : m.push(...Pe(f, t, g.cursor)), m.push({
|
|
686
|
+
t: y.INSERT,
|
|
652
687
|
body: n,
|
|
653
688
|
len: n.dataStream.length,
|
|
654
689
|
line: 0,
|
|
655
690
|
segmentId: t
|
|
656
|
-
}), g.reset(), g.moveCursor(
|
|
691
|
+
}), g.reset(), g.moveCursor(p);
|
|
657
692
|
}
|
|
658
693
|
return u.params.actions = S.editOp(m.serialize()), !!r.syncExecuteCommand(u.id, u.params);
|
|
659
694
|
}
|
|
660
|
-
},
|
|
695
|
+
}, _t = {
|
|
661
696
|
id: "doc.command.inner-cut",
|
|
662
|
-
type:
|
|
663
|
-
handler: async (
|
|
664
|
-
var
|
|
665
|
-
const { segmentId: t, textRanges: n } = e,
|
|
697
|
+
type: v.COMMAND,
|
|
698
|
+
handler: async (o, e) => {
|
|
699
|
+
var f;
|
|
700
|
+
const { segmentId: t, textRanges: n } = e, s = o.get(I), r = o.get(T), i = o.get(D), a = r.getSelections();
|
|
666
701
|
if (!Array.isArray(a) || a.length === 0)
|
|
667
702
|
return !1;
|
|
668
|
-
const c = (
|
|
703
|
+
const c = (f = i.getCurrentUniverDocInstance()) == null ? void 0 : f.getUnitId();
|
|
669
704
|
if (!c)
|
|
670
705
|
return !1;
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
706
|
+
const l = i.getUniverDocInstance(c), d = Nt(l.getSnapshot(), t);
|
|
707
|
+
if (d == null)
|
|
673
708
|
return !1;
|
|
674
709
|
const u = {
|
|
675
710
|
id: B.id,
|
|
@@ -680,47 +715,47 @@ const Kn = {
|
|
|
680
715
|
}
|
|
681
716
|
}, g = new re();
|
|
682
717
|
g.reset();
|
|
683
|
-
const m = new F(), S =
|
|
718
|
+
const m = new F(), S = N.getInstance();
|
|
684
719
|
for (const _ of a) {
|
|
685
|
-
const { startOffset:
|
|
686
|
-
|
|
687
|
-
t:
|
|
688
|
-
len:
|
|
720
|
+
const { startOffset: p, endOffset: x, collapsed: M } = _, C = p - g.cursor;
|
|
721
|
+
M ? m.push({
|
|
722
|
+
t: y.RETAIN,
|
|
723
|
+
len: C,
|
|
689
724
|
segmentId: t
|
|
690
|
-
}) : m.push(...ln(_,
|
|
725
|
+
}) : m.push(...ln(_, d, t, g.cursor)), g.reset(), g.moveCursor(x);
|
|
691
726
|
}
|
|
692
|
-
return u.params.actions = S.editOp(m.serialize()), !!
|
|
727
|
+
return u.params.actions = S.editOp(m.serialize()), !!s.syncExecuteCommand(u.id, u.params);
|
|
693
728
|
}
|
|
694
729
|
};
|
|
695
|
-
function ln(
|
|
696
|
-
const { startOffset:
|
|
697
|
-
(u) => u.startIndex - n >= c && u.startIndex - n <=
|
|
730
|
+
function ln(o, e, t = "", n = 0) {
|
|
731
|
+
const { startOffset: s, endOffset: r } = o, i = [], { paragraphs: a = [] } = e, c = s - n, l = r - n, d = a == null ? void 0 : a.find(
|
|
732
|
+
(u) => u.startIndex - n >= c && u.startIndex - n <= l
|
|
698
733
|
);
|
|
699
734
|
if (c > 0 && i.push({
|
|
700
|
-
t:
|
|
735
|
+
t: y.RETAIN,
|
|
701
736
|
len: c,
|
|
702
737
|
segmentId: t
|
|
703
|
-
}),
|
|
704
|
-
const u =
|
|
738
|
+
}), d && d.startIndex - n > c) {
|
|
739
|
+
const u = d.startIndex - n;
|
|
705
740
|
i.push({
|
|
706
|
-
t:
|
|
741
|
+
t: y.DELETE,
|
|
707
742
|
len: u - c,
|
|
708
743
|
line: 0,
|
|
709
744
|
segmentId: t
|
|
710
745
|
}), i.push({
|
|
711
|
-
t:
|
|
746
|
+
t: y.RETAIN,
|
|
712
747
|
len: 1,
|
|
713
748
|
segmentId: t
|
|
714
|
-
}),
|
|
715
|
-
t:
|
|
716
|
-
len:
|
|
749
|
+
}), l > u + 1 && i.push({
|
|
750
|
+
t: y.DELETE,
|
|
751
|
+
len: l - u - 1,
|
|
717
752
|
line: 0,
|
|
718
753
|
segmentId: t
|
|
719
754
|
});
|
|
720
755
|
} else
|
|
721
756
|
i.push({
|
|
722
|
-
t:
|
|
723
|
-
len:
|
|
757
|
+
t: y.DELETE,
|
|
758
|
+
len: l - c,
|
|
724
759
|
line: 0,
|
|
725
760
|
segmentId: t
|
|
726
761
|
});
|
|
@@ -728,197 +763,197 @@ function ln(s, e, t = "", n = 0) {
|
|
|
728
763
|
}
|
|
729
764
|
const dn = {
|
|
730
765
|
id: "doc.command.delete-left",
|
|
731
|
-
type:
|
|
766
|
+
type: v.COMMAND,
|
|
732
767
|
// eslint-disable-next-line max-lines-per-function
|
|
733
|
-
handler: async (
|
|
734
|
-
var
|
|
735
|
-
const e =
|
|
768
|
+
handler: async (o) => {
|
|
769
|
+
var M;
|
|
770
|
+
const e = o.get(T), t = o.get(H), n = o.get(D), s = o.get(I), r = e.getActiveRange(), i = e.getSelections(), a = (M = t.getCurrent()) == null ? void 0 : M.skeleton;
|
|
736
771
|
let c = !0;
|
|
737
772
|
if (r == null || a == null || i == null)
|
|
738
773
|
return !1;
|
|
739
|
-
const
|
|
740
|
-
if (!
|
|
774
|
+
const l = n.getCurrentUniverDocInstance();
|
|
775
|
+
if (!l)
|
|
741
776
|
return !1;
|
|
742
|
-
const { startOffset:
|
|
743
|
-
let _ =
|
|
744
|
-
const
|
|
745
|
-
if (
|
|
746
|
-
const
|
|
747
|
-
if (
|
|
777
|
+
const { startOffset: d, collapsed: u, segmentId: g, style: m } = r, S = a.findNodeByCharIndex(d), h = Bt(S), f = Ft(S, l.getBody());
|
|
778
|
+
let _ = d;
|
|
779
|
+
const p = a.findNodeByCharIndex(d - 1);
|
|
780
|
+
if ($t(S) && p !== S && (h === !0 || f === !0) && u) {
|
|
781
|
+
const C = Vt(S, l.getBody());
|
|
782
|
+
if (C == null)
|
|
748
783
|
return !1;
|
|
749
|
-
const A =
|
|
750
|
-
if (
|
|
751
|
-
const O =
|
|
784
|
+
const A = C == null ? void 0 : C.startIndex, E = { startIndex: 0 }, w = C.paragraphStyle;
|
|
785
|
+
if (h === !0) {
|
|
786
|
+
const O = C.paragraphStyle;
|
|
752
787
|
if (O) {
|
|
753
|
-
|
|
754
|
-
const { hanging:
|
|
755
|
-
|
|
788
|
+
E.paragraphStyle = O;
|
|
789
|
+
const { hanging: b } = O;
|
|
790
|
+
b && (E.paragraphStyle.indentStart = b, E.paragraphStyle.hanging = void 0);
|
|
756
791
|
}
|
|
757
|
-
} else if (
|
|
758
|
-
const O =
|
|
759
|
-
O && (
|
|
792
|
+
} else if (f === !0) {
|
|
793
|
+
const O = C.bullet;
|
|
794
|
+
O && (E.bullet = O), w != null && (E.paragraphStyle = { ...w }, delete E.paragraphStyle.hanging, delete E.paragraphStyle.indentStart);
|
|
760
795
|
}
|
|
761
|
-
const
|
|
796
|
+
const U = [
|
|
762
797
|
{
|
|
763
798
|
startOffset: _,
|
|
764
799
|
endOffset: _,
|
|
765
800
|
style: m
|
|
766
801
|
}
|
|
767
802
|
];
|
|
768
|
-
c = await
|
|
769
|
-
unitId:
|
|
803
|
+
c = await s.executeCommand(St.id, {
|
|
804
|
+
unitId: l.getUnitId(),
|
|
770
805
|
updateBody: {
|
|
771
806
|
dataStream: "",
|
|
772
|
-
paragraphs: [{ ...
|
|
807
|
+
paragraphs: [{ ...E }]
|
|
773
808
|
},
|
|
774
809
|
range: {
|
|
775
810
|
startOffset: A,
|
|
776
811
|
endOffset: A + 1
|
|
777
812
|
},
|
|
778
|
-
textRanges:
|
|
779
|
-
coverType:
|
|
813
|
+
textRanges: U,
|
|
814
|
+
coverType: Ee.REPLACE,
|
|
780
815
|
segmentId: g
|
|
781
816
|
});
|
|
782
817
|
} else if (u === !0) {
|
|
783
|
-
if (
|
|
818
|
+
if (p == null)
|
|
784
819
|
return !0;
|
|
785
|
-
if (
|
|
786
|
-
c = await
|
|
820
|
+
if (p.content === "\r")
|
|
821
|
+
c = await s.executeCommand(Le.id, {
|
|
787
822
|
direction: X.LEFT,
|
|
788
823
|
range: r
|
|
789
824
|
});
|
|
790
825
|
else {
|
|
791
|
-
_ -=
|
|
792
|
-
const
|
|
826
|
+
_ -= p.count;
|
|
827
|
+
const C = [
|
|
793
828
|
{
|
|
794
829
|
startOffset: _,
|
|
795
830
|
endOffset: _,
|
|
796
831
|
style: m
|
|
797
832
|
}
|
|
798
833
|
];
|
|
799
|
-
c = await
|
|
800
|
-
unitId:
|
|
834
|
+
c = await s.executeCommand(we.id, {
|
|
835
|
+
unitId: l.getUnitId(),
|
|
801
836
|
range: r,
|
|
802
837
|
segmentId: g,
|
|
803
838
|
direction: X.LEFT,
|
|
804
|
-
len:
|
|
805
|
-
textRanges:
|
|
839
|
+
len: p.count,
|
|
840
|
+
textRanges: C
|
|
806
841
|
});
|
|
807
842
|
}
|
|
808
843
|
} else {
|
|
809
|
-
const
|
|
810
|
-
c = await
|
|
844
|
+
const C = vt(r, i);
|
|
845
|
+
c = await s.executeCommand(_t.id, {
|
|
811
846
|
segmentId: g,
|
|
812
|
-
textRanges:
|
|
847
|
+
textRanges: C
|
|
813
848
|
});
|
|
814
849
|
}
|
|
815
850
|
return c;
|
|
816
851
|
}
|
|
817
852
|
}, un = {
|
|
818
853
|
id: "doc.command.delete-right",
|
|
819
|
-
type:
|
|
820
|
-
handler: async (
|
|
854
|
+
type: v.COMMAND,
|
|
855
|
+
handler: async (o) => {
|
|
821
856
|
var S;
|
|
822
|
-
const e =
|
|
857
|
+
const e = o.get(T), t = o.get(H), n = o.get(D), s = o.get(I), r = e.getActiveRange(), i = e.getSelections(), a = (S = t.getCurrent()) == null ? void 0 : S.skeleton;
|
|
823
858
|
let c;
|
|
824
859
|
if (r == null || a == null || i == null)
|
|
825
860
|
return !1;
|
|
826
|
-
const
|
|
827
|
-
if (!
|
|
861
|
+
const l = n.getCurrentUniverDocInstance();
|
|
862
|
+
if (!l)
|
|
828
863
|
return !1;
|
|
829
|
-
const { startOffset:
|
|
830
|
-
if (
|
|
864
|
+
const { startOffset: d, collapsed: u, segmentId: g, style: m } = r;
|
|
865
|
+
if (d === l.getBody().dataStream.length - 2 && u)
|
|
831
866
|
return !0;
|
|
832
867
|
if (u === !0) {
|
|
833
|
-
const
|
|
834
|
-
if (
|
|
835
|
-
c = await
|
|
868
|
+
const h = a.findNodeByCharIndex(d);
|
|
869
|
+
if (h.content === "\r")
|
|
870
|
+
c = await s.executeCommand(Le.id, {
|
|
836
871
|
direction: X.RIGHT,
|
|
837
872
|
range: r
|
|
838
873
|
});
|
|
839
874
|
else {
|
|
840
|
-
const
|
|
875
|
+
const f = [
|
|
841
876
|
{
|
|
842
|
-
startOffset:
|
|
843
|
-
endOffset:
|
|
877
|
+
startOffset: d,
|
|
878
|
+
endOffset: d,
|
|
844
879
|
style: m
|
|
845
880
|
}
|
|
846
881
|
];
|
|
847
|
-
c = await
|
|
848
|
-
unitId:
|
|
882
|
+
c = await s.executeCommand(we.id, {
|
|
883
|
+
unitId: l.getUnitId(),
|
|
849
884
|
range: r,
|
|
850
885
|
segmentId: g,
|
|
851
886
|
direction: X.RIGHT,
|
|
852
|
-
textRanges:
|
|
853
|
-
len:
|
|
887
|
+
textRanges: f,
|
|
888
|
+
len: h.count
|
|
854
889
|
});
|
|
855
890
|
}
|
|
856
891
|
} else {
|
|
857
|
-
const
|
|
858
|
-
c = await
|
|
892
|
+
const h = vt(r, i);
|
|
893
|
+
c = await s.executeCommand(_t.id, {
|
|
859
894
|
segmentId: g,
|
|
860
|
-
textRanges:
|
|
895
|
+
textRanges: h
|
|
861
896
|
});
|
|
862
897
|
}
|
|
863
898
|
return c;
|
|
864
899
|
}
|
|
865
|
-
},
|
|
900
|
+
}, Le = {
|
|
866
901
|
id: "doc.command.merge-two-paragraph",
|
|
867
|
-
type:
|
|
902
|
+
type: v.COMMAND,
|
|
868
903
|
// eslint-disable-next-line max-lines-per-function
|
|
869
|
-
handler: async (
|
|
870
|
-
var
|
|
871
|
-
const t =
|
|
904
|
+
handler: async (o, e) => {
|
|
905
|
+
var w, U, O;
|
|
906
|
+
const t = o.get(T), n = o.get(D), s = o.get(I), { direction: r, range: i } = e, a = t.getActiveRange(), c = t.getSelections();
|
|
872
907
|
if (a == null || c == null)
|
|
873
908
|
return !1;
|
|
874
|
-
const
|
|
875
|
-
if (!
|
|
909
|
+
const l = n.getCurrentUniverDocInstance();
|
|
910
|
+
if (!l)
|
|
876
911
|
return !1;
|
|
877
|
-
const { startOffset:
|
|
912
|
+
const { startOffset: d, collapsed: u, segmentId: g, style: m } = a;
|
|
878
913
|
if (!u)
|
|
879
914
|
return !1;
|
|
880
|
-
const S = r === X.LEFT ?
|
|
915
|
+
const S = r === X.LEFT ? d : d + 1, h = (O = (U = (w = l.getBody()) == null ? void 0 : w.paragraphs) == null ? void 0 : U.find((b) => b.startIndex >= S)) == null ? void 0 : O.startIndex, f = gn(l.getBody(), S, h), _ = r === X.LEFT ? d - 1 : d, p = l.getUnitId(), x = [
|
|
881
916
|
{
|
|
882
917
|
startOffset: _,
|
|
883
918
|
endOffset: _,
|
|
884
919
|
style: m
|
|
885
920
|
}
|
|
886
|
-
],
|
|
921
|
+
], M = {
|
|
887
922
|
id: B.id,
|
|
888
923
|
params: {
|
|
889
|
-
unitId:
|
|
924
|
+
unitId: p,
|
|
890
925
|
actions: [],
|
|
891
|
-
textRanges:
|
|
926
|
+
textRanges: x,
|
|
892
927
|
prevTextRanges: [i]
|
|
893
928
|
}
|
|
894
|
-
},
|
|
895
|
-
return
|
|
896
|
-
t:
|
|
897
|
-
len: r === X.LEFT ?
|
|
929
|
+
}, C = new F(), A = N.getInstance();
|
|
930
|
+
return C.push({
|
|
931
|
+
t: y.RETAIN,
|
|
932
|
+
len: r === X.LEFT ? d - 1 : d,
|
|
898
933
|
segmentId: g
|
|
899
|
-
}),
|
|
900
|
-
t:
|
|
901
|
-
body:
|
|
902
|
-
len:
|
|
934
|
+
}), f.dataStream.length && C.push({
|
|
935
|
+
t: y.INSERT,
|
|
936
|
+
body: f,
|
|
937
|
+
len: f.dataStream.length,
|
|
903
938
|
line: 0,
|
|
904
939
|
segmentId: g
|
|
905
|
-
}),
|
|
906
|
-
t:
|
|
940
|
+
}), C.push({
|
|
941
|
+
t: y.RETAIN,
|
|
907
942
|
len: 1,
|
|
908
943
|
segmentId: g
|
|
909
|
-
}),
|
|
910
|
-
t:
|
|
911
|
-
len:
|
|
944
|
+
}), C.push({
|
|
945
|
+
t: y.DELETE,
|
|
946
|
+
len: h + 1 - S,
|
|
912
947
|
line: 0,
|
|
913
948
|
segmentId: g
|
|
914
|
-
}),
|
|
949
|
+
}), M.params.actions = A.editOp(C.serialize()), !!s.syncExecuteCommand(M.id, M.params);
|
|
915
950
|
}
|
|
916
951
|
};
|
|
917
|
-
function gn(
|
|
918
|
-
const { textRuns: n } =
|
|
952
|
+
function gn(o, e, t) {
|
|
953
|
+
const { textRuns: n } = o, s = o.dataStream.substring(e, t);
|
|
919
954
|
if (n == null)
|
|
920
955
|
return {
|
|
921
|
-
dataStream:
|
|
956
|
+
dataStream: s
|
|
922
957
|
};
|
|
923
958
|
const r = [];
|
|
924
959
|
for (const i of n) {
|
|
@@ -938,94 +973,82 @@ function gn(s, e, t) {
|
|
|
938
973
|
}));
|
|
939
974
|
}
|
|
940
975
|
return {
|
|
941
|
-
dataStream:
|
|
976
|
+
dataStream: s,
|
|
942
977
|
textRuns: r
|
|
943
978
|
};
|
|
944
979
|
}
|
|
945
|
-
function
|
|
946
|
-
let t =
|
|
947
|
-
for (const
|
|
948
|
-
const { startOffset: r, endOffset: i } =
|
|
949
|
-
r == null || i == null || i <=
|
|
980
|
+
function vt(o, e) {
|
|
981
|
+
let t = o.endOffset;
|
|
982
|
+
for (const s of e) {
|
|
983
|
+
const { startOffset: r, endOffset: i } = s;
|
|
984
|
+
r == null || i == null || i <= o.endOffset && (t -= i - r);
|
|
950
985
|
}
|
|
951
986
|
return [
|
|
952
987
|
{
|
|
953
988
|
startOffset: t,
|
|
954
989
|
endOffset: t,
|
|
955
|
-
style:
|
|
990
|
+
style: o.style
|
|
956
991
|
}
|
|
957
992
|
];
|
|
958
993
|
}
|
|
959
994
|
const It = {
|
|
960
995
|
id: "doc.command.ime-input",
|
|
961
|
-
type:
|
|
962
|
-
handler: async (
|
|
963
|
-
const { unitId: t, newText: n, oldTextLen:
|
|
964
|
-
if (
|
|
996
|
+
type: v.COMMAND,
|
|
997
|
+
handler: async (o, e) => {
|
|
998
|
+
const { unitId: t, newText: n, oldTextLen: s, isCompositionEnd: r, isCompositionStart: i } = e, a = o.get(I), c = o.get(Se), l = c.getActiveRange();
|
|
999
|
+
if (l == null)
|
|
965
1000
|
return !1;
|
|
966
|
-
const { startOffset:
|
|
1001
|
+
const { startOffset: d, style: u, segmentId: g } = l, m = n.length, S = [
|
|
967
1002
|
{
|
|
968
|
-
startOffset:
|
|
969
|
-
endOffset:
|
|
1003
|
+
startOffset: d + m,
|
|
1004
|
+
endOffset: d + m,
|
|
970
1005
|
collapsed: !0,
|
|
971
1006
|
style: u
|
|
972
1007
|
}
|
|
973
|
-
],
|
|
1008
|
+
], h = {
|
|
974
1009
|
id: B.id,
|
|
975
1010
|
params: {
|
|
976
1011
|
unitId: t,
|
|
977
1012
|
actions: [],
|
|
978
1013
|
textRanges: S
|
|
979
1014
|
}
|
|
980
|
-
},
|
|
981
|
-
!
|
|
982
|
-
t:
|
|
983
|
-
len:
|
|
1015
|
+
}, f = new F(), _ = N.getInstance();
|
|
1016
|
+
!l.collapsed && i ? f.push(...Pe(l, g)) : f.push({
|
|
1017
|
+
t: y.RETAIN,
|
|
1018
|
+
len: d,
|
|
984
1019
|
segmentId: g
|
|
985
|
-
}),
|
|
986
|
-
t:
|
|
987
|
-
len:
|
|
1020
|
+
}), s > 0 && f.push({
|
|
1021
|
+
t: y.DELETE,
|
|
1022
|
+
len: s,
|
|
988
1023
|
line: 0,
|
|
989
1024
|
segmentId: g
|
|
990
|
-
}),
|
|
991
|
-
t:
|
|
1025
|
+
}), f.push({
|
|
1026
|
+
t: y.INSERT,
|
|
992
1027
|
body: {
|
|
993
1028
|
dataStream: n
|
|
994
1029
|
},
|
|
995
1030
|
len: n.length,
|
|
996
1031
|
line: 0,
|
|
997
1032
|
segmentId: g
|
|
998
|
-
}),
|
|
999
|
-
const
|
|
1000
|
-
return c.pushUndoRedoMutationParams(
|
|
1033
|
+
}), h.params.actions = _.editOp(f.serialize()), h.params.noHistory = !r, h.params.isCompositionEnd = r;
|
|
1034
|
+
const p = a.syncExecuteCommand(h.id, h.params);
|
|
1035
|
+
return c.pushUndoRedoMutationParams(p, h.params), !!p;
|
|
1001
1036
|
}
|
|
1002
1037
|
};
|
|
1003
|
-
function $(
|
|
1038
|
+
function $(o, e, t, n) {
|
|
1004
1039
|
var r;
|
|
1005
|
-
const { segmentId:
|
|
1006
|
-
return
|
|
1007
|
-
segmentId:
|
|
1008
|
-
preCommandId:
|
|
1040
|
+
const { segmentId: s } = (r = t.getActiveRange()) != null ? r : {};
|
|
1041
|
+
return s == null ? !1 : n.executeCommand(Ct.id, {
|
|
1042
|
+
segmentId: s,
|
|
1043
|
+
preCommandId: o,
|
|
1009
1044
|
...e != null ? e : {}
|
|
1010
1045
|
});
|
|
1011
1046
|
}
|
|
1012
|
-
const
|
|
1013
|
-
id: tt,
|
|
1014
|
-
type: I.COMMAND,
|
|
1015
|
-
handler: async (s, e) => {
|
|
1016
|
-
const t = s.get(v), n = s.get(T);
|
|
1017
|
-
return $(
|
|
1018
|
-
tt,
|
|
1019
|
-
e,
|
|
1020
|
-
n,
|
|
1021
|
-
t
|
|
1022
|
-
);
|
|
1023
|
-
}
|
|
1024
|
-
}, nt = "doc.command.set-inline-format-italic", Be = {
|
|
1047
|
+
const nt = "doc.command.set-inline-format-bold", Be = {
|
|
1025
1048
|
id: nt,
|
|
1026
|
-
type:
|
|
1027
|
-
handler: async (
|
|
1028
|
-
const t =
|
|
1049
|
+
type: v.COMMAND,
|
|
1050
|
+
handler: async (o, e) => {
|
|
1051
|
+
const t = o.get(I), n = o.get(T);
|
|
1029
1052
|
return $(
|
|
1030
1053
|
nt,
|
|
1031
1054
|
e,
|
|
@@ -1033,35 +1056,35 @@ const tt = "doc.command.set-inline-format-bold", Le = {
|
|
|
1033
1056
|
t
|
|
1034
1057
|
);
|
|
1035
1058
|
}
|
|
1036
|
-
},
|
|
1037
|
-
id:
|
|
1038
|
-
type:
|
|
1039
|
-
handler: async (
|
|
1040
|
-
const t =
|
|
1059
|
+
}, ot = "doc.command.set-inline-format-italic", Fe = {
|
|
1060
|
+
id: ot,
|
|
1061
|
+
type: v.COMMAND,
|
|
1062
|
+
handler: async (o, e) => {
|
|
1063
|
+
const t = o.get(I), n = o.get(T);
|
|
1041
1064
|
return $(
|
|
1042
|
-
|
|
1065
|
+
ot,
|
|
1043
1066
|
e,
|
|
1044
1067
|
n,
|
|
1045
1068
|
t
|
|
1046
1069
|
);
|
|
1047
1070
|
}
|
|
1048
|
-
},
|
|
1049
|
-
id:
|
|
1050
|
-
type:
|
|
1051
|
-
handler: async (
|
|
1052
|
-
const t =
|
|
1071
|
+
}, st = "doc.command.set-inline-format-underline", $e = {
|
|
1072
|
+
id: st,
|
|
1073
|
+
type: v.COMMAND,
|
|
1074
|
+
handler: async (o, e) => {
|
|
1075
|
+
const t = o.get(I), n = o.get(T);
|
|
1053
1076
|
return $(
|
|
1054
|
-
|
|
1077
|
+
st,
|
|
1055
1078
|
e,
|
|
1056
1079
|
n,
|
|
1057
1080
|
t
|
|
1058
1081
|
);
|
|
1059
1082
|
}
|
|
1060
|
-
}, rt = "doc.command.set-inline-format-
|
|
1083
|
+
}, rt = "doc.command.set-inline-format-strikethrough", Ve = {
|
|
1061
1084
|
id: rt,
|
|
1062
|
-
type:
|
|
1063
|
-
handler: async (
|
|
1064
|
-
const t =
|
|
1085
|
+
type: v.COMMAND,
|
|
1086
|
+
handler: async (o, e) => {
|
|
1087
|
+
const t = o.get(I), n = o.get(T);
|
|
1065
1088
|
return $(
|
|
1066
1089
|
rt,
|
|
1067
1090
|
e,
|
|
@@ -1069,11 +1092,11 @@ const tt = "doc.command.set-inline-format-bold", Le = {
|
|
|
1069
1092
|
t
|
|
1070
1093
|
);
|
|
1071
1094
|
}
|
|
1072
|
-
}, it = "doc.command.set-inline-format-
|
|
1095
|
+
}, it = "doc.command.set-inline-format-subscript", se = {
|
|
1073
1096
|
id: it,
|
|
1074
|
-
type:
|
|
1075
|
-
handler: async (
|
|
1076
|
-
const t =
|
|
1097
|
+
type: v.COMMAND,
|
|
1098
|
+
handler: async (o, e) => {
|
|
1099
|
+
const t = o.get(I), n = o.get(T);
|
|
1077
1100
|
return $(
|
|
1078
1101
|
it,
|
|
1079
1102
|
e,
|
|
@@ -1081,11 +1104,11 @@ const tt = "doc.command.set-inline-format-bold", Le = {
|
|
|
1081
1104
|
t
|
|
1082
1105
|
);
|
|
1083
1106
|
}
|
|
1084
|
-
}, at = "doc.command.set-inline-format-
|
|
1107
|
+
}, at = "doc.command.set-inline-format-superscript", ke = {
|
|
1085
1108
|
id: at,
|
|
1086
|
-
type:
|
|
1087
|
-
handler: async (
|
|
1088
|
-
const t =
|
|
1109
|
+
type: v.COMMAND,
|
|
1110
|
+
handler: async (o, e) => {
|
|
1111
|
+
const t = o.get(I), n = o.get(T);
|
|
1089
1112
|
return $(
|
|
1090
1113
|
at,
|
|
1091
1114
|
e,
|
|
@@ -1093,11 +1116,11 @@ const tt = "doc.command.set-inline-format-bold", Le = {
|
|
|
1093
1116
|
t
|
|
1094
1117
|
);
|
|
1095
1118
|
}
|
|
1096
|
-
}, ct = "doc.command.set-inline-format-
|
|
1119
|
+
}, ct = "doc.command.set-inline-format-fontsize", ze = {
|
|
1097
1120
|
id: ct,
|
|
1098
|
-
type:
|
|
1099
|
-
handler: async (
|
|
1100
|
-
const t =
|
|
1121
|
+
type: v.COMMAND,
|
|
1122
|
+
handler: async (o, e) => {
|
|
1123
|
+
const t = o.get(I), n = o.get(T);
|
|
1101
1124
|
return $(
|
|
1102
1125
|
ct,
|
|
1103
1126
|
e,
|
|
@@ -1105,11 +1128,11 @@ const tt = "doc.command.set-inline-format-bold", Le = {
|
|
|
1105
1128
|
t
|
|
1106
1129
|
);
|
|
1107
1130
|
}
|
|
1108
|
-
}, lt = "doc.command.set-inline-format-
|
|
1131
|
+
}, lt = "doc.command.set-inline-format-font-family", je = {
|
|
1109
1132
|
id: lt,
|
|
1110
|
-
type:
|
|
1111
|
-
handler: async (
|
|
1112
|
-
const t =
|
|
1133
|
+
type: v.COMMAND,
|
|
1134
|
+
handler: async (o, e) => {
|
|
1135
|
+
const t = o.get(I), n = o.get(T);
|
|
1113
1136
|
return $(
|
|
1114
1137
|
lt,
|
|
1115
1138
|
e,
|
|
@@ -1117,11 +1140,11 @@ const tt = "doc.command.set-inline-format-bold", Le = {
|
|
|
1117
1140
|
t
|
|
1118
1141
|
);
|
|
1119
1142
|
}
|
|
1120
|
-
}, dt = "doc.command.set-inline-format-text-
|
|
1143
|
+
}, dt = "doc.command.set-inline-format-text-color", Ge = {
|
|
1121
1144
|
id: dt,
|
|
1122
|
-
type:
|
|
1123
|
-
handler: async (
|
|
1124
|
-
const t =
|
|
1145
|
+
type: v.COMMAND,
|
|
1146
|
+
handler: async (o, e) => {
|
|
1147
|
+
const t = o.get(I), n = o.get(T);
|
|
1125
1148
|
return $(
|
|
1126
1149
|
dt,
|
|
1127
1150
|
e,
|
|
@@ -1129,11 +1152,11 @@ const tt = "doc.command.set-inline-format-bold", Le = {
|
|
|
1129
1152
|
t
|
|
1130
1153
|
);
|
|
1131
1154
|
}
|
|
1132
|
-
}, ut = "doc.command.
|
|
1155
|
+
}, ut = "doc.command.set-inline-format-text-background-color", Xe = {
|
|
1133
1156
|
id: ut,
|
|
1134
|
-
type:
|
|
1135
|
-
handler: async (
|
|
1136
|
-
const t =
|
|
1157
|
+
type: v.COMMAND,
|
|
1158
|
+
handler: async (o, e) => {
|
|
1159
|
+
const t = o.get(I), n = o.get(T);
|
|
1137
1160
|
return $(
|
|
1138
1161
|
ut,
|
|
1139
1162
|
e,
|
|
@@ -1141,174 +1164,186 @@ const tt = "doc.command.set-inline-format-bold", Le = {
|
|
|
1141
1164
|
t
|
|
1142
1165
|
);
|
|
1143
1166
|
}
|
|
1144
|
-
},
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1167
|
+
}, gt = "doc.command.reset-inline-format-text-background-color", He = {
|
|
1168
|
+
id: gt,
|
|
1169
|
+
type: v.COMMAND,
|
|
1170
|
+
handler: async (o, e) => {
|
|
1171
|
+
const t = o.get(I), n = o.get(T);
|
|
1172
|
+
return $(
|
|
1173
|
+
gt,
|
|
1174
|
+
e,
|
|
1175
|
+
n,
|
|
1176
|
+
t
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1156
1179
|
}, Mt = {
|
|
1180
|
+
[Be.id]: "bl",
|
|
1181
|
+
[Fe.id]: "it",
|
|
1182
|
+
[$e.id]: "ul",
|
|
1183
|
+
[Ve.id]: "st",
|
|
1184
|
+
[ze.id]: "fs",
|
|
1185
|
+
[je.id]: "ff",
|
|
1186
|
+
[Ge.id]: "cl",
|
|
1187
|
+
[Xe.id]: "bg",
|
|
1188
|
+
[He.id]: "bg",
|
|
1189
|
+
[se.id]: "va",
|
|
1190
|
+
[ke.id]: "va"
|
|
1191
|
+
}, Ct = {
|
|
1157
1192
|
id: "doc.command.set-inline-format",
|
|
1158
|
-
type:
|
|
1193
|
+
type: v.COMMAND,
|
|
1159
1194
|
// eslint-disable-next-line max-lines-per-function
|
|
1160
|
-
handler: async (
|
|
1161
|
-
const { segmentId: t, value: n, preCommandId:
|
|
1195
|
+
handler: async (o, e) => {
|
|
1196
|
+
const { segmentId: t, value: n, preCommandId: s } = e, r = o.get(I), i = o.get(T), a = o.get(D), c = i.getSelections();
|
|
1162
1197
|
if (!Array.isArray(c) || c.length === 0)
|
|
1163
1198
|
return !1;
|
|
1164
|
-
const
|
|
1165
|
-
if (!
|
|
1199
|
+
const l = a.getCurrentUniverDocInstance();
|
|
1200
|
+
if (!l)
|
|
1166
1201
|
return !1;
|
|
1167
|
-
const
|
|
1202
|
+
const d = l.getUnitId();
|
|
1168
1203
|
let u;
|
|
1169
|
-
switch (
|
|
1170
|
-
case Le.id:
|
|
1204
|
+
switch (s) {
|
|
1171
1205
|
case Be.id:
|
|
1172
1206
|
case Fe.id:
|
|
1173
1207
|
case $e.id:
|
|
1174
|
-
case
|
|
1175
|
-
case
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1208
|
+
case Ve.id:
|
|
1209
|
+
case se.id:
|
|
1210
|
+
case ke.id: {
|
|
1211
|
+
u = hn(
|
|
1212
|
+
l.getBody().textRuns,
|
|
1213
|
+
s,
|
|
1179
1214
|
c
|
|
1180
1215
|
);
|
|
1181
1216
|
break;
|
|
1182
1217
|
}
|
|
1183
|
-
case
|
|
1184
|
-
case
|
|
1218
|
+
case ze.id:
|
|
1219
|
+
case je.id: {
|
|
1185
1220
|
u = n;
|
|
1186
1221
|
break;
|
|
1187
1222
|
}
|
|
1188
|
-
case
|
|
1189
|
-
case
|
|
1223
|
+
case Ge.id:
|
|
1224
|
+
case Xe.id: {
|
|
1190
1225
|
u = {
|
|
1191
1226
|
rgb: n
|
|
1192
1227
|
};
|
|
1193
1228
|
break;
|
|
1194
1229
|
}
|
|
1195
|
-
case
|
|
1230
|
+
case He.id: {
|
|
1196
1231
|
u = {
|
|
1197
1232
|
rgb: null
|
|
1198
1233
|
};
|
|
1199
1234
|
break;
|
|
1200
1235
|
}
|
|
1201
1236
|
default:
|
|
1202
|
-
throw new Error(`Unknown command: ${
|
|
1237
|
+
throw new Error(`Unknown command: ${s} in handleInlineFormat`);
|
|
1203
1238
|
}
|
|
1204
1239
|
const g = {
|
|
1205
1240
|
id: B.id,
|
|
1206
1241
|
params: {
|
|
1207
|
-
unitId:
|
|
1242
|
+
unitId: d,
|
|
1208
1243
|
actions: [],
|
|
1209
1244
|
textRanges: c.map(J)
|
|
1210
1245
|
}
|
|
1211
|
-
}, m = new F(), S =
|
|
1212
|
-
|
|
1246
|
+
}, m = new F(), S = N.getInstance(), h = new re();
|
|
1247
|
+
h.reset();
|
|
1213
1248
|
for (const _ of c) {
|
|
1214
|
-
const { startOffset:
|
|
1249
|
+
const { startOffset: p, endOffset: x } = _, M = {
|
|
1215
1250
|
dataStream: "",
|
|
1216
1251
|
textRuns: [
|
|
1217
1252
|
{
|
|
1218
1253
|
st: 0,
|
|
1219
|
-
ed:
|
|
1254
|
+
ed: x - p,
|
|
1220
1255
|
ts: {
|
|
1221
|
-
[
|
|
1256
|
+
[Mt[s]]: u
|
|
1222
1257
|
}
|
|
1223
1258
|
}
|
|
1224
1259
|
]
|
|
1225
|
-
},
|
|
1226
|
-
|
|
1227
|
-
t:
|
|
1228
|
-
len:
|
|
1260
|
+
}, C = p - h.cursor;
|
|
1261
|
+
C !== 0 && m.push({
|
|
1262
|
+
t: y.RETAIN,
|
|
1263
|
+
len: C,
|
|
1229
1264
|
segmentId: t
|
|
1230
1265
|
}), m.push({
|
|
1231
|
-
t:
|
|
1232
|
-
body:
|
|
1233
|
-
len:
|
|
1266
|
+
t: y.RETAIN,
|
|
1267
|
+
body: M,
|
|
1268
|
+
len: x - p,
|
|
1234
1269
|
segmentId: t
|
|
1235
|
-
}),
|
|
1270
|
+
}), h.reset(), h.moveCursor(x);
|
|
1236
1271
|
}
|
|
1237
1272
|
return g.params.actions = S.editOp(m.serialize()), !!r.syncExecuteCommand(g.id, g.params);
|
|
1238
1273
|
}
|
|
1239
1274
|
};
|
|
1240
|
-
function mn(
|
|
1241
|
-
return
|
|
1275
|
+
function mn(o) {
|
|
1276
|
+
return o !== null && typeof o == "object";
|
|
1242
1277
|
}
|
|
1243
|
-
function
|
|
1244
|
-
let n = 0,
|
|
1245
|
-
const r =
|
|
1246
|
-
for (; n !==
|
|
1247
|
-
const { startOffset: i, endOffset: a } = t[
|
|
1278
|
+
function hn(o, e, t) {
|
|
1279
|
+
let n = 0, s = 0;
|
|
1280
|
+
const r = Mt[e];
|
|
1281
|
+
for (; n !== o.length && s !== t.length; ) {
|
|
1282
|
+
const { startOffset: i, endOffset: a } = t[s], { st: c, ed: l, ts: d } = o[n];
|
|
1248
1283
|
if (a <= c)
|
|
1249
|
-
|
|
1250
|
-
else if (
|
|
1284
|
+
s++;
|
|
1285
|
+
else if (l <= i)
|
|
1251
1286
|
n++;
|
|
1252
1287
|
else {
|
|
1253
1288
|
if (/bl|it/.test(r))
|
|
1254
|
-
return (
|
|
1289
|
+
return (d == null ? void 0 : d[r]) === j.TRUE ? j.FALSE : j.TRUE;
|
|
1255
1290
|
if (/ul|st/.test(r))
|
|
1256
|
-
return mn(
|
|
1291
|
+
return mn(d == null ? void 0 : d[r]) && (d == null ? void 0 : d[r]).s === j.TRUE ? {
|
|
1257
1292
|
s: j.FALSE
|
|
1258
1293
|
} : {
|
|
1259
1294
|
s: j.TRUE
|
|
1260
1295
|
};
|
|
1261
1296
|
if (/va/.test(r))
|
|
1262
|
-
return e ===
|
|
1297
|
+
return e === se.id ? (d == null ? void 0 : d[r]) === G.SUBSCRIPT ? G.NORMAL : G.SUBSCRIPT : (d == null ? void 0 : d[r]) === G.SUPERSCRIPT ? G.NORMAL : G.SUPERSCRIPT;
|
|
1263
1298
|
n++;
|
|
1264
1299
|
}
|
|
1265
1300
|
}
|
|
1266
1301
|
return /bl|it/.test(r) ? j.TRUE : /ul|st/.test(r) ? {
|
|
1267
1302
|
s: j.TRUE
|
|
1268
|
-
} : e ===
|
|
1303
|
+
} : e === se.id ? G.SUBSCRIPT : G.SUPERSCRIPT;
|
|
1269
1304
|
}
|
|
1270
|
-
const
|
|
1305
|
+
const Ye = {
|
|
1271
1306
|
id: "doc.command.list-operation",
|
|
1272
|
-
type:
|
|
1307
|
+
type: v.COMMAND,
|
|
1273
1308
|
// eslint-disable-next-line max-lines-per-function
|
|
1274
|
-
handler: (
|
|
1275
|
-
var
|
|
1276
|
-
const t =
|
|
1309
|
+
handler: (o, e) => {
|
|
1310
|
+
var b, L, Y, ce;
|
|
1311
|
+
const t = o.get(T), n = o.get(D), s = o.get(I), { listType: r } = e, i = n.getCurrentUniverDocInstance();
|
|
1277
1312
|
if (!i)
|
|
1278
1313
|
return !1;
|
|
1279
|
-
const a = t.getActiveRange(), c = (
|
|
1280
|
-
if (a == null ||
|
|
1314
|
+
const a = t.getActiveRange(), c = (b = t.getSelections()) != null ? b : [], l = (L = i.getBody()) == null ? void 0 : L.paragraphs, d = c.map(J);
|
|
1315
|
+
if (a == null || l == null)
|
|
1281
1316
|
return !1;
|
|
1282
|
-
const u =
|
|
1317
|
+
const u = Rt(a, l), { segmentId: g } = a, m = i.getUnitId(), S = u.every((W) => {
|
|
1283
1318
|
var V;
|
|
1284
1319
|
return ((V = W.bullet) == null ? void 0 : V.listType) === r;
|
|
1285
1320
|
});
|
|
1286
|
-
let
|
|
1321
|
+
let f = ee.generateRandomId(6);
|
|
1287
1322
|
if (u.length === 1) {
|
|
1288
|
-
const W =
|
|
1289
|
-
V && V.bullet && V.bullet.listType === r ?
|
|
1323
|
+
const W = l.indexOf(u[0]), V = l[W - 1], z = l[W + 1];
|
|
1324
|
+
V && V.bullet && V.bullet.listType === r ? f = V.bullet.listId : z && z.bullet && z.bullet.listType === r && (f = z.bullet.listId);
|
|
1290
1325
|
}
|
|
1291
1326
|
const _ = {
|
|
1292
1327
|
id: B.id,
|
|
1293
1328
|
params: {
|
|
1294
1329
|
unitId: m,
|
|
1295
1330
|
actions: [],
|
|
1296
|
-
textRanges:
|
|
1331
|
+
textRanges: d
|
|
1297
1332
|
}
|
|
1298
|
-
},
|
|
1299
|
-
|
|
1300
|
-
const
|
|
1301
|
-
...
|
|
1302
|
-
...
|
|
1303
|
-
}, { charSpace:
|
|
1333
|
+
}, p = new re();
|
|
1334
|
+
p.reset();
|
|
1335
|
+
const x = new F(), M = N.getInstance(), C = (Y = i.getSnapshot().lists) != null ? Y : {}, A = {
|
|
1336
|
+
...bt,
|
|
1337
|
+
...C
|
|
1338
|
+
}, { charSpace: E, defaultTabStop: w = 36, gridType: U } = i.getSnapshot().documentStyle;
|
|
1304
1339
|
for (const W of u) {
|
|
1305
|
-
const { startIndex: V, paragraphStyle: z = {} } = W, { indentFirstLine:
|
|
1306
|
-
|
|
1307
|
-
t:
|
|
1308
|
-
len: V -
|
|
1340
|
+
const { startIndex: V, paragraphStyle: z = {} } = W, { indentFirstLine: yt = 0, snapToGrid: Ot, indentStart: _e = 0 } = z, { hanging: ve, indentStart: We } = A[r].nestingLevel[0], Ie = kt(E, w, U, Ot);
|
|
1341
|
+
x.push({
|
|
1342
|
+
t: y.RETAIN,
|
|
1343
|
+
len: V - p.cursor,
|
|
1309
1344
|
segmentId: g
|
|
1310
|
-
}),
|
|
1311
|
-
t:
|
|
1345
|
+
}), x.push({
|
|
1346
|
+
t: y.RETAIN,
|
|
1312
1347
|
len: 1,
|
|
1313
1348
|
body: {
|
|
1314
1349
|
dataStream: "",
|
|
@@ -1317,7 +1352,7 @@ const He = {
|
|
|
1317
1352
|
paragraphStyle: {
|
|
1318
1353
|
...z,
|
|
1319
1354
|
hanging: void 0,
|
|
1320
|
-
indentStart:
|
|
1355
|
+
indentStart: _e ? Math.max(0, Me(_e, Ie) + ve - We) : void 0
|
|
1321
1356
|
},
|
|
1322
1357
|
startIndex: 0
|
|
1323
1358
|
} : {
|
|
@@ -1326,195 +1361,193 @@ const He = {
|
|
|
1326
1361
|
...z,
|
|
1327
1362
|
indentFirstLine: void 0,
|
|
1328
1363
|
hanging: ve,
|
|
1329
|
-
indentStart: We - ve +
|
|
1364
|
+
indentStart: We - ve + Me(yt, Ie) + Me(_e, Ie)
|
|
1330
1365
|
},
|
|
1331
1366
|
bullet: {
|
|
1332
|
-
...(
|
|
1367
|
+
...(ce = W.bullet) != null ? ce : {
|
|
1333
1368
|
nestingLevel: 0,
|
|
1334
1369
|
textStyle: {
|
|
1335
1370
|
fs: 20
|
|
1336
1371
|
}
|
|
1337
1372
|
},
|
|
1338
1373
|
listType: r,
|
|
1339
|
-
listId:
|
|
1374
|
+
listId: f
|
|
1340
1375
|
}
|
|
1341
1376
|
}
|
|
1342
1377
|
]
|
|
1343
1378
|
},
|
|
1344
1379
|
segmentId: g,
|
|
1345
|
-
coverType:
|
|
1346
|
-
}),
|
|
1380
|
+
coverType: Ee.REPLACE
|
|
1381
|
+
}), p.moveCursorTo(V + 1);
|
|
1347
1382
|
}
|
|
1348
|
-
return _.params.actions =
|
|
1383
|
+
return _.params.actions = M.editOp(x.serialize()), !!s.syncExecuteCommand(_.id, _.params);
|
|
1349
1384
|
}
|
|
1350
|
-
},
|
|
1385
|
+
}, fn = {
|
|
1351
1386
|
id: "doc.command.bullet-list",
|
|
1352
|
-
type:
|
|
1353
|
-
handler: (
|
|
1354
|
-
listType:
|
|
1387
|
+
type: v.COMMAND,
|
|
1388
|
+
handler: (o) => o.get(I).syncExecuteCommand(Ye.id, {
|
|
1389
|
+
listType: ht.BULLET_LIST
|
|
1355
1390
|
})
|
|
1356
|
-
},
|
|
1391
|
+
}, pn = {
|
|
1357
1392
|
id: "doc.command.order-list",
|
|
1358
|
-
type:
|
|
1359
|
-
handler: (
|
|
1360
|
-
listType:
|
|
1393
|
+
type: v.COMMAND,
|
|
1394
|
+
handler: (o) => o.get(I).syncExecuteCommand(Ye.id, {
|
|
1395
|
+
listType: ht.ORDER_LIST
|
|
1361
1396
|
})
|
|
1362
1397
|
};
|
|
1363
|
-
function
|
|
1364
|
-
const { startOffset: t, endOffset: n } =
|
|
1398
|
+
function Rt(o, e) {
|
|
1399
|
+
const { startOffset: t, endOffset: n } = o, s = [];
|
|
1365
1400
|
let r = -1;
|
|
1366
1401
|
for (const i of e) {
|
|
1367
1402
|
const { startIndex: a } = i;
|
|
1368
|
-
(t > r && t <= a || n > r && n <= a || a >= t && a <= n) &&
|
|
1403
|
+
(t > r && t <= a || n > r && n <= a || a >= t && a <= n) && s.push(i), r = a;
|
|
1369
1404
|
}
|
|
1370
|
-
return
|
|
1405
|
+
return s;
|
|
1371
1406
|
}
|
|
1372
1407
|
const ae = {
|
|
1373
1408
|
id: "doc.command.align-operation",
|
|
1374
|
-
type:
|
|
1409
|
+
type: v.COMMAND,
|
|
1375
1410
|
// eslint-disable-next-line max-lines-per-function
|
|
1376
|
-
handler: (
|
|
1377
|
-
var
|
|
1378
|
-
const t =
|
|
1379
|
-
if (!i)
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
return ((D = A.paragraphStyle) == null ? void 0 : D.horizontalAlign) === r;
|
|
1387
|
-
}), f = {
|
|
1411
|
+
handler: (o, e) => {
|
|
1412
|
+
var M, C;
|
|
1413
|
+
const t = o.get(T), n = o.get(D), s = o.get(I), { alignType: r } = e, i = n.getCurrentUniverDocInstance();
|
|
1414
|
+
if (!i) return !1;
|
|
1415
|
+
const a = t.getActiveRange(), c = (M = t.getSelections()) != null ? M : [], l = (C = i.getBody()) == null ? void 0 : C.paragraphs, d = c.map(J);
|
|
1416
|
+
if (a == null || l == null) return !1;
|
|
1417
|
+
const u = Rt(a, l), { segmentId: g } = a, m = i.getUnitId(), S = u.every((A) => {
|
|
1418
|
+
var E;
|
|
1419
|
+
return ((E = A.paragraphStyle) == null ? void 0 : E.horizontalAlign) === r;
|
|
1420
|
+
}), h = {
|
|
1388
1421
|
id: B.id,
|
|
1389
1422
|
params: {
|
|
1390
1423
|
unitId: m,
|
|
1391
1424
|
actions: [],
|
|
1392
|
-
textRanges:
|
|
1425
|
+
textRanges: d
|
|
1393
1426
|
}
|
|
1394
|
-
},
|
|
1395
|
-
|
|
1396
|
-
const _ = new F(),
|
|
1427
|
+
}, f = new re();
|
|
1428
|
+
f.reset();
|
|
1429
|
+
const _ = new F(), p = N.getInstance();
|
|
1397
1430
|
for (const A of u) {
|
|
1398
|
-
const { startIndex:
|
|
1431
|
+
const { startIndex: E } = A;
|
|
1399
1432
|
_.push({
|
|
1400
|
-
t:
|
|
1401
|
-
len:
|
|
1433
|
+
t: y.RETAIN,
|
|
1434
|
+
len: E - f.cursor,
|
|
1402
1435
|
segmentId: g
|
|
1403
1436
|
});
|
|
1404
|
-
const
|
|
1437
|
+
const w = {
|
|
1405
1438
|
...A.paragraphStyle,
|
|
1406
1439
|
horizontalAlign: S ? ie.UNSPECIFIED : r
|
|
1407
1440
|
};
|
|
1408
1441
|
_.push({
|
|
1409
|
-
t:
|
|
1442
|
+
t: y.RETAIN,
|
|
1410
1443
|
len: 1,
|
|
1411
1444
|
body: {
|
|
1412
1445
|
dataStream: "",
|
|
1413
1446
|
paragraphs: [
|
|
1414
1447
|
{
|
|
1415
1448
|
...A,
|
|
1416
|
-
paragraphStyle:
|
|
1449
|
+
paragraphStyle: w,
|
|
1417
1450
|
startIndex: 0
|
|
1418
1451
|
}
|
|
1419
1452
|
]
|
|
1420
1453
|
},
|
|
1421
1454
|
segmentId: g,
|
|
1422
|
-
coverType:
|
|
1423
|
-
}),
|
|
1455
|
+
coverType: Ee.REPLACE
|
|
1456
|
+
}), f.moveCursorTo(E + 1);
|
|
1424
1457
|
}
|
|
1425
|
-
return
|
|
1458
|
+
return h.params.actions = p.editOp(_.serialize()), !!s.syncExecuteCommand(h.id, h.params);
|
|
1426
1459
|
}
|
|
1427
1460
|
}, Sn = {
|
|
1428
1461
|
id: "doc.command.align-left",
|
|
1429
|
-
type:
|
|
1430
|
-
handler: (
|
|
1462
|
+
type: v.COMMAND,
|
|
1463
|
+
handler: (o) => o.get(I).syncExecuteCommand(ae.id, {
|
|
1431
1464
|
alignType: ie.LEFT
|
|
1432
1465
|
})
|
|
1433
1466
|
}, _n = {
|
|
1434
1467
|
id: "doc.command.align-center",
|
|
1435
|
-
type:
|
|
1436
|
-
handler: (
|
|
1468
|
+
type: v.COMMAND,
|
|
1469
|
+
handler: (o) => o.get(I).syncExecuteCommand(ae.id, {
|
|
1437
1470
|
alignType: ie.CENTER
|
|
1438
1471
|
})
|
|
1439
|
-
},
|
|
1472
|
+
}, vn = {
|
|
1440
1473
|
id: "doc.command.align-right",
|
|
1441
|
-
type:
|
|
1442
|
-
handler: (
|
|
1474
|
+
type: v.COMMAND,
|
|
1475
|
+
handler: (o) => o.get(I).syncExecuteCommand(ae.id, {
|
|
1443
1476
|
alignType: ie.RIGHT
|
|
1444
1477
|
})
|
|
1445
|
-
},
|
|
1478
|
+
}, In = {
|
|
1446
1479
|
id: "doc.command.align-justify",
|
|
1447
|
-
type:
|
|
1448
|
-
handler: (
|
|
1480
|
+
type: v.COMMAND,
|
|
1481
|
+
handler: (o) => o.get(I).syncExecuteCommand(ae.id, {
|
|
1449
1482
|
alignType: ie.JUSTIFIED
|
|
1450
1483
|
})
|
|
1451
1484
|
}, Mn = {
|
|
1452
1485
|
id: "doc.command-replace-content",
|
|
1453
|
-
type:
|
|
1454
|
-
handler: async (
|
|
1486
|
+
type: v.COMMAND,
|
|
1487
|
+
handler: async (o, e) => {
|
|
1455
1488
|
var m;
|
|
1456
|
-
const { unitId: t, body: n, textRanges:
|
|
1457
|
-
if (
|
|
1489
|
+
const { unitId: t, body: n, textRanges: s, segmentId: r = "" } = e, i = o.get(D), a = o.get(I), c = o.get(T), l = (m = i.getUniverDocInstance(t)) == null ? void 0 : m.getSnapshot().body, d = c.getSelections();
|
|
1490
|
+
if (l == null || !Array.isArray(d) || d.length === 0)
|
|
1458
1491
|
return !1;
|
|
1459
|
-
const u =
|
|
1460
|
-
return u.params.textRanges =
|
|
1492
|
+
const u = xt(t, r, l, n);
|
|
1493
|
+
return u.params.textRanges = s, !!a.syncExecuteCommand(u.id, u.params);
|
|
1461
1494
|
}
|
|
1462
1495
|
}, Cn = {
|
|
1463
1496
|
id: "doc.command-cover-content",
|
|
1464
|
-
type:
|
|
1465
|
-
handler: async (
|
|
1466
|
-
var
|
|
1467
|
-
const { unitId: t, body: n, segmentId:
|
|
1497
|
+
type: v.COMMAND,
|
|
1498
|
+
handler: async (o, e) => {
|
|
1499
|
+
var d;
|
|
1500
|
+
const { unitId: t, body: n, segmentId: s = "" } = e, r = o.get(D), i = o.get(I), a = o.get(Te), c = (d = r.getUniverDocInstance(t)) == null ? void 0 : d.getSnapshot().body;
|
|
1468
1501
|
if (c == null)
|
|
1469
1502
|
return !1;
|
|
1470
|
-
const
|
|
1471
|
-
return
|
|
1472
|
-
|
|
1473
|
-
|
|
1503
|
+
const l = xt(t, s, c, n);
|
|
1504
|
+
return l.params.noNeedSetTextRange = !0, l.params.noHistory = !0, i.syncExecuteCommand(
|
|
1505
|
+
l.id,
|
|
1506
|
+
l.params
|
|
1474
1507
|
), a.clearUndoRedo(t), !0;
|
|
1475
1508
|
}
|
|
1476
1509
|
};
|
|
1477
|
-
function
|
|
1478
|
-
const
|
|
1510
|
+
function xt(o, e, t, n) {
|
|
1511
|
+
const s = {
|
|
1479
1512
|
id: B.id,
|
|
1480
1513
|
params: {
|
|
1481
|
-
unitId:
|
|
1514
|
+
unitId: o,
|
|
1482
1515
|
actions: [],
|
|
1483
1516
|
textRanges: []
|
|
1484
1517
|
}
|
|
1485
|
-
}, r = new F(), i =
|
|
1518
|
+
}, r = new F(), i = N.getInstance(), a = (t == null ? void 0 : t.dataStream.length) - 2;
|
|
1486
1519
|
return a > 0 && r.push({
|
|
1487
|
-
t:
|
|
1520
|
+
t: y.DELETE,
|
|
1488
1521
|
len: a,
|
|
1489
1522
|
line: 0,
|
|
1490
1523
|
segmentId: e
|
|
1491
1524
|
}), n.dataStream.length > 0 && r.push({
|
|
1492
|
-
t:
|
|
1525
|
+
t: y.INSERT,
|
|
1493
1526
|
body: n,
|
|
1494
1527
|
len: n.dataStream.length,
|
|
1495
1528
|
line: 0,
|
|
1496
1529
|
segmentId: e
|
|
1497
|
-
}),
|
|
1530
|
+
}), s.params.actions = i.editOp(r.serialize()), s;
|
|
1498
1531
|
}
|
|
1499
|
-
const
|
|
1532
|
+
const ye = {
|
|
1500
1533
|
id: "doc.operation.move-cursor",
|
|
1501
|
-
type:
|
|
1502
|
-
handler: (
|
|
1503
|
-
},
|
|
1534
|
+
type: v.OPERATION,
|
|
1535
|
+
handler: (o, e) => !!e
|
|
1536
|
+
}, Oe = {
|
|
1504
1537
|
id: "doc.operation.move-selection",
|
|
1505
|
-
type:
|
|
1506
|
-
handler: (
|
|
1507
|
-
}, Rn = (
|
|
1508
|
-
const t =
|
|
1538
|
+
type: v.OPERATION,
|
|
1539
|
+
handler: (o, e) => !!e
|
|
1540
|
+
}, Rn = (o, e) => {
|
|
1541
|
+
const t = o.get(D).getUniverDocInstance(e.unitId), n = (t == null ? void 0 : t.zoomRatio) || 1;
|
|
1509
1542
|
return {
|
|
1510
1543
|
...ee.deepClone(e),
|
|
1511
1544
|
zoomRatio: n
|
|
1512
1545
|
};
|
|
1513
|
-
},
|
|
1546
|
+
}, de = {
|
|
1514
1547
|
id: "doc.operation.set-zoom-ratio",
|
|
1515
|
-
type:
|
|
1516
|
-
handler: (
|
|
1517
|
-
const t =
|
|
1548
|
+
type: v.OPERATION,
|
|
1549
|
+
handler: (o, e) => {
|
|
1550
|
+
const t = o.get(D).getUniverDocInstance(e.unitId);
|
|
1518
1551
|
if (!t)
|
|
1519
1552
|
return !1;
|
|
1520
1553
|
const n = t.getSnapshot();
|
|
@@ -1523,60 +1556,56 @@ const Oe = {
|
|
|
1523
1556
|
} : n.settings.zoomRatio = e.zoomRatio, !0;
|
|
1524
1557
|
}
|
|
1525
1558
|
}, xn = {
|
|
1526
|
-
type:
|
|
1559
|
+
type: v.COMMAND,
|
|
1527
1560
|
id: "doc.command.set-zoom-ratio",
|
|
1528
|
-
handler: async (
|
|
1561
|
+
handler: async (o, e) => {
|
|
1529
1562
|
var u, g, m;
|
|
1530
|
-
const t =
|
|
1531
|
-
let r = (u =
|
|
1532
|
-
if (!r)
|
|
1533
|
-
return !1;
|
|
1563
|
+
const t = o.get(I), n = o.get(Te), s = o.get(D);
|
|
1564
|
+
let r = (u = s.getCurrentUniverDocInstance()) == null ? void 0 : u.getUnitId();
|
|
1565
|
+
if (!r) return !1;
|
|
1534
1566
|
let i = 1;
|
|
1535
|
-
if (e && (r = (g = e.documentId) != null ? g : r, i = (m = e.zoomRatio) != null ? m : i), !
|
|
1536
|
-
return !1;
|
|
1567
|
+
if (e && (r = (g = e.documentId) != null ? g : r, i = (m = e.zoomRatio) != null ? m : i), !s.getUniverDocInstance(r)) return !1;
|
|
1537
1568
|
const c = {
|
|
1538
1569
|
zoomRatio: i,
|
|
1539
1570
|
unitId: r
|
|
1540
|
-
},
|
|
1541
|
-
return t.syncExecuteCommand(
|
|
1571
|
+
}, l = Rn(o, c);
|
|
1572
|
+
return t.syncExecuteCommand(de.id, c) ? (n.pushUndoRedo({
|
|
1542
1573
|
unitID: r,
|
|
1543
|
-
undoMutations: [{ id:
|
|
1544
|
-
redoMutations: [{ id:
|
|
1574
|
+
undoMutations: [{ id: de.id, params: l }],
|
|
1575
|
+
redoMutations: [{ id: de.id, params: c }]
|
|
1545
1576
|
}), !0) : !1;
|
|
1546
1577
|
}
|
|
1547
1578
|
}, yn = {
|
|
1548
1579
|
id: "doc.operation.select-all",
|
|
1549
|
-
type:
|
|
1550
|
-
handler: async (
|
|
1551
|
-
const e =
|
|
1552
|
-
if (!n)
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
if (o == null)
|
|
1556
|
-
return !1;
|
|
1580
|
+
type: v.COMMAND,
|
|
1581
|
+
handler: async (o) => {
|
|
1582
|
+
const e = o.get(D), t = o.get(T), n = e.getCurrentUniverDocInstance();
|
|
1583
|
+
if (!n) return !1;
|
|
1584
|
+
const s = n.getSnapshot().body;
|
|
1585
|
+
if (s == null) return !1;
|
|
1557
1586
|
const r = [
|
|
1558
1587
|
{
|
|
1559
1588
|
startOffset: 0,
|
|
1560
|
-
endOffset:
|
|
1589
|
+
endOffset: s.dataStream.length - 2
|
|
1561
1590
|
}
|
|
1562
1591
|
];
|
|
1563
1592
|
return t.replaceTextRanges(r, !1), !0;
|
|
1564
1593
|
}
|
|
1565
1594
|
};
|
|
1566
|
-
var On = Object.defineProperty, Tn = Object.getOwnPropertyDescriptor, En = (
|
|
1567
|
-
for (var
|
|
1568
|
-
(i =
|
|
1569
|
-
return n &&
|
|
1570
|
-
}, K = (
|
|
1571
|
-
let
|
|
1572
|
-
constructor(e, t, n,
|
|
1595
|
+
var On = Object.defineProperty, Tn = Object.getOwnPropertyDescriptor, En = (o, e, t, n) => {
|
|
1596
|
+
for (var s = n > 1 ? void 0 : n ? Tn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
1597
|
+
(i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
|
|
1598
|
+
return n && s && On(e, t, s), s;
|
|
1599
|
+
}, K = (o, e) => (t, n) => e(t, n, o);
|
|
1600
|
+
let ue = class extends Ne {
|
|
1601
|
+
constructor(e, t, n, s, r) {
|
|
1573
1602
|
super();
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._textSelectionRenderManager = n, this._imeInputManagerService =
|
|
1603
|
+
R(this, "_previousIMEContent", "");
|
|
1604
|
+
R(this, "_isCompositionStart", !0);
|
|
1605
|
+
R(this, "_onStartSubscription");
|
|
1606
|
+
R(this, "_onUpdateSubscription");
|
|
1607
|
+
R(this, "_onEndSubscription");
|
|
1608
|
+
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._textSelectionRenderManager = n, this._imeInputManagerService = s, this._commandService = r, this._initialize();
|
|
1580
1609
|
}
|
|
1581
1610
|
dispose() {
|
|
1582
1611
|
var e, t, n;
|
|
@@ -1605,19 +1634,19 @@ let de = class extends Pe {
|
|
|
1605
1634
|
});
|
|
1606
1635
|
}
|
|
1607
1636
|
async _updateContent(e, t) {
|
|
1608
|
-
var
|
|
1609
|
-
const n = (
|
|
1637
|
+
var l;
|
|
1638
|
+
const n = (l = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : l.skeleton;
|
|
1610
1639
|
if (e == null || n == null)
|
|
1611
1640
|
return;
|
|
1612
|
-
const
|
|
1613
|
-
if (!
|
|
1641
|
+
const s = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1642
|
+
if (!s)
|
|
1614
1643
|
return;
|
|
1615
1644
|
const { event: r, activeRange: i } = e;
|
|
1616
1645
|
if (n == null || i == null)
|
|
1617
1646
|
return;
|
|
1618
1647
|
const c = r.data;
|
|
1619
1648
|
c === this._previousIMEContent && t || (await this._commandService.executeCommand(It.id, {
|
|
1620
|
-
unitId:
|
|
1649
|
+
unitId: s.getUnitId(),
|
|
1621
1650
|
newText: c,
|
|
1622
1651
|
oldTextLen: this._previousIMEContent.length,
|
|
1623
1652
|
isCompositionStart: this._isCompositionStart,
|
|
@@ -1628,40 +1657,40 @@ let de = class extends Pe {
|
|
|
1628
1657
|
this._previousIMEContent = "", this._isCompositionStart = !0, this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(null);
|
|
1629
1658
|
}
|
|
1630
1659
|
};
|
|
1631
|
-
|
|
1632
|
-
Ae
|
|
1660
|
+
ue = En([
|
|
1661
|
+
De(Ae.Rendered, ue),
|
|
1633
1662
|
K(0, k(H)),
|
|
1634
|
-
K(1,
|
|
1663
|
+
K(1, D),
|
|
1635
1664
|
K(2, pe),
|
|
1636
|
-
K(3, k(
|
|
1637
|
-
K(4,
|
|
1638
|
-
],
|
|
1639
|
-
var Dn = Object.defineProperty, An = Object.getOwnPropertyDescriptor, Nn = (
|
|
1640
|
-
for (var
|
|
1641
|
-
(i =
|
|
1642
|
-
return n &&
|
|
1643
|
-
}, q = (
|
|
1644
|
-
let
|
|
1645
|
-
constructor(e, t, n,
|
|
1665
|
+
K(3, k(Se)),
|
|
1666
|
+
K(4, I)
|
|
1667
|
+
], ue);
|
|
1668
|
+
var Dn = Object.defineProperty, An = Object.getOwnPropertyDescriptor, Nn = (o, e, t, n) => {
|
|
1669
|
+
for (var s = n > 1 ? void 0 : n ? An(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
1670
|
+
(i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
|
|
1671
|
+
return n && s && Dn(e, t, s), s;
|
|
1672
|
+
}, q = (o, e) => (t, n) => e(t, n, o);
|
|
1673
|
+
let ge = class extends Ne {
|
|
1674
|
+
constructor(e, t, n, s, r) {
|
|
1646
1675
|
super();
|
|
1647
|
-
|
|
1648
|
-
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionManagerService =
|
|
1676
|
+
R(this, "_onInputSubscription");
|
|
1677
|
+
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionManagerService = s, this._commandService = r, this._commandExecutedListener();
|
|
1649
1678
|
}
|
|
1650
1679
|
dispose() {
|
|
1651
1680
|
var e;
|
|
1652
1681
|
super.dispose(), (e = this._onInputSubscription) == null || e.unsubscribe();
|
|
1653
1682
|
}
|
|
1654
1683
|
_commandExecutedListener() {
|
|
1655
|
-
const e = [
|
|
1684
|
+
const e = [ye.id, Oe.id];
|
|
1656
1685
|
this.disposeWithMe(
|
|
1657
1686
|
this._commandService.onCommandExecuted((t) => {
|
|
1658
1687
|
if (!e.includes(t.id))
|
|
1659
1688
|
return;
|
|
1660
1689
|
const n = t.params;
|
|
1661
1690
|
switch (t.id) {
|
|
1662
|
-
case
|
|
1691
|
+
case ye.id:
|
|
1663
1692
|
return this._handleMoveCursor(n.direction);
|
|
1664
|
-
case
|
|
1693
|
+
case Oe.id:
|
|
1665
1694
|
return this._handleShiftMoveSelection(n.direction);
|
|
1666
1695
|
default:
|
|
1667
1696
|
throw new Error("Unknown command");
|
|
@@ -1671,42 +1700,42 @@ let ue = class extends Pe {
|
|
|
1671
1700
|
}
|
|
1672
1701
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1673
1702
|
_handleShiftMoveSelection(e) {
|
|
1674
|
-
var
|
|
1675
|
-
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(),
|
|
1676
|
-
if (!
|
|
1703
|
+
var h, f, _;
|
|
1704
|
+
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), s = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1705
|
+
if (!s)
|
|
1677
1706
|
return;
|
|
1678
|
-
const r = (
|
|
1707
|
+
const r = (h = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : h.skeleton, i = this._getDocObject();
|
|
1679
1708
|
if (t == null || r == null || i == null)
|
|
1680
1709
|
return;
|
|
1681
|
-
const { startOffset: a, endOffset: c, style:
|
|
1710
|
+
const { startOffset: a, endOffset: c, style: l, collapsed: d, direction: u } = t;
|
|
1682
1711
|
if (n.length > 1) {
|
|
1683
|
-
let
|
|
1684
|
-
for (const
|
|
1685
|
-
|
|
1712
|
+
let p = Number.POSITIVE_INFINITY, x = Number.NEGATIVE_INFINITY;
|
|
1713
|
+
for (const M of n)
|
|
1714
|
+
p = Math.min(p, M.startOffset), x = Math.max(x, M.endOffset);
|
|
1686
1715
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1687
1716
|
{
|
|
1688
|
-
startOffset: e === P.LEFT || e === P.UP ?
|
|
1689
|
-
endOffset: e === P.LEFT || e === P.UP ?
|
|
1690
|
-
style:
|
|
1717
|
+
startOffset: e === P.LEFT || e === P.UP ? x : p,
|
|
1718
|
+
endOffset: e === P.LEFT || e === P.UP ? p : x,
|
|
1719
|
+
style: l
|
|
1691
1720
|
}
|
|
1692
1721
|
], !1);
|
|
1693
1722
|
return;
|
|
1694
1723
|
}
|
|
1695
|
-
const g =
|
|
1696
|
-
let m =
|
|
1697
|
-
const S = (
|
|
1724
|
+
const g = d || u === Ke.FORWARD ? a : c;
|
|
1725
|
+
let m = d || u === Ke.FORWARD ? c : a;
|
|
1726
|
+
const S = (f = s.getBody().dataStream.length) != null ? f : Number.POSITIVE_INFINITY;
|
|
1698
1727
|
if (e === P.LEFT || e === P.RIGHT) {
|
|
1699
|
-
const
|
|
1700
|
-
m = e === P.RIGHT ? m +
|
|
1728
|
+
const p = r.findNodeByCharIndex(m - 1), x = r.findNodeByCharIndex(m);
|
|
1729
|
+
m = e === P.RIGHT ? m + x.count : m - ((_ = p == null ? void 0 : p.count) != null ? _ : 0), m = Math.min(S - 2, Math.max(0, m)), this._textSelectionManagerService.replaceTextRanges([
|
|
1701
1730
|
{
|
|
1702
1731
|
startOffset: g,
|
|
1703
1732
|
endOffset: m,
|
|
1704
|
-
style:
|
|
1733
|
+
style: l
|
|
1705
1734
|
}
|
|
1706
1735
|
], !1);
|
|
1707
1736
|
} else {
|
|
1708
|
-
const
|
|
1709
|
-
if (
|
|
1737
|
+
const p = r.findNodeByCharIndex(m), x = i.document.getOffsetConfig(), M = this._getTopOrBottomPosition(r, p, e === P.DOWN);
|
|
1738
|
+
if (M == null) {
|
|
1710
1739
|
const A = e === P.UP ? 0 : S - 2;
|
|
1711
1740
|
if (A === m)
|
|
1712
1741
|
return;
|
|
@@ -1714,76 +1743,76 @@ let ue = class extends Pe {
|
|
|
1714
1743
|
{
|
|
1715
1744
|
startOffset: g,
|
|
1716
1745
|
endOffset: A,
|
|
1717
|
-
style:
|
|
1746
|
+
style: l
|
|
1718
1747
|
}
|
|
1719
1748
|
], !1);
|
|
1720
1749
|
return;
|
|
1721
1750
|
}
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1724
|
-
|
|
1751
|
+
const C = new qe(x, r).getRangePointData(
|
|
1752
|
+
M,
|
|
1753
|
+
M
|
|
1725
1754
|
).cursorList[0];
|
|
1726
1755
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1727
1756
|
{
|
|
1728
1757
|
startOffset: g,
|
|
1729
|
-
endOffset:
|
|
1730
|
-
style:
|
|
1758
|
+
endOffset: C.endOffset,
|
|
1759
|
+
style: l
|
|
1731
1760
|
}
|
|
1732
1761
|
], !1);
|
|
1733
1762
|
}
|
|
1734
1763
|
}
|
|
1735
1764
|
_handleMoveCursor(e) {
|
|
1736
1765
|
var g, m, S;
|
|
1737
|
-
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(),
|
|
1738
|
-
if (!
|
|
1766
|
+
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), s = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1767
|
+
if (!s)
|
|
1739
1768
|
return !1;
|
|
1740
1769
|
const r = (g = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : g.skeleton, i = this._getDocObject();
|
|
1741
1770
|
if (t == null || r == null || i == null || n == null)
|
|
1742
1771
|
return;
|
|
1743
|
-
const { startOffset: a, endOffset: c, style:
|
|
1772
|
+
const { startOffset: a, endOffset: c, style: l, collapsed: d } = t, u = (m = s.getBody().dataStream.length) != null ? m : Number.POSITIVE_INFINITY;
|
|
1744
1773
|
if (e === P.LEFT || e === P.RIGHT) {
|
|
1745
|
-
let
|
|
1774
|
+
let h;
|
|
1746
1775
|
if (!t.collapsed || n.length > 1) {
|
|
1747
|
-
let
|
|
1748
|
-
for (const
|
|
1749
|
-
|
|
1750
|
-
|
|
1776
|
+
let f = Number.POSITIVE_INFINITY, _ = Number.NEGATIVE_INFINITY;
|
|
1777
|
+
for (const p of n)
|
|
1778
|
+
f = Math.min(f, p.startOffset), _ = Math.max(_, p.endOffset);
|
|
1779
|
+
h = e === P.LEFT ? f : _;
|
|
1751
1780
|
} else {
|
|
1752
|
-
const
|
|
1753
|
-
e === P.LEFT ?
|
|
1781
|
+
const f = r.findNodeByCharIndex(a - 1), _ = r.findNodeByCharIndex(a);
|
|
1782
|
+
e === P.LEFT ? h = Math.max(0, a - ((S = f == null ? void 0 : f.count) != null ? S : 0)) : h = Math.min(u - 2, c + _.count);
|
|
1754
1783
|
}
|
|
1755
1784
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1756
1785
|
{
|
|
1757
|
-
startOffset:
|
|
1758
|
-
endOffset:
|
|
1759
|
-
style:
|
|
1786
|
+
startOffset: h,
|
|
1787
|
+
endOffset: h,
|
|
1788
|
+
style: l
|
|
1760
1789
|
}
|
|
1761
1790
|
], !1);
|
|
1762
1791
|
} else {
|
|
1763
|
-
const
|
|
1792
|
+
const h = r.findNodeByCharIndex(a), f = r.findNodeByCharIndex(c), _ = i.document.getOffsetConfig(), p = this._getTopOrBottomPosition(
|
|
1764
1793
|
r,
|
|
1765
|
-
e === P.UP ?
|
|
1794
|
+
e === P.UP ? h : f,
|
|
1766
1795
|
e === P.DOWN
|
|
1767
1796
|
);
|
|
1768
|
-
if (
|
|
1769
|
-
let
|
|
1770
|
-
|
|
1797
|
+
if (p == null) {
|
|
1798
|
+
let M;
|
|
1799
|
+
d ? M = e === P.UP ? 0 : u - 2 : M = e === P.UP ? a : c, this._textSelectionManagerService.replaceTextRanges([
|
|
1771
1800
|
{
|
|
1772
|
-
startOffset:
|
|
1773
|
-
endOffset:
|
|
1774
|
-
style:
|
|
1801
|
+
startOffset: M,
|
|
1802
|
+
endOffset: M,
|
|
1803
|
+
style: l
|
|
1775
1804
|
}
|
|
1776
1805
|
], !1);
|
|
1777
1806
|
return;
|
|
1778
1807
|
}
|
|
1779
|
-
const
|
|
1780
|
-
|
|
1781
|
-
|
|
1808
|
+
const x = new qe(_, r).getRangePointData(
|
|
1809
|
+
p,
|
|
1810
|
+
p
|
|
1782
1811
|
).cursorList[0];
|
|
1783
1812
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1784
1813
|
{
|
|
1785
|
-
...
|
|
1786
|
-
style:
|
|
1814
|
+
...x,
|
|
1815
|
+
style: l
|
|
1787
1816
|
}
|
|
1788
1817
|
], !1);
|
|
1789
1818
|
}
|
|
@@ -1791,10 +1820,10 @@ let ue = class extends Pe {
|
|
|
1791
1820
|
_getTopOrBottomPosition(e, t, n) {
|
|
1792
1821
|
if (t == null)
|
|
1793
1822
|
return;
|
|
1794
|
-
const
|
|
1823
|
+
const s = this._getSpanLeftOffsetInLine(t), r = this._getNextOrPrevLine(t, n);
|
|
1795
1824
|
if (r == null)
|
|
1796
1825
|
return;
|
|
1797
|
-
const i = this._matchPositionByLeftOffset(e, r,
|
|
1826
|
+
const i = this._matchPositionByLeftOffset(e, r, s);
|
|
1798
1827
|
if (i != null)
|
|
1799
1828
|
return { ...i, isBack: !0 };
|
|
1800
1829
|
}
|
|
@@ -1802,35 +1831,35 @@ let ue = class extends Pe {
|
|
|
1802
1831
|
const t = e.parent;
|
|
1803
1832
|
if (t == null)
|
|
1804
1833
|
return Number.NEGATIVE_INFINITY;
|
|
1805
|
-
const n = t.left, { left:
|
|
1806
|
-
return n +
|
|
1834
|
+
const n = t.left, { left: s } = e;
|
|
1835
|
+
return n + s;
|
|
1807
1836
|
}
|
|
1808
1837
|
_matchPositionByLeftOffset(e, t, n) {
|
|
1809
|
-
const
|
|
1838
|
+
const s = {
|
|
1810
1839
|
distance: Number.POSITIVE_INFINITY
|
|
1811
1840
|
};
|
|
1812
1841
|
for (const r of t.divides) {
|
|
1813
1842
|
const i = r.left;
|
|
1814
1843
|
for (const a of r.glyphGroup) {
|
|
1815
|
-
const { left: c } = a,
|
|
1816
|
-
|
|
1844
|
+
const { left: c } = a, l = i + c, d = Math.abs(n - l);
|
|
1845
|
+
d < s.distance && (s.glyph = a, s.distance = d);
|
|
1817
1846
|
}
|
|
1818
1847
|
}
|
|
1819
|
-
if (
|
|
1820
|
-
return e.findPositionByGlyph(
|
|
1848
|
+
if (s.glyph != null)
|
|
1849
|
+
return e.findPositionByGlyph(s.glyph);
|
|
1821
1850
|
}
|
|
1822
1851
|
_getNextOrPrevLine(e, t) {
|
|
1823
|
-
var S,
|
|
1852
|
+
var S, h, f, _, p, x, M, C, A, E, w, U;
|
|
1824
1853
|
const n = e.parent;
|
|
1825
1854
|
if (n == null)
|
|
1826
1855
|
return;
|
|
1827
|
-
const
|
|
1828
|
-
if (
|
|
1856
|
+
const s = n.parent;
|
|
1857
|
+
if (s == null)
|
|
1829
1858
|
return;
|
|
1830
|
-
const r =
|
|
1859
|
+
const r = s.parent;
|
|
1831
1860
|
if (r == null)
|
|
1832
1861
|
return;
|
|
1833
|
-
const i = r.lines.indexOf(
|
|
1862
|
+
const i = r.lines.indexOf(s);
|
|
1834
1863
|
if (i === -1)
|
|
1835
1864
|
return;
|
|
1836
1865
|
let a;
|
|
@@ -1839,43 +1868,43 @@ let ue = class extends Pe {
|
|
|
1839
1868
|
const c = r.parent;
|
|
1840
1869
|
if (c == null)
|
|
1841
1870
|
return;
|
|
1842
|
-
const
|
|
1843
|
-
if (
|
|
1871
|
+
const l = c.columns.indexOf(r);
|
|
1872
|
+
if (l === -1)
|
|
1844
1873
|
return;
|
|
1845
1874
|
if (t === !0)
|
|
1846
|
-
a = (S = c.columns[
|
|
1875
|
+
a = (S = c.columns[l + 1]) == null ? void 0 : S.lines[0];
|
|
1847
1876
|
else {
|
|
1848
|
-
const O = (
|
|
1877
|
+
const O = (f = (h = c.columns) == null ? void 0 : h[l - 1]) == null ? void 0 : f.lines;
|
|
1849
1878
|
a = O == null ? void 0 : O[O.length - 1];
|
|
1850
1879
|
}
|
|
1851
1880
|
if (a != null)
|
|
1852
1881
|
return a;
|
|
1853
|
-
const
|
|
1854
|
-
if (
|
|
1882
|
+
const d = c.parent;
|
|
1883
|
+
if (d == null)
|
|
1855
1884
|
return;
|
|
1856
|
-
const u =
|
|
1885
|
+
const u = d.sections.indexOf(c);
|
|
1857
1886
|
if (u === -1)
|
|
1858
1887
|
return;
|
|
1859
1888
|
if (t === !0)
|
|
1860
|
-
a = (
|
|
1889
|
+
a = (p = (_ = d.sections[u - 1]) == null ? void 0 : _.columns[0]) == null ? void 0 : p.lines[0];
|
|
1861
1890
|
else {
|
|
1862
|
-
const O = (
|
|
1863
|
-
a =
|
|
1891
|
+
const O = (M = (x = d.sections) == null ? void 0 : x[u - 1]) == null ? void 0 : M.columns, b = O == null ? void 0 : O[O.length - 1], L = b == null ? void 0 : b.lines;
|
|
1892
|
+
a = L == null ? void 0 : L[L.length - 1];
|
|
1864
1893
|
}
|
|
1865
1894
|
if (a != null)
|
|
1866
1895
|
return a;
|
|
1867
|
-
const g =
|
|
1896
|
+
const g = d.parent;
|
|
1868
1897
|
if (g == null)
|
|
1869
1898
|
return;
|
|
1870
|
-
const m = g.pages.indexOf(
|
|
1899
|
+
const m = g.pages.indexOf(d);
|
|
1871
1900
|
if (m !== -1) {
|
|
1872
1901
|
if (t === !0)
|
|
1873
|
-
a = (
|
|
1902
|
+
a = (E = (A = (C = g.pages[m + 1]) == null ? void 0 : C.sections[0]) == null ? void 0 : A.columns[0]) == null ? void 0 : E.lines[0];
|
|
1874
1903
|
else {
|
|
1875
|
-
const O = (
|
|
1904
|
+
const O = (w = g.pages[m - 1]) == null ? void 0 : w.sections;
|
|
1876
1905
|
if (O == null)
|
|
1877
1906
|
return;
|
|
1878
|
-
const
|
|
1907
|
+
const b = (U = O[O.length - 1]) == null ? void 0 : U.columns, L = b[b.length - 1], Y = L == null ? void 0 : L.lines;
|
|
1879
1908
|
a = Y[Y.length - 1];
|
|
1880
1909
|
}
|
|
1881
1910
|
if (a != null)
|
|
@@ -1883,27 +1912,27 @@ let ue = class extends Pe {
|
|
|
1883
1912
|
}
|
|
1884
1913
|
}
|
|
1885
1914
|
_getDocObject() {
|
|
1886
|
-
return
|
|
1915
|
+
return Xt(this._univerInstanceService, this._renderManagerService);
|
|
1887
1916
|
}
|
|
1888
1917
|
};
|
|
1889
|
-
|
|
1890
|
-
Ae
|
|
1918
|
+
ge = Nn([
|
|
1919
|
+
De(Ae.Rendered, ge),
|
|
1891
1920
|
q(0, k(H)),
|
|
1892
|
-
q(1,
|
|
1921
|
+
q(1, D),
|
|
1893
1922
|
q(2, ft),
|
|
1894
1923
|
q(3, k(T)),
|
|
1895
|
-
q(4,
|
|
1896
|
-
],
|
|
1897
|
-
var
|
|
1898
|
-
for (var
|
|
1899
|
-
(i =
|
|
1900
|
-
return n &&
|
|
1901
|
-
}, Q = (
|
|
1902
|
-
let
|
|
1903
|
-
constructor(e, t, n,
|
|
1924
|
+
q(4, I)
|
|
1925
|
+
], ge);
|
|
1926
|
+
var bn = Object.defineProperty, Pn = Object.getOwnPropertyDescriptor, Un = (o, e, t, n) => {
|
|
1927
|
+
for (var s = n > 1 ? void 0 : n ? Pn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
1928
|
+
(i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
|
|
1929
|
+
return n && s && bn(e, t, s), s;
|
|
1930
|
+
}, Q = (o, e) => (t, n) => e(t, n, o);
|
|
1931
|
+
let me = class extends Ne {
|
|
1932
|
+
constructor(e, t, n, s, r) {
|
|
1904
1933
|
super();
|
|
1905
|
-
|
|
1906
|
-
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionRenderManager =
|
|
1934
|
+
R(this, "_onInputSubscription");
|
|
1935
|
+
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionRenderManager = s, this._commandService = r, this._init();
|
|
1907
1936
|
}
|
|
1908
1937
|
dispose() {
|
|
1909
1938
|
var e;
|
|
@@ -1920,167 +1949,167 @@ let ge = class extends Pe {
|
|
|
1920
1949
|
const t = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1921
1950
|
if (!t)
|
|
1922
1951
|
return;
|
|
1923
|
-
const n = t.getUnitId(), { event:
|
|
1952
|
+
const n = t.getUnitId(), { event: s, content: r = "", activeRange: i } = e, a = s, c = (S = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : S.skeleton;
|
|
1924
1953
|
if (a.data == null || c == null || !c || !i)
|
|
1925
1954
|
return;
|
|
1926
|
-
const { startOffset:
|
|
1955
|
+
const { startOffset: l, segmentId: d, style: u } = i, g = r.length, m = [
|
|
1927
1956
|
{
|
|
1928
|
-
startOffset:
|
|
1929
|
-
endOffset:
|
|
1957
|
+
startOffset: l + g,
|
|
1958
|
+
endOffset: l + g,
|
|
1930
1959
|
style: u
|
|
1931
1960
|
}
|
|
1932
1961
|
];
|
|
1933
|
-
await this._commandService.executeCommand(
|
|
1962
|
+
await this._commandService.executeCommand(Ue.id, {
|
|
1934
1963
|
unitId: n,
|
|
1935
1964
|
body: {
|
|
1936
1965
|
dataStream: r
|
|
1937
1966
|
},
|
|
1938
1967
|
range: i,
|
|
1939
1968
|
textRanges: m,
|
|
1940
|
-
segmentId:
|
|
1969
|
+
segmentId: d
|
|
1941
1970
|
});
|
|
1942
1971
|
});
|
|
1943
1972
|
}
|
|
1944
1973
|
};
|
|
1945
|
-
|
|
1946
|
-
Ae
|
|
1974
|
+
me = Un([
|
|
1975
|
+
De(Ae.Rendered, me),
|
|
1947
1976
|
Q(0, k(H)),
|
|
1948
|
-
Q(1,
|
|
1977
|
+
Q(1, D),
|
|
1949
1978
|
Q(2, ft),
|
|
1950
1979
|
Q(3, pe),
|
|
1951
|
-
Q(4,
|
|
1952
|
-
],
|
|
1953
|
-
var wn = Object.defineProperty, Ln = Object.getOwnPropertyDescriptor, Bn = (
|
|
1954
|
-
for (var
|
|
1955
|
-
(i =
|
|
1956
|
-
return n &&
|
|
1957
|
-
}, Fn = (
|
|
1980
|
+
Q(4, I)
|
|
1981
|
+
], me);
|
|
1982
|
+
var wn = Object.defineProperty, Ln = Object.getOwnPropertyDescriptor, Bn = (o, e, t, n) => {
|
|
1983
|
+
for (var s = n > 1 ? void 0 : n ? Ln(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
1984
|
+
(i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
|
|
1985
|
+
return n && s && wn(e, t, s), s;
|
|
1986
|
+
}, Fn = (o, e) => (t, n) => e(t, n, o);
|
|
1958
1987
|
const $n = "docs";
|
|
1959
|
-
var
|
|
1960
|
-
let
|
|
1961
|
-
constructor(
|
|
1988
|
+
var le;
|
|
1989
|
+
let mt = (le = class extends Pt {
|
|
1990
|
+
constructor(o = {}, e) {
|
|
1962
1991
|
super(), this._injector = e, this._initializeDependencies(e), this._initializeCommands();
|
|
1963
1992
|
}
|
|
1964
1993
|
_initializeCommands() {
|
|
1965
1994
|
[
|
|
1995
|
+
ye,
|
|
1966
1996
|
Oe,
|
|
1967
|
-
Te,
|
|
1968
1997
|
dn,
|
|
1969
1998
|
un,
|
|
1970
|
-
Le,
|
|
1971
1999
|
Be,
|
|
1972
2000
|
Fe,
|
|
1973
2001
|
$e,
|
|
1974
|
-
oe,
|
|
1975
2002
|
Ve,
|
|
2003
|
+
se,
|
|
1976
2004
|
ke,
|
|
1977
2005
|
ze,
|
|
1978
2006
|
je,
|
|
1979
|
-
Xe,
|
|
1980
2007
|
Ge,
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
It,
|
|
2008
|
+
He,
|
|
2009
|
+
Xe,
|
|
2010
|
+
Ct,
|
|
2011
|
+
sn,
|
|
2012
|
+
Ue,
|
|
1987
2013
|
we,
|
|
2014
|
+
St,
|
|
2015
|
+
It,
|
|
2016
|
+
Le,
|
|
1988
2017
|
B,
|
|
1989
2018
|
Mn,
|
|
1990
2019
|
Cn,
|
|
1991
2020
|
xn,
|
|
1992
|
-
|
|
2021
|
+
de,
|
|
1993
2022
|
pt,
|
|
1994
2023
|
yn,
|
|
1995
|
-
hn,
|
|
1996
2024
|
pn,
|
|
1997
|
-
|
|
2025
|
+
fn,
|
|
2026
|
+
Ye,
|
|
1998
2027
|
Sn,
|
|
1999
2028
|
_n,
|
|
2000
|
-
|
|
2029
|
+
vn,
|
|
2001
2030
|
ae,
|
|
2002
|
-
|
|
2003
|
-
].forEach((
|
|
2004
|
-
this._injector.get(
|
|
2031
|
+
In
|
|
2032
|
+
].forEach((o) => {
|
|
2033
|
+
this._injector.get(I).registerCommand(o);
|
|
2005
2034
|
});
|
|
2006
2035
|
}
|
|
2007
|
-
_initializeDependencies(
|
|
2036
|
+
_initializeDependencies(o) {
|
|
2008
2037
|
[
|
|
2009
2038
|
// services
|
|
2010
2039
|
[H],
|
|
2011
|
-
[
|
|
2012
|
-
[me],
|
|
2040
|
+
[oe],
|
|
2013
2041
|
[he],
|
|
2042
|
+
[Se],
|
|
2014
2043
|
[
|
|
2015
2044
|
pe,
|
|
2016
2045
|
{
|
|
2017
|
-
useClass:
|
|
2046
|
+
useClass: zt
|
|
2018
2047
|
}
|
|
2019
2048
|
],
|
|
2020
2049
|
[T],
|
|
2021
2050
|
// controllers
|
|
2022
|
-
[
|
|
2023
|
-
[
|
|
2024
|
-
[
|
|
2025
|
-
].forEach((e) =>
|
|
2026
|
-
}
|
|
2027
|
-
},
|
|
2028
|
-
|
|
2029
|
-
Fn(1, k(
|
|
2030
|
-
],
|
|
2051
|
+
[me],
|
|
2052
|
+
[ue],
|
|
2053
|
+
[ge]
|
|
2054
|
+
].forEach((e) => o.add(e));
|
|
2055
|
+
}
|
|
2056
|
+
}, R(le, "pluginName", $n), R(le, "type", Z.UNIVER_DOC), le);
|
|
2057
|
+
mt = Bn([
|
|
2058
|
+
Fn(1, k(jt))
|
|
2059
|
+
], mt);
|
|
2031
2060
|
export {
|
|
2032
2061
|
_n as AlignCenterCommand,
|
|
2033
|
-
|
|
2062
|
+
In as AlignJustifyCommand,
|
|
2034
2063
|
Sn as AlignLeftCommand,
|
|
2035
2064
|
ae as AlignOperationCommand,
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2065
|
+
vn as AlignRightCommand,
|
|
2066
|
+
sn as BreakLineCommand,
|
|
2067
|
+
fn as BulletListCommand,
|
|
2039
2068
|
Cn as CoverContentCommand,
|
|
2040
|
-
|
|
2069
|
+
_t as CutContentCommand,
|
|
2041
2070
|
Xn as DOCS_COMPONENT_BACKGROUND_LAYER_INDEX,
|
|
2042
2071
|
Wn as DOCS_COMPONENT_DEFAULT_Z_INDEX,
|
|
2043
2072
|
Yn as DOCS_COMPONENT_HEADER_LAYER_INDEX,
|
|
2044
2073
|
Hn as DOCS_COMPONENT_MAIN_LAYER_INDEX,
|
|
2045
2074
|
be as DOCS_VIEW_KEY,
|
|
2046
|
-
|
|
2075
|
+
we as DeleteCommand,
|
|
2047
2076
|
dn as DeleteLeftCommand,
|
|
2048
2077
|
un as DeleteRightCommand,
|
|
2049
2078
|
H as DocSkeletonManagerService,
|
|
2050
|
-
|
|
2051
|
-
|
|
2079
|
+
he as DocStateChangeManagerService,
|
|
2080
|
+
oe as DocViewModelManagerService,
|
|
2052
2081
|
nn as EditorInsertTextCommandId,
|
|
2053
2082
|
It as IMEInputCommand,
|
|
2054
|
-
|
|
2083
|
+
Se as IMEInputManagerService,
|
|
2055
2084
|
Kn as InnerPasteCommand,
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2085
|
+
Ue as InsertCommand,
|
|
2086
|
+
ye as MoveCursorOperation,
|
|
2087
|
+
Oe as MoveSelectionOperation,
|
|
2059
2088
|
Zn as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
|
|
2060
|
-
|
|
2089
|
+
pn as OrderListCommand,
|
|
2061
2090
|
Mn as ReplaceContentCommand,
|
|
2062
|
-
|
|
2091
|
+
He as ResetInlineFormatTextBackgroundColorCommand,
|
|
2063
2092
|
B as RichTextEditingMutation,
|
|
2064
2093
|
yn as SelectAllOperation,
|
|
2065
2094
|
xn as SetDocZoomRatioCommand,
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2095
|
+
de as SetDocZoomRatioOperation,
|
|
2096
|
+
Be as SetInlineFormatBoldCommand,
|
|
2097
|
+
Ct as SetInlineFormatCommand,
|
|
2098
|
+
je as SetInlineFormatFontFamilyCommand,
|
|
2099
|
+
ze as SetInlineFormatFontSizeCommand,
|
|
2100
|
+
Fe as SetInlineFormatItalicCommand,
|
|
2101
|
+
Ve as SetInlineFormatStrikethroughCommand,
|
|
2102
|
+
se as SetInlineFormatSubscriptCommand,
|
|
2103
|
+
ke as SetInlineFormatSuperscriptCommand,
|
|
2104
|
+
Xe as SetInlineFormatTextBackgroundColorCommand,
|
|
2105
|
+
Ge as SetInlineFormatTextColorCommand,
|
|
2106
|
+
$e as SetInlineFormatUnderlineCommand,
|
|
2078
2107
|
pt as SetTextSelectionsOperation,
|
|
2079
2108
|
T as TextSelectionManagerService,
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2109
|
+
mt as UniverDocsPlugin,
|
|
2110
|
+
St as UpdateCommand,
|
|
2111
|
+
Gt as VIEWPORT_KEY,
|
|
2112
|
+
Xt as getDocObject,
|
|
2084
2113
|
Jn as getDocObjectById,
|
|
2085
2114
|
J as serializeTextRange
|
|
2086
2115
|
};
|