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