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