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