@univerjs/docs 0.1.0-beta.2 → 0.1.0-beta.3

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,12 +1,12 @@
1
- var Ft = Object.defineProperty;
2
- var kt = (i, e, t) => e in i ? Ft(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var S = (i, e, t) => (kt(i, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { CommandType as R, RxDisposable as me, ICommandService as x, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Z, IUniverInstanceService as O, IUndoRedoService as N, DataStreamTreeTokenType as Xe, Tools as re, FOCUSING_DOC as w, FOCUSING_EDITOR as fe, LocaleService as xt, MemoryCursor as Ae, getDocsUpdateBody as zt, UpdateDocsAttributeType as Ot, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as K, BooleanNumber as D, BaselineOffset as j, PresetListType as yt, LRUMap as Wt, ColorKit as ot, Disposable as W, toDisposable as qe, OnLifecycle as V, LifecycleStages as F, ILogService as Ht, IContextService as Gt, DEFAULT_DOCUMENT_SUB_COMPONENT_ID as Xt, IFloatingObjectManagerService as qt, Direction as b, IConfigService as bt, Plugin as Yt, PluginType as Zt } from "@univerjs/core";
5
- import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as Kt, ITextSelectionRenderManager as _e, DocumentViewModel as Jt, DocumentSkeleton as Qt, hasListSpan as en, isIndentBySpan as tn, isFirstSpan as nn, getParagraphBySpan as rn, PageLayoutType as at, IRenderManagerService as H, Liquid as sn, RANGE_DIRECTION as ct, NodePositionConvertToCursor as lt, Rect as on, CURSOR_TYPE as dt, Viewport as an, EVENT_TYPE as cn, ScrollBar as ln, Layer as ut, Documents as dn, TextSelectionRenderManager as un } from "@univerjs/engine-render";
6
- import { BehaviorSubject as de, takeUntil as Se } from "rxjs";
7
- import { CopyCommand as hn, CutCommand as pn, PasteCommand as gn, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as mn, HTML_CLIPBOARD_MIME_TYPE as fn, IClipboardInterfaceService as _n, LayoutService as Sn, KeyCode as $, MetaKeys as ve, IShortcutService as vn } from "@univerjs/ui";
8
- import { Inject as U, createIdentifier as Mn, Optional as Cn, Injector as Rn } from "@wendellhu/redi";
9
- function Ne(i, e) {
1
+ var kt = Object.defineProperty;
2
+ var zt = (i, e, t) => e in i ? kt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var S = (i, e, t) => (zt(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { CommandType as I, RxDisposable as me, ICommandService as O, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as K, IUniverInstanceService as y, IUndoRedoService as A, TextX as H, DataStreamTreeTokenType as Ye, Tools as ie, FOCUSING_DOC as N, EDITOR_ACTIVATED as _e, LocaleService as Ot, MemoryCursor as Ae, getDocsUpdateBody as Wt, UpdateDocsAttributeType as yt, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as J, BooleanNumber as E, BaselineOffset as V, PresetListType as bt, LRUMap as Ht, ColorKit as at, Disposable as X, toDisposable as qe, OnLifecycle as F, LifecycleStages as j, ILogService as Xt, IContextService as Gt, DEFAULT_DOCUMENT_SUB_COMPONENT_ID as Yt, IFloatingObjectManagerService as qt, Direction as D, IConfigService as Tt, Plugin as Zt, PluginType as Kt } from "@univerjs/core";
5
+ import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as Jt, ITextSelectionRenderManager as Se, DocumentViewModel as Qt, DocumentSkeleton as en, hasListSpan as tn, isIndentBySpan as nn, isFirstSpan as rn, getParagraphBySpan as sn, PageLayoutType as ct, IRenderManagerService as G, Liquid as on, RANGE_DIRECTION as lt, NodePositionConvertToCursor as dt, Rect as an, CURSOR_TYPE as ut, Viewport as cn, EVENT_TYPE as ln, ScrollBar as dn, Layer as ht, Documents as un, TextSelectionRenderManager as hn } from "@univerjs/engine-render";
6
+ import { BehaviorSubject as ue, takeUntil as ve } from "rxjs";
7
+ import { CopyCommand as gn, CutCommand as pn, PasteCommand as fn, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as mn, HTML_CLIPBOARD_MIME_TYPE as _n, IClipboardInterfaceService as Sn, LayoutService as vn, KeyCode as $, MetaKeys as Me, IShortcutService as Mn } from "@univerjs/ui";
8
+ import { Inject as w, createIdentifier as Cn, Optional as In, Injector as Rn } from "@wendellhu/redi";
9
+ function $e(i, e) {
10
10
  const n = i.getCurrentUniverDocInstance().getUnitId(), r = e.getRenderById(n);
11
11
  if (r == null)
12
12
  return;
@@ -17,7 +17,7 @@ function Ne(i, e) {
17
17
  engine: a
18
18
  };
19
19
  }
20
- function In(i, e) {
20
+ function xn(i, e) {
21
21
  const t = e.getRenderById(i);
22
22
  if (t == null)
23
23
  return;
@@ -28,18 +28,18 @@ function In(i, e) {
28
28
  engine: s
29
29
  };
30
30
  }
31
- var Ye = /* @__PURE__ */ ((i) => (i.MAIN = "__Document_Render_Main__", i))(Ye || {}), Je = /* @__PURE__ */ ((i) => (i.VIEW_MAIN = "viewMain", i.VIEW_TOP = "viewTop", i.VIEW_LEFT = "viewLeft", i.VIEW_LEFT_TOP = "viewLeftTop", i))(Je || {});
32
- const ht = 0, xn = 2, On = 10, hi = "normalTextSelectionPluginName", Dt = {
31
+ var Ze = /* @__PURE__ */ ((i) => (i.MAIN = "__Document_Render_Main__", i))(Ze || {}), Qe = /* @__PURE__ */ ((i) => (i.VIEW_MAIN = "viewMain", i.VIEW_TOP = "viewTop", i.VIEW_LEFT = "viewLeft", i.VIEW_LEFT_TOP = "viewLeftTop", i))(Qe || {});
32
+ const gt = 0, On = 2, yn = 10, gi = "normalTextSelectionPluginName", Dt = {
33
33
  id: "doc.operation.set-selections",
34
- type: R.OPERATION,
34
+ type: I.OPERATION,
35
35
  handler: (i, e) => !0
36
36
  };
37
- var yn = Object.defineProperty, bn = Object.getOwnPropertyDescriptor, Dn = (i, e, t, n) => {
38
- for (var r = n > 1 ? void 0 : n ? bn(e, t) : e, s = i.length - 1, o; s >= 0; s--)
37
+ var bn = Object.defineProperty, Tn = Object.getOwnPropertyDescriptor, Dn = (i, e, t, n) => {
38
+ for (var r = n > 1 ? void 0 : n ? Tn(e, t) : e, s = i.length - 1, o; s >= 0; s--)
39
39
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
40
- return n && r && yn(e, t, r), r;
40
+ return n && r && bn(e, t, r), r;
41
41
  }, pt = (i, e) => (t, n) => e(t, n, i);
42
- function gt(i) {
42
+ function ft(i) {
43
43
  const { startOffset: e, endOffset: t, collapsed: n } = i;
44
44
  return {
45
45
  startOffset: e,
@@ -47,12 +47,12 @@ function gt(i) {
47
47
  collapsed: n
48
48
  };
49
49
  }
50
- let P = class extends me {
50
+ let U = class extends me {
51
51
  constructor(e, t) {
52
52
  super();
53
53
  S(this, "_currentSelection", null);
54
54
  S(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
55
- S(this, "_textSelection$", new de(null));
55
+ S(this, "_textSelection$", new ue(null));
56
56
  S(this, "textSelection$", this._textSelection$.asObservable());
57
57
  this._textSelectionRenderManager = e, this._commandService = t, this._syncSelectionFromRenderService();
58
58
  }
@@ -84,17 +84,17 @@ let P = class extends me {
84
84
  const e = this._getTextRanges(this._currentSelection);
85
85
  if (e == null)
86
86
  return;
87
- const { textRanges: t, segmentId: n, style: r } = e, s = t.find((h) => h.isActive());
87
+ const { textRanges: t, segmentId: n, style: r } = e, s = t.find((g) => g.isActive());
88
88
  if (s == null)
89
89
  return null;
90
- const { startOffset: o, endOffset: a, collapsed: c, startNodePosition: d, endNodePosition: l, direction: p } = s;
90
+ const { startOffset: o, endOffset: a, collapsed: c, startNodePosition: d, endNodePosition: l, direction: h } = s;
91
91
  return o == null || a == null ? null : {
92
92
  startOffset: o,
93
93
  endOffset: a,
94
94
  collapsed: c,
95
95
  startNodePosition: d,
96
96
  endNodePosition: l,
97
- direction: p,
97
+ direction: h,
98
98
  segmentId: n,
99
99
  style: r
100
100
  };
@@ -105,7 +105,7 @@ let P = class extends me {
105
105
  ...this._currentSelection,
106
106
  textRanges: e,
107
107
  segmentId: "",
108
- style: Kt
108
+ style: Jt
109
109
  // mock style.
110
110
  });
111
111
  }
@@ -114,7 +114,7 @@ let P = class extends me {
114
114
  }
115
115
  // All textRanges should be synchronized from the render layer.
116
116
  _syncSelectionFromRenderService() {
117
- this._textSelectionRenderManager.textSelectionInner$.pipe(Se(this.dispose$)).subscribe((e) => {
117
+ this._textSelectionRenderManager.textSelectionInner$.pipe(ve(this.dispose$)).subscribe((e) => {
118
118
  e != null && this._replaceTextRangesWithNoRefresh(e);
119
119
  });
120
120
  }
@@ -132,7 +132,7 @@ let P = class extends me {
132
132
  subUnitId: r,
133
133
  segmentId: s,
134
134
  style: o,
135
- ranges: a.map(gt)
135
+ ranges: a.map(ft)
136
136
  });
137
137
  }
138
138
  _getTextRanges(e) {
@@ -144,7 +144,7 @@ let P = class extends me {
144
144
  }
145
145
  _refresh(e) {
146
146
  const t = this._getTextRanges(e);
147
- this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(gt));
147
+ this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(ft));
148
148
  }
149
149
  _replaceByParam(e) {
150
150
  const { unitId: t, subUnitId: n, style: r, segmentId: s, textRanges: o } = e;
@@ -157,11 +157,11 @@ let P = class extends me {
157
157
  a.has(n) ? a.get(n).textRanges.push(...r) : a.set(n, { textRanges: r, style: s, segmentId: o });
158
158
  }
159
159
  };
160
- P = Dn([
161
- pt(0, _e),
162
- pt(1, x)
163
- ], P);
164
- function $e(i, e = "", t = 0) {
160
+ U = Dn([
161
+ pt(0, Se),
162
+ pt(1, O)
163
+ ], U);
164
+ function Be(i, e = "", t = 0) {
165
165
  const { startOffset: n, endOffset: r } = i, s = [], o = n - t, a = r - t;
166
166
  return o > 0 && s.push({
167
167
  t: "r",
@@ -174,22 +174,22 @@ function $e(i, e = "", t = 0) {
174
174
  segmentId: e
175
175
  }), s;
176
176
  }
177
- var Tn = Object.defineProperty, Pn = Object.getOwnPropertyDescriptor, En = (i, e, t, n) => {
178
- for (var r = n > 1 ? void 0 : n ? Pn(e, t) : e, s = i.length - 1, o; s >= 0; s--)
177
+ var Pn = Object.defineProperty, En = Object.getOwnPropertyDescriptor, Un = (i, e, t, n) => {
178
+ for (var r = n > 1 ? void 0 : n ? En(e, t) : e, s = i.length - 1, o; s >= 0; s--)
179
179
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
180
- return n && r && Tn(e, t, r), r;
181
- }, Un = (i, e) => (t, n) => e(t, n, i);
182
- let ie = class extends me {
180
+ return n && r && Pn(e, t, r), r;
181
+ }, wn = (i, e) => (t, n) => e(t, n, i);
182
+ let se = class extends me {
183
183
  constructor(e) {
184
184
  super();
185
185
  S(this, "_currentViewModelUnitId", "");
186
186
  S(this, "_docViewModelMap", /* @__PURE__ */ new Map());
187
- S(this, "_currentDocViewModel$", new de(null));
187
+ S(this, "_currentDocViewModel$", new ue(null));
188
188
  S(this, "currentDocViewModel$", this._currentDocViewModel$.asObservable());
189
189
  this._currentUniverService = e, this._initialize();
190
190
  }
191
191
  _initialize() {
192
- this._currentUniverService.currentDoc$.pipe(Se(this.dispose$)).subscribe((e) => {
192
+ this._currentUniverService.currentDoc$.pipe(ve(this.dispose$)).subscribe((e) => {
193
193
  if (e == null)
194
194
  return;
195
195
  const t = e.getUnitId();
@@ -219,7 +219,7 @@ let ie = class extends me {
219
219
  docViewModel: r
220
220
  });
221
221
  }
222
- if (e === Z) {
222
+ if (e === K) {
223
223
  const r = (n = this._docViewModelMap.get(e)) == null ? void 0 : n.docViewModel;
224
224
  if (r == null)
225
225
  return;
@@ -229,17 +229,17 @@ let ie = class extends me {
229
229
  }
230
230
  }
231
231
  _buildDocViewModel(e) {
232
- return new Jt(e);
232
+ return new Qt(e);
233
233
  }
234
234
  };
235
- ie = En([
236
- Un(0, O)
237
- ], ie);
235
+ se = Un([
236
+ wn(0, y)
237
+ ], se);
238
238
  const _ = {
239
239
  id: "doc.mutation.rich-text-editing",
240
- type: R.MUTATION,
240
+ type: I.MUTATION,
241
241
  handler: (i, e) => {
242
- const { unitId: t, mutations: n } = e, s = i.get(O).getUniverDocInstance(t), a = i.get(ie).getViewModel(t);
242
+ const { unitId: t, mutations: n } = e, s = i.get(y).getUniverDocInstance(t), a = i.get(se).getViewModel(t);
243
243
  if (s == null || a == null)
244
244
  throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${t}`);
245
245
  if (n.length === 0)
@@ -250,130 +250,130 @@ const _ = {
250
250
  mutations: c
251
251
  };
252
252
  }
253
- }, Qe = {
253
+ }, et = {
254
254
  id: "doc.command.insert-text",
255
- type: R.COMMAND,
255
+ type: I.COMMAND,
256
256
  handler: async (i, e) => {
257
- const t = i.get(N), n = i.get(x), r = i.get(P), { range: s, segmentId: o, body: a, unitId: c, textRanges: d } = e, { startOffset: l, collapsed: p } = s, h = {
257
+ const t = i.get(A), n = i.get(O), r = i.get(U), { range: s, segmentId: o, body: a, unitId: c, textRanges: d } = e, { startOffset: l, collapsed: h } = s, g = {
258
258
  id: _.id,
259
259
  params: {
260
260
  unitId: c,
261
261
  mutations: []
262
262
  }
263
- };
264
- p ? l > 0 && h.params.mutations.push({
263
+ }, u = new H();
264
+ h ? l > 0 && u.push({
265
265
  t: "r",
266
266
  len: l,
267
267
  segmentId: o
268
- }) : h.params.mutations.push(...$e(s, o)), h.params.mutations.push({
268
+ }) : u.push(...Be(s, o)), u.push({
269
269
  t: "i",
270
270
  body: a,
271
271
  len: a.dataStream.length,
272
272
  line: 0,
273
273
  segmentId: o
274
- });
275
- const u = n.syncExecuteCommand(h.id, h.params);
276
- return r.replaceTextRanges(d), u ? (t.pushUndoRedo({
274
+ }), g.params.mutations = u.serialize();
275
+ const p = n.syncExecuteCommand(g.id, g.params);
276
+ return r.replaceTextRanges(d), p ? (t.pushUndoRedo({
277
277
  unitID: c,
278
- undoMutations: [{ id: _.id, params: u }],
279
- redoMutations: [{ id: _.id, params: h.params }],
278
+ undoMutations: [{ id: _.id, params: p }],
279
+ redoMutations: [{ id: _.id, params: g.params }],
280
280
  undo() {
281
- return n.syncExecuteCommand(_.id, u), r.replaceTextRanges([s]), !0;
281
+ return n.syncExecuteCommand(_.id, p), r.replaceTextRanges([s]), !0;
282
282
  },
283
283
  redo() {
284
- return n.syncExecuteCommand(_.id, h.params), r.replaceTextRanges(d), !0;
284
+ return n.syncExecuteCommand(_.id, g.params), r.replaceTextRanges(d), !0;
285
285
  }
286
286
  }), !0) : !1;
287
287
  }
288
288
  };
289
- var X = /* @__PURE__ */ ((i) => (i[i.LEFT = 0] = "LEFT", i[i.RIGHT = 1] = "RIGHT", i))(X || {});
290
- const et = {
289
+ var Y = /* @__PURE__ */ ((i) => (i[i.LEFT = 0] = "LEFT", i[i.RIGHT = 1] = "RIGHT", i))(Y || {});
290
+ const tt = {
291
291
  id: "doc.command.delete-text",
292
- type: R.COMMAND,
292
+ type: I.COMMAND,
293
293
  handler: async (i, e) => {
294
- const t = i.get(x), n = i.get(N), r = i.get(P), { range: s, segmentId: o, unitId: a, direction: c, textRanges: d, len: l = 1 } = e, { startOffset: p } = s, h = {
294
+ const t = i.get(O), n = i.get(A), r = i.get(U), { range: s, segmentId: o, unitId: a, direction: c, textRanges: d, len: l = 1 } = e, { startOffset: h } = s, g = {
295
295
  id: _.id,
296
296
  params: {
297
297
  unitId: a,
298
298
  mutations: []
299
299
  }
300
- };
301
- p > 0 && h.params.mutations.push({
300
+ }, u = new H();
301
+ h > 0 && u.push({
302
302
  t: "r",
303
- len: c === 0 ? p - l : p,
303
+ len: c === 0 ? h - l : h,
304
304
  segmentId: o
305
- }), h.params.mutations.push({
305
+ }), u.push({
306
306
  t: "d",
307
307
  len: l,
308
308
  line: 0,
309
309
  segmentId: o
310
- });
311
- const u = t.syncExecuteCommand(h.id, h.params);
312
- return r.replaceTextRanges(d), u && n.pushUndoRedo({
310
+ }), g.params.mutations = u.serialize();
311
+ const p = t.syncExecuteCommand(g.id, g.params);
312
+ return r.replaceTextRanges(d), p && n.pushUndoRedo({
313
313
  unitID: a,
314
- undoMutations: [{ id: _.id, params: u }],
315
- redoMutations: [{ id: _.id, params: h.params }],
314
+ undoMutations: [{ id: _.id, params: p }],
315
+ redoMutations: [{ id: _.id, params: g.params }],
316
316
  undo() {
317
- return t.syncExecuteCommand(_.id, u), r.replaceTextRanges([s]), !0;
317
+ return t.syncExecuteCommand(_.id, p), r.replaceTextRanges([s]), !0;
318
318
  },
319
319
  redo() {
320
- return t.syncExecuteCommand(_.id, h.params), r.replaceTextRanges(d), !0;
320
+ return t.syncExecuteCommand(_.id, g.params), r.replaceTextRanges(d), !0;
321
321
  }
322
322
  }), !1;
323
323
  }
324
- }, Tt = {
324
+ }, Pt = {
325
325
  id: "doc.command.update-text",
326
- type: R.COMMAND,
326
+ type: I.COMMAND,
327
327
  handler: async (i, e) => {
328
- const { range: t, segmentId: n, updateBody: r, coverType: s, unitId: o, textRanges: a } = e, c = i.get(x), d = i.get(N), l = i.get(P), p = {
328
+ const { range: t, segmentId: n, updateBody: r, coverType: s, unitId: o, textRanges: a } = e, c = i.get(O), d = i.get(A), l = i.get(U), h = {
329
329
  id: _.id,
330
330
  params: {
331
331
  unitId: o,
332
332
  mutations: []
333
333
  }
334
- }, { startOffset: h, endOffset: u } = t;
335
- p.params.mutations.push({
334
+ }, g = new H(), { startOffset: u, endOffset: p } = t;
335
+ g.push({
336
336
  t: "r",
337
- len: h,
337
+ len: u,
338
338
  segmentId: n
339
- }), p.params.mutations.push({
339
+ }), g.push({
340
340
  t: "r",
341
341
  body: r,
342
- len: u - h,
342
+ len: p - u,
343
343
  segmentId: n,
344
344
  coverType: s
345
- });
346
- const g = c.syncExecuteCommand(p.id, p.params);
347
- return l.replaceTextRanges(a), g ? (d.pushUndoRedo({
345
+ }), h.params.mutations = g.serialize();
346
+ const f = c.syncExecuteCommand(h.id, h.params);
347
+ return l.replaceTextRanges(a), f ? (d.pushUndoRedo({
348
348
  unitID: o,
349
- undoMutations: [{ id: _.id, params: g }],
350
- redoMutations: [{ id: _.id, params: p.params }],
349
+ undoMutations: [{ id: _.id, params: f }],
350
+ redoMutations: [{ id: _.id, params: h.params }],
351
351
  undo() {
352
- return c.syncExecuteCommand(_.id, g), l.replaceTextRanges(a), !0;
352
+ return c.syncExecuteCommand(_.id, f), l.replaceTextRanges(a), !0;
353
353
  },
354
354
  redo() {
355
- return c.syncExecuteCommand(_.id, p.params), l.replaceTextRanges(a), !0;
355
+ return c.syncExecuteCommand(_.id, h.params), l.replaceTextRanges(a), !0;
356
356
  }
357
357
  }), !0) : !1;
358
358
  }
359
359
  };
360
- function wn(i, e) {
360
+ function Nn(i, e) {
361
361
  const t = [];
362
362
  for (let n = 0, r = i.length; n < r; n++)
363
- i[n] === Xe.PARAGRAPH && t.push({
363
+ i[n] === Ye.PARAGRAPH && t.push({
364
364
  startIndex: n
365
365
  });
366
366
  if (e)
367
367
  for (const n of t)
368
- e.bullet && (n.bullet = re.deepClone(e.bullet)), e.paragraphStyle && (n.paragraphStyle = re.deepClone(e.paragraphStyle));
368
+ e.bullet && (n.bullet = ie.deepClone(e.bullet)), e.paragraphStyle && (n.paragraphStyle = ie.deepClone(e.paragraphStyle));
369
369
  return t;
370
370
  }
371
- const Pt = {
371
+ const Et = {
372
372
  id: "doc.command.break-line",
373
- type: R.COMMAND,
373
+ type: I.COMMAND,
374
374
  handler: async (i) => {
375
- var g;
376
- const e = i.get(P), t = i.get(O), n = i.get(x), r = e.getActiveRange();
375
+ var p;
376
+ const e = i.get(U), t = i.get(y), n = i.get(O), r = e.getActiveRange();
377
377
  if (r == null)
378
378
  return !1;
379
379
  const s = t.getCurrentUniverDocInstance(), o = s.getUnitId(), { startOffset: a, segmentId: c, style: d } = r, l = [
@@ -382,62 +382,62 @@ const Pt = {
382
382
  endOffset: a + 1,
383
383
  style: d
384
384
  }
385
- ], h = (((g = s.getBody()) == null ? void 0 : g.paragraphs) ?? []).find((m) => m.startIndex >= a);
386
- return await n.executeCommand(Qe.id, {
385
+ ], g = (((p = s.getBody()) == null ? void 0 : p.paragraphs) ?? []).find((f) => f.startIndex >= a);
386
+ return await n.executeCommand(et.id, {
387
387
  unitId: o,
388
388
  body: {
389
- dataStream: Xe.PARAGRAPH,
390
- paragraphs: wn(Xe.PARAGRAPH, h)
389
+ dataStream: Ye.PARAGRAPH,
390
+ paragraphs: Nn(Ye.PARAGRAPH, g)
391
391
  },
392
392
  range: r,
393
393
  textRanges: l,
394
394
  segmentId: c
395
395
  });
396
396
  }
397
- }, ke = {
398
- id: hn.id,
397
+ }, ze = {
398
+ id: gn.id,
399
399
  name: "doc.command.copy",
400
- type: R.COMMAND,
400
+ type: I.COMMAND,
401
401
  multi: !0,
402
402
  priority: 999,
403
- preconditions: (i) => i.getContextValue(w) || i.getContextValue(fe),
403
+ preconditions: (i) => i.getContextValue(N) || i.getContextValue(_e),
404
404
  handler: async () => !0
405
- }, ze = {
405
+ }, We = {
406
406
  id: pn.id,
407
407
  name: "doc.command.cut",
408
- type: R.COMMAND,
408
+ type: I.COMMAND,
409
409
  multi: !0,
410
410
  priority: 999,
411
- preconditions: (i) => i.getContextValue(w) || i.getContextValue(fe),
411
+ preconditions: (i) => i.getContextValue(N) || i.getContextValue(_e),
412
412
  handler: async () => !0
413
- }, We = {
414
- id: gn.id,
413
+ }, He = {
414
+ id: fn.id,
415
415
  name: "doc.command.paste",
416
- type: R.COMMAND,
416
+ type: I.COMMAND,
417
417
  multi: !0,
418
418
  priority: 999,
419
- preconditions: (i) => i.getContextValue(w) || i.getContextValue(fe),
419
+ preconditions: (i) => i.getContextValue(N) || i.getContextValue(_e),
420
420
  handler: async () => !0
421
421
  };
422
- var Ln = Object.defineProperty, An = Object.getOwnPropertyDescriptor, Nn = (i, e, t, n) => {
422
+ var Ln = Object.defineProperty, An = Object.getOwnPropertyDescriptor, $n = (i, e, t, n) => {
423
423
  for (var r = n > 1 ? void 0 : n ? An(e, t) : e, s = i.length - 1, o; s >= 0; s--)
424
424
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
425
425
  return n && r && Ln(e, t, r), r;
426
426
  }, mt = (i, e) => (t, n) => e(t, n, i);
427
- let A = class extends me {
427
+ let L = class extends me {
428
428
  constructor(e, t) {
429
429
  super();
430
430
  S(this, "_currentSkeletonUnitId", "");
431
431
  S(this, "_docSkeletonMap", /* @__PURE__ */ new Map());
432
- S(this, "_currentSkeleton$", new de(null));
432
+ S(this, "_currentSkeleton$", new ue(null));
433
433
  S(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
434
434
  // CurrentSkeletonBefore for pre-triggered logic during registration
435
- S(this, "_currentSkeletonBefore$", new de(null));
435
+ S(this, "_currentSkeletonBefore$", new ue(null));
436
436
  S(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
437
437
  this._localeService = e, this._docViewModelManagerService = t, this._initialize();
438
438
  }
439
439
  _initialize() {
440
- this._docViewModelManagerService.currentDocViewModel$.pipe(Se(this.dispose$)).subscribe((e) => {
440
+ this._docViewModelManagerService.currentDocViewModel$.pipe(ve(this.dispose$)).subscribe((e) => {
441
441
  e != null && this._setCurrent(e);
442
442
  });
443
443
  }
@@ -473,68 +473,68 @@ let A = class extends me {
473
473
  return this._currentSkeletonUnitId = t, this._currentSkeletonBefore$.next(this.getCurrent()), this._currentSkeleton$.next(this.getCurrent()), this.getCurrent();
474
474
  }
475
475
  _buildSkeleton(e) {
476
- return Qt.create(e, this._localeService);
476
+ return en.create(e, this._localeService);
477
477
  }
478
478
  };
479
- A = Nn([
480
- mt(0, U(xt)),
481
- mt(1, U(ie))
482
- ], A);
483
- const ft = {
479
+ L = $n([
480
+ mt(0, w(Ot)),
481
+ mt(1, w(se))
482
+ ], L);
483
+ const _t = {
484
484
  id: "doc.command.inner-paste",
485
- type: R.COMMAND,
485
+ type: I.COMMAND,
486
486
  handler: async (i, e) => {
487
- const { segmentId: t, body: n, textRanges: r } = e, s = i.get(N), o = i.get(x), a = i.get(P), c = i.get(O), d = a.getSelections();
487
+ const { segmentId: t, body: n, textRanges: r } = e, s = i.get(A), o = i.get(O), a = i.get(U), c = i.get(y), d = a.getSelections();
488
488
  if (!Array.isArray(d) || d.length === 0)
489
489
  return !1;
490
- const p = c.getCurrentUniverDocInstance().getUnitId(), h = {
490
+ const h = c.getCurrentUniverDocInstance().getUnitId(), g = {
491
491
  id: _.id,
492
492
  params: {
493
- unitId: p,
493
+ unitId: h,
494
494
  mutations: []
495
495
  }
496
496
  }, u = new Ae();
497
497
  u.reset();
498
+ const p = new H();
498
499
  for (const m of d) {
499
- const { startOffset: f, endOffset: v, collapsed: M } = m, T = f - u.cursor;
500
- M ? h.params.mutations.push({
500
+ const { startOffset: v, endOffset: M, collapsed: b } = m, T = v - u.cursor;
501
+ b ? p.push({
501
502
  t: "r",
502
503
  len: T,
503
504
  segmentId: t
504
- }) : h.params.mutations.push(
505
- ...$e(m, t, u.cursor)
506
- ), h.params.mutations.push({
505
+ }) : p.push(...Be(m, t, u.cursor)), p.push({
507
506
  t: "i",
508
507
  body: n,
509
508
  len: n.dataStream.length,
510
509
  line: 0,
511
510
  segmentId: t
512
- }), u.reset(), u.moveCursor(v);
511
+ }), u.reset(), u.moveCursor(M);
513
512
  }
514
- const g = o.syncExecuteCommand(h.id, h.params);
515
- return a.replaceTextRanges(r), g ? (s.pushUndoRedo({
516
- unitID: p,
517
- undoMutations: [{ id: _.id, params: g }],
518
- redoMutations: [{ id: _.id, params: h.params }],
513
+ g.params.mutations = p.serialize();
514
+ const f = o.syncExecuteCommand(g.id, g.params);
515
+ return a.replaceTextRanges(r), f ? (s.pushUndoRedo({
516
+ unitID: h,
517
+ undoMutations: [{ id: _.id, params: f }],
518
+ redoMutations: [{ id: _.id, params: g.params }],
519
519
  undo() {
520
- return o.syncExecuteCommand(_.id, g), a.replaceTextRanges(d), !0;
520
+ return o.syncExecuteCommand(_.id, f), a.replaceTextRanges(d), !0;
521
521
  },
522
522
  redo() {
523
- return o.syncExecuteCommand(_.id, h.params), a.replaceTextRanges(r), !0;
523
+ return o.syncExecuteCommand(_.id, g.params), a.replaceTextRanges(r), !0;
524
524
  }
525
525
  }), !0) : !1;
526
526
  }
527
- }, we = {
527
+ }, Ne = {
528
528
  id: "doc.command.inner-cut",
529
- type: R.COMMAND,
529
+ type: I.COMMAND,
530
530
  handler: async (i, e) => {
531
- const { segmentId: t, textRanges: n } = e, r = i.get(N), s = i.get(x), o = i.get(P), a = i.get(O), c = o.getSelections();
531
+ const { segmentId: t, textRanges: n } = e, r = i.get(A), s = i.get(O), o = i.get(U), a = i.get(y), c = o.getSelections();
532
532
  if (!Array.isArray(c) || c.length === 0)
533
533
  return !1;
534
- const d = a.getCurrentUniverDocInstance().getUnitId(), l = a.getUniverDocInstance(d), p = zt(l.snapshot, t);
535
- if (p == null)
534
+ const d = a.getCurrentUniverDocInstance().getUnitId(), l = a.getUniverDocInstance(d), h = Wt(l.snapshot, t);
535
+ if (h == null)
536
536
  return !1;
537
- const h = {
537
+ const g = {
538
538
  id: _.id,
539
539
  params: {
540
540
  unitId: d,
@@ -542,52 +542,52 @@ const ft = {
542
542
  }
543
543
  }, u = new Ae();
544
544
  u.reset();
545
+ const p = new H();
545
546
  for (const m of c) {
546
- const { startOffset: f, endOffset: v, collapsed: M } = m, T = f - u.cursor;
547
- M ? h.params.mutations.push({
547
+ const { startOffset: v, endOffset: M, collapsed: b } = m, T = v - u.cursor;
548
+ b ? p.push({
548
549
  t: "r",
549
550
  len: T,
550
551
  segmentId: t
551
- }) : h.params.mutations.push(
552
- ...$n(m, p, t, u.cursor)
553
- ), u.reset(), u.moveCursor(v);
552
+ }) : p.push(...Bn(m, h, t, u.cursor)), u.reset(), u.moveCursor(M);
554
553
  }
555
- const g = s.syncExecuteCommand(h.id, h.params);
556
- return o.replaceTextRanges(n), g ? (r.pushUndoRedo({
554
+ g.params.mutations = p.serialize();
555
+ const f = s.syncExecuteCommand(g.id, g.params);
556
+ return o.replaceTextRanges(n), f ? (r.pushUndoRedo({
557
557
  unitID: d,
558
- undoMutations: [{ id: _.id, params: g }],
559
- redoMutations: [{ id: _.id, params: h.params }],
558
+ undoMutations: [{ id: _.id, params: f }],
559
+ redoMutations: [{ id: _.id, params: g.params }],
560
560
  undo() {
561
- return s.syncExecuteCommand(_.id, g), o.replaceTextRanges(c), !0;
561
+ return s.syncExecuteCommand(_.id, f), o.replaceTextRanges(c), !0;
562
562
  },
563
563
  redo() {
564
- return s.syncExecuteCommand(_.id, h.params), o.replaceTextRanges(n), !0;
564
+ return s.syncExecuteCommand(_.id, g.params), o.replaceTextRanges(n), !0;
565
565
  }
566
566
  }), !0) : !1;
567
567
  }
568
568
  };
569
- function $n(i, e, t = "", n = 0) {
569
+ function Bn(i, e, t = "", n = 0) {
570
570
  const { startOffset: r, endOffset: s } = i, o = [], { paragraphs: a = [] } = e, c = r - n, d = s - n, l = a == null ? void 0 : a.find(
571
- (p) => p.startIndex - n >= c && p.startIndex - n <= d
571
+ (h) => h.startIndex - n >= c && h.startIndex - n <= d
572
572
  );
573
573
  if (c > 0 && o.push({
574
574
  t: "r",
575
575
  len: c,
576
576
  segmentId: t
577
577
  }), l && l.startIndex - n > c) {
578
- const p = l.startIndex - n;
578
+ const h = l.startIndex - n;
579
579
  o.push({
580
580
  t: "d",
581
- len: p - c,
581
+ len: h - c,
582
582
  line: 0,
583
583
  segmentId: t
584
584
  }), o.push({
585
585
  t: "r",
586
586
  len: 1,
587
587
  segmentId: t
588
- }), d > p + 1 && o.push({
588
+ }), d > h + 1 && o.push({
589
589
  t: "d",
590
- len: d - p - 1,
590
+ len: d - h - 1,
591
591
  line: 0,
592
592
  segmentId: t
593
593
  });
@@ -600,32 +600,29 @@ function $n(i, e, t = "", n = 0) {
600
600
  });
601
601
  return o;
602
602
  }
603
- const Et = {
603
+ const Ut = {
604
604
  id: "doc.command.delete-left",
605
- type: R.COMMAND,
605
+ type: I.COMMAND,
606
606
  handler: async (i) => {
607
- var y;
608
- const e = i.get(P), t = i.get(A), n = i.get(O), r = i.get(x), s = e.getActiveRange(), o = e.getSelections(), a = (y = t.getCurrent()) == null ? void 0 : y.skeleton;
609
- let c;
607
+ var T;
608
+ const e = i.get(U), t = i.get(L), n = i.get(y), r = i.get(O), s = e.getActiveRange(), o = e.getSelections(), a = (T = t.getCurrent()) == null ? void 0 : T.skeleton;
609
+ let c = !0;
610
610
  if (s == null || a == null || o == null)
611
611
  return !1;
612
- const d = n.getCurrentUniverDocInstance(), { startOffset: l, collapsed: p, segmentId: h, style: u } = s;
613
- if (l === 0 && p)
614
- return !0;
615
- const g = a.findNodeByCharIndex(l), m = en(g), f = tn(g, d.body);
612
+ const d = n.getCurrentUniverDocInstance(), { startOffset: l, collapsed: h, segmentId: g, style: u } = s, p = a.findNodeByCharIndex(l), f = tn(p), m = nn(p, d.getBody());
616
613
  let v = l;
617
614
  const M = a.findNodeByCharIndex(l - 1);
618
- if (nn(g) && M !== g && (m === !0 || f === !0)) {
619
- const C = rn(g, d.body);
615
+ if (rn(p) && M !== p && (f === !0 || m === !0)) {
616
+ const C = sn(p, d.getBody());
620
617
  if (C == null)
621
618
  return !1;
622
- const E = C == null ? void 0 : C.startIndex, L = { startIndex: 0 }, B = C.paragraphStyle;
623
- if (m === !0) {
624
- const I = C.paragraphStyle;
625
- I && (L.paragraphStyle = I);
626
- } else if (f === !0) {
627
- const I = C.bullet;
628
- I && (L.bullet = I), B != null && (L.paragraphStyle = { ...B }, delete L.paragraphStyle.hanging, delete L.paragraphStyle.indentStart);
619
+ const x = C == null ? void 0 : C.startIndex, P = { startIndex: 0 }, B = C.paragraphStyle;
620
+ if (f === !0) {
621
+ const R = C.paragraphStyle;
622
+ R && (P.paragraphStyle = R);
623
+ } else if (m === !0) {
624
+ const R = C.bullet;
625
+ R && (P.bullet = R), B != null && (P.paragraphStyle = { ...B }, delete P.paragraphStyle.hanging, delete P.paragraphStyle.indentStart);
629
626
  }
630
627
  const k = [
631
628
  {
@@ -634,24 +631,26 @@ const Et = {
634
631
  style: u
635
632
  }
636
633
  ];
637
- c = await r.executeCommand(Tt.id, {
634
+ c = await r.executeCommand(Pt.id, {
638
635
  unitId: d.getUnitId(),
639
636
  updateBody: {
640
637
  dataStream: "",
641
- paragraphs: [{ ...L }]
638
+ paragraphs: [{ ...P }]
642
639
  },
643
640
  range: {
644
- startOffset: E,
645
- endOffset: E + 1
641
+ startOffset: x,
642
+ endOffset: x + 1
646
643
  },
647
644
  textRanges: k,
648
- coverType: Ot.REPLACE,
649
- segmentId: h
645
+ coverType: yt.REPLACE,
646
+ segmentId: g
650
647
  });
651
- } else if (p === !0)
648
+ } else if (h === !0) {
649
+ if (M == null)
650
+ return !0;
652
651
  if (M.content === "\r")
653
- c = await r.executeCommand(tt.id, {
654
- direction: X.LEFT,
652
+ c = await r.executeCommand(nt.id, {
653
+ direction: Y.LEFT,
655
654
  range: s
656
655
  });
657
656
  else {
@@ -663,128 +662,128 @@ const Et = {
663
662
  style: u
664
663
  }
665
664
  ];
666
- c = await r.executeCommand(et.id, {
665
+ c = await r.executeCommand(tt.id, {
667
666
  unitId: d.getUnitId(),
668
667
  range: s,
669
- segmentId: h,
670
- direction: X.LEFT,
668
+ segmentId: g,
669
+ direction: Y.LEFT,
671
670
  len: M.count,
672
671
  textRanges: C
673
672
  });
674
673
  }
675
- else {
676
- const C = wt(s, o);
677
- c = await r.executeCommand(we.id, {
678
- segmentId: h,
674
+ } else {
675
+ const C = Nt(s, o);
676
+ c = await r.executeCommand(Ne.id, {
677
+ segmentId: g,
679
678
  textRanges: C
680
679
  });
681
680
  }
682
681
  return c;
683
682
  }
684
- }, Ut = {
683
+ }, wt = {
685
684
  id: "doc.command.delete-right",
686
- type: R.COMMAND,
685
+ type: I.COMMAND,
687
686
  handler: async (i) => {
688
- var g;
689
- const e = i.get(P), t = i.get(A), n = i.get(O), r = i.get(x), s = e.getActiveRange(), o = e.getSelections(), a = (g = t.getCurrent()) == null ? void 0 : g.skeleton;
687
+ var p;
688
+ const e = i.get(U), t = i.get(L), n = i.get(y), r = i.get(O), s = e.getActiveRange(), o = e.getSelections(), a = (p = t.getCurrent()) == null ? void 0 : p.skeleton;
690
689
  let c;
691
690
  if (s == null || a == null || o == null)
692
691
  return !1;
693
- const d = n.getCurrentUniverDocInstance(), { startOffset: l, collapsed: p, segmentId: h, style: u } = s;
694
- if (l === d.getBody().dataStream.length - 2 && p)
692
+ const d = n.getCurrentUniverDocInstance(), { startOffset: l, collapsed: h, segmentId: g, style: u } = s;
693
+ if (l === d.getBody().dataStream.length - 2 && h)
695
694
  return !0;
696
- if (p === !0) {
697
- const m = a.findNodeByCharIndex(l);
698
- if (m.content === "\r")
699
- c = await r.executeCommand(tt.id, {
700
- direction: X.RIGHT,
695
+ if (h === !0) {
696
+ const f = a.findNodeByCharIndex(l);
697
+ if (f.content === "\r")
698
+ c = await r.executeCommand(nt.id, {
699
+ direction: Y.RIGHT,
701
700
  range: s
702
701
  });
703
702
  else {
704
- const f = [
703
+ const m = [
705
704
  {
706
705
  startOffset: l,
707
706
  endOffset: l,
708
707
  style: u
709
708
  }
710
709
  ];
711
- c = await r.executeCommand(et.id, {
710
+ c = await r.executeCommand(tt.id, {
712
711
  unitId: d.getUnitId(),
713
712
  range: s,
714
- segmentId: h,
715
- direction: X.RIGHT,
716
- textRanges: f,
717
- len: m.count
713
+ segmentId: g,
714
+ direction: Y.RIGHT,
715
+ textRanges: m,
716
+ len: f.count
718
717
  });
719
718
  }
720
719
  } else {
721
- const m = wt(s, o);
722
- c = await r.executeCommand(we.id, {
723
- segmentId: h,
724
- textRanges: m
720
+ const f = Nt(s, o);
721
+ c = await r.executeCommand(Ne.id, {
722
+ segmentId: g,
723
+ textRanges: f
725
724
  });
726
725
  }
727
726
  return c;
728
727
  }
729
- }, tt = {
728
+ }, nt = {
730
729
  id: "doc.command.merge-two-paragraph",
731
- type: R.COMMAND,
730
+ type: I.COMMAND,
732
731
  handler: async (i, e) => {
733
- var L, B, k;
734
- const t = i.get(P), n = i.get(O), r = i.get(x), s = i.get(N), { direction: o, range: a } = e, c = t.getActiveRange(), d = t.getSelections();
732
+ var B, k, R;
733
+ const t = i.get(U), n = i.get(y), r = i.get(O), s = i.get(A), { direction: o, range: a } = e, c = t.getActiveRange(), d = t.getSelections();
735
734
  if (c == null || d == null)
736
735
  return !1;
737
- const l = n.getCurrentUniverDocInstance(), { startOffset: p, collapsed: h, segmentId: u, style: g } = c;
738
- if (!h)
736
+ const l = n.getCurrentUniverDocInstance(), { startOffset: h, collapsed: g, segmentId: u, style: p } = c;
737
+ if (!g)
739
738
  return !1;
740
- const m = o === X.LEFT ? p : p + 1, f = (k = (B = (L = l.getBody()) == null ? void 0 : L.paragraphs) == null ? void 0 : B.find((I) => I.startIndex >= m)) == null ? void 0 : k.startIndex, v = Bn(l.getBody(), m, f), M = o === X.LEFT ? p - 1 : p, T = l.getUnitId(), y = [
739
+ const f = o === Y.LEFT ? h : h + 1, m = (R = (k = (B = l.getBody()) == null ? void 0 : B.paragraphs) == null ? void 0 : k.find((z) => z.startIndex >= f)) == null ? void 0 : R.startIndex, v = Vn(l.getBody(), f, m), M = o === Y.LEFT ? h - 1 : h, b = l.getUnitId(), T = [
741
740
  {
742
741
  startOffset: M,
743
742
  endOffset: M,
744
- style: g
743
+ style: p
745
744
  }
746
745
  ], C = {
747
746
  id: _.id,
748
747
  params: {
749
- unitId: T,
748
+ unitId: b,
750
749
  mutations: []
751
750
  }
752
- };
753
- C.params.mutations.push({
751
+ }, x = new H();
752
+ x.push({
754
753
  t: "r",
755
- len: o === X.LEFT ? p - 1 : p,
754
+ len: o === Y.LEFT ? h - 1 : h,
756
755
  segmentId: u
757
- }), v.dataStream.length && C.params.mutations.push({
756
+ }), v.dataStream.length && x.push({
758
757
  t: "i",
759
758
  body: v,
760
759
  len: v.dataStream.length,
761
760
  line: 0,
762
761
  segmentId: u
763
- }), C.params.mutations.push({
762
+ }), x.push({
764
763
  t: "r",
765
764
  len: 1,
766
765
  segmentId: u
767
- }), C.params.mutations.push({
766
+ }), x.push({
768
767
  t: "d",
769
- len: f + 1 - m,
768
+ len: m + 1 - f,
770
769
  line: 0,
771
770
  segmentId: u
772
- });
773
- const E = r.syncExecuteCommand(C.id, C.params);
774
- return t.replaceTextRanges(y), E ? (s.pushUndoRedo({
775
- unitID: T,
776
- undoMutations: [{ id: _.id, params: E }],
771
+ }), C.params.mutations = x.serialize();
772
+ const P = r.syncExecuteCommand(C.id, C.params);
773
+ return t.replaceTextRanges(T), P ? (s.pushUndoRedo({
774
+ unitID: b,
775
+ undoMutations: [{ id: _.id, params: P }],
777
776
  redoMutations: [{ id: _.id, params: C.params }],
778
777
  undo() {
779
- return r.syncExecuteCommand(_.id, E), t.replaceTextRanges([a]), !0;
778
+ return r.syncExecuteCommand(_.id, P), t.replaceTextRanges([a]), !0;
780
779
  },
781
780
  redo() {
782
- return r.syncExecuteCommand(_.id, C.params), t.replaceTextRanges(y), !0;
781
+ return r.syncExecuteCommand(_.id, C.params), t.replaceTextRanges(T), !0;
783
782
  }
784
783
  }), !0) : !1;
785
784
  }
786
785
  };
787
- function Bn(i, e, t) {
786
+ function Vn(i, e, t) {
788
787
  const { textRuns: n } = i, r = i.dataStream.substring(e, t);
789
788
  if (n == null)
790
789
  return {
@@ -812,7 +811,7 @@ function Bn(i, e, t) {
812
811
  textRuns: s
813
812
  };
814
813
  }
815
- function wt(i, e) {
814
+ function Nt(i, e) {
816
815
  let t = i.endOffset;
817
816
  for (const r of e) {
818
817
  const { startOffset: s, endOffset: o } = r;
@@ -826,7 +825,7 @@ function wt(i, e) {
826
825
  }
827
826
  ];
828
827
  }
829
- class nt {
828
+ class rt {
830
829
  constructor() {
831
830
  S(this, "_previousActiveRange", null);
832
831
  S(this, "_undoMutationParamsCache", []);
@@ -863,7 +862,7 @@ class nt {
863
862
  t: "r",
864
863
  len: r,
865
864
  segmentId: n
866
- }), o.mutations.push(this._undoMutationParamsCache[0].mutations.find((c) => c.t === "i")), a.mutations.push(...$e(this._previousActiveRange, n))), e.length && (o.mutations.push({
865
+ }), o.mutations.push(this._undoMutationParamsCache[0].mutations.find((c) => c.t === "i")), a.mutations.push(...Be(this._previousActiveRange, n))), e.length && (o.mutations.push({
867
866
  t: "d",
868
867
  len: e.length,
869
868
  line: 0,
@@ -884,25 +883,25 @@ class nt {
884
883
  }
885
884
  const Lt = {
886
885
  id: "doc.command.ime-input",
887
- type: R.COMMAND,
886
+ type: I.COMMAND,
888
887
  handler: async (i, e) => {
889
- const { unitId: t, newText: n, oldTextLen: r, range: s, segmentId: o, textRanges: a, isCompositionEnd: c } = e, d = i.get(x), l = i.get(N), p = i.get(P), h = i.get(nt), u = {
888
+ const { unitId: t, newText: n, oldTextLen: r, range: s, segmentId: o, textRanges: a, isCompositionEnd: c } = e, d = i.get(O), l = i.get(A), h = i.get(U), g = i.get(rt), u = {
890
889
  id: _.id,
891
890
  params: {
892
891
  unitId: t,
893
892
  mutations: []
894
893
  }
895
- };
896
- s.collapsed ? u.params.mutations.push({
894
+ }, p = new H();
895
+ s.collapsed ? p.push({
897
896
  t: "r",
898
897
  len: s.startOffset,
899
898
  segmentId: o
900
- }) : u.params.mutations.push(...$e(s, o)), r > 0 && u.params.mutations.push({
899
+ }) : p.push(...Be(s, o)), r > 0 && p.push({
901
900
  t: "d",
902
901
  len: r,
903
902
  line: 0,
904
903
  segmentId: o
905
- }), u.params.mutations.push({
904
+ }), p.push({
906
905
  t: "i",
907
906
  body: {
908
907
  dataStream: n
@@ -910,107 +909,107 @@ const Lt = {
910
909
  len: n.length,
911
910
  line: 0,
912
911
  segmentId: o
913
- });
914
- const g = d.syncExecuteCommand(u.id, u.params);
915
- if (h.pushUndoRedoMutationParams(g, u.params), p.replaceTextRanges(a), c) {
916
- if (g) {
917
- const m = h.fetchComposedUndoRedoMutationParams(n);
912
+ }), u.params.mutations = p.serialize();
913
+ const f = d.syncExecuteCommand(u.id, u.params);
914
+ if (g.pushUndoRedoMutationParams(f, u.params), h.replaceTextRanges(a), c) {
915
+ if (f) {
916
+ const m = g.fetchComposedUndoRedoMutationParams(n);
918
917
  if (m == null)
919
918
  return !1;
920
- const { undoMutationParams: f, redoMutationParams: v, previousActiveRange: M } = m;
919
+ const { undoMutationParams: v, redoMutationParams: M, previousActiveRange: b } = m;
921
920
  return l.pushUndoRedo({
922
921
  unitID: t,
923
- undoMutations: [{ id: _.id, params: f }],
924
- redoMutations: [{ id: _.id, params: v }],
922
+ undoMutations: [{ id: _.id, params: v }],
923
+ redoMutations: [{ id: _.id, params: M }],
925
924
  undo() {
926
- return d.syncExecuteCommand(_.id, f), p.replaceTextRanges([M]), !0;
925
+ return d.syncExecuteCommand(_.id, v), h.replaceTextRanges([b]), !0;
927
926
  },
928
927
  redo() {
929
- return d.syncExecuteCommand(_.id, v), p.replaceTextRanges(a), !0;
928
+ return d.syncExecuteCommand(_.id, M), h.replaceTextRanges(a), !0;
930
929
  }
931
930
  }), !0;
932
931
  }
933
932
  } else
934
- return !!g;
933
+ return !!f;
935
934
  return !1;
936
935
  }
937
- }, ue = {
936
+ }, he = {
938
937
  id: "doc.command.set-inline-format-bold",
939
- type: R.COMMAND,
938
+ type: I.COMMAND,
940
939
  handler: async () => !0
941
- }, Be = {
940
+ }, Ve = {
942
941
  id: "doc.command.set-inline-format-italic",
943
- type: R.COMMAND,
942
+ type: I.COMMAND,
944
943
  handler: async () => !0
945
- }, je = {
944
+ }, Fe = {
946
945
  id: "doc.command.set-inline-format-underline",
947
- type: R.COMMAND,
946
+ type: I.COMMAND,
948
947
  handler: async () => !0
949
- }, Ve = {
948
+ }, je = {
950
949
  id: "doc.command.set-inline-format-strikethrough",
951
- type: R.COMMAND,
950
+ type: I.COMMAND,
952
951
  handler: async () => !0
953
- }, J = {
952
+ }, Q = {
954
953
  id: "doc.command.set-inline-format-subscript",
955
- type: R.COMMAND,
954
+ type: I.COMMAND,
956
955
  handler: async () => !0
957
- }, se = {
956
+ }, oe = {
958
957
  id: "doc.command.set-inline-format-superscript",
959
- type: R.COMMAND,
958
+ type: I.COMMAND,
960
959
  handler: async () => !0
961
- }, he = {
960
+ }, ge = {
962
961
  id: "doc.command.set-inline-format-fontsize",
963
- type: R.COMMAND,
962
+ type: I.COMMAND,
964
963
  handler: async () => !0
965
964
  }, pe = {
966
965
  id: "doc.command.set-inline-format-font-family",
967
- type: R.COMMAND,
966
+ type: I.COMMAND,
968
967
  handler: async () => !0
969
- }, Fe = {
968
+ }, ke = {
970
969
  id: "doc.command.set-inline-format-text-color",
971
- type: R.COMMAND,
970
+ type: I.COMMAND,
972
971
  handler: async () => !0
973
972
  }, At = {
974
- [ue.id]: "bl",
975
- [Be.id]: "it",
976
- [je.id]: "ul",
977
- [Ve.id]: "st",
978
- [he.id]: "fs",
973
+ [he.id]: "bl",
974
+ [Ve.id]: "it",
975
+ [Fe.id]: "ul",
976
+ [je.id]: "st",
977
+ [ge.id]: "fs",
979
978
  [pe.id]: "ff",
980
- [Fe.id]: "cl",
981
- [J.id]: "va",
982
- [se.id]: "va"
983
- }, Nt = {
979
+ [ke.id]: "cl",
980
+ [Q.id]: "va",
981
+ [oe.id]: "va"
982
+ }, $t = {
984
983
  id: "doc.command.set-inline-format",
985
- type: R.COMMAND,
984
+ type: I.COMMAND,
986
985
  handler: async (i, e) => {
987
- const { segmentId: t, value: n, preCommandId: r } = e, s = i.get(N), o = i.get(x), a = i.get(P), c = i.get(O), d = a.getSelections();
986
+ const { segmentId: t, value: n, preCommandId: r } = e, s = i.get(A), o = i.get(O), a = i.get(U), c = i.get(y), d = a.getSelections();
988
987
  if (!Array.isArray(d) || d.length === 0)
989
988
  return !1;
990
- let l = c.getCurrentUniverDocInstance(), p = l.getUnitId();
991
- p === K && (l = c.getUniverDocInstance(Z), p = l.getUnitId());
992
- let h;
989
+ let l = c.getCurrentUniverDocInstance(), h = l.getUnitId();
990
+ h === J && (l = c.getUniverDocInstance(K), h = l.getUnitId());
991
+ let g;
993
992
  switch (r) {
994
- case ue.id:
995
- case Be.id:
996
- case je.id:
993
+ case he.id:
997
994
  case Ve.id:
998
- case J.id:
999
- case se.id: {
1000
- h = Vn(
995
+ case Fe.id:
996
+ case je.id:
997
+ case Q.id:
998
+ case oe.id: {
999
+ g = jn(
1001
1000
  l.getBody().textRuns,
1002
1001
  r,
1003
1002
  d
1004
1003
  );
1005
1004
  break;
1006
1005
  }
1007
- case he.id:
1006
+ case ge.id:
1008
1007
  case pe.id: {
1009
- h = n;
1008
+ g = n;
1010
1009
  break;
1011
1010
  }
1012
- case Fe.id: {
1013
- h = {
1011
+ case ke.id: {
1012
+ g = {
1014
1013
  rgb: n
1015
1014
  };
1016
1015
  break;
@@ -1021,59 +1020,60 @@ const Lt = {
1021
1020
  const u = {
1022
1021
  id: _.id,
1023
1022
  params: {
1024
- unitId: p,
1023
+ unitId: h,
1025
1024
  mutations: []
1026
1025
  }
1027
- }, g = new Ae();
1028
- g.reset();
1029
- for (const v of d) {
1030
- const { startOffset: M, endOffset: T } = v, y = {
1026
+ }, p = new H(), f = new Ae();
1027
+ f.reset();
1028
+ for (const M of d) {
1029
+ const { startOffset: b, endOffset: T } = M, C = {
1031
1030
  dataStream: "",
1032
1031
  textRuns: [
1033
1032
  {
1034
1033
  st: 0,
1035
- ed: T - M,
1034
+ ed: T - b,
1036
1035
  ts: {
1037
- [At[r]]: h
1036
+ [At[r]]: g
1038
1037
  }
1039
1038
  }
1040
1039
  ]
1041
- }, C = M - g.cursor;
1042
- C !== 0 && u.params.mutations.push({
1040
+ }, x = b - f.cursor;
1041
+ x !== 0 && p.push({
1043
1042
  t: "r",
1044
- len: C,
1043
+ len: x,
1045
1044
  segmentId: t
1046
- }), u.params.mutations.push({
1045
+ }), p.push({
1047
1046
  t: "r",
1048
- body: y,
1049
- len: T - M,
1047
+ body: C,
1048
+ len: T - b,
1050
1049
  segmentId: t
1051
- }), g.reset(), g.moveCursor(T);
1050
+ }), f.reset(), f.moveCursor(T);
1052
1051
  }
1053
- const m = o.syncExecuteCommand(u.id, u.params), f = [
1054
- ue.id,
1052
+ u.params.mutations = p.serialize();
1053
+ const m = o.syncExecuteCommand(u.id, u.params), v = [
1055
1054
  he.id,
1055
+ ge.id,
1056
1056
  pe.id,
1057
- J.id,
1058
- se.id
1057
+ Q.id,
1058
+ oe.id
1059
1059
  ];
1060
- return f.includes(r) && a.refreshSelection(), m ? (s.pushUndoRedo({
1061
- unitID: p,
1060
+ return v.includes(r) && a.refreshSelection(), m ? (s.pushUndoRedo({
1061
+ unitID: h,
1062
1062
  undoMutations: [{ id: _.id, params: m }],
1063
1063
  redoMutations: [{ id: _.id, params: u.params }],
1064
1064
  undo() {
1065
- return o.syncExecuteCommand(_.id, m), f.includes(r) && a.refreshSelection(), !0;
1065
+ return o.syncExecuteCommand(_.id, m), v.includes(r) && a.refreshSelection(), !0;
1066
1066
  },
1067
1067
  redo() {
1068
- return o.syncExecuteCommand(_.id, u.params), f.includes(r) && a.refreshSelection(), !0;
1068
+ return o.syncExecuteCommand(_.id, u.params), v.includes(r) && a.refreshSelection(), !0;
1069
1069
  }
1070
1070
  }), !0) : !1;
1071
1071
  }
1072
1072
  };
1073
- function jn(i) {
1073
+ function Fn(i) {
1074
1074
  return i !== null && typeof i == "object";
1075
1075
  }
1076
- function Vn(i, e, t) {
1076
+ function jn(i, e, t) {
1077
1077
  let n = 0, r = 0;
1078
1078
  const s = At[e];
1079
1079
  for (; n !== i.length && r !== t.length; ) {
@@ -1085,124 +1085,126 @@ function Vn(i, e, t) {
1085
1085
  else {
1086
1086
  if ((l == null ? void 0 : l[s]) == null) {
1087
1087
  if (/bl|it/.test(s))
1088
- return D.TRUE;
1088
+ return E.TRUE;
1089
1089
  if (/ul|st/.test(s))
1090
1090
  return {
1091
- s: D.TRUE
1091
+ s: E.TRUE
1092
1092
  };
1093
1093
  if (/va/.test(s))
1094
- return e === J.id ? j.SUBSCRIPT : j.SUPERSCRIPT;
1094
+ return e === Q.id ? V.SUBSCRIPT : V.SUPERSCRIPT;
1095
1095
  }
1096
- if (jn(l == null ? void 0 : l[s]) && l[s].s === D.FALSE)
1096
+ if (Fn(l == null ? void 0 : l[s]) && l[s].s === E.FALSE)
1097
1097
  return {
1098
- s: D.TRUE
1098
+ s: E.TRUE
1099
1099
  };
1100
- if (e === J.id && (l == null ? void 0 : l[s]) !== j.SUBSCRIPT)
1101
- return j.SUBSCRIPT;
1102
- if (e === se.id && (l == null ? void 0 : l[s]) !== j.SUPERSCRIPT)
1103
- return j.SUPERSCRIPT;
1104
- if ((l == null ? void 0 : l[s]) === D.FALSE)
1105
- return D.TRUE;
1100
+ if (e === Q.id && (l == null ? void 0 : l[s]) !== V.SUBSCRIPT)
1101
+ return V.SUBSCRIPT;
1102
+ if (e === oe.id && (l == null ? void 0 : l[s]) !== V.SUPERSCRIPT)
1103
+ return V.SUPERSCRIPT;
1104
+ if ((l == null ? void 0 : l[s]) === E.FALSE)
1105
+ return E.TRUE;
1106
1106
  n++;
1107
1107
  }
1108
1108
  }
1109
- return /bl|it/.test(s) ? D.FALSE : /ul|st/.test(s) ? {
1110
- s: D.FALSE
1111
- } : j.NORMAL;
1109
+ return /bl|it/.test(s) ? E.FALSE : /ul|st/.test(s) ? {
1110
+ s: E.FALSE
1111
+ } : V.NORMAL;
1112
1112
  }
1113
- const Fn = {
1113
+ const kn = {
1114
1114
  id: "doc.command.bullet-list",
1115
- type: R.COMMAND,
1116
- handler: (i) => i.get(x).syncExecuteCommand(rt.id, {
1117
- listType: yt.BULLET_LIST
1115
+ type: I.COMMAND,
1116
+ handler: (i) => i.get(O).syncExecuteCommand(it.id, {
1117
+ listType: bt.BULLET_LIST
1118
1118
  })
1119
- }, kn = {
1119
+ }, zn = {
1120
1120
  id: "doc.command.order-list",
1121
- type: R.COMMAND,
1122
- handler: (i) => i.get(x).syncExecuteCommand(rt.id, {
1123
- listType: yt.ORDER_LIST
1121
+ type: I.COMMAND,
1122
+ handler: (i) => i.get(O).syncExecuteCommand(it.id, {
1123
+ listType: bt.ORDER_LIST
1124
1124
  })
1125
- }, rt = {
1125
+ }, it = {
1126
1126
  id: "doc.command.list-operation",
1127
- type: R.COMMAND,
1127
+ type: I.COMMAND,
1128
1128
  handler: (i, e) => {
1129
1129
  var T;
1130
- const t = i.get(P), n = i.get(O), r = i.get(x), s = i.get(N), { listType: o } = e, a = n.getCurrentUniverDocInstance(), c = t.getActiveRange(), d = (T = a.getBody()) == null ? void 0 : T.paragraphs;
1130
+ const t = i.get(U), n = i.get(y), r = i.get(O), s = i.get(A), { listType: o } = e, a = n.getCurrentUniverDocInstance(), c = t.getActiveRange(), d = (T = a.getBody()) == null ? void 0 : T.paragraphs;
1131
1131
  if (c == null || d == null)
1132
1132
  return !1;
1133
- const l = zn(c, d), { segmentId: p } = c, h = a.getUnitId(), u = l.every((y) => {
1134
- var C;
1135
- return ((C = y.bullet) == null ? void 0 : C.listType) === o;
1136
- }), g = 6;
1137
- let m = re.generateRandomId(g);
1133
+ const l = Wn(c, d), { segmentId: h } = c, g = a.getUnitId(), u = l.every((C) => {
1134
+ var x;
1135
+ return ((x = C.bullet) == null ? void 0 : x.listType) === o;
1136
+ }), p = 6;
1137
+ let f = ie.generateRandomId(p);
1138
1138
  if (l.length === 1) {
1139
- const y = d.indexOf(l[0]), C = d[y - 1], E = d[y + 1];
1140
- C && C.bullet && C.bullet.listType === o ? m = C.bullet.listId : E && E.bullet && E.bullet.listType === o && (m = E.bullet.listId);
1139
+ const C = d.indexOf(l[0]), x = d[C - 1], P = d[C + 1];
1140
+ x && x.bullet && x.bullet.listType === o ? f = x.bullet.listId : P && P.bullet && P.bullet.listType === o && (f = P.bullet.listId);
1141
1141
  }
1142
- const f = {
1142
+ const m = {
1143
1143
  id: _.id,
1144
1144
  params: {
1145
- unitId: h,
1145
+ unitId: g,
1146
1146
  mutations: []
1147
1147
  }
1148
1148
  }, v = new Ae();
1149
1149
  v.reset();
1150
- for (const y of l) {
1151
- const { startIndex: C } = y;
1152
- f.params.mutations.push({
1150
+ const M = new H();
1151
+ for (const C of l) {
1152
+ const { startIndex: x } = C;
1153
+ M.push({
1153
1154
  t: "r",
1154
- len: C - v.cursor,
1155
- segmentId: p
1155
+ len: x - v.cursor,
1156
+ segmentId: h
1156
1157
  });
1157
- const E = {
1158
- ...y.paragraphStyle,
1158
+ const P = {
1159
+ ...C.paragraphStyle,
1159
1160
  hanging: void 0,
1160
1161
  indentStart: void 0
1161
1162
  };
1162
- f.params.mutations.push({
1163
+ M.push({
1163
1164
  t: "r",
1164
1165
  len: 1,
1165
1166
  body: {
1166
1167
  dataStream: "",
1167
1168
  paragraphs: [
1168
1169
  u ? {
1169
- paragraphStyle: E,
1170
+ paragraphStyle: P,
1170
1171
  startIndex: 0
1171
1172
  } : {
1172
- ...y,
1173
+ ...C,
1173
1174
  startIndex: 0,
1174
1175
  bullet: {
1175
- ...y.bullet ?? {
1176
+ ...C.bullet ?? {
1176
1177
  nestingLevel: 0,
1177
1178
  textStyle: {
1178
1179
  fs: 20
1179
1180
  }
1180
1181
  },
1181
1182
  listType: o,
1182
- listId: m
1183
+ listId: f
1183
1184
  }
1184
1185
  }
1185
1186
  ]
1186
1187
  },
1187
- segmentId: p,
1188
- coverType: Ot.REPLACE
1189
- }), v.moveCursorTo(C + 1);
1188
+ segmentId: h,
1189
+ coverType: yt.REPLACE
1190
+ }), v.moveCursorTo(x + 1);
1190
1191
  }
1191
- const M = r.syncExecuteCommand(f.id, f.params);
1192
- return t.refreshSelection(), M && s.pushUndoRedo({
1193
- unitID: h,
1194
- undoMutations: [{ id: _.id, params: M }],
1195
- redoMutations: [{ id: _.id, params: f.params }],
1192
+ m.params.mutations = M.serialize();
1193
+ const b = r.syncExecuteCommand(m.id, m.params);
1194
+ return t.refreshSelection(), b && s.pushUndoRedo({
1195
+ unitID: g,
1196
+ undoMutations: [{ id: _.id, params: b }],
1197
+ redoMutations: [{ id: _.id, params: m.params }],
1196
1198
  undo() {
1197
- return r.syncExecuteCommand(_.id, M), t.refreshSelection(), !0;
1199
+ return r.syncExecuteCommand(_.id, b), t.refreshSelection(), !0;
1198
1200
  },
1199
1201
  redo() {
1200
- return r.syncExecuteCommand(_.id, f.params), t.refreshSelection(), !0;
1202
+ return r.syncExecuteCommand(_.id, m.params), t.refreshSelection(), !0;
1201
1203
  }
1202
1204
  }), !0;
1203
1205
  }
1204
1206
  };
1205
- function zn(i, e) {
1207
+ function Wn(i, e) {
1206
1208
  const { startOffset: t, endOffset: n } = i, r = [];
1207
1209
  let s = -1;
1208
1210
  for (const o of e) {
@@ -1211,82 +1213,82 @@ function zn(i, e) {
1211
1213
  }
1212
1214
  return r;
1213
1215
  }
1214
- const Wn = {
1216
+ const Hn = {
1215
1217
  id: "doc.command-replace-content",
1216
- type: R.COMMAND,
1218
+ type: I.COMMAND,
1217
1219
  handler: async (i, e) => {
1218
- var g;
1219
- const { unitId: t, body: n, textRanges: r, segmentId: s = "" } = e, o = i.get(O), a = i.get(x), c = i.get(P), d = i.get(N), l = (g = o.getUniverDocInstance(t)) == null ? void 0 : g.getSnapshot().body, p = c.getSelections();
1220
- if (l == null || !Array.isArray(p) || p.length === 0)
1220
+ var p;
1221
+ const { unitId: t, body: n, textRanges: r, segmentId: s = "" } = e, o = i.get(y), a = i.get(O), c = i.get(U), d = i.get(A), l = (p = o.getUniverDocInstance(t)) == null ? void 0 : p.getSnapshot().body, h = c.getSelections();
1222
+ if (l == null || !Array.isArray(h) || h.length === 0)
1221
1223
  return !1;
1222
- const h = $t(t, s, l, n), u = a.syncExecuteCommand(h.id, h.params);
1224
+ const g = Bt(t, s, l, n), u = a.syncExecuteCommand(g.id, g.params);
1223
1225
  return c.replaceTextRanges(r), u ? (d.pushUndoRedo({
1224
1226
  unitID: t,
1225
1227
  undoMutations: [{ id: _.id, params: u }],
1226
- redoMutations: [{ id: _.id, params: h.params }],
1228
+ redoMutations: [{ id: _.id, params: g.params }],
1227
1229
  undo() {
1228
- return a.syncExecuteCommand(_.id, u), c.replaceTextRanges(p), !0;
1230
+ return a.syncExecuteCommand(_.id, u), c.replaceTextRanges(h), !0;
1229
1231
  },
1230
1232
  redo() {
1231
- return a.syncExecuteCommand(_.id, h.params), c.replaceTextRanges(r), !0;
1233
+ return a.syncExecuteCommand(_.id, g.params), c.replaceTextRanges(r), !0;
1232
1234
  }
1233
1235
  }), !0) : !1;
1234
1236
  }
1235
- }, Hn = {
1237
+ }, Xn = {
1236
1238
  id: "doc.command-cover-content",
1237
- type: R.COMMAND,
1239
+ type: I.COMMAND,
1238
1240
  handler: async (i, e) => {
1239
1241
  var l;
1240
- const { unitId: t, body: n, segmentId: r = "" } = e, s = i.get(O), o = i.get(x), a = i.get(N), c = (l = s.getUniverDocInstance(t)) == null ? void 0 : l.getSnapshot().body;
1242
+ const { unitId: t, body: n, segmentId: r = "" } = e, s = i.get(y), o = i.get(O), a = i.get(A), c = (l = s.getUniverDocInstance(t)) == null ? void 0 : l.getSnapshot().body;
1241
1243
  if (c == null)
1242
1244
  return !1;
1243
- const d = $t(t, r, c, n);
1245
+ const d = Bt(t, r, c, n);
1244
1246
  return o.syncExecuteCommand(
1245
1247
  d.id,
1246
1248
  d.params
1247
1249
  ), a.clearUndoRedo(t), !0;
1248
1250
  }
1249
1251
  };
1250
- function $t(i, e, t, n) {
1252
+ function Bt(i, e, t, n) {
1251
1253
  const r = {
1252
1254
  id: _.id,
1253
1255
  params: {
1254
1256
  unitId: i,
1255
1257
  mutations: []
1256
1258
  }
1257
- }, s = (t == null ? void 0 : t.dataStream.length) - 2;
1258
- return s > 0 && r.params.mutations.push({
1259
+ }, s = new H(), o = (t == null ? void 0 : t.dataStream.length) - 2;
1260
+ return o > 0 && s.push({
1259
1261
  t: "d",
1260
- len: s,
1262
+ len: o,
1261
1263
  line: 0,
1262
1264
  segmentId: e
1263
- }), n.dataStream.length > 0 && r.params.mutations.push({
1265
+ }), n.dataStream.length > 0 && s.push({
1264
1266
  t: "i",
1265
1267
  body: n,
1266
1268
  len: n.dataStream.length,
1267
1269
  line: 0,
1268
1270
  segmentId: e
1269
- }), r;
1271
+ }), r.params.mutations = s.serialize(), r;
1270
1272
  }
1271
- const Q = {
1273
+ const ee = {
1272
1274
  id: "doc.operation.move-cursor",
1273
- type: R.OPERATION,
1275
+ type: I.OPERATION,
1274
1276
  handler: (i, e) => !!e
1275
- }, ee = {
1277
+ }, te = {
1276
1278
  id: "doc.operation.move-selection",
1277
- type: R.OPERATION,
1279
+ type: I.OPERATION,
1278
1280
  handler: (i, e) => !!e
1279
1281
  }, Gn = (i, e) => {
1280
- const t = i.get(O).getUniverDocInstance(e.unitId), n = (t == null ? void 0 : t.zoomRatio) || 1;
1282
+ const t = i.get(y).getUniverDocInstance(e.unitId), n = (t == null ? void 0 : t.zoomRatio) || 1;
1281
1283
  return {
1282
- ...re.deepClone(e),
1284
+ ...ie.deepClone(e),
1283
1285
  zoomRatio: n
1284
1286
  };
1285
- }, Y = {
1287
+ }, Z = {
1286
1288
  id: "doc.operation.set-zoom-ratio",
1287
- type: R.OPERATION,
1289
+ type: I.OPERATION,
1288
1290
  handler: (i, e) => {
1289
- const t = i.get(O).getUniverDocInstance(e.unitId);
1291
+ const t = i.get(y).getUniverDocInstance(e.unitId);
1290
1292
  if (!t)
1291
1293
  return !1;
1292
1294
  const n = t.getSnapshot();
@@ -1294,11 +1296,11 @@ const Q = {
1294
1296
  zoomRatio: e.zoomRatio
1295
1297
  } : n.settings.zoomRatio = e.zoomRatio, !0;
1296
1298
  }
1297
- }, Bt = {
1298
- type: R.COMMAND,
1299
+ }, Vt = {
1300
+ type: I.COMMAND,
1299
1301
  id: "doc.command.set-zoom-ratio",
1300
1302
  handler: async (i, e) => {
1301
- const t = i.get(x), n = i.get(N), r = i.get(O);
1303
+ const t = i.get(O), n = i.get(A), r = i.get(y);
1302
1304
  let s = r.getCurrentUniverDocInstance().getUnitId(), o = 1;
1303
1305
  if (e && (s = e.documentId ?? s, o = e.zoomRatio ?? o), !r.getUniverDocInstance(s))
1304
1306
  return !1;
@@ -1306,17 +1308,17 @@ const Q = {
1306
1308
  zoomRatio: o,
1307
1309
  unitId: s
1308
1310
  }, d = Gn(i, c);
1309
- return t.syncExecuteCommand(Y.id, c) ? (n.pushUndoRedo({
1311
+ return t.syncExecuteCommand(Z.id, c) ? (n.pushUndoRedo({
1310
1312
  unitID: s,
1311
- undoMutations: [{ id: Y.id, params: d }],
1312
- redoMutations: [{ id: Y.id, params: c }]
1313
+ undoMutations: [{ id: Z.id, params: d }],
1314
+ redoMutations: [{ id: Z.id, params: c }]
1313
1315
  }), !0) : !1;
1314
1316
  }
1315
- }, jt = {
1317
+ }, Ft = {
1316
1318
  id: "doc.operation.select-all",
1317
- type: R.COMMAND,
1319
+ type: I.COMMAND,
1318
1320
  handler: async (i) => {
1319
- const e = i.get(O), t = i.get(P), n = e.getCurrentUniverDocInstance().getSnapshot().body;
1321
+ const e = i.get(y), t = i.get(U), n = e.getCurrentUniverDocInstance().getSnapshot().body;
1320
1322
  if (n == null)
1321
1323
  return !1;
1322
1324
  const r = [
@@ -1327,17 +1329,17 @@ const Q = {
1327
1329
  ];
1328
1330
  return t.replaceTextRanges(r), !0;
1329
1331
  }
1330
- }, Xn = 10, qn = 6;
1331
- function Yn() {
1332
- return re.generateRandomId(qn);
1332
+ }, Yn = 10, qn = 6;
1333
+ function Zn() {
1334
+ return ie.generateRandomId(qn);
1333
1335
  }
1334
- function Zn(i) {
1336
+ function Kn(i) {
1335
1337
  const e = i.match(/data-copy-id="([^\s]+)"/);
1336
1338
  return e && e[1] ? e[1] : null;
1337
1339
  }
1338
- class Kn {
1340
+ class Jn {
1339
1341
  constructor() {
1340
- S(this, "_cache", new Wt(Xn));
1342
+ S(this, "_cache", new Ht(Yn));
1341
1343
  }
1342
1344
  set(e, t) {
1343
1345
  this._cache.set(e, t);
@@ -1349,57 +1351,57 @@ class Kn {
1349
1351
  this._cache.clear();
1350
1352
  }
1351
1353
  }
1352
- const _t = new Kn();
1353
- function Jn(i) {
1354
+ const St = new Jn();
1355
+ function Qn(i) {
1354
1356
  const e = i.style, t = {};
1355
1357
  for (let n = 0; n < e.length; n++) {
1356
1358
  const r = e[n], s = e.getPropertyValue(r);
1357
1359
  switch (r) {
1358
1360
  case "margin-top": {
1359
1361
  const o = parseInt(s);
1360
- t.spaceAbove = /pt/.test(s) ? Ze(o) : o;
1362
+ t.spaceAbove = /pt/.test(s) ? Ke(o) : o;
1361
1363
  break;
1362
1364
  }
1363
1365
  case "margin-bottom": {
1364
1366
  const o = parseInt(s);
1365
- t.spaceBelow = /pt/.test(s) ? Ze(o) : o;
1367
+ t.spaceBelow = /pt/.test(s) ? Ke(o) : o;
1366
1368
  break;
1367
1369
  }
1368
1370
  }
1369
1371
  }
1370
1372
  return Object.getOwnPropertyNames(t).length ? t : null;
1371
1373
  }
1372
- function Ze(i) {
1374
+ function Ke(i) {
1373
1375
  return i / 0.75;
1374
1376
  }
1375
- function it(i) {
1377
+ function st(i) {
1376
1378
  const e = i.style, t = {}, n = i.tagName.toLowerCase();
1377
1379
  switch (n) {
1378
1380
  case "b":
1379
1381
  case "em":
1380
1382
  case "strong": {
1381
- t.bl = D.TRUE;
1383
+ t.bl = E.TRUE;
1382
1384
  break;
1383
1385
  }
1384
1386
  case "s": {
1385
1387
  t.st = {
1386
- s: D.TRUE
1388
+ s: E.TRUE
1387
1389
  };
1388
1390
  break;
1389
1391
  }
1390
1392
  case "u": {
1391
1393
  t.ul = {
1392
- s: D.TRUE
1394
+ s: E.TRUE
1393
1395
  };
1394
1396
  break;
1395
1397
  }
1396
1398
  case "i": {
1397
- t.it = D.TRUE;
1399
+ t.it = E.TRUE;
1398
1400
  break;
1399
1401
  }
1400
1402
  case "sub":
1401
1403
  case "sup": {
1402
- t.va = n === "sup" ? j.SUPERSCRIPT : j.SUBSCRIPT;
1404
+ t.va = n === "sup" ? V.SUPERSCRIPT : V.SUBSCRIPT;
1403
1405
  break;
1404
1406
  }
1405
1407
  }
@@ -1412,36 +1414,36 @@ function it(i) {
1412
1414
  }
1413
1415
  case "font-size": {
1414
1416
  const a = parseInt(o);
1415
- Number.isNaN(a) || (t.fs = /pt$/.test(o) ? Ze(a) : a);
1417
+ Number.isNaN(a) || (t.fs = /pt$/.test(o) ? Ke(a) : a);
1416
1418
  break;
1417
1419
  }
1418
1420
  case "font-style": {
1419
- o === "italic" && (t.it = D.TRUE);
1421
+ o === "italic" && (t.it = E.TRUE);
1420
1422
  break;
1421
1423
  }
1422
1424
  case "font-weight": {
1423
- Number(o) > 400 && (t.bl = D.TRUE);
1425
+ Number(o) > 400 && (t.bl = E.TRUE);
1424
1426
  break;
1425
1427
  }
1426
1428
  case "text-decoration": {
1427
1429
  /underline/.test(o) ? t.ul = {
1428
- s: D.TRUE
1430
+ s: E.TRUE
1429
1431
  } : /overline/.test(o) ? t.ol = {
1430
- s: D.TRUE
1432
+ s: E.TRUE
1431
1433
  } : /line-through/.test(o) && (t.st = {
1432
- s: D.TRUE
1434
+ s: E.TRUE
1433
1435
  });
1434
1436
  break;
1435
1437
  }
1436
1438
  case "color": {
1437
- const a = new ot(o);
1439
+ const a = new at(o);
1438
1440
  a.isValid && (t.cl = {
1439
1441
  rgb: a.toRgbString()
1440
1442
  });
1441
1443
  break;
1442
1444
  }
1443
1445
  case "background-color": {
1444
- const a = new ot(o);
1446
+ const a = new at(o);
1445
1447
  a.isValid && (t.bg = {
1446
1448
  rgb: a.toRgbString()
1447
1449
  });
@@ -1451,11 +1453,11 @@ function it(i) {
1451
1453
  }
1452
1454
  return t;
1453
1455
  }
1454
- function Qn(i) {
1456
+ function er(i) {
1455
1457
  const e = new DOMParser(), t = `<x-univer id="univer-root">${i}</x-univer>`;
1456
1458
  return e.parseFromString(t, "text/html").querySelector("#univer-root");
1457
1459
  }
1458
- function St(i, e) {
1460
+ function vt(i, e) {
1459
1461
  const t = i.tagName.toLowerCase();
1460
1462
  return typeof e == "string" ? t === e : Array.isArray(e) ? e.some((n) => n === t) : e(i);
1461
1463
  }
@@ -1471,7 +1473,7 @@ const Le = class Le {
1471
1473
  this._pluginList.push(e);
1472
1474
  }
1473
1475
  convert(e) {
1474
- const t = Le._pluginList.find((s) => s.checkPasteType(e)), n = Qn(e), r = {
1476
+ const t = Le._pluginList.find((s) => s.checkPasteType(e)), n = er(e), r = {
1475
1477
  dataStream: "",
1476
1478
  textRuns: []
1477
1479
  };
@@ -1489,20 +1491,20 @@ const Le = class Le {
1489
1491
  ts: a
1490
1492
  });
1491
1493
  } else if (s.nodeType === Node.ELEMENT_NODE) {
1492
- const o = e ? this._styleCache.get(e) : {}, a = this._styleRules.find(({ filter: p }) => St(s, p)), c = a ? a.getStyle(s) : it(s);
1494
+ const o = e ? this._styleCache.get(e) : {}, a = this._styleRules.find(({ filter: h }) => vt(s, h)), c = a ? a.getStyle(s) : st(s);
1493
1495
  this._styleCache.set(s, { ...o, ...c });
1494
1496
  const { childNodes: d } = s;
1495
1497
  this._process(s, d, n);
1496
1498
  const l = this._afterProcessRules.find(
1497
- ({ filter: p }) => St(s, p)
1499
+ ({ filter: h }) => vt(s, h)
1498
1500
  );
1499
1501
  l && l.handler(n, s);
1500
1502
  }
1501
1503
  }
1502
1504
  };
1503
1505
  S(Le, "_pluginList", []);
1504
- let ge = Le;
1505
- const er = {
1506
+ let fe = Le;
1507
+ const tr = {
1506
1508
  name: "univer-doc-paste-plugin-lark",
1507
1509
  checkPasteType(i) {
1508
1510
  return /lark-record-clipboard/i.test(i);
@@ -1512,10 +1514,10 @@ const er = {
1512
1514
  {
1513
1515
  filter: ["s"],
1514
1516
  getStyle(i) {
1515
- const e = it(i);
1517
+ const e = st(i);
1516
1518
  return {
1517
1519
  st: {
1518
- s: D.TRUE
1520
+ s: E.TRUE
1519
1521
  },
1520
1522
  ...e
1521
1523
  };
@@ -1534,7 +1536,7 @@ const er = {
1534
1536
  }
1535
1537
  }
1536
1538
  ]
1537
- }, tr = {
1539
+ }, nr = {
1538
1540
  name: "univer-doc-paste-plugin-word",
1539
1541
  checkPasteType(i) {
1540
1542
  return /word|mso/i.test(i);
@@ -1543,8 +1545,8 @@ const er = {
1543
1545
  {
1544
1546
  filter: ["b"],
1545
1547
  getStyle(i) {
1546
- const e = it(i);
1547
- return { bl: D.TRUE, ...e };
1548
+ const e = st(i);
1549
+ return { bl: E.TRUE, ...e };
1548
1550
  }
1549
1551
  }
1550
1552
  ],
@@ -1557,57 +1559,57 @@ const er = {
1557
1559
  i.paragraphs == null && (i.paragraphs = []);
1558
1560
  const t = {
1559
1561
  startIndex: i.dataStream.length
1560
- }, n = Jn(e);
1562
+ }, n = Qn(e);
1561
1563
  n && (t.paragraphStyle = n), i.paragraphs.push(t), i.dataStream += "\r";
1562
1564
  }
1563
1565
  }
1564
1566
  ]
1565
1567
  };
1566
- function nr(i, e) {
1567
- const { st: t, ed: n, ts: r = {} } = e, { ff: s, fs: o, it: a, bl: c, ul: d, st: l, ol: p, bg: h, cl: u, va: g } = r;
1568
- let m = i.slice(t, n);
1569
- const f = [];
1570
- return a === D.TRUE && (m = `<i>${m}</i>`), g === j.SUPERSCRIPT ? m = `<sup>${m}</sup>` : g === j.SUBSCRIPT && (m = `<sub>${m}</sub>`), (d == null ? void 0 : d.s) === D.TRUE && (m = `<u>${m}</u>`), (l == null ? void 0 : l.s) === D.TRUE && (m = `<s>${m}</s>`), c === D.TRUE && (m = `<strong>${m}</strong>`), s && f.push(`font-family: ${s}`), u && f.push(`color: ${u.rgb}`), o && f.push(`font-size: ${o}px`), p && f.push("text-decoration: overline"), h && f.push(`background: ${h.rgb}`), f.length ? `<span style="${f.join(";")}">${m}</span>` : m;
1568
+ function rr(i, e) {
1569
+ const { st: t, ed: n, ts: r = {} } = e, { ff: s, fs: o, it: a, bl: c, ul: d, st: l, ol: h, bg: g, cl: u, va: p } = r;
1570
+ let f = i.slice(t, n);
1571
+ const m = [];
1572
+ return a === E.TRUE && (f = `<i>${f}</i>`), p === V.SUPERSCRIPT ? f = `<sup>${f}</sup>` : p === V.SUBSCRIPT && (f = `<sub>${f}</sub>`), (d == null ? void 0 : d.s) === E.TRUE && (f = `<u>${f}</u>`), (l == null ? void 0 : l.s) === E.TRUE && (f = `<s>${f}</s>`), c === E.TRUE && (f = `<strong>${f}</strong>`), s && m.push(`font-family: ${s}`), u && m.push(`color: ${u.rgb}`), o && m.push(`font-size: ${o}px`), h && m.push("text-decoration: overline"), g && m.push(`background: ${g.rgb}`), m.length ? `<span style="${m.join(";")}">${f}</span>` : f;
1571
1573
  }
1572
- function vt(i, e = !0) {
1574
+ function Mt(i, e = !0) {
1573
1575
  const { dataStream: t, textRuns: n = [], paragraphs: r = [] } = i;
1574
1576
  let s = 0;
1575
1577
  const o = [], a = [];
1576
1578
  for (const c of n) {
1577
1579
  const { st: d, ed: l } = c;
1578
- if (d !== s && o.push(t.slice(s, d)), o.push(nr(t, c)), s = l, e)
1579
- for (const p of r) {
1580
- const { startIndex: h, paragraphStyle: u = {} } = p;
1581
- if (h >= d && h <= l) {
1582
- const { spaceAbove: g, spaceBelow: m } = u, f = [];
1583
- g != null && (typeof g == "number" ? f.push(`margin-top: ${g}px`) : f.push(`margin-top: ${g.v}px`)), m != null && (typeof m == "number" ? f.push(`margin-bottom: ${m}px`) : f.push(`margin-bottom: ${m.v}px`)), a.push(
1584
- `<p className="UniverNormal" ${f.length ? `style="${f.join(";")}"` : ""}>${o.join("")}</p>`
1580
+ if (d !== s && o.push(t.slice(s, d)), o.push(rr(t, c)), s = l, e)
1581
+ for (const h of r) {
1582
+ const { startIndex: g, paragraphStyle: u = {} } = h;
1583
+ if (g >= d && g <= l) {
1584
+ const { spaceAbove: p, spaceBelow: f } = u, m = [];
1585
+ p != null && (typeof p == "number" ? m.push(`margin-top: ${p}px`) : m.push(`margin-top: ${p.v}px`)), f != null && (typeof f == "number" ? m.push(`margin-bottom: ${f}px`) : m.push(`margin-bottom: ${f.v}px`)), a.push(
1586
+ `<p className="UniverNormal" ${m.length ? `style="${m.join(";")}"` : ""}>${o.join("")}</p>`
1585
1587
  ), o.length = 0;
1586
1588
  }
1587
1589
  }
1588
1590
  }
1589
1591
  return a.join("") + o.join("");
1590
1592
  }
1591
- class rr {
1593
+ class ir {
1592
1594
  convert(e) {
1593
1595
  if (e.length === 0)
1594
1596
  throw new Error("The bodyList length at least to be 1");
1595
1597
  if (e.length === 1)
1596
- return vt(e[0]);
1598
+ return Mt(e[0]);
1597
1599
  let t = "";
1598
1600
  for (const n of e)
1599
- t += '<p className="UniverNormal">', t += vt(n, !1), t += "</p>";
1601
+ t += '<p className="UniverNormal">', t += Mt(n, !1), t += "</p>";
1600
1602
  return t;
1601
1603
  }
1602
1604
  }
1603
- var ir = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, or = (i, e, t, n) => {
1604
- for (var r = n > 1 ? void 0 : n ? sr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1605
+ var sr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, ar = (i, e, t, n) => {
1606
+ for (var r = n > 1 ? void 0 : n ? or(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1605
1607
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
1606
- return n && r && ir(e, t, r), r;
1607
- }, Mt = (i, e) => (t, n) => e(t, n, i);
1608
- ge.use(tr);
1609
- ge.use(er);
1610
- function ar(i) {
1608
+ return n && r && sr(e, t, r), r;
1609
+ }, Ct = (i, e) => (t, n) => e(t, n, i);
1610
+ fe.use(nr);
1611
+ fe.use(tr);
1612
+ function cr(i) {
1611
1613
  const e = i.replace(/\n/g, "\r"), t = [];
1612
1614
  for (let n = 0; n < e.length; n++)
1613
1615
  e[n] === "\r" && t.push({ startIndex: n });
@@ -1616,13 +1618,13 @@ function ar(i) {
1616
1618
  paragraphs: t
1617
1619
  };
1618
1620
  }
1619
- const Vt = Mn("doc.clipboard-service");
1620
- let Ke = class extends W {
1621
+ const jt = Cn("doc.clipboard-service");
1622
+ let Je = class extends X {
1621
1623
  constructor(e, t) {
1622
1624
  super();
1623
1625
  S(this, "_clipboardHooks", []);
1624
- S(this, "_htmlToUDM", new ge());
1625
- S(this, "_umdToHtml", new rr());
1626
+ S(this, "_htmlToUDM", new fe());
1627
+ S(this, "_umdToHtml", new ir());
1626
1628
  this._currentUniverService = e, this._clipboardInterfaceService = t;
1627
1629
  }
1628
1630
  async queryClipboardData() {
@@ -1633,12 +1635,12 @@ let Ke = class extends W {
1633
1635
  let t = "", n = "";
1634
1636
  for (const s of e)
1635
1637
  for (const o of s.types)
1636
- o === mn ? n = await s.getType(o).then((a) => a && a.text()) : o === fn && (t = await s.getType(o).then((a) => a && a.text()));
1638
+ o === mn ? n = await s.getType(o).then((a) => a && a.text()) : o === _n && (t = await s.getType(o).then((a) => a && a.text()));
1637
1639
  if (!t)
1638
- return ar(n);
1639
- const r = Zn(t);
1640
+ return cr(n);
1641
+ const r = Kn(t);
1640
1642
  if (r) {
1641
- const s = _t.get(r);
1643
+ const s = St.get(r);
1642
1644
  if (s)
1643
1645
  return s;
1644
1646
  }
@@ -1648,10 +1650,10 @@ let Ke = class extends W {
1648
1650
  }
1649
1651
  }
1650
1652
  async setClipboardData(e) {
1651
- const t = Yn(), n = e.length > 1 ? e.map((s) => s.dataStream).join(`
1653
+ const t = Zn(), n = e.length > 1 ? e.map((s) => s.dataStream).join(`
1652
1654
  `) : e[0].dataStream;
1653
1655
  let r = this._umdToHtml.convert(e);
1654
- return e.length === 1 && (r = r.replace(/(<[a-z]+)/, (s, o) => `${o} data-copy-id="${t}"`), _t.set(t, e[0])), this._clipboardInterfaceService.write(n, r);
1656
+ return e.length === 1 && (r = r.replace(/(<[a-z]+)/, (s, o) => `${o} data-copy-id="${t}"`), St.set(t, e[0])), this._clipboardInterfaceService.write(n, r);
1655
1657
  }
1656
1658
  addClipboardHook(e) {
1657
1659
  return this._clipboardHooks.push(e), qe(() => {
@@ -1660,41 +1662,41 @@ let Ke = class extends W {
1660
1662
  });
1661
1663
  }
1662
1664
  };
1663
- Ke = or([
1664
- Mt(0, O),
1665
- Mt(1, _n)
1666
- ], Ke);
1667
- var cr = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, dr = (i, e, t, n) => {
1668
- for (var r = n > 1 ? void 0 : n ? lr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1665
+ Je = ar([
1666
+ Ct(0, y),
1667
+ Ct(1, Sn)
1668
+ ], Je);
1669
+ var lr = Object.defineProperty, dr = Object.getOwnPropertyDescriptor, ur = (i, e, t, n) => {
1670
+ for (var r = n > 1 ? void 0 : n ? dr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1669
1671
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
1670
- return n && r && cr(e, t, r), r;
1671
- }, te = (i, e) => (t, n) => e(t, n, i);
1672
- let Re = class extends W {
1672
+ return n && r && lr(e, t, r), r;
1673
+ }, ne = (i, e) => (t, n) => e(t, n, i);
1674
+ let Re = class extends X {
1673
1675
  constructor(i, e, t, n, r, s) {
1674
1676
  super(), this._logService = i, this._commandService = e, this._currentUniverService = t, this._docClipboardService = n, this._textSelectionManagerService = r, this._contextService = s, this._commandExecutedListener(), this.initialize();
1675
1677
  }
1676
1678
  initialize() {
1677
- [ke, ze, We].forEach(
1679
+ [ze, We, He].forEach(
1678
1680
  (i) => this.disposeWithMe(this._commandService.registerMultipleCommand(i))
1679
- ), [ft, we].forEach(
1681
+ ), [_t, Ne].forEach(
1680
1682
  (i) => this.disposeWithMe(this._commandService.registerCommand(i))
1681
1683
  );
1682
1684
  }
1683
1685
  _commandExecutedListener() {
1684
- const i = [ze.id, ke.id, We.id];
1686
+ const i = [We.id, ze.id, He.id];
1685
1687
  this.disposeWithMe(
1686
1688
  this._commandService.onCommandExecuted((e) => {
1687
- if (i.includes(e.id) && !(!this._contextService.getContextValue(w) && !this._contextService.getContextValue(fe)))
1689
+ if (i.includes(e.id) && !(!this._contextService.getContextValue(N) && !this._contextService.getContextValue(_e)))
1688
1690
  switch (e.id) {
1689
- case We.id: {
1691
+ case He.id: {
1690
1692
  this._handlePaste();
1691
1693
  break;
1692
1694
  }
1693
- case ke.id: {
1695
+ case ze.id: {
1694
1696
  this._handleCopy();
1695
1697
  break;
1696
1698
  }
1697
- case ze.id: {
1699
+ case We.id: {
1698
1700
  this._handleCut();
1699
1701
  break;
1700
1702
  }
@@ -1725,7 +1727,7 @@ let Re = class extends W {
1725
1727
  style: n
1726
1728
  }
1727
1729
  ];
1728
- this._commandService.executeCommand(ft.id, { body: s, segmentId: e, textRanges: a });
1730
+ this._commandService.executeCommand(_t.id, { body: s, segmentId: e, textRanges: a });
1729
1731
  } catch {
1730
1732
  this._logService.error("[DocClipboardController] clipboard is empty");
1731
1733
  }
@@ -1772,33 +1774,33 @@ let Re = class extends W {
1772
1774
  style: t
1773
1775
  }
1774
1776
  ];
1775
- this._commandService.executeCommand(we.id, { segmentId: i, textRanges: s });
1777
+ this._commandService.executeCommand(Ne.id, { segmentId: i, textRanges: s });
1776
1778
  } catch {
1777
1779
  this._logService.error("[DocClipboardController] cut content failed");
1778
1780
  }
1779
1781
  }
1780
1782
  }
1781
1783
  };
1782
- Re = dr([
1783
- V(F.Rendered, Re),
1784
- te(0, Ht),
1785
- te(1, x),
1786
- te(2, O),
1787
- te(3, Vt),
1788
- te(4, U(P)),
1789
- te(5, Gt)
1784
+ Re = ur([
1785
+ F(j.Rendered, Re),
1786
+ ne(0, Xt),
1787
+ ne(1, O),
1788
+ ne(2, y),
1789
+ ne(3, jt),
1790
+ ne(4, w(U)),
1791
+ ne(5, Gt)
1790
1792
  ], Re);
1791
- var ur = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, pr = (i, e, t, n) => {
1792
- for (var r = n > 1 ? void 0 : n ? hr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1793
+ var hr = Object.defineProperty, gr = Object.getOwnPropertyDescriptor, pr = (i, e, t, n) => {
1794
+ for (var r = n > 1 ? void 0 : n ? gr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1793
1795
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
1794
- return n && r && ur(e, t, r), r;
1795
- }, He = (i, e) => (t, n) => e(t, n, i);
1796
- let Ie = class extends me {
1796
+ return n && r && hr(e, t, r), r;
1797
+ }, Xe = (i, e) => (t, n) => e(t, n, i);
1798
+ let xe = class extends me {
1797
1799
  constructor(i, e, t) {
1798
1800
  super(), this._docSkeletonManagerService = i, this._renderManagerService = e, this._commandService = t, this._initialRenderRefresh(), this._commandExecutedListener();
1799
1801
  }
1800
1802
  _initialRenderRefresh() {
1801
- this._docSkeletonManagerService.currentSkeletonBefore$.pipe(Se(this.dispose$)).subscribe((i) => {
1803
+ this._docSkeletonManagerService.currentSkeletonBefore$.pipe(ve(this.dispose$)).subscribe((i) => {
1802
1804
  if (i == null)
1803
1805
  return;
1804
1806
  const { skeleton: e, unitId: t } = i, n = this._renderManagerService.getRenderById(t);
@@ -1814,14 +1816,14 @@ let Ie = class extends me {
1814
1816
  if (s == null)
1815
1817
  return;
1816
1818
  let o = 0, a = 0;
1817
- for (let l = 0, p = s.length; l < p; l++) {
1818
- const h = s[l], { pageWidth: u, pageHeight: g } = h;
1819
- r.pageLayoutType === at.VERTICAL ? (a += g, a += r.pageMarginTop, l === p - 1 && (a += r.pageMarginTop), o = Math.max(o, u)) : r.pageLayoutType === at.HORIZONTAL && (o += u, l !== p - 1 && (o += r.pageMarginLeft), a = Math.max(a, g));
1819
+ for (let l = 0, h = s.length; l < h; l++) {
1820
+ const g = s[l], { pageWidth: u, pageHeight: p } = g;
1821
+ r.pageLayoutType === ct.VERTICAL ? (a += p, a += r.pageMarginTop, l === h - 1 && (a += r.pageMarginTop), o = Math.max(o, u)) : r.pageLayoutType === ct.HORIZONTAL && (o += u, l !== h - 1 && (o += r.pageMarginLeft), a = Math.max(a, p));
1820
1822
  }
1821
- r.resize(o, a), [Z, K].includes(i.unitId) || n.resize(o, a);
1823
+ r.resize(o, a), [K, J].includes(i.unitId) || n.resize(o, a);
1822
1824
  }
1823
1825
  _commandExecutedListener() {
1824
- const i = [_.id], e = [Z, K];
1826
+ const i = [_.id], e = [K, J];
1825
1827
  this.disposeWithMe(
1826
1828
  this._commandService.onCommandExecuted((t) => {
1827
1829
  var n;
@@ -1842,21 +1844,21 @@ let Ie = class extends me {
1842
1844
  );
1843
1845
  }
1844
1846
  };
1845
- Ie = pr([
1846
- V(F.Rendered, Ie),
1847
- He(0, U(A)),
1848
- He(1, H),
1849
- He(2, x)
1850
- ], Ie);
1851
- var gr = Object.defineProperty, mr = Object.getOwnPropertyDescriptor, fr = (i, e, t, n) => {
1847
+ xe = pr([
1848
+ F(j.Rendered, xe),
1849
+ Xe(0, w(L)),
1850
+ Xe(1, G),
1851
+ Xe(2, O)
1852
+ ], xe);
1853
+ var fr = Object.defineProperty, mr = Object.getOwnPropertyDescriptor, _r = (i, e, t, n) => {
1852
1854
  for (var r = n > 1 ? void 0 : n ? mr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1853
1855
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
1854
- return n && r && gr(e, t, r), r;
1855
- }, oe = (i, e) => (t, n) => e(t, n, i);
1856
- let xe = class extends W {
1856
+ return n && r && fr(e, t, r), r;
1857
+ }, ae = (i, e) => (t, n) => e(t, n, i);
1858
+ let Oe = class extends X {
1857
1859
  constructor(e, t, n, r, s) {
1858
1860
  super();
1859
- S(this, "_liquid", new sn());
1861
+ S(this, "_liquid", new on());
1860
1862
  S(this, "_pageMarginCache", /* @__PURE__ */ new Map());
1861
1863
  this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService = n, this._commandService = r, this._floatingObjectManagerService = s, this._initialize(), this._commandExecutedListener();
1862
1864
  }
@@ -1871,14 +1873,14 @@ let xe = class extends W {
1871
1873
  const { unitId: n, skeleton: r } = t, s = this._renderManagerService.getRenderById(n);
1872
1874
  if (s == null)
1873
1875
  return;
1874
- const { mainComponent: o, components: a, scene: c } = s, d = o, { left: l, top: p } = d;
1875
- e.forEach((h) => {
1876
- const { unitId: u, subUnitId: g, floatingObjectId: m, floatingObject: f } = h, { left: v = 0, top: M = 0, width: T = 0, height: y = 0, angle: C, flipX: E, flipY: L, skewX: B, skewY: k } = f, I = this._pageMarginCache.get(m), G = (I == null ? void 0 : I.marginLeft) || 0, z = (I == null ? void 0 : I.marginTop) || 0;
1877
- r == null || r.getViewModel().getDataModel().updateDrawing(m, {
1878
- left: v - l - G,
1879
- top: M - p - z,
1880
- height: y,
1881
- width: T
1876
+ const { mainComponent: o, components: a, scene: c } = s, d = o, { left: l, top: h } = d;
1877
+ e.forEach((g) => {
1878
+ const { unitId: u, subUnitId: p, floatingObjectId: f, floatingObject: m } = g, { left: v = 0, top: M = 0, width: b = 0, height: T = 0, angle: C, flipX: x, flipY: P, skewX: B, skewY: k } = m, R = this._pageMarginCache.get(f), z = (R == null ? void 0 : R.marginLeft) || 0, W = (R == null ? void 0 : R.marginTop) || 0;
1879
+ r == null || r.getViewModel().getDataModel().updateDrawing(f, {
1880
+ left: v - l - z,
1881
+ top: M - h - W,
1882
+ height: T,
1883
+ width: b
1882
1884
  });
1883
1885
  }), r == null || r.calculate(), o == null || o.makeDirty();
1884
1886
  });
@@ -1895,7 +1897,7 @@ let xe = class extends W {
1895
1897
  });
1896
1898
  }
1897
1899
  _commandExecutedListener() {
1898
- const e = [_.id, Y.id], t = [Z, K];
1900
+ const e = [_.id, Z.id], t = [K, J];
1899
1901
  this.disposeWithMe(
1900
1902
  this._commandService.onCommandExecuted((n) => {
1901
1903
  var r;
@@ -1922,45 +1924,45 @@ let xe = class extends W {
1922
1924
  const r = t == null ? void 0 : t.getSkeletonData(), { mainComponent: s, scene: o } = n, a = s;
1923
1925
  if (!r)
1924
1926
  return;
1925
- const { left: c, top: d, pageLayoutType: l, pageMarginLeft: p, pageMarginTop: h } = a, { pages: u } = r, g = [];
1927
+ const { left: c, top: d, pageLayoutType: l, pageMarginLeft: h, pageMarginTop: g } = a, { pages: u } = r, p = [];
1926
1928
  o.getAncestorScale(), this._liquid.reset(), this._pageMarginCache.clear();
1927
- for (let m = 0, f = u.length; m < f; m++) {
1928
- const v = u[m], { skeDrawings: M, marginLeft: T, marginTop: y } = v;
1929
+ for (let f = 0, m = u.length; f < m; f++) {
1930
+ const v = u[f], { skeDrawings: M, marginLeft: b, marginTop: T } = v;
1929
1931
  this._liquid.translatePagePadding(v), M.forEach((C) => {
1930
- const { aLeft: E, aTop: L, height: B, width: k, objectId: I } = C;
1931
- g.push({
1932
+ const { aLeft: x, aTop: P, height: B, width: k, objectId: R } = C;
1933
+ p.push({
1932
1934
  unitId: e,
1933
- subUnitId: Xt,
1934
- floatingObjectId: I,
1935
+ subUnitId: Yt,
1936
+ floatingObjectId: R,
1935
1937
  floatingObject: {
1936
- left: E + c + this._liquid.x,
1937
- top: L + d + this._liquid.y,
1938
+ left: x + c + this._liquid.x,
1939
+ top: P + d + this._liquid.y,
1938
1940
  width: k,
1939
1941
  height: B
1940
1942
  }
1941
- }), this._pageMarginCache.set(I, {
1943
+ }), this._pageMarginCache.set(R, {
1942
1944
  marginLeft: this._liquid.x,
1943
1945
  marginTop: this._liquid.y
1944
1946
  });
1945
- }), this._liquid.translatePage(v, l, p, h);
1947
+ }), this._liquid.translatePage(v, l, h, g);
1946
1948
  }
1947
- this._floatingObjectManagerService.BatchAddOrUpdate(g);
1949
+ this._floatingObjectManagerService.BatchAddOrUpdate(p);
1948
1950
  }
1949
1951
  };
1950
- xe = fr([
1951
- V(F.Steady, xe),
1952
- oe(0, U(A)),
1953
- oe(1, O),
1954
- oe(2, H),
1955
- oe(3, x),
1956
- oe(4, qt)
1957
- ], xe);
1958
- var _r = Object.defineProperty, Sr = Object.getOwnPropertyDescriptor, vr = (i, e, t, n) => {
1959
- for (var r = n > 1 ? void 0 : n ? Sr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1952
+ Oe = _r([
1953
+ F(j.Steady, Oe),
1954
+ ae(0, w(L)),
1955
+ ae(1, y),
1956
+ ae(2, G),
1957
+ ae(3, O),
1958
+ ae(4, qt)
1959
+ ], Oe);
1960
+ var Sr = Object.defineProperty, vr = Object.getOwnPropertyDescriptor, Mr = (i, e, t, n) => {
1961
+ for (var r = n > 1 ? void 0 : n ? vr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
1960
1962
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
1961
- return n && r && _r(e, t, r), r;
1962
- }, ne = (i, e) => (t, n) => e(t, n, i);
1963
- let Oe = class extends W {
1963
+ return n && r && Sr(e, t, r), r;
1964
+ }, re = (i, e) => (t, n) => e(t, n, i);
1965
+ let ye = class extends X {
1964
1966
  constructor(e, t, n, r, s, o) {
1965
1967
  super();
1966
1968
  S(this, "_previousIMEContent", "");
@@ -1982,7 +1984,7 @@ let Oe = class extends W {
1982
1984
  if (e == null)
1983
1985
  return;
1984
1986
  const { activeRange: t } = e;
1985
- t != null && (this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(re.deepClone(t)), this._previousIMERange = t);
1987
+ t != null && (this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(ie.deepClone(t)), this._previousIMERange = t);
1986
1988
  });
1987
1989
  }
1988
1990
  _initialOnCompositionUpdate() {
@@ -1996,69 +1998,69 @@ let Oe = class extends W {
1996
1998
  });
1997
1999
  }
1998
2000
  async _updateContent(e, t) {
1999
- var g;
2000
- const n = (g = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : g.skeleton;
2001
+ var p;
2002
+ const n = (p = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : p.skeleton;
2001
2003
  if (this._previousIMERange == null || e == null || n == null)
2002
2004
  return;
2003
2005
  const r = this._currentUniverService.getCurrentUniverDocInstance(), { event: s, activeRange: o } = e, { startOffset: a, segmentId: c, style: d } = this._previousIMERange;
2004
2006
  if (n == null || o == null)
2005
2007
  return;
2006
- const p = s.data;
2007
- if (p === this._previousIMEContent && t)
2008
+ const h = s.data;
2009
+ if (h === this._previousIMEContent && t)
2008
2010
  return;
2009
- const h = p.length, u = [
2011
+ const g = h.length, u = [
2010
2012
  {
2011
- startOffset: a + h,
2012
- endOffset: a + h,
2013
+ startOffset: a + g,
2014
+ endOffset: a + g,
2013
2015
  style: d
2014
2016
  }
2015
2017
  ];
2016
2018
  await this._commandService.executeCommand(Lt.id, {
2017
2019
  unitId: r.getUnitId(),
2018
- newText: p,
2020
+ newText: h,
2019
2021
  oldTextLen: this._previousIMEContent.length,
2020
2022
  range: this._previousIMERange,
2021
2023
  textRanges: u,
2022
2024
  isCompositionEnd: !t,
2023
2025
  segmentId: c
2024
- }), t ? (this._previousIMERange.collapsed || (this._previousIMERange.collapsed = !0), this._previousIMEContent = p) : this._resetIME();
2026
+ }), t ? (this._previousIMERange.collapsed || (this._previousIMERange.collapsed = !0), this._previousIMEContent = h) : this._resetIME();
2025
2027
  }
2026
2028
  _resetIME() {
2027
2029
  this._previousIMEContent = "", this._previousIMERange = null, this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(null);
2028
2030
  }
2029
2031
  _getDocObject() {
2030
- return Ne(this._currentUniverService, this._renderManagerService);
2032
+ return $e(this._currentUniverService, this._renderManagerService);
2031
2033
  }
2032
2034
  };
2033
- Oe = vr([
2034
- V(F.Rendered, Oe),
2035
- ne(0, U(A)),
2036
- ne(1, O),
2037
- ne(2, H),
2038
- ne(3, _e),
2039
- ne(4, U(nt)),
2040
- ne(5, x)
2041
- ], Oe);
2042
- var Mr = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, Rr = (i, e, t, n) => {
2043
- for (var r = n > 1 ? void 0 : n ? Cr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2035
+ ye = Mr([
2036
+ F(j.Rendered, ye),
2037
+ re(0, w(L)),
2038
+ re(1, y),
2039
+ re(2, G),
2040
+ re(3, Se),
2041
+ re(4, w(rt)),
2042
+ re(5, O)
2043
+ ], ye);
2044
+ var Cr = Object.defineProperty, Ir = Object.getOwnPropertyDescriptor, Rr = (i, e, t, n) => {
2045
+ for (var r = n > 1 ? void 0 : n ? Ir(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2044
2046
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
2045
- return n && r && Mr(e, t, r), r;
2046
- }, Ct = (i, e) => (t, n) => e(t, n, i);
2047
- let ye = class extends W {
2047
+ return n && r && Cr(e, t, r), r;
2048
+ }, It = (i, e) => (t, n) => e(t, n, i);
2049
+ let be = class extends X {
2048
2050
  constructor(i, e) {
2049
2051
  super(), this._textSelectionManagerService = i, this._commandService = e, this._commandExecutedListener();
2050
2052
  }
2051
2053
  _commandExecutedListener() {
2052
2054
  const i = [
2053
- ue.id,
2054
- Be.id,
2055
- je.id,
2056
- Ve.id,
2057
- J.id,
2058
- se.id,
2059
2055
  he.id,
2056
+ Ve.id,
2057
+ Fe.id,
2058
+ je.id,
2059
+ Q.id,
2060
+ oe.id,
2061
+ ge.id,
2060
2062
  pe.id,
2061
- Fe.id
2063
+ ke.id
2062
2064
  ];
2063
2065
  this.disposeWithMe(
2064
2066
  this._commandService.onCommandExecuted((e) => {
@@ -2068,24 +2070,24 @@ let ye = class extends W {
2068
2070
  }
2069
2071
  _handleInlineFormat(i) {
2070
2072
  const { segmentId: e } = this._textSelectionManagerService.getActiveRange() ?? {};
2071
- e != null && this._commandService.executeCommand(Nt.id, {
2073
+ e != null && this._commandService.executeCommand($t.id, {
2072
2074
  segmentId: e,
2073
2075
  preCommandId: i.id,
2074
2076
  ...i.params ?? {}
2075
2077
  });
2076
2078
  }
2077
2079
  };
2078
- ye = Rr([
2079
- V(F.Rendered, ye),
2080
- Ct(0, U(P)),
2081
- Ct(1, x)
2082
- ], ye);
2083
- var Ir = Object.defineProperty, xr = Object.getOwnPropertyDescriptor, Or = (i, e, t, n) => {
2084
- for (var r = n > 1 ? void 0 : n ? xr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2080
+ be = Rr([
2081
+ F(j.Rendered, be),
2082
+ It(0, w(U)),
2083
+ It(1, O)
2084
+ ], be);
2085
+ var xr = Object.defineProperty, Or = Object.getOwnPropertyDescriptor, yr = (i, e, t, n) => {
2086
+ for (var r = n > 1 ? void 0 : n ? Or(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2085
2087
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
2086
- return n && r && Ir(e, t, r), r;
2087
- }, ae = (i, e) => (t, n) => e(t, n, i);
2088
- let be = class extends W {
2088
+ return n && r && xr(e, t, r), r;
2089
+ }, ce = (i, e) => (t, n) => e(t, n, i);
2090
+ let Te = class extends X {
2089
2091
  constructor(e, t, n, r, s) {
2090
2092
  super();
2091
2093
  S(this, "_onInputSubscription");
@@ -2098,16 +2100,16 @@ let be = class extends W {
2098
2100
  _initialize() {
2099
2101
  }
2100
2102
  _commandExecutedListener() {
2101
- const e = [Q.id, ee.id];
2103
+ const e = [ee.id, te.id];
2102
2104
  this.disposeWithMe(
2103
2105
  this._commandService.onCommandExecuted((t) => {
2104
2106
  if (!e.includes(t.id))
2105
2107
  return;
2106
2108
  const n = t.params;
2107
2109
  switch (t.id) {
2108
- case Q.id:
2109
- return this._handleMoveCursor(n.direction);
2110
2110
  case ee.id:
2111
+ return this._handleMoveCursor(n.direction);
2112
+ case te.id:
2111
2113
  return this._handleShiftMoveSelection(n.direction);
2112
2114
  default:
2113
2115
  throw new Error("Unknown command");
@@ -2116,80 +2118,80 @@ let be = class extends W {
2116
2118
  );
2117
2119
  }
2118
2120
  _handleShiftMoveSelection(e) {
2119
- var m;
2120
- const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), r = this._currentUniverService.getCurrentUniverDocInstance(), s = (m = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : m.skeleton, o = this._getDocObject();
2121
+ var f;
2122
+ const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), r = this._currentUniverService.getCurrentUniverDocInstance(), s = (f = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : f.skeleton, o = this._getDocObject();
2121
2123
  if (t == null || s == null || o == null)
2122
2124
  return;
2123
- const { startOffset: a, endOffset: c, style: d, collapsed: l, direction: p } = t;
2125
+ const { startOffset: a, endOffset: c, style: d, collapsed: l, direction: h } = t;
2124
2126
  if (n.length > 1) {
2125
- let f = 1 / 0, v = -1 / 0;
2127
+ let m = Number.POSITIVE_INFINITY, v = Number.NEGATIVE_INFINITY;
2126
2128
  for (const M of n)
2127
- f = Math.min(f, M.startOffset), v = Math.max(v, M.endOffset);
2129
+ m = Math.min(m, M.startOffset), v = Math.max(v, M.endOffset);
2128
2130
  this._textSelectionManagerService.replaceTextRanges([
2129
2131
  {
2130
- startOffset: e === b.LEFT || e === b.UP ? v : f,
2131
- endOffset: e === b.LEFT || e === b.UP ? f : v,
2132
+ startOffset: e === D.LEFT || e === D.UP ? v : m,
2133
+ endOffset: e === D.LEFT || e === D.UP ? m : v,
2132
2134
  style: d
2133
2135
  }
2134
2136
  ]);
2135
2137
  return;
2136
2138
  }
2137
- const h = l || p === ct.FORWARD ? a : c;
2138
- let u = l || p === ct.FORWARD ? c : a;
2139
- const g = r.getBody().dataStream.length ?? 1 / 0;
2140
- if (e === b.LEFT || e === b.RIGHT) {
2141
- const f = s.findNodeByCharIndex(u - 1), v = s.findNodeByCharIndex(u);
2142
- u = e === b.RIGHT ? u + v.count : u - ((f == null ? void 0 : f.count) ?? 0), u = Math.min(g - 2, Math.max(0, u)), this._textSelectionManagerService.replaceTextRanges([
2139
+ const g = l || h === lt.FORWARD ? a : c;
2140
+ let u = l || h === lt.FORWARD ? c : a;
2141
+ const p = r.getBody().dataStream.length ?? Number.POSITIVE_INFINITY;
2142
+ if (e === D.LEFT || e === D.RIGHT) {
2143
+ const m = s.findNodeByCharIndex(u - 1), v = s.findNodeByCharIndex(u);
2144
+ u = e === D.RIGHT ? u + v.count : u - ((m == null ? void 0 : m.count) ?? 0), u = Math.min(p - 2, Math.max(0, u)), this._textSelectionManagerService.replaceTextRanges([
2143
2145
  {
2144
- startOffset: h,
2146
+ startOffset: g,
2145
2147
  endOffset: u,
2146
2148
  style: d
2147
2149
  }
2148
2150
  ]);
2149
2151
  } else {
2150
- const f = s.findNodeByCharIndex(u), v = o.document.getOffsetConfig(), M = this._getTopOrBottomPosition(s, f, e === b.DOWN);
2152
+ const m = s.findNodeByCharIndex(u), v = o.document.getOffsetConfig(), M = this._getTopOrBottomPosition(s, m, e === D.DOWN);
2151
2153
  if (M == null) {
2152
- const y = e === b.UP ? 0 : g - 2;
2153
- if (y === u)
2154
+ const T = e === D.UP ? 0 : p - 2;
2155
+ if (T === u)
2154
2156
  return;
2155
2157
  this._textSelectionManagerService.replaceTextRanges([
2156
2158
  {
2157
- startOffset: h,
2158
- endOffset: y,
2159
+ startOffset: g,
2160
+ endOffset: T,
2159
2161
  style: d
2160
2162
  }
2161
2163
  ]);
2162
2164
  return;
2163
2165
  }
2164
- const T = new lt(v, s).getRangePointData(
2166
+ const b = new dt(v, s).getRangePointData(
2165
2167
  M,
2166
2168
  M
2167
2169
  ).cursorList[0];
2168
2170
  this._textSelectionManagerService.replaceTextRanges([
2169
2171
  {
2170
- startOffset: h,
2171
- endOffset: T.endOffset,
2172
+ startOffset: g,
2173
+ endOffset: b.endOffset,
2172
2174
  style: d
2173
2175
  }
2174
2176
  ]);
2175
2177
  }
2176
2178
  }
2177
2179
  _handleMoveCursor(e) {
2178
- var h;
2179
- const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), r = this._currentUniverService.getCurrentUniverDocInstance(), s = (h = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : h.skeleton, o = this._getDocObject();
2180
+ var g;
2181
+ const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), r = this._currentUniverService.getCurrentUniverDocInstance(), s = (g = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : g.skeleton, o = this._getDocObject();
2180
2182
  if (t == null || s == null || o == null || n == null)
2181
2183
  return;
2182
- const { startOffset: a, endOffset: c, style: d, collapsed: l } = t, p = r.getBody().dataStream.length ?? 1 / 0;
2183
- if (e === b.LEFT || e === b.RIGHT) {
2184
+ const { startOffset: a, endOffset: c, style: d, collapsed: l } = t, h = r.getBody().dataStream.length ?? Number.POSITIVE_INFINITY;
2185
+ if (e === D.LEFT || e === D.RIGHT) {
2184
2186
  let u;
2185
2187
  if (!t.collapsed || n.length > 1) {
2186
- let g = 1 / 0, m = -1 / 0;
2187
- for (const f of n)
2188
- g = Math.min(g, f.startOffset), m = Math.max(m, f.endOffset);
2189
- u = e === b.LEFT ? g : m;
2188
+ let p = Number.POSITIVE_INFINITY, f = Number.NEGATIVE_INFINITY;
2189
+ for (const m of n)
2190
+ p = Math.min(p, m.startOffset), f = Math.max(f, m.endOffset);
2191
+ u = e === D.LEFT ? p : f;
2190
2192
  } else {
2191
- const g = s.findNodeByCharIndex(a - 1), m = s.findNodeByCharIndex(a);
2192
- e === b.LEFT ? u = Math.max(0, a - ((g == null ? void 0 : g.count) ?? 0)) : u = Math.min(p - 2, c + m.count);
2193
+ const p = s.findNodeByCharIndex(a - 1), f = s.findNodeByCharIndex(a);
2194
+ e === D.LEFT ? u = Math.max(0, a - ((p == null ? void 0 : p.count) ?? 0)) : u = Math.min(h - 2, c + f.count);
2193
2195
  }
2194
2196
  this._textSelectionManagerService.replaceTextRanges([
2195
2197
  {
@@ -2199,14 +2201,14 @@ let be = class extends W {
2199
2201
  }
2200
2202
  ]);
2201
2203
  } else {
2202
- const u = s.findNodeByCharIndex(a), g = s.findNodeByCharIndex(c), m = o.document.getOffsetConfig(), f = this._getTopOrBottomPosition(
2204
+ const u = s.findNodeByCharIndex(a), p = s.findNodeByCharIndex(c), f = o.document.getOffsetConfig(), m = this._getTopOrBottomPosition(
2203
2205
  s,
2204
- e === b.UP ? u : g,
2205
- e === b.DOWN
2206
+ e === D.UP ? u : p,
2207
+ e === D.DOWN
2206
2208
  );
2207
- if (f == null) {
2209
+ if (m == null) {
2208
2210
  let M;
2209
- l ? M = e === b.UP ? 0 : p - 2 : M = e === b.UP ? a : c, this._textSelectionManagerService.replaceTextRanges([
2211
+ l ? M = e === D.UP ? 0 : h - 2 : M = e === D.UP ? a : c, this._textSelectionManagerService.replaceTextRanges([
2210
2212
  {
2211
2213
  startOffset: M,
2212
2214
  endOffset: M,
@@ -2215,9 +2217,9 @@ let be = class extends W {
2215
2217
  ]);
2216
2218
  return;
2217
2219
  }
2218
- const v = new lt(m, s).getRangePointData(
2219
- f,
2220
- f
2220
+ const v = new dt(f, s).getRangePointData(
2221
+ m,
2222
+ m
2221
2223
  ).cursorList[0];
2222
2224
  this._textSelectionManagerService.replaceTextRanges([
2223
2225
  {
@@ -2240,13 +2242,13 @@ let be = class extends W {
2240
2242
  _getSpanLeftOffsetInLine(e) {
2241
2243
  const t = e.parent;
2242
2244
  if (t == null)
2243
- return -1 / 0;
2245
+ return Number.NEGATIVE_INFINITY;
2244
2246
  const n = t.left, { left: r } = e;
2245
2247
  return n + r;
2246
2248
  }
2247
2249
  _matchPositionByLeftOffset(e, t, n) {
2248
2250
  const r = {
2249
- distance: 1 / 0
2251
+ distance: Number.POSITIVE_INFINITY
2250
2252
  };
2251
2253
  for (const s of t.divides) {
2252
2254
  const o = s.left;
@@ -2259,7 +2261,7 @@ let be = class extends W {
2259
2261
  return e.findPositionBySpan(r.span);
2260
2262
  }
2261
2263
  _getNextOrPrevLine(e, t) {
2262
- var g, m, f, v, M, T, y, C, E, L, B, k;
2264
+ var p, f, m, v, M, b, T, C, x, P, B, k;
2263
2265
  const n = e.parent;
2264
2266
  if (n == null)
2265
2267
  return;
@@ -2282,63 +2284,63 @@ let be = class extends W {
2282
2284
  if (d === -1)
2283
2285
  return;
2284
2286
  if (t === !0)
2285
- a = (g = c.columns[d + 1]) == null ? void 0 : g.lines[0];
2287
+ a = (p = c.columns[d + 1]) == null ? void 0 : p.lines[0];
2286
2288
  else {
2287
- const I = (f = (m = c.columns) == null ? void 0 : m[d - 1]) == null ? void 0 : f.lines;
2288
- a = I == null ? void 0 : I[I.length - 1];
2289
+ const R = (m = (f = c.columns) == null ? void 0 : f[d - 1]) == null ? void 0 : m.lines;
2290
+ a = R == null ? void 0 : R[R.length - 1];
2289
2291
  }
2290
2292
  if (a != null)
2291
2293
  return a;
2292
2294
  const l = c.parent;
2293
2295
  if (l == null)
2294
2296
  return;
2295
- const p = l.sections.indexOf(c);
2296
- if (p === -1)
2297
+ const h = l.sections.indexOf(c);
2298
+ if (h === -1)
2297
2299
  return;
2298
2300
  if (t === !0)
2299
- a = (M = (v = l.sections[p - 1]) == null ? void 0 : v.columns[0]) == null ? void 0 : M.lines[0];
2301
+ a = (M = (v = l.sections[h - 1]) == null ? void 0 : v.columns[0]) == null ? void 0 : M.lines[0];
2300
2302
  else {
2301
- const I = (y = (T = l.sections) == null ? void 0 : T[p - 1]) == null ? void 0 : y.columns, G = I == null ? void 0 : I[I.length - 1], z = G == null ? void 0 : G.lines;
2302
- a = z == null ? void 0 : z[z.length - 1];
2303
+ const R = (T = (b = l.sections) == null ? void 0 : b[h - 1]) == null ? void 0 : T.columns, z = R == null ? void 0 : R[R.length - 1], W = z == null ? void 0 : z.lines;
2304
+ a = W == null ? void 0 : W[W.length - 1];
2303
2305
  }
2304
2306
  if (a != null)
2305
2307
  return a;
2306
- const h = l.parent;
2307
- if (h == null)
2308
+ const g = l.parent;
2309
+ if (g == null)
2308
2310
  return;
2309
- const u = h.pages.indexOf(l);
2311
+ const u = g.pages.indexOf(l);
2310
2312
  if (u !== -1) {
2311
2313
  if (t === !0)
2312
- a = (L = (E = (C = h.pages[u + 1]) == null ? void 0 : C.sections[0]) == null ? void 0 : E.columns[0]) == null ? void 0 : L.lines[0];
2314
+ a = (P = (x = (C = g.pages[u + 1]) == null ? void 0 : C.sections[0]) == null ? void 0 : x.columns[0]) == null ? void 0 : P.lines[0];
2313
2315
  else {
2314
- const I = (B = h.pages[u - 1]) == null ? void 0 : B.sections;
2315
- if (I == null)
2316
+ const R = (B = g.pages[u - 1]) == null ? void 0 : B.sections;
2317
+ if (R == null)
2316
2318
  return;
2317
- const G = (k = I[I.length - 1]) == null ? void 0 : k.columns, z = G[G.length - 1], st = z == null ? void 0 : z.lines;
2318
- a = st[st.length - 1];
2319
+ const z = (k = R[R.length - 1]) == null ? void 0 : k.columns, W = z[z.length - 1], ot = W == null ? void 0 : W.lines;
2320
+ a = ot[ot.length - 1];
2319
2321
  }
2320
2322
  if (a != null)
2321
2323
  return a;
2322
2324
  }
2323
2325
  }
2324
2326
  _getDocObject() {
2325
- return Ne(this._currentUniverService, this._renderManagerService);
2327
+ return $e(this._currentUniverService, this._renderManagerService);
2326
2328
  }
2327
2329
  };
2328
- be = Or([
2329
- V(F.Rendered, be),
2330
- ae(0, U(A)),
2331
- ae(1, O),
2332
- ae(2, H),
2333
- ae(3, U(P)),
2334
- ae(4, x)
2335
- ], be);
2336
- var yr = Object.defineProperty, br = Object.getOwnPropertyDescriptor, Dr = (i, e, t, n) => {
2337
- for (var r = n > 1 ? void 0 : n ? br(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2330
+ Te = yr([
2331
+ F(j.Rendered, Te),
2332
+ ce(0, w(L)),
2333
+ ce(1, y),
2334
+ ce(2, G),
2335
+ ce(3, w(U)),
2336
+ ce(4, O)
2337
+ ], Te);
2338
+ var br = Object.defineProperty, Tr = Object.getOwnPropertyDescriptor, Dr = (i, e, t, n) => {
2339
+ for (var r = n > 1 ? void 0 : n ? Tr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2338
2340
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
2339
- return n && r && yr(e, t, r), r;
2340
- }, ce = (i, e) => (t, n) => e(t, n, i);
2341
- let De = class extends W {
2341
+ return n && r && br(e, t, r), r;
2342
+ }, le = (i, e) => (t, n) => e(t, n, i);
2343
+ let De = class extends X {
2342
2344
  constructor(e, t, n, r, s) {
2343
2345
  super();
2344
2346
  S(this, "_onInputSubscription");
@@ -2353,20 +2355,20 @@ let De = class extends W {
2353
2355
  }
2354
2356
  _initialNormalInput() {
2355
2357
  this._onInputSubscription = this._textSelectionRenderManager.onInput$.subscribe(async (e) => {
2356
- var g;
2358
+ var p;
2357
2359
  if (e == null)
2358
2360
  return;
2359
- const n = this._currentUniverService.getCurrentUniverDocInstance().getUnitId(), { event: r, content: s = "", activeRange: o } = e, a = r, c = (g = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : g.skeleton;
2361
+ const n = this._currentUniverService.getCurrentUniverDocInstance().getUnitId(), { event: r, content: s = "", activeRange: o } = e, a = r, c = (p = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : p.skeleton;
2360
2362
  if (a.data == null || c == null || !c || !o)
2361
2363
  return;
2362
- const { startOffset: d, segmentId: l, style: p } = o, h = s.length, u = [
2364
+ const { startOffset: d, segmentId: l, style: h } = o, g = s.length, u = [
2363
2365
  {
2364
- startOffset: d + h,
2365
- endOffset: d + h,
2366
- style: p
2366
+ startOffset: d + g,
2367
+ endOffset: d + g,
2368
+ style: h
2367
2369
  }
2368
2370
  ];
2369
- await this._commandService.executeCommand(Qe.id, {
2371
+ await this._commandService.executeCommand(et.id, {
2370
2372
  unitId: n,
2371
2373
  body: {
2372
2374
  dataStream: s
@@ -2380,24 +2382,24 @@ let De = class extends W {
2380
2382
  _commandExecutedListener() {
2381
2383
  }
2382
2384
  _getDocObject() {
2383
- return Ne(this._currentUniverService, this._renderManagerService);
2385
+ return $e(this._currentUniverService, this._renderManagerService);
2384
2386
  }
2385
2387
  };
2386
2388
  De = Dr([
2387
- V(F.Rendered, De),
2388
- ce(0, U(A)),
2389
- ce(1, O),
2390
- ce(2, H),
2391
- ce(3, _e),
2392
- ce(4, x)
2389
+ F(j.Rendered, De),
2390
+ le(0, w(L)),
2391
+ le(1, y),
2392
+ le(2, G),
2393
+ le(3, Se),
2394
+ le(4, O)
2393
2395
  ], De);
2394
- var Tr = Object.defineProperty, Pr = Object.getOwnPropertyDescriptor, Er = (i, e, t, n) => {
2395
- for (var r = n > 1 ? void 0 : n ? Pr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2396
+ var Pr = Object.defineProperty, Er = Object.getOwnPropertyDescriptor, Ur = (i, e, t, n) => {
2397
+ for (var r = n > 1 ? void 0 : n ? Er(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2396
2398
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
2397
- return n && r && Tr(e, t, r), r;
2399
+ return n && r && Pr(e, t, r), r;
2398
2400
  }, Rt = (i, e) => (t, n) => e(t, n, i);
2399
- const Ur = "rgba(198, 198, 198, 1)", wr = "rgba(255, 255, 255, 1)";
2400
- let Te = class extends W {
2401
+ const wr = "rgba(198, 198, 198, 1)", Nr = "rgba(255, 255, 255, 1)";
2402
+ let Pe = class extends X {
2401
2403
  constructor(i, e) {
2402
2404
  super(), this._renderManagerService = i, this._currentUniverService = e, this._initialize(), this._commandExecutedListener();
2403
2405
  }
@@ -2414,15 +2416,15 @@ let Te = class extends W {
2414
2416
  return;
2415
2417
  const { mainComponent: t } = e, n = t, r = (s = n.getSkeleton()) == null ? void 0 : s.getPageSize();
2416
2418
  n.onPageRenderObservable.add((o) => {
2417
- if ([Z, K].includes(i))
2419
+ if ([K, J].includes(i))
2418
2420
  return;
2419
- const { page: a, pageLeft: c, pageTop: d, ctx: l } = o, { width: p, pageWidth: h, height: u, pageHeight: g } = a;
2420
- l.save(), l.translate(c - 0.5, d - 0.5), on.drawWith(l, {
2421
- width: (r == null ? void 0 : r.width) ?? h ?? p,
2422
- height: (r == null ? void 0 : r.height) ?? g ?? u,
2421
+ const { page: a, pageLeft: c, pageTop: d, ctx: l } = o, { width: h, pageWidth: g, height: u, pageHeight: p } = a;
2422
+ l.save(), l.translate(c - 0.5, d - 0.5), an.drawWith(l, {
2423
+ width: (r == null ? void 0 : r.width) ?? g ?? h,
2424
+ height: (r == null ? void 0 : r.height) ?? p ?? u,
2423
2425
  strokeWidth: 1,
2424
- stroke: Ur,
2425
- fill: wr,
2426
+ stroke: wr,
2427
+ fill: Nr,
2426
2428
  zIndex: 3
2427
2429
  }), l.restore();
2428
2430
  });
@@ -2431,17 +2433,17 @@ let Te = class extends W {
2431
2433
  _commandExecutedListener() {
2432
2434
  }
2433
2435
  };
2434
- Te = Er([
2435
- V(F.Rendered, Te),
2436
- Rt(0, H),
2437
- Rt(1, U(O))
2438
- ], Te);
2439
- var Lr = Object.defineProperty, Ar = Object.getOwnPropertyDescriptor, Nr = (i, e, t, n) => {
2436
+ Pe = Ur([
2437
+ F(j.Rendered, Pe),
2438
+ Rt(0, G),
2439
+ Rt(1, w(y))
2440
+ ], Pe);
2441
+ var Lr = Object.defineProperty, Ar = Object.getOwnPropertyDescriptor, $r = (i, e, t, n) => {
2440
2442
  for (var r = n > 1 ? void 0 : n ? Ar(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2441
2443
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
2442
2444
  return n && r && Lr(e, t, r), r;
2443
2445
  }, q = (i, e) => (t, n) => e(t, n, i);
2444
- let Pe = class extends W {
2446
+ let Ee = class extends X {
2445
2447
  constructor(e, t, n, r, s, o, a) {
2446
2448
  super();
2447
2449
  S(this, "_moveInObserver");
@@ -2456,6 +2458,7 @@ let Pe = class extends W {
2456
2458
  }
2457
2459
  _initialize() {
2458
2460
  this._skeletonListener(), this._commandExecutedListener(), this._layoutService && this.disposeWithMe(
2461
+ // the content editable div should be regarded as part of the applications container
2459
2462
  this._layoutService.registerContainer(this._textSelectionRenderManager.__getEditorContainer())
2460
2463
  );
2461
2464
  }
@@ -2471,9 +2474,9 @@ let Pe = class extends W {
2471
2474
  return;
2472
2475
  const { document: n, scene: r } = t;
2473
2476
  this._moveInObserver = n.onPointerEnterObserver.add(() => {
2474
- n.cursor = dt.TEXT;
2477
+ n.cursor = ut.TEXT;
2475
2478
  }), this._moveOutObserver = n.onPointerLeaveObserver.add(() => {
2476
- n.cursor = dt.DEFAULT, r.resetCursor();
2479
+ n.cursor = ut.DEFAULT, r.resetCursor();
2477
2480
  }), this._downObserver = n == null ? void 0 : n.onPointerDownObserver.add((s, o) => {
2478
2481
  this._currentUniverService.getCurrentUniverDocInstance().getUnitId() !== e && this._currentUniverService.setCurrentUniverDocInstance(e), this._textSelectionRenderManager.eventTrigger(s), s.button !== 2 && o.stopPropagation();
2479
2482
  }), this._dblClickObserver = n == null ? void 0 : n.onDblclickObserver.add((s) => {
@@ -2483,7 +2486,7 @@ let Pe = class extends W {
2483
2486
  });
2484
2487
  }
2485
2488
  _commandExecutedListener() {
2486
- const e = [Y.id];
2489
+ const e = [Z.id];
2487
2490
  this.disposeWithMe(
2488
2491
  this._commandService.onCommandExecuted((t) => {
2489
2492
  var n;
@@ -2511,25 +2514,25 @@ let Pe = class extends W {
2511
2514
  });
2512
2515
  }
2513
2516
  _getDocObjectById(e) {
2514
- return In(e, this._renderManagerService);
2517
+ return xn(e, this._renderManagerService);
2515
2518
  }
2516
2519
  };
2517
- Pe = Nr([
2518
- V(F.Rendered, Pe),
2519
- q(0, U(A)),
2520
- q(1, O),
2521
- q(2, x),
2522
- q(3, H),
2523
- q(4, _e),
2524
- q(5, U(P)),
2525
- q(6, Cn(Sn))
2526
- ], Pe);
2527
- var $r = Object.defineProperty, Br = Object.getOwnPropertyDescriptor, jr = (i, e, t, n) => {
2528
- for (var r = n > 1 ? void 0 : n ? Br(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2520
+ Ee = $r([
2521
+ F(j.Rendered, Ee),
2522
+ q(0, w(L)),
2523
+ q(1, y),
2524
+ q(2, O),
2525
+ q(3, G),
2526
+ q(4, Se),
2527
+ q(5, w(U)),
2528
+ q(6, In(vn))
2529
+ ], Ee);
2530
+ var Br = Object.defineProperty, Vr = Object.getOwnPropertyDescriptor, Fr = (i, e, t, n) => {
2531
+ for (var r = n > 1 ? void 0 : n ? Vr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2529
2532
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
2530
- return n && r && $r(e, t, r), r;
2531
- }, le = (i, e) => (t, n) => e(t, n, i);
2532
- let Ee = class extends W {
2533
+ return n && r && Br(e, t, r), r;
2534
+ }, de = (i, e) => (t, n) => e(t, n, i);
2535
+ let Ue = class extends X {
2533
2536
  constructor(e, t, n, r, s) {
2534
2537
  super();
2535
2538
  S(this, "_initializedRender", /* @__PURE__ */ new Set());
@@ -2546,7 +2549,7 @@ let Ee = class extends W {
2546
2549
  if (e == null)
2547
2550
  return;
2548
2551
  const { unitId: t } = e, n = this._renderManagerService.getRenderById(t);
2549
- if (n == null || this._initializedRender.has(t) || [Z, K].includes(t))
2552
+ if (n == null || this._initializedRender.has(t) || [K, J].includes(t))
2550
2553
  return;
2551
2554
  this._initializedRender.add(t);
2552
2555
  const { scene: r } = n;
@@ -2560,7 +2563,7 @@ let Ee = class extends W {
2560
2563
  a *= s.deltaY > 0 ? -1 : 1, r.scaleX < 1 && (a /= 2);
2561
2564
  const c = this._currentUniverService.getCurrentUniverDocInstance(), d = c.zoomRatio;
2562
2565
  let l = +parseFloat(`${d + a}`).toFixed(1);
2563
- l = l >= 4 ? 4 : l <= 0.1 ? 0.1 : l, this._commandService.executeCommand(Bt.id, {
2566
+ l = l >= 4 ? 4 : l <= 0.1 ? 0.1 : l, this._commandService.executeCommand(Vt.id, {
2564
2567
  zoomRatio: l,
2565
2568
  unitId: c.getUnitId()
2566
2569
  }), s.preventDefault();
@@ -2589,7 +2592,7 @@ let Ee = class extends W {
2589
2592
  );
2590
2593
  }
2591
2594
  _commandExecutedListener() {
2592
- const e = [Y.id];
2595
+ const e = [Z.id];
2593
2596
  this.disposeWithMe(
2594
2597
  this._commandService.onCommandExecuted((t) => {
2595
2598
  if (e.includes(t.id)) {
@@ -2611,12 +2614,12 @@ let Ee = class extends W {
2611
2614
  const { document: n, scene: r } = e, s = r == null ? void 0 : r.getParent(), { width: o, height: a, pageMarginLeft: c, pageMarginTop: d } = n;
2612
2615
  if (s == null || o === 1 / 0 || a === 1 / 0)
2613
2616
  return;
2614
- const { width: l, height: p } = s;
2615
- let h = 0, u = 0, g = 0, m = 0, f = 1 / 0;
2616
- l > (o + c * 2) * t ? (h = l / 2 - o * t / 2, h /= t, g = (l - c * 2) / t, f = 0) : (h = c, g = o + c * 2, f = (g - l / t) / 2), p > a ? (u = p / 2 - a / 2, m = (p - d * 2) / t) : (u = d, m = a + d * 2), r.resize(g, m + 200), n.translate(h, u);
2617
- const v = r.getViewport(Je.VIEW_MAIN);
2618
- if (f !== 1 / 0 && v != null) {
2619
- const M = v.getBarScroll(f, 0).x;
2617
+ const { width: l, height: h } = s;
2618
+ let g = 0, u = 0, p = 0, f = 0, m = 1 / 0;
2619
+ l > (o + c * 2) * t ? (g = l / 2 - o * t / 2, g /= t, p = (l - c * 2) / t, m = 0) : (g = c, p = o + c * 2, m = (p - l / t) / 2), h > a ? (u = h / 2 - a / 2, f = (h - d * 2) / t) : (u = d, f = a + d * 2), r.resize(p, f + 200), n.translate(g, u);
2620
+ const v = r.getViewport(Qe.VIEW_MAIN);
2621
+ if (m !== 1 / 0 && v != null) {
2622
+ const M = v.getBarScroll(m, 0).x;
2620
2623
  v.scrollTo({
2621
2624
  x: M
2622
2625
  });
@@ -2624,107 +2627,107 @@ let Ee = class extends W {
2624
2627
  return this;
2625
2628
  }
2626
2629
  _getDocObject() {
2627
- return Ne(this._currentUniverService, this._renderManagerService);
2630
+ return $e(this._currentUniverService, this._renderManagerService);
2628
2631
  }
2629
2632
  };
2630
- Ee = jr([
2631
- V(F.Rendered, Ee),
2632
- le(0, U(A)),
2633
- le(1, O),
2634
- le(2, x),
2635
- le(3, H),
2636
- le(4, U(P))
2637
- ], Ee);
2638
- const Vr = {
2639
- id: Pt.id,
2640
- preconditions: (i) => i.getContextValue(w),
2641
- binding: $.ENTER
2642
- }, Fr = {
2633
+ Ue = Fr([
2634
+ F(j.Rendered, Ue),
2635
+ de(0, w(L)),
2636
+ de(1, y),
2637
+ de(2, O),
2638
+ de(3, G),
2639
+ de(4, w(U))
2640
+ ], Ue);
2641
+ const jr = {
2643
2642
  id: Et.id,
2644
- preconditions: (i) => i.getContextValue(w),
2645
- binding: $.BACKSPACE
2643
+ preconditions: (i) => i.getContextValue(N),
2644
+ binding: $.ENTER
2646
2645
  }, kr = {
2647
2646
  id: Ut.id,
2648
- preconditions: (i) => i.getContextValue(w),
2649
- binding: $.DELETE
2647
+ preconditions: (i) => i.getContextValue(N),
2648
+ binding: $.BACKSPACE
2650
2649
  }, zr = {
2651
- id: Q.id,
2650
+ id: wt.id,
2651
+ preconditions: (i) => i.getContextValue(N),
2652
+ binding: $.DELETE
2653
+ }, Wr = {
2654
+ id: ee.id,
2652
2655
  binding: $.ARROW_UP,
2653
- preconditions: (i) => i.getContextValue(w),
2656
+ preconditions: (i) => i.getContextValue(N),
2654
2657
  staticParameters: {
2655
- direction: b.UP
2658
+ direction: D.UP
2656
2659
  }
2657
- }, Wr = {
2658
- id: Q.id,
2660
+ }, Hr = {
2661
+ id: ee.id,
2659
2662
  binding: $.ARROW_DOWN,
2660
- preconditions: (i) => i.getContextValue(w),
2663
+ preconditions: (i) => i.getContextValue(N),
2661
2664
  staticParameters: {
2662
- direction: b.DOWN
2665
+ direction: D.DOWN
2663
2666
  }
2664
- }, Hr = {
2665
- id: Q.id,
2667
+ }, Xr = {
2668
+ id: ee.id,
2666
2669
  binding: $.ARROW_LEFT,
2667
- preconditions: (i) => i.getContextValue(w),
2670
+ preconditions: (i) => i.getContextValue(N),
2668
2671
  staticParameters: {
2669
- direction: b.LEFT
2672
+ direction: D.LEFT
2670
2673
  }
2671
2674
  }, Gr = {
2672
- id: Q.id,
2675
+ id: ee.id,
2673
2676
  binding: $.ARROW_RIGHT,
2674
- preconditions: (i) => i.getContextValue(w),
2677
+ preconditions: (i) => i.getContextValue(N),
2675
2678
  staticParameters: {
2676
- direction: b.RIGHT
2679
+ direction: D.RIGHT
2677
2680
  }
2678
- }, Xr = {
2679
- id: ee.id,
2680
- binding: $.ARROW_UP | ve.SHIFT,
2681
- preconditions: (i) => i.getContextValue(w),
2681
+ }, Yr = {
2682
+ id: te.id,
2683
+ binding: $.ARROW_UP | Me.SHIFT,
2684
+ preconditions: (i) => i.getContextValue(N),
2682
2685
  staticParameters: {
2683
- direction: b.UP
2686
+ direction: D.UP
2684
2687
  }
2685
2688
  }, qr = {
2686
- id: ee.id,
2687
- binding: $.ARROW_DOWN | ve.SHIFT,
2688
- preconditions: (i) => i.getContextValue(w),
2689
+ id: te.id,
2690
+ binding: $.ARROW_DOWN | Me.SHIFT,
2691
+ preconditions: (i) => i.getContextValue(N),
2689
2692
  staticParameters: {
2690
- direction: b.DOWN
2691
- }
2692
- }, Yr = {
2693
- id: ee.id,
2694
- binding: $.ARROW_LEFT | ve.SHIFT,
2695
- preconditions: (i) => i.getContextValue(w),
2696
- staticParameters: {
2697
- direction: b.LEFT
2693
+ direction: D.DOWN
2698
2694
  }
2699
2695
  }, Zr = {
2700
- id: ee.id,
2701
- binding: $.ARROW_RIGHT | ve.SHIFT,
2702
- preconditions: (i) => i.getContextValue(w),
2696
+ id: te.id,
2697
+ binding: $.ARROW_LEFT | Me.SHIFT,
2698
+ preconditions: (i) => i.getContextValue(N),
2703
2699
  staticParameters: {
2704
- direction: b.RIGHT
2700
+ direction: D.LEFT
2705
2701
  }
2706
2702
  }, Kr = {
2707
- id: jt.id,
2708
- binding: $.A | ve.CTRL_COMMAND,
2709
- preconditions: (i) => i.getContextValue(w) || i.getContextValue(fe)
2703
+ id: te.id,
2704
+ binding: $.ARROW_RIGHT | Me.SHIFT,
2705
+ preconditions: (i) => i.getContextValue(N),
2706
+ staticParameters: {
2707
+ direction: D.RIGHT
2708
+ }
2709
+ }, Jr = {
2710
+ id: Ft.id,
2711
+ binding: $.A | Me.CTRL_COMMAND,
2712
+ preconditions: (i) => i.getContextValue(N) || i.getContextValue(_e)
2710
2713
  };
2711
- var Jr = Object.defineProperty, Qr = Object.getOwnPropertyDescriptor, ei = (i, e, t, n) => {
2712
- for (var r = n > 1 ? void 0 : n ? Qr(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2714
+ var Qr = Object.defineProperty, ei = Object.getOwnPropertyDescriptor, ti = (i, e, t, n) => {
2715
+ for (var r = n > 1 ? void 0 : n ? ei(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2713
2716
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
2714
- return n && r && Jr(e, t, r), r;
2715
- }, Me = (i, e) => (t, n) => e(t, n, i);
2716
- let Ue = class extends me {
2717
+ return n && r && Qr(e, t, r), r;
2718
+ }, Ce = (i, e) => (t, n) => e(t, n, i);
2719
+ let we = class extends me {
2717
2720
  constructor(e, t, n, r) {
2718
2721
  super();
2719
2722
  S(this, "_scene");
2720
2723
  S(this, "_currentDocumentModel");
2721
2724
  S(this, "_loadedMap", /* @__PURE__ */ new Set());
2722
- S(this, "_fps$", new de(""));
2725
+ S(this, "_fps$", new ue(""));
2723
2726
  S(this, "fps$", this._fps$.asObservable());
2724
2727
  this._renderManagerService = e, this._configService = t, this._currentUniverService = n, this._docViewModelManagerService = r, this._initialize();
2725
2728
  }
2726
2729
  _initialize() {
2727
- this._currentUniverService.currentDoc$.pipe(Se(this.dispose$)).subscribe((e) => {
2730
+ this._currentUniverService.currentDoc$.pipe(ve(this.dispose$)).subscribe((e) => {
2728
2731
  if (e == null)
2729
2732
  return;
2730
2733
  this._currentDocumentModel = e;
@@ -2745,109 +2748,109 @@ let Ue = class extends me {
2745
2748
  return;
2746
2749
  const { scene: o, engine: a } = s;
2747
2750
  o.openTransformer(), this._scene = o;
2748
- const c = new an(Je.VIEW_MAIN, o, {
2751
+ const c = new cn(Qe.VIEW_MAIN, o, {
2749
2752
  left: 0,
2750
2753
  top: 0,
2751
2754
  bottom: 0,
2752
2755
  right: 0,
2753
2756
  isWheelPreventDefaultX: !0
2754
2757
  });
2755
- o.attachControl(), o.on(cn.wheel, (p, h) => {
2756
- const u = p;
2758
+ o.attachControl(), o.on(ln.wheel, (h, g) => {
2759
+ const u = h;
2757
2760
  if (u.ctrlKey) {
2758
- const g = Math.abs(u.deltaX);
2759
- let m = g < 40 ? 0.2 : g < 80 ? 0.4 : 0.2;
2760
- m *= u.deltaY > 0 ? -1 : 1, o.scaleX < 1 && (m /= 2), o.scaleX + m > 4 ? o.scale(4, 4) : o.scaleX + m < 0.1 ? o.scale(0.1, 0.1) : u.preventDefault();
2761
+ const p = Math.abs(u.deltaX);
2762
+ let f = p < 40 ? 0.2 : p < 80 ? 0.4 : 0.2;
2763
+ f *= u.deltaY > 0 ? -1 : 1, o.scaleX < 1 && (f /= 2), o.scaleX + f > 4 ? o.scale(4, 4) : o.scaleX + f < 0.1 ? o.scale(0.1, 0.1) : u.preventDefault();
2761
2764
  } else
2762
- c.onMouseWheel(u, h);
2763
- }), this._configService.getConfig("hasScroll") !== !1 && t !== K && new ln(c), o.addLayer(
2764
- new ut(o, [], ht),
2765
- new ut(o, [], xn)
2765
+ c.onMouseWheel(u, g);
2766
+ }), this._configService.getConfig("hasScroll") !== !1 && t !== J && new dn(c), o.addLayer(
2767
+ new ht(o, [], gt),
2768
+ new ht(o, [], On)
2766
2769
  ), this._addComponent(s), this._currentDocumentModel.getShouldRenderLoopImmediately() && a.runRenderLoop(() => {
2767
2770
  o.render(), this._fps$.next(Math.round(a.getFps()).toString());
2768
2771
  }), this._renderManagerService.setCurrent(t);
2769
2772
  }
2770
2773
  _addComponent(e) {
2771
- const t = this._scene, n = this._currentDocumentModel, r = new dn(Ye.MAIN, void 0, {
2774
+ const t = this._scene, n = this._currentDocumentModel, r = new un(Ze.MAIN, void 0, {
2772
2775
  pageMarginLeft: n.documentStyle.marginLeft || 0,
2773
2776
  pageMarginTop: n.documentStyle.marginTop || 0
2774
2777
  });
2775
- r.zIndex = On, e.mainComponent = r, e.components.set(Ye.MAIN, r), t.addObjects([r], ht);
2778
+ r.zIndex = yn, e.mainComponent = r, e.components.set(Ze.MAIN, r), t.addObjects([r], gt);
2776
2779
  }
2777
2780
  };
2778
- Ue = ei([
2779
- V(F.Ready, Ue),
2780
- Me(0, H),
2781
- Me(1, bt),
2782
- Me(2, O),
2783
- Me(3, U(ie))
2784
- ], Ue);
2785
- var ti = Object.defineProperty, ni = Object.getOwnPropertyDescriptor, ri = (i, e, t, n) => {
2786
- for (var r = n > 1 ? void 0 : n ? ni(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2781
+ we = ti([
2782
+ F(j.Ready, we),
2783
+ Ce(0, G),
2784
+ Ce(1, Tt),
2785
+ Ce(2, y),
2786
+ Ce(3, w(se))
2787
+ ], we);
2788
+ var ni = Object.defineProperty, ri = Object.getOwnPropertyDescriptor, ii = (i, e, t, n) => {
2789
+ for (var r = n > 1 ? void 0 : n ? ri(e, t) : e, s = i.length - 1, o; s >= 0; s--)
2787
2790
  (o = i[s]) && (r = (n ? o(e, t, r) : o(r)) || r);
2788
- return n && r && ti(e, t, r), r;
2789
- }, Ce = (i, e) => (t, n) => e(t, n, i);
2790
- const ii = {
2791
+ return n && r && ni(e, t, r), r;
2792
+ }, Ie = (i, e) => (t, n) => e(t, n, i);
2793
+ const si = {
2791
2794
  hasScroll: !0
2792
- }, si = "docs";
2795
+ }, oi = "docs";
2793
2796
  var Ge;
2794
- let It = (Ge = class extends Yt {
2797
+ let xt = (Ge = class extends Zt {
2795
2798
  constructor(e = {}, t, n, r, s) {
2796
- super(si);
2799
+ super(oi);
2797
2800
  S(this, "_config");
2798
- this._injector = t, this._localeService = n, this._configService = r, this._currentUniverService = s, this._config = Object.assign(ii, e), this._initializeDependencies(t), this._initializeCommands();
2801
+ this._injector = t, this._localeService = n, this._configService = r, this._currentUniverService = s, this._config = Object.assign(si, e), this._initializeDependencies(t), this._initializeCommands();
2799
2802
  }
2800
2803
  initialize() {
2801
2804
  }
2802
2805
  _initializeCommands() {
2803
2806
  [
2804
- Q,
2805
2807
  ee,
2806
- Et,
2808
+ te,
2807
2809
  Ut,
2808
- ue,
2809
- Be,
2810
- je,
2811
- Ve,
2812
- J,
2813
- se,
2810
+ wt,
2814
2811
  he,
2815
- pe,
2812
+ Ve,
2816
2813
  Fe,
2817
- Nt,
2818
- Pt,
2819
- Qe,
2814
+ je,
2815
+ Q,
2816
+ oe,
2817
+ ge,
2818
+ pe,
2819
+ ke,
2820
+ $t,
2821
+ Et,
2820
2822
  et,
2821
- Tt,
2822
- Lt,
2823
2823
  tt,
2824
+ Pt,
2825
+ Lt,
2826
+ nt,
2824
2827
  _,
2825
- Wn,
2826
2828
  Hn,
2827
- Bt,
2828
- Y,
2829
+ Xn,
2830
+ Vt,
2831
+ Z,
2829
2832
  Dt,
2830
- jt,
2833
+ Ft,
2834
+ zn,
2831
2835
  kn,
2832
- Fn,
2833
- rt
2836
+ it
2834
2837
  ].forEach((e) => {
2835
- this._injector.get(x).registerCommand(e);
2838
+ this._injector.get(O).registerCommand(e);
2836
2839
  }), [
2837
- zr,
2838
2840
  Wr,
2839
- Gr,
2840
2841
  Hr,
2842
+ Gr,
2841
2843
  Xr,
2842
- qr,
2843
2844
  Yr,
2845
+ qr,
2844
2846
  Zr,
2845
2847
  Kr,
2846
- Fr,
2848
+ Jr,
2847
2849
  kr,
2848
- Vr
2850
+ zr,
2851
+ jr
2849
2852
  ].forEach((e) => {
2850
- this._injector.get(vn).registerShortcut(e);
2853
+ this._injector.get(Mn).registerShortcut(e);
2851
2854
  });
2852
2855
  }
2853
2856
  onReady() {
@@ -2860,83 +2863,83 @@ let It = (Ge = class extends Yt {
2860
2863
  // { useFactory: () => docInjector.createInstance(CanvasView, this._config.standalone ?? true) },
2861
2864
  // ], // FIXME: CanvasView shouldn't be a dependency of UniverDocs. Because it maybe created dynamically.
2862
2865
  //views
2863
- [Ue],
2866
+ [we],
2864
2867
  // services
2865
- [A],
2866
- [ie],
2867
- [nt],
2868
+ [L],
2869
+ [se],
2870
+ [rt],
2868
2871
  [
2869
- Vt,
2872
+ jt,
2870
2873
  {
2871
- useClass: Ke
2874
+ useClass: Je
2872
2875
  }
2873
2876
  ],
2874
2877
  [
2875
- _e,
2878
+ Se,
2876
2879
  {
2877
- useClass: un
2880
+ useClass: hn
2878
2881
  }
2879
2882
  ],
2880
- [P],
2883
+ [U],
2881
2884
  // controllers
2882
- [Ie],
2883
- [Te],
2885
+ [xe],
2884
2886
  [Pe],
2887
+ [Ee],
2885
2888
  [De],
2886
- [Oe],
2887
2889
  [ye],
2888
- [Re],
2889
2890
  [be],
2890
- [Ee],
2891
- [xe]
2891
+ [Re],
2892
+ [Te],
2893
+ [Ue],
2894
+ [Oe]
2892
2895
  ].forEach((t) => e.add(t));
2893
2896
  }
2894
- }, S(Ge, "type", Zt.Doc), Ge);
2895
- It = ri([
2896
- Ce(1, U(Rn)),
2897
- Ce(2, U(xt)),
2898
- Ce(3, bt),
2899
- Ce(4, O)
2900
- ], It);
2897
+ }, S(Ge, "type", Kt.Doc), Ge);
2898
+ xt = ii([
2899
+ Ie(1, w(Rn)),
2900
+ Ie(2, w(Ot)),
2901
+ Ie(3, Tt),
2902
+ Ie(4, y)
2903
+ ], xt);
2901
2904
  export {
2902
- Pt as BreakLineCommand,
2903
- Fn as BulletListCommand,
2904
- Hn as CoverContentCommand,
2905
- On as DOCS_COMPONENT_DEFAULT_Z_INDEX,
2906
- xn as DOCS_COMPONENT_HEADER_LAYER_INDEX,
2907
- ht as DOCS_COMPONENT_MAIN_LAYER_INDEX,
2908
- Ye as DOCS_VIEW_KEY,
2909
- et as DeleteCommand,
2910
- Et as DeleteLeftCommand,
2911
- Ut as DeleteRightCommand,
2912
- Ue as DocCanvasView,
2913
- ke as DocCopyCommand,
2914
- ze as DocCutCommand,
2915
- We as DocPasteCommand,
2916
- A as DocSkeletonManagerService,
2917
- ie as DocViewModelManagerService,
2905
+ Et as BreakLineCommand,
2906
+ kn as BulletListCommand,
2907
+ Xn as CoverContentCommand,
2908
+ yn as DOCS_COMPONENT_DEFAULT_Z_INDEX,
2909
+ On as DOCS_COMPONENT_HEADER_LAYER_INDEX,
2910
+ gt as DOCS_COMPONENT_MAIN_LAYER_INDEX,
2911
+ Ze as DOCS_VIEW_KEY,
2912
+ tt as DeleteCommand,
2913
+ Ut as DeleteLeftCommand,
2914
+ wt as DeleteRightCommand,
2915
+ we as DocCanvasView,
2916
+ ze as DocCopyCommand,
2917
+ We as DocCutCommand,
2918
+ He as DocPasteCommand,
2919
+ L as DocSkeletonManagerService,
2920
+ se as DocViewModelManagerService,
2918
2921
  Lt as IMEInputCommand,
2919
- Qe as InsertCommand,
2920
- Q as MoveCursorOperation,
2921
- ee as MoveSelectionOperation,
2922
- hi as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
2923
- kn as OrderListCommand,
2924
- Wn as ReplaceContentCommand,
2922
+ et as InsertCommand,
2923
+ ee as MoveCursorOperation,
2924
+ te as MoveSelectionOperation,
2925
+ gi as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
2926
+ zn as OrderListCommand,
2927
+ Hn as ReplaceContentCommand,
2925
2928
  _ as RichTextEditingMutation,
2926
- ue as SetInlineFormatBoldCommand,
2927
- Nt as SetInlineFormatCommand,
2929
+ he as SetInlineFormatBoldCommand,
2930
+ $t as SetInlineFormatCommand,
2928
2931
  pe as SetInlineFormatFontFamilyCommand,
2929
- he as SetInlineFormatFontSizeCommand,
2930
- Be as SetInlineFormatItalicCommand,
2931
- Ve as SetInlineFormatStrikethroughCommand,
2932
- J as SetInlineFormatSubscriptCommand,
2933
- se as SetInlineFormatSuperscriptCommand,
2934
- Fe as SetInlineFormatTextColorCommand,
2935
- je as SetInlineFormatUnderlineCommand,
2932
+ ge as SetInlineFormatFontSizeCommand,
2933
+ Ve as SetInlineFormatItalicCommand,
2934
+ je as SetInlineFormatStrikethroughCommand,
2935
+ Q as SetInlineFormatSubscriptCommand,
2936
+ oe as SetInlineFormatSuperscriptCommand,
2937
+ ke as SetInlineFormatTextColorCommand,
2938
+ Fe as SetInlineFormatUnderlineCommand,
2936
2939
  Dt as SetTextSelectionsOperation,
2937
- P as TextSelectionManagerService,
2938
- It as UniverDocsPlugin,
2939
- Tt as UpdateCommand,
2940
- Je as VIEWPORT_KEY,
2941
- Ne as getDocObject
2940
+ U as TextSelectionManagerService,
2941
+ xt as UniverDocsPlugin,
2942
+ Pt as UpdateCommand,
2943
+ Qe as VIEWPORT_KEY,
2944
+ $e as getDocObject
2942
2945
  };