@univerjs/docs-ui 0.1.0-beta.5 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,14 +1,16 @@
1
- var Le = Object.defineProperty;
2
- var Ne = (e, t, n) => t in e ? Le(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var h = (e, t, n) => (Ne(e, typeof t != "symbol" ? t + "" : t, n), n);
4
- import { FOCUSING_DOC as m, Direction as b, EDITOR_ACTIVATED as ge, LocaleService as ee, RxDisposable as Ce, ICommandService as _, BooleanNumber as u, UniverInstanceType as S, BaselineOffset as E, ThemeService as Ue, IUniverInstanceService as te, OnLifecycle as Se, LifecycleStages as Oe, Disposable as Te, Tools as ve, LRUMap as Fe, ColorKit as se, ILogService as Re, toDisposable as $e, CommandType as ne, IContextService as we, Plugin as Be, PluginType as je, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as He, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Ve } from "@univerjs/core";
5
- import { Inject as y, Injector as Y, Optional as We, createIdentifier as ze } from "@wendellhu/redi";
6
- import { KeyCode as g, MetaKeys as w, LayoutService as Ye, MenuGroup as O, MenuItemType as T, MenuPosition as v, getMenuHiddenObservable as R, FONT_FAMILY_LIST as ae, FONT_SIZE_LIST as ke, ComponentManager as Ge, FontFamily as Ke, FontFamilyItem as Ze, FontSize as Xe, IShortcutService as ye, IMenuService as qe, IUIController as Je, IClipboardInterfaceService as oe, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as Qe, HTML_CLIPBOARD_MIME_TYPE as et, CopyCommand as tt, CutCommand as nt, PasteCommand as ot } from "@univerjs/ui";
7
- import { MoveCursorOperation as k, MoveSelectionOperation as G, SelectAllOperation as rt, SetInlineFormatBoldCommand as it, SetTextSelectionsOperation as x, SetInlineFormatCommand as A, SetInlineFormatItalicCommand as st, SetInlineFormatUnderlineCommand as at, SetInlineFormatStrikethroughCommand as ct, SetInlineFormatSubscriptCommand as lt, SetInlineFormatSuperscriptCommand as dt, SetInlineFormatFontFamilyCommand as ce, SetInlineFormatFontSizeCommand as le, SetInlineFormatTextColorCommand as de, OrderListCommand as ut, BulletListCommand as pt, TextSelectionManagerService as Ie, BreakLineCommand as ht, DeleteLeftCommand as ft, DeleteRightCommand as mt, CutContentCommand as be, InnerPasteCommand as xe } from "@univerjs/docs";
8
- import { ITextSelectionRenderManager as De } from "@univerjs/engine-render";
9
- import { ColorPicker as _t } from "@univerjs/design";
10
- import { Observable as I, takeUntil as gt } from "rxjs";
11
- const Ct = {
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 = {
12
14
  undo: !0,
13
15
  redo: !0,
14
16
  // Undo redo
@@ -36,7 +38,7 @@ const Ct = {
36
38
  // 'Wrap mode'
37
39
  textRotateMode: !0
38
40
  // 'Text Rotation Mode'
39
- }, St = {
41
+ }, On = {
40
42
  outerLeft: !1,
41
43
  outerRight: !1,
42
44
  header: !0,
@@ -49,83 +51,87 @@ const Ct = {
49
51
  frozenContent: !1,
50
52
  infoBar: !0,
51
53
  toolbar: !0
52
- }, Ot = {
54
+ }, Rn = {
53
55
  layout: {
54
- docContainerConfig: St,
55
- toolbarConfig: Ct
56
+ docContainerConfig: On,
57
+ toolbarConfig: Cn
56
58
  }
57
- }, Tt = "DocUI", vt = {
58
- id: k.id,
59
- binding: g.ARROW_UP,
60
- preconditions: (e) => e.getContextValue(m),
59
+ }, Tn = "DocUI";
60
+ function D(i) {
61
+ return i.getContextValue(xe) && i.getContextValue(ot);
62
+ }
63
+ const bn = {
64
+ id: me.id,
65
+ binding: R.ARROW_UP,
66
+ preconditions: D,
61
67
  staticParameters: {
62
- direction: b.UP
68
+ direction: U.UP
63
69
  }
64
- }, Rt = {
65
- id: k.id,
66
- binding: g.ARROW_DOWN,
67
- preconditions: (e) => e.getContextValue(m),
70
+ }, In = {
71
+ id: me.id,
72
+ binding: R.ARROW_DOWN,
73
+ preconditions: D,
68
74
  staticParameters: {
69
- direction: b.DOWN
75
+ direction: U.DOWN
70
76
  }
71
- }, yt = {
72
- id: k.id,
73
- binding: g.ARROW_LEFT,
74
- preconditions: (e) => e.getContextValue(m),
77
+ }, yn = {
78
+ id: me.id,
79
+ binding: R.ARROW_LEFT,
80
+ preconditions: D,
75
81
  staticParameters: {
76
- direction: b.LEFT
82
+ direction: U.LEFT
77
83
  }
78
- }, It = {
79
- id: k.id,
80
- binding: g.ARROW_RIGHT,
81
- preconditions: (e) => e.getContextValue(m),
84
+ }, Mn = {
85
+ id: me.id,
86
+ binding: R.ARROW_RIGHT,
87
+ preconditions: D,
82
88
  staticParameters: {
83
- direction: b.RIGHT
89
+ direction: U.RIGHT
84
90
  }
85
- }, bt = {
86
- id: G.id,
87
- binding: g.ARROW_UP | w.SHIFT,
88
- preconditions: (e) => e.getContextValue(m),
91
+ }, En = {
92
+ id: Se.id,
93
+ binding: R.ARROW_UP | Q.SHIFT,
94
+ preconditions: D,
89
95
  staticParameters: {
90
- direction: b.UP
96
+ direction: U.UP
91
97
  }
92
- }, xt = {
93
- id: G.id,
94
- binding: g.ARROW_DOWN | w.SHIFT,
95
- preconditions: (e) => e.getContextValue(m),
98
+ }, Dn = {
99
+ id: Se.id,
100
+ binding: R.ARROW_DOWN | Q.SHIFT,
101
+ preconditions: D,
96
102
  staticParameters: {
97
- direction: b.DOWN
103
+ direction: U.DOWN
98
104
  }
99
- }, Dt = {
100
- id: G.id,
101
- binding: g.ARROW_LEFT | w.SHIFT,
102
- preconditions: (e) => e.getContextValue(m),
105
+ }, xn = {
106
+ id: Se.id,
107
+ binding: R.ARROW_LEFT | Q.SHIFT,
108
+ preconditions: D,
103
109
  staticParameters: {
104
- direction: b.LEFT
110
+ direction: U.LEFT
105
111
  }
106
- }, Pt = {
107
- id: G.id,
108
- binding: g.ARROW_RIGHT | w.SHIFT,
109
- preconditions: (e) => e.getContextValue(m),
112
+ }, Pn = {
113
+ id: Se.id,
114
+ binding: R.ARROW_RIGHT | Q.SHIFT,
115
+ preconditions: D,
110
116
  staticParameters: {
111
- direction: b.RIGHT
117
+ direction: U.RIGHT
112
118
  }
113
- }, Mt = {
114
- id: rt.id,
115
- binding: g.A | w.CTRL_COMMAND,
116
- preconditions: (e) => e.getContextValue(m) || e.getContextValue(ge)
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))
117
123
  };
118
- var Et = Object.defineProperty, At = Object.getOwnPropertyDescriptor, Lt = (e, t, n, o) => {
119
- for (var r = o > 1 ? void 0 : o ? At(t, n) : t, i = e.length - 1, s; i >= 0; i--)
120
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
121
- return o && r && Et(t, n, r), r;
122
- }, ue = (e, t) => (n, o) => t(n, o, e);
123
- let J = class {
124
- constructor(e, t, n) {
125
- h(this, "_docContainer");
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");
126
132
  // 获取SheetContainer组件
127
- h(this, "getComponent", (e) => {
128
- if (this._docContainer = e, !e.getContentRef().current)
133
+ m(this, "getComponent", (i) => {
134
+ if (this._docContainer = i, !i.getContentRef().current)
129
135
  throw new Error("container is not ready");
130
136
  });
131
137
  /**
@@ -135,10 +141,10 @@ let J = class {
135
141
  * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
136
142
  *
137
143
  */
138
- h(this, "changeLocale", (e) => {
139
- this._localeService.setLocale(e);
144
+ m(this, "changeLocale", (i) => {
145
+ this._localeService.setLocale(i);
140
146
  });
141
- this._config = e, this._localeService = t, this._injector = n;
147
+ this._config = i, this._localeService = e, this._injector = t;
142
148
  }
143
149
  getUIConfig() {
144
150
  return {
@@ -151,27 +157,27 @@ let J = class {
151
157
  getContentRef() {
152
158
  return this._docContainer.getContentRef();
153
159
  }
154
- UIDidMount(e) {
160
+ UIDidMount(i) {
155
161
  if (this._docContainer)
156
- return e(this._docContainer);
162
+ return i(this._docContainer);
157
163
  }
158
164
  getDocContainer() {
159
165
  return this._docContainer;
160
166
  }
161
167
  };
162
- J = Lt([
163
- ue(1, y(ee)),
164
- ue(2, y(Y))
165
- ], J);
166
- var Nt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, Ft = (e, t, n, o) => {
167
- for (var r = o > 1 ? void 0 : o ? Ut(t, n) : t, i = e.length - 1, s; i >= 0; i--)
168
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
169
- return o && r && Nt(t, n, r), r;
170
- }, H = (e, t) => (n, o) => t(n, o, e);
171
- let F = class extends Ce {
172
- constructor(t, n, o, r, i) {
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) {
173
179
  super();
174
- h(this, "_docContainerController");
180
+ m(this, "_docContainerController");
175
181
  /**
176
182
  * Change language
177
183
  * @param {string} locale new language
@@ -179,364 +185,401 @@ let F = class extends Ce {
179
185
  * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
180
186
  *
181
187
  */
182
- h(this, "changeLocale", (t) => {
183
- this._localeService.setLocale(t);
188
+ m(this, "changeLocale", (e) => {
189
+ this._localeService.setLocale(e);
184
190
  });
185
- this._localeService = n, this._injector = o, this._textSelectionRenderManager = r, this._layoutService = i, this._docContainerController = this._injector.createInstance(J, t), this._registerContainer();
191
+ this._localeService = t, this._injector = n, this._textSelectionRenderManager = r, this._layoutService = s, this._docContainerController = this._injector.createInstance(Ee, e), this._registerContainer();
186
192
  }
187
193
  _registerContainer() {
188
194
  this._layoutService && this.disposeWithMe(
189
195
  // the content editable div should be regarded as part of the applications container
190
- this._layoutService.registerContainer(this._textSelectionRenderManager.__getEditorContainer())
196
+ this._layoutService.registerContainerElement(this._textSelectionRenderManager.__getEditorContainer())
191
197
  );
192
198
  }
193
199
  getDocContainerController() {
194
200
  return this._docContainerController;
195
201
  }
196
202
  };
197
- F = Ft([
198
- H(1, y(ee)),
199
- H(2, y(Y)),
200
- H(3, De),
201
- H(4, We(Ye))
202
- ], F);
203
- const K = "UI_PLUGIN_DOCS", Pe = `${K}_COLOR_PICKER_COMPONENT`, Me = `${K}_FONT_FAMILY_COMPONENT`, Ee = `${K}_FONT_FAMILY_ITEM_COMPONENT`, Ae = `${K}_FONT_SIZE_COMPONENT`;
204
- function $t(e) {
205
- const t = e.get(_);
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 = {};
211
+ /**
212
+ * @license React
213
+ * react-jsx-runtime.production.min.js
214
+ *
215
+ * Copyright (c) Facebook, Inc. and its affiliates.
216
+ *
217
+ * This source code is licensed under the MIT license found in the
218
+ * LICENSE file in the root directory of this source tree.
219
+ */
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
+ t !== void 0 && (s = "" + t), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (o = e.ref);
224
+ 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 };
230
+ }
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);
206
241
  return {
207
- id: it.id,
208
- group: O.TOOLBAR_FORMAT,
209
- type: T.BUTTON,
242
+ id: Gt.id,
243
+ group: I.TOOLBAR_FORMAT,
244
+ type: y.BUTTON,
210
245
  icon: "BoldSingle",
211
246
  title: "Set bold",
212
247
  tooltip: "toolbar.bold",
213
- positions: [v.TOOLBAR_START],
214
- activated$: new I((n) => {
215
- const o = t.onCommandExecuted((r) => {
216
- var s;
217
- const i = r.id;
218
- if (i === x.id || i === A.id) {
219
- const a = D(e);
248
+ positions: [M.TOOLBAR_START],
249
+ activated$: new L((t) => {
250
+ const n = e.onCommandExecuted((r) => {
251
+ var o;
252
+ const s = r.id;
253
+ if (s === $.id || s === H.id) {
254
+ const a = w(i);
220
255
  if (a == null)
221
256
  return;
222
- const c = (s = a.ts) == null ? void 0 : s.bl;
223
- n.next(c === u.TRUE);
257
+ const c = (o = a.ts) == null ? void 0 : o.bl;
258
+ t.next(c === S.TRUE);
224
259
  }
225
260
  });
226
- return n.next(!1), o.dispose;
261
+ return t.next(!1), n.dispose;
227
262
  }),
228
- hidden$: R(e, S.DOC)
263
+ hidden$: E(i, b.DOC)
229
264
  };
230
265
  }
231
- function wt(e) {
232
- const t = e.get(_);
266
+ function qn(i) {
267
+ const e = i.get(C);
233
268
  return {
234
- id: st.id,
235
- group: O.TOOLBAR_FORMAT,
236
- type: T.BUTTON,
269
+ id: Zt.id,
270
+ group: I.TOOLBAR_FORMAT,
271
+ type: y.BUTTON,
237
272
  icon: "ItalicSingle",
238
273
  title: "Set italic",
239
274
  tooltip: "toolbar.italic",
240
- positions: [v.TOOLBAR_START],
241
- activated$: new I((n) => {
242
- const o = t.onCommandExecuted((r) => {
243
- var s;
244
- const i = r.id;
245
- if (i === x.id || i === A.id) {
246
- const a = D(e);
275
+ positions: [M.TOOLBAR_START],
276
+ activated$: new L((t) => {
277
+ const n = e.onCommandExecuted((r) => {
278
+ var o;
279
+ const s = r.id;
280
+ if (s === $.id || s === H.id) {
281
+ const a = w(i);
247
282
  if (a == null)
248
283
  return;
249
- const c = (s = a.ts) == null ? void 0 : s.it;
250
- n.next(c === u.TRUE);
284
+ const c = (o = a.ts) == null ? void 0 : o.it;
285
+ t.next(c === S.TRUE);
251
286
  }
252
287
  });
253
- return n.next(!1), o.dispose;
288
+ return t.next(!1), n.dispose;
254
289
  }),
255
- hidden$: R(e, S.DOC)
290
+ hidden$: E(i, b.DOC)
256
291
  };
257
292
  }
258
- function Bt(e) {
259
- const t = e.get(_);
293
+ function Kn(i) {
294
+ const e = i.get(C);
260
295
  return {
261
- id: at.id,
262
- group: O.TOOLBAR_FORMAT,
263
- type: T.BUTTON,
296
+ id: qt.id,
297
+ group: I.TOOLBAR_FORMAT,
298
+ type: y.BUTTON,
264
299
  icon: "UnderlineSingle",
265
300
  title: "Set underline",
266
301
  tooltip: "toolbar.underline",
267
- positions: [v.TOOLBAR_START],
268
- activated$: new I((n) => {
269
- const o = t.onCommandExecuted((r) => {
270
- var s;
271
- const i = r.id;
272
- if (i === x.id || i === A.id) {
273
- const a = D(e);
302
+ positions: [M.TOOLBAR_START],
303
+ activated$: new L((t) => {
304
+ const n = e.onCommandExecuted((r) => {
305
+ var o;
306
+ const s = r.id;
307
+ if (s === $.id || s === H.id) {
308
+ const a = w(i);
274
309
  if (a == null)
275
310
  return;
276
- const c = (s = a.ts) == null ? void 0 : s.ul;
277
- n.next((c == null ? void 0 : c.s) === u.TRUE);
311
+ const c = (o = a.ts) == null ? void 0 : o.ul;
312
+ t.next((c == null ? void 0 : c.s) === S.TRUE);
278
313
  }
279
314
  });
280
- return n.next(!1), o.dispose;
315
+ return t.next(!1), n.dispose;
281
316
  }),
282
- hidden$: R(e, S.DOC)
317
+ hidden$: E(i, b.DOC)
283
318
  };
284
319
  }
285
- function jt(e) {
286
- const t = e.get(_);
320
+ function Jn(i) {
321
+ const e = i.get(C);
287
322
  return {
288
- id: ct.id,
289
- group: O.TOOLBAR_FORMAT,
290
- type: T.BUTTON,
323
+ id: Kt.id,
324
+ group: I.TOOLBAR_FORMAT,
325
+ type: y.BUTTON,
291
326
  icon: "StrikethroughSingle",
292
327
  title: "Set strike through",
293
328
  tooltip: "toolbar.strikethrough",
294
- positions: [v.TOOLBAR_START],
295
- activated$: new I((n) => {
296
- const o = t.onCommandExecuted((r) => {
297
- var s;
298
- const i = r.id;
299
- if (i === x.id || i === A.id) {
300
- const a = D(e);
329
+ positions: [M.TOOLBAR_START],
330
+ activated$: new L((t) => {
331
+ const n = e.onCommandExecuted((r) => {
332
+ var o;
333
+ const s = r.id;
334
+ if (s === $.id || s === H.id) {
335
+ const a = w(i);
301
336
  if (a == null)
302
337
  return;
303
- const c = (s = a.ts) == null ? void 0 : s.st;
304
- n.next((c == null ? void 0 : c.s) === u.TRUE);
338
+ const c = (o = a.ts) == null ? void 0 : o.st;
339
+ t.next((c == null ? void 0 : c.s) === S.TRUE);
305
340
  }
306
341
  });
307
- return n.next(!1), o.dispose;
342
+ return t.next(!1), n.dispose;
308
343
  }),
309
- hidden$: R(e, S.DOC)
344
+ hidden$: E(i, b.DOC)
310
345
  };
311
346
  }
312
- function Ht(e) {
313
- const t = e.get(_);
347
+ function Qn(i) {
348
+ const e = i.get(C);
314
349
  return {
315
- id: lt.id,
316
- group: O.TOOLBAR_FORMAT,
317
- type: T.BUTTON,
350
+ id: Jt.id,
351
+ group: I.TOOLBAR_FORMAT,
352
+ type: y.BUTTON,
318
353
  icon: "SubscriptSingle",
319
354
  tooltip: "toolbar.subscript",
320
- positions: [v.TOOLBAR_START],
321
- activated$: new I((n) => {
322
- const o = t.onCommandExecuted((r) => {
323
- var s;
324
- const i = r.id;
325
- if (i === x.id || i === A.id) {
326
- const a = D(e);
355
+ positions: [M.TOOLBAR_START],
356
+ activated$: new L((t) => {
357
+ const n = e.onCommandExecuted((r) => {
358
+ var o;
359
+ const s = r.id;
360
+ if (s === $.id || s === H.id) {
361
+ const a = w(i);
327
362
  if (a == null)
328
363
  return;
329
- const c = (s = a.ts) == null ? void 0 : s.va;
330
- n.next(c === E.SUBSCRIPT);
364
+ const c = (o = a.ts) == null ? void 0 : o.va;
365
+ t.next(c === W.SUBSCRIPT);
331
366
  }
332
367
  });
333
- return n.next(!1), o.dispose;
368
+ return t.next(!1), n.dispose;
334
369
  }),
335
- hidden$: R(e, S.DOC)
370
+ hidden$: E(i, b.DOC)
336
371
  };
337
372
  }
338
- function Vt(e) {
339
- const t = e.get(_);
373
+ function er(i) {
374
+ const e = i.get(C);
340
375
  return {
341
- id: dt.id,
342
- group: O.TOOLBAR_FORMAT,
343
- type: T.BUTTON,
376
+ id: Qt.id,
377
+ group: I.TOOLBAR_FORMAT,
378
+ type: y.BUTTON,
344
379
  icon: "SuperscriptSingle",
345
380
  tooltip: "toolbar.superscript",
346
- positions: [v.TOOLBAR_START],
347
- activated$: new I((n) => {
348
- const o = t.onCommandExecuted((r) => {
349
- var s;
350
- const i = r.id;
351
- if (i === x.id || i === A.id) {
352
- const a = D(e);
381
+ positions: [M.TOOLBAR_START],
382
+ activated$: new L((t) => {
383
+ const n = e.onCommandExecuted((r) => {
384
+ var o;
385
+ const s = r.id;
386
+ if (s === $.id || s === H.id) {
387
+ const a = w(i);
353
388
  if (a == null)
354
389
  return;
355
- const c = (s = a.ts) == null ? void 0 : s.va;
356
- n.next(c === E.SUPERSCRIPT);
390
+ const c = (o = a.ts) == null ? void 0 : o.va;
391
+ t.next(c === W.SUPERSCRIPT);
357
392
  }
358
393
  });
359
- return n.next(!1), o.dispose;
394
+ return t.next(!1), n.dispose;
360
395
  }),
361
- hidden$: R(e, S.DOC)
396
+ hidden$: E(i, b.DOC)
362
397
  };
363
398
  }
364
- function Wt(e) {
365
- const t = e.get(_);
399
+ function tr(i) {
400
+ const e = i.get(C);
366
401
  return {
367
- id: ce.id,
402
+ id: Ye.id,
368
403
  tooltip: "toolbar.font",
369
- group: O.TOOLBAR_FORMAT,
370
- type: T.SELECTOR,
371
- label: Me,
372
- positions: [v.TOOLBAR_START],
373
- selections: ae.map((n) => ({
404
+ group: I.TOOLBAR_FORMAT,
405
+ type: y.SELECTOR,
406
+ label: _t,
407
+ positions: [M.TOOLBAR_START],
408
+ selections: ke.map((t) => ({
374
409
  label: {
375
- name: Ee,
410
+ name: pt,
376
411
  hoverable: !0
377
412
  },
378
- value: n.value
413
+ value: t.value
379
414
  })),
380
415
  // disabled$: getCurrentSheetDisabled$(accessor),
381
- value$: new I((n) => {
382
- const o = ae[0].value, r = t.onCommandExecuted((i) => {
416
+ value$: new L((t) => {
417
+ const n = ke[0].value, r = e.onCommandExecuted((s) => {
383
418
  var a;
384
- const s = i.id;
385
- if (s === x.id || s === ce.id) {
386
- const c = D(e);
419
+ const o = s.id;
420
+ if (o === $.id || o === Ye.id) {
421
+ const c = w(i);
387
422
  if (c == null)
388
423
  return;
389
- const l = (a = c.ts) == null ? void 0 : a.ff;
390
- n.next(l != null ? l : o);
424
+ const d = (a = c.ts) == null ? void 0 : a.ff;
425
+ t.next(d != null ? d : n);
391
426
  }
392
427
  });
393
- return n.next(o), r.dispose;
428
+ return t.next(n), r.dispose;
394
429
  }),
395
- hidden$: R(e, S.DOC)
430
+ hidden$: E(i, b.DOC)
396
431
  };
397
432
  }
398
- function zt(e) {
399
- const t = e.get(_);
433
+ function nr(i) {
434
+ const e = i.get(C);
400
435
  return {
401
- id: le.id,
402
- group: O.TOOLBAR_FORMAT,
403
- type: T.SELECTOR,
436
+ id: Xe.id,
437
+ group: I.TOOLBAR_FORMAT,
438
+ type: y.SELECTOR,
404
439
  tooltip: "toolbar.fontSize",
405
440
  label: {
406
- name: Ae,
441
+ name: gt,
407
442
  props: {
408
443
  min: 1,
409
444
  max: 400
410
445
  // disabled$,
411
446
  }
412
447
  },
413
- positions: [v.TOOLBAR_START],
414
- selections: ke,
448
+ positions: [M.TOOLBAR_START],
449
+ selections: Ut,
415
450
  // disabled$,
416
- value$: new I((n) => {
417
- const r = t.onCommandExecuted((i) => {
451
+ value$: new L((t) => {
452
+ const r = e.onCommandExecuted((s) => {
418
453
  var a;
419
- const s = i.id;
420
- if (s === x.id || s === le.id) {
421
- const c = D(e);
454
+ const o = s.id;
455
+ if (o === $.id || o === Xe.id) {
456
+ const c = w(i);
422
457
  if (c == null)
423
458
  return;
424
- const l = (a = c.ts) == null ? void 0 : a.fs;
425
- n.next(l != null ? l : 14);
459
+ const d = (a = c.ts) == null ? void 0 : a.fs;
460
+ t.next(d != null ? d : 14);
426
461
  }
427
462
  });
428
- return n.next(14), r.dispose;
463
+ return t.next(14), r.dispose;
429
464
  }),
430
- hidden$: R(e, S.DOC)
465
+ hidden$: E(i, b.DOC)
431
466
  };
432
467
  }
433
- function Yt(e) {
434
- const t = e.get(_), n = e.get(Ue);
468
+ function rr(i) {
469
+ const e = i.get(C), t = i.get(Rt);
435
470
  return {
436
- id: de.id,
471
+ id: Ge.id,
437
472
  icon: "FontColor",
438
473
  tooltip: "toolbar.textColor.main",
439
- group: O.TOOLBAR_FORMAT,
440
- type: T.BUTTON_SELECTOR,
441
- positions: [v.TOOLBAR_START],
474
+ group: I.TOOLBAR_FORMAT,
475
+ type: y.BUTTON_SELECTOR,
476
+ positions: [M.TOOLBAR_START],
442
477
  selections: [
443
478
  {
444
479
  label: {
445
- name: Pe,
480
+ name: ht,
446
481
  hoverable: !1
447
482
  }
448
483
  }
449
484
  ],
450
- value$: new I((o) => {
451
- const r = n.getCurrentTheme().textColor, i = t.onCommandExecuted((s) => {
452
- if (s.id === de.id) {
453
- const a = s.params.value;
454
- o.next(a != null ? a : r);
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);
455
490
  }
456
491
  });
457
- return o.next(r), i.dispose;
492
+ return n.next(r), s.dispose;
458
493
  }),
459
- hidden$: R(e, S.DOC)
494
+ hidden$: E(i, b.DOC)
460
495
  // disabled$: getCurrentSheetDisabled$(accessor),
461
496
  };
462
497
  }
463
- function kt(e) {
498
+ function ir(i) {
464
499
  return {
465
- id: ut.id,
466
- group: O.TOOLBAR_LAYOUT,
467
- type: T.BUTTON,
500
+ id: en.id,
501
+ group: I.TOOLBAR_LAYOUT,
502
+ type: y.BUTTON,
468
503
  icon: "OrderSingle",
469
504
  tooltip: "toolbar.order",
470
- positions: [v.TOOLBAR_START],
471
- hidden$: R(e, S.DOC)
505
+ positions: [M.TOOLBAR_START],
506
+ hidden$: E(i, b.DOC)
472
507
  };
473
508
  }
474
- function Gt(e) {
509
+ function or(i) {
475
510
  return {
476
- id: pt.id,
477
- group: O.TOOLBAR_LAYOUT,
478
- type: T.BUTTON,
511
+ id: tn.id,
512
+ group: I.TOOLBAR_LAYOUT,
513
+ type: y.BUTTON,
479
514
  icon: "UnorderSingle",
480
515
  tooltip: "toolbar.unorder",
481
- positions: [v.TOOLBAR_START],
482
- hidden$: R(e, S.DOC)
516
+ positions: [M.TOOLBAR_START],
517
+ hidden$: E(i, b.DOC)
483
518
  };
484
519
  }
485
- function D(e) {
520
+ function w(i) {
486
521
  var c;
487
- const t = e.get(te), n = e.get(Ie), o = t.getCurrentUniverDocInstance(), r = n.getActiveRange();
488
- if (o == null || r == null)
522
+ const e = i.get(P), t = i.get(Ne), n = e.getCurrentUniverDocInstance(), r = t.getActiveRange();
523
+ if (n == null || r == null)
489
524
  return;
490
- const i = (c = o.getBody()) == null ? void 0 : c.textRuns;
491
- if (i == null)
525
+ const s = (c = n.getBody()) == null ? void 0 : c.textRuns;
526
+ if (s == null)
492
527
  return;
493
- const { startOffset: s } = r;
494
- return i.find(({ st: l, ed: p }) => s >= l && s < p);
528
+ const { startOffset: o } = r;
529
+ return s.find(({ st: d, ed: u }) => o >= d && o < u);
495
530
  }
496
- var Kt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Xt = (e, t, n, o) => {
497
- for (var r = o > 1 ? void 0 : o ? Zt(t, n) : t, i = e.length - 1, s; i >= 0; i--)
498
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
499
- return o && r && Kt(t, n, r), r;
500
- }, M = (e, t) => (n, o) => t(n, o, e);
501
- let V = class extends Te {
502
- constructor(e, t, n, o, r, i) {
503
- super(), this._injector = e, this._componentManager = t, this._commandService = n, this._shortcutService = o, this._menuService = r, this._uiController = i, this._init();
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();
504
539
  }
505
540
  _initCustomComponents() {
506
- const e = this._componentManager;
507
- this.disposeWithMe(e.register(Pe, _t)), this.disposeWithMe(e.register(Me, Ke)), this.disposeWithMe(e.register(Ee, Ze)), this.disposeWithMe(e.register(Ae, Xe));
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));
508
543
  }
509
544
  _initMenus() {
510
545
  [
511
- $t,
512
- wt,
513
- Bt,
514
- jt,
515
- Ht,
516
- Vt,
517
- zt,
518
- Wt,
519
- Yt,
520
- kt,
521
- Gt
522
- ].forEach((e) => {
523
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)));
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)));
524
559
  });
525
560
  }
526
561
  _init() {
527
- this._initCustomComponents(), this._initMenus();
562
+ this._initCustomComponents(), this._initMenus(), this._initDocBackground();
563
+ }
564
+ _initDocBackground() {
565
+ const i = this._currentUniverService.getAllUniverDocsInstance()[0].getUnitId();
566
+ if (i == null)
567
+ return;
568
+ this._editorService.isEditor(i) || this.disposeWithMe(
569
+ this._uiController.registerContentComponent(() => fn(Gn, this._injector))
570
+ );
528
571
  }
529
572
  };
530
- V = Xt([
531
- Se(Oe.Rendered, V),
532
- M(0, y(Y)),
533
- M(1, y(Ge)),
534
- M(2, _),
535
- M(3, ye),
536
- M(4, qe),
537
- M(5, Je)
538
- ], V);
539
- const Nn = {
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 = {
540
583
  toolbar: {
541
584
  undo: "Undo",
542
585
  redo: "Redo",
@@ -547,6 +590,7 @@ const Nn = {
547
590
  strikethrough: "Strikethrough",
548
591
  subscript: "Subscript",
549
592
  superscript: "Superscript",
593
+ underline: "Underline",
550
594
  textColor: {
551
595
  main: "Text color",
552
596
  right: "Choose color"
@@ -555,7 +599,7 @@ const Nn = {
555
599
  order: "Ordered list",
556
600
  unorder: "Unordered list"
557
601
  }
558
- }, qt = {
602
+ }, lr = {
559
603
  toolbar: {
560
604
  undo: "撤销",
561
605
  redo: "重做",
@@ -575,375 +619,372 @@ const Nn = {
575
619
  order: "有序列表",
576
620
  unorder: "无序列表"
577
621
  }
578
- }, Jt = {
579
- id: ht.id,
580
- preconditions: (e) => e.getContextValue(m),
581
- binding: g.ENTER
582
- }, Qt = {
583
- id: ft.id,
584
- preconditions: (e) => e.getContextValue(m),
585
- binding: g.BACKSPACE
586
- }, en = {
587
- id: mt.id,
588
- preconditions: (e) => e.getContextValue(m),
589
- binding: g.DELETE
590
- }, tn = 10, nn = 6;
591
- function on() {
592
- return ve.generateRandomId(nn);
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);
593
637
  }
594
- function rn(e) {
595
- const t = e.match(/data-copy-id="([^\s]+)"/);
596
- return t && t[1] ? t[1] : null;
638
+ function fr(i) {
639
+ const e = i.match(/data-copy-id="([^\s]+)"/);
640
+ return e && e[1] ? e[1] : null;
597
641
  }
598
- class sn {
642
+ class mr {
599
643
  constructor() {
600
- h(this, "_cache", new Fe(tn));
644
+ m(this, "_cache", new Tt(_r));
601
645
  }
602
- set(t, n) {
603
- this._cache.set(t, n);
646
+ set(e, t) {
647
+ this._cache.set(e, t);
604
648
  }
605
- get(t) {
606
- return this._cache.get(t);
649
+ get(e) {
650
+ return this._cache.get(e);
607
651
  }
608
652
  clear() {
609
653
  this._cache.clear();
610
654
  }
611
655
  }
612
- const pe = new sn();
613
- function re(e) {
614
- const t = e.style, n = {}, o = e.tagName.toLowerCase();
615
- switch (o) {
656
+ const tt = new mr();
657
+ function Fe(i) {
658
+ const e = i.style, t = {}, n = i.tagName.toLowerCase();
659
+ switch (n) {
616
660
  case "b":
617
661
  case "em":
618
662
  case "strong": {
619
- n.bl = u.TRUE;
663
+ t.bl = S.TRUE;
620
664
  break;
621
665
  }
622
666
  case "s": {
623
- n.st = {
624
- s: u.TRUE
667
+ t.st = {
668
+ s: S.TRUE
625
669
  };
626
670
  break;
627
671
  }
628
672
  case "u": {
629
- n.ul = {
630
- s: u.TRUE
673
+ t.ul = {
674
+ s: S.TRUE
631
675
  };
632
676
  break;
633
677
  }
634
678
  case "i": {
635
- n.it = u.TRUE;
679
+ t.it = S.TRUE;
636
680
  break;
637
681
  }
638
682
  case "sub":
639
683
  case "sup": {
640
- n.va = o === "sup" ? E.SUPERSCRIPT : E.SUBSCRIPT;
684
+ t.va = n === "sup" ? W.SUPERSCRIPT : W.SUBSCRIPT;
641
685
  break;
642
686
  }
643
687
  }
644
- for (let r = 0; r < t.length; r++) {
645
- const i = t[r], s = t.getPropertyValue(i);
646
- switch (i) {
688
+ for (let r = 0; r < e.length; r++) {
689
+ const s = e[r], o = e.getPropertyValue(s);
690
+ switch (s) {
647
691
  case "font-family": {
648
- n.ff = s;
692
+ t.ff = o;
649
693
  break;
650
694
  }
651
695
  case "font-size": {
652
- const a = Number.parseInt(s);
653
- Number.isNaN(a) || s.endsWith("pt") && (n.fs = a);
696
+ const a = Number.parseInt(o);
697
+ Number.isNaN(a) || o.endsWith("pt") && (t.fs = a);
654
698
  break;
655
699
  }
656
700
  case "font-style": {
657
- s === "italic" && (n.it = u.TRUE);
701
+ o === "italic" && (t.it = S.TRUE);
658
702
  break;
659
703
  }
660
704
  case "font-weight": {
661
- Number(s) > 400 && (n.bl = u.TRUE);
705
+ Number(o) > 400 && (t.bl = S.TRUE);
662
706
  break;
663
707
  }
664
708
  case "text-decoration": {
665
- /underline/.test(s) ? n.ul = {
666
- s: u.TRUE
667
- } : /overline/.test(s) ? n.ol = {
668
- s: u.TRUE
669
- } : /line-through/.test(s) && (n.st = {
670
- s: u.TRUE
709
+ /underline/.test(o) ? t.ul = {
710
+ s: S.TRUE
711
+ } : /overline/.test(o) ? t.ol = {
712
+ s: S.TRUE
713
+ } : /line-through/.test(o) && (t.st = {
714
+ s: S.TRUE
671
715
  });
672
716
  break;
673
717
  }
674
718
  case "color": {
675
- const a = new se(s);
676
- a.isValid && (n.cl = {
719
+ const a = new He(o);
720
+ a.isValid && (t.cl = {
677
721
  rgb: a.toRgbString()
678
722
  });
679
723
  break;
680
724
  }
681
725
  case "background-color": {
682
- const a = new se(s);
683
- a.isValid && (n.bg = {
726
+ const a = new He(o);
727
+ a.isValid && (t.bg = {
684
728
  rgb: a.toRgbString()
685
729
  });
686
730
  break;
687
731
  }
688
732
  }
689
733
  }
690
- return n;
734
+ return t;
691
735
  }
692
- function an(e) {
693
- const t = new DOMParser(), n = `<x-univer id="univer-root">${e}</x-univer>`;
694
- return t.parseFromString(n, "text/html").querySelector("#univer-root");
736
+ function Sr(i) {
737
+ const e = new DOMParser(), t = `<x-univer id="univer-root">${i}</x-univer>`;
738
+ return e.parseFromString(t, "text/html").querySelector("#univer-root");
695
739
  }
696
- function he(e, t) {
697
- const n = e.tagName.toLowerCase();
698
- return typeof t == "string" ? n === t : Array.isArray(t) ? t.some((o) => o === n) : t(e);
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);
699
743
  }
700
- const z = class z {
744
+ const pe = class pe {
701
745
  constructor() {
702
- h(this, "_styleCache", /* @__PURE__ */ new Map());
703
- h(this, "_styleRules", []);
704
- h(this, "_afterProcessRules", []);
746
+ m(this, "_styleCache", /* @__PURE__ */ new Map());
747
+ m(this, "_styleRules", []);
748
+ m(this, "_afterProcessRules", []);
705
749
  }
706
- static use(t) {
707
- if (this._pluginList.includes(t))
708
- throw new Error(`Univer paste plugin ${t.name} already added`);
709
- this._pluginList.push(t);
750
+ static use(e) {
751
+ if (this._pluginList.includes(e))
752
+ throw new Error(`Univer paste plugin ${e.name} already added`);
753
+ this._pluginList.push(e);
710
754
  }
711
- convert(t) {
712
- const n = z._pluginList.find((i) => i.checkPasteType(t)), o = an(t), r = {
755
+ convert(e) {
756
+ const t = pe._pluginList.find((s) => s.checkPasteType(e)), n = Sr(e), r = {
713
757
  dataStream: "",
714
758
  textRuns: []
715
759
  };
716
- return n && (this._styleRules = [...n.stylesRules], this._afterProcessRules = [...n.afterProcessRules]), this._styleCache.clear(), this._process(null, o == null ? void 0 : o.childNodes, r), this._styleCache.clear(), this._styleRules = [], this._afterProcessRules = [], r;
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;
717
761
  }
718
- _process(t, n, o) {
762
+ _process(e, t, n) {
719
763
  var r;
720
- for (const i of n)
721
- if (i.nodeType === Node.TEXT_NODE) {
722
- const s = (r = i.nodeValue) == null ? void 0 : r.replace(/[\r\n]/g, "");
764
+ for (const s of t)
765
+ if (s.nodeType === Node.TEXT_NODE) {
766
+ const o = (r = s.nodeValue) == null ? void 0 : r.replace(/[\r\n]/g, "");
723
767
  let a;
724
- t && this._styleCache.has(t) && (a = this._styleCache.get(t)), o.dataStream += s, a && Object.getOwnPropertyNames(a).length && o.textRuns.push({
725
- st: o.dataStream.length - s.length,
726
- ed: o.dataStream.length,
768
+ e && this._styleCache.has(e) && (a = this._styleCache.get(e)), n.dataStream += o, a && Object.getOwnPropertyNames(a).length && n.textRuns.push({
769
+ st: n.dataStream.length - o.length,
770
+ ed: n.dataStream.length,
727
771
  ts: a
728
772
  });
729
- } else if (i.nodeType === Node.ELEMENT_NODE) {
730
- const s = t ? this._styleCache.get(t) : {}, a = this._styleRules.find(({ filter: C }) => he(i, C)), c = a ? a.getStyle(i) : re(i);
731
- this._styleCache.set(i, { ...s, ...c });
732
- const { childNodes: l } = i;
733
- this._process(i, l, o);
734
- const p = this._afterProcessRules.find(
735
- ({ filter: C }) => he(i, C)
773
+ } 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 });
776
+ const { childNodes: d } = s;
777
+ this._process(s, d, n);
778
+ const u = this._afterProcessRules.find(
779
+ ({ filter: h }) => nt(s, h)
736
780
  );
737
- p && p.handler(o, i);
781
+ u && u.handler(n, s);
738
782
  }
739
783
  }
740
784
  };
741
- h(z, "_pluginList", []);
742
- let $ = z;
743
- const cn = {
785
+ m(pe, "_pluginList", []);
786
+ let J = pe;
787
+ const vr = {
744
788
  name: "univer-doc-paste-plugin-lark",
745
- checkPasteType(e) {
746
- return /lark-record-clipboard/i.test(e);
789
+ checkPasteType(i) {
790
+ return /lark-record-clipboard/i.test(i);
747
791
  },
748
792
  // TODO: @JOCS, support inline code copy from lark.
749
793
  stylesRules: [
750
794
  {
751
795
  filter: ["s"],
752
- getStyle(e) {
753
- const t = re(e);
796
+ getStyle(i) {
797
+ const e = Fe(i);
754
798
  return {
755
799
  st: {
756
- s: u.TRUE
800
+ s: S.TRUE
757
801
  },
758
- ...t
802
+ ...e
759
803
  };
760
804
  }
761
805
  }
762
806
  ],
763
807
  afterProcessRules: [
764
808
  {
765
- filter(e) {
766
- return e.tagName === "DIV" && /ace-line/i.test(e.className);
809
+ filter(i) {
810
+ return i.tagName === "DIV" && /ace-line/i.test(i.className);
767
811
  },
768
- handler(e) {
769
- e.paragraphs == null && (e.paragraphs = []), e.paragraphs.push({
770
- startIndex: e.dataStream.length
771
- }), e.dataStream += "\r";
812
+ handler(i) {
813
+ i.paragraphs == null && (i.paragraphs = []), i.paragraphs.push({
814
+ startIndex: i.dataStream.length
815
+ }), i.dataStream += "\r";
772
816
  }
773
817
  }
774
818
  ]
775
819
  };
776
- function ln(e) {
777
- const t = e.style, n = {};
778
- for (let o = 0; o < t.length; o++) {
779
- const r = t[o], i = t.getPropertyValue(r);
820
+ function Cr(i) {
821
+ const e = i.style, t = {};
822
+ for (let n = 0; n < e.length; n++) {
823
+ const r = e[n], s = e.getPropertyValue(r);
780
824
  switch (r) {
781
825
  case "margin-top": {
782
- const s = Number.parseInt(i);
783
- n.spaceAbove = /pt/.test(i) ? fe(s) : s;
826
+ const o = Number.parseInt(s);
827
+ t.spaceAbove = /pt/.test(s) ? Ke(o) : o;
784
828
  break;
785
829
  }
786
830
  case "margin-bottom": {
787
- const s = Number.parseInt(i);
788
- n.spaceBelow = /pt/.test(i) ? fe(s) : s;
831
+ const o = Number.parseInt(s);
832
+ t.spaceBelow = /pt/.test(s) ? Ke(o) : o;
789
833
  break;
790
834
  }
791
835
  }
792
836
  }
793
- return Object.getOwnPropertyNames(n).length ? n : null;
794
- }
795
- function fe(e) {
796
- return e / 0.75;
837
+ return Object.getOwnPropertyNames(t).length ? t : null;
797
838
  }
798
- const dn = {
839
+ const Or = {
799
840
  name: "univer-doc-paste-plugin-word",
800
- checkPasteType(e) {
801
- return /word|mso/i.test(e);
841
+ checkPasteType(i) {
842
+ return /word|mso/i.test(i);
802
843
  },
803
844
  stylesRules: [
804
845
  {
805
846
  filter: ["b"],
806
- getStyle(e) {
807
- const t = re(e);
808
- return { bl: u.TRUE, ...t };
847
+ getStyle(i) {
848
+ const e = Fe(i);
849
+ return { bl: S.TRUE, ...e };
809
850
  }
810
851
  }
811
852
  ],
812
853
  afterProcessRules: [
813
854
  {
814
- filter(e) {
815
- return e.tagName === "P" && /mso/i.test(e.className);
855
+ filter(i) {
856
+ return i.tagName === "P" && /mso/i.test(i.className);
816
857
  },
817
- handler(e, t) {
818
- e.paragraphs == null && (e.paragraphs = []);
819
- const n = {
820
- startIndex: e.dataStream.length
821
- }, o = ln(t);
822
- o && (n.paragraphStyle = o), e.paragraphs.push(n), e.dataStream += "\r";
858
+ handler(i, e) {
859
+ i.paragraphs == null && (i.paragraphs = []);
860
+ const t = {
861
+ startIndex: i.dataStream.length
862
+ }, n = Cr(e);
863
+ n && (t.paragraphStyle = n), i.paragraphs.push(t), i.dataStream += "\r";
823
864
  }
824
865
  }
825
866
  ]
826
867
  };
827
- function un(e, t) {
828
- const { st: n, ed: o, ts: r = {} } = t, { ff: i, fs: s, it: a, bl: c, ul: l, st: p, ol: C, bg: L, cl: j, va: P } = r;
829
- let d = e.slice(n, o);
830
- const f = [];
831
- return a === u.TRUE && (d = `<i>${d}</i>`), P === E.SUPERSCRIPT ? d = `<sup>${d}</sup>` : P === E.SUBSCRIPT && (d = `<sub>${d}</sub>`), (l == null ? void 0 : l.s) === u.TRUE && (d = `<u>${d}</u>`), (p == null ? void 0 : p.s) === u.TRUE && (d = `<s>${d}</s>`), c === u.TRUE && (d = `<strong>${d}</strong>`), i && f.push(`font-family: ${i}`), j && f.push(`color: ${j.rgb}`), s && f.push(`font-size: ${s}px`), C && f.push("text-decoration: overline"), L && f.push(`background: ${L.rgb}`), f.length ? `<span style="${f.join(";")}">${d}</span>` : d;
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;
832
873
  }
833
- function me(e, t = !0) {
834
- const { dataStream: n, textRuns: o = [], paragraphs: r = [] } = e;
835
- let i = 0;
836
- const s = [], a = [];
837
- for (const c of o) {
838
- const { st: l, ed: p } = c;
839
- if (l !== i && s.push(n.slice(i, l)), s.push(un(n, c)), i = p, t)
840
- for (const C of r) {
841
- const { startIndex: L, paragraphStyle: j = {} } = C;
842
- if (L >= l && L <= p) {
843
- const { spaceAbove: P, spaceBelow: d } = j, f = [];
844
- P != null && (typeof P == "number" ? f.push(`margin-top: ${P}px`) : f.push(`margin-top: ${P.v}px`)), d != null && (typeof d == "number" ? f.push(`margin-bottom: ${d}px`) : f.push(`margin-bottom: ${d.v}px`)), a.push(
845
- `<p className="UniverNormal" ${f.length ? `style="${f.join(";")}"` : ""}>${s.join("")}</p>`
846
- ), s.length = 0;
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;
847
888
  }
848
889
  }
849
890
  }
850
- return i < n.length && s.push(n.slice(i, n.length)), a.join("") + s.join("");
891
+ return s < t.length && o.push(t.slice(s, t.length)), a.join("") + o.join("");
851
892
  }
852
- class pn {
853
- convert(t) {
854
- if (t.length === 0)
893
+ class Tr {
894
+ convert(e) {
895
+ if (e.length === 0)
855
896
  throw new Error("The bodyList length at least to be 1");
856
- if (t.length === 1)
857
- return me(t[0]);
858
- let n = "";
859
- for (const o of t)
860
- n += '<p className="UniverNormal">', n += me(o, !1), n += "</p>";
861
- return n;
897
+ if (e.length === 1)
898
+ return rt(e[0]);
899
+ let t = "";
900
+ for (const n of e)
901
+ t += '<p className="UniverNormal">', t += rt(n, !1), t += "</p>";
902
+ return t;
862
903
  }
863
904
  }
864
- var hn = Object.defineProperty, fn = Object.getOwnPropertyDescriptor, mn = (e, t, n, o) => {
865
- for (var r = o > 1 ? void 0 : o ? fn(t, n) : t, i = e.length - 1, s; i >= 0; i--)
866
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
867
- return o && r && hn(t, n, r), r;
868
- }, N = (e, t) => (n, o) => t(n, o, e);
869
- $.use(dn);
870
- $.use(cn);
871
- function _n(e) {
872
- const t = e.replace(/\n/g, "\r"), n = [];
873
- for (let o = 0; o < t.length; o++)
874
- t[o] === "\r" && n.push({ startIndex: o });
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 = [];
914
+ for (let n = 0; n < e.length; n++)
915
+ e[n] === "\r" && t.push({ startIndex: n });
875
916
  return {
876
- dataStream: t,
877
- paragraphs: n
917
+ dataStream: e,
918
+ paragraphs: t
878
919
  };
879
920
  }
880
- const B = ze("doc.clipboard-service");
881
- let Q = class extends Te {
882
- constructor(t, n, o, r, i) {
921
+ const te = Pt("doc.clipboard-service");
922
+ let De = class extends V {
923
+ constructor(e, t, n, r, s) {
883
924
  super();
884
- h(this, "_clipboardHooks", []);
885
- h(this, "_htmlToUDM", new $());
886
- h(this, "_umdToHtml", new pn());
887
- this._currentUniverService = t, this._logService = n, this._commandService = o, this._clipboardInterfaceService = r, this._textSelectionManagerService = i;
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;
888
929
  }
889
930
  async copy() {
890
- const t = this._getDocumentBodyInRanges();
931
+ const e = this._getDocumentBodyInRanges();
891
932
  try {
892
- this._setClipboardData(t);
893
- } catch (n) {
894
- return this._logService.error("[DocClipboardService] copy failed", n), !1;
933
+ this._setClipboardData(e);
934
+ } catch (t) {
935
+ return this._logService.error("[DocClipboardService] copy failed", t), !1;
895
936
  }
896
937
  return !0;
897
938
  }
898
939
  async cut() {
899
940
  return this._cut();
900
941
  }
901
- async paste(t) {
902
- const n = await this._generateBodyFromClipboardItems(t);
903
- return this._paste(n);
942
+ async paste(e) {
943
+ const t = await this._generateBodyFromClipboardItems(e);
944
+ return this._paste(t);
904
945
  }
905
- async legacyPaste(t, n) {
906
- const o = this._generateBodyFromHtmlAndText(t, n);
907
- return this._paste(o);
946
+ async legacyPaste(e, t) {
947
+ const n = this._generateBodyFromHtmlAndText(e, t);
948
+ return this._paste(n);
908
949
  }
909
950
  async _cut() {
910
- var i;
951
+ var s;
911
952
  const {
912
- segmentId: t,
913
- endOffset: n,
914
- style: o
915
- } = (i = this._textSelectionManagerService.getActiveRange()) != null ? i : {}, r = this._textSelectionManagerService.getSelections();
916
- if (t == null && this._logService.error("[DocClipboardController] segmentId is not existed"), n == null || r == null)
953
+ segmentId: e,
954
+ endOffset: t,
955
+ 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)
917
958
  return !1;
918
959
  this.copy();
919
960
  try {
920
- let s = n;
961
+ let o = t;
921
962
  for (const c of r) {
922
- const { startOffset: l, endOffset: p } = c;
923
- l == null || p == null || p <= n && (s -= p - l);
963
+ const { startOffset: d, endOffset: u } = c;
964
+ d == null || u == null || u <= t && (o -= u - d);
924
965
  }
925
966
  const a = [
926
967
  {
927
- startOffset: s,
928
- endOffset: s,
929
- style: o
968
+ startOffset: o,
969
+ endOffset: o,
970
+ style: n
930
971
  }
931
972
  ];
932
- return this._commandService.executeCommand(be.id, { segmentId: t, textRanges: a });
973
+ return this._commandService.executeCommand(lt.id, { segmentId: e, textRanges: a });
933
974
  } catch {
934
975
  return this._logService.error("[DocClipboardController] cut content failed"), !1;
935
976
  }
936
977
  }
937
- async _paste(t) {
938
- var s;
939
- const { segmentId: n, endOffset: o, style: r } = (s = this._textSelectionManagerService.getActiveRange()) != null ? s : {}, i = this._textSelectionManagerService.getSelections();
940
- if (n == null && this._logService.error("[DocClipboardController] segmentId does not exist!"), o == null || i == null)
978
+ async _paste(e) {
979
+ var o;
980
+ const { segmentId: t, endOffset: n, style: r } = (o = this._textSelectionManagerService.getActiveRange()) != null ? o : {}, s = this._textSelectionManagerService.getSelections();
981
+ if (t == null && this._logService.error("[DocClipboardController] segmentId does not exist!"), n == null || s == null)
941
982
  return !1;
942
983
  try {
943
- let a = o;
944
- for (const l of i) {
945
- const { startOffset: p, endOffset: C } = l;
946
- p == null || C == null || C <= o && (a += t.dataStream.length - (C - p));
984
+ let a = n;
985
+ for (const d of s) {
986
+ const { startOffset: u, endOffset: h } = d;
987
+ u == null || h == null || h <= n && (a += e.dataStream.length - (h - u));
947
988
  }
948
989
  const c = [
949
990
  {
@@ -952,142 +993,641 @@ let Q = class extends Te {
952
993
  style: r
953
994
  }
954
995
  ];
955
- return this._commandService.executeCommand(xe.id, { body: t, segmentId: n, textRanges: c });
996
+ return this._commandService.executeCommand(dt.id, { body: e, segmentId: t, textRanges: c });
956
997
  } catch {
957
998
  return this._logService.error("[DocClipboardController]", "clipboard is empty."), !1;
958
999
  }
959
1000
  }
960
- async _setClipboardData(t) {
961
- const n = on(), o = t.length > 1 ? t.map((i) => i.dataStream).join(`
962
- `) : t[0].dataStream;
963
- let r = this._umdToHtml.convert(t);
964
- return t.length === 1 && (r = r.replace(/(<[a-z]+)/, (i, s) => `${s} data-copy-id="${n}"`), pe.set(n, t[0])), this._clipboardInterfaceService.write(o, r);
1001
+ async _setClipboardData(e) {
1002
+ const t = gr(), n = e.length > 1 ? e.map((s) => s.dataStream).join(`
1003
+ `) : 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);
965
1006
  }
966
- addClipboardHook(t) {
967
- return this._clipboardHooks.push(t), $e(() => {
968
- const n = this._clipboardHooks.indexOf(t);
969
- n > -1 && this._clipboardHooks.splice(n, 1);
1007
+ addClipboardHook(e) {
1008
+ return this._clipboardHooks.push(e), he(() => {
1009
+ const t = this._clipboardHooks.indexOf(e);
1010
+ t > -1 && this._clipboardHooks.splice(t, 1);
970
1011
  });
971
1012
  }
972
1013
  _getDocumentBodyInRanges() {
973
- const t = this._textSelectionManagerService.getSelections(), n = this._currentUniverService.getCurrentUniverDocInstance(), o = [];
974
- if (t == null)
975
- return o;
976
- for (const r of t) {
977
- const { startOffset: i, endOffset: s, collapsed: a } = r;
978
- if (a || i == null || s == null)
1014
+ const e = this._textSelectionManagerService.getSelections(), t = this._currentUniverService.getCurrentUniverDocInstance(), n = [];
1015
+ if (e == null)
1016
+ return n;
1017
+ for (const r of e) {
1018
+ const { startOffset: s, endOffset: o, collapsed: a } = r;
1019
+ if (a || s == null || o == null)
979
1020
  continue;
980
- const c = n.sliceBody(i, s);
981
- c != null && o.push(c);
1021
+ const c = t.sliceBody(s, o);
1022
+ c != null && n.push(c);
982
1023
  }
983
- return o;
1024
+ return n;
984
1025
  }
985
- async _generateBodyFromClipboardItems(t) {
1026
+ async _generateBodyFromClipboardItems(e) {
986
1027
  try {
987
- let n = "", o = "";
988
- for (const r of t)
989
- for (const i of r.types)
990
- i === Qe ? o = await r.getType(i).then((s) => s && s.text()) : i === et && (n = await r.getType(i).then((s) => s && s.text()));
991
- return this._generateBodyFromHtmlAndText(n, o);
992
- } catch (n) {
993
- return Promise.reject(n);
1028
+ 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()));
1032
+ return this._generateBodyFromHtmlAndText(t, n);
1033
+ } catch (t) {
1034
+ return Promise.reject(t);
994
1035
  }
995
1036
  }
996
- _generateBodyFromHtmlAndText(t, n) {
997
- if (!t) {
998
- if (n)
999
- return _n(n);
1037
+ _generateBodyFromHtmlAndText(e, t) {
1038
+ if (!e) {
1039
+ if (t)
1040
+ return Mr(t);
1000
1041
  throw new Error("[DocClipboardService] html and text cannot be both empty!");
1001
1042
  }
1002
- const o = rn(t);
1003
- if (o) {
1004
- const r = pe.get(o);
1043
+ const n = fr(e);
1044
+ if (n) {
1045
+ const r = tt.get(n);
1005
1046
  if (r)
1006
1047
  return r;
1007
1048
  }
1008
- return this._htmlToUDM.convert(t);
1049
+ return this._htmlToUDM.convert(e);
1009
1050
  }
1010
1051
  };
1011
- Q = mn([
1012
- N(0, te),
1013
- N(1, Re),
1014
- N(2, _),
1015
- N(3, oe),
1016
- N(4, y(Ie))
1017
- ], Q);
1018
- function Z(e) {
1019
- return e.getContextValue(m) || e.getContextValue(ge);
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);
1020
1061
  }
1021
- const ie = 999, gn = {
1022
- id: tt.id,
1062
+ const Be = 999, Er = {
1063
+ id: Wt.id,
1023
1064
  name: "doc.command.copy",
1024
- type: ne.COMMAND,
1065
+ type: Le.COMMAND,
1025
1066
  multi: !0,
1026
- priority: ie,
1027
- preconditions: Z,
1028
- handler: async (e) => e.get(B).copy()
1029
- }, Cn = {
1030
- id: nt.id,
1067
+ priority: Be,
1068
+ preconditions: Re,
1069
+ handler: async (i) => i.get(te).copy()
1070
+ }, Dr = {
1071
+ id: Vt.id,
1031
1072
  name: "doc.command.cut",
1032
- type: ne.COMMAND,
1073
+ type: Le.COMMAND,
1033
1074
  multi: !0,
1034
- priority: ie,
1035
- preconditions: Z,
1036
- handler: async (e) => e.get(B).cut()
1037
- }, Sn = {
1038
- id: ot.id,
1075
+ priority: Be,
1076
+ preconditions: Re,
1077
+ handler: async (i) => i.get(te).cut()
1078
+ }, xr = {
1079
+ id: Ht.id,
1039
1080
  name: "doc.command.paste",
1040
- type: ne.COMMAND,
1081
+ type: Le.COMMAND,
1041
1082
  multi: !0,
1042
- priority: ie,
1043
- preconditions: Z,
1044
- handler: async (e) => {
1045
- const t = e.get(B), o = await e.get(oe).read();
1046
- return o.length === 0 ? !1 : t.paste(o);
1083
+ priority: Be,
1084
+ preconditions: Re,
1085
+ handler: async (i) => {
1086
+ const e = i.get(te), n = await i.get(Ue).read();
1087
+ return n.length === 0 ? !1 : e.paste(n);
1047
1088
  }
1048
1089
  };
1049
- var On = Object.defineProperty, Tn = Object.getOwnPropertyDescriptor, vn = (e, t, n, o) => {
1050
- for (var r = o > 1 ? void 0 : o ? Tn(t, n) : t, i = e.length - 1, s; i >= 0; i--)
1051
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
1052
- return o && r && On(t, n, r), r;
1053
- }, U = (e, t) => (n, o) => t(n, o, e);
1054
- let W = class extends Ce {
1055
- constructor(e, t, n, o, r) {
1056
- super(), this._commandService = e, this._clipboardInterfaceService = t, this._docClipboardService = n, this._textSelectionRenderManager = o, this._contextService = r, this._init();
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();
1057
1098
  }
1058
1099
  _init() {
1059
- [gn, Cn, Sn].forEach((e) => this.disposeWithMe(this._commandService.registerMultipleCommand(e))), [xe, be].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))), this._initLegacyPasteCommand();
1100
+ [Er, Dr, xr].forEach((i) => this.disposeWithMe(this._commandService.registerMultipleCommand(i))), [dt, lt].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i))), this._initLegacyPasteCommand();
1060
1101
  }
1061
1102
  _initLegacyPasteCommand() {
1062
- var e;
1063
- this._clipboardInterfaceService.supportClipboard || (e = this._textSelectionRenderManager) == null || e.onPaste$.pipe(gt(this.dispose$)).subscribe((t) => {
1064
- var i, s;
1065
- if (!Z(this._contextService))
1103
+ var i;
1104
+ this._clipboardInterfaceService.supportClipboard || (i = this._textSelectionRenderManager) == null || i.onPaste$.pipe(_e(this.dispose$)).subscribe((e) => {
1105
+ var s, o;
1106
+ if (!Re(this._contextService))
1107
+ return;
1108
+ 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);
1111
+ });
1112
+ }
1113
+ };
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) {
1129
+ 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();
1132
+ }
1133
+ _initialize() {
1134
+ this._editorService.resize$.subscribe((e) => {
1135
+ this._resize(e);
1136
+ }), this._editorService.getAllEditor().forEach((e) => {
1137
+ const t = e.editorUnitId;
1138
+ this._initialEditors.has(t) || (this._initialEditors.add(t), this._resize(t));
1139
+ }), this._commandExecutedListener(), this._initialSetValue(), this._initialBlur(), this._initialFocus();
1140
+ }
1141
+ _resize(e) {
1142
+ var k, Y, X;
1143
+ if (e == null)
1144
+ return;
1145
+ const t = this._editorService.getEditor(e);
1146
+ if ((t == null ? void 0 : t.cancelDefaultResizeListener) === !0)
1147
+ 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)
1150
+ 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);
1157
+ 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());
1161
+ }
1162
+ _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
+ });
1170
+ }
1171
+ _initialBlur() {
1172
+ this._editorService.blur$.subscribe(() => {
1173
+ this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.blur();
1174
+ });
1175
+ }
1176
+ _initialFocus() {
1177
+ this._editorService.focus$.subscribe((e) => {
1178
+ this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.addTextRanges([e]);
1179
+ });
1180
+ }
1181
+ /**
1182
+ * Listen to document edits to refresh the size of the normula editor.
1183
+ */
1184
+ _commandExecutedListener() {
1185
+ const e = [$e.id, kt.id];
1186
+ this.disposeWithMe(
1187
+ this._commandService.onCommandExecuted((t) => {
1188
+ if (e.includes(t.id)) {
1189
+ const n = t.params, { unitId: r } = n;
1190
+ if (this._editorService.isSheetEditor(r))
1191
+ return;
1192
+ this._resize(r);
1193
+ }
1194
+ })
1195
+ );
1196
+ }
1197
+ };
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) {
1213
+ 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();
1216
+ }
1217
+ _initialRenderRefresh() {
1218
+ this._docSkeletonManagerService.currentSkeletonBefore$.pipe(_e(this.dispose$)).subscribe((e) => {
1219
+ this._create(e);
1220
+ });
1221
+ }
1222
+ _create(e) {
1223
+ if (e == null)
1224
+ return;
1225
+ 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);
1230
+ }
1231
+ _recalculateSizeBySkeleton(e, t) {
1232
+ 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)
1235
+ 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));
1240
+ }
1241
+ o.resize(c, d), this._editorService.isEditor(s) || r.resize(c, d);
1242
+ }
1243
+ _commandExecutedListener() {
1244
+ const e = [$e.id];
1245
+ this.disposeWithMe(
1246
+ this._commandService.onCommandExecuted((t) => {
1247
+ var n;
1248
+ if (e.includes(t.id)) {
1249
+ const r = t.params, { unitId: s } = r, o = this._docSkeletonManagerService.getSkeletonByUnitId(s);
1250
+ if (o == null)
1251
+ return;
1252
+ const { skeleton: a } = o, c = this._renderManagerService.getRenderById(s);
1253
+ if (c == null)
1254
+ return;
1255
+ if (a.calculate(), this._editorService.isEditor(s)) {
1256
+ (n = c.mainComponent) == null || n.makeDirty();
1257
+ return;
1258
+ }
1259
+ this._recalculateSizeBySkeleton(c, a);
1260
+ }
1261
+ })
1262
+ );
1263
+ }
1264
+ };
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 {
1278
+ constructor(e, t, n) {
1279
+ super();
1280
+ m(this, "_scene");
1281
+ m(this, "_currentDocumentModel");
1282
+ m(this, "_fps$", new vn(""));
1283
+ m(this, "fps$", this._fps$.asObservable());
1284
+ this._renderManagerService = e, this._configService = t, this._currentUniverService = n, this._initialize();
1285
+ }
1286
+ _initialize() {
1287
+ this._renderManagerService.createRender$.pipe(_e(this.dispose$)).subscribe((e) => {
1288
+ this._create(e);
1289
+ }), this._currentUniverService.currentDoc$.pipe(_e(this.dispose$)).subscribe((e) => {
1290
+ this._create(e == null ? void 0 : e.getUnitId());
1291
+ }), this._currentUniverService.getAllUniverDocsInstance().forEach((e) => {
1292
+ this._create(e.getUnitId());
1293
+ });
1294
+ }
1295
+ dispose() {
1296
+ this._fps$.complete();
1297
+ }
1298
+ _create(e) {
1299
+ if (e == null)
1300
+ return;
1301
+ const t = this._currentUniverService.getUniverDocInstance(e);
1302
+ t != null && (this._currentDocumentModel = t, this._renderManagerService.has(e) || this._addNewRender());
1303
+ }
1304
+ _addNewRender() {
1305
+ const e = this._currentDocumentModel, t = e.getUnitId(), n = e.getContainer(), r = e.getParentRenderUnitId();
1306
+ if (n != null && r != null)
1307
+ throw new Error("container or parentRenderUnitId can only exist one");
1308
+ n == null && r != null ? this._renderManagerService.createRenderWithParent(t, r) : this._renderManagerService.createRender(t);
1309
+ const s = this._renderManagerService.getRenderById(t);
1310
+ if (s == null)
1311
+ return;
1312
+ const { scene: o, engine: a } = s;
1313
+ o.openTransformer(), this._scene = o;
1314
+ const c = new un(Ae.VIEW_MAIN, o, {
1315
+ left: 0,
1316
+ top: 0,
1317
+ bottom: 0,
1318
+ right: 0,
1319
+ isWheelPreventDefaultX: !0
1320
+ });
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();
1327
+ } 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());
1334
+ }), this._renderManagerService.setCurrent(t);
1335
+ }
1336
+ _addComponent(e) {
1337
+ const t = this._scene, n = this._currentDocumentModel, r = new _n(qe.MAIN, void 0, {
1338
+ pageMarginLeft: n.documentStyle.marginLeft || 0,
1339
+ pageMarginTop: n.documentStyle.marginTop || 0
1340
+ });
1341
+ r.zIndex = cn, e.mainComponent = r, e.components.set(qe.MAIN, r), t.addObjects([r], Ze);
1342
+ }
1343
+ };
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) {
1357
+ 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();
1361
+ }
1362
+ _initialize() {
1363
+ this._initialRenderRefresh(), this._updateOnPluginChange();
1364
+ }
1365
+ _updateOnPluginChange() {
1366
+ this._floatingObjectManagerService.pluginUpdate$.subscribe((e) => {
1367
+ const t = this._docSkeletonManagerService.getCurrent();
1368
+ if (t == null)
1369
+ return;
1370
+ const { unitId: n, skeleton: r } = t, s = this._renderManagerService.getRenderById(n);
1371
+ if (s == null)
1372
+ 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
1381
+ });
1382
+ }), r == null || r.calculate(), o == null || o.makeDirty();
1383
+ });
1384
+ }
1385
+ _initialRenderRefresh() {
1386
+ this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1387
+ if (e == null)
1388
+ return;
1389
+ const { skeleton: t, unitId: n } = e, r = this._renderManagerService.getRenderById(n);
1390
+ if (r == null)
1391
+ return;
1392
+ const { mainComponent: s } = r;
1393
+ s.changeSkeleton(t), this._refreshFloatingObject(n, t, r);
1394
+ });
1395
+ }
1396
+ _commandExecutedListener() {
1397
+ const e = [$e.id, ut.id];
1398
+ this.disposeWithMe(
1399
+ this._commandService.onCommandExecuted((t) => {
1400
+ var n;
1401
+ if (e.includes(t.id)) {
1402
+ const r = t.params, { unitId: s } = r, o = this._docSkeletonManagerService.getCurrent();
1403
+ if (o == null)
1404
+ return;
1405
+ const { unitId: a, skeleton: c } = o;
1406
+ if (s !== a)
1407
+ return;
1408
+ const d = this._renderManagerService.getRenderById(a);
1409
+ if (d == null)
1410
+ return;
1411
+ if (this._editorService.isEditor(a)) {
1412
+ (n = d.mainComponent) == null || n.makeDirty();
1413
+ return;
1414
+ }
1415
+ this._refreshFloatingObject(a, c, d);
1416
+ }
1417
+ })
1418
+ );
1419
+ }
1420
+ _refreshFloatingObject(e, t, n) {
1421
+ const r = t == null ? void 0 : t.getSkeletonData(), { mainComponent: s, scene: o } = n, a = s;
1422
+ if (!r)
1423
+ return;
1424
+ const { left: c, top: d, pageLayoutType: u, pageMarginLeft: h, pageMarginTop: g } = a, { pages: f } = r, p = [];
1425
+ 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({
1431
+ unitId: e,
1432
+ subUnitId: yt,
1433
+ floatingObjectId: x,
1434
+ floatingObject: {
1435
+ left: je + c + this._liquid.x,
1436
+ top: ze + d + this._liquid.y,
1437
+ width: Ve,
1438
+ height: We
1439
+ }
1440
+ }), this._pageMarginCache.set(x, {
1441
+ marginLeft: this._liquid.x,
1442
+ marginTop: this._liquid.y
1443
+ });
1444
+ }), this._liquid.translatePage(v, u, h, g);
1445
+ }
1446
+ this._floatingObjectManagerService.BatchAddOrUpdate(p);
1447
+ }
1448
+ };
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();
1467
+ }
1468
+ _initialize() {
1469
+ this._initialRenderRefresh();
1470
+ }
1471
+ _initialRenderRefresh() {
1472
+ this._renderManagerService.currentRender$.subscribe((i) => {
1473
+ var s;
1474
+ if (i == null)
1475
+ return;
1476
+ const e = this._renderManagerService.getRenderById(i);
1477
+ if (this._editorService.isEditor(i) || this._currentUniverService.getUniverDocInstance(i) == null || e == null)
1066
1478
  return;
1067
- t.event.preventDefault();
1068
- const n = t.event, o = (i = n.clipboardData) == null ? void 0 : i.getData("text/html"), r = (s = n.clipboardData) == null ? void 0 : s.getData("text/plain");
1069
- this._docClipboardService.legacyPaste(o, r);
1479
+ const { mainComponent: t } = e, n = t, r = (s = n.getSkeleton()) == null ? void 0 : s.getPageSize();
1480
+ this.disposeWithMe(
1481
+ he(
1482
+ n.onPageRenderObservable.add((o) => {
1483
+ var l, _, v, T;
1484
+ if (this._editorService.isEditor(i))
1485
+ 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,
1490
+ strokeWidth: 1,
1491
+ stroke: Zr,
1492
+ fill: qr,
1493
+ zIndex: 3
1494
+ }), u.restore();
1495
+ })
1496
+ )
1497
+ );
1070
1498
  });
1071
1499
  }
1500
+ _commandExecutedListener() {
1501
+ }
1072
1502
  };
1073
- W = vn([
1074
- Se(Oe.Steady, W),
1075
- U(0, _),
1076
- U(1, oe),
1077
- U(2, B),
1078
- U(3, De),
1079
- U(4, we)
1080
- ], W);
1081
- var Rn = Object.defineProperty, yn = Object.getOwnPropertyDescriptor, In = (e, t, n, o) => {
1082
- for (var r = o > 1 ? void 0 : o ? yn(t, n) : t, i = e.length - 1, s; i >= 0; i--)
1083
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
1084
- return o && r && Rn(t, n, r), r;
1085
- }, X = (e, t) => (n, o) => t(n, o, e), q;
1086
- let _e = (q = class extends Be {
1087
- constructor(e, t, n, o) {
1088
- super(Tt), this._config = e, this._injector = t, this._localeService = n, this._logService = o, this._localeService.load({
1089
- zhCN: qt
1090
- }), this._config = ve.deepMerge({}, Ot, this._config), this._initDependencies(t), this._initializeCommands();
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) {
1516
+ 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();
1519
+ }
1520
+ dispose() {
1521
+ super.dispose();
1522
+ }
1523
+ _initialize() {
1524
+ this._skeletonListener(), this._commandExecutedListener(), this._initialRenderRefresh();
1525
+ }
1526
+ _initialRenderRefresh() {
1527
+ this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1528
+ if (e == null)
1529
+ return;
1530
+ const { unitId: t } = e, n = this._renderManagerService.getRenderById(t);
1531
+ if (n == null || this._initializedRender.has(t) || this._editorService.isEditor(t))
1532
+ return;
1533
+ this._initializedRender.add(t);
1534
+ const { scene: r } = n;
1535
+ this.disposeWithMe(
1536
+ he(
1537
+ r.onMouseWheelObserver.add((s) => {
1538
+ if (!s.ctrlKey)
1539
+ return;
1540
+ 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, {
1546
+ zoomRatio: u,
1547
+ unitId: c.getUnitId()
1548
+ }), s.preventDefault();
1549
+ })
1550
+ )
1551
+ );
1552
+ });
1553
+ }
1554
+ // private _zoomEventBinding() {
1555
+ // const scene = this._getDocObject()?.scene;
1556
+ // if (scene == null) {
1557
+ // return;
1558
+ // }
1559
+ // const viewportMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
1560
+ // }
1561
+ _skeletonListener() {
1562
+ this.disposeWithMe(
1563
+ he(
1564
+ this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1565
+ if (e == null)
1566
+ return;
1567
+ const n = this._currentUniverService.getCurrentUniverDocInstance().zoomRatio || 1;
1568
+ this._updateViewZoom(n, !1);
1569
+ })
1570
+ )
1571
+ );
1572
+ }
1573
+ _commandExecutedListener() {
1574
+ const e = [ut.id];
1575
+ this.disposeWithMe(
1576
+ this._commandService.onCommandExecuted((t) => {
1577
+ if (e.includes(t.id)) {
1578
+ const n = this._currentUniverService.getCurrentUniverDocInstance(), r = t.params, { unitId: s } = r;
1579
+ if (s !== n.getUnitId())
1580
+ return;
1581
+ const o = n.zoomRatio || 1;
1582
+ this._updateViewZoom(o);
1583
+ }
1584
+ })
1585
+ );
1586
+ }
1587
+ _updateViewZoom(e, t = !0) {
1588
+ var r;
1589
+ 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());
1591
+ }
1592
+ _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)
1595
+ return;
1596
+ 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
1604
+ });
1605
+ }
1606
+ return this;
1607
+ }
1608
+ _getDocObject() {
1609
+ return dn(this._currentUniverService, this._renderManagerService);
1610
+ }
1611
+ };
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();
1091
1631
  }
1092
1632
  onRendered() {
1093
1633
  this._initModules(), this._markDocAsFocused();
@@ -1096,67 +1636,76 @@ let _e = (q = class extends Be {
1096
1636
  }
1097
1637
  _initializeCommands() {
1098
1638
  [
1099
- vt,
1100
- Rt,
1101
- It,
1102
- yt,
1103
- bt,
1104
- xt,
1105
- Dt,
1106
- Pt,
1107
- Mt,
1108
- Qt,
1109
- en,
1110
- Jt
1111
- ].forEach((e) => {
1112
- this._injector.get(ye).registerShortcut(e);
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);
1113
1653
  });
1114
1654
  }
1115
- _initDependencies(e) {
1655
+ _initDependencies(i) {
1116
1656
  [
1117
- [V],
1118
- [W],
1657
+ // Controller
1658
+ [ie],
1659
+ [oe],
1660
+ [se],
1661
+ [ae],
1662
+ [le],
1663
+ [de],
1664
+ [ue],
1119
1665
  [
1120
1666
  // controllers
1121
- F,
1667
+ K,
1122
1668
  {
1123
- useFactory: () => this._injector.createInstance(F, this._config)
1669
+ useFactory: () => this._injector.createInstance(K, this._config)
1124
1670
  }
1125
1671
  ],
1126
1672
  [
1127
- B,
1673
+ te,
1128
1674
  {
1129
- useClass: Q
1675
+ useClass: De
1130
1676
  }
1131
- ]
1132
- ].forEach((n) => {
1133
- e.add(n);
1677
+ ],
1678
+ // Render views
1679
+ [ce]
1680
+ ].forEach((t) => {
1681
+ i.add(t);
1134
1682
  });
1135
1683
  }
1136
1684
  _markDocAsFocused() {
1137
- const e = this._injector.get(te);
1685
+ const i = this._injector.get(P), e = this._injector.get(F);
1138
1686
  try {
1139
- const t = e.getCurrentUniverDocInstance(), n = t.getUnitId();
1140
- n !== He && n !== Ve && e.focusUniverInstance(t.getUnitId());
1687
+ const t = i.getCurrentUniverDocInstance(), n = t.getUnitId();
1688
+ e.isEditor(n) || i.focusUniverInstance(t.getUnitId());
1141
1689
  } catch (t) {
1142
1690
  this._logService.warn(t);
1143
1691
  }
1144
1692
  }
1145
1693
  _initModules() {
1146
- this._injector.get(F);
1147
- }
1148
- }, h(q, "type", je.Doc), q);
1149
- _e = In([
1150
- X(1, y(Y)),
1151
- X(2, y(ee)),
1152
- X(3, Re)
1153
- ], _e);
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);
1154
1702
  export {
1155
- Tt as DOC_UI_PLUGIN_NAME,
1156
- St as DefaultDocContainerConfig,
1157
- Ot as DefaultDocUiConfig,
1158
- Ct as DefaultToolbarConfig,
1159
- _e as UniverDocsUIPlugin,
1160
- Nn as enUS,
1161
- qt as zhCN
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
1162
1711
  };