@univerjs/docs 0.1.0-beta.5 → 0.1.1

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