@univerjs/docs-ui 0.1.1 → 0.1.3

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