@univerjs/docs 0.2.2 → 0.2.3
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/README.md +11 -2
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1223 -1085
- package/lib/types/commands/commands/delete.command.d.ts +7 -0
- package/lib/types/commands/commands/replace-content.command.d.ts +3 -0
- package/lib/types/commands/mutations/core-editing.mutation.d.ts +3 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/types/services/text-selection-manager.service.d.ts +4 -2
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
package/lib/es/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { DataStreamTreeTokenType as
|
|
5
|
-
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as
|
|
6
|
-
import { Inject as
|
|
7
|
-
import { BehaviorSubject as ne, takeUntil as
|
|
8
|
-
function
|
|
9
|
-
return s ===
|
|
1
|
+
var Xt = Object.defineProperty;
|
|
2
|
+
var Vt = (s, e, t) => e in s ? Xt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var b = (s, e, t) => Vt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { DataStreamTreeTokenType as P, UniverInstanceType as J, CommandType as E, RxDisposable as Ge, ICommandService as A, TextXActionType as C, IUndoRedoService as $e, UndoCommandId as at, RedoCommandId as it, JSONX as B, IUniverInstanceService as U, LocaleService as Wt, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Mt, TextX as $, normalizeBody as Yt, getBodySlice as Tt, updateAttributeByInsert as Kt, Tools as q, MemoryCursor as re, getDocsUpdateBody as Zt, UpdateDocsAttributeType as Re, PositionedObjectLayoutType as Et, getCustomRangeSlice as Jt, getCustomDecorationSlice as qt, BooleanNumber as K, BaselineOffset as Z, PRESET_LIST_TYPE as Qt, PresetListType as At, OnLifecycle as xe, LifecycleStages as Oe, Disposable as Ce, Direction as F, HorizontalAlign as ae, toDisposable as Nt, Plugin as en, createInterceptorKey as Dt, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as tn, remove as nn, composeInterceptors as sn, DisposableCollection as on } from "@univerjs/core";
|
|
5
|
+
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as rn, ITextSelectionRenderManager as ye, DocumentSkeleton as an, DocumentViewModel as cn, IRenderManagerService as ie, hasListGlyph as dn, isIndentByGlyph as ln, isFirstGlyph as un, getParagraphByGlyph as gn, getCharSpaceApply as fn, getNumberUnitValue as be, RANGE_DIRECTION as Pe, NodePositionConvertToCursor as ct, TextSelectionRenderManager as mn } from "@univerjs/engine-render";
|
|
6
|
+
import { Inject as ee, Injector as hn } from "@wendellhu/redi";
|
|
7
|
+
import { BehaviorSubject as ne, takeUntil as bt } from "rxjs";
|
|
8
|
+
function Ie(s) {
|
|
9
|
+
return s === P.CUSTOM_RANGE_END || s === P.CUSTOM_RANGE_START;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function ke(s, e, t, n) {
|
|
12
12
|
return s <= t && e >= t || s >= t && s <= n;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function je(s, e, t, n) {
|
|
15
15
|
const o = n.slice(t.startIndex + 1, t.endIndex), r = Math.max(s - (t.startIndex + 1), 0), a = s + e - 1 - (t.startIndex + 1);
|
|
16
16
|
if (a < 0)
|
|
17
17
|
return !1;
|
|
18
18
|
if (r === 0 && a >= o.length)
|
|
19
19
|
return !0;
|
|
20
20
|
const i = o.slice(0, r) + o.slice(r + e);
|
|
21
|
-
for (let c = 0,
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
21
|
+
for (let c = 0, d = i.length; c < d; c++) {
|
|
22
|
+
const l = i[c];
|
|
23
|
+
if (!Ie(l))
|
|
24
24
|
return !1;
|
|
25
25
|
}
|
|
26
26
|
return !0;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function ce(s) {
|
|
29
29
|
const { startOffset: e, endOffset: t, collapsed: n } = s, o = Math.min(e, t), r = Math.max(e, t);
|
|
30
30
|
return {
|
|
31
31
|
startOffset: o,
|
|
@@ -34,20 +34,20 @@ function ie(s) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function ze(s, e) {
|
|
37
|
-
let { startOffset: t, endOffset: n } =
|
|
38
|
-
for (; e.dataStream[t - 1] ===
|
|
37
|
+
let { startOffset: t, endOffset: n } = ce(s);
|
|
38
|
+
for (; e.dataStream[t - 1] === P.CUSTOM_RANGE_START; )
|
|
39
39
|
t -= 1;
|
|
40
|
-
for (; e.dataStream[n] ===
|
|
40
|
+
for (; e.dataStream[n] === P.CUSTOM_RANGE_END; )
|
|
41
41
|
n += 1;
|
|
42
42
|
return {
|
|
43
43
|
startOffset: t,
|
|
44
44
|
endOffset: n
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
let { startOffset: t, endOffset: n, collapsed: o } =
|
|
47
|
+
function He(s, e) {
|
|
48
|
+
let { startOffset: t, endOffset: n, collapsed: o } = ce(s);
|
|
49
49
|
if (o) {
|
|
50
|
-
for (;
|
|
50
|
+
for (; Ie(e.dataStream[t - 1]); )
|
|
51
51
|
n -= 1, t -= 1;
|
|
52
52
|
return {
|
|
53
53
|
startOffset: t,
|
|
@@ -60,12 +60,12 @@ function je(s, e) {
|
|
|
60
60
|
collapsed: !1
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
let { startOffset: t, endOffset: n, collapsed: o } =
|
|
63
|
+
function Me(s, e) {
|
|
64
|
+
let { startOffset: t, endOffset: n, collapsed: o } = ce(s);
|
|
65
65
|
if (o) {
|
|
66
|
-
for (; e.dataStream[n] ===
|
|
66
|
+
for (; e.dataStream[n] === P.CUSTOM_RANGE_END; )
|
|
67
67
|
n += 1, t += 1;
|
|
68
|
-
for (; e.dataStream[n - 1] ===
|
|
68
|
+
for (; e.dataStream[n - 1] === P.CUSTOM_RANGE_START; )
|
|
69
69
|
n -= 1, t -= 1;
|
|
70
70
|
return {
|
|
71
71
|
startOffset: t,
|
|
@@ -78,15 +78,15 @@ function Oe(s, e) {
|
|
|
78
78
|
collapsed: !1
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function pn(s, e) {
|
|
82
82
|
if (s.startOffset === s.endOffset)
|
|
83
83
|
return null;
|
|
84
84
|
const t = e.customRanges;
|
|
85
85
|
if (!t)
|
|
86
|
-
return
|
|
86
|
+
return ce(s);
|
|
87
87
|
let { startOffset: n, endOffset: o } = ze(s, e);
|
|
88
|
-
for (;
|
|
89
|
-
if (e.dataStream[n] ===
|
|
88
|
+
for (; Ie(e.dataStream[n]); ) {
|
|
89
|
+
if (e.dataStream[n] === P.CUSTOM_RANGE_START) {
|
|
90
90
|
const r = t.find((a) => a.startIndex === n);
|
|
91
91
|
if (!r)
|
|
92
92
|
throw new Error("No custom-range matched");
|
|
@@ -101,8 +101,8 @@ function mn(s, e) {
|
|
|
101
101
|
}
|
|
102
102
|
n += 1;
|
|
103
103
|
}
|
|
104
|
-
for (;
|
|
105
|
-
if (e.dataStream[n] ===
|
|
104
|
+
for (; Ie(e.dataStream[o - 1]); ) {
|
|
105
|
+
if (e.dataStream[n] === P.CUSTOM_RANGE_END) {
|
|
106
106
|
const r = t.find((a) => a.endIndex === o - 1);
|
|
107
107
|
if (!r)
|
|
108
108
|
throw new Error("No custom-range matched");
|
|
@@ -123,46 +123,46 @@ function mn(s, e) {
|
|
|
123
123
|
collapsed: !1
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const Sn = [
|
|
127
|
+
P.PARAGRAPH,
|
|
128
128
|
// 段落
|
|
129
|
-
|
|
129
|
+
P.SECTION_BREAK,
|
|
130
130
|
// 章节
|
|
131
|
-
|
|
131
|
+
P.TABLE_START,
|
|
132
132
|
// 表格开始
|
|
133
|
-
|
|
133
|
+
P.TABLE_ROW_START,
|
|
134
134
|
// 表格开始
|
|
135
|
-
|
|
135
|
+
P.TABLE_CELL_START,
|
|
136
136
|
// 表格开始
|
|
137
|
-
|
|
137
|
+
P.TABLE_CELL_END,
|
|
138
138
|
// 表格开始
|
|
139
|
-
|
|
139
|
+
P.TABLE_ROW_END,
|
|
140
140
|
// 表格开始
|
|
141
|
-
|
|
141
|
+
P.TABLE_END,
|
|
142
142
|
// 表格结束
|
|
143
|
-
|
|
143
|
+
P.CUSTOM_RANGE_START,
|
|
144
144
|
// 自定义范围开始
|
|
145
|
-
|
|
145
|
+
P.CUSTOM_RANGE_END,
|
|
146
146
|
// 自定义范围结束
|
|
147
|
-
|
|
147
|
+
P.COLUMN_BREAK,
|
|
148
148
|
// 换列
|
|
149
|
-
|
|
149
|
+
P.PAGE_BREAK,
|
|
150
150
|
// 换页
|
|
151
|
-
|
|
151
|
+
P.DOCS_END,
|
|
152
152
|
// 文档结尾
|
|
153
|
-
|
|
153
|
+
P.TAB,
|
|
154
154
|
// 制表符
|
|
155
|
-
|
|
155
|
+
P.CUSTOM_BLOCK
|
|
156
156
|
// 图片 mention 等不参与文档流的场景
|
|
157
157
|
];
|
|
158
|
-
function
|
|
158
|
+
function Cs(s, e, t) {
|
|
159
159
|
const n = s.slice(e, t);
|
|
160
|
-
return
|
|
160
|
+
return Sn.reduce((o, r) => o.replaceAll(r, ""), n);
|
|
161
161
|
}
|
|
162
|
-
var
|
|
163
|
-
const
|
|
164
|
-
function
|
|
165
|
-
const { mainComponent: e, scene: t, engine: n, components: o } = s, r = e, a = o.get(
|
|
162
|
+
var Te = /* @__PURE__ */ ((s) => (s.MAIN = "__Document_Render_Main__", s.BACKGROUND = "__Document_Render_Background__", s))(Te || {}), In = /* @__PURE__ */ ((s) => (s.VIEW_MAIN = "viewMain", s.VIEW_TOP = "viewTop", s.VIEW_LEFT = "viewLeft", s.VIEW_LEFT_TOP = "viewLeftTop", s))(In || {});
|
|
163
|
+
const ys = 0, Ms = 2, Ts = 4, Es = 10, As = "normalTextSelectionPluginName";
|
|
164
|
+
function Ns(s) {
|
|
165
|
+
const { mainComponent: e, scene: t, engine: n, components: o } = s, r = e, a = o.get(Te.BACKGROUND);
|
|
166
166
|
return {
|
|
167
167
|
document: r,
|
|
168
168
|
docBackground: a,
|
|
@@ -170,26 +170,26 @@ function Ts(s) {
|
|
|
170
170
|
engine: n
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
const t = s.getCurrentUnitForType(
|
|
173
|
+
function _n(s, e) {
|
|
174
|
+
const t = s.getCurrentUnitForType(J.UNIVER_DOC);
|
|
175
175
|
if (!t)
|
|
176
176
|
return null;
|
|
177
177
|
const n = t.getUnitId(), o = e.getRenderById(n);
|
|
178
178
|
if (o == null)
|
|
179
179
|
return;
|
|
180
|
-
const { mainComponent: r, scene: a, engine: i, components: c } = o,
|
|
180
|
+
const { mainComponent: r, scene: a, engine: i, components: c } = o, d = r, l = c.get(Te.BACKGROUND);
|
|
181
181
|
return {
|
|
182
|
-
document:
|
|
183
|
-
docBackground:
|
|
182
|
+
document: d,
|
|
183
|
+
docBackground: l,
|
|
184
184
|
scene: a,
|
|
185
185
|
engine: i
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function Ds(s, e) {
|
|
189
189
|
const t = e.getRenderById(s);
|
|
190
190
|
if (t == null)
|
|
191
191
|
return;
|
|
192
|
-
const { mainComponent: n, scene: o, engine: r, components: a } = t, i = n, c = a.get(
|
|
192
|
+
const { mainComponent: n, scene: o, engine: r, components: a } = t, i = n, c = a.get(Te.BACKGROUND);
|
|
193
193
|
return {
|
|
194
194
|
document: i,
|
|
195
195
|
docBackground: c,
|
|
@@ -197,17 +197,17 @@ function Es(s, e) {
|
|
|
197
197
|
engine: r
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
const
|
|
200
|
+
const Pt = {
|
|
201
201
|
id: "doc.operation.set-selections",
|
|
202
|
-
type:
|
|
202
|
+
type: E.OPERATION,
|
|
203
203
|
handler: (s, e) => !0
|
|
204
204
|
};
|
|
205
|
-
var
|
|
206
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
205
|
+
var vn = Object.defineProperty, Rn = Object.getOwnPropertyDescriptor, xn = (s, e, t, n) => {
|
|
206
|
+
for (var o = n > 1 ? void 0 : n ? Rn(e, t) : e, r = s.length - 1, a; r >= 0; r--)
|
|
207
207
|
(a = s[r]) && (o = (n ? a(e, t, o) : a(o)) || o);
|
|
208
|
-
return n && o &&
|
|
208
|
+
return n && o && vn(e, t, o), o;
|
|
209
209
|
}, dt = (s, e) => (t, n) => e(t, n, s);
|
|
210
|
-
function
|
|
210
|
+
function Q(s) {
|
|
211
211
|
const { startOffset: e, endOffset: t, collapsed: n } = s, o = {
|
|
212
212
|
startOffset: e,
|
|
213
213
|
endOffset: t,
|
|
@@ -215,13 +215,13 @@ function q(s) {
|
|
|
215
215
|
};
|
|
216
216
|
return typeof s.isActive == "function" && (o.isActive = s.isActive()), o;
|
|
217
217
|
}
|
|
218
|
-
let
|
|
218
|
+
let w = class extends Ge {
|
|
219
219
|
constructor(e, t) {
|
|
220
220
|
super();
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
b(this, "_currentSelection", null);
|
|
222
|
+
b(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
|
|
223
|
+
b(this, "_textSelection$", new ne(null));
|
|
224
|
+
b(this, "textSelection$", this._textSelection$.asObservable());
|
|
225
225
|
this._textSelectionRenderManager = e, this._commandService = t, this._syncSelectionFromRenderService();
|
|
226
226
|
}
|
|
227
227
|
getCurrentSelection() {
|
|
@@ -244,7 +244,7 @@ let D = class extends Le {
|
|
|
244
244
|
setCurrentSelectionNotRefresh(e) {
|
|
245
245
|
this._currentSelection = e;
|
|
246
246
|
}
|
|
247
|
-
|
|
247
|
+
getCurrentSelections() {
|
|
248
248
|
var e;
|
|
249
249
|
return (e = this._getTextRanges(this._currentSelection)) == null ? void 0 : e.textRanges;
|
|
250
250
|
}
|
|
@@ -259,15 +259,15 @@ let D = class extends Le {
|
|
|
259
259
|
const e = this._getTextRanges(this._currentSelection);
|
|
260
260
|
if (e == null)
|
|
261
261
|
return;
|
|
262
|
-
const { textRanges: t, segmentId: n, style: o, segmentPage: r } = e, a = t.find((
|
|
262
|
+
const { textRanges: t, segmentId: n, style: o, segmentPage: r } = e, a = t.find((S) => S.isActive());
|
|
263
263
|
if (a == null)
|
|
264
264
|
return null;
|
|
265
|
-
const { startOffset: i, endOffset: c, collapsed:
|
|
265
|
+
const { startOffset: i, endOffset: c, collapsed: d, startNodePosition: l, endNodePosition: g, direction: u } = a;
|
|
266
266
|
return i == null || c == null ? null : {
|
|
267
267
|
startOffset: i,
|
|
268
268
|
endOffset: c,
|
|
269
|
-
collapsed:
|
|
270
|
-
startNodePosition:
|
|
269
|
+
collapsed: d,
|
|
270
|
+
startNodePosition: l,
|
|
271
271
|
endNodePosition: g,
|
|
272
272
|
direction: u,
|
|
273
273
|
segmentId: n,
|
|
@@ -283,16 +283,16 @@ let D = class extends Le {
|
|
|
283
283
|
segmentId: "",
|
|
284
284
|
segmentPage: -1,
|
|
285
285
|
isEditing: t,
|
|
286
|
-
style:
|
|
286
|
+
style: rn
|
|
287
287
|
// mock style.
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
|
-
replaceTextRanges(e, t = !0) {
|
|
291
|
-
this._currentSelection != null && (this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.addTextRanges(e, t));
|
|
290
|
+
replaceTextRanges(e, t = !0, n) {
|
|
291
|
+
this._currentSelection != null && (this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.addTextRanges(e, t, n));
|
|
292
292
|
}
|
|
293
293
|
// All textRanges should be synchronized from the render layer.
|
|
294
294
|
_syncSelectionFromRenderService() {
|
|
295
|
-
this._textSelectionRenderManager.textSelectionInner$.pipe(
|
|
295
|
+
this._textSelectionRenderManager.textSelectionInner$.pipe(bt(this.dispose$)).subscribe((e) => {
|
|
296
296
|
e != null && this._replaceTextRangesWithNoRefresh(e);
|
|
297
297
|
});
|
|
298
298
|
}
|
|
@@ -305,13 +305,13 @@ let D = class extends Le {
|
|
|
305
305
|
};
|
|
306
306
|
this._replaceByParam(t), this._textSelection$.next(t);
|
|
307
307
|
const { unitId: n, subUnitId: o, segmentId: r, style: a, textRanges: i, isEditing: c } = t;
|
|
308
|
-
this._commandService.executeCommand(
|
|
308
|
+
this._commandService.executeCommand(Pt.id, {
|
|
309
309
|
unitId: n,
|
|
310
310
|
subUnitId: o,
|
|
311
311
|
segmentId: r,
|
|
312
312
|
style: a,
|
|
313
313
|
isEditing: c,
|
|
314
|
-
ranges: i.map(
|
|
314
|
+
ranges: i.map(Q)
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
_getTextRanges(e) {
|
|
@@ -323,7 +323,7 @@ let D = class extends Le {
|
|
|
323
323
|
}
|
|
324
324
|
_refresh(e) {
|
|
325
325
|
const t = this._getTextRanges(e);
|
|
326
|
-
this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(
|
|
326
|
+
this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(Q));
|
|
327
327
|
}
|
|
328
328
|
_replaceByParam(e) {
|
|
329
329
|
const { unitId: t, subUnitId: n, style: o, segmentId: r, textRanges: a, isEditing: i, segmentPage: c } = e;
|
|
@@ -332,38 +332,38 @@ let D = class extends Le {
|
|
|
332
332
|
_addByParam(e) {
|
|
333
333
|
const { unitId: t, subUnitId: n, textRanges: o, style: r, segmentId: a, isEditing: i, segmentPage: c } = e;
|
|
334
334
|
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map());
|
|
335
|
-
const
|
|
336
|
-
|
|
335
|
+
const d = this._textSelectionInfo.get(t);
|
|
336
|
+
d.has(n) ? d.get(n).textRanges.push(...o) : d.set(n, { textRanges: o, style: r, segmentId: a, isEditing: i, segmentPage: c });
|
|
337
337
|
}
|
|
338
338
|
};
|
|
339
|
-
|
|
340
|
-
dt(0,
|
|
341
|
-
dt(1,
|
|
342
|
-
],
|
|
343
|
-
function
|
|
344
|
-
var
|
|
345
|
-
const { startOffset: o, endOffset: r } = s, a = [], i = o - t, c = r - t,
|
|
346
|
-
|
|
347
|
-
g.has(
|
|
339
|
+
w = xn([
|
|
340
|
+
dt(0, ye),
|
|
341
|
+
dt(1, A)
|
|
342
|
+
], w);
|
|
343
|
+
function Xe(s, e = "", t, n) {
|
|
344
|
+
var I;
|
|
345
|
+
const { startOffset: o, endOffset: r } = s, a = [], i = o - t, c = r - t, d = n.dataStream, l = (I = n.customRanges) == null ? void 0 : I.filter((h) => ke(h.startIndex, h.endIndex, o, r)), g = new Set(l == null ? void 0 : l.filter((h) => je(o, r - o, h, d))), u = /* @__PURE__ */ new Set();
|
|
346
|
+
l == null || l.forEach((h) => {
|
|
347
|
+
g.has(h) || (h.startIndex - t >= i && h.startIndex - t <= c && h.endIndex - t > c && u.add(h.startIndex), h.endIndex - t >= i && h.endIndex - t <= c && h.startIndex < i && u.add(h.endIndex));
|
|
348
348
|
}), i > 0 && a.push({
|
|
349
349
|
t: C.RETAIN,
|
|
350
350
|
len: i,
|
|
351
351
|
segmentId: e
|
|
352
352
|
});
|
|
353
|
-
const
|
|
353
|
+
const S = [...u].sort((h, m) => h - m);
|
|
354
354
|
let f = i;
|
|
355
|
-
return
|
|
356
|
-
const
|
|
357
|
-
|
|
355
|
+
return S.forEach((h) => {
|
|
356
|
+
const m = h - f;
|
|
357
|
+
m > 0 && a.push({
|
|
358
358
|
t: C.DELETE,
|
|
359
|
-
len:
|
|
359
|
+
len: m,
|
|
360
360
|
line: 0,
|
|
361
361
|
segmentId: e
|
|
362
362
|
}), a.push({
|
|
363
363
|
t: C.RETAIN,
|
|
364
364
|
len: 1,
|
|
365
365
|
segmentId: e
|
|
366
|
-
}), f =
|
|
366
|
+
}), f = h + 1;
|
|
367
367
|
}), f < c && (a.push({
|
|
368
368
|
t: C.DELETE,
|
|
369
369
|
len: c - f,
|
|
@@ -375,23 +375,23 @@ function He(s, e = "", t, n) {
|
|
|
375
375
|
retain: u.size
|
|
376
376
|
};
|
|
377
377
|
}
|
|
378
|
-
var
|
|
379
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
378
|
+
var On = Object.defineProperty, Cn = Object.getOwnPropertyDescriptor, yn = (s, e, t, n) => {
|
|
379
|
+
for (var o = n > 1 ? void 0 : n ? Cn(e, t) : e, r = s.length - 1, a; r >= 0; r--)
|
|
380
380
|
(a = s[r]) && (o = (n ? a(e, t, o) : a(o)) || o);
|
|
381
|
-
return n && o &&
|
|
382
|
-
},
|
|
383
|
-
const
|
|
384
|
-
let
|
|
381
|
+
return n && o && On(e, t, o), o;
|
|
382
|
+
}, we = (s, e) => (t, n) => e(t, n, s);
|
|
383
|
+
const lt = 300;
|
|
384
|
+
let _e = class extends Ge {
|
|
385
385
|
constructor(e, t, n) {
|
|
386
386
|
super();
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
b(this, "_docStateChange$", new ne(null));
|
|
388
|
+
b(this, "docStateChange$", this._docStateChange$.asObservable());
|
|
389
389
|
// This cache used for history compose.
|
|
390
|
-
|
|
390
|
+
b(this, "_historyStateCache", /* @__PURE__ */ new Map());
|
|
391
391
|
// This cache used for collaboration state compose.
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
b(this, "_changeStateCache", /* @__PURE__ */ new Map());
|
|
393
|
+
b(this, "_historyTimer", null);
|
|
394
|
+
b(this, "_changeStateCacheTimer", null);
|
|
395
395
|
this._undoRedoService = e, this._commandService = t, this._univerInstanceService = n, this._initialize();
|
|
396
396
|
}
|
|
397
397
|
setChangeState(e) {
|
|
@@ -400,7 +400,7 @@ let Se = class extends Le {
|
|
|
400
400
|
_initialize() {
|
|
401
401
|
this.disposeWithMe(
|
|
402
402
|
this._commandService.beforeCommandExecuted((e) => {
|
|
403
|
-
if (e.id ===
|
|
403
|
+
if (e.id === at || e.id === it) {
|
|
404
404
|
const t = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
405
405
|
if (t == null)
|
|
406
406
|
return;
|
|
@@ -412,19 +412,19 @@ let Se = class extends Le {
|
|
|
412
412
|
}
|
|
413
413
|
_cacheChangeState(e, t = "history") {
|
|
414
414
|
const { trigger: n, unitId: o, noHistory: r, debounce: a = !1 } = e;
|
|
415
|
-
if (r || t === "history" && (n ===
|
|
415
|
+
if (r || n == null || t === "history" && (n === it || n === at))
|
|
416
416
|
return;
|
|
417
417
|
const i = t === "history" ? this._historyStateCache : this._changeStateCache, c = t === "history" ? this._pushHistory.bind(this) : this._emitChangeState.bind(this);
|
|
418
418
|
if (i.has(o)) {
|
|
419
|
-
const
|
|
420
|
-
|
|
419
|
+
const d = i.get(o);
|
|
420
|
+
d == null || d.push(e);
|
|
421
421
|
} else
|
|
422
422
|
i.set(o, [e]);
|
|
423
423
|
a ? t === "history" ? (this._historyTimer && clearTimeout(this._historyTimer), this._historyTimer = setTimeout(() => {
|
|
424
424
|
c(o);
|
|
425
|
-
},
|
|
425
|
+
}, lt)) : (this._changeStateCacheTimer && clearTimeout(this._changeStateCacheTimer), this._changeStateCacheTimer = setTimeout(() => {
|
|
426
426
|
c(o);
|
|
427
|
-
},
|
|
427
|
+
}, lt)) : c(o);
|
|
428
428
|
}
|
|
429
429
|
_pushHistory(e) {
|
|
430
430
|
const t = this._undoRedoService, n = this._historyStateCache.get(e);
|
|
@@ -432,17 +432,17 @@ let Se = class extends Le {
|
|
|
432
432
|
return;
|
|
433
433
|
const o = n.length, r = n[0].commandId, a = n[0], i = n[o - 1], c = {
|
|
434
434
|
unitId: e,
|
|
435
|
-
actions: n.reduce((
|
|
435
|
+
actions: n.reduce((l, g) => B.compose(l, g.redoState.actions), null),
|
|
436
436
|
textRanges: i.redoState.textRanges
|
|
437
|
-
},
|
|
437
|
+
}, d = {
|
|
438
438
|
unitId: e,
|
|
439
439
|
// Always need to put undoParams after redoParams, because `reverse` will change the `cacheStates` order.
|
|
440
|
-
actions: n.reverse().reduce((
|
|
440
|
+
actions: n.reverse().reduce((l, g) => B.compose(l, g.undoState.actions), null),
|
|
441
441
|
textRanges: a.undoState.textRanges
|
|
442
442
|
};
|
|
443
443
|
t.pushUndoRedo({
|
|
444
444
|
unitID: e,
|
|
445
|
-
undoMutations: [{ id: r, params:
|
|
445
|
+
undoMutations: [{ id: r, params: d }],
|
|
446
446
|
redoMutations: [{ id: r, params: c }]
|
|
447
447
|
}), n.length = 0;
|
|
448
448
|
}
|
|
@@ -450,16 +450,16 @@ let Se = class extends Le {
|
|
|
450
450
|
const t = this._changeStateCache.get(e);
|
|
451
451
|
if (!Array.isArray(t) || t.length === 0)
|
|
452
452
|
return;
|
|
453
|
-
const n = t.length, { commandId: o, trigger: r, segmentId: a, noHistory: i, debounce: c } = t[0],
|
|
453
|
+
const n = t.length, { commandId: o, trigger: r, segmentId: a, noHistory: i, debounce: c } = t[0], d = t[0], l = t[n - 1], g = {
|
|
454
454
|
unitId: e,
|
|
455
|
-
actions: t.reduce((f,
|
|
456
|
-
textRanges:
|
|
455
|
+
actions: t.reduce((f, I) => B.compose(f, I.redoState.actions), null),
|
|
456
|
+
textRanges: l.redoState.textRanges
|
|
457
457
|
}, u = {
|
|
458
458
|
unitId: e,
|
|
459
459
|
// Always need to put undoParams after redoParams, because `reverse` will change the `cacheStates` order.
|
|
460
|
-
actions: t.reverse().reduce((f,
|
|
461
|
-
textRanges:
|
|
462
|
-
},
|
|
460
|
+
actions: t.reverse().reduce((f, I) => B.compose(f, I.undoState.actions), null),
|
|
461
|
+
textRanges: d.undoState.textRanges
|
|
462
|
+
}, S = {
|
|
463
463
|
commandId: o,
|
|
464
464
|
unitId: e,
|
|
465
465
|
trigger: r,
|
|
@@ -469,19 +469,19 @@ let Se = class extends Le {
|
|
|
469
469
|
noHistory: i,
|
|
470
470
|
debounce: c
|
|
471
471
|
};
|
|
472
|
-
t.length = 0, this._docStateChange$.next(
|
|
472
|
+
t.length = 0, this._docStateChange$.next(S);
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
],
|
|
480
|
-
class
|
|
475
|
+
_e = yn([
|
|
476
|
+
we(0, ee($e)),
|
|
477
|
+
we(1, A),
|
|
478
|
+
we(2, U)
|
|
479
|
+
], _e);
|
|
480
|
+
class Ee {
|
|
481
481
|
constructor() {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
482
|
+
b(this, "_previousActiveRange", null);
|
|
483
|
+
b(this, "_undoMutationParamsCache", []);
|
|
484
|
+
b(this, "_redoMutationParamsCache", []);
|
|
485
485
|
}
|
|
486
486
|
clearUndoRedoMutationParamsCache() {
|
|
487
487
|
this._undoMutationParamsCache = [], this._redoMutationParamsCache = [];
|
|
@@ -509,13 +509,13 @@ class ye {
|
|
|
509
509
|
return null;
|
|
510
510
|
const { unitId: e } = this._undoMutationParamsCache[0], t = {
|
|
511
511
|
unitId: e,
|
|
512
|
-
actions: this._undoMutationParamsCache.reverse().reduce((o, r) =>
|
|
512
|
+
actions: this._undoMutationParamsCache.reverse().reduce((o, r) => B.compose(o, r.actions), null),
|
|
513
513
|
textRanges: []
|
|
514
514
|
// Add empty array, will never use, just fix type error
|
|
515
515
|
};
|
|
516
516
|
return { redoMutationParams: {
|
|
517
517
|
unitId: e,
|
|
518
|
-
actions: this._redoMutationParamsCache.reduce((o, r) =>
|
|
518
|
+
actions: this._redoMutationParamsCache.reduce((o, r) => B.compose(o, r.actions), null),
|
|
519
519
|
textRanges: []
|
|
520
520
|
// Add empty array, will never use, just fix type error
|
|
521
521
|
}, undoMutationParams: t, previousActiveRange: this._previousActiveRange };
|
|
@@ -524,24 +524,24 @@ class ye {
|
|
|
524
524
|
this._undoMutationParamsCache = [], this._redoMutationParamsCache = [], this._previousActiveRange = null;
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
-
var
|
|
528
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
527
|
+
var Mn = Object.defineProperty, Tn = Object.getOwnPropertyDescriptor, En = (s, e, t, n) => {
|
|
528
|
+
for (var o = n > 1 ? void 0 : n ? Tn(e, t) : e, r = s.length - 1, a; r >= 0; r--)
|
|
529
529
|
(a = s[r]) && (o = (n ? a(e, t, o) : a(o)) || o);
|
|
530
|
-
return n && o &&
|
|
531
|
-
},
|
|
532
|
-
let
|
|
530
|
+
return n && o && Mn(e, t, o), o;
|
|
531
|
+
}, ut = (s, e) => (t, n) => e(t, n, s);
|
|
532
|
+
let W = class extends Ge {
|
|
533
533
|
constructor(e, t, n) {
|
|
534
534
|
super();
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
535
|
+
b(this, "_skeleton");
|
|
536
|
+
b(this, "_docViewModel");
|
|
537
|
+
b(this, "_currentSkeleton$", new ne(null));
|
|
538
|
+
b(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
|
|
539
539
|
// CurrentSkeletonBefore for pre-triggered logic during registration
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
this._context = e, this._localeService = t, this._univerInstanceService = n, this._init(), this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
540
|
+
b(this, "_currentSkeletonBefore$", new ne(null));
|
|
541
|
+
b(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
|
|
542
|
+
b(this, "_currentViewModel$", new ne(null));
|
|
543
|
+
b(this, "currentViewModel$", this._currentViewModel$.asObservable());
|
|
544
|
+
this._context = e, this._localeService = t, this._univerInstanceService = n, this._init(), this._univerInstanceService.getCurrentTypeOfUnit$(J.UNIVER_DOC).pipe(bt(this.dispose$)).subscribe((o) => {
|
|
545
545
|
(o == null ? void 0 : o.getUnitId()) === this._context.unitId && this._update(o);
|
|
546
546
|
});
|
|
547
547
|
}
|
|
@@ -562,27 +562,27 @@ let X = class extends Le {
|
|
|
562
562
|
const t = this._context.unitId;
|
|
563
563
|
if (e.getBody() == null)
|
|
564
564
|
return;
|
|
565
|
-
this._docViewModel && t ===
|
|
565
|
+
this._docViewModel && t === Mt ? (this._docViewModel.reset(e), this._context.unit = e) : this._docViewModel || (this._docViewModel = this._buildDocViewModel(e)), this._skeleton || (this._skeleton = this._buildSkeleton(this._docViewModel));
|
|
566
566
|
const n = this._skeleton;
|
|
567
567
|
n.calculate(), this._currentSkeletonBefore$.next(n), this._currentSkeleton$.next(n), this._currentViewModel$.next(this._docViewModel);
|
|
568
568
|
}
|
|
569
569
|
_buildSkeleton(e) {
|
|
570
|
-
return
|
|
570
|
+
return an.create(e, this._localeService);
|
|
571
571
|
}
|
|
572
572
|
_buildDocViewModel(e) {
|
|
573
|
-
return new
|
|
573
|
+
return new cn(e);
|
|
574
574
|
}
|
|
575
575
|
};
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
],
|
|
580
|
-
const
|
|
581
|
-
id:
|
|
582
|
-
type:
|
|
576
|
+
W = En([
|
|
577
|
+
ut(1, ee(Wt)),
|
|
578
|
+
ut(2, U)
|
|
579
|
+
], W);
|
|
580
|
+
const gt = "doc.mutation.rich-text-editing", G = {
|
|
581
|
+
id: gt,
|
|
582
|
+
type: E.MUTATION,
|
|
583
583
|
// eslint-disable-next-line max-lines-per-function
|
|
584
584
|
handler: (s, e) => {
|
|
585
|
-
var
|
|
585
|
+
var y, T;
|
|
586
586
|
const {
|
|
587
587
|
unitId: t,
|
|
588
588
|
segmentId: n = "",
|
|
@@ -591,25 +591,25 @@ const ft = "doc.mutation.rich-text-editing", F = {
|
|
|
591
591
|
prevTextRanges: a,
|
|
592
592
|
trigger: i,
|
|
593
593
|
noHistory: c,
|
|
594
|
-
isCompositionEnd:
|
|
595
|
-
noNeedSetTextRange:
|
|
594
|
+
isCompositionEnd: d,
|
|
595
|
+
noNeedSetTextRange: l,
|
|
596
596
|
debounce: g
|
|
597
|
-
} = e, u = s.get(
|
|
598
|
-
if (f == null ||
|
|
597
|
+
} = e, u = s.get(U), S = s.get(ie), f = u.getUniverDocInstance(t), I = (y = S.getRenderById(t)) == null ? void 0 : y.with(W).getViewModel();
|
|
598
|
+
if (f == null || I == null)
|
|
599
599
|
throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${t}`);
|
|
600
|
-
const
|
|
601
|
-
if (
|
|
600
|
+
const h = s.get(w), p = ((T = h.getCurrentSelections()) != null ? T : []).map(Q), v = s.get(_e), x = s.get(Ee), M = !!f.getSnapshot().disabled;
|
|
601
|
+
if (B.isNoop(o) || o && o.length === 0 || M)
|
|
602
602
|
return {
|
|
603
603
|
unitId: t,
|
|
604
604
|
actions: [],
|
|
605
605
|
textRanges: p
|
|
606
606
|
};
|
|
607
|
-
const _ =
|
|
608
|
-
f.apply(o),
|
|
609
|
-
|
|
607
|
+
const _ = B.invertWithDoc(o, f.getSnapshot());
|
|
608
|
+
f.apply(o), I.reset(f), !l && r && i != null && queueMicrotask(() => {
|
|
609
|
+
h.replaceTextRanges(r, !0, e.options);
|
|
610
610
|
});
|
|
611
|
-
const
|
|
612
|
-
commandId:
|
|
611
|
+
const O = {
|
|
612
|
+
commandId: gt,
|
|
613
613
|
unitId: t,
|
|
614
614
|
segmentId: n,
|
|
615
615
|
trigger: i,
|
|
@@ -624,25 +624,25 @@ const ft = "doc.mutation.rich-text-editing", F = {
|
|
|
624
624
|
textRanges: a != null ? a : p
|
|
625
625
|
}
|
|
626
626
|
};
|
|
627
|
-
if (
|
|
628
|
-
const
|
|
629
|
-
if (
|
|
627
|
+
if (d) {
|
|
628
|
+
const R = x.fetchComposedUndoRedoMutationParams();
|
|
629
|
+
if (R == null)
|
|
630
630
|
throw new Error("historyParams is null in RichTextEditingMutation");
|
|
631
|
-
const { undoMutationParams:
|
|
632
|
-
|
|
631
|
+
const { undoMutationParams: D, redoMutationParams: N, previousActiveRange: L } = R;
|
|
632
|
+
O.redoState.actions = N.actions, O.undoState.actions = D.actions, O.undoState.textRanges = [L];
|
|
633
633
|
}
|
|
634
|
-
return
|
|
634
|
+
return v.setChangeState(O), {
|
|
635
635
|
unitId: t,
|
|
636
636
|
actions: _,
|
|
637
637
|
textRanges: p
|
|
638
638
|
};
|
|
639
639
|
}
|
|
640
640
|
};
|
|
641
|
-
function
|
|
641
|
+
function wt(s, e) {
|
|
642
642
|
var n;
|
|
643
|
-
return (n = s.get(
|
|
643
|
+
return (n = s.get(ie).getRenderById(e)) == null ? void 0 : n.with(W);
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function j(s, e = "") {
|
|
646
646
|
if (!e)
|
|
647
647
|
return ["body"];
|
|
648
648
|
const { headers: t, footers: n } = s.getSnapshot();
|
|
@@ -654,76 +654,76 @@ function z(s, e = "") {
|
|
|
654
654
|
return ["footers", e, "body"];
|
|
655
655
|
throw new Error("Segment id not found in headers or footers");
|
|
656
656
|
}
|
|
657
|
-
const
|
|
658
|
-
id:
|
|
659
|
-
type:
|
|
657
|
+
const An = "doc.command.insert-text", ve = {
|
|
658
|
+
id: An,
|
|
659
|
+
type: E.COMMAND,
|
|
660
660
|
// eslint-disable-next-line max-lines-per-function
|
|
661
661
|
handler: async (s, e) => {
|
|
662
|
-
var
|
|
663
|
-
const t = s.get(
|
|
662
|
+
var y;
|
|
663
|
+
const t = s.get(A), { range: n, segmentId: o, body: r, unitId: a, textRanges: i, cursorOffset: c } = e, d = s.get(w), g = s.get(U).getUnit(a, J.UNIVER_DOC);
|
|
664
664
|
if (g == null)
|
|
665
665
|
return !1;
|
|
666
|
-
const u =
|
|
667
|
-
if (!
|
|
666
|
+
const u = d.getActiveRange(), S = g.getSelfOrHeaderFooterModel((y = u == null ? void 0 : u.segmentId) != null ? y : "").getBody();
|
|
667
|
+
if (!S)
|
|
668
668
|
return !1;
|
|
669
|
-
const f =
|
|
669
|
+
const f = Me(n, S), { startOffset: I, collapsed: h } = f, m = c != null ? c : r.dataStream.length, p = [
|
|
670
670
|
{
|
|
671
|
-
startOffset:
|
|
672
|
-
endOffset:
|
|
671
|
+
startOffset: I + m,
|
|
672
|
+
endOffset: I + m,
|
|
673
673
|
style: u == null ? void 0 : u.style,
|
|
674
|
-
collapsed:
|
|
674
|
+
collapsed: h
|
|
675
675
|
}
|
|
676
|
-
],
|
|
677
|
-
id:
|
|
676
|
+
], v = {
|
|
677
|
+
id: G.id,
|
|
678
678
|
params: {
|
|
679
679
|
unitId: a,
|
|
680
680
|
actions: [],
|
|
681
681
|
textRanges: i != null ? i : p,
|
|
682
682
|
debounce: !0
|
|
683
683
|
}
|
|
684
|
-
},
|
|
685
|
-
if (
|
|
686
|
-
|
|
684
|
+
}, x = new $(), M = B.getInstance();
|
|
685
|
+
if (h)
|
|
686
|
+
I > 0 && x.push({
|
|
687
687
|
t: C.RETAIN,
|
|
688
|
-
len:
|
|
688
|
+
len: I,
|
|
689
689
|
segmentId: o
|
|
690
690
|
});
|
|
691
691
|
else {
|
|
692
|
-
const { dos:
|
|
693
|
-
|
|
694
|
-
startOffset:
|
|
695
|
-
endOffset:
|
|
696
|
-
collapsed:
|
|
692
|
+
const { dos: T, retain: R } = Xe(f, o, 0, S);
|
|
693
|
+
x.push(...T), i || (v.params.textRanges = [{
|
|
694
|
+
startOffset: I + m + R,
|
|
695
|
+
endOffset: I + m + R,
|
|
696
|
+
collapsed: h
|
|
697
697
|
}]);
|
|
698
698
|
}
|
|
699
|
-
|
|
699
|
+
x.push({
|
|
700
700
|
t: C.INSERT,
|
|
701
701
|
body: r,
|
|
702
702
|
len: r.dataStream.length,
|
|
703
703
|
line: 0,
|
|
704
704
|
segmentId: o
|
|
705
705
|
});
|
|
706
|
-
const _ =
|
|
707
|
-
return
|
|
706
|
+
const _ = j(g, o);
|
|
707
|
+
return v.params.actions = M.editOp(x.serialize(), _), !!t.syncExecuteCommand(v.id, v.params);
|
|
708
708
|
}
|
|
709
709
|
};
|
|
710
|
-
var
|
|
711
|
-
const
|
|
710
|
+
var k = /* @__PURE__ */ ((s) => (s[s.LEFT = 0] = "LEFT", s[s.RIGHT = 1] = "RIGHT", s))(k || {});
|
|
711
|
+
const se = {
|
|
712
712
|
id: "doc.command.delete-text",
|
|
713
|
-
type:
|
|
713
|
+
type: E.COMMAND,
|
|
714
714
|
handler: async (s, e) => {
|
|
715
|
-
var
|
|
716
|
-
const t = s.get(
|
|
717
|
-
if (
|
|
715
|
+
var T;
|
|
716
|
+
const t = s.get(A), n = s.get(U), { range: o, segmentId: r, unitId: a, direction: i, len: c = 1 } = e, d = n.getUnit(a, J.UNIVER_DOC), l = d == null ? void 0 : d.getSelfOrHeaderFooterModel(r).getBody();
|
|
717
|
+
if (d == null || l == null)
|
|
718
718
|
return !1;
|
|
719
|
-
const { startOffset: g } = o, u =
|
|
720
|
-
for (let
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}),
|
|
725
|
-
const p =
|
|
726
|
-
id:
|
|
719
|
+
const { startOffset: g } = o, u = l.dataStream, S = i === 0 ? g - c : g, f = S + c - 1, I = (T = l.customRanges) == null ? void 0 : T.filter((R) => ke(R.startIndex, R.endIndex, S, f)), h = I == null ? void 0 : I.filter((R) => je(S, c, R, u)), m = [];
|
|
720
|
+
for (let R = 0; R < c; R++)
|
|
721
|
+
m.push(S + R);
|
|
722
|
+
h == null || h.forEach((R) => {
|
|
723
|
+
m.push(R.startIndex, R.endIndex);
|
|
724
|
+
}), m.sort((R, D) => R - D);
|
|
725
|
+
const p = m[0], v = {
|
|
726
|
+
id: G.id,
|
|
727
727
|
params: {
|
|
728
728
|
unitId: a,
|
|
729
729
|
actions: [],
|
|
@@ -734,39 +734,39 @@ const Xe = {
|
|
|
734
734
|
}],
|
|
735
735
|
debounce: !0
|
|
736
736
|
}
|
|
737
|
-
},
|
|
737
|
+
}, x = new $(), M = B.getInstance();
|
|
738
738
|
let _ = 0;
|
|
739
|
-
for (let
|
|
740
|
-
const
|
|
741
|
-
|
|
739
|
+
for (let R = 0; R < m.length; R++) {
|
|
740
|
+
const D = m[R];
|
|
741
|
+
D - _ > 0 && x.push({
|
|
742
742
|
t: C.RETAIN,
|
|
743
|
-
len:
|
|
743
|
+
len: D - _,
|
|
744
744
|
segmentId: r
|
|
745
|
-
}),
|
|
745
|
+
}), x.push({
|
|
746
746
|
t: C.DELETE,
|
|
747
747
|
len: 1,
|
|
748
748
|
segmentId: r,
|
|
749
749
|
line: 0
|
|
750
|
-
}), _ =
|
|
750
|
+
}), _ = D + 1;
|
|
751
751
|
}
|
|
752
|
-
const
|
|
753
|
-
return
|
|
752
|
+
const O = j(d, r);
|
|
753
|
+
return v.params.actions = M.editOp(x.serialize(), O), !!t.syncExecuteCommand(v.id, v.params);
|
|
754
754
|
}
|
|
755
|
-
},
|
|
755
|
+
}, Ut = {
|
|
756
756
|
id: "doc.command.update-text",
|
|
757
|
-
type:
|
|
757
|
+
type: E.COMMAND,
|
|
758
758
|
handler: async (s, e) => {
|
|
759
|
-
const { range: t, segmentId: n, updateBody: o, coverType: r, unitId: a, textRanges: i } = e, c = s.get(
|
|
760
|
-
if (
|
|
759
|
+
const { range: t, segmentId: n, updateBody: o, coverType: r, unitId: a, textRanges: i } = e, c = s.get(A), l = s.get(U).getCurrentUniverDocInstance();
|
|
760
|
+
if (l == null)
|
|
761
761
|
return !1;
|
|
762
762
|
const g = {
|
|
763
|
-
id:
|
|
763
|
+
id: G.id,
|
|
764
764
|
params: {
|
|
765
765
|
unitId: a,
|
|
766
766
|
actions: [],
|
|
767
767
|
textRanges: i
|
|
768
768
|
}
|
|
769
|
-
}, u = new
|
|
769
|
+
}, u = new $(), S = B.getInstance(), { startOffset: f, endOffset: I } = t;
|
|
770
770
|
u.push({
|
|
771
771
|
t: C.RETAIN,
|
|
772
772
|
len: f,
|
|
@@ -774,100 +774,100 @@ const Xe = {
|
|
|
774
774
|
}), u.push({
|
|
775
775
|
t: C.RETAIN,
|
|
776
776
|
body: o,
|
|
777
|
-
len:
|
|
777
|
+
len: I - f,
|
|
778
778
|
segmentId: n,
|
|
779
779
|
coverType: r
|
|
780
780
|
});
|
|
781
|
-
const
|
|
782
|
-
return g.params.actions =
|
|
781
|
+
const h = j(l, n);
|
|
782
|
+
return g.params.actions = S.editOp(u.serialize(), h), !!c.syncExecuteCommand(g.id, g.params);
|
|
783
783
|
}
|
|
784
784
|
};
|
|
785
|
-
function
|
|
785
|
+
function ft(s, e) {
|
|
786
786
|
const t = [];
|
|
787
787
|
for (let n = 0, o = s.length; n < o; n++)
|
|
788
|
-
s[n] ===
|
|
788
|
+
s[n] === P.PARAGRAPH && t.push({
|
|
789
789
|
startIndex: n
|
|
790
790
|
});
|
|
791
791
|
if (e)
|
|
792
792
|
for (const n of t)
|
|
793
|
-
e.bullet && (n.bullet =
|
|
793
|
+
e.bullet && (n.bullet = q.deepClone(e.bullet)), e.paragraphStyle && (n.paragraphStyle = q.deepClone(e.paragraphStyle));
|
|
794
794
|
return t;
|
|
795
795
|
}
|
|
796
|
-
const
|
|
796
|
+
const Nn = {
|
|
797
797
|
id: "doc.command.break-line",
|
|
798
|
-
type:
|
|
798
|
+
type: E.COMMAND,
|
|
799
799
|
handler: async (s) => {
|
|
800
|
-
var
|
|
801
|
-
const e = s.get(
|
|
800
|
+
var S;
|
|
801
|
+
const e = s.get(w), t = s.get(U), n = s.get(A), o = e.getActiveRange();
|
|
802
802
|
if (o == null)
|
|
803
803
|
return !1;
|
|
804
|
-
const r = t.getCurrentUniverDocInstance(),
|
|
805
|
-
if (!
|
|
804
|
+
const { segmentId: r } = o, a = t.getCurrentUniverDocInstance(), i = a == null ? void 0 : a.getSelfOrHeaderFooterModel(r).getBody();
|
|
805
|
+
if (!a || !i)
|
|
806
806
|
return !1;
|
|
807
|
-
const
|
|
807
|
+
const c = a.getUnitId(), { startOffset: d, endOffset: l } = Me(o, i), u = ((S = i.paragraphs) != null ? S : []).find((f) => f.startIndex >= d);
|
|
808
808
|
if (u && u.startIndex > l) {
|
|
809
|
-
const
|
|
810
|
-
startOffset:
|
|
809
|
+
const f = Yt(Tt(i, l, u.startIndex)), I = {
|
|
810
|
+
startOffset: d,
|
|
811
811
|
endOffset: u.startIndex,
|
|
812
812
|
collapsed: !1
|
|
813
813
|
};
|
|
814
814
|
return Kt(
|
|
815
|
-
|
|
815
|
+
f,
|
|
816
816
|
{
|
|
817
|
-
dataStream:
|
|
818
|
-
paragraphs:
|
|
817
|
+
dataStream: P.PARAGRAPH,
|
|
818
|
+
paragraphs: ft(P.PARAGRAPH, u)
|
|
819
819
|
},
|
|
820
820
|
1,
|
|
821
821
|
0
|
|
822
|
-
), await n.executeCommand(
|
|
823
|
-
unitId:
|
|
824
|
-
body:
|
|
825
|
-
range:
|
|
826
|
-
segmentId:
|
|
822
|
+
), await n.executeCommand(ve.id, {
|
|
823
|
+
unitId: c,
|
|
824
|
+
body: f,
|
|
825
|
+
range: I,
|
|
826
|
+
segmentId: r,
|
|
827
827
|
cursorOffset: 1
|
|
828
828
|
});
|
|
829
829
|
} else
|
|
830
|
-
return await n.executeCommand(
|
|
831
|
-
unitId:
|
|
830
|
+
return await n.executeCommand(ve.id, {
|
|
831
|
+
unitId: c,
|
|
832
832
|
body: {
|
|
833
|
-
dataStream:
|
|
834
|
-
paragraphs:
|
|
833
|
+
dataStream: P.PARAGRAPH,
|
|
834
|
+
paragraphs: ft(P.PARAGRAPH, u)
|
|
835
835
|
},
|
|
836
836
|
range: o,
|
|
837
|
-
segmentId:
|
|
837
|
+
segmentId: r
|
|
838
838
|
});
|
|
839
839
|
}
|
|
840
|
-
},
|
|
840
|
+
}, bs = {
|
|
841
841
|
id: "doc.command.inner-paste",
|
|
842
|
-
type:
|
|
842
|
+
type: E.COMMAND,
|
|
843
843
|
handler: async (s, e) => {
|
|
844
|
-
const { segmentId: t, textRanges: n } = e, o = e.body, r = s.get(
|
|
844
|
+
const { segmentId: t, textRanges: n } = e, o = e.body, r = s.get(A), a = s.get(w), i = s.get(U), c = a.getCurrentSelections();
|
|
845
845
|
if (!Array.isArray(c) || c.length === 0)
|
|
846
846
|
return !1;
|
|
847
|
-
const
|
|
848
|
-
if (
|
|
847
|
+
const d = i.getCurrentUniverDocInstance(), l = d == null ? void 0 : d.getSelfOrHeaderFooterModel(t).getBody();
|
|
848
|
+
if (d == null || l == null)
|
|
849
849
|
return !1;
|
|
850
|
-
const g =
|
|
851
|
-
id:
|
|
850
|
+
const g = d.getUnitId(), u = {
|
|
851
|
+
id: G.id,
|
|
852
852
|
params: {
|
|
853
853
|
unitId: g,
|
|
854
854
|
actions: [],
|
|
855
855
|
textRanges: n
|
|
856
856
|
}
|
|
857
|
-
},
|
|
858
|
-
|
|
859
|
-
const f = new
|
|
857
|
+
}, S = new re();
|
|
858
|
+
S.reset();
|
|
859
|
+
const f = new $(), I = B.getInstance();
|
|
860
860
|
for (const p of c) {
|
|
861
|
-
const { startOffset:
|
|
862
|
-
if (
|
|
861
|
+
const { startOffset: v, endOffset: x, collapsed: M } = p, _ = v - S.cursor;
|
|
862
|
+
if (M)
|
|
863
863
|
f.push({
|
|
864
864
|
t: C.RETAIN,
|
|
865
865
|
len: _,
|
|
866
866
|
segmentId: t
|
|
867
867
|
});
|
|
868
868
|
else {
|
|
869
|
-
const { dos:
|
|
870
|
-
f.push(...
|
|
869
|
+
const { dos: O } = Xe(p, t, S.cursor, l);
|
|
870
|
+
f.push(...O);
|
|
871
871
|
}
|
|
872
872
|
f.push({
|
|
873
873
|
t: C.INSERT,
|
|
@@ -875,306 +875,440 @@ const En = {
|
|
|
875
875
|
len: o.dataStream.length,
|
|
876
876
|
line: 0,
|
|
877
877
|
segmentId: t
|
|
878
|
-
}),
|
|
878
|
+
}), S.reset(), S.moveCursor(x);
|
|
879
879
|
}
|
|
880
|
-
const
|
|
881
|
-
return u.params.actions =
|
|
880
|
+
const h = j(d, t);
|
|
881
|
+
return u.params.actions = I.editOp(f.serialize(), h), !!r.syncExecuteCommand(u.id, u.params);
|
|
882
882
|
}
|
|
883
883
|
}, Bt = {
|
|
884
884
|
id: "doc.command.inner-cut",
|
|
885
|
-
type:
|
|
885
|
+
type: E.COMMAND,
|
|
886
|
+
// eslint-disable-next-line max-lines-per-function
|
|
886
887
|
handler: async (s, e) => {
|
|
887
|
-
var
|
|
888
|
-
const { segmentId: t, textRanges: n } = e, o = s.get(
|
|
888
|
+
var _, O, y;
|
|
889
|
+
const { segmentId: t, textRanges: n } = e, o = s.get(A), r = s.get(w), a = s.get(U), i = r.getCurrentSelections();
|
|
889
890
|
if (!Array.isArray(i) || i.length === 0)
|
|
890
891
|
return !1;
|
|
891
|
-
const c = (
|
|
892
|
+
const c = (_ = a.getCurrentUniverDocInstance()) == null ? void 0 : _.getUnitId();
|
|
892
893
|
if (!c)
|
|
893
894
|
return !1;
|
|
894
|
-
const
|
|
895
|
-
if (
|
|
895
|
+
const d = a.getUniverDocInstance(c), l = Zt(d.getSnapshot(), t);
|
|
896
|
+
if (d == null || l == null)
|
|
896
897
|
return !1;
|
|
897
898
|
const g = {
|
|
898
|
-
id:
|
|
899
|
+
id: G.id,
|
|
899
900
|
params: {
|
|
900
901
|
unitId: c,
|
|
901
902
|
actions: [],
|
|
902
903
|
textRanges: n
|
|
903
904
|
}
|
|
904
|
-
}, u = new
|
|
905
|
+
}, u = new re();
|
|
905
906
|
u.reset();
|
|
906
|
-
const
|
|
907
|
-
for (const
|
|
908
|
-
const { startOffset: R, endOffset:
|
|
909
|
-
|
|
907
|
+
const S = new $(), f = B.getInstance(), I = [];
|
|
908
|
+
for (const T of i) {
|
|
909
|
+
const { startOffset: R, endOffset: D, collapsed: N } = T;
|
|
910
|
+
if (R == null || D == null)
|
|
911
|
+
continue;
|
|
912
|
+
const L = R - u.cursor;
|
|
913
|
+
N ? S.push({
|
|
910
914
|
t: C.RETAIN,
|
|
911
|
-
len:
|
|
915
|
+
len: L,
|
|
912
916
|
segmentId: t
|
|
913
|
-
}) :
|
|
917
|
+
}) : S.push(...bn(T, l, t, u.cursor)), u.reset(), u.moveCursor(D);
|
|
914
918
|
}
|
|
915
|
-
const
|
|
916
|
-
|
|
919
|
+
const h = j(d, t);
|
|
920
|
+
I.push(f.editOp(S.serialize(), h));
|
|
921
|
+
const m = Dn(l, i), p = (O = d.getDrawings()) != null ? O : {}, v = (y = d.getDrawingsOrder()) != null ? y : [], x = m.sort((T, R) => v.indexOf(T) > v.indexOf(R) ? -1 : v.indexOf(T) < v.indexOf(R) ? 1 : 0);
|
|
922
|
+
if (x.length > 0)
|
|
923
|
+
for (const T of x) {
|
|
924
|
+
const R = p[T], D = v.indexOf(T);
|
|
925
|
+
if (R == null || D < 0)
|
|
926
|
+
continue;
|
|
927
|
+
const N = f.removeOp(["drawings", T], R), L = f.removeOp(["drawingsOrder", D], T);
|
|
928
|
+
I.push(N), I.push(L);
|
|
929
|
+
}
|
|
930
|
+
return g.params.actions = I.reduce((T, R) => B.compose(T, R), null), !!o.syncExecuteCommand(g.id, g.params);
|
|
917
931
|
}
|
|
918
932
|
};
|
|
919
|
-
function
|
|
920
|
-
|
|
921
|
-
const
|
|
922
|
-
|
|
923
|
-
|
|
933
|
+
function Dn(s, e) {
|
|
934
|
+
const t = [], { customBlocks: n = [] } = s;
|
|
935
|
+
for (const o of e) {
|
|
936
|
+
const { startOffset: r, endOffset: a } = o;
|
|
937
|
+
if (!(r == null || a == null))
|
|
938
|
+
for (const i of n) {
|
|
939
|
+
const { startIndex: c } = i;
|
|
940
|
+
c >= r && c < a && t.push(i.blockId);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return t;
|
|
944
|
+
}
|
|
945
|
+
function bn(s, e, t = "", n = 0) {
|
|
946
|
+
var m;
|
|
947
|
+
const { startOffset: o, endOffset: r } = He(s, e), a = [], { paragraphs: i = [], dataStream: c } = e, d = o - n, l = r - n, g = i == null ? void 0 : i.find(
|
|
948
|
+
(p) => p.startIndex - n >= d && p.startIndex - n <= l
|
|
949
|
+
), u = (m = e.customRanges) == null ? void 0 : m.filter((p) => ke(p.startIndex, p.endIndex, o, r)), S = new Set(u == null ? void 0 : u.filter((p) => je(o, r - o, p, c))), f = /* @__PURE__ */ new Set();
|
|
924
950
|
if (u == null || u.forEach((p) => {
|
|
925
|
-
|
|
926
|
-
}),
|
|
951
|
+
S.has(p) || (p.startIndex - n >= d && p.startIndex - n <= l && p.endIndex - n > l && f.add(p.startIndex), p.endIndex - n >= d && p.endIndex - n <= l && p.startIndex < d && f.add(p.endIndex));
|
|
952
|
+
}), d > 0 && a.push({
|
|
927
953
|
t: C.RETAIN,
|
|
928
|
-
len:
|
|
954
|
+
len: d,
|
|
929
955
|
segmentId: t
|
|
930
|
-
}), g && g.startIndex - n >
|
|
956
|
+
}), g && g.startIndex - n > d) {
|
|
931
957
|
const p = g.startIndex - n;
|
|
932
958
|
f.add(p);
|
|
933
959
|
}
|
|
934
|
-
const
|
|
935
|
-
let
|
|
936
|
-
return
|
|
937
|
-
const
|
|
938
|
-
|
|
960
|
+
const I = [...f].sort((p, v) => p - v);
|
|
961
|
+
let h = d;
|
|
962
|
+
return I.forEach((p) => {
|
|
963
|
+
const v = p - h;
|
|
964
|
+
v > 0 && a.push({
|
|
939
965
|
t: C.DELETE,
|
|
940
|
-
len:
|
|
966
|
+
len: v,
|
|
941
967
|
line: 0,
|
|
942
968
|
segmentId: t
|
|
943
969
|
}), a.push({
|
|
944
970
|
t: C.RETAIN,
|
|
945
971
|
len: 1,
|
|
946
972
|
segmentId: t
|
|
947
|
-
}),
|
|
948
|
-
}),
|
|
973
|
+
}), h = p + 1;
|
|
974
|
+
}), h < l && a.push({
|
|
949
975
|
t: C.DELETE,
|
|
950
|
-
len:
|
|
976
|
+
len: l - h,
|
|
951
977
|
line: 0,
|
|
952
978
|
segmentId: t
|
|
953
979
|
}), a;
|
|
954
980
|
}
|
|
955
981
|
const Ve = {
|
|
982
|
+
id: "doc.command.delete-custom-block",
|
|
983
|
+
type: E.COMMAND,
|
|
984
|
+
handler: async (s, e) => {
|
|
985
|
+
var R;
|
|
986
|
+
const t = s.get(w), n = s.get(U), o = s.get(A), r = t.getActiveRange(), a = n.getCurrentUniverDocInstance();
|
|
987
|
+
if (r == null || a == null)
|
|
988
|
+
return !1;
|
|
989
|
+
const { direction: i, range: c, unitId: d, drawingId: l } = e, { startOffset: g, segmentId: u, style: S } = r, f = i === k.LEFT ? g - 1 : g, I = [
|
|
990
|
+
{
|
|
991
|
+
startOffset: f,
|
|
992
|
+
endOffset: f,
|
|
993
|
+
style: S
|
|
994
|
+
}
|
|
995
|
+
], h = {
|
|
996
|
+
id: G.id,
|
|
997
|
+
params: {
|
|
998
|
+
unitId: d,
|
|
999
|
+
actions: [],
|
|
1000
|
+
textRanges: I,
|
|
1001
|
+
prevTextRanges: [c]
|
|
1002
|
+
}
|
|
1003
|
+
}, m = new $(), p = B.getInstance(), v = [];
|
|
1004
|
+
g > 0 && m.push({
|
|
1005
|
+
t: C.RETAIN,
|
|
1006
|
+
len: i === k.LEFT ? g - 1 : g,
|
|
1007
|
+
segmentId: u
|
|
1008
|
+
}), m.push({
|
|
1009
|
+
t: C.DELETE,
|
|
1010
|
+
len: 1,
|
|
1011
|
+
line: 0,
|
|
1012
|
+
segmentId: u
|
|
1013
|
+
}), v.push(p.editOp(m.serialize()));
|
|
1014
|
+
const x = ((R = a.getDrawings()) != null ? R : {})[l], _ = a.getDrawingsOrder().indexOf(l), O = p.removeOp(["drawings", l], x), y = p.removeOp(["drawingsOrder", _], l);
|
|
1015
|
+
return v.push(O), v.push(y), h.params.actions = v.reduce((D, N) => B.compose(D, N), null), !!o.syncExecuteCommand(h.id, h.params);
|
|
1016
|
+
}
|
|
1017
|
+
}, We = {
|
|
956
1018
|
id: "doc.command.merge-two-paragraph",
|
|
957
|
-
type:
|
|
1019
|
+
type: E.COMMAND,
|
|
958
1020
|
// eslint-disable-next-line max-lines-per-function
|
|
959
1021
|
handler: async (s, e) => {
|
|
960
|
-
var
|
|
961
|
-
const t = s.get(
|
|
1022
|
+
var D, N;
|
|
1023
|
+
const t = s.get(w), n = s.get(U), o = s.get(A), { direction: r, range: a } = e, i = t.getActiveRange(), c = t.getCurrentSelections();
|
|
962
1024
|
if (i == null || c == null)
|
|
963
1025
|
return !1;
|
|
964
|
-
const { segmentId:
|
|
1026
|
+
const { segmentId: d, style: l } = i, g = n.getCurrentUniverDocInstance(), u = g == null ? void 0 : g.getSelfOrHeaderFooterModel(d).getBody();
|
|
965
1027
|
if (!g || !u)
|
|
966
1028
|
return !1;
|
|
967
|
-
const
|
|
968
|
-
if (!
|
|
1029
|
+
const S = He(i, u), { startOffset: f, collapsed: I } = S;
|
|
1030
|
+
if (!I)
|
|
969
1031
|
return !1;
|
|
970
|
-
const
|
|
1032
|
+
const h = r === k.LEFT ? f : f + 1, m = (N = (D = u.paragraphs) == null ? void 0 : D.find((L) => L.startIndex >= h)) == null ? void 0 : N.startIndex, p = Un(u, h, m), v = r === k.LEFT ? f - 1 : f, x = g.getUnitId(), M = [
|
|
971
1033
|
{
|
|
972
|
-
startOffset:
|
|
973
|
-
endOffset:
|
|
974
|
-
style:
|
|
1034
|
+
startOffset: v,
|
|
1035
|
+
endOffset: v,
|
|
1036
|
+
style: l
|
|
975
1037
|
}
|
|
976
1038
|
], _ = {
|
|
977
|
-
id:
|
|
1039
|
+
id: G.id,
|
|
978
1040
|
params: {
|
|
979
|
-
unitId:
|
|
1041
|
+
unitId: x,
|
|
980
1042
|
actions: [],
|
|
981
|
-
textRanges:
|
|
1043
|
+
textRanges: M,
|
|
982
1044
|
prevTextRanges: [a]
|
|
983
1045
|
}
|
|
984
|
-
},
|
|
985
|
-
|
|
1046
|
+
}, O = new $(), y = B.getInstance();
|
|
1047
|
+
O.push({
|
|
986
1048
|
t: C.RETAIN,
|
|
987
|
-
len: r ===
|
|
988
|
-
segmentId:
|
|
989
|
-
}), p.dataStream.length &&
|
|
1049
|
+
len: r === k.LEFT ? f - 1 : f,
|
|
1050
|
+
segmentId: d
|
|
1051
|
+
}), p.dataStream.length && O.push({
|
|
990
1052
|
t: C.INSERT,
|
|
991
1053
|
body: p,
|
|
992
1054
|
len: p.dataStream.length,
|
|
993
1055
|
line: 0,
|
|
994
|
-
segmentId:
|
|
995
|
-
}),
|
|
1056
|
+
segmentId: d
|
|
1057
|
+
}), O.push({
|
|
996
1058
|
t: C.RETAIN,
|
|
997
1059
|
len: 1,
|
|
998
|
-
segmentId:
|
|
999
|
-
}),
|
|
1060
|
+
segmentId: d
|
|
1061
|
+
}), O.push({
|
|
1000
1062
|
t: C.DELETE,
|
|
1001
|
-
len:
|
|
1063
|
+
len: m + 1 - h,
|
|
1002
1064
|
line: 0,
|
|
1003
|
-
segmentId:
|
|
1065
|
+
segmentId: d
|
|
1004
1066
|
});
|
|
1005
|
-
const
|
|
1006
|
-
return _.params.actions =
|
|
1067
|
+
const T = j(g, d);
|
|
1068
|
+
return _.params.actions = y.editOp(O.serialize(), T), !!o.syncExecuteCommand(_.id, _.params);
|
|
1007
1069
|
}
|
|
1008
|
-
},
|
|
1070
|
+
}, Pn = {
|
|
1009
1071
|
id: "doc.command.delete-left",
|
|
1010
|
-
type:
|
|
1072
|
+
type: E.COMMAND,
|
|
1011
1073
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1012
1074
|
handler: async (s) => {
|
|
1013
|
-
|
|
1075
|
+
var y, T;
|
|
1076
|
+
const e = s.get(w), t = s.get(U), n = s.get(A);
|
|
1014
1077
|
let o = !0;
|
|
1015
1078
|
const r = t.getCurrentUniverDocInstance();
|
|
1016
1079
|
if (!r)
|
|
1017
1080
|
return !1;
|
|
1018
|
-
const a = r.getUnitId(), i =
|
|
1019
|
-
if (c == null ||
|
|
1081
|
+
const a = r.getUnitId(), i = wt(s, a), c = e.getActiveRange(), d = e.getCurrentSelections(), l = i == null ? void 0 : i.getSkeleton();
|
|
1082
|
+
if (c == null || l == null || d == null)
|
|
1020
1083
|
return !1;
|
|
1021
|
-
const { segmentId: g, style: u, segmentPage:
|
|
1084
|
+
const { segmentId: g, style: u, segmentPage: S } = c, f = r.getSelfOrHeaderFooterModel(g).getBody();
|
|
1022
1085
|
if (f == null)
|
|
1023
1086
|
return !1;
|
|
1024
|
-
const
|
|
1025
|
-
let
|
|
1026
|
-
const _ =
|
|
1027
|
-
if (
|
|
1028
|
-
const
|
|
1029
|
-
if (
|
|
1087
|
+
const I = He(c, f), { startOffset: h, collapsed: m } = I, p = l.findNodeByCharIndex(h, g, S), v = dn(p), x = ln(p, f);
|
|
1088
|
+
let M = h;
|
|
1089
|
+
const _ = l.findNodeByCharIndex(h - 1, g, S);
|
|
1090
|
+
if (un(p) && _ !== p && (v === !0 || x === !0) && m) {
|
|
1091
|
+
const R = gn(p, f);
|
|
1092
|
+
if (R == null)
|
|
1030
1093
|
return !1;
|
|
1031
|
-
const
|
|
1032
|
-
if (
|
|
1033
|
-
const
|
|
1034
|
-
if (
|
|
1035
|
-
|
|
1036
|
-
const { hanging:
|
|
1037
|
-
|
|
1094
|
+
const D = R == null ? void 0 : R.startIndex, N = { startIndex: 0 }, L = R.paragraphStyle;
|
|
1095
|
+
if (v === !0) {
|
|
1096
|
+
const V = R.paragraphStyle;
|
|
1097
|
+
if (V) {
|
|
1098
|
+
N.paragraphStyle = V;
|
|
1099
|
+
const { hanging: H } = V;
|
|
1100
|
+
H && (N.paragraphStyle.indentStart = H, N.paragraphStyle.hanging = void 0);
|
|
1038
1101
|
}
|
|
1039
|
-
} else if (
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1102
|
+
} else if (x === !0) {
|
|
1103
|
+
const V = R.bullet;
|
|
1104
|
+
V && (N.bullet = V), L != null && (N.paragraphStyle = { ...L }, delete N.paragraphStyle.hanging, delete N.paragraphStyle.indentStart);
|
|
1042
1105
|
}
|
|
1043
|
-
const
|
|
1106
|
+
const le = [
|
|
1044
1107
|
{
|
|
1045
|
-
startOffset:
|
|
1046
|
-
endOffset:
|
|
1108
|
+
startOffset: M,
|
|
1109
|
+
endOffset: M,
|
|
1047
1110
|
style: u
|
|
1048
1111
|
}
|
|
1049
1112
|
];
|
|
1050
|
-
o = await n.executeCommand(
|
|
1113
|
+
o = await n.executeCommand(Ut.id, {
|
|
1051
1114
|
unitId: r.getUnitId(),
|
|
1052
1115
|
updateBody: {
|
|
1053
1116
|
dataStream: "",
|
|
1054
|
-
paragraphs: [{ ...
|
|
1117
|
+
paragraphs: [{ ...N }]
|
|
1055
1118
|
},
|
|
1056
1119
|
range: {
|
|
1057
|
-
startOffset:
|
|
1058
|
-
endOffset:
|
|
1120
|
+
startOffset: D,
|
|
1121
|
+
endOffset: D + 1
|
|
1059
1122
|
},
|
|
1060
|
-
textRanges:
|
|
1061
|
-
coverType:
|
|
1123
|
+
textRanges: le,
|
|
1124
|
+
coverType: Re.REPLACE,
|
|
1062
1125
|
segmentId: g
|
|
1063
1126
|
});
|
|
1064
|
-
} else if (
|
|
1127
|
+
} else if (m === !0) {
|
|
1065
1128
|
if (_ == null)
|
|
1066
1129
|
return !0;
|
|
1067
|
-
_.content === "\r"
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1130
|
+
if (_.content === "\r")
|
|
1131
|
+
o = await n.executeCommand(We.id, {
|
|
1132
|
+
direction: k.LEFT,
|
|
1133
|
+
range: I
|
|
1134
|
+
});
|
|
1135
|
+
else if (_.streamType === "\b") {
|
|
1136
|
+
const R = (T = r.getSnapshot().drawings) == null ? void 0 : T[(y = _.drawingId) != null ? y : ""];
|
|
1137
|
+
if (R == null)
|
|
1138
|
+
return !0;
|
|
1139
|
+
if (R.layoutType === Et.INLINE) {
|
|
1140
|
+
const N = r.getUnitId();
|
|
1141
|
+
o = await n.executeCommand(Ve.id, {
|
|
1142
|
+
direction: k.LEFT,
|
|
1143
|
+
range: c,
|
|
1144
|
+
unitId: N,
|
|
1145
|
+
drawingId: _.drawingId
|
|
1146
|
+
});
|
|
1147
|
+
} else {
|
|
1148
|
+
const N = l.findNodeByCharIndex(h - 2);
|
|
1149
|
+
if (N == null)
|
|
1150
|
+
return !0;
|
|
1151
|
+
M -= _.count, M -= N.count;
|
|
1152
|
+
const L = [
|
|
1153
|
+
{
|
|
1154
|
+
startOffset: M,
|
|
1155
|
+
endOffset: M,
|
|
1156
|
+
style: u
|
|
1157
|
+
}
|
|
1158
|
+
];
|
|
1159
|
+
o = await n.executeCommand(se.id, {
|
|
1160
|
+
unitId: r.getUnitId(),
|
|
1161
|
+
range: {
|
|
1162
|
+
...c,
|
|
1163
|
+
startOffset: c.startOffset - 1,
|
|
1164
|
+
endOffset: c.endOffset - 1
|
|
1165
|
+
},
|
|
1166
|
+
segmentId: g,
|
|
1167
|
+
direction: k.LEFT,
|
|
1168
|
+
len: N.count,
|
|
1169
|
+
textRanges: L
|
|
1170
|
+
});
|
|
1072
1171
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1172
|
+
} else
|
|
1173
|
+
M -= _.count, o = await n.executeCommand(se.id, {
|
|
1174
|
+
unitId: r.getUnitId(),
|
|
1175
|
+
range: I,
|
|
1176
|
+
segmentId: g,
|
|
1177
|
+
direction: k.LEFT,
|
|
1178
|
+
len: _.count
|
|
1179
|
+
});
|
|
1080
1180
|
} else {
|
|
1081
|
-
const
|
|
1181
|
+
const R = Lt({
|
|
1082
1182
|
...c,
|
|
1083
|
-
...
|
|
1084
|
-
},
|
|
1183
|
+
...I
|
|
1184
|
+
}, d);
|
|
1085
1185
|
o = await n.executeCommand(Bt.id, {
|
|
1086
1186
|
segmentId: g,
|
|
1087
|
-
textRanges:
|
|
1187
|
+
textRanges: R
|
|
1088
1188
|
});
|
|
1089
1189
|
}
|
|
1090
1190
|
return o;
|
|
1091
1191
|
}
|
|
1092
|
-
},
|
|
1192
|
+
}, wn = {
|
|
1093
1193
|
id: "doc.command.delete-right",
|
|
1094
|
-
type:
|
|
1194
|
+
type: E.COMMAND,
|
|
1195
|
+
// eslint-disable-next-line max-lines-per-function
|
|
1095
1196
|
handler: async (s) => {
|
|
1096
|
-
|
|
1197
|
+
var p, v;
|
|
1198
|
+
const e = s.get(w), n = s.get(U).getCurrentUniverDocInstance();
|
|
1097
1199
|
if (!n)
|
|
1098
1200
|
return !1;
|
|
1099
|
-
const o =
|
|
1201
|
+
const o = wt(s, n.getUnitId()), r = s.get(A), a = e.getActiveRange(), i = e.getCurrentSelections(), c = o == null ? void 0 : o.getSkeleton();
|
|
1100
1202
|
if (a == null || c == null || i == null)
|
|
1101
1203
|
return !1;
|
|
1102
|
-
const { segmentId:
|
|
1204
|
+
const { segmentId: d, style: l, segmentPage: g } = a, u = n == null ? void 0 : n.getSelfOrHeaderFooterModel(d).getBody();
|
|
1103
1205
|
if (!n || !u)
|
|
1104
1206
|
return !1;
|
|
1105
|
-
const
|
|
1106
|
-
if (f === u.dataStream.length - 2 &&
|
|
1207
|
+
const S = Me(a, u), { startOffset: f, endOffset: I, collapsed: h } = S;
|
|
1208
|
+
if (f === u.dataStream.length - 2 && h)
|
|
1107
1209
|
return !0;
|
|
1108
1210
|
let m = !1;
|
|
1109
|
-
if (
|
|
1110
|
-
const
|
|
1111
|
-
if (
|
|
1112
|
-
m = await r.executeCommand(
|
|
1113
|
-
direction:
|
|
1211
|
+
if (h === !0) {
|
|
1212
|
+
const x = c.findNodeByCharIndex(f, d, g), M = c.findNodeByCharIndex(f + 1);
|
|
1213
|
+
if (x.content === "\r")
|
|
1214
|
+
m = await r.executeCommand(We.id, {
|
|
1215
|
+
direction: k.RIGHT,
|
|
1114
1216
|
range: a
|
|
1115
1217
|
});
|
|
1116
|
-
else {
|
|
1117
|
-
const p =
|
|
1218
|
+
else if (x.streamType === "\b") {
|
|
1219
|
+
const _ = (v = n.getSnapshot().drawings) == null ? void 0 : v[(p = x.drawingId) != null ? p : ""];
|
|
1220
|
+
if (_ == null)
|
|
1221
|
+
return !0;
|
|
1222
|
+
if (_.layoutType === Et.INLINE) {
|
|
1223
|
+
const y = n.getUnitId();
|
|
1224
|
+
m = await r.executeCommand(Ve.id, {
|
|
1225
|
+
direction: k.RIGHT,
|
|
1226
|
+
range: a,
|
|
1227
|
+
unitId: y,
|
|
1228
|
+
drawingId: x.drawingId
|
|
1229
|
+
});
|
|
1230
|
+
} else {
|
|
1231
|
+
if (M == null)
|
|
1232
|
+
return !0;
|
|
1233
|
+
const y = [
|
|
1234
|
+
{
|
|
1235
|
+
startOffset: f + 1,
|
|
1236
|
+
endOffset: f + 1,
|
|
1237
|
+
style: l
|
|
1238
|
+
}
|
|
1239
|
+
];
|
|
1240
|
+
m = await r.executeCommand(se.id, {
|
|
1241
|
+
unitId: n.getUnitId(),
|
|
1242
|
+
range: {
|
|
1243
|
+
...a,
|
|
1244
|
+
startOffset: f + 1,
|
|
1245
|
+
endOffset: I + 1
|
|
1246
|
+
},
|
|
1247
|
+
segmentId: d,
|
|
1248
|
+
direction: k.RIGHT,
|
|
1249
|
+
textRanges: y,
|
|
1250
|
+
len: M.count
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
} else {
|
|
1254
|
+
const _ = [
|
|
1118
1255
|
{
|
|
1119
1256
|
startOffset: f,
|
|
1120
1257
|
endOffset: f,
|
|
1121
|
-
style:
|
|
1258
|
+
style: l
|
|
1122
1259
|
}
|
|
1123
1260
|
];
|
|
1124
|
-
m = await r.executeCommand(
|
|
1261
|
+
m = await r.executeCommand(se.id, {
|
|
1125
1262
|
unitId: n.getUnitId(),
|
|
1126
|
-
range:
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
segmentId: l,
|
|
1132
|
-
direction: Y.RIGHT,
|
|
1133
|
-
textRanges: p,
|
|
1134
|
-
len: h.count
|
|
1263
|
+
range: S,
|
|
1264
|
+
segmentId: d,
|
|
1265
|
+
direction: k.RIGHT,
|
|
1266
|
+
textRanges: _,
|
|
1267
|
+
len: x.count
|
|
1135
1268
|
});
|
|
1136
1269
|
}
|
|
1137
1270
|
} else {
|
|
1138
|
-
const
|
|
1271
|
+
const x = Lt(a, i);
|
|
1139
1272
|
m = await r.executeCommand(Bt.id, {
|
|
1140
|
-
segmentId:
|
|
1141
|
-
textRanges:
|
|
1273
|
+
segmentId: d,
|
|
1274
|
+
textRanges: x
|
|
1142
1275
|
});
|
|
1143
1276
|
}
|
|
1144
1277
|
return m;
|
|
1145
1278
|
}
|
|
1146
1279
|
};
|
|
1147
|
-
function
|
|
1148
|
-
const { textRuns: n
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
};
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
const { st: i, ed: c } = a;
|
|
1158
|
-
c <= e || i >= t || (i < e ? r.push({
|
|
1159
|
-
...a,
|
|
1280
|
+
function Un(s, e, t) {
|
|
1281
|
+
const { textRuns: n = [], customBlocks: o = [] } = s, a = {
|
|
1282
|
+
dataStream: s.dataStream.substring(e, t),
|
|
1283
|
+
customRanges: Jt(s, e, t).customRanges,
|
|
1284
|
+
customDecorations: qt(s, e, t)
|
|
1285
|
+
}, i = [];
|
|
1286
|
+
for (const d of n) {
|
|
1287
|
+
const { st: l, ed: g } = d;
|
|
1288
|
+
g <= e || l >= t || (l < e ? i.push({
|
|
1289
|
+
...d,
|
|
1160
1290
|
st: 0,
|
|
1161
|
-
ed:
|
|
1162
|
-
}) :
|
|
1163
|
-
...
|
|
1164
|
-
st:
|
|
1291
|
+
ed: g - e
|
|
1292
|
+
}) : g > t ? i.push({
|
|
1293
|
+
...d,
|
|
1294
|
+
st: l - e,
|
|
1165
1295
|
ed: t - e
|
|
1166
|
-
}) :
|
|
1167
|
-
...
|
|
1168
|
-
st:
|
|
1169
|
-
ed:
|
|
1296
|
+
}) : i.push({
|
|
1297
|
+
...d,
|
|
1298
|
+
st: l - e,
|
|
1299
|
+
ed: g - e
|
|
1170
1300
|
}));
|
|
1171
1301
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1302
|
+
i.length > 0 && (a.textRuns = i);
|
|
1303
|
+
const c = [];
|
|
1304
|
+
for (const d of o) {
|
|
1305
|
+
const { startIndex: l } = d;
|
|
1306
|
+
l >= e && l <= t && c.push({
|
|
1307
|
+
...d,
|
|
1308
|
+
startIndex: l - e
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
return c.length > 0 && (a.customBlocks = c), a;
|
|
1178
1312
|
}
|
|
1179
1313
|
function Lt(s, e) {
|
|
1180
1314
|
let t = s.endOffset;
|
|
@@ -1192,54 +1326,54 @@ function Lt(s, e) {
|
|
|
1192
1326
|
}
|
|
1193
1327
|
const Ft = {
|
|
1194
1328
|
id: "doc.command.ime-input",
|
|
1195
|
-
type:
|
|
1329
|
+
type: E.COMMAND,
|
|
1196
1330
|
// eslint-disable-next-line max-lines-per-function
|
|
1197
1331
|
handler: async (s, e) => {
|
|
1198
|
-
const { unitId: t, newText: n, oldTextLen: o, isCompositionEnd: r, isCompositionStart: a } = e, i = s.get(
|
|
1199
|
-
if (
|
|
1332
|
+
const { unitId: t, newText: n, oldTextLen: o, isCompositionEnd: r, isCompositionStart: a } = e, i = s.get(A), c = s.get(Ee), l = s.get(U).getCurrentUniverDocInstance();
|
|
1333
|
+
if (l == null)
|
|
1200
1334
|
return !1;
|
|
1201
1335
|
const g = c.getActiveRange();
|
|
1202
1336
|
if (!g)
|
|
1203
1337
|
return !1;
|
|
1204
|
-
const { startOffset: u, style:
|
|
1205
|
-
if (
|
|
1338
|
+
const { startOffset: u, style: S, segmentId: f } = g, I = l.getSelfOrHeaderFooterModel(f).getBody();
|
|
1339
|
+
if (I == null)
|
|
1206
1340
|
return !1;
|
|
1207
|
-
const
|
|
1208
|
-
Object.assign(g,
|
|
1209
|
-
const
|
|
1341
|
+
const h = Me(g, I);
|
|
1342
|
+
Object.assign(g, h);
|
|
1343
|
+
const m = n.length, p = [
|
|
1210
1344
|
{
|
|
1211
|
-
startOffset: u +
|
|
1212
|
-
endOffset: u +
|
|
1345
|
+
startOffset: u + m,
|
|
1346
|
+
endOffset: u + m,
|
|
1213
1347
|
collapsed: !0,
|
|
1214
|
-
style:
|
|
1348
|
+
style: S
|
|
1215
1349
|
}
|
|
1216
|
-
],
|
|
1217
|
-
id:
|
|
1350
|
+
], v = {
|
|
1351
|
+
id: G.id,
|
|
1218
1352
|
params: {
|
|
1219
1353
|
unitId: t,
|
|
1220
1354
|
actions: [],
|
|
1221
1355
|
textRanges: p
|
|
1222
1356
|
}
|
|
1223
|
-
},
|
|
1357
|
+
}, x = new $(), M = B.getInstance();
|
|
1224
1358
|
if (!g.collapsed && a) {
|
|
1225
|
-
const { dos:
|
|
1226
|
-
|
|
1227
|
-
startOffset: u +
|
|
1228
|
-
endOffset: u +
|
|
1359
|
+
const { dos: y, retain: T, cursor: R } = Xe(g, f, 0, I);
|
|
1360
|
+
x.push(...y), v.params.textRanges = [{
|
|
1361
|
+
startOffset: u + m + T,
|
|
1362
|
+
endOffset: u + m + T,
|
|
1229
1363
|
collapsed: !0
|
|
1230
1364
|
}];
|
|
1231
1365
|
} else
|
|
1232
|
-
|
|
1366
|
+
x.push({
|
|
1233
1367
|
t: C.RETAIN,
|
|
1234
1368
|
len: u,
|
|
1235
1369
|
segmentId: f
|
|
1236
1370
|
});
|
|
1237
|
-
o > 0 &&
|
|
1371
|
+
o > 0 && x.push({
|
|
1238
1372
|
t: C.DELETE,
|
|
1239
1373
|
len: o,
|
|
1240
1374
|
line: 0,
|
|
1241
1375
|
segmentId: f
|
|
1242
|
-
}),
|
|
1376
|
+
}), x.push({
|
|
1243
1377
|
t: C.INSERT,
|
|
1244
1378
|
body: {
|
|
1245
1379
|
dataStream: n
|
|
@@ -1248,205 +1382,205 @@ const Ft = {
|
|
|
1248
1382
|
line: 0,
|
|
1249
1383
|
segmentId: f
|
|
1250
1384
|
});
|
|
1251
|
-
const _ =
|
|
1252
|
-
|
|
1253
|
-
const
|
|
1254
|
-
return c.pushUndoRedoMutationParams(
|
|
1385
|
+
const _ = j(l, f);
|
|
1386
|
+
v.params.actions = M.editOp(x.serialize(), _), v.params.noHistory = !r, v.params.isCompositionEnd = r;
|
|
1387
|
+
const O = i.syncExecuteCommand(v.id, v.params);
|
|
1388
|
+
return c.pushUndoRedoMutationParams(O, v.params), !!O;
|
|
1255
1389
|
}
|
|
1256
1390
|
};
|
|
1257
|
-
function
|
|
1391
|
+
function z(s, e, t, n) {
|
|
1258
1392
|
var r;
|
|
1259
1393
|
const { segmentId: o } = (r = t.getActiveRange()) != null ? r : {};
|
|
1260
|
-
return o == null ? !1 : n.executeCommand(
|
|
1394
|
+
return o == null ? !1 : n.executeCommand($t.id, {
|
|
1261
1395
|
segmentId: o,
|
|
1262
1396
|
preCommandId: s,
|
|
1263
1397
|
...e != null ? e : {}
|
|
1264
1398
|
});
|
|
1265
1399
|
}
|
|
1266
|
-
const
|
|
1400
|
+
const mt = "doc.command.set-inline-format-bold", Ye = {
|
|
1401
|
+
id: mt,
|
|
1402
|
+
type: E.COMMAND,
|
|
1403
|
+
handler: async (s, e) => {
|
|
1404
|
+
const t = s.get(A), n = s.get(w);
|
|
1405
|
+
return z(
|
|
1406
|
+
mt,
|
|
1407
|
+
e,
|
|
1408
|
+
n,
|
|
1409
|
+
t
|
|
1410
|
+
);
|
|
1411
|
+
}
|
|
1412
|
+
}, ht = "doc.command.set-inline-format-italic", Ke = {
|
|
1267
1413
|
id: ht,
|
|
1268
|
-
type:
|
|
1414
|
+
type: E.COMMAND,
|
|
1269
1415
|
handler: async (s, e) => {
|
|
1270
|
-
const t = s.get(
|
|
1271
|
-
return
|
|
1416
|
+
const t = s.get(A), n = s.get(w);
|
|
1417
|
+
return z(
|
|
1272
1418
|
ht,
|
|
1273
1419
|
e,
|
|
1274
1420
|
n,
|
|
1275
1421
|
t
|
|
1276
1422
|
);
|
|
1277
1423
|
}
|
|
1278
|
-
}, pt = "doc.command.set-inline-format-
|
|
1424
|
+
}, pt = "doc.command.set-inline-format-underline", Ze = {
|
|
1279
1425
|
id: pt,
|
|
1280
|
-
type:
|
|
1426
|
+
type: E.COMMAND,
|
|
1281
1427
|
handler: async (s, e) => {
|
|
1282
|
-
const t = s.get(
|
|
1283
|
-
return
|
|
1428
|
+
const t = s.get(A), n = s.get(w);
|
|
1429
|
+
return z(
|
|
1284
1430
|
pt,
|
|
1285
1431
|
e,
|
|
1286
1432
|
n,
|
|
1287
1433
|
t
|
|
1288
1434
|
);
|
|
1289
1435
|
}
|
|
1290
|
-
}, St = "doc.command.set-inline-format-
|
|
1436
|
+
}, St = "doc.command.set-inline-format-strikethrough", Je = {
|
|
1291
1437
|
id: St,
|
|
1292
|
-
type:
|
|
1438
|
+
type: E.COMMAND,
|
|
1293
1439
|
handler: async (s, e) => {
|
|
1294
|
-
const t = s.get(
|
|
1295
|
-
return
|
|
1440
|
+
const t = s.get(A), n = s.get(w);
|
|
1441
|
+
return z(
|
|
1296
1442
|
St,
|
|
1297
1443
|
e,
|
|
1298
1444
|
n,
|
|
1299
1445
|
t
|
|
1300
1446
|
);
|
|
1301
1447
|
}
|
|
1302
|
-
}, It = "doc.command.set-inline-format-
|
|
1448
|
+
}, It = "doc.command.set-inline-format-subscript", oe = {
|
|
1303
1449
|
id: It,
|
|
1304
|
-
type:
|
|
1450
|
+
type: E.COMMAND,
|
|
1305
1451
|
handler: async (s, e) => {
|
|
1306
|
-
const t = s.get(
|
|
1307
|
-
return
|
|
1452
|
+
const t = s.get(A), n = s.get(w);
|
|
1453
|
+
return z(
|
|
1308
1454
|
It,
|
|
1309
1455
|
e,
|
|
1310
1456
|
n,
|
|
1311
1457
|
t
|
|
1312
1458
|
);
|
|
1313
1459
|
}
|
|
1314
|
-
}, _t = "doc.command.set-inline-format-
|
|
1460
|
+
}, _t = "doc.command.set-inline-format-superscript", qe = {
|
|
1315
1461
|
id: _t,
|
|
1316
|
-
type:
|
|
1462
|
+
type: E.COMMAND,
|
|
1317
1463
|
handler: async (s, e) => {
|
|
1318
|
-
const t = s.get(
|
|
1319
|
-
return
|
|
1464
|
+
const t = s.get(A), n = s.get(w);
|
|
1465
|
+
return z(
|
|
1320
1466
|
_t,
|
|
1321
1467
|
e,
|
|
1322
1468
|
n,
|
|
1323
1469
|
t
|
|
1324
1470
|
);
|
|
1325
1471
|
}
|
|
1326
|
-
},
|
|
1327
|
-
id: Rt,
|
|
1328
|
-
type: T.COMMAND,
|
|
1329
|
-
handler: async (s, e) => {
|
|
1330
|
-
const t = s.get(E), n = s.get(D);
|
|
1331
|
-
return j(
|
|
1332
|
-
Rt,
|
|
1333
|
-
e,
|
|
1334
|
-
n,
|
|
1335
|
-
t
|
|
1336
|
-
);
|
|
1337
|
-
}
|
|
1338
|
-
}, vt = "doc.command.set-inline-format-fontsize", Je = {
|
|
1472
|
+
}, vt = "doc.command.set-inline-format-fontsize", Qe = {
|
|
1339
1473
|
id: vt,
|
|
1340
|
-
type:
|
|
1474
|
+
type: E.COMMAND,
|
|
1341
1475
|
handler: async (s, e) => {
|
|
1342
|
-
const t = s.get(
|
|
1343
|
-
return
|
|
1476
|
+
const t = s.get(A), n = s.get(w);
|
|
1477
|
+
return z(
|
|
1344
1478
|
vt,
|
|
1345
1479
|
e,
|
|
1346
1480
|
n,
|
|
1347
1481
|
t
|
|
1348
1482
|
);
|
|
1349
1483
|
}
|
|
1350
|
-
},
|
|
1351
|
-
id:
|
|
1352
|
-
type:
|
|
1484
|
+
}, Rt = "doc.command.set-inline-format-font-family", et = {
|
|
1485
|
+
id: Rt,
|
|
1486
|
+
type: E.COMMAND,
|
|
1353
1487
|
handler: async (s, e) => {
|
|
1354
|
-
const t = s.get(
|
|
1355
|
-
return
|
|
1356
|
-
|
|
1488
|
+
const t = s.get(A), n = s.get(w);
|
|
1489
|
+
return z(
|
|
1490
|
+
Rt,
|
|
1357
1491
|
e,
|
|
1358
1492
|
n,
|
|
1359
1493
|
t
|
|
1360
1494
|
);
|
|
1361
1495
|
}
|
|
1362
|
-
},
|
|
1363
|
-
id:
|
|
1364
|
-
type:
|
|
1496
|
+
}, xt = "doc.command.set-inline-format-text-color", tt = {
|
|
1497
|
+
id: xt,
|
|
1498
|
+
type: E.COMMAND,
|
|
1365
1499
|
handler: async (s, e) => {
|
|
1366
|
-
const t = s.get(
|
|
1367
|
-
return
|
|
1368
|
-
|
|
1500
|
+
const t = s.get(A), n = s.get(w);
|
|
1501
|
+
return z(
|
|
1502
|
+
xt,
|
|
1369
1503
|
e,
|
|
1370
1504
|
n,
|
|
1371
1505
|
t
|
|
1372
1506
|
);
|
|
1373
1507
|
}
|
|
1374
|
-
}, Ot = "doc.command.set-inline-format-text-background-color",
|
|
1508
|
+
}, Ot = "doc.command.set-inline-format-text-background-color", nt = {
|
|
1375
1509
|
id: Ot,
|
|
1376
|
-
type:
|
|
1510
|
+
type: E.COMMAND,
|
|
1377
1511
|
handler: async (s, e) => {
|
|
1378
|
-
const t = s.get(
|
|
1379
|
-
return
|
|
1512
|
+
const t = s.get(A), n = s.get(w);
|
|
1513
|
+
return z(
|
|
1380
1514
|
Ot,
|
|
1381
1515
|
e,
|
|
1382
1516
|
n,
|
|
1383
1517
|
t
|
|
1384
1518
|
);
|
|
1385
1519
|
}
|
|
1386
|
-
},
|
|
1387
|
-
id:
|
|
1388
|
-
type:
|
|
1520
|
+
}, Ct = "doc.command.reset-inline-format-text-background-color", st = {
|
|
1521
|
+
id: Ct,
|
|
1522
|
+
type: E.COMMAND,
|
|
1389
1523
|
handler: async (s, e) => {
|
|
1390
|
-
const t = s.get(
|
|
1391
|
-
return
|
|
1392
|
-
|
|
1524
|
+
const t = s.get(A), n = s.get(w);
|
|
1525
|
+
return z(
|
|
1526
|
+
Ct,
|
|
1393
1527
|
e,
|
|
1394
1528
|
n,
|
|
1395
1529
|
t
|
|
1396
1530
|
);
|
|
1397
1531
|
}
|
|
1398
|
-
}, $t = {
|
|
1399
|
-
[ke.id]: "bl",
|
|
1400
|
-
[We.id]: "it",
|
|
1401
|
-
[Ye.id]: "ul",
|
|
1402
|
-
[Ke.id]: "st",
|
|
1403
|
-
[Je.id]: "fs",
|
|
1404
|
-
[qe.id]: "ff",
|
|
1405
|
-
[Qe.id]: "cl",
|
|
1406
|
-
[et.id]: "bg",
|
|
1407
|
-
[tt.id]: "bg",
|
|
1408
|
-
[se.id]: "va",
|
|
1409
|
-
[Ze.id]: "va"
|
|
1410
1532
|
}, Gt = {
|
|
1533
|
+
[Ye.id]: "bl",
|
|
1534
|
+
[Ke.id]: "it",
|
|
1535
|
+
[Ze.id]: "ul",
|
|
1536
|
+
[Je.id]: "st",
|
|
1537
|
+
[Qe.id]: "fs",
|
|
1538
|
+
[et.id]: "ff",
|
|
1539
|
+
[tt.id]: "cl",
|
|
1540
|
+
[nt.id]: "bg",
|
|
1541
|
+
[st.id]: "bg",
|
|
1542
|
+
[oe.id]: "va",
|
|
1543
|
+
[qe.id]: "va"
|
|
1544
|
+
}, $t = {
|
|
1411
1545
|
id: "doc.command.set-inline-format",
|
|
1412
|
-
type:
|
|
1546
|
+
type: E.COMMAND,
|
|
1413
1547
|
// eslint-disable-next-line max-lines-per-function
|
|
1414
1548
|
handler: async (s, e) => {
|
|
1415
|
-
const { segmentId: t, value: n, preCommandId: o } = e, r = s.get(
|
|
1549
|
+
const { segmentId: t, value: n, preCommandId: o } = e, r = s.get(A), a = s.get(w), i = s.get(U), c = a.getCurrentSelections();
|
|
1416
1550
|
if (!Array.isArray(c) || c.length === 0)
|
|
1417
1551
|
return !1;
|
|
1418
|
-
const
|
|
1419
|
-
if (
|
|
1552
|
+
const d = i.getCurrentUniverDocInstance();
|
|
1553
|
+
if (d == null)
|
|
1420
1554
|
return !1;
|
|
1421
|
-
const
|
|
1555
|
+
const l = d.getUnitId();
|
|
1422
1556
|
let g;
|
|
1423
1557
|
switch (o) {
|
|
1424
|
-
case ke.id:
|
|
1425
|
-
case We.id:
|
|
1426
1558
|
case Ye.id:
|
|
1427
1559
|
case Ke.id:
|
|
1428
|
-
case
|
|
1429
|
-
case
|
|
1430
|
-
|
|
1431
|
-
|
|
1560
|
+
case Ze.id:
|
|
1561
|
+
case Je.id:
|
|
1562
|
+
case oe.id:
|
|
1563
|
+
case qe.id: {
|
|
1564
|
+
g = Ln(
|
|
1565
|
+
d.getSelfOrHeaderFooterModel(t).getBody().textRuns,
|
|
1432
1566
|
o,
|
|
1433
1567
|
c
|
|
1434
1568
|
);
|
|
1435
1569
|
break;
|
|
1436
1570
|
}
|
|
1437
|
-
case
|
|
1438
|
-
case
|
|
1571
|
+
case Qe.id:
|
|
1572
|
+
case et.id: {
|
|
1439
1573
|
g = n;
|
|
1440
1574
|
break;
|
|
1441
1575
|
}
|
|
1442
|
-
case
|
|
1443
|
-
case
|
|
1576
|
+
case tt.id:
|
|
1577
|
+
case nt.id: {
|
|
1444
1578
|
g = {
|
|
1445
1579
|
rgb: n
|
|
1446
1580
|
};
|
|
1447
1581
|
break;
|
|
1448
1582
|
}
|
|
1449
|
-
case
|
|
1583
|
+
case st.id: {
|
|
1450
1584
|
g = {
|
|
1451
1585
|
rgb: null
|
|
1452
1586
|
};
|
|
@@ -1456,113 +1590,113 @@ const ht = "doc.command.set-inline-format-bold", ke = {
|
|
|
1456
1590
|
throw new Error(`Unknown command: ${o} in handleInlineFormat`);
|
|
1457
1591
|
}
|
|
1458
1592
|
const u = {
|
|
1459
|
-
id:
|
|
1593
|
+
id: G.id,
|
|
1460
1594
|
params: {
|
|
1461
|
-
unitId:
|
|
1595
|
+
unitId: l,
|
|
1462
1596
|
actions: [],
|
|
1463
|
-
textRanges: c.map(
|
|
1597
|
+
textRanges: c.map(Q)
|
|
1464
1598
|
}
|
|
1465
|
-
},
|
|
1466
|
-
|
|
1599
|
+
}, S = new $(), f = B.getInstance(), I = new re();
|
|
1600
|
+
I.reset();
|
|
1467
1601
|
for (const p of c) {
|
|
1468
|
-
const { startOffset:
|
|
1602
|
+
const { startOffset: v, endOffset: x } = p, M = {
|
|
1469
1603
|
dataStream: "",
|
|
1470
1604
|
textRuns: [
|
|
1471
1605
|
{
|
|
1472
1606
|
st: 0,
|
|
1473
|
-
ed:
|
|
1607
|
+
ed: x - v,
|
|
1474
1608
|
ts: {
|
|
1475
|
-
[
|
|
1609
|
+
[Gt[o]]: g
|
|
1476
1610
|
}
|
|
1477
1611
|
}
|
|
1478
1612
|
]
|
|
1479
|
-
}, _ =
|
|
1480
|
-
_ !== 0 &&
|
|
1613
|
+
}, _ = v - I.cursor;
|
|
1614
|
+
_ !== 0 && S.push({
|
|
1481
1615
|
t: C.RETAIN,
|
|
1482
1616
|
len: _,
|
|
1483
1617
|
segmentId: t
|
|
1484
|
-
}),
|
|
1618
|
+
}), S.push({
|
|
1485
1619
|
t: C.RETAIN,
|
|
1486
|
-
body:
|
|
1487
|
-
len:
|
|
1620
|
+
body: M,
|
|
1621
|
+
len: x - v,
|
|
1488
1622
|
segmentId: t
|
|
1489
|
-
}),
|
|
1623
|
+
}), I.reset(), I.moveCursor(x);
|
|
1490
1624
|
}
|
|
1491
|
-
const
|
|
1492
|
-
return u.params.actions = f.editOp(
|
|
1625
|
+
const h = j(d, t);
|
|
1626
|
+
return u.params.actions = f.editOp(S.serialize(), h), !!r.syncExecuteCommand(u.id, u.params);
|
|
1493
1627
|
}
|
|
1494
1628
|
};
|
|
1495
|
-
function
|
|
1629
|
+
function Bn(s) {
|
|
1496
1630
|
return s !== null && typeof s == "object";
|
|
1497
1631
|
}
|
|
1498
|
-
function
|
|
1632
|
+
function Ln(s, e, t) {
|
|
1499
1633
|
let n = 0, o = 0;
|
|
1500
|
-
const r =
|
|
1634
|
+
const r = Gt[e];
|
|
1501
1635
|
for (; n !== s.length && o !== t.length; ) {
|
|
1502
|
-
const { startOffset: a, endOffset: i } = t[o], { st: c, ed:
|
|
1636
|
+
const { startOffset: a, endOffset: i } = t[o], { st: c, ed: d, ts: l } = s[n];
|
|
1503
1637
|
if (i <= c)
|
|
1504
1638
|
o++;
|
|
1505
|
-
else if (
|
|
1639
|
+
else if (d <= a)
|
|
1506
1640
|
n++;
|
|
1507
1641
|
else {
|
|
1508
1642
|
if (/bl|it/.test(r))
|
|
1509
|
-
return (
|
|
1643
|
+
return (l == null ? void 0 : l[r]) === K.TRUE ? K.FALSE : K.TRUE;
|
|
1510
1644
|
if (/ul|st/.test(r))
|
|
1511
|
-
return
|
|
1512
|
-
s:
|
|
1645
|
+
return Bn(l == null ? void 0 : l[r]) && (l == null ? void 0 : l[r]).s === K.TRUE ? {
|
|
1646
|
+
s: K.FALSE
|
|
1513
1647
|
} : {
|
|
1514
|
-
s:
|
|
1648
|
+
s: K.TRUE
|
|
1515
1649
|
};
|
|
1516
1650
|
if (/va/.test(r))
|
|
1517
|
-
return e ===
|
|
1651
|
+
return e === oe.id ? (l == null ? void 0 : l[r]) === Z.SUBSCRIPT ? Z.NORMAL : Z.SUBSCRIPT : (l == null ? void 0 : l[r]) === Z.SUPERSCRIPT ? Z.NORMAL : Z.SUPERSCRIPT;
|
|
1518
1652
|
n++;
|
|
1519
1653
|
}
|
|
1520
1654
|
}
|
|
1521
|
-
return /bl|it/.test(r) ?
|
|
1522
|
-
s:
|
|
1523
|
-
} : e ===
|
|
1655
|
+
return /bl|it/.test(r) ? K.TRUE : /ul|st/.test(r) ? {
|
|
1656
|
+
s: K.TRUE
|
|
1657
|
+
} : e === oe.id ? Z.SUBSCRIPT : Z.SUPERSCRIPT;
|
|
1524
1658
|
}
|
|
1525
|
-
const
|
|
1659
|
+
const ot = {
|
|
1526
1660
|
id: "doc.command.list-operation",
|
|
1527
|
-
type:
|
|
1661
|
+
type: E.COMMAND,
|
|
1528
1662
|
// eslint-disable-next-line max-lines-per-function
|
|
1529
1663
|
handler: (s, e) => {
|
|
1530
|
-
var
|
|
1531
|
-
const t = s.get(
|
|
1664
|
+
var N, L, le, V;
|
|
1665
|
+
const t = s.get(w), n = s.get(U), o = s.get(A), { listType: r } = e, a = n.getCurrentUniverDocInstance(), i = t.getActiveRange();
|
|
1532
1666
|
if (a == null || i == null)
|
|
1533
1667
|
return !1;
|
|
1534
|
-
const { segmentId: c } = i,
|
|
1535
|
-
if (
|
|
1668
|
+
const { segmentId: c } = i, d = (N = t.getCurrentSelections()) != null ? N : [], l = (L = a.getSelfOrHeaderFooterModel(c).getBody()) == null ? void 0 : L.paragraphs, g = d.map(Q);
|
|
1669
|
+
if (l == null)
|
|
1536
1670
|
return !1;
|
|
1537
|
-
const u =
|
|
1538
|
-
var
|
|
1539
|
-
return ((
|
|
1671
|
+
const u = kt(i, l), S = a.getUnitId(), f = u.every((H) => {
|
|
1672
|
+
var X;
|
|
1673
|
+
return ((X = H.bullet) == null ? void 0 : X.listType) === r;
|
|
1540
1674
|
});
|
|
1541
|
-
let
|
|
1675
|
+
let h = q.generateRandomId(6);
|
|
1542
1676
|
if (u.length === 1) {
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1677
|
+
const H = l.indexOf(u[0]), X = l[H - 1], Y = l[H + 1];
|
|
1678
|
+
X && X.bullet && X.bullet.listType === r ? h = X.bullet.listId : Y && Y.bullet && Y.bullet.listType === r && (h = Y.bullet.listId);
|
|
1545
1679
|
}
|
|
1546
|
-
const
|
|
1547
|
-
id:
|
|
1680
|
+
const m = {
|
|
1681
|
+
id: G.id,
|
|
1548
1682
|
params: {
|
|
1549
|
-
unitId:
|
|
1683
|
+
unitId: S,
|
|
1550
1684
|
actions: [],
|
|
1551
1685
|
textRanges: g
|
|
1552
1686
|
}
|
|
1553
|
-
}, p = new
|
|
1687
|
+
}, p = new re();
|
|
1554
1688
|
p.reset();
|
|
1555
|
-
const
|
|
1556
|
-
...
|
|
1557
|
-
...
|
|
1558
|
-
}, { charSpace:
|
|
1559
|
-
for (const
|
|
1560
|
-
const { startIndex:
|
|
1561
|
-
|
|
1689
|
+
const v = new $(), x = B.getInstance(), M = (le = a.getSnapshot().lists) != null ? le : {}, _ = {
|
|
1690
|
+
...Qt,
|
|
1691
|
+
...M
|
|
1692
|
+
}, { charSpace: O, defaultTabStop: y = 36, gridType: T } = a.getSnapshot().documentStyle;
|
|
1693
|
+
for (const H of u) {
|
|
1694
|
+
const { startIndex: X, paragraphStyle: Y = {} } = H, { indentFirstLine: zt = 0, snapToGrid: Ht, indentStart: Ae = 0 } = Y, { hanging: Ne, indentStart: rt } = _[r].nestingLevel[0], De = fn(O, y, T, Ht);
|
|
1695
|
+
v.push({
|
|
1562
1696
|
t: C.RETAIN,
|
|
1563
|
-
len:
|
|
1697
|
+
len: X - p.cursor,
|
|
1564
1698
|
segmentId: c
|
|
1565
|
-
}),
|
|
1699
|
+
}), v.push({
|
|
1566
1700
|
t: C.RETAIN,
|
|
1567
1701
|
len: 1,
|
|
1568
1702
|
body: {
|
|
@@ -1570,53 +1704,53 @@ const nt = {
|
|
|
1570
1704
|
paragraphs: [
|
|
1571
1705
|
f ? {
|
|
1572
1706
|
paragraphStyle: {
|
|
1573
|
-
...
|
|
1707
|
+
...Y,
|
|
1574
1708
|
hanging: void 0,
|
|
1575
|
-
indentStart:
|
|
1709
|
+
indentStart: Ae ? Math.max(0, be(Ae, De) + Ne - rt) : void 0
|
|
1576
1710
|
},
|
|
1577
1711
|
startIndex: 0
|
|
1578
1712
|
} : {
|
|
1579
1713
|
startIndex: 0,
|
|
1580
1714
|
paragraphStyle: {
|
|
1581
|
-
...
|
|
1715
|
+
...Y,
|
|
1582
1716
|
indentFirstLine: void 0,
|
|
1583
|
-
hanging:
|
|
1584
|
-
indentStart:
|
|
1717
|
+
hanging: Ne,
|
|
1718
|
+
indentStart: rt - Ne + be(zt, De) + be(Ae, De)
|
|
1585
1719
|
},
|
|
1586
1720
|
bullet: {
|
|
1587
|
-
...(
|
|
1721
|
+
...(V = H.bullet) != null ? V : {
|
|
1588
1722
|
nestingLevel: 0,
|
|
1589
1723
|
textStyle: {
|
|
1590
1724
|
fs: 20
|
|
1591
1725
|
}
|
|
1592
1726
|
},
|
|
1593
1727
|
listType: r,
|
|
1594
|
-
listId:
|
|
1728
|
+
listId: h
|
|
1595
1729
|
}
|
|
1596
1730
|
}
|
|
1597
1731
|
]
|
|
1598
1732
|
},
|
|
1599
1733
|
segmentId: c,
|
|
1600
|
-
coverType:
|
|
1601
|
-
}), p.moveCursorTo(
|
|
1734
|
+
coverType: Re.REPLACE
|
|
1735
|
+
}), p.moveCursorTo(X + 1);
|
|
1602
1736
|
}
|
|
1603
|
-
const
|
|
1604
|
-
return
|
|
1737
|
+
const R = j(a, c);
|
|
1738
|
+
return m.params.actions = x.editOp(v.serialize(), R), !!o.syncExecuteCommand(m.id, m.params);
|
|
1605
1739
|
}
|
|
1606
|
-
},
|
|
1740
|
+
}, Fn = {
|
|
1607
1741
|
id: "doc.command.bullet-list",
|
|
1608
|
-
type:
|
|
1609
|
-
handler: (s) => s.get(
|
|
1742
|
+
type: E.COMMAND,
|
|
1743
|
+
handler: (s) => s.get(A).syncExecuteCommand(ot.id, {
|
|
1610
1744
|
listType: At.BULLET_LIST
|
|
1611
1745
|
})
|
|
1612
|
-
},
|
|
1746
|
+
}, Gn = {
|
|
1613
1747
|
id: "doc.command.order-list",
|
|
1614
|
-
type:
|
|
1615
|
-
handler: (s) => s.get(
|
|
1748
|
+
type: E.COMMAND,
|
|
1749
|
+
handler: (s) => s.get(A).syncExecuteCommand(ot.id, {
|
|
1616
1750
|
listType: At.ORDER_LIST
|
|
1617
1751
|
})
|
|
1618
1752
|
};
|
|
1619
|
-
function
|
|
1753
|
+
function kt(s, e) {
|
|
1620
1754
|
const { startOffset: t, endOffset: n } = s, o = [];
|
|
1621
1755
|
let r = -1;
|
|
1622
1756
|
for (const a of e) {
|
|
@@ -1625,39 +1759,39 @@ function zt(s, e) {
|
|
|
1625
1759
|
}
|
|
1626
1760
|
return o;
|
|
1627
1761
|
}
|
|
1628
|
-
const
|
|
1762
|
+
const $n = {
|
|
1629
1763
|
id: "doc.command-replace-content",
|
|
1630
|
-
type:
|
|
1764
|
+
type: E.COMMAND,
|
|
1631
1765
|
handler: async (s, e) => {
|
|
1632
|
-
const { unitId: t, body: n, textRanges: o, segmentId: r = "" } = e,
|
|
1633
|
-
if (l == null ||
|
|
1766
|
+
const { unitId: t, body: n, textRanges: o, segmentId: r = "", options: a } = e, i = s.get(U), c = s.get(A), d = s.get(w), l = i.getUniverDocInstance(t), g = l == null ? void 0 : l.getSnapshot().body, u = d.getCurrentSelections();
|
|
1767
|
+
if (l == null || g == null || !Array.isArray(u) || u.length === 0)
|
|
1634
1768
|
return !1;
|
|
1635
|
-
const
|
|
1636
|
-
return
|
|
1769
|
+
const S = jt(t, r, l, g, n);
|
|
1770
|
+
return S.params.textRanges = o, a && (S.params.options = a), !!c.syncExecuteCommand(S.id, S.params);
|
|
1637
1771
|
}
|
|
1638
|
-
},
|
|
1772
|
+
}, kn = {
|
|
1639
1773
|
id: "doc.command-cover-content",
|
|
1640
|
-
type:
|
|
1774
|
+
type: E.COMMAND,
|
|
1641
1775
|
handler: async (s, e) => {
|
|
1642
|
-
const { unitId: t, body: n, segmentId: o = "" } = e, r = s.get(
|
|
1643
|
-
if (c == null ||
|
|
1776
|
+
const { unitId: t, body: n, segmentId: o = "" } = e, r = s.get(U), a = s.get(A), i = s.get($e), c = r.getUniverDocInstance(t), d = c == null ? void 0 : c.getSnapshot().body;
|
|
1777
|
+
if (c == null || d == null)
|
|
1644
1778
|
return !1;
|
|
1645
|
-
const
|
|
1646
|
-
return
|
|
1647
|
-
|
|
1648
|
-
|
|
1779
|
+
const l = jt(t, o, c, d, n);
|
|
1780
|
+
return l.params.noNeedSetTextRange = !0, l.params.noHistory = !0, a.syncExecuteCommand(
|
|
1781
|
+
l.id,
|
|
1782
|
+
l.params
|
|
1649
1783
|
), i.clearUndoRedo(t), !0;
|
|
1650
1784
|
}
|
|
1651
1785
|
};
|
|
1652
1786
|
function jt(s, e, t, n, o) {
|
|
1653
1787
|
const r = {
|
|
1654
|
-
id:
|
|
1788
|
+
id: G.id,
|
|
1655
1789
|
params: {
|
|
1656
1790
|
unitId: s,
|
|
1657
1791
|
actions: [],
|
|
1658
1792
|
textRanges: []
|
|
1659
1793
|
}
|
|
1660
|
-
}, a = new
|
|
1794
|
+
}, a = new $(), i = B.getInstance(), c = (n == null ? void 0 : n.dataStream.length) - 2;
|
|
1661
1795
|
c > 0 && a.push({
|
|
1662
1796
|
t: C.DELETE,
|
|
1663
1797
|
len: c,
|
|
@@ -1670,20 +1804,20 @@ function jt(s, e, t, n, o) {
|
|
|
1670
1804
|
line: 0,
|
|
1671
1805
|
segmentId: e
|
|
1672
1806
|
});
|
|
1673
|
-
const
|
|
1674
|
-
return r.params.actions = i.editOp(a.serialize(),
|
|
1807
|
+
const d = j(t, e);
|
|
1808
|
+
return r.params.actions = i.editOp(a.serialize(), d), r;
|
|
1675
1809
|
}
|
|
1676
|
-
const
|
|
1677
|
-
const t = s.get(
|
|
1810
|
+
const jn = (s, e) => {
|
|
1811
|
+
const t = s.get(U).getUniverDocInstance(e.unitId), n = (t == null ? void 0 : t.zoomRatio) || 1;
|
|
1678
1812
|
return {
|
|
1679
|
-
...
|
|
1813
|
+
...q.deepClone(e),
|
|
1680
1814
|
zoomRatio: n
|
|
1681
1815
|
};
|
|
1682
|
-
},
|
|
1816
|
+
}, me = {
|
|
1683
1817
|
id: "doc.operation.set-zoom-ratio",
|
|
1684
|
-
type:
|
|
1818
|
+
type: E.OPERATION,
|
|
1685
1819
|
handler: (s, e) => {
|
|
1686
|
-
const t = s.get(
|
|
1820
|
+
const t = s.get(U).getUniverDocInstance(e.unitId);
|
|
1687
1821
|
if (!t)
|
|
1688
1822
|
return !1;
|
|
1689
1823
|
const n = t.getSnapshot();
|
|
@@ -1691,39 +1825,39 @@ const $n = (s, e) => {
|
|
|
1691
1825
|
zoomRatio: e.zoomRatio
|
|
1692
1826
|
} : n.settings.zoomRatio = e.zoomRatio, !0;
|
|
1693
1827
|
}
|
|
1694
|
-
},
|
|
1695
|
-
type:
|
|
1828
|
+
}, zn = {
|
|
1829
|
+
type: E.COMMAND,
|
|
1696
1830
|
id: "doc.command.set-zoom-ratio",
|
|
1697
1831
|
handler: async (s, e) => {
|
|
1698
|
-
var g, u,
|
|
1699
|
-
const t = s.get(
|
|
1832
|
+
var g, u, S;
|
|
1833
|
+
const t = s.get(A), n = s.get($e), o = s.get(U);
|
|
1700
1834
|
let r = (g = o.getCurrentUniverDocInstance()) == null ? void 0 : g.getUnitId();
|
|
1701
1835
|
if (!r) return !1;
|
|
1702
1836
|
let a = 1;
|
|
1703
|
-
if (e && (r = (u = e.documentId) != null ? u : r, a = (
|
|
1837
|
+
if (e && (r = (u = e.documentId) != null ? u : r, a = (S = e.zoomRatio) != null ? S : a), !o.getUniverDocInstance(r)) return !1;
|
|
1704
1838
|
const c = {
|
|
1705
1839
|
zoomRatio: a,
|
|
1706
1840
|
unitId: r
|
|
1707
|
-
},
|
|
1708
|
-
return t.syncExecuteCommand(
|
|
1841
|
+
}, d = jn(s, c);
|
|
1842
|
+
return t.syncExecuteCommand(me.id, c) ? (n.pushUndoRedo({
|
|
1709
1843
|
unitID: r,
|
|
1710
|
-
undoMutations: [{ id:
|
|
1711
|
-
redoMutations: [{ id:
|
|
1844
|
+
undoMutations: [{ id: me.id, params: d }],
|
|
1845
|
+
redoMutations: [{ id: me.id, params: c }]
|
|
1712
1846
|
}), !0) : !1;
|
|
1713
1847
|
}
|
|
1714
|
-
},
|
|
1848
|
+
}, Le = {
|
|
1715
1849
|
id: "doc.operation.move-cursor",
|
|
1716
|
-
type:
|
|
1850
|
+
type: E.OPERATION,
|
|
1717
1851
|
handler: (s, e) => !!e
|
|
1718
|
-
},
|
|
1852
|
+
}, Fe = {
|
|
1719
1853
|
id: "doc.operation.move-selection",
|
|
1720
|
-
type:
|
|
1854
|
+
type: E.OPERATION,
|
|
1721
1855
|
handler: (s, e) => !!e
|
|
1722
|
-
},
|
|
1856
|
+
}, Hn = {
|
|
1723
1857
|
id: "doc.operation.select-all",
|
|
1724
|
-
type:
|
|
1858
|
+
type: E.COMMAND,
|
|
1725
1859
|
handler: async (s) => {
|
|
1726
|
-
const e = s.get(
|
|
1860
|
+
const e = s.get(U), t = s.get(w), n = e.getCurrentUniverDocInstance(), o = t.getActiveRange();
|
|
1727
1861
|
if (n == null || o == null)
|
|
1728
1862
|
return !1;
|
|
1729
1863
|
const { segmentId: r } = o, a = n.getSelfOrHeaderFooterModel(r).getSnapshot().body;
|
|
@@ -1738,19 +1872,19 @@ const $n = (s, e) => {
|
|
|
1738
1872
|
return t.replaceTextRanges(i, !1), !0;
|
|
1739
1873
|
}
|
|
1740
1874
|
};
|
|
1741
|
-
var
|
|
1742
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
1875
|
+
var Xn = Object.defineProperty, Vn = Object.getOwnPropertyDescriptor, Wn = (s, e, t, n) => {
|
|
1876
|
+
for (var o = n > 1 ? void 0 : n ? Vn(e, t) : e, r = s.length - 1, a; r >= 0; r--)
|
|
1743
1877
|
(a = s[r]) && (o = (n ? a(e, t, o) : a(o)) || o);
|
|
1744
|
-
return n && o &&
|
|
1878
|
+
return n && o && Xn(e, t, o), o;
|
|
1745
1879
|
}, te = (s, e) => (t, n) => e(t, n, s);
|
|
1746
|
-
let
|
|
1880
|
+
let he = class extends Ce {
|
|
1747
1881
|
constructor(e, t, n, o, r) {
|
|
1748
1882
|
super();
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1883
|
+
b(this, "_previousIMEContent", "");
|
|
1884
|
+
b(this, "_isCompositionStart", !0);
|
|
1885
|
+
b(this, "_onStartSubscription");
|
|
1886
|
+
b(this, "_onUpdateSubscription");
|
|
1887
|
+
b(this, "_onEndSubscription");
|
|
1754
1888
|
this._univerInstanceService = e, this._renderManagerSrv = t, this._textSelectionRenderManager = n, this._imeInputManagerService = o, this._commandService = r, this._initialize();
|
|
1755
1889
|
}
|
|
1756
1890
|
dispose() {
|
|
@@ -1766,7 +1900,7 @@ let fe = class extends xe {
|
|
|
1766
1900
|
return;
|
|
1767
1901
|
this._resetIME();
|
|
1768
1902
|
const { activeRange: t } = e;
|
|
1769
|
-
t != null && this._imeInputManagerService.setActiveRange(
|
|
1903
|
+
t != null && this._imeInputManagerService.setActiveRange(q.deepClone(t));
|
|
1770
1904
|
});
|
|
1771
1905
|
}
|
|
1772
1906
|
_initialOnCompositionUpdate() {
|
|
@@ -1780,13 +1914,13 @@ let fe = class extends xe {
|
|
|
1780
1914
|
});
|
|
1781
1915
|
}
|
|
1782
1916
|
async _updateContent(e, t) {
|
|
1783
|
-
var
|
|
1917
|
+
var d;
|
|
1784
1918
|
if (e == null)
|
|
1785
1919
|
return;
|
|
1786
1920
|
const n = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1787
1921
|
if (!n)
|
|
1788
1922
|
return;
|
|
1789
|
-
const o = (
|
|
1923
|
+
const o = (d = this._renderManagerSrv.getRenderById(n.getUnitId())) == null ? void 0 : d.with(W).getSkeleton(), { event: r, activeRange: a } = e;
|
|
1790
1924
|
if (o == null || a == null)
|
|
1791
1925
|
return;
|
|
1792
1926
|
const c = r.data;
|
|
@@ -1802,23 +1936,23 @@ let fe = class extends xe {
|
|
|
1802
1936
|
this._previousIMEContent = "", this._isCompositionStart = !0, this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(null);
|
|
1803
1937
|
}
|
|
1804
1938
|
};
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
te(0,
|
|
1808
|
-
te(1,
|
|
1809
|
-
te(2,
|
|
1810
|
-
te(3,
|
|
1811
|
-
te(4,
|
|
1812
|
-
],
|
|
1813
|
-
var
|
|
1814
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
1939
|
+
he = Wn([
|
|
1940
|
+
xe(Oe.Rendered, he),
|
|
1941
|
+
te(0, U),
|
|
1942
|
+
te(1, ie),
|
|
1943
|
+
te(2, ye),
|
|
1944
|
+
te(3, ee(Ee)),
|
|
1945
|
+
te(4, A)
|
|
1946
|
+
], he);
|
|
1947
|
+
var Yn = Object.defineProperty, Kn = Object.getOwnPropertyDescriptor, Zn = (s, e, t, n) => {
|
|
1948
|
+
for (var o = n > 1 ? void 0 : n ? Kn(e, t) : e, r = s.length - 1, a; r >= 0; r--)
|
|
1815
1949
|
(a = s[r]) && (o = (n ? a(e, t, o) : a(o)) || o);
|
|
1816
|
-
return n && o &&
|
|
1817
|
-
},
|
|
1818
|
-
let
|
|
1950
|
+
return n && o && Yn(e, t, o), o;
|
|
1951
|
+
}, ue = (s, e) => (t, n) => e(t, n, s);
|
|
1952
|
+
let pe = class extends Ce {
|
|
1819
1953
|
constructor(e, t, n, o) {
|
|
1820
1954
|
super();
|
|
1821
|
-
|
|
1955
|
+
b(this, "_onInputSubscription");
|
|
1822
1956
|
this._univerInstanceService = e, this._renderManagerService = t, this._textSelectionManagerService = n, this._commandService = o, this._commandExecutedListener();
|
|
1823
1957
|
}
|
|
1824
1958
|
dispose() {
|
|
@@ -1826,16 +1960,16 @@ let me = class extends xe {
|
|
|
1826
1960
|
super.dispose(), (e = this._onInputSubscription) == null || e.unsubscribe();
|
|
1827
1961
|
}
|
|
1828
1962
|
_commandExecutedListener() {
|
|
1829
|
-
const e = [
|
|
1963
|
+
const e = [Le.id, Fe.id];
|
|
1830
1964
|
this.disposeWithMe(
|
|
1831
1965
|
this._commandService.onCommandExecuted((t) => {
|
|
1832
1966
|
if (!e.includes(t.id))
|
|
1833
1967
|
return;
|
|
1834
1968
|
const n = t.params;
|
|
1835
1969
|
switch (t.id) {
|
|
1836
|
-
case
|
|
1970
|
+
case Le.id:
|
|
1837
1971
|
return this._handleMoveCursor(n.direction);
|
|
1838
|
-
case
|
|
1972
|
+
case Fe.id:
|
|
1839
1973
|
return this._handleShiftMoveSelection(n.direction);
|
|
1840
1974
|
default:
|
|
1841
1975
|
throw new Error("Unknown command");
|
|
@@ -1845,131 +1979,131 @@ let me = class extends xe {
|
|
|
1845
1979
|
}
|
|
1846
1980
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1847
1981
|
_handleShiftMoveSelection(e) {
|
|
1848
|
-
var
|
|
1849
|
-
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.
|
|
1982
|
+
var v, x, M;
|
|
1983
|
+
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getCurrentSelections(), o = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1850
1984
|
if (!o)
|
|
1851
1985
|
return;
|
|
1852
|
-
const r = (
|
|
1986
|
+
const r = (v = this._renderManagerService.getRenderById(o.getUnitId())) == null ? void 0 : v.with(W).getSkeleton(), a = this._getDocObject();
|
|
1853
1987
|
if (t == null || r == null || a == null)
|
|
1854
1988
|
return;
|
|
1855
1989
|
const {
|
|
1856
1990
|
startOffset: i,
|
|
1857
1991
|
endOffset: c,
|
|
1858
|
-
style:
|
|
1859
|
-
collapsed:
|
|
1992
|
+
style: d,
|
|
1993
|
+
collapsed: l,
|
|
1860
1994
|
direction: g,
|
|
1861
1995
|
segmentId: u,
|
|
1862
|
-
startNodePosition:
|
|
1996
|
+
startNodePosition: S,
|
|
1863
1997
|
endNodePosition: f,
|
|
1864
|
-
segmentPage:
|
|
1998
|
+
segmentPage: I
|
|
1865
1999
|
} = t;
|
|
1866
2000
|
if (n.length > 1) {
|
|
1867
|
-
let _ = Number.POSITIVE_INFINITY,
|
|
1868
|
-
for (const
|
|
1869
|
-
_ = Math.min(_,
|
|
2001
|
+
let _ = Number.POSITIVE_INFINITY, O = Number.NEGATIVE_INFINITY;
|
|
2002
|
+
for (const y of n)
|
|
2003
|
+
_ = Math.min(_, y.startOffset), O = Math.max(O, y.endOffset);
|
|
1870
2004
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1871
2005
|
{
|
|
1872
|
-
startOffset: e ===
|
|
1873
|
-
endOffset: e ===
|
|
1874
|
-
style:
|
|
2006
|
+
startOffset: e === F.LEFT || e === F.UP ? O : _,
|
|
2007
|
+
endOffset: e === F.LEFT || e === F.UP ? _ : O,
|
|
2008
|
+
style: d
|
|
1875
2009
|
}
|
|
1876
2010
|
], !1);
|
|
1877
2011
|
return;
|
|
1878
2012
|
}
|
|
1879
|
-
const
|
|
1880
|
-
let
|
|
1881
|
-
const p = (
|
|
1882
|
-
if (e ===
|
|
1883
|
-
const _ = r.findNodeByCharIndex(
|
|
1884
|
-
|
|
2013
|
+
const h = l || g === Pe.FORWARD ? i : c;
|
|
2014
|
+
let m = l || g === Pe.FORWARD ? c : i;
|
|
2015
|
+
const p = (x = o.getSelfOrHeaderFooterModel(u).getBody().dataStream.length) != null ? x : Number.POSITIVE_INFINITY;
|
|
2016
|
+
if (e === F.LEFT || e === F.RIGHT) {
|
|
2017
|
+
const _ = r.findNodeByCharIndex(m - 1, u, I), O = r.findNodeByCharIndex(m, u, I);
|
|
2018
|
+
m = e === F.RIGHT ? m + O.count : m - ((M = _ == null ? void 0 : _.count) != null ? M : 0), m = Math.min(p - 2, Math.max(0, m)), this._textSelectionManagerService.replaceTextRanges([
|
|
1885
2019
|
{
|
|
1886
|
-
startOffset:
|
|
1887
|
-
endOffset:
|
|
1888
|
-
style:
|
|
2020
|
+
startOffset: h,
|
|
2021
|
+
endOffset: m,
|
|
2022
|
+
style: d
|
|
1889
2023
|
}
|
|
1890
2024
|
], !1);
|
|
1891
2025
|
} else {
|
|
1892
|
-
const _ = r.findNodeByCharIndex(
|
|
1893
|
-
if (
|
|
1894
|
-
const
|
|
1895
|
-
if (
|
|
2026
|
+
const _ = r.findNodeByCharIndex(m, u, I), O = a.document.getOffsetConfig(), y = l ? S : g === Pe.FORWARD ? f : S, T = this._getTopOrBottomPosition(r, _, y, e === F.DOWN);
|
|
2027
|
+
if (T == null) {
|
|
2028
|
+
const D = e === F.UP ? 0 : p - 2;
|
|
2029
|
+
if (D === m)
|
|
1896
2030
|
return;
|
|
1897
2031
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1898
2032
|
{
|
|
1899
|
-
startOffset:
|
|
1900
|
-
endOffset:
|
|
1901
|
-
style:
|
|
2033
|
+
startOffset: h,
|
|
2034
|
+
endOffset: D,
|
|
2035
|
+
style: d
|
|
1902
2036
|
}
|
|
1903
2037
|
], !1);
|
|
1904
2038
|
return;
|
|
1905
2039
|
}
|
|
1906
|
-
const
|
|
1907
|
-
|
|
1908
|
-
|
|
2040
|
+
const R = new ct(O, r).getRangePointData(
|
|
2041
|
+
T,
|
|
2042
|
+
T
|
|
1909
2043
|
).cursorList[0];
|
|
1910
2044
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1911
2045
|
{
|
|
1912
|
-
startOffset:
|
|
1913
|
-
endOffset:
|
|
1914
|
-
style:
|
|
2046
|
+
startOffset: h,
|
|
2047
|
+
endOffset: R.endOffset,
|
|
2048
|
+
style: d
|
|
1915
2049
|
}
|
|
1916
2050
|
], !1);
|
|
1917
2051
|
}
|
|
1918
2052
|
}
|
|
1919
2053
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1920
2054
|
_handleMoveCursor(e) {
|
|
1921
|
-
var
|
|
1922
|
-
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.
|
|
2055
|
+
var h, m, p;
|
|
2056
|
+
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getCurrentSelections(), o = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1923
2057
|
if (!o)
|
|
1924
2058
|
return !1;
|
|
1925
|
-
const r = (
|
|
2059
|
+
const r = (h = this._renderManagerService.getRenderById(o.getUnitId())) == null ? void 0 : h.with(W).getSkeleton(), a = this._getDocObject();
|
|
1926
2060
|
if (t == null || r == null || a == null || n == null)
|
|
1927
2061
|
return;
|
|
1928
|
-
const { startOffset: i, endOffset: c, style:
|
|
1929
|
-
if (e ===
|
|
1930
|
-
let
|
|
2062
|
+
const { startOffset: i, endOffset: c, style: d, collapsed: l, segmentId: g, startNodePosition: u, endNodePosition: S, segmentPage: f } = t, I = (m = o.getSelfOrHeaderFooterModel(g).getBody().dataStream.length) != null ? m : Number.POSITIVE_INFINITY;
|
|
2063
|
+
if (e === F.LEFT || e === F.RIGHT) {
|
|
2064
|
+
let v;
|
|
1931
2065
|
if (!t.collapsed || n.length > 1) {
|
|
1932
|
-
let
|
|
2066
|
+
let x = Number.POSITIVE_INFINITY, M = Number.NEGATIVE_INFINITY;
|
|
1933
2067
|
for (const _ of n)
|
|
1934
|
-
|
|
1935
|
-
|
|
2068
|
+
x = Math.min(x, _.startOffset), M = Math.max(M, _.endOffset);
|
|
2069
|
+
v = e === F.LEFT ? x : M;
|
|
1936
2070
|
} else {
|
|
1937
|
-
const
|
|
1938
|
-
e ===
|
|
2071
|
+
const x = r.findNodeByCharIndex(i - 1, g, f), M = r.findNodeByCharIndex(i, g, f);
|
|
2072
|
+
e === F.LEFT ? v = Math.max(0, i - ((p = x == null ? void 0 : x.count) != null ? p : 0)) : v = Math.min(I - 2, c + M.count);
|
|
1939
2073
|
}
|
|
1940
2074
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1941
2075
|
{
|
|
1942
|
-
startOffset:
|
|
1943
|
-
endOffset:
|
|
1944
|
-
style:
|
|
2076
|
+
startOffset: v,
|
|
2077
|
+
endOffset: v,
|
|
2078
|
+
style: d
|
|
1945
2079
|
}
|
|
1946
2080
|
], !1);
|
|
1947
2081
|
} else {
|
|
1948
|
-
const
|
|
2082
|
+
const v = r.findNodeByCharIndex(i, g, f), x = r.findNodeByCharIndex(c, g, f), M = a.document.getOffsetConfig(), _ = this._getTopOrBottomPosition(
|
|
1949
2083
|
r,
|
|
1950
|
-
e ===
|
|
1951
|
-
e ===
|
|
1952
|
-
e ===
|
|
2084
|
+
e === F.UP ? v : x,
|
|
2085
|
+
e === F.UP ? u : S,
|
|
2086
|
+
e === F.DOWN
|
|
1953
2087
|
);
|
|
1954
2088
|
if (_ == null) {
|
|
1955
|
-
let
|
|
1956
|
-
|
|
2089
|
+
let y;
|
|
2090
|
+
l ? y = e === F.UP ? 0 : I - 2 : y = e === F.UP ? i : c, this._textSelectionManagerService.replaceTextRanges([
|
|
1957
2091
|
{
|
|
1958
|
-
startOffset:
|
|
1959
|
-
endOffset:
|
|
1960
|
-
style:
|
|
2092
|
+
startOffset: y,
|
|
2093
|
+
endOffset: y,
|
|
2094
|
+
style: d
|
|
1961
2095
|
}
|
|
1962
2096
|
], !1);
|
|
1963
2097
|
return;
|
|
1964
2098
|
}
|
|
1965
|
-
const
|
|
2099
|
+
const O = new ct(M, r).getRangePointData(
|
|
1966
2100
|
_,
|
|
1967
2101
|
_
|
|
1968
2102
|
).cursorList[0];
|
|
1969
2103
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1970
2104
|
{
|
|
1971
|
-
...
|
|
1972
|
-
style:
|
|
2105
|
+
...O,
|
|
2106
|
+
style: d
|
|
1973
2107
|
}
|
|
1974
2108
|
], !1);
|
|
1975
2109
|
}
|
|
@@ -1997,9 +2131,9 @@ let me = class extends xe {
|
|
|
1997
2131
|
};
|
|
1998
2132
|
for (const i of t.divides) {
|
|
1999
2133
|
const c = i.left;
|
|
2000
|
-
for (const
|
|
2001
|
-
const { left:
|
|
2002
|
-
u < r.distance && (r.glyph =
|
|
2134
|
+
for (const d of i.glyphGroup) {
|
|
2135
|
+
const { left: l } = d, g = c + l, u = Math.abs(n - g);
|
|
2136
|
+
u < r.distance && (r.glyph = d, r.distance = u);
|
|
2003
2137
|
}
|
|
2004
2138
|
}
|
|
2005
2139
|
if (r.glyph == null)
|
|
@@ -2009,7 +2143,7 @@ let me = class extends xe {
|
|
|
2009
2143
|
}
|
|
2010
2144
|
// eslint-disable-next-line max-lines-per-function
|
|
2011
2145
|
_getNextOrPrevLine(e, t) {
|
|
2012
|
-
var f,
|
|
2146
|
+
var f, I, h, m, p, v, x, M, _, O, y, T;
|
|
2013
2147
|
const n = e.parent;
|
|
2014
2148
|
if (n == null)
|
|
2015
2149
|
return;
|
|
@@ -2028,69 +2162,69 @@ let me = class extends xe {
|
|
|
2028
2162
|
const c = r.parent;
|
|
2029
2163
|
if (c == null)
|
|
2030
2164
|
return;
|
|
2031
|
-
const
|
|
2032
|
-
if (
|
|
2165
|
+
const d = c.columns.indexOf(r);
|
|
2166
|
+
if (d === -1)
|
|
2033
2167
|
return;
|
|
2034
2168
|
if (t === !0)
|
|
2035
|
-
i = (f = c.columns[
|
|
2169
|
+
i = (f = c.columns[d + 1]) == null ? void 0 : f.lines[0];
|
|
2036
2170
|
else {
|
|
2037
|
-
const
|
|
2038
|
-
i =
|
|
2171
|
+
const R = (h = (I = c.columns) == null ? void 0 : I[d - 1]) == null ? void 0 : h.lines;
|
|
2172
|
+
i = R == null ? void 0 : R[R.length - 1];
|
|
2039
2173
|
}
|
|
2040
2174
|
if (i != null)
|
|
2041
2175
|
return i;
|
|
2042
|
-
const
|
|
2043
|
-
if (
|
|
2176
|
+
const l = c.parent;
|
|
2177
|
+
if (l == null)
|
|
2044
2178
|
return;
|
|
2045
|
-
const g =
|
|
2179
|
+
const g = l.sections.indexOf(c);
|
|
2046
2180
|
if (g === -1)
|
|
2047
2181
|
return;
|
|
2048
2182
|
if (t === !0)
|
|
2049
|
-
i = (p = (
|
|
2183
|
+
i = (p = (m = l.sections[g - 1]) == null ? void 0 : m.columns[0]) == null ? void 0 : p.lines[0];
|
|
2050
2184
|
else {
|
|
2051
|
-
const
|
|
2052
|
-
i =
|
|
2185
|
+
const R = (x = (v = l.sections) == null ? void 0 : v[g - 1]) == null ? void 0 : x.columns, D = R == null ? void 0 : R[R.length - 1], N = D == null ? void 0 : D.lines;
|
|
2186
|
+
i = N == null ? void 0 : N[N.length - 1];
|
|
2053
2187
|
}
|
|
2054
2188
|
if (i != null)
|
|
2055
2189
|
return i;
|
|
2056
|
-
const u =
|
|
2190
|
+
const u = l.parent;
|
|
2057
2191
|
if (u == null)
|
|
2058
2192
|
return;
|
|
2059
|
-
const
|
|
2060
|
-
if (
|
|
2193
|
+
const S = u.pages.indexOf(l);
|
|
2194
|
+
if (S !== -1) {
|
|
2061
2195
|
if (t === !0)
|
|
2062
|
-
i = (
|
|
2196
|
+
i = (O = (_ = (M = u.pages[S + 1]) == null ? void 0 : M.sections[0]) == null ? void 0 : _.columns[0]) == null ? void 0 : O.lines[0];
|
|
2063
2197
|
else {
|
|
2064
|
-
const
|
|
2065
|
-
if (
|
|
2198
|
+
const R = (y = u.pages[S - 1]) == null ? void 0 : y.sections;
|
|
2199
|
+
if (R == null)
|
|
2066
2200
|
return;
|
|
2067
|
-
const
|
|
2068
|
-
i =
|
|
2201
|
+
const D = (T = R[R.length - 1]) == null ? void 0 : T.columns, N = D[D.length - 1], L = N == null ? void 0 : N.lines;
|
|
2202
|
+
i = L[L.length - 1];
|
|
2069
2203
|
}
|
|
2070
2204
|
if (i != null)
|
|
2071
2205
|
return i;
|
|
2072
2206
|
}
|
|
2073
2207
|
}
|
|
2074
2208
|
_getDocObject() {
|
|
2075
|
-
return
|
|
2209
|
+
return _n(this._univerInstanceService, this._renderManagerService);
|
|
2076
2210
|
}
|
|
2077
2211
|
};
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
],
|
|
2085
|
-
var
|
|
2086
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
2212
|
+
pe = Zn([
|
|
2213
|
+
xe(Oe.Rendered, pe),
|
|
2214
|
+
ue(0, U),
|
|
2215
|
+
ue(1, ie),
|
|
2216
|
+
ue(2, ee(w)),
|
|
2217
|
+
ue(3, A)
|
|
2218
|
+
], pe);
|
|
2219
|
+
var Jn = Object.defineProperty, qn = Object.getOwnPropertyDescriptor, Qn = (s, e, t, n) => {
|
|
2220
|
+
for (var o = n > 1 ? void 0 : n ? qn(e, t) : e, r = s.length - 1, a; r >= 0; r--)
|
|
2087
2221
|
(a = s[r]) && (o = (n ? a(e, t, o) : a(o)) || o);
|
|
2088
|
-
return n && o &&
|
|
2089
|
-
},
|
|
2090
|
-
let
|
|
2222
|
+
return n && o && Jn(e, t, o), o;
|
|
2223
|
+
}, ge = (s, e) => (t, n) => e(t, n, s);
|
|
2224
|
+
let Se = class extends Ce {
|
|
2091
2225
|
constructor(e, t, n, o) {
|
|
2092
2226
|
super();
|
|
2093
|
-
|
|
2227
|
+
b(this, "_onInputSubscription");
|
|
2094
2228
|
this._univerInstanceService = e, this._renderManagerService = t, this._textSelectionRenderManager = n, this._commandService = o, this._init();
|
|
2095
2229
|
}
|
|
2096
2230
|
dispose() {
|
|
@@ -2102,127 +2236,127 @@ let he = class extends xe {
|
|
|
2102
2236
|
}
|
|
2103
2237
|
_initialNormalInput() {
|
|
2104
2238
|
this._onInputSubscription = this._textSelectionRenderManager.onInput$.subscribe(async (e) => {
|
|
2105
|
-
var
|
|
2239
|
+
var I;
|
|
2106
2240
|
if (e == null)
|
|
2107
2241
|
return;
|
|
2108
2242
|
const t = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
2109
2243
|
if (!t)
|
|
2110
2244
|
return;
|
|
2111
|
-
const n = t.getUnitId(), { event: o, content: r = "", activeRange: a } = e, i = o, c = (
|
|
2245
|
+
const n = t.getUnitId(), { event: o, content: r = "", activeRange: a } = e, i = o, c = (I = this._renderManagerService.getRenderById(t.getUnitId())) == null ? void 0 : I.with(W).getSkeleton();
|
|
2112
2246
|
if (i.data == null || c == null || !c || !a)
|
|
2113
2247
|
return;
|
|
2114
|
-
const { startOffset:
|
|
2248
|
+
const { startOffset: d, segmentId: l, style: g, segmentPage: u } = a, S = r.length, f = [
|
|
2115
2249
|
{
|
|
2116
|
-
startOffset:
|
|
2117
|
-
endOffset:
|
|
2118
|
-
segmentId:
|
|
2250
|
+
startOffset: d + S,
|
|
2251
|
+
endOffset: d + S,
|
|
2252
|
+
segmentId: l,
|
|
2119
2253
|
segmentPage: u,
|
|
2120
2254
|
style: g
|
|
2121
2255
|
}
|
|
2122
2256
|
];
|
|
2123
|
-
await this._commandService.executeCommand(
|
|
2257
|
+
await this._commandService.executeCommand(ve.id, {
|
|
2124
2258
|
unitId: n,
|
|
2125
2259
|
body: {
|
|
2126
2260
|
dataStream: r
|
|
2127
2261
|
},
|
|
2128
2262
|
textRanges: f,
|
|
2129
2263
|
range: a,
|
|
2130
|
-
segmentId:
|
|
2264
|
+
segmentId: l
|
|
2131
2265
|
});
|
|
2132
2266
|
});
|
|
2133
2267
|
}
|
|
2134
2268
|
};
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
],
|
|
2142
|
-
const
|
|
2269
|
+
Se = Qn([
|
|
2270
|
+
xe(Oe.Rendered, Se),
|
|
2271
|
+
ge(0, U),
|
|
2272
|
+
ge(1, ie),
|
|
2273
|
+
ge(2, ye),
|
|
2274
|
+
ge(3, A)
|
|
2275
|
+
], Se);
|
|
2276
|
+
const de = {
|
|
2143
2277
|
id: "doc.command.align-operation",
|
|
2144
|
-
type:
|
|
2278
|
+
type: E.COMMAND,
|
|
2145
2279
|
// eslint-disable-next-line max-lines-per-function
|
|
2146
2280
|
handler: (s, e) => {
|
|
2147
|
-
var
|
|
2148
|
-
const t = s.get(
|
|
2281
|
+
var M, _;
|
|
2282
|
+
const t = s.get(w), n = s.get(U), o = s.get(A), { alignType: r } = e, a = n.getCurrentUniverDocInstance(), i = t.getActiveRange();
|
|
2149
2283
|
if (a == null || i == null)
|
|
2150
2284
|
return !1;
|
|
2151
|
-
const { segmentId: c } = i,
|
|
2152
|
-
if (
|
|
2285
|
+
const { segmentId: c } = i, d = (M = t.getCurrentSelections()) != null ? M : [], l = (_ = a.getSelfOrHeaderFooterModel(c).getBody()) == null ? void 0 : _.paragraphs, g = d.map(Q);
|
|
2286
|
+
if (l == null)
|
|
2153
2287
|
return !1;
|
|
2154
|
-
const u =
|
|
2155
|
-
var
|
|
2156
|
-
return ((
|
|
2157
|
-
}),
|
|
2158
|
-
id:
|
|
2288
|
+
const u = kt(i, l), S = a.getUnitId(), f = u.every((O) => {
|
|
2289
|
+
var y;
|
|
2290
|
+
return ((y = O.paragraphStyle) == null ? void 0 : y.horizontalAlign) === r;
|
|
2291
|
+
}), I = {
|
|
2292
|
+
id: G.id,
|
|
2159
2293
|
params: {
|
|
2160
|
-
unitId:
|
|
2294
|
+
unitId: S,
|
|
2161
2295
|
actions: [],
|
|
2162
2296
|
textRanges: g
|
|
2163
2297
|
}
|
|
2164
|
-
},
|
|
2165
|
-
|
|
2166
|
-
const
|
|
2167
|
-
for (const
|
|
2168
|
-
const { startIndex:
|
|
2169
|
-
|
|
2298
|
+
}, h = new re();
|
|
2299
|
+
h.reset();
|
|
2300
|
+
const m = new $(), p = B.getInstance();
|
|
2301
|
+
for (const O of u) {
|
|
2302
|
+
const { startIndex: y } = O;
|
|
2303
|
+
m.push({
|
|
2170
2304
|
t: C.RETAIN,
|
|
2171
|
-
len:
|
|
2305
|
+
len: y - h.cursor,
|
|
2172
2306
|
segmentId: c
|
|
2173
2307
|
});
|
|
2174
|
-
const
|
|
2175
|
-
...
|
|
2176
|
-
horizontalAlign: f ?
|
|
2308
|
+
const T = {
|
|
2309
|
+
...O.paragraphStyle,
|
|
2310
|
+
horizontalAlign: f ? ae.UNSPECIFIED : r
|
|
2177
2311
|
};
|
|
2178
|
-
|
|
2312
|
+
m.push({
|
|
2179
2313
|
t: C.RETAIN,
|
|
2180
2314
|
len: 1,
|
|
2181
2315
|
body: {
|
|
2182
2316
|
dataStream: "",
|
|
2183
2317
|
paragraphs: [
|
|
2184
2318
|
{
|
|
2185
|
-
...
|
|
2186
|
-
paragraphStyle:
|
|
2319
|
+
...O,
|
|
2320
|
+
paragraphStyle: T,
|
|
2187
2321
|
startIndex: 0
|
|
2188
2322
|
}
|
|
2189
2323
|
]
|
|
2190
2324
|
},
|
|
2191
2325
|
segmentId: c,
|
|
2192
|
-
coverType:
|
|
2193
|
-
}),
|
|
2326
|
+
coverType: Re.REPLACE
|
|
2327
|
+
}), h.moveCursorTo(y + 1);
|
|
2194
2328
|
}
|
|
2195
|
-
const
|
|
2196
|
-
return
|
|
2329
|
+
const v = j(a, c);
|
|
2330
|
+
return I.params.actions = p.editOp(m.serialize(), v), !!o.syncExecuteCommand(I.id, I.params);
|
|
2197
2331
|
}
|
|
2198
|
-
},
|
|
2332
|
+
}, es = {
|
|
2199
2333
|
id: "doc.command.align-left",
|
|
2200
|
-
type:
|
|
2201
|
-
handler: (s) => s.get(
|
|
2202
|
-
alignType:
|
|
2334
|
+
type: E.COMMAND,
|
|
2335
|
+
handler: (s) => s.get(A).syncExecuteCommand(de.id, {
|
|
2336
|
+
alignType: ae.LEFT
|
|
2203
2337
|
})
|
|
2204
|
-
},
|
|
2338
|
+
}, ts = {
|
|
2205
2339
|
id: "doc.command.align-center",
|
|
2206
|
-
type:
|
|
2207
|
-
handler: (s) => s.get(
|
|
2208
|
-
alignType:
|
|
2340
|
+
type: E.COMMAND,
|
|
2341
|
+
handler: (s) => s.get(A).syncExecuteCommand(de.id, {
|
|
2342
|
+
alignType: ae.CENTER
|
|
2209
2343
|
})
|
|
2210
|
-
},
|
|
2344
|
+
}, ns = {
|
|
2211
2345
|
id: "doc.command.align-right",
|
|
2212
|
-
type:
|
|
2213
|
-
handler: (s) => s.get(
|
|
2214
|
-
alignType:
|
|
2346
|
+
type: E.COMMAND,
|
|
2347
|
+
handler: (s) => s.get(A).syncExecuteCommand(de.id, {
|
|
2348
|
+
alignType: ae.RIGHT
|
|
2215
2349
|
})
|
|
2216
|
-
},
|
|
2350
|
+
}, ss = {
|
|
2217
2351
|
id: "doc.command.align-justify",
|
|
2218
|
-
type:
|
|
2219
|
-
handler: (s) => s.get(
|
|
2220
|
-
alignType:
|
|
2352
|
+
type: E.COMMAND,
|
|
2353
|
+
handler: (s) => s.get(A).syncExecuteCommand(de.id, {
|
|
2354
|
+
alignType: ae.JUSTIFIED
|
|
2221
2355
|
})
|
|
2222
2356
|
};
|
|
2223
|
-
class
|
|
2357
|
+
class os {
|
|
2224
2358
|
constructor() {
|
|
2225
|
-
|
|
2359
|
+
b(this, "_customRangeHooks", []);
|
|
2226
2360
|
}
|
|
2227
2361
|
addClipboardHook(e) {
|
|
2228
2362
|
return this._customRangeHooks.push(e), Nt(() => {
|
|
@@ -2237,110 +2371,111 @@ class ts {
|
|
|
2237
2371
|
}), t;
|
|
2238
2372
|
}
|
|
2239
2373
|
}
|
|
2240
|
-
var
|
|
2241
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
2374
|
+
var rs = Object.defineProperty, as = Object.getOwnPropertyDescriptor, is = (s, e, t, n) => {
|
|
2375
|
+
for (var o = n > 1 ? void 0 : n ? as(e, t) : e, r = s.length - 1, a; r >= 0; r--)
|
|
2242
2376
|
(a = s[r]) && (o = (n ? a(e, t, o) : a(o)) || o);
|
|
2243
|
-
return n && o &&
|
|
2244
|
-
},
|
|
2245
|
-
const
|
|
2246
|
-
var
|
|
2247
|
-
let yt = (
|
|
2377
|
+
return n && o && rs(e, t, o), o;
|
|
2378
|
+
}, cs = (s, e) => (t, n) => e(t, n, s);
|
|
2379
|
+
const ds = "docs";
|
|
2380
|
+
var fe;
|
|
2381
|
+
let yt = (fe = class extends en {
|
|
2248
2382
|
constructor(s = {}, e) {
|
|
2249
2383
|
super(), this._injector = e, this._initializeDependencies(e), this._initializeCommands();
|
|
2250
2384
|
}
|
|
2251
2385
|
_initializeCommands() {
|
|
2252
2386
|
[
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
ke,
|
|
2258
|
-
We,
|
|
2387
|
+
Le,
|
|
2388
|
+
Fe,
|
|
2389
|
+
Pn,
|
|
2390
|
+
wn,
|
|
2259
2391
|
Ye,
|
|
2260
2392
|
Ke,
|
|
2261
|
-
se,
|
|
2262
2393
|
Ze,
|
|
2263
2394
|
Je,
|
|
2395
|
+
oe,
|
|
2264
2396
|
qe,
|
|
2265
2397
|
Qe,
|
|
2266
|
-
tt,
|
|
2267
2398
|
et,
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2399
|
+
tt,
|
|
2400
|
+
st,
|
|
2401
|
+
nt,
|
|
2402
|
+
$t,
|
|
2403
|
+
Nn,
|
|
2404
|
+
ve,
|
|
2405
|
+
se,
|
|
2274
2406
|
Ve,
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2407
|
+
Ut,
|
|
2408
|
+
Ft,
|
|
2409
|
+
We,
|
|
2410
|
+
G,
|
|
2411
|
+
$n,
|
|
2412
|
+
kn,
|
|
2281
2413
|
zn,
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2414
|
+
me,
|
|
2415
|
+
Pt,
|
|
2416
|
+
Hn,
|
|
2417
|
+
Gn,
|
|
2418
|
+
Fn,
|
|
2419
|
+
ot,
|
|
2420
|
+
es,
|
|
2421
|
+
ts,
|
|
2422
|
+
ns,
|
|
2423
|
+
de,
|
|
2424
|
+
ss
|
|
2290
2425
|
].forEach((s) => {
|
|
2291
|
-
this._injector.get(
|
|
2426
|
+
this._injector.get(A).registerCommand(s);
|
|
2292
2427
|
});
|
|
2293
2428
|
}
|
|
2294
2429
|
_initializeDependencies(s) {
|
|
2295
2430
|
[
|
|
2296
2431
|
// services
|
|
2297
|
-
[
|
|
2298
|
-
[
|
|
2432
|
+
[_e],
|
|
2433
|
+
[Ee],
|
|
2299
2434
|
[
|
|
2300
|
-
|
|
2435
|
+
ye,
|
|
2301
2436
|
{
|
|
2302
|
-
useClass:
|
|
2437
|
+
useClass: mn
|
|
2303
2438
|
}
|
|
2304
2439
|
],
|
|
2305
|
-
[
|
|
2306
|
-
[
|
|
2440
|
+
[w],
|
|
2441
|
+
[os],
|
|
2307
2442
|
// controllers
|
|
2443
|
+
[Se],
|
|
2308
2444
|
[he],
|
|
2309
|
-
[
|
|
2310
|
-
[me]
|
|
2445
|
+
[pe]
|
|
2311
2446
|
].forEach((e) => s.add(e));
|
|
2312
2447
|
}
|
|
2313
|
-
},
|
|
2314
|
-
yt =
|
|
2315
|
-
|
|
2448
|
+
}, b(fe, "pluginName", ds), b(fe, "type", J.UNIVER_DOC), fe);
|
|
2449
|
+
yt = is([
|
|
2450
|
+
cs(1, ee(hn))
|
|
2316
2451
|
], yt);
|
|
2317
|
-
function
|
|
2318
|
-
const { range: t, rangeId: n, rangeType: o, segmentId: r } = s, a =
|
|
2452
|
+
function ls(s, e) {
|
|
2453
|
+
const { range: t, rangeId: n, rangeType: o, segmentId: r } = s, a = pn(t, e);
|
|
2319
2454
|
if (!a)
|
|
2320
2455
|
return null;
|
|
2321
|
-
const { startOffset: i, endOffset: c } = a,
|
|
2322
|
-
return i > 0 &&
|
|
2456
|
+
const { startOffset: i, endOffset: c } = a, d = new $();
|
|
2457
|
+
return i > 0 && d.push({
|
|
2323
2458
|
t: C.RETAIN,
|
|
2324
2459
|
len: i,
|
|
2325
2460
|
segmentId: r
|
|
2326
|
-
}),
|
|
2461
|
+
}), d.push({
|
|
2327
2462
|
t: C.INSERT,
|
|
2328
2463
|
body: {
|
|
2329
|
-
dataStream:
|
|
2464
|
+
dataStream: P.CUSTOM_RANGE_START
|
|
2330
2465
|
},
|
|
2331
2466
|
len: 1,
|
|
2332
2467
|
line: 0
|
|
2333
|
-
}),
|
|
2468
|
+
}), d.push({
|
|
2334
2469
|
t: C.RETAIN,
|
|
2335
2470
|
body: {
|
|
2336
2471
|
dataStream: ""
|
|
2337
2472
|
},
|
|
2338
2473
|
len: c - i,
|
|
2339
2474
|
segmentId: r
|
|
2340
|
-
}),
|
|
2475
|
+
}), d.push({
|
|
2341
2476
|
t: C.INSERT,
|
|
2342
2477
|
body: {
|
|
2343
|
-
dataStream:
|
|
2478
|
+
dataStream: P.CUSTOM_RANGE_END,
|
|
2344
2479
|
customRanges: [
|
|
2345
2480
|
{
|
|
2346
2481
|
rangeId: n,
|
|
@@ -2352,78 +2487,78 @@ function is(s, e) {
|
|
|
2352
2487
|
},
|
|
2353
2488
|
len: 1,
|
|
2354
2489
|
line: 0
|
|
2355
|
-
}),
|
|
2490
|
+
}), d;
|
|
2356
2491
|
}
|
|
2357
|
-
function
|
|
2492
|
+
function Ps(s, e) {
|
|
2358
2493
|
const t = {
|
|
2359
|
-
id:
|
|
2494
|
+
id: G.id,
|
|
2360
2495
|
params: {
|
|
2361
2496
|
unitId: s.unitId,
|
|
2362
2497
|
actions: [],
|
|
2363
2498
|
textRanges: void 0
|
|
2364
2499
|
}
|
|
2365
|
-
}, n =
|
|
2500
|
+
}, n = B.getInstance(), o = ls(s, e);
|
|
2366
2501
|
return o ? (t.params.actions = n.editOp(o.serialize()), t) : !1;
|
|
2367
2502
|
}
|
|
2368
|
-
function
|
|
2369
|
-
var
|
|
2370
|
-
const { segmentId: t, rangeId: n, rangeType: o } = e, r = s.get(
|
|
2503
|
+
function ws(s, e) {
|
|
2504
|
+
var M;
|
|
2505
|
+
const { segmentId: t, rangeId: n, rangeType: o } = e, r = s.get(w), a = s.get(U), i = r.getActiveRange();
|
|
2371
2506
|
if (!i)
|
|
2372
2507
|
return !1;
|
|
2373
|
-
const c = a.getCurrentUnitForType(
|
|
2508
|
+
const c = a.getCurrentUnitForType(J.UNIVER_DOC);
|
|
2374
2509
|
if (!c)
|
|
2375
2510
|
return !1;
|
|
2376
|
-
const
|
|
2377
|
-
if (!
|
|
2511
|
+
const d = c.getBody(), l = c.getUnitId();
|
|
2512
|
+
if (!d)
|
|
2378
2513
|
return !1;
|
|
2379
|
-
const { startOffset: g, endOffset: u } =
|
|
2380
|
-
for (let _ = 0,
|
|
2381
|
-
const
|
|
2382
|
-
if (
|
|
2514
|
+
const { startOffset: g, endOffset: u } = ce(i), S = (M = d.customRanges) != null ? M : [], f = [];
|
|
2515
|
+
for (let _ = 0, O = S.length; _ < O; _++) {
|
|
2516
|
+
const y = S[_];
|
|
2517
|
+
if (y.rangeType === o && Math.max(y.startIndex, g) <= Math.min(y.endIndex, u - 1) && f.push({ ...y }), y.startIndex >= u)
|
|
2383
2518
|
break;
|
|
2384
2519
|
}
|
|
2385
|
-
const
|
|
2386
|
-
let
|
|
2387
|
-
const
|
|
2388
|
-
startOffset: Math.min(
|
|
2389
|
-
endOffset: Math.max(
|
|
2520
|
+
const I = f.map((_) => [_.startIndex, _.endIndex]).flat().sort((_, O) => _ - O);
|
|
2521
|
+
let h = 0;
|
|
2522
|
+
const m = new $(), p = I.length ? {
|
|
2523
|
+
startOffset: Math.min(I[0], g),
|
|
2524
|
+
endOffset: Math.max(I[I.length - 1] + 1, u)
|
|
2390
2525
|
} : i;
|
|
2391
|
-
p.startOffset !==
|
|
2526
|
+
p.startOffset !== h && (m.push({
|
|
2392
2527
|
t: C.RETAIN,
|
|
2393
|
-
len: p.startOffset -
|
|
2528
|
+
len: p.startOffset - h,
|
|
2394
2529
|
segmentId: t
|
|
2395
|
-
}),
|
|
2530
|
+
}), h = p.startOffset), m.push({
|
|
2396
2531
|
t: C.INSERT,
|
|
2397
2532
|
body: {
|
|
2398
|
-
dataStream:
|
|
2533
|
+
dataStream: P.CUSTOM_RANGE_START
|
|
2399
2534
|
},
|
|
2400
2535
|
len: 1,
|
|
2401
2536
|
line: 0,
|
|
2402
2537
|
segmentId: t
|
|
2403
|
-
}),
|
|
2404
|
-
_ !==
|
|
2538
|
+
}), I.forEach((_, O) => {
|
|
2539
|
+
_ !== h && (m.push({
|
|
2405
2540
|
t: C.RETAIN,
|
|
2406
|
-
len: _ -
|
|
2541
|
+
len: _ - h,
|
|
2407
2542
|
segmentId: t
|
|
2408
|
-
}),
|
|
2543
|
+
}), h = _), m.push({
|
|
2409
2544
|
t: C.DELETE,
|
|
2410
2545
|
len: 1,
|
|
2411
2546
|
line: 0,
|
|
2412
2547
|
segmentId: t
|
|
2413
|
-
}),
|
|
2414
|
-
}),
|
|
2548
|
+
}), h++;
|
|
2549
|
+
}), h !== p.endOffset && (m.push({
|
|
2415
2550
|
t: C.RETAIN,
|
|
2416
|
-
len: p.endOffset -
|
|
2551
|
+
len: p.endOffset - h,
|
|
2417
2552
|
segmentId: t
|
|
2418
|
-
}),
|
|
2553
|
+
}), h = p.endOffset), m.push({
|
|
2419
2554
|
t: C.INSERT,
|
|
2420
2555
|
body: {
|
|
2421
|
-
dataStream:
|
|
2556
|
+
dataStream: P.CUSTOM_RANGE_END,
|
|
2422
2557
|
customRanges: [
|
|
2423
2558
|
{
|
|
2424
2559
|
rangeId: n,
|
|
2425
2560
|
rangeType: o,
|
|
2426
|
-
startIndex: -(p.endOffset - p.startOffset -
|
|
2561
|
+
startIndex: -(p.endOffset - p.startOffset - I.length + 1),
|
|
2427
2562
|
endIndex: 0
|
|
2428
2563
|
}
|
|
2429
2564
|
]
|
|
@@ -2432,70 +2567,70 @@ function Ds(s, e) {
|
|
|
2432
2567
|
line: 0,
|
|
2433
2568
|
segmentId: t
|
|
2434
2569
|
});
|
|
2435
|
-
const
|
|
2436
|
-
id:
|
|
2570
|
+
const v = B.getInstance(), x = {
|
|
2571
|
+
id: G.id,
|
|
2437
2572
|
params: {
|
|
2438
|
-
unitId:
|
|
2573
|
+
unitId: l,
|
|
2439
2574
|
actions: [],
|
|
2440
2575
|
textRanges: void 0
|
|
2441
2576
|
}
|
|
2442
2577
|
};
|
|
2443
|
-
return
|
|
2578
|
+
return x.params.actions = v.editOp(m.serialize()), x;
|
|
2444
2579
|
}
|
|
2445
|
-
function
|
|
2446
|
-
var u,
|
|
2447
|
-
const { unitId: t, rangeId: n, segmentId: o } = e, a = s.get(
|
|
2580
|
+
function us(s, e) {
|
|
2581
|
+
var u, S;
|
|
2582
|
+
const { unitId: t, rangeId: n, segmentId: o } = e, a = s.get(U).getUnit(t);
|
|
2448
2583
|
if (!a)
|
|
2449
2584
|
return !1;
|
|
2450
|
-
const i = (
|
|
2585
|
+
const i = (S = (u = a.getBody()) == null ? void 0 : u.customRanges) == null ? void 0 : S.find((f) => f.rangeId === n);
|
|
2451
2586
|
if (!i)
|
|
2452
2587
|
return !1;
|
|
2453
|
-
const { startIndex: c, endIndex:
|
|
2454
|
-
return c > 0 &&
|
|
2588
|
+
const { startIndex: c, endIndex: d } = i, l = new $(), g = d - c + 1;
|
|
2589
|
+
return c > 0 && l.push({
|
|
2455
2590
|
t: C.RETAIN,
|
|
2456
2591
|
len: c,
|
|
2457
2592
|
segmentId: o
|
|
2458
|
-
}),
|
|
2593
|
+
}), l.push({
|
|
2459
2594
|
t: C.DELETE,
|
|
2460
2595
|
len: 1,
|
|
2461
2596
|
segmentId: o,
|
|
2462
2597
|
line: 0
|
|
2463
|
-
}), g - 2 > 0 &&
|
|
2598
|
+
}), g - 2 > 0 && l.push({
|
|
2464
2599
|
t: C.RETAIN,
|
|
2465
2600
|
len: g - 2,
|
|
2466
2601
|
segmentId: o
|
|
2467
|
-
}),
|
|
2602
|
+
}), l.push({
|
|
2468
2603
|
t: C.DELETE,
|
|
2469
2604
|
len: 1,
|
|
2470
2605
|
segmentId: o,
|
|
2471
2606
|
line: 0
|
|
2472
|
-
}),
|
|
2607
|
+
}), l;
|
|
2473
2608
|
}
|
|
2474
|
-
function
|
|
2609
|
+
function Us(s, e) {
|
|
2475
2610
|
const t = {
|
|
2476
|
-
id:
|
|
2611
|
+
id: G.id,
|
|
2477
2612
|
params: {
|
|
2478
2613
|
unitId: e.unitId,
|
|
2479
2614
|
actions: [],
|
|
2480
2615
|
textRanges: void 0
|
|
2481
2616
|
}
|
|
2482
|
-
}, n =
|
|
2617
|
+
}, n = B.getInstance(), o = us(s, e);
|
|
2483
2618
|
return o ? (t.params.actions = n.editOp(o.serialize()), t) : !1;
|
|
2484
2619
|
}
|
|
2485
|
-
function
|
|
2620
|
+
function gs(s) {
|
|
2486
2621
|
const { unitId: e, range: t, id: n, type: o, segmentId: r } = s, { startOffset: a, endOffset: i } = t, c = {
|
|
2487
|
-
id:
|
|
2622
|
+
id: G.id,
|
|
2488
2623
|
params: {
|
|
2489
2624
|
unitId: e,
|
|
2490
2625
|
actions: [],
|
|
2491
2626
|
textRanges: void 0
|
|
2492
2627
|
}
|
|
2493
|
-
},
|
|
2494
|
-
return a > 0 &&
|
|
2628
|
+
}, d = new $(), l = B.getInstance();
|
|
2629
|
+
return a > 0 && d.push({
|
|
2495
2630
|
t: C.RETAIN,
|
|
2496
2631
|
len: a,
|
|
2497
2632
|
segmentId: r
|
|
2498
|
-
}),
|
|
2633
|
+
}), d.push({
|
|
2499
2634
|
t: C.RETAIN,
|
|
2500
2635
|
body: {
|
|
2501
2636
|
dataStream: "",
|
|
@@ -2508,19 +2643,19 @@ function ls(s) {
|
|
|
2508
2643
|
},
|
|
2509
2644
|
len: i - a,
|
|
2510
2645
|
segmentId: r
|
|
2511
|
-
}), c.params.actions =
|
|
2646
|
+
}), c.params.actions = l.editOp(d.serialize()), c;
|
|
2512
2647
|
}
|
|
2513
|
-
function
|
|
2514
|
-
const { segmentId: t, id: n, type: o } = e, r = s.get(
|
|
2648
|
+
function Bs(s, e) {
|
|
2649
|
+
const { segmentId: t, id: n, type: o } = e, r = s.get(w), a = s.get(U), i = r.getActiveRange();
|
|
2515
2650
|
if (!i)
|
|
2516
2651
|
return !1;
|
|
2517
|
-
const c = a.getCurrentUnitForType(
|
|
2652
|
+
const c = a.getCurrentUnitForType(J.UNIVER_DOC);
|
|
2518
2653
|
if (!c)
|
|
2519
2654
|
return !1;
|
|
2520
|
-
const
|
|
2521
|
-
return
|
|
2655
|
+
const d = c.getBody(), l = c.getUnitId();
|
|
2656
|
+
return d ? gs(
|
|
2522
2657
|
{
|
|
2523
|
-
unitId:
|
|
2658
|
+
unitId: l,
|
|
2524
2659
|
range: {
|
|
2525
2660
|
startOffset: i.startOffset,
|
|
2526
2661
|
endOffset: i.endOffset,
|
|
@@ -2532,64 +2667,64 @@ function bs(s, e) {
|
|
|
2532
2667
|
}
|
|
2533
2668
|
) : !1;
|
|
2534
2669
|
}
|
|
2535
|
-
function
|
|
2536
|
-
var
|
|
2537
|
-
const { unitId: t, id: n, segmentId: o } = e, a = s.get(
|
|
2670
|
+
function Ls(s, e) {
|
|
2671
|
+
var I, h;
|
|
2672
|
+
const { unitId: t, id: n, segmentId: o } = e, a = s.get(U).getUnit(t), i = a == null ? void 0 : a.getBody();
|
|
2538
2673
|
if (!a || !i)
|
|
2539
2674
|
return !1;
|
|
2540
|
-
const c = (
|
|
2675
|
+
const c = (h = (I = a.getBody()) == null ? void 0 : I.customDecorations) == null ? void 0 : h.filter((m) => m.id === n);
|
|
2541
2676
|
if (!(c != null && c.length))
|
|
2542
2677
|
return !1;
|
|
2543
|
-
const
|
|
2544
|
-
var
|
|
2545
|
-
const p =
|
|
2546
|
-
return p.customDecorations = (
|
|
2678
|
+
const d = c.map((m) => Tt(i, m.startIndex, m.endIndex + 1)), l = d.map((m) => {
|
|
2679
|
+
var v;
|
|
2680
|
+
const p = q.deepClone(m);
|
|
2681
|
+
return p.customDecorations = (v = p.customDecorations) == null ? void 0 : v.filter((x) => x.id !== n), p;
|
|
2547
2682
|
}), g = {
|
|
2548
|
-
id:
|
|
2683
|
+
id: G.id,
|
|
2549
2684
|
params: {
|
|
2550
2685
|
unitId: t,
|
|
2551
2686
|
actions: [],
|
|
2552
2687
|
textRanges: void 0
|
|
2553
2688
|
}
|
|
2554
|
-
}, u = new
|
|
2689
|
+
}, u = new $(), S = B.getInstance();
|
|
2555
2690
|
let f = 0;
|
|
2556
|
-
return c.forEach((
|
|
2557
|
-
const
|
|
2558
|
-
|
|
2691
|
+
return c.forEach((m, p) => {
|
|
2692
|
+
const v = l[p], x = d[p];
|
|
2693
|
+
m.startIndex !== f && u.push({
|
|
2559
2694
|
t: C.RETAIN,
|
|
2560
|
-
len:
|
|
2695
|
+
len: m.startIndex - f,
|
|
2561
2696
|
segmentId: o
|
|
2562
|
-
}), f =
|
|
2697
|
+
}), f = m.startIndex, u.push({
|
|
2563
2698
|
t: C.RETAIN,
|
|
2564
|
-
len:
|
|
2699
|
+
len: m.endIndex - m.startIndex + 1,
|
|
2565
2700
|
segmentId: o,
|
|
2566
|
-
body:
|
|
2567
|
-
oldBody:
|
|
2568
|
-
coverType:
|
|
2569
|
-
}), f = f + (
|
|
2570
|
-
}), g.params.actions =
|
|
2701
|
+
body: v,
|
|
2702
|
+
oldBody: x,
|
|
2703
|
+
coverType: Re.REPLACE
|
|
2704
|
+
}), f = f + (m.endIndex - m.startIndex + 1);
|
|
2705
|
+
}), g.params.actions = S.editOp(u.serialize()), g;
|
|
2571
2706
|
}
|
|
2572
|
-
const
|
|
2573
|
-
CUSTOM_RANGE:
|
|
2574
|
-
CUSTOM_DECORATION:
|
|
2707
|
+
const fs = Dt("CUSTOM_RANGE"), ms = Dt("CUSTOM_DECORATION"), Ue = {
|
|
2708
|
+
CUSTOM_RANGE: fs,
|
|
2709
|
+
CUSTOM_DECORATION: ms
|
|
2575
2710
|
};
|
|
2576
|
-
var
|
|
2577
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
2711
|
+
var hs = Object.defineProperty, ps = Object.getOwnPropertyDescriptor, Ss = (s, e, t, n) => {
|
|
2712
|
+
for (var o = n > 1 ? void 0 : n ? ps(e, t) : e, r = s.length - 1, a; r >= 0; r--)
|
|
2578
2713
|
(a = s[r]) && (o = (n ? a(e, t, o) : a(o)) || o);
|
|
2579
|
-
return n && o &&
|
|
2580
|
-
},
|
|
2581
|
-
let
|
|
2714
|
+
return n && o && hs(e, t, o), o;
|
|
2715
|
+
}, Is = (s, e) => (t, n) => e(t, n, s);
|
|
2716
|
+
let Be = class extends Ce {
|
|
2582
2717
|
constructor(e, t) {
|
|
2583
2718
|
super();
|
|
2584
|
-
|
|
2719
|
+
b(this, "_interceptorsByName", /* @__PURE__ */ new Map());
|
|
2585
2720
|
this._context = e, this._docSkeletonManagerService = t, this.disposeWithMe(this._docSkeletonManagerService.currentViewModel$.subscribe((n) => {
|
|
2586
2721
|
if (n) {
|
|
2587
2722
|
const o = n.getDataModel().getUnitId();
|
|
2588
|
-
if (o ===
|
|
2723
|
+
if (o === Mt || o === tn)
|
|
2589
2724
|
return;
|
|
2590
2725
|
this.interceptDocumentViewModel(n);
|
|
2591
2726
|
}
|
|
2592
|
-
})), this.disposeWithMe(this.intercept(
|
|
2727
|
+
})), this.disposeWithMe(this.intercept(Ue.CUSTOM_RANGE, {
|
|
2593
2728
|
priority: -1,
|
|
2594
2729
|
handler: (n, o, r) => r(n)
|
|
2595
2730
|
}));
|
|
@@ -2604,18 +2739,18 @@ let Ue = class extends xe {
|
|
|
2604
2739
|
var i, c;
|
|
2605
2740
|
return ((i = a.priority) != null ? i : 0) - ((c = r.priority) != null ? c : 0);
|
|
2606
2741
|
})
|
|
2607
|
-
), this.disposeWithMe(Nt(() =>
|
|
2742
|
+
), this.disposeWithMe(Nt(() => nn(this._interceptorsByName.get(n), t)));
|
|
2608
2743
|
}
|
|
2609
2744
|
fetchThroughInterceptors(e) {
|
|
2610
2745
|
const t = e, n = this._interceptorsByName.get(t);
|
|
2611
|
-
return
|
|
2746
|
+
return sn(n || []);
|
|
2612
2747
|
}
|
|
2613
2748
|
interceptDocumentViewModel(e) {
|
|
2614
|
-
const t = new
|
|
2749
|
+
const t = new on();
|
|
2615
2750
|
return t.add(e.registerCustomRangeInterceptor({
|
|
2616
2751
|
getCustomRange: (n) => {
|
|
2617
2752
|
var o;
|
|
2618
|
-
return this.fetchThroughInterceptors(
|
|
2753
|
+
return this.fetchThroughInterceptors(Ue.CUSTOM_RANGE)(
|
|
2619
2754
|
e.getCustomRangeRaw(n),
|
|
2620
2755
|
{
|
|
2621
2756
|
index: n,
|
|
@@ -2626,7 +2761,7 @@ let Ue = class extends xe {
|
|
|
2626
2761
|
},
|
|
2627
2762
|
getCustomDecoration: (n) => {
|
|
2628
2763
|
var o;
|
|
2629
|
-
return this.fetchThroughInterceptors(
|
|
2764
|
+
return this.fetchThroughInterceptors(Ue.CUSTOM_DECORATION)(
|
|
2630
2765
|
e.getCustomDecorationRaw(n),
|
|
2631
2766
|
{
|
|
2632
2767
|
index: n,
|
|
@@ -2638,77 +2773,80 @@ let Ue = class extends xe {
|
|
|
2638
2773
|
})), t;
|
|
2639
2774
|
}
|
|
2640
2775
|
};
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
],
|
|
2776
|
+
Be = Ss([
|
|
2777
|
+
xe(Oe.Starting, Be),
|
|
2778
|
+
Is(1, ee(W))
|
|
2779
|
+
], Be);
|
|
2645
2780
|
export {
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2781
|
+
ts as AlignCenterCommand,
|
|
2782
|
+
ss as AlignJustifyCommand,
|
|
2783
|
+
es as AlignLeftCommand,
|
|
2784
|
+
de as AlignOperationCommand,
|
|
2785
|
+
ns as AlignRightCommand,
|
|
2786
|
+
Nn as BreakLineCommand,
|
|
2787
|
+
Fn as BulletListCommand,
|
|
2788
|
+
kn as CoverContentCommand,
|
|
2654
2789
|
Bt as CutContentCommand,
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2790
|
+
ys as DOCS_COMPONENT_BACKGROUND_LAYER_INDEX,
|
|
2791
|
+
Es as DOCS_COMPONENT_DEFAULT_Z_INDEX,
|
|
2792
|
+
Ts as DOCS_COMPONENT_HEADER_LAYER_INDEX,
|
|
2793
|
+
Ms as DOCS_COMPONENT_MAIN_LAYER_INDEX,
|
|
2794
|
+
Te as DOCS_VIEW_KEY,
|
|
2795
|
+
Ue as DOC_INTERCEPTOR_POINT,
|
|
2796
|
+
se as DeleteCommand,
|
|
2797
|
+
Ve as DeleteCustomBlockCommand,
|
|
2798
|
+
Pn as DeleteLeftCommand,
|
|
2799
|
+
wn as DeleteRightCommand,
|
|
2800
|
+
os as DocCustomRangeService,
|
|
2801
|
+
Be as DocInterceptorService,
|
|
2802
|
+
W as DocSkeletonManagerService,
|
|
2803
|
+
_e as DocStateChangeManagerService,
|
|
2804
|
+
An as EditorInsertTextCommandId,
|
|
2669
2805
|
Ft as IMEInputCommand,
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2806
|
+
Ee as IMEInputManagerService,
|
|
2807
|
+
bs as InnerPasteCommand,
|
|
2808
|
+
ve as InsertCommand,
|
|
2809
|
+
ot as ListOperationCommand,
|
|
2810
|
+
We as MergeTwoParagraphCommand,
|
|
2811
|
+
Le as MoveCursorOperation,
|
|
2812
|
+
Fe as MoveSelectionOperation,
|
|
2813
|
+
As as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
|
|
2814
|
+
Gn as OrderListCommand,
|
|
2815
|
+
$n as ReplaceContentCommand,
|
|
2816
|
+
st as ResetInlineFormatTextBackgroundColorCommand,
|
|
2817
|
+
G as RichTextEditingMutation,
|
|
2818
|
+
Hn as SelectAllOperation,
|
|
2819
|
+
zn as SetDocZoomRatioCommand,
|
|
2820
|
+
me as SetDocZoomRatioOperation,
|
|
2821
|
+
Ye as SetInlineFormatBoldCommand,
|
|
2822
|
+
$t as SetInlineFormatCommand,
|
|
2823
|
+
et as SetInlineFormatFontFamilyCommand,
|
|
2824
|
+
Qe as SetInlineFormatFontSizeCommand,
|
|
2825
|
+
Ke as SetInlineFormatItalicCommand,
|
|
2826
|
+
Je as SetInlineFormatStrikethroughCommand,
|
|
2827
|
+
oe as SetInlineFormatSubscriptCommand,
|
|
2828
|
+
qe as SetInlineFormatSuperscriptCommand,
|
|
2829
|
+
nt as SetInlineFormatTextBackgroundColorCommand,
|
|
2830
|
+
tt as SetInlineFormatTextColorCommand,
|
|
2831
|
+
Ze as SetInlineFormatUnderlineCommand,
|
|
2832
|
+
Pt as SetTextSelectionsOperation,
|
|
2833
|
+
w as TextSelectionManagerService,
|
|
2698
2834
|
yt as UniverDocsPlugin,
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2835
|
+
Ut as UpdateCommand,
|
|
2836
|
+
In as VIEWPORT_KEY,
|
|
2837
|
+
Bs as addCustomDecorationBySelectionFactory,
|
|
2838
|
+
gs as addCustomDecorationFactory,
|
|
2839
|
+
ws as addCustomRangeBySelectionFactory,
|
|
2840
|
+
Ps as addCustomRangeFactory,
|
|
2841
|
+
Ls as deleteCustomDecorationFactory,
|
|
2842
|
+
Us as deleteCustomRangeFactory,
|
|
2843
|
+
He as getDeleteSelection,
|
|
2844
|
+
_n as getDocObject,
|
|
2845
|
+
Ds as getDocObjectById,
|
|
2846
|
+
Me as getInsertSelection,
|
|
2847
|
+
Xe as getRetainAndDeleteFromReplace,
|
|
2848
|
+
j as getRichTextEditPath,
|
|
2849
|
+
Cs as getSelectionText,
|
|
2850
|
+
Ns as neoGetDocObject,
|
|
2851
|
+
Q as serializeTextRange
|
|
2714
2852
|
};
|