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

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