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

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