@univerjs/docs 0.2.1 → 0.2.3

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