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