@univerjs/docs 0.2.3 → 0.2.4

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