@univerjs/docs 0.1.16 → 0.1.17

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