@univerjs/docs 0.1.0-beta.4 → 0.1.0-beta.5

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