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