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