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