@univerjs/docs 0.1.15 → 0.1.16

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