@univerjs/docs 0.1.7 → 0.1.9

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