@univerjs/docs 0.1.12 → 0.1.13

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,20 +1,20 @@
1
- var yt = Object.defineProperty;
2
- var Ot = (o, e, t) => e in o ? yt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var y = (o, e, t) => (Ot(o, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { UniverInstanceType as W, CommandType as v, RxDisposable as ge, ICommandService as I, TextXActionType as x, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as ut, IUniverInstanceService as E, IUndoRedoService as Te, UndoCommandId as Ye, RedoCommandId as We, TextX as b, DataStreamTreeTokenType as xe, Tools as Q, LocaleService as Tt, MemoryCursor as se, getDocsUpdateBody as Et, UpdateDocsAttributeType as Ee, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Dt, BooleanNumber as z, BaselineOffset as G, PRESET_LIST_TYPE as At, PresetListType as mt, HorizontalAlign as re, OnLifecycle as De, LifecycleStages as Ae, Disposable as Ne, Direction as N, Plugin as Nt } from "@univerjs/core";
5
- import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as Pt, ITextSelectionRenderManager as fe, DocumentViewModel as bt, DocumentSkeleton as Ut, hasListGlyph as wt, isIndentByGlyph as Lt, isFirstGlyph as Bt, getParagraphByGlyph as Ft, getCharSpaceApply as $t, getNumberUnitValue as Me, RANGE_DIRECTION as Ze, NodePositionConvertToCursor as Ke, IRenderManagerService as gt, TextSelectionRenderManager as Vt } from "@univerjs/engine-render";
6
- import { BehaviorSubject as ee, takeUntil as te } from "rxjs";
7
- import { Inject as V, Injector as kt } from "@wendellhu/redi";
8
- var Pe = /* @__PURE__ */ ((o) => (o.MAIN = "__Document_Render_Main__", o.BACKGROUND = "__Document_Render_Background__", o))(Pe || {}), zt = /* @__PURE__ */ ((o) => (o.VIEW_MAIN = "viewMain", o.VIEW_TOP = "viewTop", o.VIEW_LEFT = "viewLeft", o.VIEW_LEFT_TOP = "viewLeftTop", o))(zt || {});
9
- const Gn = 0, jn = 2, Hn = 4, Xn = 10, Yn = "normalTextSelectionPluginName";
10
- function Gt(o, e) {
11
- const t = o.getCurrentUnitForType(W.UNIVER_DOC);
1
+ var Tt = Object.defineProperty;
2
+ var Et = (s, e, t) => e in s ? Tt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var y = (s, e, t) => (Et(s, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { UniverInstanceType as Z, CommandType as I, RxDisposable as fe, ICommandService as v, TextXActionType as x, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as mt, IUniverInstanceService as E, IUndoRedoService as Ee, UndoCommandId as Ze, RedoCommandId as Je, JSONX as b, TextX as F, DataStreamTreeTokenType as ye, Tools as ee, LocaleService as Dt, MemoryCursor as re, getDocsUpdateBody as At, UpdateDocsAttributeType as De, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Nt, BooleanNumber as j, BaselineOffset as G, PRESET_LIST_TYPE as Pt, PresetListType as ft, HorizontalAlign as ie, OnLifecycle as Ae, LifecycleStages as Ne, Disposable as Pe, Direction as P, Plugin as bt } from "@univerjs/core";
5
+ import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as Ut, ITextSelectionRenderManager as he, DocumentViewModel as wt, DocumentSkeleton as Lt, hasListGlyph as Bt, isIndentByGlyph as Ft, isFirstGlyph as $t, getParagraphByGlyph as Vt, getCharSpaceApply as kt, getNumberUnitValue as Ce, RANGE_DIRECTION as Ke, NodePositionConvertToCursor as qe, IRenderManagerService as ht, TextSelectionRenderManager as zt } from "@univerjs/engine-render";
6
+ import { BehaviorSubject as te, takeUntil as ne } from "rxjs";
7
+ import { Inject as k, Injector as jt } from "@wendellhu/redi";
8
+ var be = /* @__PURE__ */ ((s) => (s.MAIN = "__Document_Render_Main__", s.BACKGROUND = "__Document_Render_Background__", s))(be || {}), Gt = /* @__PURE__ */ ((s) => (s.VIEW_MAIN = "viewMain", s.VIEW_TOP = "viewTop", s.VIEW_LEFT = "viewLeft", s.VIEW_LEFT_TOP = "viewLeftTop", s))(Gt || {});
9
+ const Xn = 0, Hn = 2, Yn = 4, Wn = 10, Zn = "normalTextSelectionPluginName";
10
+ function Xt(s, e) {
11
+ const t = s.getCurrentUnitForType(Z.UNIVER_DOC);
12
12
  if (!t)
13
13
  return null;
14
- const n = t.getUnitId(), s = e.getRenderById(n);
15
- if (s == null)
14
+ const n = t.getUnitId(), o = e.getRenderById(n);
15
+ if (o == null)
16
16
  return;
17
- const { mainComponent: r, scene: i, engine: a, components: c } = s, d = r, l = c.get(Pe.BACKGROUND);
17
+ const { mainComponent: r, scene: i, engine: a, components: c } = o, d = r, l = c.get(be.BACKGROUND);
18
18
  return {
19
19
  document: d,
20
20
  docBackground: l,
@@ -22,42 +22,42 @@ function Gt(o, e) {
22
22
  engine: a
23
23
  };
24
24
  }
25
- function Wn(o, e) {
26
- const t = e.getRenderById(o);
25
+ function Jn(s, e) {
26
+ const t = e.getRenderById(s);
27
27
  if (t == null)
28
28
  return;
29
- const { mainComponent: n, scene: s, engine: r, components: i } = t, a = n, c = i.get(Pe.BACKGROUND);
29
+ const { mainComponent: n, scene: o, engine: r, components: i } = t, a = n, c = i.get(be.BACKGROUND);
30
30
  return {
31
31
  document: a,
32
32
  docBackground: c,
33
- scene: s,
33
+ scene: o,
34
34
  engine: r
35
35
  };
36
36
  }
37
- const ft = {
37
+ const pt = {
38
38
  id: "doc.operation.set-selections",
39
- type: v.OPERATION,
40
- handler: (o, e) => !0
39
+ type: I.OPERATION,
40
+ handler: (s, e) => !0
41
41
  };
42
- var jt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Xt = (o, e, t, n) => {
43
- for (var s = n > 1 ? void 0 : n ? Ht(e, t) : e, r = o.length - 1, i; r >= 0; r--)
44
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
45
- return n && s && jt(e, t, s), s;
46
- }, Je = (o, e) => (t, n) => e(t, n, o);
47
- function Z(o) {
48
- const { startOffset: e, endOffset: t, collapsed: n } = o, s = {
42
+ var Ht = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Wt = (s, e, t, n) => {
43
+ for (var o = n > 1 ? void 0 : n ? Yt(e, t) : e, r = s.length - 1, i; r >= 0; r--)
44
+ (i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
45
+ return n && o && Ht(e, t, o), o;
46
+ }, Qe = (s, e) => (t, n) => e(t, n, s);
47
+ function J(s) {
48
+ const { startOffset: e, endOffset: t, collapsed: n } = s, o = {
49
49
  startOffset: e,
50
50
  endOffset: t,
51
51
  collapsed: n
52
52
  };
53
- return typeof o.isActive == "function" && (s.isActive = o.isActive()), s;
53
+ return typeof s.isActive == "function" && (o.isActive = s.isActive()), o;
54
54
  }
55
- let T = class extends ge {
55
+ let T = class extends fe {
56
56
  constructor(e, t) {
57
57
  super();
58
58
  y(this, "_currentSelection", null);
59
59
  y(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
60
- y(this, "_textSelection$", new ee(null));
60
+ y(this, "_textSelection$", new te(null));
61
61
  y(this, "textSelection$", this._textSelection$.asObservable());
62
62
  this._textSelectionRenderManager = e, this._commandService = t, this._syncSelectionFromRenderService();
63
63
  }
@@ -85,11 +85,18 @@ let T = class extends ge {
85
85
  var e;
86
86
  return (e = this._getTextRanges(this._currentSelection)) == null ? void 0 : e.textRanges;
87
87
  }
88
+ getActiveTextRange() {
89
+ const e = this._getTextRanges(this._currentSelection);
90
+ if (e == null)
91
+ return;
92
+ const { textRanges: t } = e;
93
+ return t.find((n) => n.isActive());
94
+ }
88
95
  getActiveRange() {
89
96
  const e = this._getTextRanges(this._currentSelection);
90
97
  if (e == null)
91
98
  return;
92
- const { textRanges: t, segmentId: n, style: s } = e, r = t.find((m) => m.isActive());
99
+ const { textRanges: t, segmentId: n, style: o } = e, r = t.find((g) => g.isActive());
93
100
  if (r == null)
94
101
  return null;
95
102
  const { startOffset: i, endOffset: a, collapsed: c, startNodePosition: d, endNodePosition: l, direction: u } = r;
@@ -101,7 +108,7 @@ let T = class extends ge {
101
108
  endNodePosition: l,
102
109
  direction: u,
103
110
  segmentId: n,
104
- style: s
111
+ style: o
105
112
  };
106
113
  }
107
114
  // **Only used in test case** because this does not go through the render layer.
@@ -111,7 +118,7 @@ let T = class extends ge {
111
118
  textRanges: e,
112
119
  segmentId: "",
113
120
  isEditing: t,
114
- style: Pt
121
+ style: Ut
115
122
  // mock style.
116
123
  });
117
124
  }
@@ -120,7 +127,7 @@ let T = class extends ge {
120
127
  }
121
128
  // All textRanges should be synchronized from the render layer.
122
129
  _syncSelectionFromRenderService() {
123
- this._textSelectionRenderManager.textSelectionInner$.pipe(te(this.dispose$)).subscribe((e) => {
130
+ this._textSelectionRenderManager.textSelectionInner$.pipe(ne(this.dispose$)).subscribe((e) => {
124
131
  e != null && this._replaceTextRangesWithNoRefresh(e);
125
132
  });
126
133
  }
@@ -132,44 +139,44 @@ let T = class extends ge {
132
139
  ...e
133
140
  };
134
141
  this._replaceByParam(t), this._textSelection$.next(t);
135
- const { unitId: n, subUnitId: s, segmentId: r, style: i, textRanges: a, isEditing: c } = t;
136
- this._commandService.executeCommand(ft.id, {
142
+ const { unitId: n, subUnitId: o, segmentId: r, style: i, textRanges: a, isEditing: c } = t;
143
+ this._commandService.executeCommand(pt.id, {
137
144
  unitId: n,
138
- subUnitId: s,
145
+ subUnitId: o,
139
146
  segmentId: r,
140
147
  style: i,
141
148
  isEditing: c,
142
- ranges: a.map(Z)
149
+ ranges: a.map(J)
143
150
  });
144
151
  }
145
152
  _getTextRanges(e) {
146
- var s;
153
+ var o;
147
154
  if (e == null)
148
155
  return;
149
156
  const { unitId: t, subUnitId: n = "" } = e;
150
- return (s = this._textSelectionInfo.get(t)) == null ? void 0 : s.get(n);
157
+ return (o = this._textSelectionInfo.get(t)) == null ? void 0 : o.get(n);
151
158
  }
152
159
  _refresh(e) {
153
160
  const t = this._getTextRanges(e);
154
- this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(Z));
161
+ this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(J));
155
162
  }
156
163
  _replaceByParam(e) {
157
- const { unitId: t, subUnitId: n, style: s, segmentId: r, textRanges: i, isEditing: a } = e;
158
- this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map()), this._textSelectionInfo.get(t).set(n, { textRanges: i, style: s, segmentId: r, isEditing: a });
164
+ const { unitId: t, subUnitId: n, style: o, segmentId: r, textRanges: i, isEditing: a } = e;
165
+ this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map()), this._textSelectionInfo.get(t).set(n, { textRanges: i, style: o, segmentId: r, isEditing: a });
159
166
  }
160
167
  _addByParam(e) {
161
- const { unitId: t, subUnitId: n, textRanges: s, style: r, segmentId: i, isEditing: a } = e;
168
+ const { unitId: t, subUnitId: n, textRanges: o, style: r, segmentId: i, isEditing: a } = e;
162
169
  this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map());
163
170
  const c = this._textSelectionInfo.get(t);
164
- c.has(n) ? c.get(n).textRanges.push(...s) : c.set(n, { textRanges: s, style: r, segmentId: i, isEditing: a });
171
+ c.has(n) ? c.get(n).textRanges.push(...o) : c.set(n, { textRanges: o, style: r, segmentId: i, isEditing: a });
165
172
  }
166
173
  };
167
- T = Xt([
168
- Je(0, fe),
169
- Je(1, I)
174
+ T = Wt([
175
+ Qe(0, he),
176
+ Qe(1, v)
170
177
  ], T);
171
- function be(o, e = "", t = 0) {
172
- const { startOffset: n, endOffset: s } = o, r = [], i = n - t, a = s - t;
178
+ function Ue(s, e = "", t = 0) {
179
+ const { startOffset: n, endOffset: o } = s, r = [], i = n - t, a = o - t;
173
180
  return i > 0 && r.push({
174
181
  t: x.RETAIN,
175
182
  len: i,
@@ -181,16 +188,16 @@ function be(o, e = "", t = 0) {
181
188
  segmentId: e
182
189
  }), r;
183
190
  }
184
- var Yt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, Zt = (o, e, t, n) => {
185
- for (var s = n > 1 ? void 0 : n ? Wt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
186
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
187
- return n && s && Yt(e, t, s), s;
188
- }, Kt = (o, e) => (t, n) => e(t, n, o);
189
- let ne = class extends ge {
191
+ var Zt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, Kt = (s, e, t, n) => {
192
+ for (var o = n > 1 ? void 0 : n ? Jt(e, t) : e, r = s.length - 1, i; r >= 0; r--)
193
+ (i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
194
+ return n && o && Zt(e, t, o), o;
195
+ }, qt = (s, e) => (t, n) => e(t, n, s);
196
+ let se = class extends fe {
190
197
  constructor(e) {
191
198
  super();
192
199
  y(this, "_docViewModelMap", /* @__PURE__ */ new Map());
193
- y(this, "_currentDocViewModel$", new ee(null));
200
+ y(this, "_currentDocViewModel$", new te(null));
194
201
  y(this, "currentDocViewModel$", this._currentDocViewModel$.asObservable());
195
202
  this._univerInstanceService = e, this._initialize();
196
203
  }
@@ -201,11 +208,11 @@ let ne = class extends ge {
201
208
  this._currentDocViewModel$.complete(), this._docViewModelMap.clear();
202
209
  }
203
210
  _init() {
204
- this._univerInstanceService.getCurrentTypeOfUnit$(W.UNIVER_DOC).pipe(te(this.dispose$)).subscribe((e) => {
211
+ this._univerInstanceService.getCurrentTypeOfUnit$(Z.UNIVER_DOC).pipe(ne(this.dispose$)).subscribe((e) => {
205
212
  this._create(e);
206
- }), this._univerInstanceService.getAllUnitsForType(W.UNIVER_DOC).forEach((e) => {
213
+ }), this._univerInstanceService.getAllUnitsForType(Z.UNIVER_DOC).forEach((e) => {
207
214
  this._create(e);
208
- }), this._univerInstanceService.getTypeOfUnitDisposed$(W.UNIVER_DOC).pipe(te(this.dispose$)).subscribe((e) => {
215
+ }), this._univerInstanceService.getTypeOfUnitDisposed$(Z.UNIVER_DOC).pipe(ne(this.dispose$)).subscribe((e) => {
209
216
  this._docViewModelMap.delete(e.getUnitId());
210
217
  });
211
218
  }
@@ -229,38 +236,38 @@ let ne = class extends ge {
229
236
  throw new Error(`Document data model with id ${e} not found when build view model.`);
230
237
  if (t.getBody() != null) {
231
238
  if (!this._docViewModelMap.has(e)) {
232
- const s = this._buildDocViewModel(t);
239
+ const o = this._buildDocViewModel(t);
233
240
  this._docViewModelMap.set(e, {
234
241
  unitId: e,
235
- docViewModel: s
242
+ docViewModel: o
236
243
  });
237
244
  }
238
- if (e === ut) {
239
- const s = (n = this._docViewModelMap.get(e)) == null ? void 0 : n.docViewModel;
240
- if (s == null)
245
+ if (e === mt) {
246
+ const o = (n = this._docViewModelMap.get(e)) == null ? void 0 : n.docViewModel;
247
+ if (o == null)
241
248
  return;
242
- s.reset(t);
249
+ o.reset(t);
243
250
  }
244
251
  this._currentDocViewModel$.next(this._docViewModelMap.get(e));
245
252
  }
246
253
  }
247
254
  _buildDocViewModel(e) {
248
- return new bt(e);
255
+ return new wt(e);
249
256
  }
250
257
  };
251
- ne = Zt([
252
- Kt(0, E)
253
- ], ne);
254
- var Jt = Object.defineProperty, qt = Object.getOwnPropertyDescriptor, Qt = (o, e, t, n) => {
255
- for (var s = n > 1 ? void 0 : n ? qt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
256
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
257
- return n && s && Jt(e, t, s), s;
258
- }, Ce = (o, e) => (t, n) => e(t, n, o);
259
- const en = 300;
260
- let me = class extends ge {
258
+ se = Kt([
259
+ qt(0, E)
260
+ ], se);
261
+ var Qt = Object.defineProperty, en = Object.getOwnPropertyDescriptor, tn = (s, e, t, n) => {
262
+ for (var o = n > 1 ? void 0 : n ? en(e, t) : e, r = s.length - 1, i; r >= 0; r--)
263
+ (i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
264
+ return n && o && Qt(e, t, o), o;
265
+ }, Re = (s, e) => (t, n) => e(t, n, s);
266
+ const nn = 300;
267
+ let me = class extends fe {
261
268
  constructor(e, t, n) {
262
269
  super();
263
- y(this, "_docStateChange$", new ee(null));
270
+ y(this, "_docStateChange$", new te(null));
264
271
  y(this, "docStateChange$", this._docStateChange$.asObservable());
265
272
  y(this, "_stateCache", /* @__PURE__ */ new Map());
266
273
  y(this, "_timer", null);
@@ -273,7 +280,7 @@ let me = class extends ge {
273
280
  _initialize() {
274
281
  this.disposeWithMe(
275
282
  this._commandService.beforeCommandExecuted((e) => {
276
- if (e.id === Ye || e.id === We) {
283
+ if (e.id === Ze || e.id === Je) {
277
284
  const t = this._univerInstanceService.getCurrentUniverDocInstance();
278
285
  if (t == null)
279
286
  return;
@@ -284,30 +291,30 @@ let me = class extends ge {
284
291
  );
285
292
  }
286
293
  _cacheChangeState(e) {
287
- const { trigger: t, unitId: n, noHistory: s } = e;
288
- if (!(t === We || t === Ye || s)) {
294
+ const { trigger: t, unitId: n, noHistory: o } = e;
295
+ if (!(t === Je || t === Ze || o)) {
289
296
  if (this._stateCache.has(n)) {
290
297
  const r = this._stateCache.get(n);
291
298
  r == null || r.push(e);
292
299
  } else
293
300
  this._stateCache.set(n, [e]);
294
- t === pe.id || t === Se.id ? (this._timer && clearTimeout(this._timer), this._timer = setTimeout(() => {
301
+ t === Se.id || t === _e.id ? (this._timer && clearTimeout(this._timer), this._timer = setTimeout(() => {
295
302
  this._pushHistory(n);
296
- }, en)) : this._pushHistory(n);
303
+ }, nn)) : this._pushHistory(n);
297
304
  }
298
305
  }
299
306
  _pushHistory(e) {
300
307
  const t = this._undoRedoService, n = this._stateCache.get(e);
301
308
  if (!Array.isArray(n) || n.length === 0)
302
309
  return;
303
- const s = n.length, r = n[0].commandId, i = n[0], a = n[s - 1], c = {
310
+ const o = n.length, r = n[0].commandId, i = n[0], a = n[o - 1], c = {
304
311
  unitId: e,
305
- actions: n.reduce((l, u) => b.compose(l, u.redoState.actions), []),
312
+ actions: n.reduce((l, u) => b.compose(l, u.redoState.actions), null),
306
313
  textRanges: a.redoState.textRanges
307
314
  }, d = {
308
315
  unitId: e,
309
316
  // Always need to put undoParams after redoParams, because `reverse` will change the `cacheStates` order.
310
- actions: n.reverse().reduce((l, u) => b.compose(l, u.undoState.actions), []),
317
+ actions: n.reverse().reduce((l, u) => b.compose(l, u.undoState.actions), null),
311
318
  textRanges: i.undoState.textRanges
312
319
  };
313
320
  t.pushUndoRedo({
@@ -317,12 +324,12 @@ let me = class extends ge {
317
324
  }), n.length = 0;
318
325
  }
319
326
  };
320
- me = Qt([
321
- Ce(0, V(Te)),
322
- Ce(1, I),
323
- Ce(2, E)
327
+ me = tn([
328
+ Re(0, k(Ee)),
329
+ Re(1, v),
330
+ Re(2, E)
324
331
  ], me);
325
- class he {
332
+ class pe {
326
333
  constructor() {
327
334
  y(this, "_previousActiveRange", null);
328
335
  y(this, "_undoMutationParamsCache", []);
@@ -354,13 +361,13 @@ class he {
354
361
  return null;
355
362
  const { unitId: e } = this._undoMutationParamsCache[0], t = {
356
363
  unitId: e,
357
- actions: this._undoMutationParamsCache.reverse().reduce((s, r) => b.compose(s, r.actions), []),
364
+ actions: this._undoMutationParamsCache.reverse().reduce((o, r) => b.compose(o, r.actions), null),
358
365
  textRanges: []
359
366
  // Add empty array, will never use, just fix type error
360
367
  };
361
368
  return { redoMutationParams: {
362
369
  unitId: e,
363
- actions: this._redoMutationParamsCache.reduce((s, r) => b.compose(s, r.actions), []),
370
+ actions: this._redoMutationParamsCache.reduce((o, r) => b.compose(o, r.actions), null),
364
371
  textRanges: []
365
372
  // Add empty array, will never use, just fix type error
366
373
  }, undoMutationParams: t, previousActiveRange: this._previousActiveRange };
@@ -369,191 +376,195 @@ class he {
369
376
  this._undoMutationParamsCache = [], this._redoMutationParamsCache = [], this._previousActiveRange = null;
370
377
  }
371
378
  }
372
- const qe = "doc.mutation.rich-text-editing", L = {
373
- id: qe,
374
- type: v.MUTATION,
379
+ const et = "doc.mutation.rich-text-editing", B = {
380
+ id: et,
381
+ type: I.MUTATION,
375
382
  // eslint-disable-next-line max-lines-per-function
376
- handler: (o, e) => {
377
- var B;
383
+ handler: (s, e) => {
384
+ var L;
378
385
  const {
379
386
  unitId: t,
380
- actions: n,
381
- textRanges: s,
382
- prevTextRanges: r,
383
- trigger: i,
384
- noHistory: a,
385
- isCompositionEnd: c,
386
- noNeedSetTextRange: d
387
- } = e, u = o.get(E).getUniverDocInstance(t), g = o.get(ne).getViewModel(t), p = o.get(T), f = ((B = p.getSelections()) != null ? B : []).map(Z), S = o.get(me), _ = o.get(he);
388
- if (u == null || g == null)
387
+ segmentId: n = "",
388
+ actions: o,
389
+ textRanges: r,
390
+ prevTextRanges: i,
391
+ trigger: a,
392
+ noHistory: c,
393
+ isCompositionEnd: d,
394
+ noNeedSetTextRange: l
395
+ } = e, g = s.get(E).getUniverDocInstance(t), S = s.get(se).getViewModel(t), f = s.get(T), _ = ((L = f.getSelections()) != null ? L : []).map(J), p = s.get(me), R = s.get(pe);
396
+ if (g == null || S == null)
389
397
  throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${t}`);
390
- const R = !!u.getSnapshot().disabled;
391
- if (n.length === 0 || R)
398
+ const C = !!g.getSnapshot().disabled;
399
+ if (b.isNoop(o) || o && o.length === 0 || C)
392
400
  return {
393
401
  unitId: t,
394
402
  actions: [],
395
- textRanges: f
403
+ textRanges: _
396
404
  };
397
- const M = u.apply(n), { segmentId: C } = n[0], D = u.getSelfOrHeaderFooterModel(C);
398
- g.getSelfOrHeaderFooterViewModel(C).reset(D), !d && s && i != null && queueMicrotask(() => {
399
- p.replaceTextRanges(s);
405
+ const M = b.invertWithDoc(o, g.getSnapshot());
406
+ g.apply(o);
407
+ const A = g.getSelfOrHeaderFooterModel(n);
408
+ S.getSelfOrHeaderFooterViewModel(n).reset(A), !l && r && a != null && queueMicrotask(() => {
409
+ f.replaceTextRanges(r);
400
410
  });
401
- const P = {
402
- commandId: qe,
411
+ const N = {
412
+ commandId: et,
403
413
  unitId: t,
404
- trigger: i,
405
- noHistory: a,
414
+ segmentId: n,
415
+ trigger: a,
416
+ noHistory: c,
406
417
  redoState: {
407
- actions: n,
408
- textRanges: s
418
+ actions: o,
419
+ textRanges: r
409
420
  },
410
421
  undoState: {
411
422
  actions: M,
412
- textRanges: r != null ? r : f
423
+ textRanges: i != null ? i : _
413
424
  }
414
425
  };
415
- if (c) {
416
- const O = _.fetchComposedUndoRedoMutationParams();
426
+ if (d) {
427
+ const O = R.fetchComposedUndoRedoMutationParams();
417
428
  if (O == null)
418
429
  throw new Error("historyParams is null in RichTextEditingMutation");
419
- const { undoMutationParams: U, redoMutationParams: w, previousActiveRange: X } = O;
420
- P.redoState.actions = w.actions, P.undoState.actions = U.actions, P.undoState.textRanges = [X];
430
+ const { undoMutationParams: U, redoMutationParams: w, previousActiveRange: Y } = O;
431
+ N.redoState.actions = w.actions, N.undoState.actions = U.actions, N.undoState.textRanges = [Y];
421
432
  }
422
- return S.setChangeState(P), {
433
+ return p.setChangeState(N), {
423
434
  unitId: t,
424
435
  actions: M,
425
- textRanges: f
436
+ textRanges: _
426
437
  };
427
438
  }
428
- }, pe = {
439
+ }, Se = {
429
440
  id: "doc.command.insert-text",
430
- type: v.COMMAND,
431
- handler: async (o, e) => {
432
- const t = o.get(I), { range: n, segmentId: s, body: r, unitId: i, textRanges: a } = e, { startOffset: c, collapsed: d } = n, l = {
433
- id: L.id,
441
+ type: I.COMMAND,
442
+ handler: async (s, e) => {
443
+ const t = s.get(v), { range: n, segmentId: o, body: r, unitId: i, textRanges: a } = e, { startOffset: c, collapsed: d } = n, l = {
444
+ id: B.id,
434
445
  params: {
435
446
  unitId: i,
436
447
  actions: [],
437
448
  textRanges: a
438
449
  }
439
- }, u = new b();
450
+ }, u = new F(), g = b.getInstance();
440
451
  return d ? c > 0 && u.push({
441
452
  t: x.RETAIN,
442
453
  len: c,
443
- segmentId: s
444
- }) : u.push(...be(n, s)), u.push({
454
+ segmentId: o
455
+ }) : u.push(...Ue(n, o)), u.push({
445
456
  t: x.INSERT,
446
457
  body: r,
447
458
  len: r.dataStream.length,
448
459
  line: 0,
449
- segmentId: s
450
- }), l.params.actions = u.serialize(), !!t.syncExecuteCommand(l.id, l.params);
460
+ segmentId: o
461
+ }), l.params.actions = g.editOp(u.serialize()), !!t.syncExecuteCommand(l.id, l.params);
451
462
  }
452
463
  };
453
- var j = /* @__PURE__ */ ((o) => (o[o.LEFT = 0] = "LEFT", o[o.RIGHT = 1] = "RIGHT", o))(j || {});
454
- const Se = {
464
+ var X = /* @__PURE__ */ ((s) => (s[s.LEFT = 0] = "LEFT", s[s.RIGHT = 1] = "RIGHT", s))(X || {});
465
+ const _e = {
455
466
  id: "doc.command.delete-text",
456
- type: v.COMMAND,
457
- handler: async (o, e) => {
458
- const t = o.get(I), { range: n, segmentId: s, unitId: r, direction: i, textRanges: a, len: c = 1 } = e, { startOffset: d } = n, l = {
459
- id: L.id,
467
+ type: I.COMMAND,
468
+ handler: async (s, e) => {
469
+ const t = s.get(v), { range: n, segmentId: o, unitId: r, direction: i, textRanges: a, len: c = 1 } = e, { startOffset: d } = n, l = {
470
+ id: B.id,
460
471
  params: {
461
472
  unitId: r,
462
473
  actions: [],
463
474
  textRanges: a
464
475
  }
465
- }, u = new b();
476
+ }, u = new F(), g = b.getInstance();
466
477
  return d > 0 && u.push({
467
478
  t: x.RETAIN,
468
479
  len: i === 0 ? d - c : d,
469
- segmentId: s
480
+ segmentId: o
470
481
  }), u.push({
471
482
  t: x.DELETE,
472
483
  len: c,
473
484
  line: 0,
474
- segmentId: s
475
- }), l.params.actions = u.serialize(), !!t.syncExecuteCommand(l.id, l.params);
485
+ segmentId: o
486
+ }), l.params.actions = g.editOp(u.serialize()), !!t.syncExecuteCommand(l.id, l.params);
476
487
  }
477
- }, ht = {
488
+ }, St = {
478
489
  id: "doc.command.update-text",
479
- type: v.COMMAND,
480
- handler: async (o, e) => {
481
- const { range: t, segmentId: n, updateBody: s, coverType: r, unitId: i, textRanges: a } = e, c = o.get(I), d = {
482
- id: L.id,
490
+ type: I.COMMAND,
491
+ handler: async (s, e) => {
492
+ const { range: t, segmentId: n, updateBody: o, coverType: r, unitId: i, textRanges: a } = e, c = s.get(v), d = {
493
+ id: B.id,
483
494
  params: {
484
495
  unitId: i,
485
496
  actions: [],
486
497
  textRanges: a
487
498
  }
488
- }, l = new b(), { startOffset: u, endOffset: m } = t;
499
+ }, l = new F(), u = b.getInstance(), { startOffset: g, endOffset: m } = t;
489
500
  return l.push({
490
501
  t: x.RETAIN,
491
- len: u,
502
+ len: g,
492
503
  segmentId: n
493
504
  }), l.push({
494
505
  t: x.RETAIN,
495
- body: s,
496
- len: m - u,
506
+ body: o,
507
+ len: m - g,
497
508
  segmentId: n,
498
509
  coverType: r
499
- }), d.params.actions = l.serialize(), !!c.syncExecuteCommand(d.id, d.params);
510
+ }), d.params.actions = u.editOp(l.serialize()), !!c.syncExecuteCommand(d.id, d.params);
500
511
  }
501
512
  };
502
- function tn(o, e) {
513
+ function sn(s, e) {
503
514
  const t = [];
504
- for (let n = 0, s = o.length; n < s; n++)
505
- o[n] === xe.PARAGRAPH && t.push({
515
+ for (let n = 0, o = s.length; n < o; n++)
516
+ s[n] === ye.PARAGRAPH && t.push({
506
517
  startIndex: n
507
518
  });
508
519
  if (e)
509
520
  for (const n of t)
510
- e.bullet && (n.bullet = Q.deepClone(e.bullet)), e.paragraphStyle && (n.paragraphStyle = Q.deepClone(e.paragraphStyle));
521
+ e.bullet && (n.bullet = ee.deepClone(e.bullet)), e.paragraphStyle && (n.paragraphStyle = ee.deepClone(e.paragraphStyle));
511
522
  return t;
512
523
  }
513
- const nn = {
524
+ const on = {
514
525
  id: "doc.command.break-line",
515
- type: v.COMMAND,
516
- handler: async (o) => {
517
- var p, h;
518
- const e = o.get(T), t = o.get(E), n = o.get(I), s = e.getActiveRange();
519
- if (s == null)
526
+ type: I.COMMAND,
527
+ handler: async (s) => {
528
+ var S, f;
529
+ const e = s.get(T), t = s.get(E), n = s.get(v), o = e.getActiveRange();
530
+ if (o == null)
520
531
  return !1;
521
532
  const r = t.getCurrentUniverDocInstance();
522
533
  if (!r)
523
534
  return !1;
524
- const i = r.getUnitId(), { startOffset: a, segmentId: c, style: d } = s, l = [
535
+ const i = r.getUnitId(), { startOffset: a, segmentId: c, style: d } = o, l = [
525
536
  {
526
537
  startOffset: a + 1,
527
538
  endOffset: a + 1,
528
539
  style: d
529
540
  }
530
- ], m = ((h = (p = r.getBody()) == null ? void 0 : p.paragraphs) != null ? h : []).find((f) => f.startIndex >= a);
531
- return await n.executeCommand(pe.id, {
541
+ ], g = ((f = (S = r.getBody()) == null ? void 0 : S.paragraphs) != null ? f : []).find((h) => h.startIndex >= a);
542
+ return await n.executeCommand(Se.id, {
532
543
  unitId: i,
533
544
  body: {
534
- dataStream: xe.PARAGRAPH,
535
- paragraphs: tn(xe.PARAGRAPH, m)
545
+ dataStream: ye.PARAGRAPH,
546
+ paragraphs: sn(ye.PARAGRAPH, g)
536
547
  },
537
- range: s,
548
+ range: o,
538
549
  textRanges: l,
539
550
  segmentId: c
540
551
  });
541
552
  }
542
553
  };
543
- var on = Object.defineProperty, sn = Object.getOwnPropertyDescriptor, rn = (o, e, t, n) => {
544
- for (var s = n > 1 ? void 0 : n ? sn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
545
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
546
- return n && s && on(e, t, s), s;
547
- }, Re = (o, e) => (t, n) => e(t, n, o);
548
- let H = class extends ge {
554
+ var rn = Object.defineProperty, an = Object.getOwnPropertyDescriptor, cn = (s, e, t, n) => {
555
+ for (var o = n > 1 ? void 0 : n ? an(e, t) : e, r = s.length - 1, i; r >= 0; r--)
556
+ (i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
557
+ return n && o && rn(e, t, o), o;
558
+ }, xe = (s, e) => (t, n) => e(t, n, s);
559
+ let H = class extends fe {
549
560
  constructor(e, t, n) {
550
561
  super();
551
562
  y(this, "_currentSkeletonUnitId", "");
552
563
  y(this, "_docSkeletonMap", /* @__PURE__ */ new Map());
553
- y(this, "_currentSkeleton$", new ee(null));
564
+ y(this, "_currentSkeleton$", new te(null));
554
565
  y(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
555
566
  // CurrentSkeletonBefore for pre-triggered logic during registration
556
- y(this, "_currentSkeletonBefore$", new ee(null));
567
+ y(this, "_currentSkeletonBefore$", new te(null));
557
568
  y(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
558
569
  this._localeService = e, this._docViewModelManagerService = t, this._univerInstanceService = n, this._initialize();
559
570
  }
@@ -564,13 +575,13 @@ let H = class extends ge {
564
575
  this._currentSkeletonBefore$.complete(), this._currentSkeleton$.complete(), this._docSkeletonMap.clear();
565
576
  }
566
577
  _init() {
567
- this._docViewModelManagerService.currentDocViewModel$.pipe(te(this.dispose$)).subscribe((e) => {
578
+ this._docViewModelManagerService.currentDocViewModel$.pipe(ne(this.dispose$)).subscribe((e) => {
568
579
  e != null && this._setCurrent(e);
569
580
  }), this._docViewModelManagerService.getAllModel().forEach((e) => {
570
581
  e != null && this._setCurrent(e);
571
- }), this._univerInstanceService.getTypeOfUnitDisposed$(W.UNIVER_DOC).pipe(te(this.dispose$)).subscribe((e) => {
582
+ }), this._univerInstanceService.getTypeOfUnitDisposed$(Z.UNIVER_DOC).pipe(ne(this.dispose$)).subscribe((e) => {
572
583
  var t, n;
573
- this._docSkeletonMap.delete(e.getUnitId()), this._currentSkeletonUnitId = (n = (t = this._univerInstanceService.getCurrentUnitForType(W.UNIVER_DOC)) == null ? void 0 : t.getUnitId()) != null ? n : "";
584
+ this._docSkeletonMap.delete(e.getUnitId()), this._currentSkeletonUnitId = (n = (t = this._univerInstanceService.getCurrentUnitForType(Z.UNIVER_DOC)) == null ? void 0 : t.getUnitId()) != null ? n : "";
574
585
  });
575
586
  }
576
587
  getCurrent() {
@@ -605,87 +616,87 @@ let H = class extends ge {
605
616
  return this._currentSkeletonUnitId = t, this._currentSkeletonBefore$.next(this.getCurrent()), this._currentSkeleton$.next(this.getCurrent()), this.getCurrent();
606
617
  }
607
618
  _buildSkeleton(e) {
608
- return Ut.create(e, this._localeService);
619
+ return Lt.create(e, this._localeService);
609
620
  }
610
621
  };
611
- H = rn([
612
- Re(0, V(Tt)),
613
- Re(1, V(ne)),
614
- Re(2, E)
622
+ H = cn([
623
+ xe(0, k(Dt)),
624
+ xe(1, k(se)),
625
+ xe(2, E)
615
626
  ], H);
616
- const Zn = {
627
+ const Kn = {
617
628
  id: "doc.command.inner-paste",
618
- type: v.COMMAND,
619
- handler: async (o, e) => {
620
- const { segmentId: t, body: n, textRanges: s } = e, r = o.get(I), i = o.get(T), a = o.get(E), c = i.getSelections();
629
+ type: I.COMMAND,
630
+ handler: async (s, e) => {
631
+ const { segmentId: t, body: n, textRanges: o } = e, r = s.get(v), i = s.get(T), a = s.get(E), c = i.getSelections();
621
632
  if (!Array.isArray(c) || c.length === 0)
622
633
  return !1;
623
634
  const d = a.getCurrentUniverDocInstance();
624
635
  if (!d)
625
636
  return !1;
626
637
  const l = d.getUnitId(), u = {
627
- id: L.id,
638
+ id: B.id,
628
639
  params: {
629
640
  unitId: l,
630
641
  actions: [],
631
- textRanges: s
642
+ textRanges: o
632
643
  }
633
- }, m = new se();
634
- m.reset();
635
- const g = new b();
644
+ }, g = new re();
645
+ g.reset();
646
+ const m = new F(), S = b.getInstance();
636
647
  for (const h of c) {
637
- const { startOffset: f, endOffset: S, collapsed: _ } = h, R = f - m.cursor;
638
- _ ? g.push({
648
+ const { startOffset: _, endOffset: p, collapsed: R } = h, C = _ - g.cursor;
649
+ R ? m.push({
639
650
  t: x.RETAIN,
640
- len: R,
651
+ len: C,
641
652
  segmentId: t
642
- }) : g.push(...be(h, t, m.cursor)), g.push({
653
+ }) : m.push(...Ue(h, t, g.cursor)), m.push({
643
654
  t: x.INSERT,
644
655
  body: n,
645
656
  len: n.dataStream.length,
646
657
  line: 0,
647
658
  segmentId: t
648
- }), m.reset(), m.moveCursor(S);
659
+ }), g.reset(), g.moveCursor(p);
649
660
  }
650
- return u.params.actions = g.serialize(), !!r.syncExecuteCommand(u.id, u.params);
661
+ return u.params.actions = S.editOp(m.serialize()), !!r.syncExecuteCommand(u.id, u.params);
651
662
  }
652
- }, pt = {
663
+ }, _t = {
653
664
  id: "doc.command.inner-cut",
654
- type: v.COMMAND,
655
- handler: async (o, e) => {
665
+ type: I.COMMAND,
666
+ handler: async (s, e) => {
656
667
  var h;
657
- const { segmentId: t, textRanges: n } = e, s = o.get(I), r = o.get(T), i = o.get(E), a = r.getSelections();
668
+ const { segmentId: t, textRanges: n } = e, o = s.get(v), r = s.get(T), i = s.get(E), a = r.getSelections();
658
669
  if (!Array.isArray(a) || a.length === 0)
659
670
  return !1;
660
671
  const c = (h = i.getCurrentUniverDocInstance()) == null ? void 0 : h.getUnitId();
661
672
  if (!c)
662
673
  return !1;
663
- const d = i.getUniverDocInstance(c), l = Et(d.snapshot, t);
674
+ const d = i.getUniverDocInstance(c), l = At(d.getSnapshot(), t);
664
675
  if (l == null)
665
676
  return !1;
666
677
  const u = {
667
- id: L.id,
678
+ id: B.id,
668
679
  params: {
669
680
  unitId: c,
670
681
  actions: [],
671
682
  textRanges: n
672
683
  }
673
- }, m = new se();
674
- m.reset();
675
- const g = new b();
676
- for (const f of a) {
677
- const { startOffset: S, endOffset: _, collapsed: R } = f, M = S - m.cursor;
678
- R ? g.push({
684
+ }, g = new re();
685
+ g.reset();
686
+ const m = new F(), S = b.getInstance();
687
+ for (const _ of a) {
688
+ const { startOffset: p, endOffset: R, collapsed: C } = _, M = p - g.cursor;
689
+ C ? m.push({
679
690
  t: x.RETAIN,
680
691
  len: M,
681
692
  segmentId: t
682
- }) : g.push(...an(f, l, t, m.cursor)), m.reset(), m.moveCursor(_);
693
+ }) : m.push(...ln(_, l, t, g.cursor)), g.reset(), g.moveCursor(R);
683
694
  }
684
- return u.params.actions = g.serialize(), !!s.syncExecuteCommand(u.id, u.params);
695
+ return u.params.actions = S.editOp(m.serialize()), !!o.syncExecuteCommand(u.id, u.params);
685
696
  }
686
697
  };
687
- function an(o, e, t = "", n = 0) {
688
- const { startOffset: s, endOffset: r } = o, i = [], { paragraphs: a = [] } = e, c = s - n, d = r - n, l = a == null ? void 0 : a.find(
698
+ function ln(s, e, t = "", n = 0) {
699
+ const { startOffset: o, endOffset: r } = s, i = [], { paragraphs: a = [] } = e, c = o - n, d = r - n, l = a == null ? void 0 : a.find(
689
700
  (u) => u.startIndex - n >= c && u.startIndex - n <= d
690
701
  );
691
702
  if (c > 0 && i.push({
@@ -718,199 +729,199 @@ function an(o, e, t = "", n = 0) {
718
729
  });
719
730
  return i;
720
731
  }
721
- const cn = {
732
+ const dn = {
722
733
  id: "doc.command.delete-left",
723
- type: v.COMMAND,
734
+ type: I.COMMAND,
724
735
  // eslint-disable-next-line max-lines-per-function
725
- handler: async (o) => {
726
- var M;
727
- const e = o.get(T), t = o.get(H), n = o.get(E), s = o.get(I), r = e.getActiveRange(), i = e.getSelections(), a = (M = t.getCurrent()) == null ? void 0 : M.skeleton;
736
+ handler: async (s) => {
737
+ var C;
738
+ const e = s.get(T), t = s.get(H), n = s.get(E), o = s.get(v), r = e.getActiveRange(), i = e.getSelections(), a = (C = t.getCurrent()) == null ? void 0 : C.skeleton;
728
739
  let c = !0;
729
740
  if (r == null || a == null || i == null)
730
741
  return !1;
731
742
  const d = n.getCurrentUniverDocInstance();
732
743
  if (!d)
733
744
  return !1;
734
- const { startOffset: l, collapsed: u, segmentId: m, style: g } = r, p = a.findNodeByCharIndex(l), h = wt(p), f = Lt(p, d.getBody());
735
- let S = l;
736
- const _ = a.findNodeByCharIndex(l - 1);
737
- if (Bt(p) && _ !== p && (h === !0 || f === !0) && u) {
738
- const C = Ft(p, d.getBody());
739
- if (C == null)
745
+ const { startOffset: l, collapsed: u, segmentId: g, style: m } = r, S = a.findNodeByCharIndex(l), f = Bt(S), h = Ft(S, d.getBody());
746
+ let _ = l;
747
+ const p = a.findNodeByCharIndex(l - 1);
748
+ if ($t(S) && p !== S && (f === !0 || h === !0) && u) {
749
+ const M = Vt(S, d.getBody());
750
+ if (M == null)
740
751
  return !1;
741
- const D = C == null ? void 0 : C.startIndex, A = { startIndex: 0 }, P = C.paragraphStyle;
742
- if (h === !0) {
743
- const O = C.paragraphStyle;
752
+ const A = M == null ? void 0 : M.startIndex, D = { startIndex: 0 }, N = M.paragraphStyle;
753
+ if (f === !0) {
754
+ const O = M.paragraphStyle;
744
755
  if (O) {
745
- A.paragraphStyle = O;
756
+ D.paragraphStyle = O;
746
757
  const { hanging: U } = O;
747
- U && (A.paragraphStyle.indentStart = U, A.paragraphStyle.hanging = void 0);
758
+ U && (D.paragraphStyle.indentStart = U, D.paragraphStyle.hanging = void 0);
748
759
  }
749
- } else if (f === !0) {
750
- const O = C.bullet;
751
- O && (A.bullet = O), P != null && (A.paragraphStyle = { ...P }, delete A.paragraphStyle.hanging, delete A.paragraphStyle.indentStart);
760
+ } else if (h === !0) {
761
+ const O = M.bullet;
762
+ O && (D.bullet = O), N != null && (D.paragraphStyle = { ...N }, delete D.paragraphStyle.hanging, delete D.paragraphStyle.indentStart);
752
763
  }
753
- const B = [
764
+ const L = [
754
765
  {
755
- startOffset: S,
756
- endOffset: S,
757
- style: g
766
+ startOffset: _,
767
+ endOffset: _,
768
+ style: m
758
769
  }
759
770
  ];
760
- c = await s.executeCommand(ht.id, {
771
+ c = await o.executeCommand(St.id, {
761
772
  unitId: d.getUnitId(),
762
773
  updateBody: {
763
774
  dataStream: "",
764
- paragraphs: [{ ...A }]
775
+ paragraphs: [{ ...D }]
765
776
  },
766
777
  range: {
767
- startOffset: D,
768
- endOffset: D + 1
778
+ startOffset: A,
779
+ endOffset: A + 1
769
780
  },
770
- textRanges: B,
771
- coverType: Ee.REPLACE,
772
- segmentId: m
781
+ textRanges: L,
782
+ coverType: De.REPLACE,
783
+ segmentId: g
773
784
  });
774
785
  } else if (u === !0) {
775
- if (_ == null)
786
+ if (p == null)
776
787
  return !0;
777
- if (_.content === "\r")
778
- c = await s.executeCommand(Ue.id, {
779
- direction: j.LEFT,
788
+ if (p.content === "\r")
789
+ c = await o.executeCommand(we.id, {
790
+ direction: X.LEFT,
780
791
  range: r
781
792
  });
782
793
  else {
783
- S -= _.count;
784
- const C = [
794
+ _ -= p.count;
795
+ const M = [
785
796
  {
786
- startOffset: S,
787
- endOffset: S,
788
- style: g
797
+ startOffset: _,
798
+ endOffset: _,
799
+ style: m
789
800
  }
790
801
  ];
791
- c = await s.executeCommand(Se.id, {
802
+ c = await o.executeCommand(_e.id, {
792
803
  unitId: d.getUnitId(),
793
804
  range: r,
794
- segmentId: m,
795
- direction: j.LEFT,
796
- len: _.count,
797
- textRanges: C
805
+ segmentId: g,
806
+ direction: X.LEFT,
807
+ len: p.count,
808
+ textRanges: M
798
809
  });
799
810
  }
800
811
  } else {
801
- const C = St(r, i);
802
- c = await s.executeCommand(pt.id, {
803
- segmentId: m,
804
- textRanges: C
812
+ const M = It(r, i);
813
+ c = await o.executeCommand(_t.id, {
814
+ segmentId: g,
815
+ textRanges: M
805
816
  });
806
817
  }
807
818
  return c;
808
819
  }
809
- }, ln = {
820
+ }, un = {
810
821
  id: "doc.command.delete-right",
811
- type: v.COMMAND,
812
- handler: async (o) => {
813
- var p;
814
- const e = o.get(T), t = o.get(H), n = o.get(E), s = o.get(I), r = e.getActiveRange(), i = e.getSelections(), a = (p = t.getCurrent()) == null ? void 0 : p.skeleton;
822
+ type: I.COMMAND,
823
+ handler: async (s) => {
824
+ var S;
825
+ const e = s.get(T), t = s.get(H), n = s.get(E), o = s.get(v), r = e.getActiveRange(), i = e.getSelections(), a = (S = t.getCurrent()) == null ? void 0 : S.skeleton;
815
826
  let c;
816
827
  if (r == null || a == null || i == null)
817
828
  return !1;
818
829
  const d = n.getCurrentUniverDocInstance();
819
830
  if (!d)
820
831
  return !1;
821
- const { startOffset: l, collapsed: u, segmentId: m, style: g } = r;
832
+ const { startOffset: l, collapsed: u, segmentId: g, style: m } = r;
822
833
  if (l === d.getBody().dataStream.length - 2 && u)
823
834
  return !0;
824
835
  if (u === !0) {
825
- const h = a.findNodeByCharIndex(l);
826
- if (h.content === "\r")
827
- c = await s.executeCommand(Ue.id, {
828
- direction: j.RIGHT,
836
+ const f = a.findNodeByCharIndex(l);
837
+ if (f.content === "\r")
838
+ c = await o.executeCommand(we.id, {
839
+ direction: X.RIGHT,
829
840
  range: r
830
841
  });
831
842
  else {
832
- const f = [
843
+ const h = [
833
844
  {
834
845
  startOffset: l,
835
846
  endOffset: l,
836
- style: g
847
+ style: m
837
848
  }
838
849
  ];
839
- c = await s.executeCommand(Se.id, {
850
+ c = await o.executeCommand(_e.id, {
840
851
  unitId: d.getUnitId(),
841
852
  range: r,
842
- segmentId: m,
843
- direction: j.RIGHT,
844
- textRanges: f,
845
- len: h.count
853
+ segmentId: g,
854
+ direction: X.RIGHT,
855
+ textRanges: h,
856
+ len: f.count
846
857
  });
847
858
  }
848
859
  } else {
849
- const h = St(r, i);
850
- c = await s.executeCommand(pt.id, {
851
- segmentId: m,
852
- textRanges: h
860
+ const f = It(r, i);
861
+ c = await o.executeCommand(_t.id, {
862
+ segmentId: g,
863
+ textRanges: f
853
864
  });
854
865
  }
855
866
  return c;
856
867
  }
857
- }, Ue = {
868
+ }, we = {
858
869
  id: "doc.command.merge-two-paragraph",
859
- type: v.COMMAND,
870
+ type: I.COMMAND,
860
871
  // eslint-disable-next-line max-lines-per-function
861
- handler: async (o, e) => {
862
- var A, P, B;
863
- const t = o.get(T), n = o.get(E), s = o.get(I), { direction: r, range: i } = e, a = t.getActiveRange(), c = t.getSelections();
872
+ handler: async (s, e) => {
873
+ var N, L, O;
874
+ const t = s.get(T), n = s.get(E), o = s.get(v), { direction: r, range: i } = e, a = t.getActiveRange(), c = t.getSelections();
864
875
  if (a == null || c == null)
865
876
  return !1;
866
877
  const d = n.getCurrentUniverDocInstance();
867
878
  if (!d)
868
879
  return !1;
869
- const { startOffset: l, collapsed: u, segmentId: m, style: g } = a;
880
+ const { startOffset: l, collapsed: u, segmentId: g, style: m } = a;
870
881
  if (!u)
871
882
  return !1;
872
- const p = r === j.LEFT ? l : l + 1, h = (B = (P = (A = d.getBody()) == null ? void 0 : A.paragraphs) == null ? void 0 : P.find((O) => O.startIndex >= p)) == null ? void 0 : B.startIndex, f = dn(d.getBody(), p, h), S = r === j.LEFT ? l - 1 : l, _ = d.getUnitId(), R = [
883
+ const S = r === X.LEFT ? l : l + 1, f = (O = (L = (N = d.getBody()) == null ? void 0 : N.paragraphs) == null ? void 0 : L.find((U) => U.startIndex >= S)) == null ? void 0 : O.startIndex, h = gn(d.getBody(), S, f), _ = r === X.LEFT ? l - 1 : l, p = d.getUnitId(), R = [
873
884
  {
874
- startOffset: S,
875
- endOffset: S,
876
- style: g
885
+ startOffset: _,
886
+ endOffset: _,
887
+ style: m
877
888
  }
878
- ], M = {
879
- id: L.id,
889
+ ], C = {
890
+ id: B.id,
880
891
  params: {
881
- unitId: _,
892
+ unitId: p,
882
893
  actions: [],
883
894
  textRanges: R,
884
895
  prevTextRanges: [i]
885
896
  }
886
- }, C = new b();
887
- return C.push({
897
+ }, M = new F(), A = b.getInstance();
898
+ return M.push({
888
899
  t: x.RETAIN,
889
- len: r === j.LEFT ? l - 1 : l,
890
- segmentId: m
891
- }), f.dataStream.length && C.push({
900
+ len: r === X.LEFT ? l - 1 : l,
901
+ segmentId: g
902
+ }), h.dataStream.length && M.push({
892
903
  t: x.INSERT,
893
- body: f,
894
- len: f.dataStream.length,
904
+ body: h,
905
+ len: h.dataStream.length,
895
906
  line: 0,
896
- segmentId: m
897
- }), C.push({
907
+ segmentId: g
908
+ }), M.push({
898
909
  t: x.RETAIN,
899
910
  len: 1,
900
- segmentId: m
901
- }), C.push({
911
+ segmentId: g
912
+ }), M.push({
902
913
  t: x.DELETE,
903
- len: h + 1 - p,
914
+ len: f + 1 - S,
904
915
  line: 0,
905
- segmentId: m
906
- }), M.params.actions = C.serialize(), !!s.syncExecuteCommand(M.id, M.params);
916
+ segmentId: g
917
+ }), C.params.actions = A.editOp(M.serialize()), !!o.syncExecuteCommand(C.id, C.params);
907
918
  }
908
919
  };
909
- function dn(o, e, t) {
910
- const { textRuns: n } = o, s = o.dataStream.substring(e, t);
920
+ function gn(s, e, t) {
921
+ const { textRuns: n } = s, o = s.dataStream.substring(e, t);
911
922
  if (n == null)
912
923
  return {
913
- dataStream: s
924
+ dataStream: o
914
925
  };
915
926
  const r = [];
916
927
  for (const i of n) {
@@ -930,552 +941,555 @@ function dn(o, e, t) {
930
941
  }));
931
942
  }
932
943
  return {
933
- dataStream: s,
944
+ dataStream: o,
934
945
  textRuns: r
935
946
  };
936
947
  }
937
- function St(o, e) {
938
- let t = o.endOffset;
939
- for (const s of e) {
940
- const { startOffset: r, endOffset: i } = s;
941
- r == null || i == null || i <= o.endOffset && (t -= i - r);
948
+ function It(s, e) {
949
+ let t = s.endOffset;
950
+ for (const o of e) {
951
+ const { startOffset: r, endOffset: i } = o;
952
+ r == null || i == null || i <= s.endOffset && (t -= i - r);
942
953
  }
943
954
  return [
944
955
  {
945
956
  startOffset: t,
946
957
  endOffset: t,
947
- style: o.style
958
+ style: s.style
948
959
  }
949
960
  ];
950
961
  }
951
- const _t = {
962
+ const vt = {
952
963
  id: "doc.command.ime-input",
953
- type: v.COMMAND,
954
- handler: async (o, e) => {
955
- const { unitId: t, newText: n, oldTextLen: s, isCompositionEnd: r, isCompositionStart: i } = e, a = o.get(I), c = o.get(he), d = c.getActiveRange();
964
+ type: I.COMMAND,
965
+ handler: async (s, e) => {
966
+ const { unitId: t, newText: n, oldTextLen: o, isCompositionEnd: r, isCompositionStart: i } = e, a = s.get(v), c = s.get(pe), d = c.getActiveRange();
956
967
  if (d == null)
957
968
  return !1;
958
- const { startOffset: l, style: u, segmentId: m } = d, g = n.length, p = [
969
+ const { startOffset: l, style: u, segmentId: g } = d, m = n.length, S = [
959
970
  {
960
- startOffset: l + g,
961
- endOffset: l + g,
971
+ startOffset: l + m,
972
+ endOffset: l + m,
962
973
  collapsed: !0,
963
974
  style: u
964
975
  }
965
- ], h = {
966
- id: L.id,
976
+ ], f = {
977
+ id: B.id,
967
978
  params: {
968
979
  unitId: t,
969
980
  actions: [],
970
- textRanges: p
981
+ textRanges: S
971
982
  }
972
- }, f = new b();
973
- !d.collapsed && i ? f.push(...be(d, m)) : f.push({
983
+ }, h = new F(), _ = b.getInstance();
984
+ !d.collapsed && i ? h.push(...Ue(d, g)) : h.push({
974
985
  t: x.RETAIN,
975
986
  len: l,
976
- segmentId: m
977
- }), s > 0 && f.push({
987
+ segmentId: g
988
+ }), o > 0 && h.push({
978
989
  t: x.DELETE,
979
- len: s,
990
+ len: o,
980
991
  line: 0,
981
- segmentId: m
982
- }), f.push({
992
+ segmentId: g
993
+ }), h.push({
983
994
  t: x.INSERT,
984
995
  body: {
985
996
  dataStream: n
986
997
  },
987
998
  len: n.length,
988
999
  line: 0,
989
- segmentId: m
990
- }), h.params.actions = f.serialize(), h.params.noHistory = !r, h.params.isCompositionEnd = r;
991
- const S = a.syncExecuteCommand(h.id, h.params);
992
- return c.pushUndoRedoMutationParams(S, h.params), !!S;
1000
+ segmentId: g
1001
+ }), f.params.actions = _.editOp(h.serialize()), f.params.noHistory = !r, f.params.isCompositionEnd = r;
1002
+ const p = a.syncExecuteCommand(f.id, f.params);
1003
+ return c.pushUndoRedoMutationParams(p, f.params), !!p;
993
1004
  }
994
1005
  };
995
- function F(o, e, t, n) {
1006
+ function $(s, e, t, n) {
996
1007
  var r;
997
- const { segmentId: s } = (r = t.getActiveRange()) != null ? r : {};
998
- return s == null ? !1 : n.executeCommand(It.id, {
999
- segmentId: s,
1000
- preCommandId: o,
1008
+ const { segmentId: o } = (r = t.getActiveRange()) != null ? r : {};
1009
+ return o == null ? !1 : n.executeCommand(Ct.id, {
1010
+ segmentId: o,
1011
+ preCommandId: s,
1001
1012
  ...e != null ? e : {}
1002
1013
  });
1003
1014
  }
1004
- const Qe = "doc.command.set-inline-format-bold", we = {
1005
- id: Qe,
1006
- type: v.COMMAND,
1007
- handler: async (o, e) => {
1008
- const t = o.get(I), n = o.get(T);
1009
- return F(
1010
- Qe,
1011
- e,
1012
- n,
1013
- t
1014
- );
1015
- }
1016
- }, et = "doc.command.set-inline-format-italic", Le = {
1017
- id: et,
1018
- type: v.COMMAND,
1019
- handler: async (o, e) => {
1020
- const t = o.get(I), n = o.get(T);
1021
- return F(
1022
- et,
1023
- e,
1024
- n,
1025
- t
1026
- );
1027
- }
1028
- }, tt = "doc.command.set-inline-format-underline", Be = {
1015
+ const tt = "doc.command.set-inline-format-bold", Le = {
1029
1016
  id: tt,
1030
- type: v.COMMAND,
1031
- handler: async (o, e) => {
1032
- const t = o.get(I), n = o.get(T);
1033
- return F(
1017
+ type: I.COMMAND,
1018
+ handler: async (s, e) => {
1019
+ const t = s.get(v), n = s.get(T);
1020
+ return $(
1034
1021
  tt,
1035
1022
  e,
1036
1023
  n,
1037
1024
  t
1038
1025
  );
1039
1026
  }
1040
- }, nt = "doc.command.set-inline-format-strikethrough", Fe = {
1027
+ }, nt = "doc.command.set-inline-format-italic", Be = {
1041
1028
  id: nt,
1042
- type: v.COMMAND,
1043
- handler: async (o, e) => {
1044
- const t = o.get(I), n = o.get(T);
1045
- return F(
1029
+ type: I.COMMAND,
1030
+ handler: async (s, e) => {
1031
+ const t = s.get(v), n = s.get(T);
1032
+ return $(
1046
1033
  nt,
1047
1034
  e,
1048
1035
  n,
1049
1036
  t
1050
1037
  );
1051
1038
  }
1052
- }, ot = "doc.command.set-inline-format-subscript", oe = {
1053
- id: ot,
1054
- type: v.COMMAND,
1055
- handler: async (o, e) => {
1056
- const t = o.get(I), n = o.get(T);
1057
- return F(
1058
- ot,
1039
+ }, st = "doc.command.set-inline-format-underline", Fe = {
1040
+ id: st,
1041
+ type: I.COMMAND,
1042
+ handler: async (s, e) => {
1043
+ const t = s.get(v), n = s.get(T);
1044
+ return $(
1045
+ st,
1059
1046
  e,
1060
1047
  n,
1061
1048
  t
1062
1049
  );
1063
1050
  }
1064
- }, st = "doc.command.set-inline-format-superscript", $e = {
1065
- id: st,
1066
- type: v.COMMAND,
1067
- handler: async (o, e) => {
1068
- const t = o.get(I), n = o.get(T);
1069
- return F(
1070
- st,
1051
+ }, ot = "doc.command.set-inline-format-strikethrough", $e = {
1052
+ id: ot,
1053
+ type: I.COMMAND,
1054
+ handler: async (s, e) => {
1055
+ const t = s.get(v), n = s.get(T);
1056
+ return $(
1057
+ ot,
1071
1058
  e,
1072
1059
  n,
1073
1060
  t
1074
1061
  );
1075
1062
  }
1076
- }, rt = "doc.command.set-inline-format-fontsize", Ve = {
1063
+ }, rt = "doc.command.set-inline-format-subscript", oe = {
1077
1064
  id: rt,
1078
- type: v.COMMAND,
1079
- handler: async (o, e) => {
1080
- const t = o.get(I), n = o.get(T);
1081
- return F(
1065
+ type: I.COMMAND,
1066
+ handler: async (s, e) => {
1067
+ const t = s.get(v), n = s.get(T);
1068
+ return $(
1082
1069
  rt,
1083
1070
  e,
1084
1071
  n,
1085
1072
  t
1086
1073
  );
1087
1074
  }
1088
- }, it = "doc.command.set-inline-format-font-family", ke = {
1075
+ }, it = "doc.command.set-inline-format-superscript", Ve = {
1089
1076
  id: it,
1090
- type: v.COMMAND,
1091
- handler: async (o, e) => {
1092
- const t = o.get(I), n = o.get(T);
1093
- return F(
1077
+ type: I.COMMAND,
1078
+ handler: async (s, e) => {
1079
+ const t = s.get(v), n = s.get(T);
1080
+ return $(
1094
1081
  it,
1095
1082
  e,
1096
1083
  n,
1097
1084
  t
1098
1085
  );
1099
1086
  }
1100
- }, at = "doc.command.set-inline-format-text-color", ze = {
1087
+ }, at = "doc.command.set-inline-format-fontsize", ke = {
1101
1088
  id: at,
1102
- type: v.COMMAND,
1103
- handler: async (o, e) => {
1104
- const t = o.get(I), n = o.get(T);
1105
- return F(
1089
+ type: I.COMMAND,
1090
+ handler: async (s, e) => {
1091
+ const t = s.get(v), n = s.get(T);
1092
+ return $(
1106
1093
  at,
1107
1094
  e,
1108
1095
  n,
1109
1096
  t
1110
1097
  );
1111
1098
  }
1112
- }, ct = "doc.command.set-inline-format-text-background-color", Ge = {
1099
+ }, ct = "doc.command.set-inline-format-font-family", ze = {
1113
1100
  id: ct,
1114
- type: v.COMMAND,
1115
- handler: async (o, e) => {
1116
- const t = o.get(I), n = o.get(T);
1117
- return F(
1101
+ type: I.COMMAND,
1102
+ handler: async (s, e) => {
1103
+ const t = s.get(v), n = s.get(T);
1104
+ return $(
1118
1105
  ct,
1119
1106
  e,
1120
1107
  n,
1121
1108
  t
1122
1109
  );
1123
1110
  }
1124
- }, lt = "doc.command.reset-inline-format-text-background-color", je = {
1111
+ }, lt = "doc.command.set-inline-format-text-color", je = {
1125
1112
  id: lt,
1126
- type: v.COMMAND,
1127
- handler: async (o, e) => {
1128
- const t = o.get(I), n = o.get(T);
1129
- return F(
1113
+ type: I.COMMAND,
1114
+ handler: async (s, e) => {
1115
+ const t = s.get(v), n = s.get(T);
1116
+ return $(
1130
1117
  lt,
1131
1118
  e,
1132
1119
  n,
1133
1120
  t
1134
1121
  );
1135
1122
  }
1136
- }, vt = {
1137
- [we.id]: "bl",
1138
- [Le.id]: "it",
1139
- [Be.id]: "ul",
1140
- [Fe.id]: "st",
1141
- [Ve.id]: "fs",
1142
- [ke.id]: "ff",
1143
- [ze.id]: "cl",
1123
+ }, dt = "doc.command.set-inline-format-text-background-color", Ge = {
1124
+ id: dt,
1125
+ type: I.COMMAND,
1126
+ handler: async (s, e) => {
1127
+ const t = s.get(v), n = s.get(T);
1128
+ return $(
1129
+ dt,
1130
+ e,
1131
+ n,
1132
+ t
1133
+ );
1134
+ }
1135
+ }, ut = "doc.command.reset-inline-format-text-background-color", Xe = {
1136
+ id: ut,
1137
+ type: I.COMMAND,
1138
+ handler: async (s, e) => {
1139
+ const t = s.get(v), n = s.get(T);
1140
+ return $(
1141
+ ut,
1142
+ e,
1143
+ n,
1144
+ t
1145
+ );
1146
+ }
1147
+ }, Mt = {
1148
+ [Le.id]: "bl",
1149
+ [Be.id]: "it",
1150
+ [Fe.id]: "ul",
1151
+ [$e.id]: "st",
1152
+ [ke.id]: "fs",
1153
+ [ze.id]: "ff",
1154
+ [je.id]: "cl",
1144
1155
  [Ge.id]: "bg",
1145
- [je.id]: "bg",
1156
+ [Xe.id]: "bg",
1146
1157
  [oe.id]: "va",
1147
- [$e.id]: "va"
1148
- }, It = {
1158
+ [Ve.id]: "va"
1159
+ }, Ct = {
1149
1160
  id: "doc.command.set-inline-format",
1150
- type: v.COMMAND,
1151
- handler: async (o, e) => {
1152
- const { segmentId: t, value: n, preCommandId: s } = e, r = o.get(I), i = o.get(T), a = o.get(E), c = i.getSelections();
1161
+ type: I.COMMAND,
1162
+ // eslint-disable-next-line max-lines-per-function
1163
+ handler: async (s, e) => {
1164
+ const { segmentId: t, value: n, preCommandId: o } = e, r = s.get(v), i = s.get(T), a = s.get(E), c = i.getSelections();
1153
1165
  if (!Array.isArray(c) || c.length === 0)
1154
1166
  return !1;
1155
1167
  let d = a.getCurrentUniverDocInstance();
1156
1168
  if (!d)
1157
1169
  return !1;
1158
1170
  let l = d.getUnitId();
1159
- l === Dt && (d = a.getUniverDocInstance(ut), l = d.getUnitId());
1171
+ l === Nt && (d = a.getUniverDocInstance(mt), l = d.getUnitId());
1160
1172
  let u;
1161
- switch (s) {
1162
- case we.id:
1173
+ switch (o) {
1163
1174
  case Le.id:
1164
1175
  case Be.id:
1165
1176
  case Fe.id:
1177
+ case $e.id:
1166
1178
  case oe.id:
1167
- case $e.id: {
1168
- u = mn(
1179
+ case Ve.id: {
1180
+ u = fn(
1169
1181
  d.getBody().textRuns,
1170
- s,
1182
+ o,
1171
1183
  c
1172
1184
  );
1173
1185
  break;
1174
1186
  }
1175
- case Ve.id:
1176
- case ke.id: {
1187
+ case ke.id:
1188
+ case ze.id: {
1177
1189
  u = n;
1178
1190
  break;
1179
1191
  }
1180
- case ze.id:
1192
+ case je.id:
1181
1193
  case Ge.id: {
1182
1194
  u = {
1183
1195
  rgb: n
1184
1196
  };
1185
1197
  break;
1186
1198
  }
1187
- case je.id: {
1199
+ case Xe.id: {
1188
1200
  u = {
1189
1201
  rgb: null
1190
1202
  };
1191
1203
  break;
1192
1204
  }
1193
1205
  default:
1194
- throw new Error(`Unknown command: ${s} in handleInlineFormat`);
1206
+ throw new Error(`Unknown command: ${o} in handleInlineFormat`);
1195
1207
  }
1196
- const m = {
1197
- id: L.id,
1208
+ const g = {
1209
+ id: B.id,
1198
1210
  params: {
1199
1211
  unitId: l,
1200
1212
  actions: [],
1201
- textRanges: c.map(Z)
1213
+ textRanges: c.map(J)
1202
1214
  }
1203
- }, g = new b(), p = new se();
1204
- p.reset();
1205
- for (const f of c) {
1206
- const { startOffset: S, endOffset: _ } = f, R = {
1215
+ }, m = new F(), S = b.getInstance(), f = new re();
1216
+ f.reset();
1217
+ for (const _ of c) {
1218
+ const { startOffset: p, endOffset: R } = _, C = {
1207
1219
  dataStream: "",
1208
1220
  textRuns: [
1209
1221
  {
1210
1222
  st: 0,
1211
- ed: _ - S,
1223
+ ed: R - p,
1212
1224
  ts: {
1213
- [vt[s]]: u
1225
+ [Mt[o]]: u
1214
1226
  }
1215
1227
  }
1216
1228
  ]
1217
- }, M = S - p.cursor;
1218
- M !== 0 && g.push({
1229
+ }, M = p - f.cursor;
1230
+ M !== 0 && m.push({
1219
1231
  t: x.RETAIN,
1220
1232
  len: M,
1221
1233
  segmentId: t
1222
- }), g.push({
1234
+ }), m.push({
1223
1235
  t: x.RETAIN,
1224
- body: R,
1225
- len: _ - S,
1236
+ body: C,
1237
+ len: R - p,
1226
1238
  segmentId: t
1227
- }), p.reset(), p.moveCursor(_);
1239
+ }), f.reset(), f.moveCursor(R);
1228
1240
  }
1229
- return m.params.actions = g.serialize(), !!r.syncExecuteCommand(m.id, m.params);
1241
+ return g.params.actions = S.editOp(m.serialize()), !!r.syncExecuteCommand(g.id, g.params);
1230
1242
  }
1231
1243
  };
1232
- function un(o) {
1233
- return o !== null && typeof o == "object";
1244
+ function mn(s) {
1245
+ return s !== null && typeof s == "object";
1234
1246
  }
1235
- function mn(o, e, t) {
1236
- let n = 0, s = 0;
1237
- const r = vt[e];
1238
- for (; n !== o.length && s !== t.length; ) {
1239
- const { startOffset: i, endOffset: a } = t[s], { st: c, ed: d, ts: l } = o[n];
1247
+ function fn(s, e, t) {
1248
+ let n = 0, o = 0;
1249
+ const r = Mt[e];
1250
+ for (; n !== s.length && o !== t.length; ) {
1251
+ const { startOffset: i, endOffset: a } = t[o], { st: c, ed: d, ts: l } = s[n];
1240
1252
  if (a <= c)
1241
- s++;
1253
+ o++;
1242
1254
  else if (d <= i)
1243
1255
  n++;
1244
1256
  else {
1245
1257
  if (/bl|it/.test(r))
1246
- return (l == null ? void 0 : l[r]) === z.TRUE ? z.FALSE : z.TRUE;
1258
+ return (l == null ? void 0 : l[r]) === j.TRUE ? j.FALSE : j.TRUE;
1247
1259
  if (/ul|st/.test(r))
1248
- return un(l == null ? void 0 : l[r]) && (l == null ? void 0 : l[r]).s === z.TRUE ? {
1249
- s: z.FALSE
1260
+ return mn(l == null ? void 0 : l[r]) && (l == null ? void 0 : l[r]).s === j.TRUE ? {
1261
+ s: j.FALSE
1250
1262
  } : {
1251
- s: z.TRUE
1263
+ s: j.TRUE
1252
1264
  };
1253
1265
  if (/va/.test(r))
1254
1266
  return e === oe.id ? (l == null ? void 0 : l[r]) === G.SUBSCRIPT ? G.NORMAL : G.SUBSCRIPT : (l == null ? void 0 : l[r]) === G.SUPERSCRIPT ? G.NORMAL : G.SUPERSCRIPT;
1255
1267
  n++;
1256
1268
  }
1257
1269
  }
1258
- return /bl|it/.test(r) ? z.TRUE : /ul|st/.test(r) ? {
1259
- s: z.TRUE
1270
+ return /bl|it/.test(r) ? j.TRUE : /ul|st/.test(r) ? {
1271
+ s: j.TRUE
1260
1272
  } : e === oe.id ? G.SUBSCRIPT : G.SUPERSCRIPT;
1261
1273
  }
1262
1274
  const He = {
1263
1275
  id: "doc.command.list-operation",
1264
- type: v.COMMAND,
1265
- handler: (o, e) => {
1266
- var O, U, w, X;
1267
- const t = o.get(T), n = o.get(E), s = o.get(I), { listType: r } = e, i = n.getCurrentUniverDocInstance();
1276
+ type: I.COMMAND,
1277
+ // eslint-disable-next-line max-lines-per-function
1278
+ handler: (s, e) => {
1279
+ var U, w, Y, Ye;
1280
+ const t = s.get(T), n = s.get(E), o = s.get(v), { listType: r } = e, i = n.getCurrentUniverDocInstance();
1268
1281
  if (!i)
1269
1282
  return !1;
1270
- const a = t.getActiveRange(), c = (O = t.getSelections()) != null ? O : [], d = (U = i.getBody()) == null ? void 0 : U.paragraphs, l = c.map(Z);
1283
+ const a = t.getActiveRange(), c = (U = t.getSelections()) != null ? U : [], d = (w = i.getBody()) == null ? void 0 : w.paragraphs, l = c.map(J);
1271
1284
  if (a == null || d == null)
1272
1285
  return !1;
1273
- const u = Mt(a, d), { segmentId: m } = a, g = i.getUnitId(), p = u.every((Y) => {
1274
- var $;
1275
- return (($ = Y.bullet) == null ? void 0 : $.listType) === r;
1286
+ const u = Rt(a, d), { segmentId: g } = a, m = i.getUnitId(), S = u.every((W) => {
1287
+ var V;
1288
+ return ((V = W.bullet) == null ? void 0 : V.listType) === r;
1276
1289
  });
1277
- let f = Q.generateRandomId(6);
1290
+ let h = ee.generateRandomId(6);
1278
1291
  if (u.length === 1) {
1279
- const Y = d.indexOf(u[0]), $ = d[Y - 1], k = d[Y + 1];
1280
- $ && $.bullet && $.bullet.listType === r ? f = $.bullet.listId : k && k.bullet && k.bullet.listType === r && (f = k.bullet.listId);
1292
+ const W = d.indexOf(u[0]), V = d[W - 1], z = d[W + 1];
1293
+ V && V.bullet && V.bullet.listType === r ? h = V.bullet.listId : z && z.bullet && z.bullet.listType === r && (h = z.bullet.listId);
1281
1294
  }
1282
- const S = {
1283
- id: L.id,
1295
+ const _ = {
1296
+ id: B.id,
1284
1297
  params: {
1285
- unitId: g,
1298
+ unitId: m,
1286
1299
  actions: [],
1287
1300
  textRanges: l
1288
1301
  }
1289
- }, _ = new se();
1290
- _.reset();
1291
- const R = new b(), M = (w = i.getSnapshot().lists) != null ? w : {}, C = {
1292
- ...At,
1302
+ }, p = new re();
1303
+ p.reset();
1304
+ const R = new F(), C = b.getInstance(), M = (Y = i.getSnapshot().lists) != null ? Y : {}, A = {
1305
+ ...Pt,
1293
1306
  ...M
1294
- }, { charSpace: D, defaultTabStop: A = 36, gridType: P } = i.getSnapshot().documentStyle;
1295
- for (const Y of u) {
1296
- const { startIndex: $, paragraphStyle: k = {} } = Y, { indentFirstLine: Rt = 0, snapToGrid: xt, indentStart: _e = 0 } = k, { hanging: ve, indentStart: Xe } = C[r].nestingLevel[0], Ie = $t(D, A, P, xt);
1307
+ }, { charSpace: D, defaultTabStop: N = 36, gridType: L } = i.getSnapshot().documentStyle;
1308
+ for (const W of u) {
1309
+ const { startIndex: V, paragraphStyle: z = {} } = W, { indentFirstLine: yt = 0, snapToGrid: Ot, indentStart: Ie = 0 } = z, { hanging: ve, indentStart: We } = A[r].nestingLevel[0], Me = kt(D, N, L, Ot);
1297
1310
  R.push({
1298
1311
  t: x.RETAIN,
1299
- len: $ - _.cursor,
1300
- segmentId: m
1312
+ len: V - p.cursor,
1313
+ segmentId: g
1301
1314
  }), R.push({
1302
1315
  t: x.RETAIN,
1303
1316
  len: 1,
1304
1317
  body: {
1305
1318
  dataStream: "",
1306
1319
  paragraphs: [
1307
- p ? {
1320
+ S ? {
1308
1321
  paragraphStyle: {
1309
- ...k,
1322
+ ...z,
1310
1323
  hanging: void 0,
1311
- indentStart: _e ? Math.max(0, Me(_e, Ie) + ve - Xe) : void 0
1324
+ indentStart: Ie ? Math.max(0, Ce(Ie, Me) + ve - We) : void 0
1312
1325
  },
1313
1326
  startIndex: 0
1314
1327
  } : {
1315
1328
  startIndex: 0,
1316
1329
  paragraphStyle: {
1317
- ...k,
1330
+ ...z,
1318
1331
  indentFirstLine: void 0,
1319
1332
  hanging: ve,
1320
- indentStart: Xe - ve + Me(Rt, Ie) + Me(_e, Ie)
1333
+ indentStart: We - ve + Ce(yt, Me) + Ce(Ie, Me)
1321
1334
  },
1322
1335
  bullet: {
1323
- ...(X = Y.bullet) != null ? X : {
1336
+ ...(Ye = W.bullet) != null ? Ye : {
1324
1337
  nestingLevel: 0,
1325
1338
  textStyle: {
1326
1339
  fs: 20
1327
1340
  }
1328
1341
  },
1329
1342
  listType: r,
1330
- listId: f
1343
+ listId: h
1331
1344
  }
1332
1345
  }
1333
1346
  ]
1334
1347
  },
1335
- segmentId: m,
1336
- coverType: Ee.REPLACE
1337
- }), _.moveCursorTo($ + 1);
1348
+ segmentId: g,
1349
+ coverType: De.REPLACE
1350
+ }), p.moveCursorTo(V + 1);
1338
1351
  }
1339
- return S.params.actions = R.serialize(), !!s.syncExecuteCommand(S.id, S.params);
1352
+ return _.params.actions = C.editOp(R.serialize()), !!o.syncExecuteCommand(_.id, _.params);
1340
1353
  }
1341
- }, gn = {
1354
+ }, hn = {
1342
1355
  id: "doc.command.bullet-list",
1343
- type: v.COMMAND,
1344
- handler: (o) => o.get(I).syncExecuteCommand(He.id, {
1345
- listType: mt.BULLET_LIST
1356
+ type: I.COMMAND,
1357
+ handler: (s) => s.get(v).syncExecuteCommand(He.id, {
1358
+ listType: ft.BULLET_LIST
1346
1359
  })
1347
- }, fn = {
1360
+ }, pn = {
1348
1361
  id: "doc.command.order-list",
1349
- type: v.COMMAND,
1350
- handler: (o) => o.get(I).syncExecuteCommand(He.id, {
1351
- listType: mt.ORDER_LIST
1362
+ type: I.COMMAND,
1363
+ handler: (s) => s.get(v).syncExecuteCommand(He.id, {
1364
+ listType: ft.ORDER_LIST
1352
1365
  })
1353
1366
  };
1354
- function Mt(o, e) {
1355
- const { startOffset: t, endOffset: n } = o, s = [];
1367
+ function Rt(s, e) {
1368
+ const { startOffset: t, endOffset: n } = s, o = [];
1356
1369
  let r = -1;
1357
1370
  for (const i of e) {
1358
1371
  const { startIndex: a } = i;
1359
- (t > r && t <= a || n > r && n <= a || a >= t && a <= n) && s.push(i), r = a;
1372
+ (t > r && t <= a || n > r && n <= a || a >= t && a <= n) && o.push(i), r = a;
1360
1373
  }
1361
- return s;
1374
+ return o;
1362
1375
  }
1363
- const ie = {
1376
+ const ae = {
1364
1377
  id: "doc.command.align-operation",
1365
- type: v.COMMAND,
1366
- handler: (o, e) => {
1367
- var R, M;
1368
- const t = o.get(T), n = o.get(E), s = o.get(I), { alignType: r } = e, i = n.getCurrentUniverDocInstance();
1378
+ type: I.COMMAND,
1379
+ // eslint-disable-next-line max-lines-per-function
1380
+ handler: (s, e) => {
1381
+ var C, M;
1382
+ const t = s.get(T), n = s.get(E), o = s.get(v), { alignType: r } = e, i = n.getCurrentUniverDocInstance();
1369
1383
  if (!i)
1370
1384
  return !1;
1371
- const a = t.getActiveRange(), c = (R = t.getSelections()) != null ? R : [], d = (M = i.getBody()) == null ? void 0 : M.paragraphs, l = c.map(Z);
1385
+ const a = t.getActiveRange(), c = (C = t.getSelections()) != null ? C : [], d = (M = i.getBody()) == null ? void 0 : M.paragraphs, l = c.map(J);
1372
1386
  if (a == null || d == null)
1373
1387
  return !1;
1374
- const u = Mt(a, d), { segmentId: m } = a, g = i.getUnitId(), p = u.every((C) => {
1388
+ const u = Rt(a, d), { segmentId: g } = a, m = i.getUnitId(), S = u.every((A) => {
1375
1389
  var D;
1376
- return ((D = C.paragraphStyle) == null ? void 0 : D.horizontalAlign) === r;
1377
- }), h = {
1378
- id: L.id,
1390
+ return ((D = A.paragraphStyle) == null ? void 0 : D.horizontalAlign) === r;
1391
+ }), f = {
1392
+ id: B.id,
1379
1393
  params: {
1380
- unitId: g,
1394
+ unitId: m,
1381
1395
  actions: [],
1382
1396
  textRanges: l
1383
1397
  }
1384
- }, f = new se();
1385
- f.reset();
1386
- const S = new b();
1387
- for (const C of u) {
1388
- const { startIndex: D } = C;
1389
- S.push({
1398
+ }, h = new re();
1399
+ h.reset();
1400
+ const _ = new F(), p = b.getInstance();
1401
+ for (const A of u) {
1402
+ const { startIndex: D } = A;
1403
+ _.push({
1390
1404
  t: x.RETAIN,
1391
- len: D - f.cursor,
1392
- segmentId: m
1405
+ len: D - h.cursor,
1406
+ segmentId: g
1393
1407
  });
1394
- const A = {
1395
- ...C.paragraphStyle,
1396
- horizontalAlign: p ? re.UNSPECIFIED : r
1408
+ const N = {
1409
+ ...A.paragraphStyle,
1410
+ horizontalAlign: S ? ie.UNSPECIFIED : r
1397
1411
  };
1398
- S.push({
1412
+ _.push({
1399
1413
  t: x.RETAIN,
1400
1414
  len: 1,
1401
1415
  body: {
1402
1416
  dataStream: "",
1403
1417
  paragraphs: [
1404
1418
  {
1405
- ...C,
1406
- paragraphStyle: A,
1419
+ ...A,
1420
+ paragraphStyle: N,
1407
1421
  startIndex: 0
1408
1422
  }
1409
1423
  ]
1410
1424
  },
1411
- segmentId: m,
1412
- coverType: Ee.REPLACE
1413
- }), f.moveCursorTo(D + 1);
1425
+ segmentId: g,
1426
+ coverType: De.REPLACE
1427
+ }), h.moveCursorTo(D + 1);
1414
1428
  }
1415
- return h.params.actions = S.serialize(), !!s.syncExecuteCommand(h.id, h.params);
1429
+ return f.params.actions = p.editOp(_.serialize()), !!o.syncExecuteCommand(f.id, f.params);
1416
1430
  }
1417
- }, hn = {
1431
+ }, Sn = {
1418
1432
  id: "doc.command.align-left",
1419
- type: v.COMMAND,
1420
- handler: (o) => o.get(I).syncExecuteCommand(ie.id, {
1421
- alignType: re.LEFT
1433
+ type: I.COMMAND,
1434
+ handler: (s) => s.get(v).syncExecuteCommand(ae.id, {
1435
+ alignType: ie.LEFT
1422
1436
  })
1423
- }, pn = {
1437
+ }, _n = {
1424
1438
  id: "doc.command.align-center",
1425
- type: v.COMMAND,
1426
- handler: (o) => o.get(I).syncExecuteCommand(ie.id, {
1427
- alignType: re.CENTER
1439
+ type: I.COMMAND,
1440
+ handler: (s) => s.get(v).syncExecuteCommand(ae.id, {
1441
+ alignType: ie.CENTER
1428
1442
  })
1429
- }, Sn = {
1443
+ }, In = {
1430
1444
  id: "doc.command.align-right",
1431
- type: v.COMMAND,
1432
- handler: (o) => o.get(I).syncExecuteCommand(ie.id, {
1433
- alignType: re.RIGHT
1445
+ type: I.COMMAND,
1446
+ handler: (s) => s.get(v).syncExecuteCommand(ae.id, {
1447
+ alignType: ie.RIGHT
1434
1448
  })
1435
- }, _n = {
1449
+ }, vn = {
1436
1450
  id: "doc.command.align-justify",
1437
- type: v.COMMAND,
1438
- handler: (o) => o.get(I).syncExecuteCommand(ie.id, {
1439
- alignType: re.JUSTIFIED
1451
+ type: I.COMMAND,
1452
+ handler: (s) => s.get(v).syncExecuteCommand(ae.id, {
1453
+ alignType: ie.JUSTIFIED
1440
1454
  })
1441
- }, vn = {
1455
+ }, Mn = {
1442
1456
  id: "doc.command-replace-content",
1443
- type: v.COMMAND,
1444
- handler: async (o, e) => {
1445
- var g;
1446
- const { unitId: t, body: n, textRanges: s, segmentId: r = "" } = e, i = o.get(E), a = o.get(I), c = o.get(T), d = (g = i.getUniverDocInstance(t)) == null ? void 0 : g.getSnapshot().body, l = c.getSelections();
1457
+ type: I.COMMAND,
1458
+ handler: async (s, e) => {
1459
+ var m;
1460
+ const { unitId: t, body: n, textRanges: o, segmentId: r = "" } = e, i = s.get(E), a = s.get(v), c = s.get(T), d = (m = i.getUniverDocInstance(t)) == null ? void 0 : m.getSnapshot().body, l = c.getSelections();
1447
1461
  if (d == null || !Array.isArray(l) || l.length === 0)
1448
1462
  return !1;
1449
- const u = Ct(t, r, d, n);
1450
- return u.params.textRanges = s, !!a.syncExecuteCommand(u.id, u.params);
1463
+ const u = xt(t, r, d, n);
1464
+ return u.params.textRanges = o, !!a.syncExecuteCommand(u.id, u.params);
1451
1465
  }
1452
- }, In = {
1466
+ }, Cn = {
1453
1467
  id: "doc.command-cover-content",
1454
- type: v.COMMAND,
1455
- handler: async (o, e) => {
1468
+ type: I.COMMAND,
1469
+ handler: async (s, e) => {
1456
1470
  var l;
1457
- const { unitId: t, body: n, segmentId: s = "" } = e, r = o.get(E), i = o.get(I), a = o.get(Te), c = (l = r.getUniverDocInstance(t)) == null ? void 0 : l.getSnapshot().body;
1471
+ const { unitId: t, body: n, segmentId: o = "" } = e, r = s.get(E), i = s.get(v), a = s.get(Ee), c = (l = r.getUniverDocInstance(t)) == null ? void 0 : l.getSnapshot().body;
1458
1472
  if (c == null)
1459
1473
  return !1;
1460
- const d = Ct(t, s, c, n);
1474
+ const d = xt(t, o, c, n);
1461
1475
  return d.params.noNeedSetTextRange = !0, d.params.noHistory = !0, i.syncExecuteCommand(
1462
1476
  d.id,
1463
1477
  d.params
1464
1478
  ), a.clearUndoRedo(t), !0;
1465
1479
  }
1466
1480
  };
1467
- function Ct(o, e, t, n) {
1468
- const s = {
1469
- id: L.id,
1481
+ function xt(s, e, t, n) {
1482
+ const o = {
1483
+ id: B.id,
1470
1484
  params: {
1471
- unitId: o,
1485
+ unitId: s,
1472
1486
  actions: [],
1473
1487
  textRanges: []
1474
1488
  }
1475
- }, r = new b(), i = (t == null ? void 0 : t.dataStream.length) - 2;
1476
- return i > 0 && r.push({
1489
+ }, r = new F(), i = b.getInstance(), a = (t == null ? void 0 : t.dataStream.length) - 2;
1490
+ return a > 0 && r.push({
1477
1491
  t: x.DELETE,
1478
- len: i,
1492
+ len: a,
1479
1493
  line: 0,
1480
1494
  segmentId: e
1481
1495
  }), n.dataStream.length > 0 && r.push({
@@ -1484,27 +1498,27 @@ function Ct(o, e, t, n) {
1484
1498
  len: n.dataStream.length,
1485
1499
  line: 0,
1486
1500
  segmentId: e
1487
- }), s.params.actions = r.serialize(), s;
1501
+ }), o.params.actions = i.editOp(r.serialize()), o;
1488
1502
  }
1489
- const ye = {
1503
+ const Oe = {
1490
1504
  id: "doc.operation.move-cursor",
1491
- type: v.OPERATION,
1492
- handler: (o, e) => !!e
1493
- }, Oe = {
1505
+ type: I.OPERATION,
1506
+ handler: (s, e) => !!e
1507
+ }, Te = {
1494
1508
  id: "doc.operation.move-selection",
1495
- type: v.OPERATION,
1496
- handler: (o, e) => !!e
1497
- }, Mn = (o, e) => {
1498
- const t = o.get(E).getUniverDocInstance(e.unitId), n = (t == null ? void 0 : t.zoomRatio) || 1;
1509
+ type: I.OPERATION,
1510
+ handler: (s, e) => !!e
1511
+ }, Rn = (s, e) => {
1512
+ const t = s.get(E).getUniverDocInstance(e.unitId), n = (t == null ? void 0 : t.zoomRatio) || 1;
1499
1513
  return {
1500
- ...Q.deepClone(e),
1514
+ ...ee.deepClone(e),
1501
1515
  zoomRatio: n
1502
1516
  };
1503
- }, ce = {
1517
+ }, le = {
1504
1518
  id: "doc.operation.set-zoom-ratio",
1505
- type: v.OPERATION,
1506
- handler: (o, e) => {
1507
- const t = o.get(E).getUniverDocInstance(e.unitId);
1519
+ type: I.OPERATION,
1520
+ handler: (s, e) => {
1521
+ const t = s.get(E).getUniverDocInstance(e.unitId);
1508
1522
  if (!t)
1509
1523
  return !1;
1510
1524
  const n = t.getSnapshot();
@@ -1512,61 +1526,61 @@ const ye = {
1512
1526
  zoomRatio: e.zoomRatio
1513
1527
  } : n.settings.zoomRatio = e.zoomRatio, !0;
1514
1528
  }
1515
- }, Cn = {
1516
- type: v.COMMAND,
1529
+ }, xn = {
1530
+ type: I.COMMAND,
1517
1531
  id: "doc.command.set-zoom-ratio",
1518
- handler: async (o, e) => {
1519
- var u, m, g;
1520
- const t = o.get(I), n = o.get(Te), s = o.get(E);
1521
- let r = (u = s.getCurrentUniverDocInstance()) == null ? void 0 : u.getUnitId();
1532
+ handler: async (s, e) => {
1533
+ var u, g, m;
1534
+ const t = s.get(v), n = s.get(Ee), o = s.get(E);
1535
+ let r = (u = o.getCurrentUniverDocInstance()) == null ? void 0 : u.getUnitId();
1522
1536
  if (!r)
1523
1537
  return !1;
1524
1538
  let i = 1;
1525
- if (e && (r = (m = e.documentId) != null ? m : r, i = (g = e.zoomRatio) != null ? g : i), !s.getUniverDocInstance(r))
1539
+ if (e && (r = (g = e.documentId) != null ? g : r, i = (m = e.zoomRatio) != null ? m : i), !o.getUniverDocInstance(r))
1526
1540
  return !1;
1527
1541
  const c = {
1528
1542
  zoomRatio: i,
1529
1543
  unitId: r
1530
- }, d = Mn(o, c);
1531
- return t.syncExecuteCommand(ce.id, c) ? (n.pushUndoRedo({
1544
+ }, d = Rn(s, c);
1545
+ return t.syncExecuteCommand(le.id, c) ? (n.pushUndoRedo({
1532
1546
  unitID: r,
1533
- undoMutations: [{ id: ce.id, params: d }],
1534
- redoMutations: [{ id: ce.id, params: c }]
1547
+ undoMutations: [{ id: le.id, params: d }],
1548
+ redoMutations: [{ id: le.id, params: c }]
1535
1549
  }), !0) : !1;
1536
1550
  }
1537
- }, Rn = {
1551
+ }, yn = {
1538
1552
  id: "doc.operation.select-all",
1539
- type: v.COMMAND,
1540
- handler: async (o) => {
1541
- const e = o.get(E), t = o.get(T), n = e.getCurrentUniverDocInstance();
1553
+ type: I.COMMAND,
1554
+ handler: async (s) => {
1555
+ const e = s.get(E), t = s.get(T), n = e.getCurrentUniverDocInstance();
1542
1556
  if (!n)
1543
1557
  return !1;
1544
- const s = n.getSnapshot().body;
1545
- if (s == null)
1558
+ const o = n.getSnapshot().body;
1559
+ if (o == null)
1546
1560
  return !1;
1547
1561
  const r = [
1548
1562
  {
1549
1563
  startOffset: 0,
1550
- endOffset: s.dataStream.length - 2
1564
+ endOffset: o.dataStream.length - 2
1551
1565
  }
1552
1566
  ];
1553
1567
  return t.replaceTextRanges(r, !1), !0;
1554
1568
  }
1555
1569
  };
1556
- var xn = Object.defineProperty, yn = Object.getOwnPropertyDescriptor, On = (o, e, t, n) => {
1557
- for (var s = n > 1 ? void 0 : n ? yn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1558
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
1559
- return n && s && xn(e, t, s), s;
1560
- }, K = (o, e) => (t, n) => e(t, n, o);
1561
- let le = class extends Ne {
1562
- constructor(e, t, n, s, r) {
1570
+ var On = Object.defineProperty, Tn = Object.getOwnPropertyDescriptor, En = (s, e, t, n) => {
1571
+ for (var o = n > 1 ? void 0 : n ? Tn(e, t) : e, r = s.length - 1, i; r >= 0; r--)
1572
+ (i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
1573
+ return n && o && On(e, t, o), o;
1574
+ }, K = (s, e) => (t, n) => e(t, n, s);
1575
+ let de = class extends Pe {
1576
+ constructor(e, t, n, o, r) {
1563
1577
  super();
1564
1578
  y(this, "_previousIMEContent", "");
1565
1579
  y(this, "_isCompositionStart", !0);
1566
1580
  y(this, "_onStartSubscription");
1567
1581
  y(this, "_onUpdateSubscription");
1568
1582
  y(this, "_onEndSubscription");
1569
- this._docSkeletonManagerService = e, this._univerInstanceService = t, this._textSelectionRenderManager = n, this._imeInputManagerService = s, this._commandService = r, this._initialize();
1583
+ this._docSkeletonManagerService = e, this._univerInstanceService = t, this._textSelectionRenderManager = n, this._imeInputManagerService = o, this._commandService = r, this._initialize();
1570
1584
  }
1571
1585
  dispose() {
1572
1586
  var e, t, n;
@@ -1581,7 +1595,7 @@ let le = class extends Ne {
1581
1595
  return;
1582
1596
  this._resetIME();
1583
1597
  const { activeRange: t } = e;
1584
- t != null && this._imeInputManagerService.setActiveRange(Q.deepClone(t));
1598
+ t != null && this._imeInputManagerService.setActiveRange(ee.deepClone(t));
1585
1599
  });
1586
1600
  }
1587
1601
  _initialOnCompositionUpdate() {
@@ -1599,15 +1613,15 @@ let le = class extends Ne {
1599
1613
  const n = (d = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : d.skeleton;
1600
1614
  if (e == null || n == null)
1601
1615
  return;
1602
- const s = this._univerInstanceService.getCurrentUniverDocInstance();
1603
- if (!s)
1616
+ const o = this._univerInstanceService.getCurrentUniverDocInstance();
1617
+ if (!o)
1604
1618
  return;
1605
1619
  const { event: r, activeRange: i } = e;
1606
1620
  if (n == null || i == null)
1607
1621
  return;
1608
1622
  const c = r.data;
1609
- c === this._previousIMEContent && t || (await this._commandService.executeCommand(_t.id, {
1610
- unitId: s.getUnitId(),
1623
+ c === this._previousIMEContent && t || (await this._commandService.executeCommand(vt.id, {
1624
+ unitId: o.getUnitId(),
1611
1625
  newText: c,
1612
1626
  oldTextLen: this._previousIMEContent.length,
1613
1627
  isCompositionStart: this._isCompositionStart,
@@ -1618,40 +1632,40 @@ let le = class extends Ne {
1618
1632
  this._previousIMEContent = "", this._isCompositionStart = !0, this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(null);
1619
1633
  }
1620
1634
  };
1621
- le = On([
1622
- De(Ae.Rendered, le),
1623
- K(0, V(H)),
1635
+ de = En([
1636
+ Ae(Ne.Rendered, de),
1637
+ K(0, k(H)),
1624
1638
  K(1, E),
1625
- K(2, fe),
1626
- K(3, V(he)),
1627
- K(4, I)
1628
- ], le);
1629
- var Tn = Object.defineProperty, En = Object.getOwnPropertyDescriptor, Dn = (o, e, t, n) => {
1630
- for (var s = n > 1 ? void 0 : n ? En(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1631
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
1632
- return n && s && Tn(e, t, s), s;
1633
- }, J = (o, e) => (t, n) => e(t, n, o);
1634
- let de = class extends Ne {
1635
- constructor(e, t, n, s, r) {
1639
+ K(2, he),
1640
+ K(3, k(pe)),
1641
+ K(4, v)
1642
+ ], de);
1643
+ var Dn = Object.defineProperty, An = Object.getOwnPropertyDescriptor, Nn = (s, e, t, n) => {
1644
+ for (var o = n > 1 ? void 0 : n ? An(e, t) : e, r = s.length - 1, i; r >= 0; r--)
1645
+ (i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
1646
+ return n && o && Dn(e, t, o), o;
1647
+ }, q = (s, e) => (t, n) => e(t, n, s);
1648
+ let ue = class extends Pe {
1649
+ constructor(e, t, n, o, r) {
1636
1650
  super();
1637
1651
  y(this, "_onInputSubscription");
1638
- this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionManagerService = s, this._commandService = r, this._commandExecutedListener();
1652
+ this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionManagerService = o, this._commandService = r, this._commandExecutedListener();
1639
1653
  }
1640
1654
  dispose() {
1641
1655
  var e;
1642
1656
  super.dispose(), (e = this._onInputSubscription) == null || e.unsubscribe();
1643
1657
  }
1644
1658
  _commandExecutedListener() {
1645
- const e = [ye.id, Oe.id];
1659
+ const e = [Oe.id, Te.id];
1646
1660
  this.disposeWithMe(
1647
1661
  this._commandService.onCommandExecuted((t) => {
1648
1662
  if (!e.includes(t.id))
1649
1663
  return;
1650
1664
  const n = t.params;
1651
1665
  switch (t.id) {
1652
- case ye.id:
1653
- return this._handleMoveCursor(n.direction);
1654
1666
  case Oe.id:
1667
+ return this._handleMoveCursor(n.direction);
1668
+ case Te.id:
1655
1669
  return this._handleShiftMoveSelection(n.direction);
1656
1670
  default:
1657
1671
  throw new Error("Unknown command");
@@ -1660,114 +1674,114 @@ let de = class extends Ne {
1660
1674
  );
1661
1675
  }
1662
1676
  _handleShiftMoveSelection(e) {
1663
- var h, f, S;
1664
- const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), s = this._univerInstanceService.getCurrentUniverDocInstance();
1665
- if (!s)
1677
+ var f, h, _;
1678
+ const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), o = this._univerInstanceService.getCurrentUniverDocInstance();
1679
+ if (!o)
1666
1680
  return;
1667
- const r = (h = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : h.skeleton, i = this._getDocObject();
1681
+ const r = (f = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : f.skeleton, i = this._getDocObject();
1668
1682
  if (t == null || r == null || i == null)
1669
1683
  return;
1670
1684
  const { startOffset: a, endOffset: c, style: d, collapsed: l, direction: u } = t;
1671
1685
  if (n.length > 1) {
1672
- let _ = Number.POSITIVE_INFINITY, R = Number.NEGATIVE_INFINITY;
1673
- for (const M of n)
1674
- _ = Math.min(_, M.startOffset), R = Math.max(R, M.endOffset);
1686
+ let p = Number.POSITIVE_INFINITY, R = Number.NEGATIVE_INFINITY;
1687
+ for (const C of n)
1688
+ p = Math.min(p, C.startOffset), R = Math.max(R, C.endOffset);
1675
1689
  this._textSelectionManagerService.replaceTextRanges([
1676
1690
  {
1677
- startOffset: e === N.LEFT || e === N.UP ? R : _,
1678
- endOffset: e === N.LEFT || e === N.UP ? _ : R,
1691
+ startOffset: e === P.LEFT || e === P.UP ? R : p,
1692
+ endOffset: e === P.LEFT || e === P.UP ? p : R,
1679
1693
  style: d
1680
1694
  }
1681
1695
  ], !1);
1682
1696
  return;
1683
1697
  }
1684
- const m = l || u === Ze.FORWARD ? a : c;
1685
- let g = l || u === Ze.FORWARD ? c : a;
1686
- const p = (f = s.getBody().dataStream.length) != null ? f : Number.POSITIVE_INFINITY;
1687
- if (e === N.LEFT || e === N.RIGHT) {
1688
- const _ = r.findNodeByCharIndex(g - 1), R = r.findNodeByCharIndex(g);
1689
- g = e === N.RIGHT ? g + R.count : g - ((S = _ == null ? void 0 : _.count) != null ? S : 0), g = Math.min(p - 2, Math.max(0, g)), this._textSelectionManagerService.replaceTextRanges([
1698
+ const g = l || u === Ke.FORWARD ? a : c;
1699
+ let m = l || u === Ke.FORWARD ? c : a;
1700
+ const S = (h = o.getBody().dataStream.length) != null ? h : Number.POSITIVE_INFINITY;
1701
+ if (e === P.LEFT || e === P.RIGHT) {
1702
+ const p = r.findNodeByCharIndex(m - 1), R = r.findNodeByCharIndex(m);
1703
+ m = e === P.RIGHT ? m + R.count : m - ((_ = p == null ? void 0 : p.count) != null ? _ : 0), m = Math.min(S - 2, Math.max(0, m)), this._textSelectionManagerService.replaceTextRanges([
1690
1704
  {
1691
- startOffset: m,
1692
- endOffset: g,
1705
+ startOffset: g,
1706
+ endOffset: m,
1693
1707
  style: d
1694
1708
  }
1695
1709
  ], !1);
1696
1710
  } else {
1697
- const _ = r.findNodeByCharIndex(g), R = i.document.getOffsetConfig(), M = this._getTopOrBottomPosition(r, _, e === N.DOWN);
1698
- if (M == null) {
1699
- const D = e === N.UP ? 0 : p - 2;
1700
- if (D === g)
1711
+ const p = r.findNodeByCharIndex(m), R = i.document.getOffsetConfig(), C = this._getTopOrBottomPosition(r, p, e === P.DOWN);
1712
+ if (C == null) {
1713
+ const A = e === P.UP ? 0 : S - 2;
1714
+ if (A === m)
1701
1715
  return;
1702
1716
  this._textSelectionManagerService.replaceTextRanges([
1703
1717
  {
1704
- startOffset: m,
1705
- endOffset: D,
1718
+ startOffset: g,
1719
+ endOffset: A,
1706
1720
  style: d
1707
1721
  }
1708
1722
  ], !1);
1709
1723
  return;
1710
1724
  }
1711
- const C = new Ke(R, r).getRangePointData(
1712
- M,
1713
- M
1725
+ const M = new qe(R, r).getRangePointData(
1726
+ C,
1727
+ C
1714
1728
  ).cursorList[0];
1715
1729
  this._textSelectionManagerService.replaceTextRanges([
1716
1730
  {
1717
- startOffset: m,
1718
- endOffset: C.endOffset,
1731
+ startOffset: g,
1732
+ endOffset: M.endOffset,
1719
1733
  style: d
1720
1734
  }
1721
1735
  ], !1);
1722
1736
  }
1723
1737
  }
1724
1738
  _handleMoveCursor(e) {
1725
- var m, g, p;
1726
- const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), s = this._univerInstanceService.getCurrentUniverDocInstance();
1727
- if (!s)
1739
+ var g, m, S;
1740
+ const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), o = this._univerInstanceService.getCurrentUniverDocInstance();
1741
+ if (!o)
1728
1742
  return !1;
1729
- const r = (m = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : m.skeleton, i = this._getDocObject();
1743
+ const r = (g = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : g.skeleton, i = this._getDocObject();
1730
1744
  if (t == null || r == null || i == null || n == null)
1731
1745
  return;
1732
- const { startOffset: a, endOffset: c, style: d, collapsed: l } = t, u = (g = s.getBody().dataStream.length) != null ? g : Number.POSITIVE_INFINITY;
1733
- if (e === N.LEFT || e === N.RIGHT) {
1734
- let h;
1746
+ const { startOffset: a, endOffset: c, style: d, collapsed: l } = t, u = (m = o.getBody().dataStream.length) != null ? m : Number.POSITIVE_INFINITY;
1747
+ if (e === P.LEFT || e === P.RIGHT) {
1748
+ let f;
1735
1749
  if (!t.collapsed || n.length > 1) {
1736
- let f = Number.POSITIVE_INFINITY, S = Number.NEGATIVE_INFINITY;
1737
- for (const _ of n)
1738
- f = Math.min(f, _.startOffset), S = Math.max(S, _.endOffset);
1739
- h = e === N.LEFT ? f : S;
1750
+ let h = Number.POSITIVE_INFINITY, _ = Number.NEGATIVE_INFINITY;
1751
+ for (const p of n)
1752
+ h = Math.min(h, p.startOffset), _ = Math.max(_, p.endOffset);
1753
+ f = e === P.LEFT ? h : _;
1740
1754
  } else {
1741
- const f = r.findNodeByCharIndex(a - 1), S = r.findNodeByCharIndex(a);
1742
- e === N.LEFT ? h = Math.max(0, a - ((p = f == null ? void 0 : f.count) != null ? p : 0)) : h = Math.min(u - 2, c + S.count);
1755
+ const h = r.findNodeByCharIndex(a - 1), _ = r.findNodeByCharIndex(a);
1756
+ e === P.LEFT ? f = Math.max(0, a - ((S = h == null ? void 0 : h.count) != null ? S : 0)) : f = Math.min(u - 2, c + _.count);
1743
1757
  }
1744
1758
  this._textSelectionManagerService.replaceTextRanges([
1745
1759
  {
1746
- startOffset: h,
1747
- endOffset: h,
1760
+ startOffset: f,
1761
+ endOffset: f,
1748
1762
  style: d
1749
1763
  }
1750
1764
  ], !1);
1751
1765
  } else {
1752
- const h = r.findNodeByCharIndex(a), f = r.findNodeByCharIndex(c), S = i.document.getOffsetConfig(), _ = this._getTopOrBottomPosition(
1766
+ const f = r.findNodeByCharIndex(a), h = r.findNodeByCharIndex(c), _ = i.document.getOffsetConfig(), p = this._getTopOrBottomPosition(
1753
1767
  r,
1754
- e === N.UP ? h : f,
1755
- e === N.DOWN
1768
+ e === P.UP ? f : h,
1769
+ e === P.DOWN
1756
1770
  );
1757
- if (_ == null) {
1758
- let M;
1759
- l ? M = e === N.UP ? 0 : u - 2 : M = e === N.UP ? a : c, this._textSelectionManagerService.replaceTextRanges([
1771
+ if (p == null) {
1772
+ let C;
1773
+ l ? C = e === P.UP ? 0 : u - 2 : C = e === P.UP ? a : c, this._textSelectionManagerService.replaceTextRanges([
1760
1774
  {
1761
- startOffset: M,
1762
- endOffset: M,
1775
+ startOffset: C,
1776
+ endOffset: C,
1763
1777
  style: d
1764
1778
  }
1765
1779
  ], !1);
1766
1780
  return;
1767
1781
  }
1768
- const R = new Ke(S, r).getRangePointData(
1769
- _,
1770
- _
1782
+ const R = new qe(_, r).getRangePointData(
1783
+ p,
1784
+ p
1771
1785
  ).cursorList[0];
1772
1786
  this._textSelectionManagerService.replaceTextRanges([
1773
1787
  {
@@ -1780,10 +1794,10 @@ let de = class extends Ne {
1780
1794
  _getTopOrBottomPosition(e, t, n) {
1781
1795
  if (t == null)
1782
1796
  return;
1783
- const s = this._getSpanLeftOffsetInLine(t), r = this._getNextOrPrevLine(t, n);
1797
+ const o = this._getSpanLeftOffsetInLine(t), r = this._getNextOrPrevLine(t, n);
1784
1798
  if (r == null)
1785
1799
  return;
1786
- const i = this._matchPositionByLeftOffset(e, r, s);
1800
+ const i = this._matchPositionByLeftOffset(e, r, o);
1787
1801
  if (i != null)
1788
1802
  return { ...i, isBack: !0 };
1789
1803
  }
@@ -1791,35 +1805,35 @@ let de = class extends Ne {
1791
1805
  const t = e.parent;
1792
1806
  if (t == null)
1793
1807
  return Number.NEGATIVE_INFINITY;
1794
- const n = t.left, { left: s } = e;
1795
- return n + s;
1808
+ const n = t.left, { left: o } = e;
1809
+ return n + o;
1796
1810
  }
1797
1811
  _matchPositionByLeftOffset(e, t, n) {
1798
- const s = {
1812
+ const o = {
1799
1813
  distance: Number.POSITIVE_INFINITY
1800
1814
  };
1801
1815
  for (const r of t.divides) {
1802
1816
  const i = r.left;
1803
1817
  for (const a of r.glyphGroup) {
1804
1818
  const { left: c } = a, d = i + c, l = Math.abs(n - d);
1805
- l < s.distance && (s.glyph = a, s.distance = l);
1819
+ l < o.distance && (o.glyph = a, o.distance = l);
1806
1820
  }
1807
1821
  }
1808
- if (s.glyph != null)
1809
- return e.findPositionByGlyph(s.glyph);
1822
+ if (o.glyph != null)
1823
+ return e.findPositionByGlyph(o.glyph);
1810
1824
  }
1811
1825
  _getNextOrPrevLine(e, t) {
1812
- var p, h, f, S, _, R, M, C, D, A, P, B;
1826
+ var S, f, h, _, p, R, C, M, A, D, N, L;
1813
1827
  const n = e.parent;
1814
1828
  if (n == null)
1815
1829
  return;
1816
- const s = n.parent;
1817
- if (s == null)
1830
+ const o = n.parent;
1831
+ if (o == null)
1818
1832
  return;
1819
- const r = s.parent;
1833
+ const r = o.parent;
1820
1834
  if (r == null)
1821
1835
  return;
1822
- const i = r.lines.indexOf(s);
1836
+ const i = r.lines.indexOf(o);
1823
1837
  if (i === -1)
1824
1838
  return;
1825
1839
  let a;
@@ -1832,9 +1846,9 @@ let de = class extends Ne {
1832
1846
  if (d === -1)
1833
1847
  return;
1834
1848
  if (t === !0)
1835
- a = (p = c.columns[d + 1]) == null ? void 0 : p.lines[0];
1849
+ a = (S = c.columns[d + 1]) == null ? void 0 : S.lines[0];
1836
1850
  else {
1837
- const O = (f = (h = c.columns) == null ? void 0 : h[d - 1]) == null ? void 0 : f.lines;
1851
+ const O = (h = (f = c.columns) == null ? void 0 : f[d - 1]) == null ? void 0 : h.lines;
1838
1852
  a = O == null ? void 0 : O[O.length - 1];
1839
1853
  }
1840
1854
  if (a != null)
@@ -1846,53 +1860,53 @@ let de = class extends Ne {
1846
1860
  if (u === -1)
1847
1861
  return;
1848
1862
  if (t === !0)
1849
- a = (_ = (S = l.sections[u - 1]) == null ? void 0 : S.columns[0]) == null ? void 0 : _.lines[0];
1863
+ a = (p = (_ = l.sections[u - 1]) == null ? void 0 : _.columns[0]) == null ? void 0 : p.lines[0];
1850
1864
  else {
1851
- const O = (M = (R = l.sections) == null ? void 0 : R[u - 1]) == null ? void 0 : M.columns, U = O == null ? void 0 : O[O.length - 1], w = U == null ? void 0 : U.lines;
1865
+ const O = (C = (R = l.sections) == null ? void 0 : R[u - 1]) == null ? void 0 : C.columns, U = O == null ? void 0 : O[O.length - 1], w = U == null ? void 0 : U.lines;
1852
1866
  a = w == null ? void 0 : w[w.length - 1];
1853
1867
  }
1854
1868
  if (a != null)
1855
1869
  return a;
1856
- const m = l.parent;
1857
- if (m == null)
1870
+ const g = l.parent;
1871
+ if (g == null)
1858
1872
  return;
1859
- const g = m.pages.indexOf(l);
1860
- if (g !== -1) {
1873
+ const m = g.pages.indexOf(l);
1874
+ if (m !== -1) {
1861
1875
  if (t === !0)
1862
- a = (A = (D = (C = m.pages[g + 1]) == null ? void 0 : C.sections[0]) == null ? void 0 : D.columns[0]) == null ? void 0 : A.lines[0];
1876
+ a = (D = (A = (M = g.pages[m + 1]) == null ? void 0 : M.sections[0]) == null ? void 0 : A.columns[0]) == null ? void 0 : D.lines[0];
1863
1877
  else {
1864
- const O = (P = m.pages[g - 1]) == null ? void 0 : P.sections;
1878
+ const O = (N = g.pages[m - 1]) == null ? void 0 : N.sections;
1865
1879
  if (O == null)
1866
1880
  return;
1867
- const U = (B = O[O.length - 1]) == null ? void 0 : B.columns, w = U[U.length - 1], X = w == null ? void 0 : w.lines;
1868
- a = X[X.length - 1];
1881
+ const U = (L = O[O.length - 1]) == null ? void 0 : L.columns, w = U[U.length - 1], Y = w == null ? void 0 : w.lines;
1882
+ a = Y[Y.length - 1];
1869
1883
  }
1870
1884
  if (a != null)
1871
1885
  return a;
1872
1886
  }
1873
1887
  }
1874
1888
  _getDocObject() {
1875
- return Gt(this._univerInstanceService, this._renderManagerService);
1889
+ return Xt(this._univerInstanceService, this._renderManagerService);
1876
1890
  }
1877
1891
  };
1878
- de = Dn([
1879
- De(Ae.Rendered, de),
1880
- J(0, V(H)),
1881
- J(1, E),
1882
- J(2, gt),
1883
- J(3, V(T)),
1884
- J(4, I)
1885
- ], de);
1886
- var An = Object.defineProperty, Nn = Object.getOwnPropertyDescriptor, Pn = (o, e, t, n) => {
1887
- for (var s = n > 1 ? void 0 : n ? Nn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1888
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
1889
- return n && s && An(e, t, s), s;
1890
- }, q = (o, e) => (t, n) => e(t, n, o);
1891
- let ue = class extends Ne {
1892
- constructor(e, t, n, s, r) {
1892
+ ue = Nn([
1893
+ Ae(Ne.Rendered, ue),
1894
+ q(0, k(H)),
1895
+ q(1, E),
1896
+ q(2, ht),
1897
+ q(3, k(T)),
1898
+ q(4, v)
1899
+ ], ue);
1900
+ var Pn = Object.defineProperty, bn = Object.getOwnPropertyDescriptor, Un = (s, e, t, n) => {
1901
+ for (var o = n > 1 ? void 0 : n ? bn(e, t) : e, r = s.length - 1, i; r >= 0; r--)
1902
+ (i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
1903
+ return n && o && Pn(e, t, o), o;
1904
+ }, Q = (s, e) => (t, n) => e(t, n, s);
1905
+ let ge = class extends Pe {
1906
+ constructor(e, t, n, o, r) {
1893
1907
  super();
1894
1908
  y(this, "_onInputSubscription");
1895
- this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionRenderManager = s, this._commandService = r, this._init();
1909
+ this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionRenderManager = o, this._commandService = r, this._init();
1896
1910
  }
1897
1911
  dispose() {
1898
1912
  var e;
@@ -1903,172 +1917,172 @@ let ue = class extends Ne {
1903
1917
  }
1904
1918
  _initialNormalInput() {
1905
1919
  this._onInputSubscription = this._textSelectionRenderManager.onInput$.subscribe(async (e) => {
1906
- var p;
1920
+ var S;
1907
1921
  if (e == null)
1908
1922
  return;
1909
1923
  const t = this._univerInstanceService.getCurrentUniverDocInstance();
1910
1924
  if (!t)
1911
1925
  return;
1912
- const n = t.getUnitId(), { event: s, content: r = "", activeRange: i } = e, a = s, c = (p = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : p.skeleton;
1926
+ const n = t.getUnitId(), { event: o, content: r = "", activeRange: i } = e, a = o, c = (S = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : S.skeleton;
1913
1927
  if (a.data == null || c == null || !c || !i)
1914
1928
  return;
1915
- const { startOffset: d, segmentId: l, style: u } = i, m = r.length, g = [
1929
+ const { startOffset: d, segmentId: l, style: u } = i, g = r.length, m = [
1916
1930
  {
1917
- startOffset: d + m,
1918
- endOffset: d + m,
1931
+ startOffset: d + g,
1932
+ endOffset: d + g,
1919
1933
  style: u
1920
1934
  }
1921
1935
  ];
1922
- await this._commandService.executeCommand(pe.id, {
1936
+ await this._commandService.executeCommand(Se.id, {
1923
1937
  unitId: n,
1924
1938
  body: {
1925
1939
  dataStream: r
1926
1940
  },
1927
1941
  range: i,
1928
- textRanges: g,
1942
+ textRanges: m,
1929
1943
  segmentId: l
1930
1944
  });
1931
1945
  });
1932
1946
  }
1933
1947
  };
1934
- ue = Pn([
1935
- De(Ae.Rendered, ue),
1936
- q(0, V(H)),
1937
- q(1, E),
1938
- q(2, gt),
1939
- q(3, fe),
1940
- q(4, I)
1941
- ], ue);
1942
- var bn = Object.defineProperty, Un = Object.getOwnPropertyDescriptor, wn = (o, e, t, n) => {
1943
- for (var s = n > 1 ? void 0 : n ? Un(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1944
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
1945
- return n && s && bn(e, t, s), s;
1946
- }, Ln = (o, e) => (t, n) => e(t, n, o);
1947
- const Bn = "docs";
1948
- var ae;
1949
- let dt = (ae = class extends Nt {
1950
- constructor(o = {}, e) {
1948
+ ge = Un([
1949
+ Ae(Ne.Rendered, ge),
1950
+ Q(0, k(H)),
1951
+ Q(1, E),
1952
+ Q(2, ht),
1953
+ Q(3, he),
1954
+ Q(4, v)
1955
+ ], ge);
1956
+ var wn = Object.defineProperty, Ln = Object.getOwnPropertyDescriptor, Bn = (s, e, t, n) => {
1957
+ for (var o = n > 1 ? void 0 : n ? Ln(e, t) : e, r = s.length - 1, i; r >= 0; r--)
1958
+ (i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
1959
+ return n && o && wn(e, t, o), o;
1960
+ }, Fn = (s, e) => (t, n) => e(t, n, s);
1961
+ const $n = "docs";
1962
+ var ce;
1963
+ let gt = (ce = class extends bt {
1964
+ constructor(s = {}, e) {
1951
1965
  super(), this._injector = e, this._initializeDependencies(e), this._initializeCommands();
1952
1966
  }
1953
1967
  _initializeCommands() {
1954
1968
  [
1955
- ye,
1956
1969
  Oe,
1957
- cn,
1958
- ln,
1959
- we,
1970
+ Te,
1971
+ dn,
1972
+ un,
1960
1973
  Le,
1961
1974
  Be,
1962
1975
  Fe,
1963
- oe,
1964
1976
  $e,
1977
+ oe,
1965
1978
  Ve,
1966
1979
  ke,
1967
1980
  ze,
1968
1981
  je,
1982
+ Xe,
1969
1983
  Ge,
1970
- It,
1971
- nn,
1972
- pe,
1984
+ Ct,
1985
+ on,
1973
1986
  Se,
1974
- ht,
1975
- _t,
1976
- Ue,
1977
- L,
1978
- vn,
1979
- In,
1987
+ _e,
1988
+ St,
1989
+ vt,
1990
+ we,
1991
+ B,
1992
+ Mn,
1980
1993
  Cn,
1981
- ce,
1982
- ft,
1983
- Rn,
1984
- fn,
1985
- gn,
1986
- He,
1987
- hn,
1994
+ xn,
1995
+ le,
1996
+ pt,
1997
+ yn,
1988
1998
  pn,
1999
+ hn,
2000
+ He,
1989
2001
  Sn,
1990
- ie,
1991
- _n
1992
- ].forEach((o) => {
1993
- this._injector.get(I).registerCommand(o);
2002
+ _n,
2003
+ In,
2004
+ ae,
2005
+ vn
2006
+ ].forEach((s) => {
2007
+ this._injector.get(v).registerCommand(s);
1994
2008
  });
1995
2009
  }
1996
- _initializeDependencies(o) {
2010
+ _initializeDependencies(s) {
1997
2011
  [
1998
2012
  // services
1999
2013
  [H],
2000
- [ne],
2014
+ [se],
2001
2015
  [me],
2002
- [he],
2016
+ [pe],
2003
2017
  [
2004
- fe,
2018
+ he,
2005
2019
  {
2006
- useClass: Vt
2020
+ useClass: zt
2007
2021
  }
2008
2022
  ],
2009
2023
  [T],
2010
2024
  // controllers
2011
- [ue],
2012
- [le],
2013
- [de]
2014
- ].forEach((e) => o.add(e));
2015
- }
2016
- }, y(ae, "pluginName", Bn), y(ae, "type", W.UNIVER_DOC), ae);
2017
- dt = wn([
2018
- Ln(1, V(kt))
2019
- ], dt);
2025
+ [ge],
2026
+ [de],
2027
+ [ue]
2028
+ ].forEach((e) => s.add(e));
2029
+ }
2030
+ }, y(ce, "pluginName", $n), y(ce, "type", Z.UNIVER_DOC), ce);
2031
+ gt = Bn([
2032
+ Fn(1, k(jt))
2033
+ ], gt);
2020
2034
  export {
2021
- pn as AlignCenterCommand,
2022
- _n as AlignJustifyCommand,
2023
- hn as AlignLeftCommand,
2024
- ie as AlignOperationCommand,
2025
- Sn as AlignRightCommand,
2026
- nn as BreakLineCommand,
2027
- gn as BulletListCommand,
2028
- In as CoverContentCommand,
2029
- pt as CutContentCommand,
2030
- Gn as DOCS_COMPONENT_BACKGROUND_LAYER_INDEX,
2031
- Xn as DOCS_COMPONENT_DEFAULT_Z_INDEX,
2032
- Hn as DOCS_COMPONENT_HEADER_LAYER_INDEX,
2033
- jn as DOCS_COMPONENT_MAIN_LAYER_INDEX,
2034
- Pe as DOCS_VIEW_KEY,
2035
- Se as DeleteCommand,
2036
- cn as DeleteLeftCommand,
2037
- ln as DeleteRightCommand,
2035
+ _n as AlignCenterCommand,
2036
+ vn as AlignJustifyCommand,
2037
+ Sn as AlignLeftCommand,
2038
+ ae as AlignOperationCommand,
2039
+ In as AlignRightCommand,
2040
+ on as BreakLineCommand,
2041
+ hn as BulletListCommand,
2042
+ Cn as CoverContentCommand,
2043
+ _t as CutContentCommand,
2044
+ Xn as DOCS_COMPONENT_BACKGROUND_LAYER_INDEX,
2045
+ Wn as DOCS_COMPONENT_DEFAULT_Z_INDEX,
2046
+ Yn as DOCS_COMPONENT_HEADER_LAYER_INDEX,
2047
+ Hn as DOCS_COMPONENT_MAIN_LAYER_INDEX,
2048
+ be as DOCS_VIEW_KEY,
2049
+ _e as DeleteCommand,
2050
+ dn as DeleteLeftCommand,
2051
+ un as DeleteRightCommand,
2038
2052
  H as DocSkeletonManagerService,
2039
2053
  me as DocStateChangeManagerService,
2040
- ne as DocViewModelManagerService,
2041
- _t as IMEInputCommand,
2042
- he as IMEInputManagerService,
2043
- Zn as InnerPasteCommand,
2044
- pe as InsertCommand,
2045
- ye as MoveCursorOperation,
2046
- Oe as MoveSelectionOperation,
2047
- Yn as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
2048
- fn as OrderListCommand,
2049
- vn as ReplaceContentCommand,
2050
- je as ResetInlineFormatTextBackgroundColorCommand,
2051
- L as RichTextEditingMutation,
2052
- Rn as SelectAllOperation,
2053
- Cn as SetDocZoomRatioCommand,
2054
- ce as SetDocZoomRatioOperation,
2055
- we as SetInlineFormatBoldCommand,
2056
- It as SetInlineFormatCommand,
2057
- ke as SetInlineFormatFontFamilyCommand,
2058
- Ve as SetInlineFormatFontSizeCommand,
2059
- Le as SetInlineFormatItalicCommand,
2060
- Fe as SetInlineFormatStrikethroughCommand,
2054
+ se as DocViewModelManagerService,
2055
+ vt as IMEInputCommand,
2056
+ pe as IMEInputManagerService,
2057
+ Kn as InnerPasteCommand,
2058
+ Se as InsertCommand,
2059
+ Oe as MoveCursorOperation,
2060
+ Te as MoveSelectionOperation,
2061
+ Zn as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
2062
+ pn as OrderListCommand,
2063
+ Mn as ReplaceContentCommand,
2064
+ Xe as ResetInlineFormatTextBackgroundColorCommand,
2065
+ B as RichTextEditingMutation,
2066
+ yn as SelectAllOperation,
2067
+ xn as SetDocZoomRatioCommand,
2068
+ le as SetDocZoomRatioOperation,
2069
+ Le as SetInlineFormatBoldCommand,
2070
+ Ct as SetInlineFormatCommand,
2071
+ ze as SetInlineFormatFontFamilyCommand,
2072
+ ke as SetInlineFormatFontSizeCommand,
2073
+ Be as SetInlineFormatItalicCommand,
2074
+ $e as SetInlineFormatStrikethroughCommand,
2061
2075
  oe as SetInlineFormatSubscriptCommand,
2062
- $e as SetInlineFormatSuperscriptCommand,
2076
+ Ve as SetInlineFormatSuperscriptCommand,
2063
2077
  Ge as SetInlineFormatTextBackgroundColorCommand,
2064
- ze as SetInlineFormatTextColorCommand,
2065
- Be as SetInlineFormatUnderlineCommand,
2066
- ft as SetTextSelectionsOperation,
2078
+ je as SetInlineFormatTextColorCommand,
2079
+ Fe as SetInlineFormatUnderlineCommand,
2080
+ pt as SetTextSelectionsOperation,
2067
2081
  T as TextSelectionManagerService,
2068
- dt as UniverDocsPlugin,
2069
- ht as UpdateCommand,
2070
- zt as VIEWPORT_KEY,
2071
- Gt as getDocObject,
2072
- Wn as getDocObjectById,
2073
- Z as serializeTextRange
2082
+ gt as UniverDocsPlugin,
2083
+ St as UpdateCommand,
2084
+ Gt as VIEWPORT_KEY,
2085
+ Xt as getDocObject,
2086
+ Jn as getDocObjectById,
2087
+ J as serializeTextRange
2074
2088
  };