@univerjs/docs-ui 0.1.16 → 0.1.17

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,16 +1,16 @@
1
- var jt = Object.defineProperty;
2
- var Wt = (i, e, t) => e in i ? jt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var g = (i, e, t) => Wt(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { FOCUSING_DOC as xe, FOCUSING_UNIVER_EDITOR as Ze, FOCUSING_COMMON_DRAWINGS as bt, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE as zt, Direction as w, EDITOR_ACTIVATED as Mt, LocaleService as qe, RxDisposable as de, ICommandService as v, BooleanNumber as C, UniverInstanceType as f, BaselineOffset as K, ThemeService as yt, HorizontalAlign as De, IUniverInstanceService as P, Disposable as k, OnLifecycle as U, LifecycleStages as A, Tools as Je, LRUMap as kt, ColorKit as st, toDisposable as B, ILogService as Et, CommandType as Qe, IContextService as Ht, checkForSubstrings as Yt, IConfigService as Gt, PositionedObjectLayoutType as Xt, DEFAULT_DOCUMENT_SUB_COMPONENT_ID as Kt, DisposableCollection as Zt, Plugin as qt, ObjectRelativeFromH as Jt, ObjectRelativeFromV as Qt } from "@univerjs/core";
5
- import { Inject as O, Injector as Pe, Optional as en, createIdentifier as tn } from "@wendellhu/redi";
6
- import { KeyCode as E, MetaKeys as ue, ILayoutService as xt, MenuGroup as I, MenuItemType as T, MenuPosition as b, getMenuHiddenObservable as M, FONT_FAMILY_LIST as at, FONT_SIZE_LIST as nn, FontFamily as rn, FontFamilyItem as on, FontSize as sn, BuiltInUIPart as an, ComponentManager as cn, IEditorService as L, IMenuService as ln, IUIPartsService as dn, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as un, HTML_CLIPBOARD_MIME_TYPE as hn, IClipboardInterfaceService as et, CopyCommand as pn, CutCommand as _n, PasteCommand as gn, SetEditorResizeOperation as fn, ICanvasPopupService as mn, IShortcutService as Sn } from "@univerjs/ui";
7
- import { MoveCursorOperation as Ne, MoveSelectionOperation as Ue, SelectAllOperation as vn, SetInlineFormatBoldCommand as Cn, SetTextSelectionsOperation as x, SetInlineFormatCommand as q, SetInlineFormatItalicCommand as On, SetInlineFormatUnderlineCommand as Rn, SetInlineFormatStrikethroughCommand as Tn, SetInlineFormatSubscriptCommand as In, SetInlineFormatSuperscriptCommand as bn, SetInlineFormatFontFamilyCommand as ct, SetInlineFormatFontSizeCommand as lt, SetInlineFormatTextColorCommand as dt, AlignLeftCommand as Mn, AlignOperationCommand as Ae, AlignCenterCommand as yn, AlignRightCommand as En, AlignJustifyCommand as xn, OrderListCommand as Dn, BulletListCommand as Pn, ResetInlineFormatTextBackgroundColorCommand as Nn, SetInlineFormatTextBackgroundColorCommand as He, TextSelectionManagerService as J, BreakLineCommand as Un, DeleteLeftCommand as An, DeleteRightCommand as Ln, CutContentCommand as Dt, InnerPasteCommand as Pt, VIEWPORT_KEY as Q, CoverContentCommand as $n, RichTextEditingMutation as tt, DocSkeletonManagerService as ee, DOCS_VIEW_KEY as X, DOCS_COMPONENT_MAIN_LAYER_INDEX as We, DOCS_COMPONENT_HEADER_LAYER_INDEX as Bn, DOCS_COMPONENT_DEFAULT_Z_INDEX as ut, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX as wn, SetDocZoomRatioOperation as Le, SetDocZoomRatioCommand as Fn, getDocObject as Nt, getDocObjectById as Vn } from "@univerjs/docs";
8
- import { connectInjector as jn } from "@wendellhu/redi/react-bindings";
9
- import { ITextSelectionRenderManager as he, pixelToPt as Wn, ptToPixel as ht, ScrollBar as Ye, IRenderManagerService as F, PageLayoutType as pt, Viewport as zn, EVENT_TYPE as kn, Layer as _t, Documents as Hn, DocBackground as Yn, Liquid as Gn, CURSOR_TYPE as gt, NodePositionConvertToCursor as Xn, getAnchorBounding as Kn } from "@univerjs/engine-render";
10
- import Zn from "react";
11
- import { Observable as y, takeUntil as le, fromEvent as ft, BehaviorSubject as Ut } from "rxjs";
12
- import { ColorPicker as qn } from "@univerjs/design";
13
- const Jn = {
1
+ var Bt = Object.defineProperty;
2
+ var Ft = (t, e, n) => e in t ? Bt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var v = (t, e, n) => Ft(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { FOCUSING_DOC as Se, FOCUSING_UNIVER_EDITOR as Xe, FOCUSING_COMMON_DRAWINGS as Tt, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE as Vt, Direction as U, EDITOR_ACTIVATED as It, LocaleService as bt, RxDisposable as re, ICommandService as S, BooleanNumber as C, UniverInstanceType as g, BaselineOffset as k, ThemeService as Et, HorizontalAlign as ve, IUniverInstanceService as P, Disposable as F, OnLifecycle as Ce, LifecycleStages as Oe, Tools as Ke, LRUMap as jt, ColorKit as it, skipParseTagNames as Wt, toDisposable as zt, ILogService as yt, CommandType as Ze, IContextService as Ht, checkForSubstrings as kt, IConfigService as Yt, PositionedObjectLayoutType as Gt, DEFAULT_DOCUMENT_SUB_COMPONENT_ID as Xt, DisposableCollection as Kt, Plugin as Zt, ObjectRelativeFromH as qt, ObjectRelativeFromV as Jt } from "@univerjs/core";
5
+ import { Inject as O, Injector as Re, Optional as Qt, createIdentifier as en } from "@wendellhu/redi";
6
+ import { KeyCode as y, MetaKeys as oe, ILayoutService as Mt, MenuGroup as T, MenuItemType as R, MenuPosition as I, getMenuHiddenObservable as b, FONT_FAMILY_LIST as rt, FONT_SIZE_LIST as tn, FontFamily as nn, FontFamilyItem as rn, FontSize as on, BuiltInUIPart as sn, ComponentManager as an, IEditorService as A, IMenuService as cn, IUIPartsService as ln, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as dn, HTML_CLIPBOARD_MIME_TYPE as un, IClipboardInterfaceService as qe, CopyCommand as hn, CutCommand as pn, PasteCommand as _n, SetEditorResizeOperation as gn, ICanvasPopupService as fn, IShortcutService as mn } from "@univerjs/ui";
7
+ import { ITextSelectionRenderManager as se, pixelToPt as Sn, ptToPixel as ot, ScrollBar as Be, IRenderManagerService as Te, Viewport as vn, Layer as st, Documents as Cn, DocBackground as On, PageLayoutType as at, Liquid as Rn, CURSOR_TYPE as ct, NodePositionConvertToCursor as Tn, getAnchorBounding as In } from "@univerjs/engine-render";
8
+ import { MoveCursorOperation as Ie, MoveSelectionOperation as be, SelectAllOperation as bn, SetInlineFormatBoldCommand as En, SetTextSelectionsOperation as M, SetInlineFormatCommand as G, SetInlineFormatItalicCommand as yn, SetInlineFormatUnderlineCommand as Mn, SetInlineFormatStrikethroughCommand as xn, SetInlineFormatSubscriptCommand as Pn, SetInlineFormatSuperscriptCommand as Dn, SetInlineFormatFontFamilyCommand as lt, SetInlineFormatFontSizeCommand as dt, SetInlineFormatTextColorCommand as ut, AlignLeftCommand as Nn, AlignOperationCommand as Ee, AlignCenterCommand as Un, AlignRightCommand as An, AlignJustifyCommand as Ln, OrderListCommand as $n, BulletListCommand as wn, ResetInlineFormatTextBackgroundColorCommand as Bn, SetInlineFormatTextBackgroundColorCommand as Fe, TextSelectionManagerService as X, BreakLineCommand as Fn, DeleteLeftCommand as Vn, DeleteRightCommand as jn, CutContentCommand as xt, InnerPasteCommand as Pt, DocSkeletonManagerService as V, VIEWPORT_KEY as K, CoverContentCommand as Wn, RichTextEditingMutation as Je, DOCS_COMPONENT_MAIN_LAYER_INDEX as Ue, DOCS_COMPONENT_HEADER_LAYER_INDEX as zn, DOCS_VIEW_KEY as W, DOCS_COMPONENT_DEFAULT_Z_INDEX as ht, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX as Hn, SetDocZoomRatioOperation as ye, SetDocZoomRatioCommand as kn, neoGetDocObject as fe } from "@univerjs/docs";
9
+ import { connectInjector as Yn } from "@wendellhu/redi/react-bindings";
10
+ import Gn from "react";
11
+ import { Observable as E, takeUntil as H, fromEvent as pt, BehaviorSubject as Xn } from "rxjs";
12
+ import { ColorPicker as Kn } from "@univerjs/design";
13
+ const Zn = {
14
14
  undo: !0,
15
15
  redo: !0,
16
16
  // Undo redo
@@ -38,7 +38,7 @@ const Jn = {
38
38
  // 'Wrap mode'
39
39
  textRotateMode: !0
40
40
  // 'Text Rotation Mode'
41
- }, Qn = {
41
+ }, qn = {
42
42
  outerLeft: !1,
43
43
  outerRight: !1,
44
44
  header: !0,
@@ -51,90 +51,90 @@ const Jn = {
51
51
  frozenContent: !1,
52
52
  infoBar: !0,
53
53
  toolbar: !0
54
- }, ei = {
54
+ }, Jn = {
55
55
  layout: {
56
- docContainerConfig: Qn,
57
- toolbarConfig: Jn
56
+ docContainerConfig: qn,
57
+ toolbarConfig: Zn
58
58
  }
59
- }, ti = "DocUI";
60
- function N(i) {
61
- return i.getContextValue(xe) && i.getContextValue(Ze) && !i.getContextValue(bt);
59
+ }, Qn = "DocUI";
60
+ function D(t) {
61
+ return t.getContextValue(Se) && t.getContextValue(Xe) && !t.getContextValue(Tt);
62
62
  }
63
- function ni(i) {
64
- return i.getContextValue(xe) && i.getContextValue(Ze) && !i.getContextValue(zt) && !i.getContextValue(bt);
63
+ function ei(t) {
64
+ return t.getContextValue(Se) && t.getContextValue(Xe) && !t.getContextValue(Vt) && !t.getContextValue(Tt);
65
65
  }
66
- const ii = {
67
- id: Ne.id,
68
- binding: E.ARROW_UP,
69
- preconditions: N,
66
+ const ti = {
67
+ id: Ie.id,
68
+ binding: y.ARROW_UP,
69
+ preconditions: D,
70
70
  staticParameters: {
71
- direction: w.UP
71
+ direction: U.UP
72
+ }
73
+ }, ni = {
74
+ id: Ie.id,
75
+ binding: y.ARROW_DOWN,
76
+ preconditions: D,
77
+ staticParameters: {
78
+ direction: U.DOWN
79
+ }
80
+ }, ii = {
81
+ id: Ie.id,
82
+ binding: y.ARROW_LEFT,
83
+ preconditions: D,
84
+ staticParameters: {
85
+ direction: U.LEFT
72
86
  }
73
87
  }, ri = {
74
- id: Ne.id,
75
- binding: E.ARROW_DOWN,
76
- preconditions: N,
88
+ id: Ie.id,
89
+ binding: y.ARROW_RIGHT,
90
+ preconditions: D,
77
91
  staticParameters: {
78
- direction: w.DOWN
92
+ direction: U.RIGHT
79
93
  }
80
94
  }, oi = {
81
- id: Ne.id,
82
- binding: E.ARROW_LEFT,
83
- preconditions: N,
95
+ id: be.id,
96
+ binding: y.ARROW_UP | oe.SHIFT,
97
+ preconditions: D,
84
98
  staticParameters: {
85
- direction: w.LEFT
99
+ direction: U.UP
86
100
  }
87
101
  }, si = {
88
- id: Ne.id,
89
- binding: E.ARROW_RIGHT,
90
- preconditions: N,
102
+ id: be.id,
103
+ binding: y.ARROW_DOWN | oe.SHIFT,
104
+ preconditions: D,
91
105
  staticParameters: {
92
- direction: w.RIGHT
106
+ direction: U.DOWN
93
107
  }
94
108
  }, ai = {
95
- id: Ue.id,
96
- binding: E.ARROW_UP | ue.SHIFT,
97
- preconditions: N,
109
+ id: be.id,
110
+ binding: y.ARROW_LEFT | oe.SHIFT,
111
+ preconditions: D,
98
112
  staticParameters: {
99
- direction: w.UP
113
+ direction: U.LEFT
100
114
  }
101
115
  }, ci = {
102
- id: Ue.id,
103
- binding: E.ARROW_DOWN | ue.SHIFT,
104
- preconditions: N,
116
+ id: be.id,
117
+ binding: y.ARROW_RIGHT | oe.SHIFT,
118
+ preconditions: D,
105
119
  staticParameters: {
106
- direction: w.DOWN
120
+ direction: U.RIGHT
107
121
  }
108
122
  }, li = {
109
- id: Ue.id,
110
- binding: E.ARROW_LEFT | ue.SHIFT,
111
- preconditions: N,
112
- staticParameters: {
113
- direction: w.LEFT
114
- }
115
- }, di = {
116
- id: Ue.id,
117
- binding: E.ARROW_RIGHT | ue.SHIFT,
118
- preconditions: N,
119
- staticParameters: {
120
- direction: w.RIGHT
121
- }
122
- }, ui = {
123
- id: vn.id,
124
- binding: E.A | ue.CTRL_COMMAND,
125
- preconditions: (i) => i.getContextValue(Ze) && (i.getContextValue(xe) || i.getContextValue(Mt))
123
+ id: bn.id,
124
+ binding: y.A | oe.CTRL_COMMAND,
125
+ preconditions: (t) => t.getContextValue(Xe) && (t.getContextValue(Se) || t.getContextValue(It))
126
126
  };
127
- var hi = Object.defineProperty, pi = Object.getOwnPropertyDescriptor, _i = (i, e, t, n) => {
128
- for (var r = n > 1 ? void 0 : n ? pi(e, t) : e, o = i.length - 1, s; o >= 0; o--)
129
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
130
- return n && r && hi(e, t, r), r;
131
- }, mt = (i, e) => (t, n) => e(t, n, i);
132
- let Ge = class {
133
- constructor(i, e, t) {
134
- g(this, "_docContainer");
127
+ var di = Object.defineProperty, ui = Object.getOwnPropertyDescriptor, hi = (t, e, n, i) => {
128
+ for (var r = i > 1 ? void 0 : i ? ui(e, n) : e, o = t.length - 1, s; o >= 0; o--)
129
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
130
+ return i && r && di(e, n, r), r;
131
+ }, _t = (t, e) => (n, i) => e(n, i, t);
132
+ let Ve = class {
133
+ constructor(t, e, n) {
134
+ v(this, "_docContainer");
135
135
  // 获取SheetContainer组件
136
- g(this, "getComponent", (i) => {
137
- if (this._docContainer = i, !i.getContentRef().current)
136
+ v(this, "getComponent", (t) => {
137
+ if (this._docContainer = t, !t.getContentRef().current)
138
138
  throw new Error("container is not ready");
139
139
  });
140
140
  /**
@@ -144,10 +144,10 @@ let Ge = class {
144
144
  * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
145
145
  *
146
146
  */
147
- g(this, "changeLocale", (i) => {
148
- this._localeService.setLocale(i);
147
+ v(this, "changeLocale", (t) => {
148
+ this._localeService.setLocale(t);
149
149
  });
150
- this._config = i, this._localeService = e, this._injector = t;
150
+ this._config = t, this._localeService = e, this._injector = n;
151
151
  }
152
152
  getUIConfig() {
153
153
  return {
@@ -160,27 +160,27 @@ let Ge = class {
160
160
  getContentRef() {
161
161
  return this._docContainer.getContentRef();
162
162
  }
163
- UIDidMount(i) {
163
+ UIDidMount(t) {
164
164
  if (this._docContainer)
165
- return i(this._docContainer);
165
+ return t(this._docContainer);
166
166
  }
167
167
  getDocContainer() {
168
168
  return this._docContainer;
169
169
  }
170
170
  };
171
- Ge = _i([
172
- mt(1, O(qe)),
173
- mt(2, O(Pe))
174
- ], Ge);
175
- var gi = Object.defineProperty, fi = Object.getOwnPropertyDescriptor, mi = (i, e, t, n) => {
176
- for (var r = n > 1 ? void 0 : n ? fi(e, t) : e, o = i.length - 1, s; o >= 0; o--)
177
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
178
- return n && r && gi(e, t, r), r;
179
- }, _e = (i, e) => (t, n) => e(t, n, i);
180
- let ae = class extends de {
181
- constructor(e, t, n, r, o) {
171
+ Ve = hi([
172
+ _t(1, O(bt)),
173
+ _t(2, O(Re))
174
+ ], Ve);
175
+ var pi = Object.defineProperty, _i = Object.getOwnPropertyDescriptor, gi = (t, e, n, i) => {
176
+ for (var r = i > 1 ? void 0 : i ? _i(e, n) : e, o = t.length - 1, s; o >= 0; o--)
177
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
178
+ return i && r && pi(e, n, r), r;
179
+ }, le = (t, e) => (n, i) => e(n, i, t);
180
+ let ne = class extends re {
181
+ constructor(e, n, i, r, o) {
182
182
  super();
183
- g(this, "_docContainerController");
183
+ v(this, "_docContainerController");
184
184
  /**
185
185
  * Change language
186
186
  * @param {string} locale new language
@@ -188,10 +188,10 @@ let ae = class extends de {
188
188
  * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
189
189
  *
190
190
  */
191
- g(this, "changeLocale", (e) => {
191
+ v(this, "changeLocale", (e) => {
192
192
  this._localeService.setLocale(e);
193
193
  });
194
- this._localeService = t, this._injector = n, this._textSelectionRenderManager = r, this._layoutService = o, this._docContainerController = this._injector.createInstance(Ge, e), this._registerContainer();
194
+ this._localeService = n, this._injector = i, this._textSelectionRenderManager = r, this._layoutService = o, this._docContainerController = this._injector.createInstance(Ve, e), this._registerContainer();
195
195
  }
196
196
  _registerContainer() {
197
197
  this._layoutService && this.disposeWithMe(
@@ -203,14 +203,14 @@ let ae = class extends de {
203
203
  return this._docContainerController;
204
204
  }
205
205
  };
206
- ae = mi([
207
- _e(1, O(qe)),
208
- _e(2, O(Pe)),
209
- _e(3, he),
210
- _e(4, en(xt))
211
- ], ae);
212
- const $e = "UI_PLUGIN_DOCS", nt = `${$e}_COLOR_PICKER_COMPONENT`, At = `${$e}_FONT_FAMILY_COMPONENT`, Lt = `${$e}_FONT_FAMILY_ITEM_COMPONENT`, $t = `${$e}_FONT_SIZE_COMPONENT`;
213
- var Bt = { exports: {} }, Be = {};
206
+ ne = gi([
207
+ le(1, O(bt)),
208
+ le(2, O(Re)),
209
+ le(3, se),
210
+ le(4, Qt(Mt))
211
+ ], ne);
212
+ const Me = "UI_PLUGIN_DOCS", Qe = `${Me}_COLOR_PICKER_COMPONENT`, Dt = `${Me}_FONT_FAMILY_COMPONENT`, Nt = `${Me}_FONT_FAMILY_ITEM_COMPONENT`, Ut = `${Me}_FONT_SIZE_COMPONENT`;
213
+ var At = { exports: {} }, xe = {};
214
214
  /**
215
215
  * @license React
216
216
  * react-jsx-runtime.production.min.js
@@ -220,451 +220,451 @@ var Bt = { exports: {} }, Be = {};
220
220
  * This source code is licensed under the MIT license found in the
221
221
  * LICENSE file in the root directory of this source tree.
222
222
  */
223
- var Si = Zn, vi = Symbol.for("react.element"), Ci = Symbol.for("react.fragment"), Oi = Object.prototype.hasOwnProperty, Ri = Si.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Ti = { key: !0, ref: !0, __self: !0, __source: !0 };
224
- function wt(i, e, t) {
225
- var n, r = {}, o = null, s = null;
226
- t !== void 0 && (o = "" + t), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
227
- for (n in e) Oi.call(e, n) && !Ti.hasOwnProperty(n) && (r[n] = e[n]);
228
- if (i && i.defaultProps) for (n in e = i.defaultProps, e) r[n] === void 0 && (r[n] = e[n]);
229
- return { $$typeof: vi, type: i, key: o, ref: s, props: r, _owner: Ri.current };
223
+ var fi = Gn, mi = Symbol.for("react.element"), Si = Symbol.for("react.fragment"), vi = Object.prototype.hasOwnProperty, Ci = fi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Oi = { key: !0, ref: !0, __self: !0, __source: !0 };
224
+ function Lt(t, e, n) {
225
+ var i, r = {}, o = null, s = null;
226
+ n !== void 0 && (o = "" + n), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
227
+ for (i in e) vi.call(e, i) && !Oi.hasOwnProperty(i) && (r[i] = e[i]);
228
+ if (t && t.defaultProps) for (i in e = t.defaultProps, e) r[i] === void 0 && (r[i] = e[i]);
229
+ return { $$typeof: mi, type: t, key: o, ref: s, props: r, _owner: Ci.current };
230
230
  }
231
- Be.Fragment = Ci;
232
- Be.jsx = wt;
233
- Be.jsxs = wt;
234
- Bt.exports = Be;
235
- var Ii = Bt.exports;
236
- const bi = "univer-docs-ui-canvas-background", Mi = {
237
- docsUiCanvasBackground: bi
238
- }, yi = () => /* @__PURE__ */ Ii.jsx("div", { className: Mi.docsUiCanvasBackground });
239
- function Ei(i) {
240
- const e = i.get(v);
231
+ xe.Fragment = Si;
232
+ xe.jsx = Lt;
233
+ xe.jsxs = Lt;
234
+ At.exports = xe;
235
+ var Ri = At.exports;
236
+ const Ti = "univer-docs-ui-canvas-background", Ii = {
237
+ docsUiCanvasBackground: Ti
238
+ }, bi = () => /* @__PURE__ */ Ri.jsx("div", { className: Ii.docsUiCanvasBackground });
239
+ function Ei(t) {
240
+ const e = t.get(S);
241
241
  return {
242
- id: Cn.id,
243
- group: I.TOOLBAR_FORMAT,
244
- type: T.BUTTON,
242
+ id: En.id,
243
+ group: T.TOOLBAR_FORMAT,
244
+ type: R.BUTTON,
245
245
  icon: "BoldSingle",
246
246
  title: "Set bold",
247
247
  tooltip: "toolbar.bold",
248
- positions: [b.TOOLBAR_START],
249
- activated$: new y((t) => {
250
- const n = e.onCommandExecuted((r) => {
248
+ positions: [I.TOOLBAR_START],
249
+ activated$: new E((n) => {
250
+ const i = e.onCommandExecuted((r) => {
251
251
  var s;
252
252
  const o = r.id;
253
- if (o === x.id || o === q.id) {
254
- const a = V(i);
253
+ if (o === M.id || o === G.id) {
254
+ const a = L(t);
255
255
  if (a == null)
256
256
  return;
257
257
  const c = (s = a.ts) == null ? void 0 : s.bl;
258
- t.next(c === C.TRUE);
258
+ n.next(c === C.TRUE);
259
259
  }
260
260
  });
261
- return t.next(!1), n.dispose;
261
+ return n.next(!1), i.dispose;
262
262
  }),
263
- hidden$: M(i, f.UNIVER_DOC)
263
+ hidden$: b(t, g.UNIVER_DOC)
264
264
  };
265
265
  }
266
- function xi(i) {
267
- const e = i.get(v);
266
+ function yi(t) {
267
+ const e = t.get(S);
268
268
  return {
269
- id: On.id,
270
- group: I.TOOLBAR_FORMAT,
271
- type: T.BUTTON,
269
+ id: yn.id,
270
+ group: T.TOOLBAR_FORMAT,
271
+ type: R.BUTTON,
272
272
  icon: "ItalicSingle",
273
273
  title: "Set italic",
274
274
  tooltip: "toolbar.italic",
275
- positions: [b.TOOLBAR_START],
276
- activated$: new y((t) => {
277
- const n = e.onCommandExecuted((r) => {
275
+ positions: [I.TOOLBAR_START],
276
+ activated$: new E((n) => {
277
+ const i = e.onCommandExecuted((r) => {
278
278
  var s;
279
279
  const o = r.id;
280
- if (o === x.id || o === q.id) {
281
- const a = V(i);
280
+ if (o === M.id || o === G.id) {
281
+ const a = L(t);
282
282
  if (a == null)
283
283
  return;
284
284
  const c = (s = a.ts) == null ? void 0 : s.it;
285
- t.next(c === C.TRUE);
285
+ n.next(c === C.TRUE);
286
286
  }
287
287
  });
288
- return t.next(!1), n.dispose;
288
+ return n.next(!1), i.dispose;
289
289
  }),
290
- hidden$: M(i, f.UNIVER_DOC)
290
+ hidden$: b(t, g.UNIVER_DOC)
291
291
  };
292
292
  }
293
- function Di(i) {
294
- const e = i.get(v);
293
+ function Mi(t) {
294
+ const e = t.get(S);
295
295
  return {
296
- id: Rn.id,
297
- group: I.TOOLBAR_FORMAT,
298
- type: T.BUTTON,
296
+ id: Mn.id,
297
+ group: T.TOOLBAR_FORMAT,
298
+ type: R.BUTTON,
299
299
  icon: "UnderlineSingle",
300
300
  title: "Set underline",
301
301
  tooltip: "toolbar.underline",
302
- positions: [b.TOOLBAR_START],
303
- activated$: new y((t) => {
304
- const n = e.onCommandExecuted((r) => {
302
+ positions: [I.TOOLBAR_START],
303
+ activated$: new E((n) => {
304
+ const i = e.onCommandExecuted((r) => {
305
305
  var s;
306
306
  const o = r.id;
307
- if (o === x.id || o === q.id) {
308
- const a = V(i);
307
+ if (o === M.id || o === G.id) {
308
+ const a = L(t);
309
309
  if (a == null)
310
310
  return;
311
311
  const c = (s = a.ts) == null ? void 0 : s.ul;
312
- t.next((c == null ? void 0 : c.s) === C.TRUE);
312
+ n.next((c == null ? void 0 : c.s) === C.TRUE);
313
313
  }
314
314
  });
315
- return t.next(!1), n.dispose;
315
+ return n.next(!1), i.dispose;
316
316
  }),
317
- hidden$: M(i, f.UNIVER_DOC)
317
+ hidden$: b(t, g.UNIVER_DOC)
318
318
  };
319
319
  }
320
- function Pi(i) {
321
- const e = i.get(v);
320
+ function xi(t) {
321
+ const e = t.get(S);
322
322
  return {
323
- id: Tn.id,
324
- group: I.TOOLBAR_FORMAT,
325
- type: T.BUTTON,
323
+ id: xn.id,
324
+ group: T.TOOLBAR_FORMAT,
325
+ type: R.BUTTON,
326
326
  icon: "StrikethroughSingle",
327
327
  title: "Set strike through",
328
328
  tooltip: "toolbar.strikethrough",
329
- positions: [b.TOOLBAR_START],
330
- activated$: new y((t) => {
331
- const n = e.onCommandExecuted((r) => {
329
+ positions: [I.TOOLBAR_START],
330
+ activated$: new E((n) => {
331
+ const i = e.onCommandExecuted((r) => {
332
332
  var s;
333
333
  const o = r.id;
334
- if (o === x.id || o === q.id) {
335
- const a = V(i);
334
+ if (o === M.id || o === G.id) {
335
+ const a = L(t);
336
336
  if (a == null)
337
337
  return;
338
338
  const c = (s = a.ts) == null ? void 0 : s.st;
339
- t.next((c == null ? void 0 : c.s) === C.TRUE);
339
+ n.next((c == null ? void 0 : c.s) === C.TRUE);
340
340
  }
341
341
  });
342
- return t.next(!1), n.dispose;
342
+ return n.next(!1), i.dispose;
343
343
  }),
344
- hidden$: M(i, f.UNIVER_DOC)
344
+ hidden$: b(t, g.UNIVER_DOC)
345
345
  };
346
346
  }
347
- function Ni(i) {
348
- const e = i.get(v);
347
+ function Pi(t) {
348
+ const e = t.get(S);
349
349
  return {
350
- id: In.id,
351
- group: I.TOOLBAR_FORMAT,
352
- type: T.BUTTON,
350
+ id: Pn.id,
351
+ group: T.TOOLBAR_FORMAT,
352
+ type: R.BUTTON,
353
353
  icon: "SubscriptSingle",
354
354
  tooltip: "toolbar.subscript",
355
- positions: [b.TOOLBAR_START],
356
- activated$: new y((t) => {
357
- const n = e.onCommandExecuted((r) => {
355
+ positions: [I.TOOLBAR_START],
356
+ activated$: new E((n) => {
357
+ const i = e.onCommandExecuted((r) => {
358
358
  var s;
359
359
  const o = r.id;
360
- if (o === x.id || o === q.id) {
361
- const a = V(i);
360
+ if (o === M.id || o === G.id) {
361
+ const a = L(t);
362
362
  if (a == null)
363
363
  return;
364
364
  const c = (s = a.ts) == null ? void 0 : s.va;
365
- t.next(c === K.SUBSCRIPT);
365
+ n.next(c === k.SUBSCRIPT);
366
366
  }
367
367
  });
368
- return t.next(!1), n.dispose;
368
+ return n.next(!1), i.dispose;
369
369
  }),
370
- hidden$: M(i, f.UNIVER_DOC)
370
+ hidden$: b(t, g.UNIVER_DOC)
371
371
  };
372
372
  }
373
- function Ui(i) {
374
- const e = i.get(v);
373
+ function Di(t) {
374
+ const e = t.get(S);
375
375
  return {
376
- id: bn.id,
377
- group: I.TOOLBAR_FORMAT,
378
- type: T.BUTTON,
376
+ id: Dn.id,
377
+ group: T.TOOLBAR_FORMAT,
378
+ type: R.BUTTON,
379
379
  icon: "SuperscriptSingle",
380
380
  tooltip: "toolbar.superscript",
381
- positions: [b.TOOLBAR_START],
382
- activated$: new y((t) => {
383
- const n = e.onCommandExecuted((r) => {
381
+ positions: [I.TOOLBAR_START],
382
+ activated$: new E((n) => {
383
+ const i = e.onCommandExecuted((r) => {
384
384
  var s;
385
385
  const o = r.id;
386
- if (o === x.id || o === q.id) {
387
- const a = V(i);
386
+ if (o === M.id || o === G.id) {
387
+ const a = L(t);
388
388
  if (a == null)
389
389
  return;
390
390
  const c = (s = a.ts) == null ? void 0 : s.va;
391
- t.next(c === K.SUPERSCRIPT);
391
+ n.next(c === k.SUPERSCRIPT);
392
392
  }
393
393
  });
394
- return t.next(!1), n.dispose;
394
+ return n.next(!1), i.dispose;
395
395
  }),
396
- hidden$: M(i, f.UNIVER_DOC)
396
+ hidden$: b(t, g.UNIVER_DOC)
397
397
  };
398
398
  }
399
- function Ai(i) {
400
- const e = i.get(v);
399
+ function Ni(t) {
400
+ const e = t.get(S);
401
401
  return {
402
- id: ct.id,
402
+ id: lt.id,
403
403
  tooltip: "toolbar.font",
404
- group: I.TOOLBAR_FORMAT,
405
- type: T.SELECTOR,
406
- label: At,
407
- positions: [b.TOOLBAR_START],
408
- selections: at.map((t) => ({
404
+ group: T.TOOLBAR_FORMAT,
405
+ type: R.SELECTOR,
406
+ label: Dt,
407
+ positions: [I.TOOLBAR_START],
408
+ selections: rt.map((n) => ({
409
409
  label: {
410
- name: Lt,
410
+ name: Nt,
411
411
  hoverable: !0
412
412
  },
413
- value: t.value
413
+ value: n.value
414
414
  })),
415
415
  // disabled$: getCurrentSheetDisabled$(accessor),
416
- value$: new y((t) => {
417
- const n = at[0].value, r = e.onCommandExecuted((o) => {
416
+ value$: new E((n) => {
417
+ const i = rt[0].value, r = e.onCommandExecuted((o) => {
418
418
  var a;
419
419
  const s = o.id;
420
- if (s === x.id || s === ct.id) {
421
- const c = V(i);
420
+ if (s === M.id || s === lt.id) {
421
+ const c = L(t);
422
422
  if (c == null)
423
423
  return;
424
424
  const l = (a = c.ts) == null ? void 0 : a.ff;
425
- t.next(l != null ? l : n);
425
+ n.next(l != null ? l : i);
426
426
  }
427
427
  });
428
- return t.next(n), r.dispose;
428
+ return n.next(i), r.dispose;
429
429
  }),
430
- hidden$: M(i, f.UNIVER_DOC)
430
+ hidden$: b(t, g.UNIVER_DOC)
431
431
  };
432
432
  }
433
- function Li(i) {
434
- const e = i.get(v);
433
+ function Ui(t) {
434
+ const e = t.get(S);
435
435
  return {
436
- id: lt.id,
437
- group: I.TOOLBAR_FORMAT,
438
- type: T.SELECTOR,
436
+ id: dt.id,
437
+ group: T.TOOLBAR_FORMAT,
438
+ type: R.SELECTOR,
439
439
  tooltip: "toolbar.fontSize",
440
440
  label: {
441
- name: $t,
441
+ name: Ut,
442
442
  props: {
443
443
  min: 1,
444
444
  max: 400
445
445
  // disabled$,
446
446
  }
447
447
  },
448
- positions: [b.TOOLBAR_START],
449
- selections: nn,
448
+ positions: [I.TOOLBAR_START],
449
+ selections: tn,
450
450
  // disabled$,
451
- value$: new y((t) => {
451
+ value$: new E((n) => {
452
452
  const r = e.onCommandExecuted((o) => {
453
453
  var a;
454
454
  const s = o.id;
455
- if (s === x.id || s === lt.id) {
456
- const c = V(i);
455
+ if (s === M.id || s === dt.id) {
456
+ const c = L(t);
457
457
  if (c == null)
458
458
  return;
459
459
  const l = (a = c.ts) == null ? void 0 : a.fs;
460
- t.next(l != null ? l : 14);
460
+ n.next(l != null ? l : 14);
461
461
  }
462
462
  });
463
- return t.next(14), r.dispose;
463
+ return n.next(14), r.dispose;
464
464
  }),
465
- hidden$: M(i, f.UNIVER_DOC)
465
+ hidden$: b(t, g.UNIVER_DOC)
466
466
  };
467
467
  }
468
- function $i(i) {
469
- const e = i.get(v), t = i.get(yt);
468
+ function Ai(t) {
469
+ const e = t.get(S), n = t.get(Et);
470
470
  return {
471
- id: dt.id,
471
+ id: ut.id,
472
472
  icon: "FontColor",
473
473
  tooltip: "toolbar.textColor.main",
474
- group: I.TOOLBAR_FORMAT,
475
- type: T.BUTTON_SELECTOR,
476
- positions: [b.TOOLBAR_START],
474
+ group: T.TOOLBAR_FORMAT,
475
+ type: R.BUTTON_SELECTOR,
476
+ positions: [I.TOOLBAR_START],
477
477
  selections: [
478
478
  {
479
479
  label: {
480
- name: nt,
480
+ name: Qe,
481
481
  hoverable: !1
482
482
  }
483
483
  }
484
484
  ],
485
- value$: new y((n) => {
486
- const r = t.getCurrentTheme().textColor, o = e.onCommandExecuted((s) => {
487
- if (s.id === dt.id) {
485
+ value$: new E((i) => {
486
+ const r = n.getCurrentTheme().textColor, o = e.onCommandExecuted((s) => {
487
+ if (s.id === ut.id) {
488
488
  const a = s.params.value;
489
- n.next(a != null ? a : r);
489
+ i.next(a != null ? a : r);
490
490
  }
491
491
  });
492
- return n.next(r), o.dispose;
492
+ return i.next(r), o.dispose;
493
493
  }),
494
- hidden$: M(i, f.UNIVER_DOC)
494
+ hidden$: b(t, g.UNIVER_DOC)
495
495
  // disabled$: getCurrentSheetDisabled$(accessor),
496
496
  };
497
497
  }
498
- function Bi(i) {
499
- const e = i.get(v);
498
+ function Li(t) {
499
+ const e = t.get(S);
500
500
  return {
501
- id: Mn.id,
502
- group: I.TOOLBAR_LAYOUT,
503
- type: T.BUTTON,
501
+ id: Nn.id,
502
+ group: T.TOOLBAR_LAYOUT,
503
+ type: R.BUTTON,
504
504
  icon: "LeftJustifyingSingle",
505
505
  tooltip: "toolbar.alignLeft",
506
- positions: [b.TOOLBAR_START],
507
- activated$: new y((t) => {
508
- const n = e.onCommandExecuted((r) => {
506
+ positions: [I.TOOLBAR_START],
507
+ activated$: new E((n) => {
508
+ const i = e.onCommandExecuted((r) => {
509
509
  var s;
510
510
  const o = r.id;
511
- if (o === x.id || o === Ae.id) {
512
- const a = we(i);
511
+ if (o === M.id || o === Ee.id) {
512
+ const a = Pe(t);
513
513
  if (a == null)
514
514
  return;
515
515
  const c = (s = a.paragraphStyle) == null ? void 0 : s.horizontalAlign;
516
- t.next(c === De.LEFT);
516
+ n.next(c === ve.LEFT);
517
517
  }
518
518
  });
519
- return t.next(!1), n.dispose;
519
+ return n.next(!1), i.dispose;
520
520
  }),
521
- hidden$: M(i, f.UNIVER_DOC)
521
+ hidden$: b(t, g.UNIVER_DOC)
522
522
  };
523
523
  }
524
- function wi(i) {
525
- const e = i.get(v);
524
+ function $i(t) {
525
+ const e = t.get(S);
526
526
  return {
527
- id: yn.id,
528
- group: I.TOOLBAR_LAYOUT,
529
- type: T.BUTTON,
527
+ id: Un.id,
528
+ group: T.TOOLBAR_LAYOUT,
529
+ type: R.BUTTON,
530
530
  icon: "HorizontallySingle",
531
531
  tooltip: "toolbar.alignCenter",
532
- positions: [b.TOOLBAR_START],
533
- activated$: new y((t) => {
534
- const n = e.onCommandExecuted((r) => {
532
+ positions: [I.TOOLBAR_START],
533
+ activated$: new E((n) => {
534
+ const i = e.onCommandExecuted((r) => {
535
535
  var s;
536
536
  const o = r.id;
537
- if (o === x.id || o === Ae.id) {
538
- const a = we(i);
537
+ if (o === M.id || o === Ee.id) {
538
+ const a = Pe(t);
539
539
  if (a == null)
540
540
  return;
541
541
  const c = (s = a.paragraphStyle) == null ? void 0 : s.horizontalAlign;
542
- t.next(c === De.CENTER);
542
+ n.next(c === ve.CENTER);
543
543
  }
544
544
  });
545
- return t.next(!1), n.dispose;
545
+ return n.next(!1), i.dispose;
546
546
  }),
547
- hidden$: M(i, f.UNIVER_DOC)
547
+ hidden$: b(t, g.UNIVER_DOC)
548
548
  };
549
549
  }
550
- function Fi(i) {
551
- const e = i.get(v);
550
+ function wi(t) {
551
+ const e = t.get(S);
552
552
  return {
553
- id: En.id,
554
- group: I.TOOLBAR_LAYOUT,
555
- type: T.BUTTON,
553
+ id: An.id,
554
+ group: T.TOOLBAR_LAYOUT,
555
+ type: R.BUTTON,
556
556
  icon: "RightJustifyingSingle",
557
557
  tooltip: "toolbar.alignRight",
558
- positions: [b.TOOLBAR_START],
559
- activated$: new y((t) => {
560
- const n = e.onCommandExecuted((r) => {
558
+ positions: [I.TOOLBAR_START],
559
+ activated$: new E((n) => {
560
+ const i = e.onCommandExecuted((r) => {
561
561
  var s;
562
562
  const o = r.id;
563
- if (o === x.id || o === Ae.id) {
564
- const a = we(i);
563
+ if (o === M.id || o === Ee.id) {
564
+ const a = Pe(t);
565
565
  if (a == null)
566
566
  return;
567
567
  const c = (s = a.paragraphStyle) == null ? void 0 : s.horizontalAlign;
568
- t.next(c === De.RIGHT);
568
+ n.next(c === ve.RIGHT);
569
569
  }
570
570
  });
571
- return t.next(!1), n.dispose;
571
+ return n.next(!1), i.dispose;
572
572
  }),
573
- hidden$: M(i, f.UNIVER_DOC)
573
+ hidden$: b(t, g.UNIVER_DOC)
574
574
  };
575
575
  }
576
- function Vi(i) {
577
- const e = i.get(v);
576
+ function Bi(t) {
577
+ const e = t.get(S);
578
578
  return {
579
- id: xn.id,
580
- group: I.TOOLBAR_LAYOUT,
581
- type: T.BUTTON,
579
+ id: Ln.id,
580
+ group: T.TOOLBAR_LAYOUT,
581
+ type: R.BUTTON,
582
582
  icon: "AlignTextBothSingle",
583
583
  tooltip: "toolbar.alignJustify",
584
- positions: [b.TOOLBAR_START],
585
- activated$: new y((t) => {
586
- const n = e.onCommandExecuted((r) => {
584
+ positions: [I.TOOLBAR_START],
585
+ activated$: new E((n) => {
586
+ const i = e.onCommandExecuted((r) => {
587
587
  var s;
588
588
  const o = r.id;
589
- if (o === x.id || o === Ae.id) {
590
- const a = we(i);
589
+ if (o === M.id || o === Ee.id) {
590
+ const a = Pe(t);
591
591
  if (a == null)
592
592
  return;
593
593
  const c = (s = a.paragraphStyle) == null ? void 0 : s.horizontalAlign;
594
- t.next(c === De.JUSTIFIED);
594
+ n.next(c === ve.JUSTIFIED);
595
595
  }
596
596
  });
597
- return t.next(!1), n.dispose;
597
+ return n.next(!1), i.dispose;
598
598
  }),
599
- hidden$: M(i, f.UNIVER_DOC)
599
+ hidden$: b(t, g.UNIVER_DOC)
600
600
  };
601
601
  }
602
- function ji(i) {
602
+ function Fi(t) {
603
603
  return {
604
- id: Dn.id,
605
- group: I.TOOLBAR_LAYOUT,
606
- type: T.BUTTON,
604
+ id: $n.id,
605
+ group: T.TOOLBAR_LAYOUT,
606
+ type: R.BUTTON,
607
607
  icon: "OrderSingle",
608
608
  tooltip: "toolbar.order",
609
- positions: [b.TOOLBAR_START],
610
- hidden$: M(i, f.UNIVER_DOC)
609
+ positions: [I.TOOLBAR_START],
610
+ hidden$: b(t, g.UNIVER_DOC)
611
611
  };
612
612
  }
613
- function Wi(i) {
613
+ function Vi(t) {
614
614
  return {
615
- id: Pn.id,
616
- group: I.TOOLBAR_LAYOUT,
617
- type: T.BUTTON,
615
+ id: wn.id,
616
+ group: T.TOOLBAR_LAYOUT,
617
+ type: R.BUTTON,
618
618
  icon: "UnorderSingle",
619
619
  tooltip: "toolbar.unorder",
620
- positions: [b.TOOLBAR_START],
621
- hidden$: M(i, f.UNIVER_DOC)
620
+ positions: [I.TOOLBAR_START],
621
+ hidden$: b(t, g.UNIVER_DOC)
622
622
  };
623
623
  }
624
- function zi(i) {
624
+ function ji(t) {
625
625
  return {
626
- id: Nn.id,
627
- type: T.BUTTON,
626
+ id: Bn.id,
627
+ type: R.BUTTON,
628
628
  title: "toolbar.resetColor",
629
629
  icon: "NoColor",
630
- positions: He.id
630
+ positions: Fe.id
631
631
  };
632
632
  }
633
- function ki(i) {
634
- const e = i.get(v), t = i.get(yt);
633
+ function Wi(t) {
634
+ const e = t.get(S), n = t.get(Et);
635
635
  return {
636
- id: He.id,
636
+ id: Fe.id,
637
637
  tooltip: "toolbar.fillColor.main",
638
- group: I.TOOLBAR_FORMAT,
639
- type: T.BUTTON_SELECTOR,
640
- positions: [b.TOOLBAR_START],
638
+ group: T.TOOLBAR_FORMAT,
639
+ type: R.BUTTON_SELECTOR,
640
+ positions: [I.TOOLBAR_START],
641
641
  icon: "PaintBucket",
642
642
  selections: [
643
643
  {
644
644
  label: {
645
- name: nt,
645
+ name: Qe,
646
646
  hoverable: !1
647
647
  }
648
648
  }
649
649
  ],
650
- value$: new y((n) => {
651
- const r = t.getCurrentTheme().primaryColor, o = e.onCommandExecuted((s) => {
652
- if (s.id === He.id) {
650
+ value$: new E((i) => {
651
+ const r = n.getCurrentTheme().primaryColor, o = e.onCommandExecuted((s) => {
652
+ if (s.id === Fe.id) {
653
653
  const a = s.params.value;
654
- n.next(a != null ? a : r);
654
+ i.next(a != null ? a : r);
655
655
  }
656
656
  });
657
- return n.next(r), o.dispose;
657
+ return i.next(r), o.dispose;
658
658
  }),
659
- hidden$: M(i, f.UNIVER_DOC)
659
+ hidden$: b(t, g.UNIVER_DOC)
660
660
  };
661
661
  }
662
- function V(i) {
662
+ function L(t) {
663
663
  var c;
664
- const e = i.get(P), t = i.get(J), n = e.getCurrentUniverDocInstance(), r = t.getActiveRange();
665
- if (n == null || r == null)
664
+ const e = t.get(P), n = t.get(X), i = e.getCurrentUniverDocInstance(), r = n.getActiveRange();
665
+ if (i == null || r == null)
666
666
  return;
667
- const o = (c = n.getBody()) == null ? void 0 : c.textRuns;
667
+ const o = (c = i.getBody()) == null ? void 0 : c.textRuns;
668
668
  if (o == null)
669
669
  return;
670
670
  const { startOffset: s } = r;
@@ -682,12 +682,12 @@ function V(i) {
682
682
  }
683
683
  return a;
684
684
  }
685
- function we(i) {
685
+ function Pe(t) {
686
686
  var c;
687
- const e = i.get(P), t = i.get(J), n = e.getCurrentUniverDocInstance(), r = t.getActiveRange();
688
- if (n == null || r == null)
687
+ const e = t.get(P), n = t.get(X), i = e.getCurrentUniverDocInstance(), r = n.getActiveRange();
688
+ if (i == null || r == null)
689
689
  return;
690
- const o = (c = n.getBody()) == null ? void 0 : c.paragraphs;
690
+ const o = (c = i.getBody()) == null ? void 0 : c.paragraphs;
691
691
  if (o == null)
692
692
  return;
693
693
  const { startOffset: s } = r;
@@ -700,98 +700,98 @@ function we(i) {
700
700
  }
701
701
  return null;
702
702
  }
703
- var Hi = Object.defineProperty, Yi = Object.getOwnPropertyDescriptor, Gi = (i, e, t, n) => {
704
- for (var r = n > 1 ? void 0 : n ? Yi(e, t) : e, o = i.length - 1, s; o >= 0; o--)
705
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
706
- return n && r && Hi(e, t, r), r;
707
- }, W = (i, e) => (t, n) => e(t, n, i);
708
- let ce = class extends k {
709
- constructor(i, e, t, n, r, o, s, a) {
710
- super(), this._config = i, this._injector = e, this._componentManager = t, this._layoutService = n, this._editorService = r, this._menuService = o, this._uiPartsService = s, this._univerInstanceService = a, this._init();
703
+ var zi = Object.defineProperty, Hi = Object.getOwnPropertyDescriptor, ki = (t, e, n, i) => {
704
+ for (var r = i > 1 ? void 0 : i ? Hi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
705
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
706
+ return i && r && zi(e, n, r), r;
707
+ }, B = (t, e) => (n, i) => e(n, i, t);
708
+ let ie = class extends F {
709
+ constructor(t, e, n, i, r, o, s, a) {
710
+ super(), this._config = t, this._injector = e, this._componentManager = n, this._layoutService = i, this._editorService = r, this._menuService = o, this._uiPartsService = s, this._univerInstanceService = a, this._init();
711
711
  }
712
712
  _initCustomComponents() {
713
- const i = this._componentManager;
714
- this.disposeWithMe(i.register(nt, qn)), this.disposeWithMe(i.register(At, rn)), this.disposeWithMe(i.register(Lt, on)), this.disposeWithMe(i.register($t, sn));
713
+ const t = this._componentManager;
714
+ this.disposeWithMe(t.register(Qe, Kn)), this.disposeWithMe(t.register(Dt, nn)), this.disposeWithMe(t.register(Nt, rn)), this.disposeWithMe(t.register(Ut, on));
715
715
  }
716
716
  _initMenus() {
717
- const { menu: i = {} } = this._config;
717
+ const { menu: t = {} } = this._config;
718
718
  [
719
719
  Ei,
720
+ yi,
721
+ Mi,
720
722
  xi,
721
- Di,
722
723
  Pi,
723
- Ni,
724
+ Di,
724
725
  Ui,
725
- Li,
726
+ Ni,
726
727
  Ai,
728
+ Li,
727
729
  $i,
728
- Bi,
729
730
  wi,
731
+ Bi,
730
732
  Fi,
731
733
  Vi,
732
734
  ji,
733
- Wi,
734
- zi,
735
- ki
735
+ Wi
736
736
  ].forEach((e) => {
737
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), i));
737
+ this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), t));
738
738
  });
739
739
  }
740
740
  _init() {
741
741
  this._initCustomComponents(), this._initMenus(), this._initDocBackground(), this._initFocusHandler();
742
742
  }
743
743
  _initDocBackground() {
744
- const i = this._univerInstanceService.getAllUnitsForType(f.UNIVER_DOC)[0].getUnitId();
745
- if (i == null)
744
+ const t = this._univerInstanceService.getAllUnitsForType(g.UNIVER_DOC)[0].getUnitId();
745
+ if (t == null)
746
746
  return;
747
- this._editorService.isEditor(i) || this.disposeWithMe(
748
- this._uiPartsService.registerComponent(an.CONTENT, () => jn(yi, this._injector))
747
+ this._editorService.isEditor(t) || this.disposeWithMe(
748
+ this._uiPartsService.registerComponent(sn.CONTENT, () => Yn(bi, this._injector))
749
749
  );
750
750
  }
751
751
  _initFocusHandler() {
752
752
  this.disposeWithMe(
753
- this._layoutService.registerFocusHandler(f.UNIVER_DOC, () => {
754
- this._injector.get(he).focus();
753
+ this._layoutService.registerFocusHandler(g.UNIVER_DOC, () => {
754
+ this._injector.get(se).focus();
755
755
  })
756
756
  );
757
757
  }
758
758
  };
759
- ce = Gi([
760
- U(A.Rendered, ce),
761
- W(1, O(Pe)),
762
- W(2, O(cn)),
763
- W(3, xt),
764
- W(4, L),
765
- W(5, ln),
766
- W(6, dn),
767
- W(7, P)
768
- ], ce);
769
- const Xi = {
770
- id: Un.id,
771
- preconditions: ni,
772
- binding: E.ENTER
773
- }, Ki = {
774
- id: An.id,
775
- preconditions: N,
776
- binding: E.BACKSPACE
777
- }, Zi = {
778
- id: Ln.id,
779
- preconditions: N,
780
- binding: E.DELETE
781
- }, qi = 10, Ji = 6;
782
- function Qi() {
783
- return Je.generateRandomId(Ji);
759
+ ie = ki([
760
+ Ce(Oe.Rendered, ie),
761
+ B(1, O(Re)),
762
+ B(2, O(an)),
763
+ B(3, Mt),
764
+ B(4, A),
765
+ B(5, cn),
766
+ B(6, ln),
767
+ B(7, P)
768
+ ], ie);
769
+ const Yi = {
770
+ id: Fn.id,
771
+ preconditions: ei,
772
+ binding: y.ENTER
773
+ }, Gi = {
774
+ id: Vn.id,
775
+ preconditions: D,
776
+ binding: y.BACKSPACE
777
+ }, Xi = {
778
+ id: jn.id,
779
+ preconditions: D,
780
+ binding: y.DELETE
781
+ }, Ki = 10, Zi = 6;
782
+ function qi() {
783
+ return Ke.generateRandomId(Zi);
784
784
  }
785
- function er(i) {
786
- const e = i.match(/data-copy-id="([^\s]+)"/);
785
+ function Ji(t) {
786
+ const e = t.match(/data-copy-id="([^\s]+)"/);
787
787
  return e && e[1] ? e[1] : null;
788
788
  }
789
- class tr {
789
+ class Qi {
790
790
  constructor() {
791
- g(this, "_cache", new kt(qi));
791
+ v(this, "_cache", new jt(Ki));
792
792
  }
793
- set(e, t) {
794
- this._cache.set(e, t);
793
+ set(e, n) {
794
+ this._cache.set(e, n);
795
795
  }
796
796
  get(e) {
797
797
  return this._cache.get(e);
@@ -800,35 +800,35 @@ class tr {
800
800
  this._cache.clear();
801
801
  }
802
802
  }
803
- const St = new tr();
804
- function it(i) {
805
- const e = i.style, t = {}, n = i.tagName.toLowerCase();
806
- switch (n) {
803
+ const gt = new Qi();
804
+ function et(t) {
805
+ const e = t.style, n = {}, i = t.tagName.toLowerCase();
806
+ switch (i) {
807
807
  case "b":
808
808
  case "em":
809
809
  case "strong": {
810
- t.bl = C.TRUE;
810
+ n.bl = C.TRUE;
811
811
  break;
812
812
  }
813
813
  case "s": {
814
- t.st = {
814
+ n.st = {
815
815
  s: C.TRUE
816
816
  };
817
817
  break;
818
818
  }
819
819
  case "u": {
820
- t.ul = {
820
+ n.ul = {
821
821
  s: C.TRUE
822
822
  };
823
823
  break;
824
824
  }
825
825
  case "i": {
826
- t.it = C.TRUE;
826
+ n.it = C.TRUE;
827
827
  break;
828
828
  }
829
829
  case "sub":
830
830
  case "sup": {
831
- t.va = n === "sup" ? K.SUPERSCRIPT : K.SUBSCRIPT;
831
+ n.va = i === "sup" ? k.SUPERSCRIPT : k.SUBSCRIPT;
832
832
  break;
833
833
  }
834
834
  }
@@ -836,63 +836,63 @@ function it(i) {
836
836
  const o = e[r], s = e.getPropertyValue(o);
837
837
  switch (o) {
838
838
  case "font-family": {
839
- t.ff = s;
839
+ n.ff = s;
840
840
  break;
841
841
  }
842
842
  case "font-size": {
843
843
  const a = Number.parseInt(s);
844
- Number.isNaN(a) || (s.endsWith("pt") ? t.fs = a : s.endsWith("px") && (t.fs = Wn(a)));
844
+ Number.isNaN(a) || (s.endsWith("pt") ? n.fs = a : s.endsWith("px") && (n.fs = Sn(a)));
845
845
  break;
846
846
  }
847
847
  case "font-style": {
848
- s === "italic" && (t.it = C.TRUE);
848
+ s === "italic" && (n.it = C.TRUE);
849
849
  break;
850
850
  }
851
851
  case "font-weight": {
852
- Number(s) > 400 && (t.bl = C.TRUE);
852
+ (Number(s) > 400 || String(s) === "bold") && (n.bl = C.TRUE);
853
853
  break;
854
854
  }
855
855
  case "text-decoration": {
856
- /underline/.test(s) ? t.ul = {
856
+ /underline/.test(s) ? n.ul = {
857
857
  s: C.TRUE
858
- } : /overline/.test(s) ? t.ol = {
858
+ } : /overline/.test(s) ? n.ol = {
859
859
  s: C.TRUE
860
- } : /line-through/.test(s) && (t.st = {
860
+ } : /line-through/.test(s) && (n.st = {
861
861
  s: C.TRUE
862
862
  });
863
863
  break;
864
864
  }
865
865
  case "color": {
866
- const a = new st(s);
867
- a.isValid && (t.cl = {
866
+ const a = new it(s);
867
+ a.isValid && (n.cl = {
868
868
  rgb: a.toRgbString()
869
869
  });
870
870
  break;
871
871
  }
872
872
  case "background-color": {
873
- const a = new st(s);
874
- a.isValid && (t.bg = {
873
+ const a = new it(s);
874
+ a.isValid && (n.bg = {
875
875
  rgb: a.toRgbString()
876
876
  });
877
877
  break;
878
878
  }
879
879
  }
880
880
  }
881
- return t;
881
+ return n;
882
882
  }
883
- function nr(i) {
884
- const e = new DOMParser(), t = `<x-univer id="univer-root">${i}</x-univer>`;
885
- return e.parseFromString(t, "text/html").querySelector("#univer-root");
883
+ function er(t) {
884
+ const e = new DOMParser(), n = `<x-univer id="univer-root">${t}</x-univer>`;
885
+ return e.parseFromString(n, "text/html").querySelector("#univer-root");
886
886
  }
887
- function vt(i, e) {
888
- const t = i.tagName.toLowerCase();
889
- return typeof e == "string" ? t === e : Array.isArray(e) ? e.some((n) => n === t) : e(i);
887
+ function ft(t, e) {
888
+ const n = t.tagName.toLowerCase();
889
+ return typeof e == "string" ? n === e : Array.isArray(e) ? e.some((i) => i === n) : e(t);
890
890
  }
891
- const Ee = class Ee {
891
+ const me = class me {
892
892
  constructor() {
893
- g(this, "_styleCache", /* @__PURE__ */ new Map());
894
- g(this, "_styleRules", []);
895
- g(this, "_afterProcessRules", []);
893
+ v(this, "_styleCache", /* @__PURE__ */ new Map());
894
+ v(this, "_styleRules", []);
895
+ v(this, "_afterProcessRules", []);
896
896
  }
897
897
  static use(e) {
898
898
  if (this._pluginList.includes(e))
@@ -900,48 +900,54 @@ const Ee = class Ee {
900
900
  this._pluginList.push(e);
901
901
  }
902
902
  convert(e) {
903
- const t = Ee._pluginList.find((o) => o.checkPasteType(e)), n = nr(e), r = {
903
+ const n = me._pluginList.find((o) => o.checkPasteType(e)), i = er(e), r = {
904
904
  dataStream: "",
905
905
  textRuns: []
906
906
  };
907
- return t && (this._styleRules = [...t.stylesRules], this._afterProcessRules = [...t.afterProcessRules]), this._styleCache.clear(), this._process(null, n == null ? void 0 : n.childNodes, r), this._styleCache.clear(), this._styleRules = [], this._afterProcessRules = [], r;
908
- }
909
- _process(e, t, n) {
910
- var r;
911
- for (const o of t)
912
- if (o.nodeType === Node.TEXT_NODE) {
913
- const s = (r = o.nodeValue) == null ? void 0 : r.replace(/[\r\n]/g, "");
914
- let a;
915
- e && this._styleCache.has(e) && (a = this._styleCache.get(e)), n.dataStream += s, a && Object.getOwnPropertyNames(a).length && n.textRuns.push({
916
- st: n.dataStream.length - s.length,
917
- ed: n.dataStream.length,
918
- ts: a
907
+ return n && (this._styleRules = [...n.stylesRules], this._afterProcessRules = [...n.afterProcessRules]), this._styleCache.clear(), this._process(null, i == null ? void 0 : i.childNodes, r), this._styleCache.clear(), this._styleRules = [], this._afterProcessRules = [], r;
908
+ }
909
+ _process(e, n, i) {
910
+ var r, o;
911
+ for (const s of n)
912
+ if (s.nodeType === Node.TEXT_NODE) {
913
+ if (((r = s.nodeValue) == null ? void 0 : r.trim()) === "")
914
+ continue;
915
+ const a = (o = s.nodeValue) == null ? void 0 : o.replace(/[\r\n]/g, "");
916
+ let c;
917
+ e && this._styleCache.has(e) && (c = this._styleCache.get(e)), i.dataStream += a, c && Object.getOwnPropertyNames(c).length && i.textRuns.push({
918
+ st: i.dataStream.length - a.length,
919
+ ed: i.dataStream.length,
920
+ ts: c
919
921
  });
920
- } else if (o.nodeType === Node.ELEMENT_NODE) {
921
- const s = e ? this._styleCache.get(e) : {}, a = this._styleRules.find(({ filter: h }) => vt(o, h)), c = a ? a.getStyle(o) : it(o);
922
- this._styleCache.set(o, { ...s, ...c });
923
- const { childNodes: l } = o;
924
- this._process(o, l, n);
925
- const u = this._afterProcessRules.find(
926
- ({ filter: h }) => vt(o, h)
927
- );
928
- u && u.handler(n, o);
922
+ } else {
923
+ if (Wt.includes(s.nodeName.toLowerCase()))
924
+ continue;
925
+ if (s.nodeType === Node.ELEMENT_NODE) {
926
+ const a = e ? this._styleCache.get(e) : {}, c = this._styleRules.find(({ filter: _ }) => ft(s, _)), l = c ? c.getStyle(s) : et(s);
927
+ this._styleCache.set(s, { ...a, ...l });
928
+ const { childNodes: u } = s;
929
+ this._process(s, u, i);
930
+ const h = this._afterProcessRules.find(
931
+ ({ filter: _ }) => ft(s, _)
932
+ );
933
+ h && h.handler(i, s);
934
+ }
929
935
  }
930
936
  }
931
937
  };
932
- g(Ee, "_pluginList", []);
933
- let Z = Ee;
934
- const ir = {
938
+ v(me, "_pluginList", []);
939
+ let Y = me;
940
+ const tr = {
935
941
  name: "univer-doc-paste-plugin-lark",
936
- checkPasteType(i) {
937
- return /lark-record-clipboard/i.test(i);
942
+ checkPasteType(t) {
943
+ return /lark-record-clipboard/i.test(t);
938
944
  },
939
945
  // TODO: @JOCS, support inline code copy from lark.
940
946
  stylesRules: [
941
947
  {
942
948
  filter: ["s"],
943
- getStyle(i) {
944
- const e = it(i);
949
+ getStyle(t) {
950
+ const e = et(t);
945
951
  return {
946
952
  st: {
947
953
  s: C.TRUE
@@ -953,163 +959,163 @@ const ir = {
953
959
  ],
954
960
  afterProcessRules: [
955
961
  {
956
- filter(i) {
957
- return i.tagName === "DIV" && /ace-line/i.test(i.className);
962
+ filter(t) {
963
+ return t.tagName === "DIV" && /ace-line/i.test(t.className);
958
964
  },
959
- handler(i) {
960
- i.paragraphs == null && (i.paragraphs = []), i.paragraphs.push({
961
- startIndex: i.dataStream.length
962
- }), i.dataStream += "\r";
965
+ handler(t) {
966
+ t.paragraphs == null && (t.paragraphs = []), t.paragraphs.push({
967
+ startIndex: t.dataStream.length
968
+ }), t.dataStream += "\r";
963
969
  }
964
970
  }
965
971
  ]
966
- }, rr = ir;
967
- function Ft(i) {
968
- const e = i.style, t = {};
969
- for (let n = 0; n < e.length; n++) {
970
- const r = e[n], o = e.getPropertyValue(r);
972
+ }, nr = tr;
973
+ function $t(t) {
974
+ const e = t.style, n = {};
975
+ for (let i = 0; i < e.length; i++) {
976
+ const r = e[i], o = e.getPropertyValue(r);
971
977
  switch (r) {
972
978
  case "margin-top": {
973
979
  const s = Number.parseInt(o);
974
- t.spaceAbove = /pt/.test(o) ? ht(s) : s;
980
+ n.spaceAbove = /pt/.test(o) ? ot(s) : s;
975
981
  break;
976
982
  }
977
983
  case "margin-bottom": {
978
984
  const s = Number.parseInt(o);
979
- t.spaceBelow = /pt/.test(o) ? ht(s) : s;
985
+ n.spaceBelow = /pt/.test(o) ? ot(s) : s;
980
986
  break;
981
987
  }
982
988
  case "line-height": {
983
989
  const s = Number.parseFloat(o);
984
- t.lineSpacing = s;
990
+ n.lineSpacing = s;
985
991
  break;
986
992
  }
987
993
  }
988
994
  }
989
- return Object.getOwnPropertyNames(t).length ? t : null;
995
+ return Object.getOwnPropertyNames(n).length ? n : null;
990
996
  }
991
- const or = {
997
+ const ir = {
992
998
  name: "univer-doc-paste-plugin-word",
993
- checkPasteType(i) {
994
- return /word|mso/i.test(i);
999
+ checkPasteType(t) {
1000
+ return /word|mso/i.test(t);
995
1001
  },
996
1002
  stylesRules: [
997
1003
  {
998
1004
  filter: ["b"],
999
- getStyle(i) {
1000
- const e = it(i);
1005
+ getStyle(t) {
1006
+ const e = et(t);
1001
1007
  return { bl: C.TRUE, ...e };
1002
1008
  }
1003
1009
  }
1004
1010
  ],
1005
1011
  afterProcessRules: [
1006
1012
  {
1007
- filter(i) {
1008
- return i.tagName === "P" && /mso/i.test(i.className);
1013
+ filter(t) {
1014
+ return t.tagName === "P";
1009
1015
  },
1010
- handler(i, e) {
1011
- i.paragraphs == null && (i.paragraphs = []);
1012
- const t = {
1013
- startIndex: i.dataStream.length
1014
- }, n = Ft(e);
1015
- n && (t.paragraphStyle = n), i.paragraphs.push(t), i.dataStream += "\r";
1016
+ handler(t, e) {
1017
+ t.paragraphs == null && (t.paragraphs = []);
1018
+ const n = {
1019
+ startIndex: t.dataStream.length
1020
+ }, i = $t(e);
1021
+ i && (n.paragraphStyle = i), t.paragraphs.push(n), t.dataStream += "\r";
1016
1022
  }
1017
1023
  }
1018
1024
  ]
1019
- }, sr = or, ar = {
1025
+ }, rr = ir, or = {
1020
1026
  name: "univer-doc-paste-plugin-univer",
1021
- checkPasteType(i) {
1022
- return /UniverNormal/i.test(i);
1027
+ checkPasteType(t) {
1028
+ return /UniverNormal/i.test(t);
1023
1029
  },
1024
1030
  stylesRules: [],
1025
1031
  afterProcessRules: [
1026
1032
  {
1027
- filter(i) {
1028
- return i.tagName === "P" && /UniverNormal/i.test(i.className);
1033
+ filter(t) {
1034
+ return t.tagName === "P" && /UniverNormal/i.test(t.className);
1029
1035
  },
1030
- handler(i, e) {
1031
- i.paragraphs == null && (i.paragraphs = []);
1032
- const t = {
1033
- startIndex: i.dataStream.length
1034
- }, n = Ft(e);
1035
- n && (t.paragraphStyle = n), i.paragraphs.push(t), i.dataStream += "\r";
1036
+ handler(t, e) {
1037
+ t.paragraphs == null && (t.paragraphs = []);
1038
+ const n = {
1039
+ startIndex: t.dataStream.length
1040
+ }, i = $t(e);
1041
+ i && (n.paragraphStyle = i), t.paragraphs.push(n), t.dataStream += "\r";
1036
1042
  }
1037
1043
  }
1038
1044
  ]
1039
- }, cr = ar;
1040
- function Ct(i, e) {
1041
- const { st: t, ed: n, ts: r = {} } = e, { ff: o, fs: s, it: a, bl: c, ul: l, st: u, ol: h, bg: m, cl: p, va: S } = r;
1042
- let d = i.slice(t, n);
1043
- const _ = [];
1044
- return a === C.TRUE && (d = `<i>${d}</i>`), S === K.SUPERSCRIPT ? d = `<sup>${d}</sup>` : S === K.SUBSCRIPT && (d = `<sub>${d}</sub>`), (l == null ? void 0 : l.s) === C.TRUE && (d = `<u>${d}</u>`), (u == null ? void 0 : u.s) === C.TRUE && (d = `<s>${d}</s>`), c === C.TRUE && (d = `<strong>${d}</strong>`), o && _.push(`font-family: ${o}`), p && _.push(`color: ${p.rgb}`), s && _.push(`font-size: ${s}pt`), h && _.push("text-decoration: overline"), m && _.push(`background: ${m.rgb}`), _.length ? `<span style="${_.join("; ")};">${d}</span>` : d;
1045
+ }, sr = or;
1046
+ function mt(t, e) {
1047
+ const { st: n, ed: i, ts: r = {} } = e, { ff: o, fs: s, it: a, bl: c, ul: l, st: u, ol: h, bg: _, cl: p, va: m } = r;
1048
+ let d = t.slice(n, i);
1049
+ const f = [];
1050
+ return a === C.TRUE && (d = `<i>${d}</i>`), m === k.SUPERSCRIPT ? d = `<sup>${d}</sup>` : m === k.SUBSCRIPT && (d = `<sub>${d}</sub>`), (l == null ? void 0 : l.s) === C.TRUE && (d = `<u>${d}</u>`), (u == null ? void 0 : u.s) === C.TRUE && (d = `<s>${d}</s>`), c === C.TRUE && (d = `<strong>${d}</strong>`), o && f.push(`font-family: ${o}`), p && f.push(`color: ${p.rgb}`), s && f.push(`font-size: ${s}pt`), h && f.push("text-decoration: overline"), _ && f.push(`background: ${_.rgb}`), f.length ? `<span style="${f.join("; ")};">${d}</span>` : d;
1045
1051
  }
1046
- function ze(i, e, t) {
1047
- const { dataStream: n, textRuns: r = [] } = i;
1052
+ function Ae(t, e, n) {
1053
+ const { dataStream: i, textRuns: r = [] } = t;
1048
1054
  let o = e;
1049
1055
  const s = [];
1050
1056
  for (const a of r) {
1051
1057
  const { st: c, ed: l } = a;
1052
- Je.hasIntersectionBetweenTwoRanges(e, t, c, l) && (c > o ? (s.push(n.slice(o, c)), s.push(Ct(n, {
1058
+ Ke.hasIntersectionBetweenTwoRanges(e, n, c, l) && (c > o ? (s.push(i.slice(o, c)), s.push(mt(i, {
1053
1059
  ...a,
1054
- ed: Math.min(l, t)
1055
- }))) : s.push(Ct(n, {
1060
+ ed: Math.min(l, n)
1061
+ }))) : s.push(mt(i, {
1056
1062
  ...a,
1057
1063
  st: o,
1058
- ed: Math.min(l, t)
1059
- }))), o = Math.max(e, Math.min(l, t));
1064
+ ed: Math.min(l, n)
1065
+ }))), o = Math.max(e, Math.min(l, n));
1060
1066
  }
1061
- return o !== t && s.push(n.slice(o, t)), s.join("");
1067
+ return o !== n && s.push(i.slice(o, n)), s.join("");
1062
1068
  }
1063
- function Ot(i, e = !0) {
1064
- var t;
1065
- if (e && ((t = i.paragraphs) != null && t.length)) {
1066
- const { dataStream: n, paragraphs: r = [] } = i;
1069
+ function St(t, e = !0) {
1070
+ var n;
1071
+ if (e && ((n = t.paragraphs) != null && n.length)) {
1072
+ const { dataStream: i, paragraphs: r = [] } = t;
1067
1073
  let o = "", s = -1;
1068
1074
  for (const a of r) {
1069
- const { startIndex: c, paragraphStyle: l = {} } = a, { spaceAbove: u, spaceBelow: h, lineSpacing: m } = l, p = [];
1070
- u != null && (typeof u == "number" ? p.push(`margin-top: ${u}px`) : p.push(`margin-top: ${u.v}px`)), h != null && (typeof h == "number" ? p.push(`margin-bottom: ${h}px`) : p.push(`margin-bottom: ${h.v}px`)), m != null && p.push(`line-height: ${m}`), c > s + 1 ? o += `<p class="UniverNormal" ${p.length ? `style="${p.join("; ")};"` : ""}>${ze(i, s + 1, c)}</p>` : o += `<p class="UniverNormal" ${p.length ? `style="${p.join("; ")};"` : ""}></p>`, s = c;
1075
+ const { startIndex: c, paragraphStyle: l = {} } = a, { spaceAbove: u, spaceBelow: h, lineSpacing: _ } = l, p = [];
1076
+ u != null && (typeof u == "number" ? p.push(`margin-top: ${u}px`) : p.push(`margin-top: ${u.v}px`)), h != null && (typeof h == "number" ? p.push(`margin-bottom: ${h}px`) : p.push(`margin-bottom: ${h.v}px`)), _ != null && p.push(`line-height: ${_}`), c > s + 1 ? o += `<p class="UniverNormal" ${p.length ? `style="${p.join("; ")};"` : ""}>${Ae(t, s + 1, c)}</p>` : o += `<p class="UniverNormal" ${p.length ? `style="${p.join("; ")};"` : ""}></p>`, s = c;
1071
1077
  }
1072
- return s !== n.length && (o += ze(i, s, n.length)), o;
1078
+ return s !== i.length && (o += Ae(t, s, i.length)), o;
1073
1079
  } else
1074
- return ze(i, 0, i.dataStream.length);
1080
+ return Ae(t, 0, t.dataStream.length);
1075
1081
  }
1076
- class lr {
1082
+ class ar {
1077
1083
  convert(e) {
1078
1084
  if (e.length === 0)
1079
1085
  throw new Error("The bodyList length at least to be 1");
1080
1086
  if (e.length === 1)
1081
- return Ot(e[0]);
1082
- let t = "";
1083
- for (const n of e)
1084
- t += '<p className="UniverNormal">', t += Ot(n, !1), t += "</p>";
1085
- return t;
1087
+ return St(e[0]);
1088
+ let n = "";
1089
+ for (const i of e)
1090
+ n += '<p className="UniverNormal">', n += St(i, !1), n += "</p>";
1091
+ return n;
1086
1092
  }
1087
1093
  }
1088
- var dr = Object.defineProperty, ur = Object.getOwnPropertyDescriptor, hr = (i, e, t, n) => {
1089
- for (var r = n > 1 ? void 0 : n ? ur(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1090
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1091
- return n && r && dr(e, t, r), r;
1092
- }, re = (i, e) => (t, n) => e(t, n, i);
1093
- Z.use(sr);
1094
- Z.use(rr);
1095
- Z.use(cr);
1096
- function pr(i) {
1097
- const e = i.replace(/\n/g, "\r"), t = [];
1098
- for (let n = 0; n < e.length; n++)
1099
- e[n] === "\r" && t.push({ startIndex: n });
1094
+ var cr = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, dr = (t, e, n, i) => {
1095
+ for (var r = i > 1 ? void 0 : i ? lr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1096
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1097
+ return i && r && cr(e, n, r), r;
1098
+ }, J = (t, e) => (n, i) => e(n, i, t);
1099
+ Y.use(rr);
1100
+ Y.use(nr);
1101
+ Y.use(sr);
1102
+ function ur(t) {
1103
+ const e = t.replace(/\n/g, "\r"), n = [];
1104
+ for (let i = 0; i < e.length; i++)
1105
+ e[i] === "\r" && n.push({ startIndex: i });
1100
1106
  return {
1101
1107
  dataStream: e,
1102
- paragraphs: t
1108
+ paragraphs: n
1103
1109
  };
1104
1110
  }
1105
- const pe = tn("doc.clipboard-service");
1106
- let Xe = class extends k {
1107
- constructor(e, t, n, r, o) {
1111
+ const ae = en("doc.clipboard-service");
1112
+ let je = class extends F {
1113
+ constructor(e, n, i, r, o) {
1108
1114
  super();
1109
- g(this, "_clipboardHooks", []);
1110
- g(this, "_htmlToUDM", new Z());
1111
- g(this, "_umdToHtml", new lr());
1112
- this._univerInstanceService = e, this._logService = t, this._commandService = n, this._clipboardInterfaceService = r, this._textSelectionManagerService = o;
1115
+ v(this, "_clipboardHooks", []);
1116
+ v(this, "_htmlToUDM", new Y());
1117
+ v(this, "_umdToHtml", new ar());
1118
+ this._univerInstanceService = e, this._logService = n, this._commandService = i, this._clipboardInterfaceService = r, this._textSelectionManagerService = o;
1113
1119
  }
1114
1120
  async copy() {
1115
1121
  const e = this._getDocumentBodyInRanges();
@@ -1117,8 +1123,8 @@ let Xe = class extends k {
1117
1123
  return !1;
1118
1124
  try {
1119
1125
  this._setClipboardData(e);
1120
- } catch (t) {
1121
- return this._logService.error("[DocClipboardService] copy failed", t), !1;
1126
+ } catch (n) {
1127
+ return this._logService.error("[DocClipboardService] copy failed", n), !1;
1122
1128
  }
1123
1129
  return !0;
1124
1130
  }
@@ -1126,51 +1132,51 @@ let Xe = class extends k {
1126
1132
  return this._cut();
1127
1133
  }
1128
1134
  async paste(e) {
1129
- const t = await this._generateBodyFromClipboardItems(e);
1130
- return this._paste(t);
1131
- }
1132
- async legacyPaste(e, t) {
1133
- const n = this._generateBodyFromHtmlAndText(e, t);
1135
+ const n = await this._generateBodyFromClipboardItems(e);
1134
1136
  return this._paste(n);
1135
1137
  }
1138
+ async legacyPaste(e, n) {
1139
+ const i = this._generateBodyFromHtmlAndText(e, n);
1140
+ return this._paste(i);
1141
+ }
1136
1142
  async _cut() {
1137
1143
  var o;
1138
1144
  const {
1139
1145
  segmentId: e,
1140
- endOffset: t,
1141
- style: n
1146
+ endOffset: n,
1147
+ style: i
1142
1148
  } = (o = this._textSelectionManagerService.getActiveRange()) != null ? o : {}, r = this._textSelectionManagerService.getSelections();
1143
- if (e == null && this._logService.error("[DocClipboardController] segmentId is not existed"), t == null || r == null)
1149
+ if (e == null && this._logService.error("[DocClipboardController] segmentId is not existed"), n == null || r == null)
1144
1150
  return !1;
1145
1151
  this.copy();
1146
1152
  try {
1147
- let s = t;
1153
+ let s = n;
1148
1154
  for (const c of r) {
1149
1155
  const { startOffset: l, endOffset: u } = c;
1150
- l == null || u == null || u <= t && (s -= u - l);
1156
+ l == null || u == null || u <= n && (s -= u - l);
1151
1157
  }
1152
1158
  const a = [
1153
1159
  {
1154
1160
  startOffset: s,
1155
1161
  endOffset: s,
1156
- style: n
1162
+ style: i
1157
1163
  }
1158
1164
  ];
1159
- return this._commandService.executeCommand(Dt.id, { segmentId: e, textRanges: a });
1165
+ return this._commandService.executeCommand(xt.id, { segmentId: e, textRanges: a });
1160
1166
  } catch {
1161
1167
  return this._logService.error("[DocClipboardController] cut content failed"), !1;
1162
1168
  }
1163
1169
  }
1164
1170
  async _paste(e) {
1165
1171
  var s;
1166
- const { segmentId: t, endOffset: n, style: r } = (s = this._textSelectionManagerService.getActiveRange()) != null ? s : {}, o = this._textSelectionManagerService.getSelections();
1167
- if (t == null && this._logService.error("[DocClipboardController] segmentId does not exist!"), n == null || o == null)
1172
+ const { segmentId: n, endOffset: i, style: r } = (s = this._textSelectionManagerService.getActiveRange()) != null ? s : {}, o = this._textSelectionManagerService.getSelections();
1173
+ if (n == null && this._logService.error("[DocClipboardController] segmentId does not exist!"), i == null || o == null)
1168
1174
  return !1;
1169
1175
  try {
1170
- let a = n;
1176
+ let a = i;
1171
1177
  for (const l of o) {
1172
1178
  const { startOffset: u, endOffset: h } = l;
1173
- u == null || h == null || h <= n && (a += e.dataStream.length - (h - u));
1179
+ u == null || h == null || h <= i && (a += e.dataStream.length - (h - u));
1174
1180
  }
1175
1181
  const c = [
1176
1182
  {
@@ -1179,142 +1185,142 @@ let Xe = class extends k {
1179
1185
  style: r
1180
1186
  }
1181
1187
  ];
1182
- return this._commandService.executeCommand(Pt.id, { body: e, segmentId: t, textRanges: c });
1188
+ return this._commandService.executeCommand(Pt.id, { body: e, segmentId: n, textRanges: c });
1183
1189
  } catch {
1184
1190
  return this._logService.error("[DocClipboardController]", "clipboard is empty."), !1;
1185
1191
  }
1186
1192
  }
1187
1193
  async _setClipboardData(e) {
1188
- const t = Qi(), n = e.length > 1 ? e.map((o) => o.dataStream).join(`
1194
+ const n = qi(), i = e.length > 1 ? e.map((o) => o.dataStream).join(`
1189
1195
  `) : e[0].dataStream;
1190
1196
  let r = this._umdToHtml.convert(e);
1191
- return e.length === 1 && (r = r.replace(/(<[a-z]+)/, (o, s) => `${s} data-copy-id="${t}"`), St.set(t, e[0])), this._clipboardInterfaceService.write(n, r);
1197
+ return e.length === 1 && (r = r.replace(/(<[a-z]+)/, (o, s) => `${s} data-copy-id="${n}"`), gt.set(n, e[0])), this._clipboardInterfaceService.write(i, r);
1192
1198
  }
1193
1199
  addClipboardHook(e) {
1194
- return this._clipboardHooks.push(e), B(() => {
1195
- const t = this._clipboardHooks.indexOf(e);
1196
- t > -1 && this._clipboardHooks.splice(t, 1);
1200
+ return this._clipboardHooks.push(e), zt(() => {
1201
+ const n = this._clipboardHooks.indexOf(e);
1202
+ n > -1 && this._clipboardHooks.splice(n, 1);
1197
1203
  });
1198
1204
  }
1199
1205
  _getDocumentBodyInRanges() {
1200
- const e = this._textSelectionManagerService.getSelections(), t = this._univerInstanceService.getCurrentUniverDocInstance(), n = [];
1201
- if (e == null || !t)
1202
- return n;
1206
+ const e = this._textSelectionManagerService.getSelections(), n = this._univerInstanceService.getCurrentUniverDocInstance(), i = [];
1207
+ if (e == null || !n)
1208
+ return i;
1203
1209
  for (const r of e) {
1204
1210
  const { startOffset: o, endOffset: s, collapsed: a } = r;
1205
1211
  if (a || o == null || s == null)
1206
1212
  continue;
1207
- const c = t.sliceBody(o, s);
1208
- c != null && n.push(c);
1213
+ const c = n.sliceBody(o, s);
1214
+ c != null && i.push(c);
1209
1215
  }
1210
- return n;
1216
+ return i;
1211
1217
  }
1212
1218
  async _generateBodyFromClipboardItems(e) {
1213
1219
  try {
1214
- let t = "", n = "";
1220
+ let n = "", i = "";
1215
1221
  for (const r of e)
1216
1222
  for (const o of r.types)
1217
- o === un ? n = await r.getType(o).then((s) => s && s.text()) : o === hn && (t = await r.getType(o).then((s) => s && s.text()));
1218
- return this._generateBodyFromHtmlAndText(t, n);
1219
- } catch (t) {
1220
- return Promise.reject(t);
1223
+ o === dn ? i = await r.getType(o).then((s) => s && s.text()) : o === un && (n = await r.getType(o).then((s) => s && s.text()));
1224
+ return this._generateBodyFromHtmlAndText(n, i);
1225
+ } catch (n) {
1226
+ return Promise.reject(n);
1221
1227
  }
1222
1228
  }
1223
- _generateBodyFromHtmlAndText(e, t) {
1229
+ _generateBodyFromHtmlAndText(e, n) {
1224
1230
  if (!e) {
1225
- if (t)
1226
- return pr(t);
1231
+ if (n)
1232
+ return ur(n);
1227
1233
  throw new Error("[DocClipboardService] html and text cannot be both empty!");
1228
1234
  }
1229
- const n = er(e);
1230
- if (n) {
1231
- const r = St.get(n);
1235
+ const i = Ji(e);
1236
+ if (i) {
1237
+ const r = gt.get(i);
1232
1238
  if (r)
1233
1239
  return r;
1234
1240
  }
1235
1241
  return this._htmlToUDM.convert(e);
1236
1242
  }
1237
1243
  };
1238
- Xe = hr([
1239
- re(0, P),
1240
- re(1, Et),
1241
- re(2, v),
1242
- re(3, et),
1243
- re(4, O(J))
1244
- ], Xe);
1245
- function Fe(i) {
1246
- return i.getContextValue(xe) || i.getContextValue(Mt);
1244
+ je = dr([
1245
+ J(0, P),
1246
+ J(1, yt),
1247
+ J(2, S),
1248
+ J(3, qe),
1249
+ J(4, O(X))
1250
+ ], je);
1251
+ function De(t) {
1252
+ return t.getContextValue(Se) || t.getContextValue(It);
1247
1253
  }
1248
- const rt = 999, _r = {
1249
- id: pn.id,
1254
+ const tt = 999, hr = {
1255
+ id: hn.id,
1250
1256
  name: "doc.command.copy",
1251
- type: Qe.COMMAND,
1257
+ type: Ze.COMMAND,
1252
1258
  multi: !0,
1253
- priority: rt,
1254
- preconditions: Fe,
1255
- handler: async (i) => i.get(pe).copy()
1256
- }, gr = {
1257
- id: _n.id,
1259
+ priority: tt,
1260
+ preconditions: De,
1261
+ handler: async (t) => t.get(ae).copy()
1262
+ }, pr = {
1263
+ id: pn.id,
1258
1264
  name: "doc.command.cut",
1259
- type: Qe.COMMAND,
1265
+ type: Ze.COMMAND,
1260
1266
  multi: !0,
1261
- priority: rt,
1262
- preconditions: Fe,
1263
- handler: async (i) => i.get(pe).cut()
1264
- }, fr = {
1265
- id: gn.id,
1267
+ priority: tt,
1268
+ preconditions: De,
1269
+ handler: async (t) => t.get(ae).cut()
1270
+ }, _r = {
1271
+ id: _n.id,
1266
1272
  name: "doc.command.paste",
1267
- type: Qe.COMMAND,
1273
+ type: Ze.COMMAND,
1268
1274
  multi: !0,
1269
- priority: rt,
1270
- preconditions: Fe,
1271
- handler: async (i) => {
1272
- const e = i.get(pe), n = await i.get(et).read();
1273
- return n.length === 0 ? !1 : e.paste(n);
1275
+ priority: tt,
1276
+ preconditions: De,
1277
+ handler: async (t) => {
1278
+ const e = t.get(ae), i = await t.get(qe).read();
1279
+ return i.length === 0 ? !1 : e.paste(i);
1274
1280
  }
1275
1281
  };
1276
- var mr = Object.defineProperty, Sr = Object.getOwnPropertyDescriptor, vr = (i, e, t, n) => {
1277
- for (var r = n > 1 ? void 0 : n ? Sr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1278
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1279
- return n && r && mr(e, t, r), r;
1280
- }, oe = (i, e) => (t, n) => e(t, n, i);
1281
- let Ce = class extends de {
1282
- constructor(i, e, t, n, r) {
1283
- super(), this._commandService = i, this._clipboardInterfaceService = e, this._docClipboardService = t, this._textSelectionRenderManager = n, this._contextService = r, this._init();
1282
+ var gr = Object.defineProperty, fr = Object.getOwnPropertyDescriptor, mr = (t, e, n, i) => {
1283
+ for (var r = i > 1 ? void 0 : i ? fr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1284
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1285
+ return i && r && gr(e, n, r), r;
1286
+ }, Q = (t, e) => (n, i) => e(n, i, t);
1287
+ let pe = class extends re {
1288
+ constructor(t, e, n, i, r) {
1289
+ super(), this._commandService = t, this._clipboardInterfaceService = e, this._docClipboardService = n, this._textSelectionRenderManager = i, this._contextService = r, this._init();
1284
1290
  }
1285
1291
  _init() {
1286
- [_r, gr, fr].forEach((i) => this.disposeWithMe(this._commandService.registerMultipleCommand(i))), [Pt, Dt].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i))), this._initLegacyPasteCommand();
1292
+ [hr, pr, _r].forEach((t) => this.disposeWithMe(this._commandService.registerMultipleCommand(t))), [Pt, xt].forEach((t) => this.disposeWithMe(this._commandService.registerCommand(t))), this._initLegacyPasteCommand();
1287
1293
  }
1288
1294
  _initLegacyPasteCommand() {
1289
- var i;
1290
- (i = this._textSelectionRenderManager) == null || i.onPaste$.pipe(le(this.dispose$)).subscribe((e) => {
1295
+ var t;
1296
+ (t = this._textSelectionRenderManager) == null || t.onPaste$.pipe(H(this.dispose$)).subscribe((e) => {
1291
1297
  var o, s;
1292
- if (!Fe(this._contextService))
1298
+ if (!De(this._contextService))
1293
1299
  return;
1294
1300
  e.event.preventDefault();
1295
- const t = e.event, n = (o = t.clipboardData) == null ? void 0 : o.getData("text/html"), r = (s = t.clipboardData) == null ? void 0 : s.getData("text/plain");
1296
- this._docClipboardService.legacyPaste(n, r);
1301
+ const n = e.event, i = (o = n.clipboardData) == null ? void 0 : o.getData("text/html"), r = (s = n.clipboardData) == null ? void 0 : s.getData("text/plain");
1302
+ this._docClipboardService.legacyPaste(i, r);
1297
1303
  });
1298
1304
  }
1299
1305
  };
1300
- Ce = vr([
1301
- U(A.Rendered, Ce),
1302
- oe(0, v),
1303
- oe(1, et),
1304
- oe(2, pe),
1305
- oe(3, he),
1306
- oe(4, Ht)
1307
- ], Ce);
1308
- var Cr = Object.defineProperty, Or = Object.getOwnPropertyDescriptor, Rr = (i, e, t, n) => {
1309
- for (var r = n > 1 ? void 0 : n ? Or(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1310
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1311
- return n && r && Cr(e, t, r), r;
1312
- }, Y = (i, e) => (t, n) => e(t, n, i);
1313
- let Oe = class extends k {
1314
- constructor(e, t, n, r, o, s) {
1306
+ pe = mr([
1307
+ Ce(Oe.Rendered, pe),
1308
+ Q(0, S),
1309
+ Q(1, qe),
1310
+ Q(2, ae),
1311
+ Q(3, se),
1312
+ Q(4, Ht)
1313
+ ], pe);
1314
+ var Sr = Object.defineProperty, vr = Object.getOwnPropertyDescriptor, Cr = (t, e, n, i) => {
1315
+ for (var r = i > 1 ? void 0 : i ? vr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1316
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1317
+ return i && r && Sr(e, n, r), r;
1318
+ }, ee = (t, e) => (n, i) => e(n, i, t);
1319
+ let _e = class extends F {
1320
+ constructor(e, n, i, r, o) {
1315
1321
  super();
1316
- g(this, "_initialEditors", /* @__PURE__ */ new Set());
1317
- this._univerInstanceService = e, this._docSkeletonManagerService = t, this._editorService = n, this._commandService = r, this._textSelectionRenderManager = o, this._renderManagerService = s, this._initialize();
1322
+ v(this, "_initialEditors", /* @__PURE__ */ new Set());
1323
+ this._univerInstanceService = e, this._editorService = n, this._commandService = i, this._textSelectionRenderManager = r, this._renderManagerService = o, this._initialize();
1318
1324
  }
1319
1325
  _initialize() {
1320
1326
  this.disposeWithMe(
@@ -1322,36 +1328,39 @@ let Oe = class extends k {
1322
1328
  this._resize(e);
1323
1329
  })
1324
1330
  ), this._editorService.getAllEditor().forEach((e) => {
1325
- const t = e.editorUnitId;
1326
- this._initialEditors.has(t) || (this._initialEditors.add(t), this._resize(t));
1331
+ const n = e.editorUnitId;
1332
+ this._initialEditors.has(n) || (this._initialEditors.add(n), this._resize(n));
1327
1333
  }), this._commandExecutedListener(), this._initialSetValue(), this._initialBlur(), this._initialFocus(), this._initialValueChange();
1328
1334
  }
1329
1335
  _resize(e) {
1330
- var $, H, j;
1336
+ var j, $, w;
1331
1337
  if (e == null)
1332
1338
  return;
1333
- const t = this._editorService.getEditor(e);
1334
- if ((t == null ? void 0 : t.cancelDefaultResizeListener) === !0)
1339
+ const n = this._editorService.getEditor(e);
1340
+ if ((n == null ? void 0 : n.cancelDefaultResizeListener) === !0)
1335
1341
  return;
1336
- const n = ($ = this._docSkeletonManagerService.getSkeletonByUnitId(e)) == null ? void 0 : $.skeleton, r = this._univerInstanceService.getUniverDocInstance(e);
1337
- if (t == null || t.render == null || n == null || r == null)
1342
+ const i = this._univerInstanceService.getUniverDocInstance(e);
1343
+ if (!i)
1338
1344
  return;
1339
- n.calculate();
1340
- const { marginTop: o = 0, marginBottom: s = 0, marginLeft: a = 0, marginRight: c = 0 } = r.getSnapshot().documentStyle, { scene: l, mainComponent: u } = t.render;
1341
- let { actualHeight: h, actualWidth: m } = n.getActualSize();
1342
- h += o + s, m += a + c;
1343
- const { width: p, height: S } = t.getBoundingClientRect(), d = l.getViewport(Q.VIEW_MAIN);
1344
- let _ = d == null ? void 0 : d.getScrollBar();
1345
- const R = Math.max(m, p), D = Math.max(h, S);
1345
+ const r = (j = this._renderManagerService.getRenderById(i.getUnitId())) == null ? void 0 : j.with(V).getSkeleton();
1346
+ if (n == null || n.render == null || r == null || i == null)
1347
+ return;
1348
+ r.calculate();
1349
+ const { marginTop: o = 0, marginBottom: s = 0, marginLeft: a = 0, marginRight: c = 0 } = i.getSnapshot().documentStyle, { scene: l, mainComponent: u } = n.render;
1350
+ let { actualHeight: h, actualWidth: _ } = r.getActualSize();
1351
+ h += o + s, _ += a + c;
1352
+ const { width: p, height: m } = n.getBoundingClientRect(), d = l.getViewport(K.VIEW_MAIN);
1353
+ let f = d == null ? void 0 : d.getScrollBar();
1354
+ const x = Math.max(_, p), N = Math.max(h, m);
1346
1355
  l.transformByState({
1347
- width: R,
1348
- height: D
1349
- }), u == null || u.resize(R, D), t.isSingle() ? m > p ? _ == null ? d && new Ye(d, { barSize: 8, enableVertical: !1 }) : d == null || d.resetCanvasSizeAndUpdateScrollBar() : (_ = null, d == null || d.scrollTo({ x: 0, y: 0 }), (j = d == null ? void 0 : d.getScrollBar()) == null || j.dispose()) : h > S ? _ == null ? d && new Ye(d, { enableHorizontal: !1, barSize: 8 }) : d == null || d.resetCanvasSizeAndUpdateScrollBar() : (_ = null, d == null || d.scrollTo({ x: 0, y: 0 }), (H = d == null ? void 0 : d.getScrollBar()) == null || H.dispose());
1356
+ width: x,
1357
+ height: N
1358
+ }), u == null || u.resize(x, N), n.isSingle() ? _ > p ? f == null ? d && new Be(d, { barSize: 8, enableVertical: !1 }) : d == null || d.resetCanvasSizeAndUpdateScrollBar() : (f = null, d == null || d.scrollTo({ x: 0, y: 0 }), (w = d == null ? void 0 : d.getScrollBar()) == null || w.dispose()) : h > m ? f == null ? d && new Be(d, { enableHorizontal: !1, barSize: 8 }) : d == null || d.resetCanvasSizeAndUpdateScrollBar() : (f = null, d == null || d.scrollTo({ x: 0, y: 0 }), ($ = d == null ? void 0 : d.getScrollBar()) == null || $.dispose());
1350
1359
  }
1351
1360
  _initialSetValue() {
1352
1361
  this.disposeWithMe(
1353
1362
  this._editorService.setValue$.subscribe((e) => {
1354
- this._commandService.executeCommand($n.id, {
1363
+ this._commandService.executeCommand(Wn.id, {
1355
1364
  unitId: e.editorUnitId,
1356
1365
  body: e.body,
1357
1366
  segmentId: null
@@ -1370,15 +1379,15 @@ let Oe = class extends k {
1370
1379
  const e = (r = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : r.getUnitId();
1371
1380
  if (e == null)
1372
1381
  return;
1373
- const t = this._editorService.getEditor(e), n = this._editorService.getFocusEditor();
1374
- t == null || t.isSheetEditor() || n && n.editorUnitId === e || this._editorService.blur();
1382
+ const n = this._editorService.getEditor(e), i = this._editorService.getFocusEditor();
1383
+ n == null || n.isSheetEditor() || i && i.editorUnitId === e || this._editorService.blur();
1375
1384
  })
1376
1385
  );
1377
1386
  }
1378
1387
  _initialFocus() {
1379
1388
  this.disposeWithMe(
1380
- this._editorService.focus$.subscribe((n) => {
1381
- this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.addTextRanges([n]);
1389
+ this._editorService.focus$.subscribe((i) => {
1390
+ this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.addTextRanges([i]);
1382
1391
  })
1383
1392
  );
1384
1393
  const e = [
@@ -1388,17 +1397,17 @@ let Oe = class extends k {
1388
1397
  "univer-formula-help-param"
1389
1398
  ];
1390
1399
  this.disposeWithMe(
1391
- ft(window, "mousedown").subscribe((n) => {
1392
- const o = n.target.classList[0] || "";
1393
- if (Yt(o, e)) {
1394
- this._editorService.changeSpreadsheetFocusState(!0), n.stopPropagation();
1400
+ pt(window, "mousedown").subscribe((i) => {
1401
+ const o = i.target.classList[0] || "";
1402
+ if (kt(o, e)) {
1403
+ this._editorService.changeSpreadsheetFocusState(!0), i.stopPropagation();
1395
1404
  return;
1396
1405
  }
1397
1406
  this._editorService.changeSpreadsheetFocusState(!1);
1398
1407
  })
1399
- ), this._univerInstanceService.getAllUnitsForType(f.UNIVER_SHEET).forEach((n) => {
1400
- const r = n.getUnitId(), o = this._renderManagerService.getRenderById(r), s = o == null ? void 0 : o.engine.getCanvas().getCanvasEle();
1401
- s != null && ft(s, "mousedown").subscribe((a) => {
1408
+ ), this._univerInstanceService.getAllUnitsForType(g.UNIVER_SHEET).forEach((i) => {
1409
+ const r = i.getUnitId(), o = this._renderManagerService.getRenderById(r), s = o == null ? void 0 : o.engine.getCanvas().getCanvasEle();
1410
+ s != null && pt(s, "mousedown").subscribe((a) => {
1402
1411
  this._editorService.changeSpreadsheetFocusState(!0), a.stopPropagation();
1403
1412
  });
1404
1413
  });
@@ -1415,22 +1424,22 @@ let Oe = class extends k {
1415
1424
  );
1416
1425
  }
1417
1426
  _valueChange() {
1418
- var n;
1419
- const e = (n = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : n.getUnitId();
1427
+ var i;
1428
+ const e = (i = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : i.getUnitId();
1420
1429
  if (e == null)
1421
1430
  return;
1422
- const t = this._editorService.getEditor(e);
1423
- t == null || t.isSheetEditor() || this._editorService.refreshValueChange(e);
1431
+ const n = this._editorService.getEditor(e);
1432
+ n == null || n.isSheetEditor() || this._editorService.refreshValueChange(e);
1424
1433
  }
1425
1434
  /**
1426
1435
  * Listen to document edits to refresh the size of the formula editor.
1427
1436
  */
1428
1437
  _commandExecutedListener() {
1429
- const e = [tt.id, fn.id];
1438
+ const e = [Je.id, gn.id];
1430
1439
  this.disposeWithMe(
1431
- this._commandService.onCommandExecuted((t) => {
1432
- if (e.includes(t.id)) {
1433
- const n = t.params, { unitId: r } = n;
1440
+ this._commandService.onCommandExecuted((n) => {
1441
+ if (e.includes(n.id)) {
1442
+ const i = n.params, { unitId: r } = i;
1434
1443
  if (this._editorService.isSheetEditor(r))
1435
1444
  return;
1436
1445
  this._resize(r), this._valueChange();
@@ -1439,122 +1448,25 @@ let Oe = class extends k {
1439
1448
  );
1440
1449
  }
1441
1450
  };
1442
- Oe = Rr([
1443
- U(A.Rendered, Oe),
1444
- Y(0, P),
1445
- Y(1, O(ee)),
1446
- Y(2, L),
1447
- Y(3, v),
1448
- Y(4, he),
1449
- Y(5, F)
1450
- ], Oe);
1451
- var Tr = Object.defineProperty, Ir = Object.getOwnPropertyDescriptor, br = (i, e, t, n) => {
1452
- for (var r = n > 1 ? void 0 : n ? Ir(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1453
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1454
- return n && r && Tr(e, t, r), r;
1455
- }, ge = (i, e) => (t, n) => e(t, n, i);
1456
- let Re = class extends de {
1457
- constructor(e, t, n, r) {
1458
- super();
1459
- g(this, "_docRenderMap", /* @__PURE__ */ new Set());
1460
- this._docSkeletonManagerService = e, this._renderManagerService = t, this._commandService = n, this._editorService = r, this._initialRenderRefresh(), this._commandExecutedListener();
1461
- }
1462
- _initialRenderRefresh() {
1463
- this._docSkeletonManagerService.currentSkeletonBefore$.pipe(le(this.dispose$)).subscribe((e) => {
1464
- this._create(e);
1465
- });
1466
- }
1467
- _create(e) {
1468
- if (e == null)
1469
- return;
1470
- const { skeleton: t, unitId: n } = e;
1471
- let r = this._renderManagerService.getRenderById(n);
1472
- r == null && (this._renderManagerService.create(n), r = this._renderManagerService.getRenderById(n));
1473
- const { mainComponent: o, components: s } = r, a = o, c = s.get(X.BACKGROUND);
1474
- a.changeSkeleton(t), c.changeSkeleton(t), this._recalculateSizeBySkeleton(r, t);
1475
- }
1476
- _recalculateSizeBySkeleton(e, t) {
1477
- var m;
1478
- const { mainComponent: n, scene: r, unitId: o, components: s } = e, a = n, c = s.get(X.BACKGROUND), l = (m = t.getSkeletonData()) == null ? void 0 : m.pages;
1479
- if (l == null)
1480
- return;
1481
- let u = 0, h = 0;
1482
- for (let p = 0, S = l.length; p < S; p++) {
1483
- const d = l[p], { pageWidth: _, pageHeight: R } = d;
1484
- a.pageLayoutType === pt.VERTICAL ? (h += R, h += a.pageMarginTop, p === S - 1 && (h += a.pageMarginTop), u = Math.max(u, _)) : a.pageLayoutType === pt.HORIZONTAL && (u += _, p !== S - 1 && (u += a.pageMarginLeft), h = Math.max(h, R));
1485
- }
1486
- a.resize(u, h), c.resize(u, h), this._editorService.isEditor(o) || r.resize(u, h);
1487
- }
1488
- _commandExecutedListener() {
1489
- const e = [tt.id];
1490
- this.disposeWithMe(
1491
- this._commandService.onCommandExecuted((t) => {
1492
- var n;
1493
- if (e.includes(t.id)) {
1494
- const r = t.params, { unitId: o } = r, s = this._docSkeletonManagerService.getSkeletonByUnitId(o);
1495
- if (s == null)
1496
- return;
1497
- const { skeleton: a } = s, c = this._renderManagerService.getRenderById(o);
1498
- if (c == null || !!a.getViewModel().getDataModel().getSnapshot().disabled)
1499
- return;
1500
- if (a.calculate(), this._editorService.isEditor(o)) {
1501
- (n = c.mainComponent) == null || n.makeDirty();
1502
- return;
1503
- }
1504
- this._recalculateSizeBySkeleton(c, a);
1505
- }
1506
- })
1507
- );
1508
- }
1509
- };
1510
- Re = br([
1511
- U(A.Rendered, Re),
1512
- ge(0, O(ee)),
1513
- ge(1, F),
1514
- ge(2, v),
1515
- ge(3, L)
1516
- ], Re);
1517
- var Mr = Object.defineProperty, yr = Object.getOwnPropertyDescriptor, Er = (i, e, t, n) => {
1518
- for (var r = n > 1 ? void 0 : n ? yr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1519
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1520
- return n && r && Mr(e, t, r), r;
1521
- }, fe = (i, e) => (t, n) => e(t, n, i);
1522
- let Te = class extends de {
1523
- constructor(e, t, n, r) {
1524
- super();
1525
- g(this, "_scene");
1526
- g(this, "_currentDocumentModel");
1527
- g(this, "_fps$", new Ut(""));
1528
- g(this, "fps$", this._fps$.asObservable());
1529
- this._renderManagerService = e, this._configService = t, this._univerInstanceService = n, this._editorService = r, this._initialize();
1530
- }
1531
- _initialize() {
1532
- this._renderManagerService.createRender$.pipe(le(this.dispose$)).subscribe((e) => {
1533
- this._create(e);
1534
- }), this._univerInstanceService.getCurrentTypeOfUnit$(f.UNIVER_DOC).pipe(le(this.dispose$)).subscribe((e) => {
1535
- this._create(e == null ? void 0 : e.getUnitId());
1536
- }), this._univerInstanceService.getAllUnitsForType(f.UNIVER_DOC).forEach((e) => {
1537
- this._create(e.getUnitId());
1538
- });
1539
- }
1540
- dispose() {
1541
- this._fps$.complete();
1542
- }
1543
- _create(e) {
1544
- if (e == null)
1545
- return;
1546
- const t = this._univerInstanceService.getUniverDocInstance(e);
1547
- t != null && (this._currentDocumentModel = t, this._renderManagerService.has(e) || this._addNewRender());
1451
+ _e = Cr([
1452
+ Ce(Oe.Rendered, _e),
1453
+ ee(0, P),
1454
+ ee(1, A),
1455
+ ee(2, S),
1456
+ ee(3, se),
1457
+ ee(4, Te)
1458
+ ], _e);
1459
+ var Or = Object.defineProperty, Rr = Object.getOwnPropertyDescriptor, Tr = (t, e, n, i) => {
1460
+ for (var r = i > 1 ? void 0 : i ? Rr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1461
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1462
+ return i && r && Or(e, n, r), r;
1463
+ }, de = (t, e) => (n, i) => e(n, i, t);
1464
+ let We = class extends re {
1465
+ constructor(t, e, n, i, r) {
1466
+ super(), this._context = t, this._commandService = e, this._docSkeletonManagerService = n, this._configService = i, this._editorService = r, this._addNewRender(), this._initRenderRefresh(), this._initCommandListener();
1548
1467
  }
1549
1468
  _addNewRender() {
1550
- const t = this._currentDocumentModel.getUnitId();
1551
- this._renderManagerService.createRender(t);
1552
- const n = this._renderManagerService.getRenderById(t);
1553
- if (n == null)
1554
- return;
1555
- const { scene: r, engine: o } = n;
1556
- this._scene = r;
1557
- const s = new zn(Q.VIEW_MAIN, r, {
1469
+ const { scene: t, engine: e, unit: n } = this._context, i = new vn(K.VIEW_MAIN, t, {
1558
1470
  left: 0,
1559
1471
  top: 0,
1560
1472
  bottom: 0,
@@ -1563,335 +1475,289 @@ let Te = class extends de {
1563
1475
  isRelativeY: !0,
1564
1476
  isWheelPreventDefaultX: !0
1565
1477
  });
1566
- r.attachControl(), r.on(kn.wheel, (l, u) => {
1567
- const h = l;
1568
- if (h.ctrlKey) {
1569
- const m = Math.abs(h.deltaX);
1570
- let p = m < 40 ? 0.2 : m < 80 ? 0.4 : 0.2;
1571
- p *= h.deltaY > 0 ? -1 : 1, r.scaleX < 1 && (p /= 2), r.scaleX + p > 4 ? r.scale(4, 4) : r.scaleX + p < 0.1 ? r.scale(0.1, 0.1) : h.preventDefault();
1478
+ t.attachControl(), t.onMouseWheel$.subscribeEvent((s, a) => {
1479
+ const c = s;
1480
+ if (c.ctrlKey) {
1481
+ const l = Math.abs(c.deltaX);
1482
+ let u = l < 40 ? 0.2 : l < 80 ? 0.4 : 0.2;
1483
+ u *= c.deltaY > 0 ? -1 : 1, t.scaleX < 1 && (u /= 2), t.scaleX + u > 4 ? t.scale(4, 4) : t.scaleX + u < 0.1 ? t.scale(0.1, 0.1) : c.preventDefault();
1572
1484
  } else
1573
- s.onMouseWheel(h, u);
1574
- }), this._configService.getConfig("hasScroll") !== !1 && new Ye(s), r.addLayer(
1575
- new _t(r, [], We),
1576
- new _t(r, [], Bn)
1577
- ), this._addComponent(n), this._currentDocumentModel.getShouldRenderLoopImmediately() && o.runRenderLoop(() => {
1578
- r.render(), this._fps$.next(Math.round(o.getFps()).toString());
1579
- }), this._renderManagerService.setCurrent(t);
1580
- }
1581
- _addComponent(e) {
1582
- const t = this._scene, n = this._currentDocumentModel, r = {
1583
- pageMarginLeft: n.documentStyle.marginLeft || 0,
1584
- pageMarginTop: n.documentStyle.marginTop || 0
1585
- }, o = new Hn(X.MAIN, void 0, r), s = new Yn(X.BACKGROUND, void 0, r);
1586
- o.zIndex = ut, s.zIndex = ut, e.mainComponent = o, e.components.set(X.MAIN, o), e.components.set(X.BACKGROUND, s), t.addObjects([o], We), t.addObjects([s], wn), this._editorService.getEditor(n.getUnitId()) == null && t.enableLayerCache(We);
1485
+ i.onMouseWheel(c, a);
1486
+ }), this._configService.getConfig("hasScroll") !== !1 && new Be(i), t.addLayer(
1487
+ new st(t, [], Ue),
1488
+ new st(t, [], zn)
1489
+ ), this._addComponent(), n.getShouldRenderLoopImmediately() && e.runRenderLoop(() => {
1490
+ t.render();
1491
+ });
1492
+ }
1493
+ _addComponent() {
1494
+ const { scene: t, unit: e, components: n } = this._context, i = {
1495
+ pageMarginLeft: e.documentStyle.marginLeft || 0,
1496
+ pageMarginTop: e.documentStyle.marginTop || 0
1497
+ }, r = new Cn(W.MAIN, void 0, i);
1498
+ r.zIndex = ht;
1499
+ const o = new On(W.BACKGROUND, void 0, i);
1500
+ o.zIndex = ht, this._context.mainComponent = r, n.set(W.MAIN, r), n.set(W.BACKGROUND, o), t.addObjects([r], Ue), t.addObjects([o], Hn), this._editorService.getEditor(e.getUnitId()) == null && t.enableLayerCache(Ue);
1501
+ }
1502
+ _initRenderRefresh() {
1503
+ this._docSkeletonManagerService.currentSkeletonBefore$.pipe(H(this.dispose$)).subscribe((t) => {
1504
+ this._create(t);
1505
+ });
1506
+ }
1507
+ _create(t) {
1508
+ if (!t)
1509
+ return;
1510
+ const { mainComponent: e, components: n } = this._context, i = e, r = n.get(W.BACKGROUND);
1511
+ i.changeSkeleton(t), r.changeSkeleton(t), this._recalculateSizeBySkeleton(t);
1512
+ }
1513
+ _initCommandListener() {
1514
+ const t = [Je.id];
1515
+ this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
1516
+ var n;
1517
+ if (t.includes(e.id)) {
1518
+ const i = e.params, { unitId: r } = i, o = this._docSkeletonManagerService.getSkeleton();
1519
+ if (!o || !!o.getViewModel().getDataModel().getSnapshot().disabled)
1520
+ return;
1521
+ if (o.calculate(), this._editorService.isEditor(r)) {
1522
+ (n = this._context.mainComponent) == null || n.makeDirty();
1523
+ return;
1524
+ }
1525
+ this._recalculateSizeBySkeleton(o);
1526
+ }
1527
+ }));
1528
+ }
1529
+ _recalculateSizeBySkeleton(t) {
1530
+ var u;
1531
+ const { mainComponent: e, scene: n, unitId: i, components: r } = this._context, o = e, s = r.get(W.BACKGROUND), a = (u = t.getSkeletonData()) == null ? void 0 : u.pages;
1532
+ if (a == null)
1533
+ return;
1534
+ let c = 0, l = 0;
1535
+ for (let h = 0, _ = a.length; h < _; h++) {
1536
+ const p = a[h], { pageWidth: m, pageHeight: d } = p;
1537
+ o.pageLayoutType === at.VERTICAL ? (l += d, l += o.pageMarginTop, h === _ - 1 && (l += o.pageMarginTop), c = Math.max(c, m)) : o.pageLayoutType === at.HORIZONTAL && (c += m, h !== _ - 1 && (c += o.pageMarginLeft), l = Math.max(l, d));
1538
+ }
1539
+ o.resize(c, l), s.resize(c, l), this._editorService.isEditor(i) || n.resize(c, l);
1587
1540
  }
1588
1541
  };
1589
- Te = Er([
1590
- U(A.Starting, Te),
1591
- fe(0, F),
1592
- fe(1, Gt),
1593
- fe(2, P),
1594
- fe(3, L)
1595
- ], Te);
1596
- var xr = Object.defineProperty, Dr = Object.getOwnPropertyDescriptor, Pr = (i, e, t, n) => {
1597
- for (var r = n > 1 ? void 0 : n ? Dr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1598
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1599
- return n && r && xr(e, t, r), r;
1600
- }, me = (i, e) => (t, n) => e(t, n, i);
1601
- let Ie = class extends k {
1602
- constructor(e, t, n, r) {
1542
+ We = Tr([
1543
+ de(1, S),
1544
+ de(2, O(V)),
1545
+ de(3, Yt),
1546
+ de(4, A)
1547
+ ], We);
1548
+ var Ir = Object.defineProperty, br = Object.getOwnPropertyDescriptor, Er = (t, e, n, i) => {
1549
+ for (var r = i > 1 ? void 0 : i ? br(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1550
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1551
+ return i && r && Ir(e, n, r), r;
1552
+ }, Le = (t, e) => (n, i) => e(n, i, t);
1553
+ let ze = class extends F {
1554
+ constructor(e, n, i, r) {
1603
1555
  super();
1604
- g(this, "_liquid", new Gn());
1605
- g(this, "_pageMarginCache", /* @__PURE__ */ new Map());
1606
- this._docSkeletonManagerService = e, this._renderManagerService = t, this._commandService = n, this._editorService = r, this._initialize(), this._commandExecutedListener();
1556
+ v(this, "_liquid", new Rn());
1557
+ v(this, "_pageMarginCache", /* @__PURE__ */ new Map());
1558
+ this._context = e, this._docSkeletonManagerService = n, this._commandService = i, this._editorService = r, this._initialize(), this._commandExecutedListener();
1607
1559
  }
1608
1560
  _initialize() {
1609
- this._initialRenderRefresh(), this._updateOnPluginChange();
1610
- }
1611
- _updateOnPluginChange() {
1612
- }
1613
- _initialRenderRefresh() {
1614
1561
  this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1615
- if (e == null)
1616
- return;
1617
- const { skeleton: t, unitId: n } = e, r = this._renderManagerService.getRenderById(n);
1618
- if (r == null)
1619
- return;
1620
- const { mainComponent: o } = r;
1621
- o.changeSkeleton(t), this._refreshDrawing(n, t, r);
1562
+ e != null && this._refreshDrawing(e);
1622
1563
  });
1623
1564
  }
1624
1565
  _commandExecutedListener() {
1625
- const e = [tt.id, Le.id];
1566
+ const e = [Je.id, ye.id];
1626
1567
  this.disposeWithMe(
1627
- this._commandService.onCommandExecuted((t) => {
1628
- var n;
1629
- if (e.includes(t.id)) {
1630
- const r = t.params, { unitId: o } = r, s = this._docSkeletonManagerService.getCurrent();
1631
- if (s == null)
1632
- return;
1633
- const { unitId: a, skeleton: c } = s;
1634
- if (o !== a)
1635
- return;
1636
- const l = this._renderManagerService.getRenderById(a);
1637
- if (l == null)
1568
+ this._commandService.onCommandExecuted((n) => {
1569
+ var i;
1570
+ if (e.includes(n.id)) {
1571
+ const r = n.params, { unitId: o } = r, s = this._docSkeletonManagerService.getSkeleton();
1572
+ if (!s)
1638
1573
  return;
1639
- if (this._editorService.isEditor(a)) {
1640
- (n = l.mainComponent) == null || n.makeDirty();
1574
+ if (this._editorService.isEditor(o)) {
1575
+ (i = this._context.mainComponent) == null || i.makeDirty();
1641
1576
  return;
1642
1577
  }
1643
- this._refreshDrawing(a, c, l);
1578
+ this._refreshDrawing(s);
1644
1579
  }
1645
1580
  })
1646
1581
  );
1647
1582
  }
1648
- _refreshDrawing(e, t, n) {
1649
- const r = t == null ? void 0 : t.getSkeletonData(), { mainComponent: o, scene: s } = n, a = o;
1650
- if (!r)
1583
+ _refreshDrawing(e) {
1584
+ const n = e == null ? void 0 : e.getSkeletonData(), { mainComponent: i, scene: r, unitId: o } = this._context, s = i;
1585
+ if (!n)
1651
1586
  return;
1652
- const { left: c, top: l, pageLayoutType: u, pageMarginLeft: h, pageMarginTop: m } = a, { pages: p } = r, S = [];
1653
- s.getAncestorScale(), this._liquid.reset(), this._pageMarginCache.clear();
1654
- for (let d = 0, _ = p.length; d < _; d++) {
1655
- const R = p[d], { skeDrawings: D, marginLeft: $, marginTop: H } = R;
1656
- this._liquid.translatePagePadding(R), D.forEach((j) => {
1657
- const { aLeft: te, aTop: ne, height: Ve, width: je, drawingId: ie, drawingOrigin: ot } = j, Vt = ot.layoutType === Xt.WRAP_NONE && ot.behindDoc === C.TRUE;
1658
- S.push({
1659
- unitId: e,
1660
- subUnitId: Kt,
1661
- floatingObjectId: ie,
1662
- behindText: Vt,
1587
+ const { left: a, top: c, pageLayoutType: l, pageMarginLeft: u, pageMarginTop: h } = s, { pages: _ } = n, p = [];
1588
+ r.getAncestorScale(), this._liquid.reset(), this._pageMarginCache.clear();
1589
+ for (let m = 0, d = _.length; m < d; m++) {
1590
+ const f = _[m], { skeDrawings: x, marginLeft: N, marginTop: j } = f;
1591
+ this._liquid.translatePagePadding(f), x.forEach(($) => {
1592
+ const { aLeft: w, aTop: Z, height: q, width: Ne, drawingId: ce, drawingOrigin: nt } = $, wt = nt.layoutType === Gt.WRAP_NONE && nt.behindDoc === C.TRUE;
1593
+ p.push({
1594
+ unitId: o,
1595
+ subUnitId: Xt,
1596
+ floatingObjectId: ce,
1597
+ behindText: wt,
1663
1598
  floatingObject: {
1664
- left: te + c + this._liquid.x,
1665
- top: ne + l + this._liquid.y,
1666
- width: je,
1667
- height: Ve
1599
+ left: w + a + this._liquid.x,
1600
+ top: Z + c + this._liquid.y,
1601
+ width: Ne,
1602
+ height: q
1668
1603
  }
1669
- }), this._pageMarginCache.set(ie, {
1604
+ }), this._pageMarginCache.set(ce, {
1670
1605
  marginLeft: this._liquid.x,
1671
1606
  marginTop: this._liquid.y
1672
1607
  });
1673
- }), this._liquid.restorePagePadding(R), this._liquid.translatePage(R, u, h, m);
1608
+ }), this._liquid.restorePagePadding(f), this._liquid.translatePage(f, l, u, h);
1674
1609
  }
1675
1610
  }
1676
1611
  };
1677
- Ie = Pr([
1678
- U(A.Steady, Ie),
1679
- me(0, O(ee)),
1680
- me(1, F),
1681
- me(2, v),
1682
- me(3, L)
1683
- ], Ie);
1684
- var Nr = Object.defineProperty, Ur = Object.getOwnPropertyDescriptor, Ar = (i, e, t, n) => {
1685
- for (var r = n > 1 ? void 0 : n ? Ur(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1686
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1687
- return n && r && Nr(e, t, r), r;
1688
- }, G = (i, e) => (t, n) => e(t, n, i);
1689
- let be = class extends k {
1690
- constructor(e, t, n, r, o, s) {
1691
- super();
1692
- g(this, "_initializedRender", /* @__PURE__ */ new Set());
1693
- this._docSkeletonManagerService = e, this._univerInstanceService = t, this._commandService = n, this._renderManagerService = r, this._textSelectionManagerService = o, this._editorService = s, this._initialize();
1694
- }
1695
- dispose() {
1696
- super.dispose();
1612
+ ze = Er([
1613
+ Le(1, O(V)),
1614
+ Le(2, S),
1615
+ Le(3, A)
1616
+ ], ze);
1617
+ var yr = Object.defineProperty, Mr = Object.getOwnPropertyDescriptor, xr = (t, e, n, i) => {
1618
+ for (var r = i > 1 ? void 0 : i ? Mr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1619
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1620
+ return i && r && yr(e, n, r), r;
1621
+ }, te = (t, e) => (n, i) => e(n, i, t);
1622
+ let He = class extends F {
1623
+ constructor(t, e, n, i, r, o) {
1624
+ super(), this._context = t, this._docSkeletonManagerService = e, this._univerInstanceService = n, this._commandService = i, this._textSelectionManagerService = r, this._editorService = o, this._init();
1697
1625
  }
1698
- _initialize() {
1699
- this._skeletonListener(), this._commandExecutedListener(), this._initialRenderRefresh();
1626
+ _init() {
1627
+ this._initSkeletonListener(), this._initCommandExecutedListener(), this._initRenderRefresher(), setTimeout(() => this._updateViewZoom(1, !0), 20);
1700
1628
  }
1701
- _initialRenderRefresh() {
1702
- this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1703
- if (e == null)
1629
+ _initRenderRefresher() {
1630
+ this._docSkeletonManagerService.currentSkeleton$.subscribe((t) => {
1631
+ if (t == null)
1704
1632
  return;
1705
- const { unitId: t } = e, n = this._renderManagerService.getRenderById(t);
1706
- if (n == null || this._initializedRender.has(t) || this._editorService.isEditor(t))
1707
- return;
1708
- this._initializedRender.add(t);
1709
- const { scene: r } = n;
1710
- this.disposeWithMe(
1711
- B(
1712
- r.onMouseWheelObserver.add((o) => {
1713
- if (!o.ctrlKey)
1714
- return;
1715
- const s = this._univerInstanceService.getCurrentUniverDocInstance();
1716
- if (!s)
1717
- return;
1718
- const a = Math.abs(o.deltaX);
1719
- let c = a < 40 ? 0.2 : a < 80 ? 0.4 : 0.2;
1720
- c *= o.deltaY > 0 ? -1 : 1, r.scaleX < 1 && (c /= 2);
1721
- const l = s.zoomRatio;
1722
- let u = +Number.parseFloat(`${l + c}`).toFixed(1);
1723
- u = u >= 4 ? 4 : u <= 0.1 ? 0.1 : u, this._commandService.executeCommand(Fn.id, {
1724
- zoomRatio: u,
1725
- unitId: s.getUnitId()
1726
- }), o.preventDefault();
1727
- })
1728
- )
1729
- );
1633
+ const { unitId: e, scene: n } = this._context;
1634
+ this._editorService.isEditor(e) || this.disposeWithMe(n.onMouseWheel$.subscribeEvent((i) => {
1635
+ if (!i.ctrlKey)
1636
+ return;
1637
+ const r = this._univerInstanceService.getCurrentUniverDocInstance();
1638
+ if (!r)
1639
+ return;
1640
+ const o = Math.abs(i.deltaX);
1641
+ let s = o < 40 ? 0.2 : o < 80 ? 0.4 : 0.2;
1642
+ s *= i.deltaY > 0 ? -1 : 1, n.scaleX < 1 && (s /= 2);
1643
+ const a = r.zoomRatio;
1644
+ let c = +Number.parseFloat(`${a + s}`).toFixed(1);
1645
+ c = c >= 4 ? 4 : c <= 0.1 ? 0.1 : c, this._commandService.executeCommand(kn.id, {
1646
+ zoomRatio: c,
1647
+ unitId: r.getUnitId()
1648
+ }), i.preventDefault();
1649
+ }));
1730
1650
  });
1731
1651
  }
1732
- // private _zoomEventBinding() {
1733
- // const scene = this._getDocObject()?.scene;
1734
- // if (scene == null) {
1735
- // return;
1736
- // }
1737
- // const viewportMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
1738
- // }
1739
- _skeletonListener() {
1740
- this.disposeWithMe(
1741
- B(
1742
- this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1743
- if (e == null)
1744
- return;
1745
- const t = this._univerInstanceService.getCurrentUniverDocInstance();
1746
- if (!t) return;
1747
- const n = t.zoomRatio || 1;
1748
- this._updateViewZoom(n, !1);
1749
- })
1750
- )
1751
- );
1652
+ _initSkeletonListener() {
1653
+ this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe((t) => {
1654
+ if (t == null)
1655
+ return;
1656
+ const e = this._univerInstanceService.getCurrentUniverDocInstance();
1657
+ if (!e) return;
1658
+ const n = e.zoomRatio || 1;
1659
+ this._updateViewZoom(n, !1);
1660
+ }));
1752
1661
  }
1753
- _commandExecutedListener() {
1754
- const e = [Le.id];
1755
- this.disposeWithMe(
1756
- this._commandService.onCommandExecuted((t) => {
1757
- if (e.includes(t.id)) {
1758
- const n = this._univerInstanceService.getCurrentUniverDocInstance();
1759
- if (!n) return;
1760
- const r = t.params, { unitId: o } = r;
1761
- if (o !== n.getUnitId())
1762
- return;
1763
- const s = n.zoomRatio || 1;
1764
- this._updateViewZoom(s);
1765
- }
1766
- })
1767
- );
1662
+ _initCommandExecutedListener() {
1663
+ const t = [ye.id];
1664
+ this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
1665
+ if (t.includes(e.id)) {
1666
+ const n = this._univerInstanceService.getCurrentUniverDocInstance();
1667
+ if (!n) return;
1668
+ const i = e.params, { unitId: r } = i;
1669
+ if (r !== n.getUnitId())
1670
+ return;
1671
+ const o = n.zoomRatio || 1;
1672
+ this._updateViewZoom(o);
1673
+ }
1674
+ }));
1768
1675
  }
1769
- _updateViewZoom(e, t = !0) {
1770
- var r;
1771
- const n = this._getDocObject();
1772
- n != null && (n.scene.scale(e, e), this._calculatePagePosition(n, e), t && this._textSelectionManagerService.refreshSelection(), (r = n.scene.getTransformer()) == null || r.clearSelectedObjects());
1676
+ _updateViewZoom(t, e = !0) {
1677
+ var i;
1678
+ const n = fe(this._context);
1679
+ n.scene.scale(t, t), this._calculatePagePosition(n, t), e && this._textSelectionManagerService.refreshSelection(), (i = n.scene.getTransformer()) == null || i.clearSelectedObjects();
1773
1680
  }
1774
- _calculatePagePosition(e, t) {
1775
- const { document: n, scene: r, docBackground: o } = e, s = r == null ? void 0 : r.getParent(), { width: a, height: c, pageMarginLeft: l, pageMarginTop: u } = n;
1776
- if (s == null || a === Number.POSITIVE_INFINITY || c === Number.POSITIVE_INFINITY)
1681
+ _calculatePagePosition(t, e) {
1682
+ const { document: n, scene: i, docBackground: r } = t, o = i == null ? void 0 : i.getParent(), { width: s, height: a, pageMarginLeft: c, pageMarginTop: l } = n;
1683
+ if (o == null || s === Number.POSITIVE_INFINITY || a === Number.POSITIVE_INFINITY)
1777
1684
  return;
1778
- const { width: h, height: m } = s;
1779
- let p = 0, S = 0, d = 0, _ = 0, R = Number.POSITIVE_INFINITY;
1780
- h > (a + l * 2) * t ? (p = h / 2 - a * t / 2, p /= t, d = (h - l * 2) / t, R = 0) : (p = l, d = a + l * 2, R = (d - h / t) / 2), m > c ? (S = m / 2 - c / 2, _ = (m - u * 2) / t) : (S = u, _ = c + u * 2), r.resize(d, _ + 200), n.translate(p, S), o.translate(p, S);
1781
- const D = r.getViewport(Q.VIEW_MAIN);
1782
- if (R !== Number.POSITIVE_INFINITY && D != null) {
1783
- const $ = D.transViewportScroll2ScrollValue(R, 0).x;
1784
- D.scrollTo({
1785
- x: $
1685
+ const { width: u, height: h } = o;
1686
+ let _ = 0, p = 0, m = 0, d = 0, f = Number.POSITIVE_INFINITY;
1687
+ u > (s + c * 2) * e ? (_ = u / 2 - s * e / 2, _ /= e, m = (u - c * 2) / e, f = 0) : (_ = c, m = s + c * 2, f = (m - u / e) / 2), h > a ? (p = h / 2 - a / 2, d = (h - l * 2) / e) : (p = l, d = a + l * 2), i.resize(m, d + 200), n.translate(_, p), r.translate(_, p);
1688
+ const x = i.getViewport(K.VIEW_MAIN);
1689
+ if (f !== Number.POSITIVE_INFINITY && x != null) {
1690
+ const N = x.transViewportScroll2ScrollValue(f, 0).x;
1691
+ x.scrollTo({
1692
+ x: N
1786
1693
  });
1787
1694
  }
1788
1695
  return this;
1789
1696
  }
1790
- _getDocObject() {
1791
- return Nt(this._univerInstanceService, this._renderManagerService);
1792
- }
1793
1697
  };
1794
- be = Ar([
1795
- U(A.Rendered, be),
1796
- G(0, O(ee)),
1797
- G(1, P),
1798
- G(2, v),
1799
- G(3, F),
1800
- G(4, O(J)),
1801
- G(5, L)
1802
- ], be);
1803
- var Lr = Object.defineProperty, $r = Object.getOwnPropertyDescriptor, Br = (i, e, t, n) => {
1804
- for (var r = n > 1 ? void 0 : n ? $r(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1805
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1806
- return n && r && Lr(e, t, r), r;
1807
- }, z = (i, e) => (t, n) => e(t, n, i);
1808
- let Me = class extends k {
1809
- constructor(e, t, n, r, o, s, a) {
1698
+ He = xr([
1699
+ te(1, O(V)),
1700
+ te(2, P),
1701
+ te(3, S),
1702
+ te(4, O(X)),
1703
+ te(5, A)
1704
+ ], He);
1705
+ var Pr = Object.defineProperty, Dr = Object.getOwnPropertyDescriptor, Nr = (t, e, n, i) => {
1706
+ for (var r = i > 1 ? void 0 : i ? Dr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1707
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1708
+ return i && r && Pr(e, n, r), r;
1709
+ }, z = (t, e) => (n, i) => e(n, i, t);
1710
+ let ke = class extends F {
1711
+ constructor(e, n, i, r, o, s, a) {
1810
1712
  super();
1811
- g(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
1812
- this._docSkeletonManagerService = e, this._univerInstanceService = t, this._commandService = n, this._renderManagerService = r, this._textSelectionRenderManager = o, this._textSelectionManagerService = s, this._editorService = a, this._initialize();
1713
+ v(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
1714
+ this._context = e, this._commandService = n, this._editorService = i, this._instanceSrv = r, this._textSelectionRenderManager = o, this._docSkeletonManagerService = s, this._textSelectionManagerService = a, this._initialize();
1813
1715
  }
1814
1716
  _initialize() {
1815
1717
  this._init(), this._skeletonListener(), this._commandExecutedListener();
1816
1718
  }
1817
1719
  _init() {
1818
- this.disposeWithMe(
1819
- this._renderManagerService.currentRender$.subscribe((e) => {
1820
- this._create(e);
1821
- })
1822
- ), this._renderManagerService.getRenderAll().forEach((e, t) => {
1823
- this._create(t);
1824
- });
1720
+ const { unitId: e } = this._context, n = fe(this._context);
1721
+ n == null || n.document == null || this._loadedMap.has(n.document) || (this._initialMain(e), this._loadedMap.add(n.document));
1825
1722
  }
1826
- _create(e) {
1827
- if (e == null || this._univerInstanceService.getUniverDocInstance(e) == null)
1828
- return;
1829
- const t = this._getDocObjectById(e);
1830
- t == null || t.document == null || this._loadedMap.has(t.document) || (this._initialMain(e), this._loadedMap.add(t.document));
1831
- }
1832
- // eslint-disable-next-line max-lines-per-function
1833
1723
  _initialMain(e) {
1834
- const t = this._getDocObjectById(e);
1835
- if (t == null)
1836
- return;
1837
- const { document: n, scene: r } = t;
1838
- this.disposeWithMe(
1839
- B(
1840
- n.onPointerEnterObserver.add(() => {
1841
- this._isEditorReadOnly(e) || (n.cursor = gt.TEXT);
1842
- })
1843
- )
1844
- ), this.disposeWithMe(
1845
- B(
1846
- n.onPointerLeaveObserver.add(() => {
1847
- n.cursor = gt.DEFAULT, r.resetCursor();
1848
- })
1849
- )
1850
- ), this.disposeWithMe(
1851
- B(
1852
- n == null ? void 0 : n.onPointerDownObserver.add((o, s) => {
1853
- if (this._isEditorReadOnly(e))
1854
- return;
1855
- const a = this._univerInstanceService.getCurrentUniverDocInstance();
1856
- (a == null ? void 0 : a.getUnitId()) !== e && this._univerInstanceService.setCurrentUnitForType(e), this._textSelectionRenderManager.eventTrigger(o);
1857
- const { offsetX: c, offsetY: l } = o;
1858
- this._editorService.getEditor(e) && (this._setEditorFocus(e), setTimeout(() => {
1859
- this._setEditorFocus(e), this._textSelectionRenderManager.setCursorManually(c, l);
1860
- }, 0)), o.button !== 2 && s.stopPropagation();
1861
- })
1862
- )
1863
- ), this.disposeWithMe(
1864
- B(
1865
- n == null ? void 0 : n.onDblclickObserver.add((o) => {
1866
- this._isEditorReadOnly(e) || this._textSelectionRenderManager.handleDblClick(o);
1867
- })
1868
- )
1869
- ), this.disposeWithMe(
1870
- B(
1871
- n == null ? void 0 : n.onTripleClickObserver.add((o) => {
1872
- this._isEditorReadOnly(e) || this._textSelectionRenderManager.handleTripleClick(o);
1873
- })
1874
- )
1875
- );
1724
+ const n = fe(this._context), { document: i, scene: r } = n;
1725
+ this.disposeWithMe(i.onPointerEnter$.subscribeEvent(() => {
1726
+ this._isEditorReadOnly(e) || (i.cursor = ct.TEXT);
1727
+ })), this.disposeWithMe(i.onPointerLeave$.subscribeEvent(() => {
1728
+ i.cursor = ct.DEFAULT, r.resetCursor();
1729
+ })), this.disposeWithMe(i.onPointerDown$.subscribeEvent((o, s) => {
1730
+ if (this._isEditorReadOnly(e))
1731
+ return;
1732
+ const a = this._instanceSrv.getCurrentUnitForType(g.UNIVER_DOC);
1733
+ if ((a == null ? void 0 : a.getUnitId()) !== e && this._instanceSrv.setCurrentUnitForType(e), this._textSelectionRenderManager.eventTrigger(o), this._editorService.getEditor(e)) {
1734
+ this._setEditorFocus(e);
1735
+ const { offsetX: c, offsetY: l } = o;
1736
+ setTimeout(() => {
1737
+ this._setEditorFocus(e), this._textSelectionRenderManager.setCursorManually(c, l);
1738
+ }, 0);
1739
+ }
1740
+ o.button !== 2 && s.stopPropagation();
1741
+ })), this.disposeWithMe(i.onDblclick$.subscribeEvent((o) => {
1742
+ this._isEditorReadOnly(e) || this._textSelectionRenderManager.handleDblClick(o);
1743
+ })), this.disposeWithMe(i.onTripleClick$.subscribeEvent((o) => {
1744
+ this._isEditorReadOnly(e) || this._textSelectionRenderManager.handleTripleClick(o);
1745
+ }));
1876
1746
  }
1877
1747
  _isEditorReadOnly(e) {
1878
- const t = this._editorService.getEditor(e);
1879
- return t ? t.isReadOnly() : !1;
1748
+ const n = this._editorService.getEditor(e);
1749
+ return n ? n.isReadOnly() : !1;
1880
1750
  }
1881
1751
  _setEditorFocus(e) {
1882
- if (this._univerInstanceService.getAllUnitsForType(f.UNIVER_SHEET).length > 0) {
1883
- const n = this._univerInstanceService.getCurrentUnitForType(f.UNIVER_SHEET);
1884
- this._editorService.setOperationSheetUnitId(n.getUnitId());
1885
- }
1886
1752
  this._editorService.focusStyle(e);
1887
1753
  }
1888
1754
  _commandExecutedListener() {
1889
- const e = [Le.id];
1755
+ const e = [ye.id];
1890
1756
  this.disposeWithMe(
1891
- this._commandService.onCommandExecuted((t) => {
1892
- var n;
1893
- if (e.includes(t.id)) {
1894
- const r = t.params, { unitId: o } = r, s = (n = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : n.unitId;
1757
+ this._commandService.onCommandExecuted((n) => {
1758
+ var i;
1759
+ if (e.includes(n.id)) {
1760
+ const r = n.params, { unitId: o } = r, s = (i = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : i.unitId;
1895
1761
  if (o !== s)
1896
1762
  return;
1897
1763
  this._textSelectionManagerService.refreshSelection();
@@ -1904,14 +1770,11 @@ let Me = class extends k {
1904
1770
  this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1905
1771
  if (e == null)
1906
1772
  return;
1907
- const { unitId: t, skeleton: n } = e, r = this._renderManagerService.getRenderById(t);
1908
- if (r == null)
1909
- return;
1910
- const { scene: o, mainComponent: s } = r;
1911
- this._textSelectionRenderManager.changeRuntime(n, o, s), this._textSelectionManagerService.setCurrentSelectionNotRefresh({
1912
- unitId: t,
1773
+ const { scene: n, mainComponent: i, unitId: r } = this._context;
1774
+ this._textSelectionRenderManager.changeRuntime(e, n, i), this._textSelectionManagerService.setCurrentSelectionNotRefresh({
1775
+ unitId: r,
1913
1776
  subUnitId: ""
1914
- }), this._editorService.isEditor(t) || this._textSelectionManagerService.replaceTextRanges([
1777
+ }), this._editorService.isEditor(r) || this._textSelectionManagerService.replaceTextRanges([
1915
1778
  {
1916
1779
  startOffset: 0,
1917
1780
  endOffset: 0
@@ -1920,129 +1783,117 @@ let Me = class extends k {
1920
1783
  })
1921
1784
  );
1922
1785
  }
1923
- _getDocObjectById(e) {
1924
- return this._univerInstanceService.getUnitType(e) !== f.UNIVER_DOC ? null : Vn(e, this._renderManagerService);
1925
- }
1926
1786
  };
1927
- Me = Br([
1928
- U(A.Rendered, Me),
1929
- z(0, O(ee)),
1930
- z(1, P),
1931
- z(2, v),
1932
- z(3, F),
1933
- z(4, he),
1934
- z(5, O(J)),
1935
- z(6, L)
1936
- ], Me);
1937
- var wr = Object.defineProperty, Fr = Object.getOwnPropertyDescriptor, Vr = (i, e, t, n) => {
1938
- for (var r = n > 1 ? void 0 : n ? Fr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1939
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1940
- return n && r && wr(e, t, r), r;
1941
- }, se = (i, e) => (t, n) => e(t, n, i);
1942
- const Rt = 1.5;
1943
- let ye = class extends de {
1944
- constructor(i, e, t, n, r) {
1945
- super(), this._docSkeletonManagerService = i, this._textSelectionManagerService = e, this._editorService = t, this._univerInstanceService = n, this._renderManagerService = r, this._init();
1787
+ ke = Nr([
1788
+ z(1, S),
1789
+ z(2, A),
1790
+ z(3, P),
1791
+ z(4, se),
1792
+ z(5, O(V)),
1793
+ z(6, O(X))
1794
+ ], ke);
1795
+ var Ur = Object.defineProperty, Ar = Object.getOwnPropertyDescriptor, Lr = (t, e, n, i) => {
1796
+ for (var r = i > 1 ? void 0 : i ? Ar(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1797
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1798
+ return i && r && Ur(e, n, r), r;
1799
+ }, $e = (t, e) => (n, i) => e(n, i, t);
1800
+ const vt = 1.5;
1801
+ let Ye = class extends re {
1802
+ constructor(t, e, n, i) {
1803
+ super(), this._context = t, this._docSkeletonManagerService = e, this._textSelectionManagerService = n, this._editorService = i, this._init();
1946
1804
  }
1947
1805
  _init() {
1948
- this._textSelectionManagerService.textSelection$.pipe(le(this.dispose$)).subscribe((i) => {
1949
- if (i == null)
1806
+ this._textSelectionManagerService.textSelection$.pipe(H(this.dispose$)).subscribe((t) => {
1807
+ if (t == null)
1950
1808
  return;
1951
- const { isEditing: e, unitId: t } = i;
1952
- e && this._scrollToSelection(t);
1809
+ const { isEditing: e, unitId: n } = t;
1810
+ e && this._scrollToSelection(n);
1953
1811
  });
1954
1812
  }
1955
1813
  // Let the selection show on the current screen.
1956
- _scrollToSelection(i) {
1957
- var ie;
1958
- const e = this._textSelectionManagerService.getActiveRange(), t = this._getDocObject(), n = (ie = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : ie.skeleton;
1959
- if (e == null || t == null || n == null)
1814
+ _scrollToSelection(t) {
1815
+ const e = this._textSelectionManagerService.getActiveRange(), n = fe(this._context), i = this._docSkeletonManagerService.getSkeleton();
1816
+ if (e == null || n == null)
1960
1817
  return;
1961
1818
  const { collapsed: r, startNodePosition: o } = e;
1962
1819
  if (!r)
1963
1820
  return;
1964
- const s = t.document.getOffsetConfig(), { docsLeft: a, docsTop: c } = s, l = new Xn(s, n), { contentBoxPointGroup: u } = l.getRangePointData(o, o), { left: h, top: m, height: p } = Kn(u), S = h + a, d = m + c, _ = t.scene.getViewport(Q.VIEW_MAIN), R = !!this._editorService.getEditor(i);
1965
- if (_ == null)
1821
+ const s = n.document.getOffsetConfig(), { docsLeft: a, docsTop: c } = s, l = new Tn(s, i), { contentBoxPointGroup: u } = l.getRangePointData(o, o), { left: h, top: _, height: p } = In(u), m = h + a, d = _ + c, f = n.scene.getViewport(K.VIEW_MAIN), x = !!this._editorService.getEditor(t);
1822
+ if (f == null)
1966
1823
  return;
1967
1824
  const {
1968
- left: D,
1969
- top: $,
1970
- right: H,
1971
- bottom: j
1972
- } = _.getBounding().viewBound;
1973
- let te = 0, ne = 0;
1974
- const Ve = R ? 0 : 100;
1975
- d < $ ? te = d - $ : d > j - p && (te = d - j + p + Ve), S < D ? ne = S - D : S > H - Rt && (ne = S - H + Rt);
1976
- const je = _.transViewportScroll2ScrollValue(ne, te);
1977
- _.scrollBy(je);
1978
- }
1979
- _getDocObject() {
1980
- return Nt(this._univerInstanceService, this._renderManagerService);
1825
+ left: N,
1826
+ top: j,
1827
+ right: $,
1828
+ bottom: w
1829
+ } = f.getBounding().viewBound;
1830
+ let Z = 0, q = 0;
1831
+ const Ne = x ? 0 : 100;
1832
+ d < j ? Z = d - j : d > w - p && (Z = d - w + p + Ne), m < N ? q = m - N : m > $ - vt && (q = m - $ + vt);
1833
+ const ce = f.transViewportScroll2ScrollValue(q, Z);
1834
+ f.scrollBy(ce);
1981
1835
  }
1982
1836
  };
1983
- ye = Vr([
1984
- U(A.Rendered, ye),
1985
- se(0, O(ee)),
1986
- se(1, O(J)),
1987
- se(2, L),
1988
- se(3, P),
1989
- se(4, F)
1990
- ], ye);
1991
- var jr = Object.defineProperty, Wr = Object.getOwnPropertyDescriptor, zr = (i, e, t, n) => {
1992
- for (var r = n > 1 ? void 0 : n ? Wr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1993
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
1994
- return n && r && jr(e, t, r), r;
1995
- }, Se = (i, e) => (t, n) => e(t, n, i);
1996
- function kr(i, e) {
1997
- const t = Tt(i.left, i.top, e), n = Tt(i.right, i.bottom, e);
1837
+ Ye = Lr([
1838
+ $e(1, O(V)),
1839
+ $e(2, O(X)),
1840
+ $e(3, A)
1841
+ ], Ye);
1842
+ var $r = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, Br = (t, e, n, i) => {
1843
+ for (var r = i > 1 ? void 0 : i ? wr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1844
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1845
+ return i && r && $r(e, n, r), r;
1846
+ }, ue = (t, e) => (n, i) => e(n, i, t);
1847
+ function Fr(t, e) {
1848
+ const n = Ct(t.left, t.top, e), i = Ct(t.right, t.bottom, e);
1998
1849
  return {
1999
- left: t.x,
2000
- top: t.y,
2001
- right: n.x,
2002
- bottom: n.y
1850
+ left: n.x,
1851
+ top: n.y,
1852
+ right: i.x,
1853
+ bottom: i.y
2003
1854
  };
2004
1855
  }
2005
- function Tt(i, e, t) {
2006
- const { scaleX: n, scaleY: r } = t.getAncestorScale(), o = t.getViewport(Q.VIEW_MAIN);
1856
+ function Ct(t, e, n) {
1857
+ const { scaleX: i, scaleY: r } = n.getAncestorScale(), o = n.getViewport(K.VIEW_MAIN);
2007
1858
  if (!o)
2008
1859
  return {
2009
- x: i,
1860
+ x: t,
2010
1861
  y: e
2011
1862
  };
2012
- const { viewportScrollX: s, viewportScrollY: a } = o, c = (i - s) * n, l = (e - a) * r;
1863
+ const { viewportScrollX: s, viewportScrollY: a } = o, c = (t - s) * i, l = (e - a) * r;
2013
1864
  return {
2014
1865
  x: c,
2015
1866
  y: l
2016
1867
  };
2017
1868
  }
2018
- let Ke = class extends k {
2019
- constructor(i, e, t, n) {
2020
- super(), this._globalPopupManagerService = i, this._renderManagerService = e, this._univerInstanceService = t, this._commandService = n;
1869
+ let Ge = class extends F {
1870
+ constructor(t, e, n, i) {
1871
+ super(), this._globalPopupManagerService = t, this._renderManagerService = e, this._univerInstanceService = n, this._commandService = i;
2021
1872
  }
2022
1873
  // #region attach to object
2023
- _createObjectPositionObserver(i, e) {
2024
- const t = () => {
2025
- const { scene: a } = e, { left: c, top: l, width: u, height: h } = i, m = {
1874
+ _createObjectPositionObserver(t, e) {
1875
+ const n = () => {
1876
+ const { scene: a } = e, { left: c, top: l, width: u, height: h } = t, _ = {
2026
1877
  left: c,
2027
1878
  right: c + u,
2028
1879
  top: l,
2029
1880
  bottom: l + h
2030
- }, p = kr(m, a);
1881
+ }, p = Fr(_, a);
2031
1882
  return {
2032
1883
  left: p.left,
2033
1884
  right: p.right,
2034
1885
  top: p.top,
2035
1886
  bottom: p.bottom
2036
1887
  };
2037
- }, n = t(), r = new Ut(n), o = new Zt();
1888
+ }, i = n(), r = new Xn(i), o = new Kt();
2038
1889
  o.add(this._commandService.onCommandExecuted((a) => {
2039
- a.id === Le.id && r.next(t());
1890
+ a.id === ye.id && r.next(n());
2040
1891
  }));
2041
- const s = e.scene.getViewport(Q.VIEW_MAIN);
2042
- return o.add(s == null ? void 0 : s.onScrollAfterObserver.add(() => {
2043
- r.next(t());
1892
+ const s = e.scene.getViewport(K.VIEW_MAIN);
1893
+ return s && o.add(s.onScrollAfter$.subscribeEvent(() => {
1894
+ r.next(n());
2044
1895
  })), {
2045
- position: n,
1896
+ position: i,
2046
1897
  position$: r,
2047
1898
  disposable: o
2048
1899
  };
@@ -2053,16 +1904,16 @@ let Ke = class extends k {
2053
1904
  * @param popup popup item
2054
1905
  * @returns disposable
2055
1906
  */
2056
- attachPopupToObject(i, e) {
2057
- const n = this._univerInstanceService.getCurrentUnitForType(f.UNIVER_DOC).getUnitId(), r = this._renderManagerService.getRenderById(n);
1907
+ attachPopupToObject(t, e) {
1908
+ const i = this._univerInstanceService.getCurrentUnitForType(g.UNIVER_DOC).getUnitId(), r = this._renderManagerService.getRenderById(i);
2058
1909
  if (!r)
2059
1910
  return {
2060
1911
  dispose: () => {
2061
1912
  }
2062
1913
  };
2063
- const { position: o, position$: s, disposable: a } = this._createObjectPositionObserver(i, r), c = this._globalPopupManagerService.addPopup({
1914
+ const { position: o, position$: s, disposable: a } = this._createObjectPositionObserver(t, r), c = this._globalPopupManagerService.addPopup({
2064
1915
  ...e,
2065
- unitId: n,
1916
+ unitId: i,
2066
1917
  subUnitId: "default",
2067
1918
  anchorRect: o,
2068
1919
  anchorRect$: s
@@ -2074,134 +1925,160 @@ let Ke = class extends k {
2074
1925
  };
2075
1926
  }
2076
1927
  };
2077
- Ke = zr([
2078
- Se(0, O(mn)),
2079
- Se(1, F),
2080
- Se(2, P),
2081
- Se(3, v)
2082
- ], Ke);
2083
- var Hr = Object.defineProperty, Yr = Object.getOwnPropertyDescriptor, Gr = (i, e, t, n) => {
2084
- for (var r = n > 1 ? void 0 : n ? Yr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
2085
- (s = i[o]) && (r = (n ? s(e, t, r) : s(r)) || r);
2086
- return n && r && Hr(e, t, r), r;
2087
- }, ke = (i, e) => (t, n) => e(t, n, i), ve;
2088
- let It = (ve = class extends qt {
2089
- constructor(i, e, t, n) {
2090
- super(), this._config = i, this._injector = e, this._localeService = t, this._logService = n, this._config = Je.deepMerge({}, ei, this._config), this._initDependencies(e), this._initializeCommands();
1928
+ Ge = Br([
1929
+ ue(0, O(fn)),
1930
+ ue(1, Te),
1931
+ ue(2, P),
1932
+ ue(3, S)
1933
+ ], Ge);
1934
+ var Vr = Object.defineProperty, jr = Object.getOwnPropertyDescriptor, Wr = (t, e, n, i) => {
1935
+ for (var r = i > 1 ? void 0 : i ? jr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1936
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1937
+ return i && r && Vr(e, n, r), r;
1938
+ }, Ot = (t, e) => (n, i) => e(n, i, t);
1939
+ let ge = class extends re {
1940
+ constructor(t, e) {
1941
+ super(), this._instanceSrv = t, this._renderManagerService = e, this._init();
1942
+ }
1943
+ _init() {
1944
+ this._renderManagerService.createRender$.pipe(H(this.dispose$)).subscribe((t) => this._createRenderWithId(t)), this._instanceSrv.getTypeOfUnitAdded$(g.UNIVER_DOC).pipe(H(this.dispose$)).subscribe((t) => this._createRenderer(t)), this._instanceSrv.getAllUnitsForType(g.UNIVER_DOC).forEach((t) => this._createRenderer(t)), this._instanceSrv.getTypeOfUnitDisposed$(g.UNIVER_DOC).pipe(H(this.dispose$)).subscribe((t) => this._disposeRenderer(t));
1945
+ }
1946
+ _createRenderer(t) {
1947
+ const e = t.getUnitId();
1948
+ this._renderManagerService.has(e) || (this._createRenderWithId(e), this._renderManagerService.setCurrent(e));
1949
+ }
1950
+ _createRenderWithId(t) {
1951
+ this._renderManagerService.createRender(t);
1952
+ }
1953
+ _disposeRenderer(t) {
1954
+ const e = t.getUnitId();
1955
+ this._renderManagerService.removeRender(e);
1956
+ }
1957
+ };
1958
+ ge = Wr([
1959
+ Ce(Oe.Ready, ge),
1960
+ Ot(0, P),
1961
+ Ot(1, Te)
1962
+ ], ge);
1963
+ var zr = Object.defineProperty, Hr = Object.getOwnPropertyDescriptor, kr = (t, e, n, i) => {
1964
+ for (var r = i > 1 ? void 0 : i ? Hr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
1965
+ (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
1966
+ return i && r && zr(e, n, r), r;
1967
+ }, we = (t, e) => (n, i) => e(n, i, t), he;
1968
+ let Rt = (he = class extends Zt {
1969
+ constructor(t, e, n, i) {
1970
+ super(), this._config = t, this._injector = e, this._renderManagerSrv = n, this._logService = i, this._config = Ke.deepMerge({}, Jn, this._config), this._initDependencies(e), this._initializeCommands();
1971
+ }
1972
+ onReady() {
1973
+ this._initRenderBasics();
2091
1974
  }
2092
1975
  onRendered() {
2093
- this._initModules(), this._markDocAsFocused();
1976
+ this._initUI(), this._initRenderModules(), this._markDocAsFocused();
2094
1977
  }
2095
1978
  _initializeCommands() {
2096
1979
  [
2097
- ii,
1980
+ ti,
1981
+ ni,
2098
1982
  ri,
2099
- si,
1983
+ ii,
2100
1984
  oi,
1985
+ si,
2101
1986
  ai,
2102
1987
  ci,
2103
1988
  li,
2104
- di,
2105
- ui,
2106
- Ki,
2107
- Zi,
2108
- Xi
2109
- ].forEach((i) => {
2110
- this._injector.get(Sn).registerShortcut(i);
1989
+ Gi,
1990
+ Xi,
1991
+ Yi
1992
+ ].forEach((t) => {
1993
+ this._injector.get(mn).registerShortcut(t);
2111
1994
  });
2112
1995
  }
2113
- _initDependencies(i) {
1996
+ _initDependencies(t) {
2114
1997
  [
2115
- // Controller
2116
- [
2117
- ce,
2118
- {
2119
- useFactory: () => this._injector.createInstance(ce, this._config)
2120
- }
2121
- ],
2122
- [Ce],
2123
- [Oe],
2124
- [Re],
2125
- [Ie],
2126
- [be],
2127
- [Me],
2128
- [ye],
2129
- [
2130
- // controllers
2131
- ae,
2132
- {
2133
- useFactory: () => this._injector.createInstance(ae, this._config)
2134
- }
2135
- ],
2136
- [
2137
- pe,
2138
- {
2139
- useClass: Xe
2140
- }
2141
- ],
2142
- [Ke],
2143
- // Render views
2144
- [Te]
2145
- ].forEach((t) => {
2146
- i.add(t);
2147
- });
1998
+ [ie, { useFactory: () => this._injector.createInstance(ie, this._config) }],
1999
+ [pe],
2000
+ [_e],
2001
+ [ge],
2002
+ [ne, { useFactory: () => this._injector.createInstance(ne, this._config) }],
2003
+ [ae, { useClass: je }],
2004
+ [Ge]
2005
+ ].forEach((n) => t.add(n));
2148
2006
  }
2149
2007
  _markDocAsFocused() {
2150
- const i = this._injector.get(P), e = this._injector.get(L);
2008
+ const t = this._injector.get(P), e = this._injector.get(A);
2151
2009
  try {
2152
- const t = i.getCurrentUniverDocInstance();
2153
- if (!t) return;
2154
- const n = t.getUnitId();
2155
- e.isEditor(n) || i.focusUnit(t.getUnitId());
2156
- } catch (t) {
2157
- this._logService.warn(t);
2010
+ const n = t.getCurrentUnitForType(g.UNIVER_DOC);
2011
+ if (!n) return;
2012
+ const i = n.getUnitId();
2013
+ e.isEditor(i) || t.focusUnit(n.getUnitId());
2014
+ } catch (n) {
2015
+ this._logService.warn(n);
2158
2016
  }
2159
2017
  }
2160
- _initModules() {
2161
- this._injector.get(ae);
2018
+ _initUI() {
2019
+ this._injector.get(ne);
2020
+ }
2021
+ _initRenderBasics() {
2022
+ [
2023
+ V,
2024
+ We,
2025
+ He
2026
+ ].forEach((t) => {
2027
+ this._renderManagerSrv.registerRenderModule(g.UNIVER_DOC, t);
2028
+ });
2029
+ }
2030
+ _initRenderModules() {
2031
+ [
2032
+ Ye,
2033
+ ze,
2034
+ ke
2035
+ ].forEach((t) => {
2036
+ this._renderManagerSrv.registerRenderModule(g.UNIVER_DOC, t);
2037
+ });
2162
2038
  }
2163
- }, g(ve, "pluginName", ti), g(ve, "type", f.UNIVER_DOC), ve);
2164
- It = Gr([
2165
- ke(1, O(Pe)),
2166
- ke(2, O(qe)),
2167
- ke(3, Et)
2168
- ], It);
2169
- function ro(i) {
2039
+ }, v(he, "pluginName", Qn), v(he, "type", g.UNIVER_DOC), he);
2040
+ Rt = kr([
2041
+ we(1, O(Re)),
2042
+ we(2, Te),
2043
+ we(3, yt)
2044
+ ], Rt);
2045
+ function no(t) {
2170
2046
  return {
2171
- left: i.positionH.posOffset,
2172
- top: i.positionV.posOffset,
2173
- width: i.size.width,
2174
- height: i.size.height
2047
+ left: t.positionH.posOffset,
2048
+ top: t.positionV.posOffset,
2049
+ width: t.size.width,
2050
+ height: t.size.height
2175
2051
  };
2176
2052
  }
2177
- function oo(i, e = 0, t = 0) {
2053
+ function io(t, e = 0, n = 0) {
2178
2054
  return {
2179
2055
  size: {
2180
- width: i.width,
2181
- height: i.height
2056
+ width: t.width,
2057
+ height: t.height
2182
2058
  },
2183
2059
  positionH: {
2184
- relativeFrom: Jt.MARGIN,
2185
- posOffset: (i.left || 0) - e
2060
+ relativeFrom: qt.MARGIN,
2061
+ posOffset: (t.left || 0) - e
2186
2062
  },
2187
2063
  positionV: {
2188
- relativeFrom: Qt.PAGE,
2189
- posOffset: (i.top || 0) - t
2064
+ relativeFrom: Jt.PAGE,
2065
+ posOffset: (t.top || 0) - n
2190
2066
  },
2191
- angle: i.angle || 0
2067
+ angle: t.angle || 0
2192
2068
  };
2193
2069
  }
2194
2070
  export {
2195
- ti as DOC_UI_PLUGIN_NAME,
2196
- Qn as DefaultDocContainerConfig,
2197
- ei as DefaultDocUiConfig,
2198
- Jn as DefaultToolbarConfig,
2199
- Ke as DocCanvasPopManagerService,
2200
- Te as DocCanvasView,
2201
- rr as PastePluginLark,
2202
- cr as PastePluginUniver,
2203
- sr as PastePluginWord,
2204
- It as UniverDocsUIPlugin,
2205
- ro as docDrawingPositionToTransform,
2206
- oo as transformToDocDrawingPosition
2071
+ Qn as DOC_UI_PLUGIN_NAME,
2072
+ qn as DefaultDocContainerConfig,
2073
+ Jn as DefaultDocUiConfig,
2074
+ Zn as DefaultToolbarConfig,
2075
+ Ge as DocCanvasPopManagerService,
2076
+ We as DocRenderController,
2077
+ ge as DocsRenderService,
2078
+ nr as PastePluginLark,
2079
+ sr as PastePluginUniver,
2080
+ rr as PastePluginWord,
2081
+ Rt as UniverDocsUIPlugin,
2082
+ no as docDrawingPositionToTransform,
2083
+ io as transformToDocDrawingPosition
2207
2084
  };