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