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