@univerjs/docs-ui 0.2.2 → 0.2.4-alpha.0

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,36 +1,34 @@
1
- var vn = Object.defineProperty;
2
- var On = (n, e, t) => e in n ? vn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var E = (n, e, t) => On(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { FOCUSING_DOC as Ne, FOCUSING_UNIVER_EDITOR as ht, FOCUSING_COMMON_DRAWINGS as Kt, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE as Rn, Tools as ee, LRUMap as Cn, BaselineOffset as ae, BooleanNumber as S, ColorKit as St, skipParseTagNames as En, IUniverInstanceService as L, ILogService as Zt, ICommandService as C, Disposable as K, normalizeBody as Tn, toDisposable as qt, RxDisposable as Oe, Direction as Z, EDITOR_ACTIVATED as Jt, LocaleService as le, CommandType as de, DocumentFlavor as In, JSONX as et, UniverInstanceType as v, ThemeService as Qt, HorizontalAlign as Le, OnLifecycle as Ue, LifecycleStages as we, IContextService as bn, checkForSubstrings as Mn, IConfigService as xn, PositionedObjectLayoutType as yn, DEFAULT_DOCUMENT_SUB_COMPONENT_ID as Pn, DisposableCollection as vt, Plugin as Dn, ObjectRelativeFromH as An, ObjectRelativeFromV as Fn } from "@univerjs/core";
5
- import { IClipboardInterfaceService as gt, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as Nn, HTML_CLIPBOARD_MIME_TYPE as Ln, IEditorService as Y, KeyCode as H, MetaKeys as Re, ILayoutService as en, ISidebarService as Un, ComponentManager as tn, MenuGroup as P, MenuItemType as x, MenuPosition as D, getMenuHiddenObservable as A, FONT_FAMILY_LIST as Ot, FONT_SIZE_LIST as wn, getHeaderFooterMenuHiddenObservable as Bn, FontFamily as $n, FontFamilyItem as Hn, FontSize as Vn, BuiltInUIPart as jn, IMenuService as Wn, IUIPartsService as kn, CopyCommand as zn, CutCommand as Gn, PasteCommand as Yn, SetEditorResizeOperation as Xn, ICanvasPopupService as Kn, IShortcutService as Zn } from "@univerjs/ui";
6
- import { createIdentifier as qn, Inject as T, Injector as Be, Optional as Jn } from "@wendellhu/redi";
7
- import { TextSelectionManagerService as ne, CutContentCommand as nn, InnerPasteCommand as on, getDeleteSelection as Qn, DocSkeletonManagerService as N, VIEWPORT_KEY as te, getDocObject as eo, MoveCursorOperation as $e, MoveSelectionOperation as He, SelectAllOperation as to, neoGetDocObject as Q, RichTextEditingMutation as Ve, SetInlineFormatBoldCommand as no, SetTextSelectionsOperation as V, SetInlineFormatCommand as ue, SetInlineFormatItalicCommand as oo, SetInlineFormatUnderlineCommand as io, SetInlineFormatStrikethroughCommand as ro, SetInlineFormatSubscriptCommand as so, SetInlineFormatSuperscriptCommand as ao, SetInlineFormatFontFamilyCommand as Rt, SetInlineFormatFontSizeCommand as Ct, SetInlineFormatTextColorCommand as Et, AlignLeftCommand as co, AlignOperationCommand as je, AlignCenterCommand as lo, AlignRightCommand as uo, AlignJustifyCommand as ho, OrderListCommand as go, BulletListCommand as po, ResetInlineFormatTextBackgroundColorCommand as _o, SetInlineFormatTextBackgroundColorCommand as tt, BreakLineCommand as fo, DeleteLeftCommand as mo, DeleteRightCommand as So, CoverContentCommand as vo, DOCS_COMPONENT_MAIN_LAYER_INDEX as Ye, DOCS_COMPONENT_HEADER_LAYER_INDEX as Oo, DOCS_VIEW_KEY as ie, DOCS_COMPONENT_DEFAULT_Z_INDEX as Tt, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX as Ro, SetDocZoomRatioOperation as ve, SetDocZoomRatioCommand as Co, DocInterceptorService as Eo } from "@univerjs/docs";
8
- import { pixelToPt as To, ptToPixel as It, NodePositionConvertToCursor as rn, getAnchorBounding as Io, IRenderManagerService as k, ITextSelectionRenderManager as oe, Shape as bo, DocumentEditArea as F, PageLayoutType as De, Vector2 as sn, Rect as Xe, Path as bt, ScrollBar as nt, Viewport as Mo, Layer as Mt, Documents as xo, DocBackground as yo, Liquid as Po, CURSOR_TYPE as xt, getLineBounding as Do } from "@univerjs/engine-render";
9
- import { takeUntil as se, Observable as w, combineLatest as Ao, fromEvent as yt, BehaviorSubject as Pt, map as Fo } from "rxjs";
10
- import { useDependency as G, connectInjector as No } from "@wendellhu/redi/react-bindings";
11
- import Lo, { useState as an, useEffect as cn } from "react";
12
- import { Checkbox as Dt, InputNumber as At, Button as Uo, ColorPicker as wo } from "@univerjs/design";
13
- import Bo from "clsx";
14
- function z(n) {
15
- return n.getContextValue(Ne) && n.getContextValue(ht) && !n.getContextValue(Kt);
1
+ var Sn = Object.defineProperty;
2
+ var vn = (t, e, n) => e in t ? Sn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var C = (t, e, n) => vn(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { FOCUSING_DOC as Ue, FOCUSING_UNIVER_EDITOR as dt, FOCUSING_COMMON_DRAWINGS as Xt, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE as Rn, Tools as j, LRUMap as On, BaselineOffset as ae, BooleanNumber as S, ColorKit as ft, DataStreamTreeTokenType as Pe, CustomRangeType as Kt, skipParseTagNames as Cn, createIdentifier as En, Inject as E, IUniverInstanceService as w, ILogService as Zt, ICommandService as O, Disposable as Q, SliceBodyType as mt, normalizeBody as Tn, UniverInstanceType as v, toDisposable as Jt, RxDisposable as Se, Direction as K, EDITOR_ACTIVATED as qt, LocaleService as le, Injector as Le, Optional as In, useDependency as z, CommandType as de, DocumentFlavor as bn, JSONX as Qe, ThemeService as Qt, HorizontalAlign as we, OnLifecycle as Be, LifecycleStages as $e, IContextService as Mn, checkForSubstrings as yn, IConfigService as xn, isInternalEditorID as Pn, DisposableCollection as St, Plugin as Dn, ObjectRelativeFromH as An, ObjectRelativeFromV as Nn } from "@univerjs/core";
5
+ import { IClipboardInterfaceService as ut, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as Fn, HTML_CLIPBOARD_MIME_TYPE as Un, IEditorService as ee, KeyCode as H, MetaKeys as ve, ILayoutService as en, ISidebarService as Ln, ComponentManager as tn, MenuGroup as x, MenuItemType as y, MenuPosition as P, getMenuHiddenObservable as D, FONT_FAMILY_LIST as vt, FONT_SIZE_LIST as wn, getHeaderFooterMenuHiddenObservable as Bn, FontFamily as $n, FontFamilyItem as Hn, FontSize as Vn, IMenuService as jn, CopyCommand as Wn, CutCommand as kn, PasteCommand as Gn, SetEditorResizeOperation as zn, ICanvasPopupService as Yn, IShortcutService as Xn } from "@univerjs/ui";
6
+ import { TextSelectionManagerService as te, DocCustomRangeService as Kn, CutContentCommand as nn, InnerPasteCommand as on, getDeleteSelection as Zn, DocSkeletonManagerService as L, VIEWPORT_KEY as q, getDocObject as Jn, MoveCursorOperation as He, MoveSelectionOperation as Ve, SelectAllOperation as qn, neoGetDocObject as J, RichTextEditingMutation as ht, SetInlineFormatBoldCommand as Qn, SetTextSelectionsOperation as V, SetInlineFormatCommand as ue, SetInlineFormatItalicCommand as eo, SetInlineFormatUnderlineCommand as to, SetInlineFormatStrikethroughCommand as no, SetInlineFormatSubscriptCommand as oo, SetInlineFormatSuperscriptCommand as ro, SetInlineFormatFontFamilyCommand as Rt, SetInlineFormatFontSizeCommand as Ot, SetInlineFormatTextColorCommand as Ct, AlignLeftCommand as io, AlignOperationCommand as je, AlignCenterCommand as so, AlignRightCommand as ao, AlignJustifyCommand as co, OrderListCommand as lo, BulletListCommand as uo, ResetInlineFormatTextBackgroundColorCommand as ho, SetInlineFormatTextBackgroundColorCommand as et, BreakLineCommand as go, DeleteLeftCommand as po, DeleteRightCommand as _o, CoverContentCommand as fo, DOCS_COMPONENT_MAIN_LAYER_INDEX as Ye, DOCS_COMPONENT_HEADER_LAYER_INDEX as mo, DOCS_VIEW_KEY as oe, DOCS_COMPONENT_DEFAULT_Z_INDEX as Et, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX as So, SetDocZoomRatioCommand as vo, SetDocZoomRatioOperation as De, DocInterceptorService as Ro } from "@univerjs/docs";
7
+ import { pixelToPt as Oo, ptToPixel as Tt, NodePositionConvertToCursor as rn, getAnchorBounding as Co, IRenderManagerService as W, ITextSelectionRenderManager as ne, Shape as Eo, DocumentEditArea as F, PageLayoutType as Ae, Vector2 as sn, Rect as Xe, Path as It, ScrollBar as tt, Viewport as To, Layer as bt, Documents as Io, DocBackground as bo, CURSOR_TYPE as Mt, getLineBounding as Mo } from "@univerjs/engine-render";
8
+ import { takeUntil as se, Observable as B, combineLatest as yo, fromEvent as yt, BehaviorSubject as xt, map as xo } from "rxjs";
9
+ import Po, { useState as an, useEffect as cn } from "react";
10
+ import { Checkbox as Pt, InputNumber as Dt, Button as Do, ColorPicker as Ao } from "@univerjs/design";
11
+ import No from "clsx";
12
+ function k(t) {
13
+ return t.getContextValue(Ue) && t.getContextValue(dt) && !t.getContextValue(Xt);
16
14
  }
17
- function $o(n) {
18
- return n.getContextValue(Ne) && n.getContextValue(ht) && !n.getContextValue(Rn) && !n.getContextValue(Kt);
15
+ function Fo(t) {
16
+ return t.getContextValue(Ue) && t.getContextValue(dt) && !t.getContextValue(Rn) && !t.getContextValue(Xt);
19
17
  }
20
- const Ho = 10, Vo = 6;
21
- function jo() {
22
- return ee.generateRandomId(Vo);
18
+ const Uo = 10, Lo = 6;
19
+ function wo() {
20
+ return j.generateRandomId(Lo);
23
21
  }
24
- function Wo(n) {
25
- const e = n.match(/data-copy-id="([^\s]+)"/);
22
+ function Bo(t) {
23
+ const e = t.match(/data-copy-id="([^\s]+)"/);
26
24
  return e && e[1] ? e[1] : null;
27
25
  }
28
- class ko {
26
+ class $o {
29
27
  constructor() {
30
- E(this, "_cache", new Cn(Ho));
28
+ C(this, "_cache", new On(Uo));
31
29
  }
32
- set(e, t) {
33
- this._cache.set(e, t);
30
+ set(e, n) {
31
+ this._cache.set(e, n);
34
32
  }
35
33
  get(e) {
36
34
  return this._cache.get(e);
@@ -39,99 +37,99 @@ class ko {
39
37
  this._cache.clear();
40
38
  }
41
39
  }
42
- const Ft = new ko();
43
- function pt(n) {
44
- const e = n.style, t = {}, o = n.tagName.toLowerCase();
40
+ const At = new $o();
41
+ function gt(t) {
42
+ const e = t.style, n = {}, o = t.tagName.toLowerCase();
45
43
  switch (o) {
46
44
  case "b":
47
45
  case "em":
48
46
  case "strong": {
49
- t.bl = S.TRUE;
47
+ n.bl = S.TRUE;
50
48
  break;
51
49
  }
52
50
  case "s": {
53
- t.st = {
51
+ n.st = {
54
52
  s: S.TRUE
55
53
  };
56
54
  break;
57
55
  }
58
56
  case "u": {
59
- t.ul = {
57
+ n.ul = {
60
58
  s: S.TRUE
61
59
  };
62
60
  break;
63
61
  }
64
62
  case "i": {
65
- t.it = S.TRUE;
63
+ n.it = S.TRUE;
66
64
  break;
67
65
  }
68
66
  case "sub":
69
67
  case "sup": {
70
- t.va = o === "sup" ? ae.SUPERSCRIPT : ae.SUBSCRIPT;
68
+ n.va = o === "sup" ? ae.SUPERSCRIPT : ae.SUBSCRIPT;
71
69
  break;
72
70
  }
73
71
  }
74
- for (let i = 0; i < e.length; i++) {
75
- const r = e[i], s = e.getPropertyValue(r);
76
- switch (r) {
72
+ for (let r = 0; r < e.length; r++) {
73
+ const i = e[r], s = e.getPropertyValue(i);
74
+ switch (i) {
77
75
  case "font-family": {
78
- t.ff = s;
76
+ n.ff = s;
79
77
  break;
80
78
  }
81
79
  case "font-size": {
82
80
  const a = Number.parseInt(s);
83
- Number.isNaN(a) || (s.endsWith("pt") ? t.fs = a : s.endsWith("px") && (t.fs = To(a)));
81
+ Number.isNaN(a) || (s.endsWith("pt") ? n.fs = a : s.endsWith("px") && (n.fs = Oo(a)));
84
82
  break;
85
83
  }
86
84
  case "font-style": {
87
- s === "italic" && (t.it = S.TRUE);
85
+ s === "italic" && (n.it = S.TRUE);
88
86
  break;
89
87
  }
90
88
  case "font-weight": {
91
- (Number(s) > 400 || String(s) === "bold") && (t.bl = S.TRUE);
89
+ (Number(s) > 400 || String(s) === "bold") && (n.bl = S.TRUE);
92
90
  break;
93
91
  }
94
92
  case "text-decoration": {
95
- /underline/.test(s) ? t.ul = {
93
+ /underline/.test(s) ? n.ul = {
96
94
  s: S.TRUE
97
- } : /overline/.test(s) ? t.ol = {
95
+ } : /overline/.test(s) ? n.ol = {
98
96
  s: S.TRUE
99
- } : /line-through/.test(s) && (t.st = {
97
+ } : /line-through/.test(s) && (n.st = {
100
98
  s: S.TRUE
101
99
  });
102
100
  break;
103
101
  }
104
102
  case "color": {
105
- const a = new St(s);
106
- a.isValid && (t.cl = {
103
+ const a = new ft(s);
104
+ a.isValid && (n.cl = {
107
105
  rgb: a.toRgbString()
108
106
  });
109
107
  break;
110
108
  }
111
109
  case "background-color": {
112
- const a = new St(s);
113
- a.isValid && (t.bg = {
110
+ const a = new ft(s);
111
+ a.isValid && (n.bg = {
114
112
  rgb: a.toRgbString()
115
113
  });
116
114
  break;
117
115
  }
118
116
  }
119
117
  }
120
- return t;
118
+ return n;
121
119
  }
122
- function zo(n) {
123
- const e = new DOMParser(), t = `<x-univer id="univer-root">${n}</x-univer>`;
124
- return e.parseFromString(t, "text/html").querySelector("#univer-root");
120
+ function Ho(t) {
121
+ const e = new DOMParser(), n = `<x-univer id="univer-root">${t}</x-univer>`;
122
+ return e.parseFromString(n, "text/html").querySelector("#univer-root");
125
123
  }
126
- function Nt(n, e) {
127
- const t = n.tagName.toLowerCase();
128
- return typeof e == "string" ? t === e : Array.isArray(e) ? e.some((o) => o === t) : e(n);
124
+ function Nt(t, e) {
125
+ const n = t.tagName.toLowerCase();
126
+ return typeof e == "string" ? n === e : Array.isArray(e) ? e.some((o) => o === n) : e(t);
129
127
  }
130
128
  const Fe = class Fe {
131
129
  constructor() {
132
- E(this, "_styleCache", /* @__PURE__ */ new Map());
133
- E(this, "_styleRules", []);
134
- E(this, "_afterProcessRules", []);
130
+ C(this, "_styleCache", /* @__PURE__ */ new Map());
131
+ C(this, "_styleRules", []);
132
+ C(this, "_afterProcessRules", []);
135
133
  }
136
134
  static use(e) {
137
135
  if (this._pluginList.includes(e))
@@ -139,54 +137,68 @@ const Fe = class Fe {
139
137
  this._pluginList.push(e);
140
138
  }
141
139
  convert(e) {
142
- const t = Fe._pluginList.find((r) => r.checkPasteType(e)), o = zo(e), i = {
140
+ const n = Fe._pluginList.find((i) => i.checkPasteType(e)), o = Ho(e), r = {
143
141
  dataStream: "",
144
142
  textRuns: []
145
143
  };
146
- return t && (this._styleRules = [...t.stylesRules], this._afterProcessRules = [...t.afterProcessRules]), this._styleCache.clear(), this._process(null, o == null ? void 0 : o.childNodes, i), this._styleCache.clear(), this._styleRules = [], this._afterProcessRules = [], i;
144
+ 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;
147
145
  }
148
- _process(e, t, o) {
149
- var i, r;
150
- for (const s of t)
151
- if (s.nodeType === Node.TEXT_NODE) {
152
- if (((i = s.nodeValue) == null ? void 0 : i.trim()) === "")
146
+ _process(e, n, o) {
147
+ var r, i, s;
148
+ for (const a of n)
149
+ if (a.nodeType === Node.TEXT_NODE) {
150
+ if (((r = a.nodeValue) == null ? void 0 : r.trim()) === "")
153
151
  continue;
154
- const a = (r = s.nodeValue) == null ? void 0 : r.replace(/[\r\n]/g, "");
155
- let c;
156
- e && this._styleCache.has(e) && (c = this._styleCache.get(e)), o.dataStream += a, c && Object.getOwnPropertyNames(c).length && o.textRuns.push({
157
- st: o.dataStream.length - a.length,
152
+ let c = (i = a.nodeValue) == null ? void 0 : i.replace(/[\r\n]/g, ""), d;
153
+ if (e && e.nodeType === Node.ELEMENT_NODE && e.tagName.toUpperCase() === "A") {
154
+ const g = j.generateRandomId();
155
+ c = `${Pe.CUSTOM_RANGE_START}${c}${Pe.CUSTOM_RANGE_END}`, o.customRanges = [
156
+ ...(s = o.customRanges) != null ? s : [],
157
+ {
158
+ startIndex: o.dataStream.length,
159
+ endIndex: o.dataStream.length + c.length - 1,
160
+ rangeId: g,
161
+ rangeType: Kt.HYPERLINK
162
+ }
163
+ ], o.payloads = {
164
+ ...o.payloads,
165
+ [g]: e.href
166
+ };
167
+ }
168
+ e && this._styleCache.has(e) && (d = this._styleCache.get(e)), o.dataStream += c, d && Object.getOwnPropertyNames(d).length && o.textRuns.push({
169
+ st: o.dataStream.length - c.length,
158
170
  ed: o.dataStream.length,
159
- ts: c
171
+ ts: d
160
172
  });
161
173
  } else {
162
- if (En.includes(s.nodeName.toLowerCase()))
174
+ if (Cn.includes(a.nodeName.toLowerCase()))
163
175
  continue;
164
- if (s.nodeType === Node.ELEMENT_NODE) {
165
- const a = e ? this._styleCache.get(e) : {}, c = this._styleRules.find(({ filter: h }) => Nt(s, h)), d = c ? c.getStyle(s) : pt(s);
166
- this._styleCache.set(s, { ...a, ...d });
167
- const { childNodes: p } = s;
168
- this._process(s, p, o);
169
- const g = this._afterProcessRules.find(
170
- ({ filter: h }) => Nt(s, h)
176
+ if (a.nodeType === Node.ELEMENT_NODE) {
177
+ const c = e ? this._styleCache.get(e) : {}, d = this._styleRules.find(({ filter: l }) => Nt(a, l)), g = d ? d.getStyle(a) : gt(a);
178
+ this._styleCache.set(a, { ...c, ...g });
179
+ const { childNodes: h } = a;
180
+ this._process(a, h, o);
181
+ const p = this._afterProcessRules.find(
182
+ ({ filter: l }) => Nt(a, l)
171
183
  );
172
- g && g.handler(o, s);
184
+ p && p.handler(o, a);
173
185
  }
174
186
  }
175
187
  }
176
188
  };
177
- E(Fe, "_pluginList", []);
189
+ C(Fe, "_pluginList", []);
178
190
  let ce = Fe;
179
- const Go = {
191
+ const Vo = {
180
192
  name: "univer-doc-paste-plugin-lark",
181
- checkPasteType(n) {
182
- return /lark-record-clipboard/i.test(n);
193
+ checkPasteType(t) {
194
+ return /lark-record-clipboard/i.test(t);
183
195
  },
184
196
  // TODO: @JOCS, support inline code copy from lark.
185
197
  stylesRules: [
186
198
  {
187
199
  filter: ["s"],
188
- getStyle(n) {
189
- const e = pt(n);
200
+ getStyle(t) {
201
+ const e = gt(t);
190
202
  return {
191
203
  st: {
192
204
  s: S.TRUE
@@ -198,173 +210,164 @@ const Go = {
198
210
  ],
199
211
  afterProcessRules: [
200
212
  {
201
- filter(n) {
202
- return n.tagName === "DIV" && /ace-line/i.test(n.className);
213
+ filter(t) {
214
+ return t.tagName === "DIV" && /ace-line/i.test(t.className);
203
215
  },
204
- handler(n) {
205
- n.paragraphs == null && (n.paragraphs = []), n.paragraphs.push({
206
- startIndex: n.dataStream.length
207
- }), n.dataStream += "\r";
216
+ handler(t) {
217
+ t.paragraphs == null && (t.paragraphs = []), t.paragraphs.push({
218
+ startIndex: t.dataStream.length
219
+ }), t.dataStream += "\r";
208
220
  }
209
221
  }
210
222
  ]
211
- }, Yo = Go;
212
- function ln(n) {
213
- const e = n.style, t = {};
223
+ }, jo = Vo;
224
+ function ln(t) {
225
+ const e = t.style, n = {};
214
226
  for (let o = 0; o < e.length; o++) {
215
- const i = e[o], r = e.getPropertyValue(i);
216
- switch (i) {
227
+ const r = e[o], i = e.getPropertyValue(r);
228
+ switch (r) {
217
229
  case "margin-top": {
218
- const s = Number.parseInt(r);
219
- t.spaceAbove = /pt/.test(r) ? It(s) : s;
230
+ const s = Number.parseInt(i);
231
+ n.spaceAbove = { v: /pt/.test(i) ? Tt(s) : s };
220
232
  break;
221
233
  }
222
234
  case "margin-bottom": {
223
- const s = Number.parseInt(r);
224
- t.spaceBelow = /pt/.test(r) ? It(s) : s;
235
+ const s = Number.parseInt(i);
236
+ n.spaceBelow = { v: /pt/.test(i) ? Tt(s) : s };
225
237
  break;
226
238
  }
227
239
  case "line-height": {
228
- const s = Number.parseFloat(r);
229
- t.lineSpacing = s;
240
+ const s = Number.parseFloat(i);
241
+ n.lineSpacing = s;
230
242
  break;
231
243
  }
232
244
  }
233
245
  }
234
- return Object.getOwnPropertyNames(t).length ? t : null;
246
+ return Object.getOwnPropertyNames(n).length ? n : null;
235
247
  }
236
- const Xo = {
248
+ const Wo = {
237
249
  name: "univer-doc-paste-plugin-word",
238
- checkPasteType(n) {
239
- return /word|mso/i.test(n);
250
+ checkPasteType(t) {
251
+ return /word|mso/i.test(t);
240
252
  },
241
253
  stylesRules: [
242
254
  {
243
255
  filter: ["b"],
244
- getStyle(n) {
245
- const e = pt(n);
256
+ getStyle(t) {
257
+ const e = gt(t);
246
258
  return { bl: S.TRUE, ...e };
247
259
  }
248
260
  }
249
261
  ],
250
262
  afterProcessRules: [
251
263
  {
252
- filter(n) {
253
- return n.tagName === "P";
264
+ filter(t) {
265
+ return t.tagName === "P";
254
266
  },
255
- handler(n, e) {
256
- n.paragraphs == null && (n.paragraphs = []);
257
- const t = {
258
- startIndex: n.dataStream.length
267
+ handler(t, e) {
268
+ t.paragraphs == null && (t.paragraphs = []);
269
+ const n = {
270
+ startIndex: t.dataStream.length
259
271
  }, o = ln(e);
260
- o && (t.paragraphStyle = o), n.paragraphs.push(t), n.dataStream += "\r";
272
+ o && (n.paragraphStyle = o), t.paragraphs.push(n), t.dataStream += "\r";
261
273
  }
262
274
  }
263
275
  ]
264
- }, Ko = Xo, Zo = {
276
+ }, ko = Wo, Go = {
265
277
  name: "univer-doc-paste-plugin-univer",
266
- checkPasteType(n) {
267
- return /UniverNormal/i.test(n);
278
+ checkPasteType(t) {
279
+ return /UniverNormal/i.test(t);
268
280
  },
269
281
  stylesRules: [],
270
282
  afterProcessRules: [
271
283
  {
272
- filter(n) {
273
- return n.tagName === "P" && /UniverNormal/i.test(n.className);
284
+ filter(t) {
285
+ return t.tagName === "P" && /UniverNormal/i.test(t.className);
274
286
  },
275
- handler(n, e) {
276
- n.paragraphs == null && (n.paragraphs = []);
277
- const t = {
278
- startIndex: n.dataStream.length
287
+ handler(t, e) {
288
+ t.paragraphs == null && (t.paragraphs = []);
289
+ const n = {
290
+ startIndex: t.dataStream.length
279
291
  }, o = ln(e);
280
- o && (t.paragraphStyle = o), n.paragraphs.push(t), n.dataStream += "\r";
292
+ o && (n.paragraphStyle = o), t.paragraphs.push(n), t.dataStream += "\r";
281
293
  }
282
294
  }
283
295
  ]
284
- }, qo = Zo;
285
- function Lt(n, e) {
286
- const { st: t, ed: o, ts: i = {} } = e, { ff: r, fs: s, it: a, bl: c, ul: d, st: p, ol: g, bg: h, cl: l, va: f } = i;
287
- let u = n.slice(t, o);
288
- const _ = [];
289
- return a === S.TRUE && (u = `<i>${u}</i>`), f === ae.SUPERSCRIPT ? u = `<sup>${u}</sup>` : f === ae.SUBSCRIPT && (u = `<sub>${u}</sub>`), (d == null ? void 0 : d.s) === S.TRUE && (u = `<u>${u}</u>`), (p == null ? void 0 : p.s) === S.TRUE && (u = `<s>${u}</s>`), c === S.TRUE && (u = `<strong>${u}</strong>`), r && _.push(`font-family: ${r}`), l && _.push(`color: ${l.rgb}`), s && _.push(`font-size: ${s}pt`), g && _.push("text-decoration: overline"), h && _.push(`background: ${h.rgb}`), _.length ? `<span style="${_.join("; ")};">${u}</span>` : u;
296
+ }, zo = Go;
297
+ function Ft(t, e) {
298
+ const { st: n, ed: o, ts: r = {} } = e, { ff: i, fs: s, it: a, bl: c, ul: d, st: g, ol: h, bg: p, cl: l, va: _ } = r;
299
+ let u = t.slice(n, o);
300
+ const f = [];
301
+ return a === S.TRUE && (u = `<i>${u}</i>`), _ === ae.SUPERSCRIPT ? u = `<sup>${u}</sup>` : _ === ae.SUBSCRIPT && (u = `<sub>${u}</sub>`), (d == null ? void 0 : d.s) === S.TRUE && (u = `<u>${u}</u>`), (g == null ? void 0 : g.s) === S.TRUE && (u = `<s>${u}</s>`), c === S.TRUE && (u = `<strong>${u}</strong>`), i && f.push(`font-family: ${i}`), l && f.push(`color: ${l.rgb}`), s && f.push(`font-size: ${s}pt`), h && f.push("text-decoration: overline"), p && f.push(`background: ${p.rgb}`), f.length ? `<span style="${f.join("; ")};">${u}</span>` : u;
290
302
  }
291
- function Ke(n, e, t) {
292
- const { dataStream: o, textRuns: i = [] } = n;
293
- let r = e;
303
+ function Ke(t, e, n) {
304
+ const { dataStream: o, textRuns: r = [] } = t;
305
+ let i = e;
294
306
  const s = [];
295
- for (const a of i) {
307
+ for (const a of r) {
296
308
  const { st: c, ed: d } = a;
297
- ee.hasIntersectionBetweenTwoRanges(e, t, c, d) && (c > r ? (s.push(o.slice(r, c)), s.push(Lt(o, {
309
+ j.hasIntersectionBetweenTwoRanges(e, n, c, d) && (c > i ? (s.push(o.slice(i, c)), s.push(Ft(o, {
298
310
  ...a,
299
- ed: Math.min(d, t)
300
- }))) : s.push(Lt(o, {
311
+ ed: Math.min(d, n)
312
+ }))) : s.push(Ft(o, {
301
313
  ...a,
302
- st: r,
303
- ed: Math.min(d, t)
304
- }))), r = Math.max(e, Math.min(d, t));
314
+ st: i,
315
+ ed: Math.min(d, n)
316
+ }))), i = Math.max(e, Math.min(d, n));
305
317
  }
306
- return r !== t && s.push(o.slice(r, t)), s.join("");
318
+ return i !== n && s.push(o.slice(i, n)), s.join("");
307
319
  }
308
- function Ut(n, e = !0) {
309
- var t;
310
- if (e && ((t = n.paragraphs) != null && t.length)) {
311
- const { dataStream: o, paragraphs: i = [] } = n;
312
- let r = "", s = -1;
313
- for (const a of i) {
314
- const { startIndex: c, paragraphStyle: d = {} } = a, { spaceAbove: p, spaceBelow: g, lineSpacing: h } = d, l = [];
315
- p != null && (typeof p == "number" ? l.push(`margin-top: ${p}px`) : l.push(`margin-top: ${p.v}px`)), g != null && (typeof g == "number" ? l.push(`margin-bottom: ${g}px`) : l.push(`margin-bottom: ${g.v}px`)), h != null && l.push(`line-height: ${h}`), c > s + 1 ? r += `<p class="UniverNormal" ${l.length ? `style="${l.join("; ")};"` : ""}>${Ke(n, s + 1, c)}</p>` : r += `<p class="UniverNormal" ${l.length ? `style="${l.join("; ")};"` : ""}></p>`, s = c;
320
+ function Ut(t, e = !0) {
321
+ var n;
322
+ if (e && ((n = t.paragraphs) != null && n.length)) {
323
+ const { dataStream: o, paragraphs: r = [] } = t;
324
+ let i = "", s = -1;
325
+ for (const a of r) {
326
+ const { startIndex: c, paragraphStyle: d = {} } = a, { spaceAbove: g, spaceBelow: h, lineSpacing: p } = d, l = [];
327
+ g != null && (typeof g == "number" ? l.push(`margin-top: ${g}px`) : l.push(`margin-top: ${g.v}px`)), h != null && (typeof h == "number" ? l.push(`margin-bottom: ${h}px`) : l.push(`margin-bottom: ${h.v}px`)), p != null && l.push(`line-height: ${p}`), c > s + 1 ? i += `<p class="UniverNormal" ${l.length ? `style="${l.join("; ")};"` : ""}>${Ke(t, s + 1, c)}</p>` : i += `<p class="UniverNormal" ${l.length ? `style="${l.join("; ")};"` : ""}></p>`, s = c;
316
328
  }
317
- return s !== o.length && (r += Ke(n, s, o.length)), r;
329
+ return s !== o.length && (i += Ke(t, s, o.length)), i;
318
330
  } else
319
- return Ke(n, 0, n.dataStream.length);
331
+ return Ke(t, 0, t.dataStream.length);
320
332
  }
321
- class Jo {
333
+ class Yo {
322
334
  convert(e) {
323
335
  if (e.length === 0)
324
336
  throw new Error("The bodyList length at least to be 1");
325
337
  if (e.length === 1)
326
338
  return Ut(e[0]);
327
- let t = "";
339
+ let n = "";
328
340
  for (const o of e)
329
- t += '<p className="UniverNormal">', t += Ut(o, !1), t += "</p>";
330
- return t;
341
+ n += '<p className="UniverNormal">', n += Ut(o, !1), n += "</p>";
342
+ return n;
331
343
  }
332
344
  }
333
- var Qo = Object.defineProperty, ei = Object.getOwnPropertyDescriptor, ti = (n, e, t, o) => {
334
- for (var i = o > 1 ? void 0 : o ? ei(e, t) : e, r = n.length - 1, s; r >= 0; r--)
335
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
336
- return o && i && Qo(e, t, i), i;
337
- }, he = (n, e) => (t, o) => e(t, o, n);
338
- ce.use(Ko);
339
- ce.use(Yo);
340
- ce.use(qo);
341
- function ni(n) {
342
- const e = n.replace(/\n/g, "\r"), t = [];
343
- for (let o = 0; o < e.length; o++)
344
- e[o] === "\r" && t.push({ startIndex: o });
345
- return {
346
- dataStream: e,
347
- paragraphs: t
348
- };
349
- }
350
- const Ce = qn("doc.clipboard-service");
351
- let ot = class extends K {
352
- constructor(e, t, o, i, r) {
345
+ var Xo = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, Zo = (t, e, n, o) => {
346
+ for (var r = o > 1 ? void 0 : o ? Ko(e, n) : e, i = t.length - 1, s; i >= 0; i--)
347
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
348
+ return o && r && Xo(e, n, r), r;
349
+ }, re = (t, e) => (n, o) => e(n, o, t);
350
+ ce.use(ko);
351
+ ce.use(jo);
352
+ ce.use(zo);
353
+ const Re = En("doc.clipboard-service");
354
+ let nt = class extends Q {
355
+ constructor(e, n, o, r, i, s) {
353
356
  super();
354
- E(this, "_clipboardHooks", []);
355
- E(this, "_htmlToUDM", new ce());
356
- E(this, "_umdToHtml", new Jo());
357
- this._univerInstanceService = e, this._logService = t, this._commandService = o, this._clipboardInterfaceService = i, this._textSelectionManagerService = r;
358
- }
359
- async copy() {
360
- const e = this._getDocumentBodyInRanges();
361
- if (e.length === 0)
357
+ C(this, "_clipboardHooks", []);
358
+ C(this, "_htmlToUDM", new ce());
359
+ C(this, "_umdToHtml", new Yo());
360
+ this._univerInstanceService = e, this._logService = n, this._commandService = o, this._clipboardInterfaceService = r, this._textSelectionManagerService = i, this._docCustomRangeService = s;
361
+ }
362
+ async copy(e = mt.copy) {
363
+ const n = this._getDocumentBodyInRanges(e);
364
+ if (n.length === 0)
362
365
  return !1;
363
366
  try {
364
- const t = this._textSelectionManagerService.getActiveRange(), o = !!(t != null && t.segmentId);
365
- this._setClipboardData(e, !o);
366
- } catch (t) {
367
- return this._logService.error("[DocClipboardService] copy failed", t), !1;
367
+ const o = this._textSelectionManagerService.getActiveRange(), r = !!(o != null && o.segmentId);
368
+ this._setClipboardData(n, !r);
369
+ } catch (o) {
370
+ return this._logService.error("[DocClipboardService] copy failed", o), !1;
368
371
  }
369
372
  return !0;
370
373
  }
@@ -372,28 +375,28 @@ let ot = class extends K {
372
375
  return this._cut();
373
376
  }
374
377
  async paste(e) {
375
- const t = await this._generateBodyFromClipboardItems(e);
376
- return this._paste(t);
378
+ const n = await this._generateBodyFromClipboardItems(e);
379
+ return this._paste(n);
377
380
  }
378
- async legacyPaste(e, t) {
379
- const o = this._generateBodyFromHtmlAndText(e, t);
381
+ async legacyPaste(e, n) {
382
+ const o = this._generateBodyFromHtmlAndText(e, n);
380
383
  return this._paste(o);
381
384
  }
382
385
  async _cut() {
383
- var r;
386
+ var i;
384
387
  const {
385
388
  segmentId: e,
386
- endOffset: t,
389
+ endOffset: n,
387
390
  style: o
388
- } = (r = this._textSelectionManagerService.getActiveRange()) != null ? r : {}, i = this._textSelectionManagerService.getSelections();
389
- if (e == null && this._logService.error("[DocClipboardController] segmentId is not existed"), t == null || i == null)
391
+ } = (i = this._textSelectionManagerService.getActiveRange()) != null ? i : {}, r = this._textSelectionManagerService.getCurrentSelections();
392
+ if (e == null && this._logService.error("[DocClipboardController] segmentId is not existed"), n == null || r == null)
390
393
  return !1;
391
- this.copy();
394
+ this.copy(mt.cut);
392
395
  try {
393
- let s = t;
394
- for (const c of i) {
395
- const { startOffset: d, endOffset: p } = c;
396
- d == null || p == null || p <= t && (s -= p - d);
396
+ let s = n;
397
+ for (const c of r) {
398
+ const { startOffset: d, endOffset: g } = c;
399
+ d == null || g == null || g <= n && (s -= g - d);
397
400
  }
398
401
  const a = [
399
402
  {
@@ -408,167 +411,198 @@ let ot = class extends K {
408
411
  }
409
412
  }
410
413
  async _paste(e) {
411
- let t = Tn(e);
412
- this._clipboardHooks.forEach((c) => {
413
- c.onBeforePaste && (t = c.onBeforePaste(t));
414
- });
415
- const o = this._textSelectionManagerService.getActiveRange(), { segmentId: i, endOffset: r, style: s } = o || {}, a = this._textSelectionManagerService.getSelections();
416
- if (i == null && this._logService.error("[DocClipboardController] segmentId does not exist!"), r == null || a == null)
414
+ var d, g;
415
+ let n = Tn(e);
416
+ const o = (d = this._univerInstanceService.getCurrentUnitForType(v.UNIVER_DOC)) == null ? void 0 : d.getUnitId();
417
+ if (!o)
418
+ return !1;
419
+ this._clipboardHooks.forEach((h) => {
420
+ h.onBeforePaste && (n = h.onBeforePaste(n));
421
+ }), n.customRanges = (g = n.customRanges) == null ? void 0 : g.map((h) => this._docCustomRangeService.copyCustomRange(o, h));
422
+ const r = this._textSelectionManagerService.getActiveRange(), { segmentId: i, endOffset: s, style: a } = r || {}, c = this._textSelectionManagerService.getCurrentSelections();
423
+ if (i == null && this._logService.error("[DocClipboardController] segmentId does not exist!"), s == null || c == null)
417
424
  return !1;
418
425
  try {
419
- let c = r;
420
- for (const p of a) {
421
- const { startOffset: g, endOffset: h } = p;
422
- g == null || h == null || h <= r && (c += t.dataStream.length - (h - g));
426
+ let h = s;
427
+ for (const l of c) {
428
+ const { startOffset: _, endOffset: u } = l;
429
+ _ == null || u == null || u <= s && (h += n.dataStream.length - (u - _));
423
430
  }
424
- const d = [
431
+ const p = [
425
432
  {
426
- startOffset: c,
427
- endOffset: c,
428
- style: s
433
+ startOffset: h,
434
+ endOffset: h,
435
+ style: a
429
436
  }
430
437
  ];
431
- return this._commandService.executeCommand(on.id, { body: t, segmentId: i, textRanges: d });
438
+ return this._commandService.executeCommand(on.id, { body: n, segmentId: i, textRanges: p });
432
439
  } catch {
433
440
  return this._logService.error("[DocClipboardController]", "clipboard is empty."), !1;
434
441
  }
435
442
  }
436
- async _setClipboardData(e, t = !0) {
437
- const o = jo(), i = e.length > 1 ? e.map((s) => s.dataStream).join(`
443
+ async _setClipboardData(e, n = !0) {
444
+ const o = wo(), r = e.length > 1 ? e.map((s) => s.dataStream).join(`
438
445
  `) : e[0].dataStream;
439
- let r = this._umdToHtml.convert(e);
440
- return e.length === 1 && t && (r = r.replace(/(<[a-z]+)/, (s, a) => `${a} data-copy-id="${o}"`), Ft.set(o, e[0])), this._clipboardInterfaceService.write(i, r);
446
+ let i = this._umdToHtml.convert(e);
447
+ return e.length === 1 && n && (i = i.replace(/(<[a-z]+)/, (s, a) => `${a} data-copy-id="${o}"`), At.set(o, e[0])), this._clipboardInterfaceService.write(r, i);
441
448
  }
442
449
  addClipboardHook(e) {
443
- return this._clipboardHooks.push(e), qt(() => {
444
- const t = this._clipboardHooks.indexOf(e);
445
- t > -1 && this._clipboardHooks.splice(t, 1);
450
+ return this._clipboardHooks.push(e), Jt(() => {
451
+ const n = this._clipboardHooks.indexOf(e);
452
+ n > -1 && this._clipboardHooks.splice(n, 1);
446
453
  });
447
454
  }
448
- _getDocumentBodyInRanges() {
449
- const e = this._textSelectionManagerService.getSelections(), t = this._textSelectionManagerService.getActiveRange(), o = this._univerInstanceService.getCurrentUniverDocInstance(), i = [], r = o == null ? void 0 : o.getBody();
450
- if (e == null || o == null || r == null || t == null)
455
+ _getDocumentBodyInRanges(e) {
456
+ const n = this._textSelectionManagerService.getCurrentSelections(), o = this._textSelectionManagerService.getActiveRange(), r = this._univerInstanceService.getCurrentUniverDocInstance(), i = [], s = r == null ? void 0 : r.getBody();
457
+ if (n == null || r == null || s == null || o == null)
451
458
  return i;
452
- const { segmentId: s } = t;
453
- for (const a of e) {
454
- const { startOffset: c, endOffset: d, collapsed: p } = a;
455
- if (p || c == null || d == null)
459
+ const { segmentId: a } = o;
460
+ for (const c of n) {
461
+ const { startOffset: d, endOffset: g, collapsed: h } = c;
462
+ if (h || d == null || g == null)
456
463
  continue;
457
- const g = Qn({ startOffset: c, endOffset: d, collapsed: p }, r), h = o.getSelfOrHeaderFooterModel(s).sliceBody(g.startOffset, g.endOffset);
458
- if (h != null) {
459
- if (h.customRanges) {
460
- const l = [];
461
- h.customRanges.forEach((_) => {
462
- _.startIndex === _.endIndex && l.push(_);
463
- }), h.customRanges = h.customRanges.filter((_) => l.indexOf(_) === -1);
464
- let f = "", u = 0;
465
- l.forEach((_) => {
466
- f += h.dataStream.slice(u, _.endIndex), u = _.endIndex + 1;
467
- }), f += h.dataStream.slice(u, h.dataStream.length), h.dataStream = f;
464
+ const p = Zn({ startOffset: d, endOffset: g, collapsed: h }, s), l = r.getSelfOrHeaderFooterModel(a).sliceBody(p.startOffset, p.endOffset, e);
465
+ if (l != null) {
466
+ if (l.customRanges) {
467
+ const _ = [];
468
+ l.customRanges.forEach((m) => {
469
+ m.startIndex === m.endIndex && _.push(m);
470
+ }), l.customRanges = l.customRanges.filter((m) => _.indexOf(m) === -1);
471
+ let u = "", f = 0;
472
+ _.forEach((m) => {
473
+ u += l.dataStream.slice(f, m.endIndex), f = m.endIndex + 1;
474
+ }), u += l.dataStream.slice(f, l.dataStream.length), l.dataStream = u;
468
475
  }
469
- i.push(h);
476
+ i.push(l);
470
477
  }
471
478
  }
472
479
  return i;
473
480
  }
474
481
  async _generateBodyFromClipboardItems(e) {
475
482
  try {
476
- let t = "", o = "";
477
- for (const i of e)
478
- for (const r of i.types)
479
- r === Nn ? o = await i.getType(r).then((s) => s && s.text()) : r === Ln && (t = await i.getType(r).then((s) => s && s.text()));
480
- return this._generateBodyFromHtmlAndText(t, o);
481
- } catch (t) {
482
- return Promise.reject(t);
483
+ let n = "", o = "";
484
+ for (const r of e)
485
+ for (const i of r.types)
486
+ i === Fn ? o = await r.getType(i).then((s) => s && s.text()) : i === Un && (n = await r.getType(i).then((s) => s && s.text()));
487
+ return this._generateBodyFromHtmlAndText(n, o);
488
+ } catch (n) {
489
+ return Promise.reject(n);
483
490
  }
484
491
  }
485
- _generateBodyFromHtmlAndText(e, t) {
492
+ _generateBody(e) {
493
+ const n = e.replace(/\n/g, "\r");
494
+ if (!e.includes("\r") && j.isLegalUrl(e)) {
495
+ const r = j.generateRandomId(), i = this._univerInstanceService.getCurrentUnitForType(v.UNIVER_DOC), s = this._docCustomRangeService.copyCustomRange(
496
+ i.getUnitId(),
497
+ {
498
+ startIndex: 0,
499
+ endIndex: n.length - 1,
500
+ rangeId: r,
501
+ rangeType: Kt.HYPERLINK,
502
+ data: e
503
+ }
504
+ );
505
+ return {
506
+ dataStream: `${Pe.CUSTOM_RANGE_START}${n}${Pe.CUSTOM_RANGE_END}`,
507
+ customRanges: [s]
508
+ };
509
+ }
510
+ const o = [];
511
+ for (let r = 0; r < n.length; r++)
512
+ n[r] === "\r" && o.push({ startIndex: r });
513
+ return {
514
+ dataStream: n,
515
+ paragraphs: o
516
+ };
517
+ }
518
+ _generateBodyFromHtmlAndText(e, n) {
486
519
  if (!e) {
487
- if (t)
488
- return ni(t);
520
+ if (n)
521
+ return this._generateBody(n);
489
522
  throw new Error("[DocClipboardService] html and text cannot be both empty!");
490
523
  }
491
- const o = Wo(e);
524
+ const o = Bo(e);
492
525
  if (o) {
493
- const i = Ft.get(o);
494
- if (i)
495
- return i;
526
+ const r = At.get(o);
527
+ if (r)
528
+ return r;
496
529
  }
497
530
  return this._htmlToUDM.convert(e);
498
531
  }
499
532
  };
500
- ot = ti([
501
- he(0, L),
502
- he(1, Zt),
503
- he(2, C),
504
- he(3, gt),
505
- he(4, T(ne))
506
- ], ot);
507
- var oi = Object.defineProperty, ii = Object.getOwnPropertyDescriptor, ri = (n, e, t, o) => {
508
- for (var i = o > 1 ? void 0 : o ? ii(e, t) : e, r = n.length - 1, s; r >= 0; r--)
509
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
510
- return o && i && oi(e, t, i), i;
511
- }, Ee = (n, e) => (t, o) => e(t, o, n);
512
- const wt = 1.5;
513
- let it = class extends Oe {
514
- constructor(n, e, t, o, i) {
515
- super(), this._context = n, this._textSelectionManagerService = e, this._editorService = t, this._univerInstanceService = o, this._renderManagerService = i, this._init();
533
+ nt = Zo([
534
+ re(0, w),
535
+ re(1, Zt),
536
+ re(2, O),
537
+ re(3, ut),
538
+ re(4, E(te)),
539
+ re(5, E(Kn))
540
+ ], nt);
541
+ var Jo = Object.defineProperty, qo = Object.getOwnPropertyDescriptor, Qo = (t, e, n, o) => {
542
+ for (var r = o > 1 ? void 0 : o ? qo(e, n) : e, i = t.length - 1, s; i >= 0; i--)
543
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
544
+ return o && r && Jo(e, n, r), r;
545
+ }, Oe = (t, e) => (n, o) => e(n, o, t);
546
+ const Lt = 1.5;
547
+ let ot = class extends Se {
548
+ constructor(t, e, n, o, r) {
549
+ super(), this._context = t, this._textSelectionManagerService = e, this._editorService = n, this._univerInstanceService = o, this._renderManagerService = r, this._init();
516
550
  }
517
551
  _init() {
518
- this._textSelectionManagerService.textSelection$.pipe(se(this.dispose$)).subscribe((n) => {
519
- if (n == null)
552
+ this._textSelectionManagerService.textSelection$.pipe(se(this.dispose$)).subscribe((t) => {
553
+ if (t == null)
520
554
  return;
521
- const { isEditing: e, unitId: t } = n;
522
- e && this._scrollToSelection(t);
555
+ const { isEditing: e, unitId: n } = t;
556
+ e && this._scrollToSelection(n);
523
557
  });
524
558
  }
525
- scrollToRange(n, e) {
559
+ scrollToRange(t, e) {
526
560
  var s;
527
- const t = (s = this._renderManagerService.getRenderById(n)) == null ? void 0 : s.with(N), o = t == null ? void 0 : t.getSkeleton();
561
+ const n = (s = this._renderManagerService.getRenderById(t)) == null ? void 0 : s.with(L), o = n == null ? void 0 : n.getSkeleton();
528
562
  if (!o)
529
563
  return;
530
- const { startOffset: i } = e, r = o.findNodePositionByCharIndex(i);
531
- this.scrollToNode(n, r);
564
+ const { startOffset: r } = e, i = o.findNodePositionByCharIndex(r);
565
+ this.scrollToNode(t, i);
532
566
  }
533
- scrollToNode(n, e) {
534
- var $;
535
- const t = this._getDocObject(), o = ($ = this._renderManagerService.getRenderById(n)) == null ? void 0 : $.with(N), i = o == null ? void 0 : o.getSkeleton();
536
- if (t == null || i == null)
567
+ scrollToNode(t, e) {
568
+ var G;
569
+ const n = this._getDocObject(), o = (G = this._renderManagerService.getRenderById(t)) == null ? void 0 : G.with(L), r = o == null ? void 0 : o.getSkeleton();
570
+ if (n == null || r == null)
537
571
  return;
538
- const r = t.document.getOffsetConfig(), { docsLeft: s, docsTop: a } = r, c = new rn(r, i), { contentBoxPointGroup: d } = c.getRangePointData(e, e), { left: p, top: g, height: h } = Io(d), l = p + s, f = g + a, u = t.scene.getViewport(te.VIEW_MAIN), _ = !!this._editorService.getEditor(n);
572
+ const i = n.document.getOffsetConfig(), { docsLeft: s, docsTop: a } = i, c = new rn(i, r), { contentBoxPointGroup: d } = c.getRangePointData(e, e), { left: g, top: h, height: p } = Co(d), l = g + s, _ = h + a, u = n.scene.getViewport(q.VIEW_MAIN), f = !!this._editorService.getEditor(t);
539
573
  if (u == null)
540
574
  return;
541
575
  const {
542
576
  left: m,
543
- top: O,
544
- right: M,
545
- bottom: I
577
+ top: R,
578
+ right: I,
579
+ bottom: b
546
580
  } = u.getBounding().viewBound;
547
- let R = 0, y = 0;
548
- const j = _ ? 0 : 100;
549
- f < O ? R = f - O - j : f > I - h && (R = f - I + h + j), l < m ? y = l - m : l > M - wt && (y = l - M + wt);
550
- const W = u.transViewportScroll2ScrollValue(y, R);
551
- u.scrollBy(W);
581
+ let T = 0, A = 0;
582
+ const N = f ? 0 : 100;
583
+ _ < R ? T = _ - R - N : _ > b - p && (T = _ - b + p + N), l < m ? A = l - m : l > I - Lt && (A = l - I + Lt);
584
+ const Y = u.transViewportScroll2ScrollValue(A, T);
585
+ u.scrollBy(Y);
552
586
  }
553
587
  // Let the selection show on the current screen.
554
- _scrollToSelection(n) {
588
+ _scrollToSelection(t) {
555
589
  const e = this._textSelectionManagerService.getActiveRange();
556
590
  if (e == null)
557
591
  return;
558
- const { collapsed: t, startNodePosition: o } = e;
559
- t && this.scrollToNode(n, o);
592
+ const { collapsed: n, startNodePosition: o } = e;
593
+ n && this.scrollToNode(t, o);
560
594
  }
561
595
  _getDocObject() {
562
- return eo(this._univerInstanceService, this._renderManagerService);
596
+ return Jn(this._univerInstanceService, this._renderManagerService);
563
597
  }
564
598
  };
565
- it = ri([
566
- Ee(1, T(ne)),
567
- Ee(2, Y),
568
- Ee(3, T(L)),
569
- Ee(4, k)
570
- ], it);
571
- const si = {
599
+ ot = Qo([
600
+ Oe(1, E(te)),
601
+ Oe(2, ee),
602
+ Oe(3, E(w)),
603
+ Oe(4, W)
604
+ ], ot);
605
+ const er = {
572
606
  undo: !0,
573
607
  redo: !0,
574
608
  // Undo redo
@@ -596,7 +630,7 @@ const si = {
596
630
  // 'Wrap mode'
597
631
  textRotateMode: !0
598
632
  // 'Text Rotation Mode'
599
- }, ai = {
633
+ }, tr = {
600
634
  outerLeft: !1,
601
635
  outerRight: !1,
602
636
  header: !0,
@@ -609,83 +643,83 @@ const si = {
609
643
  frozenContent: !1,
610
644
  infoBar: !0,
611
645
  toolbar: !0
612
- }, ci = {
646
+ }, nr = {
613
647
  layout: {
614
- docContainerConfig: ai,
615
- toolbarConfig: si
648
+ docContainerConfig: tr,
649
+ toolbarConfig: er
616
650
  }
617
- }, li = "DocUI", di = {
618
- id: $e.id,
651
+ }, or = "DocUI", rr = {
652
+ id: He.id,
619
653
  binding: H.ARROW_UP,
620
- preconditions: z,
654
+ preconditions: k,
621
655
  staticParameters: {
622
- direction: Z.UP
656
+ direction: K.UP
623
657
  }
624
- }, ui = {
625
- id: $e.id,
658
+ }, ir = {
659
+ id: He.id,
626
660
  binding: H.ARROW_DOWN,
627
- preconditions: z,
661
+ preconditions: k,
628
662
  staticParameters: {
629
- direction: Z.DOWN
663
+ direction: K.DOWN
630
664
  }
631
- }, hi = {
632
- id: $e.id,
665
+ }, sr = {
666
+ id: He.id,
633
667
  binding: H.ARROW_LEFT,
634
- preconditions: z,
668
+ preconditions: k,
635
669
  staticParameters: {
636
- direction: Z.LEFT
670
+ direction: K.LEFT
637
671
  }
638
- }, gi = {
639
- id: $e.id,
672
+ }, ar = {
673
+ id: He.id,
640
674
  binding: H.ARROW_RIGHT,
641
- preconditions: z,
675
+ preconditions: k,
642
676
  staticParameters: {
643
- direction: Z.RIGHT
677
+ direction: K.RIGHT
644
678
  }
645
- }, pi = {
646
- id: He.id,
647
- binding: H.ARROW_UP | Re.SHIFT,
648
- preconditions: z,
679
+ }, cr = {
680
+ id: Ve.id,
681
+ binding: H.ARROW_UP | ve.SHIFT,
682
+ preconditions: k,
649
683
  staticParameters: {
650
- direction: Z.UP
684
+ direction: K.UP
651
685
  }
652
- }, _i = {
653
- id: He.id,
654
- binding: H.ARROW_DOWN | Re.SHIFT,
655
- preconditions: z,
686
+ }, lr = {
687
+ id: Ve.id,
688
+ binding: H.ARROW_DOWN | ve.SHIFT,
689
+ preconditions: k,
656
690
  staticParameters: {
657
- direction: Z.DOWN
691
+ direction: K.DOWN
658
692
  }
659
- }, fi = {
660
- id: He.id,
661
- binding: H.ARROW_LEFT | Re.SHIFT,
662
- preconditions: z,
693
+ }, dr = {
694
+ id: Ve.id,
695
+ binding: H.ARROW_LEFT | ve.SHIFT,
696
+ preconditions: k,
663
697
  staticParameters: {
664
- direction: Z.LEFT
698
+ direction: K.LEFT
665
699
  }
666
- }, mi = {
667
- id: He.id,
668
- binding: H.ARROW_RIGHT | Re.SHIFT,
669
- preconditions: z,
700
+ }, ur = {
701
+ id: Ve.id,
702
+ binding: H.ARROW_RIGHT | ve.SHIFT,
703
+ preconditions: k,
670
704
  staticParameters: {
671
- direction: Z.RIGHT
705
+ direction: K.RIGHT
672
706
  }
673
- }, Si = {
674
- id: to.id,
675
- binding: H.A | Re.CTRL_COMMAND,
676
- preconditions: (n) => n.getContextValue(ht) && (n.getContextValue(Ne) || n.getContextValue(Jt))
707
+ }, hr = {
708
+ id: qn.id,
709
+ binding: H.A | ve.CTRL_COMMAND,
710
+ preconditions: (t) => t.getContextValue(dt) && (t.getContextValue(Ue) || t.getContextValue(qt))
677
711
  };
678
- var vi = Object.defineProperty, Oi = Object.getOwnPropertyDescriptor, Ri = (n, e, t, o) => {
679
- for (var i = o > 1 ? void 0 : o ? Oi(e, t) : e, r = n.length - 1, s; r >= 0; r--)
680
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
681
- return o && i && vi(e, t, i), i;
682
- }, Bt = (n, e) => (t, o) => e(t, o, n);
712
+ var gr = Object.defineProperty, pr = Object.getOwnPropertyDescriptor, _r = (t, e, n, o) => {
713
+ for (var r = o > 1 ? void 0 : o ? pr(e, n) : e, i = t.length - 1, s; i >= 0; i--)
714
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
715
+ return o && r && gr(e, n, r), r;
716
+ }, wt = (t, e) => (n, o) => e(n, o, t);
683
717
  let rt = class {
684
- constructor(n, e, t) {
685
- E(this, "_docContainer");
718
+ constructor(t, e, n) {
719
+ C(this, "_docContainer");
686
720
  // 获取SheetContainer组件
687
- E(this, "getComponent", (n) => {
688
- if (this._docContainer = n, !n.getContentRef().current)
721
+ C(this, "getComponent", (t) => {
722
+ if (this._docContainer = t, !t.getContentRef().current)
689
723
  throw new Error("container is not ready");
690
724
  });
691
725
  /**
@@ -695,10 +729,10 @@ let rt = class {
695
729
  * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
696
730
  *
697
731
  */
698
- E(this, "changeLocale", (n) => {
699
- this._localeService.setLocale(n);
732
+ C(this, "changeLocale", (t) => {
733
+ this._localeService.setLocale(t);
700
734
  });
701
- this._config = n, this._localeService = e, this._injector = t;
735
+ this._config = t, this._localeService = e, this._injector = n;
702
736
  }
703
737
  getUIConfig() {
704
738
  return {
@@ -711,27 +745,27 @@ let rt = class {
711
745
  getContentRef() {
712
746
  return this._docContainer.getContentRef();
713
747
  }
714
- UIDidMount(n) {
748
+ UIDidMount(t) {
715
749
  if (this._docContainer)
716
- return n(this._docContainer);
750
+ return t(this._docContainer);
717
751
  }
718
752
  getDocContainer() {
719
753
  return this._docContainer;
720
754
  }
721
755
  };
722
- rt = Ri([
723
- Bt(1, T(le)),
724
- Bt(2, T(Be))
756
+ rt = _r([
757
+ wt(1, E(le)),
758
+ wt(2, E(Le))
725
759
  ], rt);
726
- var Ci = Object.defineProperty, Ei = Object.getOwnPropertyDescriptor, Ti = (n, e, t, o) => {
727
- for (var i = o > 1 ? void 0 : o ? Ei(e, t) : e, r = n.length - 1, s; r >= 0; r--)
728
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
729
- return o && i && Ci(e, t, i), i;
730
- }, Te = (n, e) => (t, o) => e(t, o, n);
731
- let me = class extends Oe {
732
- constructor(e, t, o, i, r) {
760
+ var fr = Object.defineProperty, mr = Object.getOwnPropertyDescriptor, Sr = (t, e, n, o) => {
761
+ for (var r = o > 1 ? void 0 : o ? mr(e, n) : e, i = t.length - 1, s; i >= 0; i--)
762
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
763
+ return o && r && fr(e, n, r), r;
764
+ }, Ce = (t, e) => (n, o) => e(n, o, t);
765
+ let fe = class extends Se {
766
+ constructor(e, n, o, r, i) {
733
767
  super();
734
- E(this, "_docContainerController");
768
+ C(this, "_docContainerController");
735
769
  /**
736
770
  * Change language
737
771
  * @param {string} locale new language
@@ -739,10 +773,10 @@ let me = class extends Oe {
739
773
  * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
740
774
  *
741
775
  */
742
- E(this, "changeLocale", (e) => {
776
+ C(this, "changeLocale", (e) => {
743
777
  this._localeService.setLocale(e);
744
778
  });
745
- this._localeService = t, this._injector = o, this._textSelectionRenderManager = i, this._layoutService = r, this._docContainerController = this._injector.createInstance(rt, e), this._registerContainer();
779
+ this._localeService = n, this._injector = o, this._textSelectionRenderManager = r, this._layoutService = i, this._docContainerController = this._injector.createInstance(rt, e), this._registerContainer();
746
780
  }
747
781
  _registerContainer() {
748
782
  this._layoutService && this.disposeWithMe(
@@ -754,231 +788,229 @@ let me = class extends Oe {
754
788
  return this._docContainerController;
755
789
  }
756
790
  };
757
- me = Ti([
758
- Te(1, T(le)),
759
- Te(2, T(Be)),
760
- Te(3, oe),
761
- Te(4, Jn(en))
762
- ], me);
763
- const We = "UI_PLUGIN_DOCS", _t = `${We}_COLOR_PICKER_COMPONENT`, dn = `${We}_FONT_FAMILY_COMPONENT`, un = `${We}_FONT_FAMILY_ITEM_COMPONENT`, hn = `${We}_FONT_SIZE_COMPONENT`;
764
- var gn = { exports: {} }, ke = {};
765
- /**
766
- * @license React
767
- * react-jsx-runtime.production.min.js
768
- *
769
- * Copyright (c) Facebook, Inc. and its affiliates.
770
- *
771
- * This source code is licensed under the MIT license found in the
772
- * LICENSE file in the root directory of this source tree.
773
- */
774
- var Ii = Lo, bi = Symbol.for("react.element"), Mi = Symbol.for("react.fragment"), xi = Object.prototype.hasOwnProperty, yi = Ii.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Pi = { key: !0, ref: !0, __self: !0, __source: !0 };
775
- function pn(n, e, t) {
776
- var o, i = {}, r = null, s = null;
777
- t !== void 0 && (r = "" + t), e.key !== void 0 && (r = "" + e.key), e.ref !== void 0 && (s = e.ref);
778
- for (o in e) xi.call(e, o) && !Pi.hasOwnProperty(o) && (i[o] = e[o]);
779
- if (n && n.defaultProps) for (o in e = n.defaultProps, e) i[o] === void 0 && (i[o] = e[o]);
780
- return { $$typeof: bi, type: n, key: r, ref: s, props: i, _owner: yi.current };
781
- }
782
- ke.Fragment = Mi;
783
- ke.jsx = pn;
784
- ke.jsxs = pn;
785
- gn.exports = ke;
786
- var b = gn.exports;
787
- const Di = "univer-docs-ui-canvas-background", Ai = {
788
- docsUiCanvasBackground: Di
789
- }, Fi = () => /* @__PURE__ */ b.jsx("div", { className: Ai.docsUiCanvasBackground }), $t = 18, Ht = 200, Ze = 6, Ni = 4;
790
- function Li(n, e) {
791
- let { radius: t, width: o, height: i } = e;
792
- t = t != null ? t : 0, o = o != null ? o : 30, i = i != null ? i : 30;
793
- let r = 0;
794
- r = Math.min(t, o / 2, i / 2), n.beginPath(), n.moveTo(0, 0), n.lineTo(o, 0), n.lineTo(o, i - r), n.arc(o - r, i - r, r, 0, Math.PI / 2, !1), n.lineTo(0, i), n.lineTo(0, 0), n.closePath(), e.fill && (n.save(), n.fillStyle = e.fill, e.fillRule === "evenodd" ? n.fill("evenodd") : n.fill(), n.restore());
791
+ fe = Sr([
792
+ Ce(1, E(le)),
793
+ Ce(2, E(Le)),
794
+ Ce(3, ne),
795
+ Ce(4, In(en))
796
+ ], fe);
797
+ const We = "UI_PLUGIN_DOCS", pt = `${We}_COLOR_PICKER_COMPONENT`, dn = `${We}_FONT_FAMILY_COMPONENT`, un = `${We}_FONT_FAMILY_ITEM_COMPONENT`, hn = `${We}_FONT_SIZE_COMPONENT`, Bt = 18, $t = 200, Ze = 6, vr = 4;
798
+ function Rr(t, e) {
799
+ let { radius: n, width: o, height: r } = e;
800
+ n = n != null ? n : 0, o = o != null ? o : 30, r = r != null ? r : 30;
801
+ let i = 0;
802
+ i = Math.min(n, o / 2, r / 2), t.beginPath(), t.moveTo(0, 0), t.lineTo(o, 0), t.lineTo(o, r - i), t.arc(o - i, r - i, i, 0, Math.PI / 2, !1), t.lineTo(0, r), t.lineTo(0, 0), t.closePath(), e.fill && (t.save(), t.fillStyle = e.fill, e.fillRule === "evenodd" ? t.fill("evenodd") : t.fill(), t.restore());
795
803
  }
796
- class Ae extends bo {
797
- constructor(t, o) {
798
- super(t, o);
799
- E(this, "color");
800
- E(this, "text");
804
+ class Ne extends Eo {
805
+ constructor(n, o) {
806
+ super(n, o);
807
+ C(this, "color");
808
+ C(this, "text");
801
809
  this.color = o == null ? void 0 : o.color, this.text = o == null ? void 0 : o.text;
802
810
  }
803
- static drawWith(t, o) {
804
- const { text: i, color: r } = o;
805
- t.save(), t.font = "13px Source Han Sans CN";
806
- const s = t.measureText(i).width, a = Math.min(
811
+ static drawWith(n, o) {
812
+ const { text: r, color: i } = o;
813
+ n.save(), n.font = "13px Source Han Sans CN";
814
+ const s = n.measureText(r).width, a = Math.min(
807
815
  s + 2 * Ze,
808
- Ht
816
+ $t
809
817
  );
810
- Li(t, {
811
- height: $t,
818
+ Rr(n, {
819
+ height: Bt,
812
820
  width: a,
813
821
  radius: 4,
814
- fill: r,
822
+ fill: i,
815
823
  evented: !1
816
- }), t.fillStyle = "rgba(58, 96, 247, 1)";
817
- const c = Ze, d = $t - Ni, p = Ht - 2 * Ze;
818
- if (s > p) {
819
- let g = "", h = 0;
820
- for (const l of i) {
821
- const f = t.measureText(l).width;
822
- if (h + f <= p - t.measureText("...").width)
823
- g += l, h += f;
824
+ }), n.fillStyle = "rgba(58, 96, 247, 1)";
825
+ const c = Ze, d = Bt - vr, g = $t - 2 * Ze;
826
+ if (s > g) {
827
+ let h = "", p = 0;
828
+ for (const l of r) {
829
+ const _ = n.measureText(l).width;
830
+ if (p + _ <= g - n.measureText("...").width)
831
+ h += l, p += _;
824
832
  else {
825
- g += "...";
833
+ h += "...";
826
834
  break;
827
835
  }
828
836
  }
829
- t.fillText(g, c, d);
837
+ n.fillText(h, c, d);
830
838
  } else
831
- t.fillText(i, c, d);
832
- t.restore();
839
+ n.fillText(r, c, d);
840
+ n.restore();
833
841
  }
834
- _draw(t) {
835
- Ae.drawWith(t, this);
842
+ _draw(n) {
843
+ Ne.drawWith(n, this);
836
844
  }
837
845
  }
838
- const _n = "COMPONENT_DOC_HEADER_FOOTER_PANEL", Ui = "univer-panel", wi = "univer-options-section", Bi = "univer-options-form-item", $i = "univer-options-input", Hi = "univer-options-margin-setting", B = {
839
- panel: Ui,
840
- optionsSection: wi,
841
- optionsFormItem: Bi,
842
- optionsInput: $i,
843
- optionsMarginSetting: Hi
844
- }, Vi = (n) => {
845
- const e = G(le), t = G(L), o = G(k), i = G(C), r = G(oe), s = G(ne), { unitId: a } = n, [c, d] = an({}), p = (l, f) => {
846
- var j;
847
- d((W) => ({
848
- ...W,
849
- [f]: l ? S.TRUE : S.FALSE
846
+ const gn = "COMPONENT_DOC_HEADER_FOOTER_PANEL";
847
+ var pn = { exports: {} }, ke = {};
848
+ /**
849
+ * @license React
850
+ * react-jsx-runtime.production.min.js
851
+ *
852
+ * Copyright (c) Facebook, Inc. and its affiliates.
853
+ *
854
+ * This source code is licensed under the MIT license found in the
855
+ * LICENSE file in the root directory of this source tree.
856
+ */
857
+ var Or = Po, Cr = Symbol.for("react.element"), Er = Symbol.for("react.fragment"), Tr = Object.prototype.hasOwnProperty, Ir = Or.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, br = { key: !0, ref: !0, __self: !0, __source: !0 };
858
+ function _n(t, e, n) {
859
+ var o, r = {}, i = null, s = null;
860
+ n !== void 0 && (i = "" + n), e.key !== void 0 && (i = "" + e.key), e.ref !== void 0 && (s = e.ref);
861
+ for (o in e) Tr.call(e, o) && !br.hasOwnProperty(o) && (r[o] = e[o]);
862
+ if (t && t.defaultProps) for (o in e = t.defaultProps, e) r[o] === void 0 && (r[o] = e[o]);
863
+ return { $$typeof: Cr, type: t, key: i, ref: s, props: r, _owner: Ir.current };
864
+ }
865
+ ke.Fragment = Er;
866
+ ke.jsx = _n;
867
+ ke.jsxs = _n;
868
+ pn.exports = ke;
869
+ var M = pn.exports;
870
+ const Mr = "univer-panel", yr = "univer-options-section", xr = "univer-options-form-item", Pr = "univer-options-input", Dr = "univer-options-margin-setting", $ = {
871
+ panel: Mr,
872
+ optionsSection: yr,
873
+ optionsFormItem: xr,
874
+ optionsInput: Pr,
875
+ optionsMarginSetting: Dr
876
+ }, Ar = (t) => {
877
+ const e = z(le), n = z(w), o = z(W), r = z(O), i = z(ne), s = z(te), { unitId: a } = t, [c, d] = an({}), g = (l, _) => {
878
+ var N;
879
+ d((Y) => ({
880
+ ...Y,
881
+ [_]: l ? S.TRUE : S.FALSE
850
882
  }));
851
- const u = t.getUniverDocInstance(a), _ = u == null ? void 0 : u.getSnapshot().documentStyle, m = (j = o.getRenderById(a)) == null ? void 0 : j.with(N), O = m == null ? void 0 : m.getViewModel();
852
- if (_ == null || O == null)
883
+ const u = n.getUniverDocInstance(a), f = u == null ? void 0 : u.getSnapshot().documentStyle, m = (N = o.getRenderById(a)) == null ? void 0 : N.with(L), R = m == null ? void 0 : m.getViewModel();
884
+ if (f == null || R == null)
853
885
  return;
854
- const M = O.getEditArea();
855
- let I = !1;
856
- const R = r.getSegmentPage();
857
- let y = !1;
858
- if (f === "useFirstPageHeaderFooter" && l === !0 && ((M === F.HEADER && !_.firstPageHeaderId || M === F.FOOTER && !_.firstPageFooterId) && (I = !0), I && R === 0 && (y = !0)), f === "evenAndOddHeaders" && l === !0 && ((M === F.HEADER && !_.evenPageHeaderId || M === F.FOOTER && !_.evenPageFooterId) && (I = !0), I && R % 2 === 1 && (y = !0)), I) {
859
- const $ = ee.generateRandomId(6);
860
- y && r.setSegment($), i.executeCommand(Me, {
886
+ const I = R.getEditArea();
887
+ let b = !1;
888
+ const T = i.getSegmentPage();
889
+ let A = !1;
890
+ if (_ === "useFirstPageHeaderFooter" && l === !0 && ((I === F.HEADER && !f.firstPageHeaderId || I === F.FOOTER && !f.firstPageFooterId) && (b = !0), b && T === 0 && (A = !0)), _ === "evenAndOddHeaders" && l === !0 && ((I === F.HEADER && !f.evenPageHeaderId || I === F.FOOTER && !f.evenPageFooterId) && (b = !0), b && T % 2 === 1 && (A = !0)), b) {
891
+ const G = j.generateRandomId(6);
892
+ A && i.setSegment(G), r.executeCommand(be, {
861
893
  unitId: a,
862
- segmentId: $,
894
+ segmentId: G,
863
895
  headerFooterProps: {
864
- [f]: l ? S.TRUE : S.FALSE
896
+ [_]: l ? S.TRUE : S.FALSE
865
897
  }
866
898
  });
867
899
  } else
868
- i.executeCommand(Me, {
900
+ r.executeCommand(be, {
869
901
  unitId: a,
870
902
  headerFooterProps: {
871
- [f]: l ? S.TRUE : S.FALSE
903
+ [_]: l ? S.TRUE : S.FALSE
872
904
  }
873
905
  });
874
- }, g = async (l, f) => {
906
+ }, h = async (l, _) => {
875
907
  d((u) => ({
876
908
  ...u,
877
- [f]: l
878
- })), await i.executeCommand(Me, {
909
+ [_]: l
910
+ })), await r.executeCommand(be, {
879
911
  unitId: a,
880
912
  headerFooterProps: {
881
- [f]: l
913
+ [_]: l
882
914
  }
883
- }), r.removeAllTextRanges(), r.blur();
884
- }, h = () => {
885
- var m, O;
886
- const l = (m = o.getRenderById(a)) == null ? void 0 : m.with(N), f = l == null ? void 0 : l.getSkeleton(), u = l == null ? void 0 : l.getViewModel(), _ = o.getRenderById(a);
887
- _ == null || u == null || f == null || (s.replaceTextRanges([]), r.setSegment(""), r.setSegmentPage(-1), u.setEditArea(F.BODY), f.calculate(), (O = _.mainComponent) == null || O.makeDirty(!0));
915
+ }), i.removeAllTextRanges(), i.blur();
916
+ }, p = () => {
917
+ var m, R;
918
+ const l = (m = o.getRenderById(a)) == null ? void 0 : m.with(L), _ = l == null ? void 0 : l.getSkeleton(), u = l == null ? void 0 : l.getViewModel(), f = o.getRenderById(a);
919
+ f == null || u == null || _ == null || (s.replaceTextRanges([]), i.setSegment(""), i.setSegmentPage(-1), u.setEditArea(F.BODY), _.calculate(), (R = f.mainComponent) == null || R.makeDirty(!0));
888
920
  };
889
921
  return cn(() => {
890
- const l = t.getUniverDocInstance(a), f = l == null ? void 0 : l.getSnapshot().documentStyle;
891
- if (f) {
892
- const { marginHeader: u, marginFooter: _, useFirstPageHeaderFooter: m, evenAndOddHeaders: O } = f;
922
+ const l = n.getUniverDocInstance(a), _ = l == null ? void 0 : l.getSnapshot().documentStyle;
923
+ if (_) {
924
+ const { marginHeader: u, marginFooter: f, useFirstPageHeaderFooter: m, evenAndOddHeaders: R } = _;
893
925
  d({
894
926
  marginHeader: u,
895
- marginFooter: _,
927
+ marginFooter: f,
896
928
  useFirstPageHeaderFooter: m,
897
- evenAndOddHeaders: O
929
+ evenAndOddHeaders: R
898
930
  });
899
931
  }
900
- }, [a]), /* @__PURE__ */ b.jsxs("div", { className: B.options, children: [
901
- /* @__PURE__ */ b.jsxs("div", { className: B.optionsSection, children: [
902
- /* @__PURE__ */ b.jsx("div", { className: B.optionsFormItem, children: /* @__PURE__ */ b.jsx(
903
- Dt,
932
+ }, [a]), /* @__PURE__ */ M.jsxs("div", { className: $.options, children: [
933
+ /* @__PURE__ */ M.jsxs("div", { className: $.optionsSection, children: [
934
+ /* @__PURE__ */ M.jsx("div", { className: $.optionsFormItem, children: /* @__PURE__ */ M.jsx(
935
+ Pt,
904
936
  {
905
937
  checked: c.useFirstPageHeaderFooter === S.TRUE,
906
938
  onChange: (l) => {
907
- p(l, "useFirstPageHeaderFooter");
939
+ g(l, "useFirstPageHeaderFooter");
908
940
  },
909
941
  children: e.t("headerFooter.firstPageCheckBox")
910
942
  }
911
943
  ) }),
912
- /* @__PURE__ */ b.jsx("div", { className: B.optionsFormItem, children: /* @__PURE__ */ b.jsx(
913
- Dt,
944
+ /* @__PURE__ */ M.jsx("div", { className: $.optionsFormItem, children: /* @__PURE__ */ M.jsx(
945
+ Pt,
914
946
  {
915
947
  checked: c.evenAndOddHeaders === S.TRUE,
916
948
  onChange: (l) => {
917
- p(l, "evenAndOddHeaders");
949
+ g(l, "evenAndOddHeaders");
918
950
  },
919
951
  children: e.t("headerFooter.oddEvenCheckBox")
920
952
  }
921
953
  ) })
922
954
  ] }),
923
- /* @__PURE__ */ b.jsxs("div", { className: Bo(B.optionsSection, B.optionsMarginSetting), children: [
924
- /* @__PURE__ */ b.jsxs("div", { className: B.optionsMarginItem, children: [
925
- /* @__PURE__ */ b.jsx("span", { children: e.t("headerFooter.headerTopMargin") }),
926
- /* @__PURE__ */ b.jsx(
927
- At,
955
+ /* @__PURE__ */ M.jsxs("div", { className: No($.optionsSection, $.optionsMarginSetting), children: [
956
+ /* @__PURE__ */ M.jsxs("div", { className: $.optionsMarginItem, children: [
957
+ /* @__PURE__ */ M.jsx("span", { children: e.t("headerFooter.headerTopMargin") }),
958
+ /* @__PURE__ */ M.jsx(
959
+ Dt,
928
960
  {
929
961
  min: 0,
930
962
  max: 200,
931
963
  precision: 1,
932
964
  value: c.marginHeader,
933
965
  onChange: (l) => {
934
- g(l, "marginHeader");
966
+ h(l, "marginHeader");
935
967
  },
936
- className: B.optionsInput
968
+ className: $.optionsInput
937
969
  }
938
970
  )
939
971
  ] }),
940
- /* @__PURE__ */ b.jsxs("div", { className: B.optionsMarginItem, children: [
941
- /* @__PURE__ */ b.jsx("span", { children: e.t("headerFooter.footerBottomMargin") }),
942
- /* @__PURE__ */ b.jsx(
943
- At,
972
+ /* @__PURE__ */ M.jsxs("div", { className: $.optionsMarginItem, children: [
973
+ /* @__PURE__ */ M.jsx("span", { children: e.t("headerFooter.footerBottomMargin") }),
974
+ /* @__PURE__ */ M.jsx(
975
+ Dt,
944
976
  {
945
977
  min: 0,
946
978
  max: 200,
947
979
  precision: 1,
948
980
  value: c.marginFooter,
949
981
  onChange: (l) => {
950
- g(l, "marginFooter");
982
+ h(l, "marginFooter");
951
983
  },
952
- className: B.optionsInput
984
+ className: $.optionsInput
953
985
  }
954
986
  )
955
987
  ] })
956
988
  ] }),
957
- /* @__PURE__ */ b.jsx("div", { className: B.optionsSection, children: /* @__PURE__ */ b.jsx(Uo, { onClick: h, children: e.t("headerFooter.closeHeaderFooter") }) })
989
+ /* @__PURE__ */ M.jsx("div", { className: $.optionsSection, children: /* @__PURE__ */ M.jsx(Do, { onClick: p, children: e.t("headerFooter.closeHeaderFooter") }) })
958
990
  ] });
959
- }, ji = () => {
991
+ }, Nr = () => {
960
992
  var d;
961
- const n = G(le), e = G(k), i = G(L).getCurrentUniverDocInstance().getUnitId(), s = ((d = e.getRenderById(i)) == null ? void 0 : d.with(N)).getViewModel(), [a, c] = an(!0);
993
+ const t = z(le), e = z(W), r = z(w).getCurrentUniverDocInstance().getUnitId(), s = ((d = e.getRenderById(r)) == null ? void 0 : d.with(L)).getViewModel(), [a, c] = an(!0);
962
994
  return cn(() => {
963
- const p = s.getEditArea();
964
- c(p !== F.BODY);
965
- const g = s.editAreaChange$.subscribe((h) => {
966
- h != null && c(h !== F.BODY);
995
+ const g = s.getEditArea();
996
+ c(g !== F.BODY);
997
+ const h = s.editAreaChange$.subscribe((p) => {
998
+ p != null && c(p !== F.BODY);
967
999
  });
968
1000
  return () => {
969
- g.unsubscribe();
1001
+ h.unsubscribe();
970
1002
  };
971
- }, []), /* @__PURE__ */ b.jsx("div", { className: B.panel, children: a ? /* @__PURE__ */ b.jsx(Vi, { unitId: i }) : /* @__PURE__ */ b.jsx("div", { className: B.panelDisableText, children: n.t("headerFooter.disableText") }) });
1003
+ }, []), /* @__PURE__ */ M.jsx("div", { className: $.panel, children: a ? /* @__PURE__ */ M.jsx(Ar, { unitId: r }) : /* @__PURE__ */ M.jsx("div", { className: $.panelDisableText, children: t.t("headerFooter.disableText") }) });
972
1004
  }, fn = {
973
1005
  id: "sidebar.operation.doc-header-footer-panel",
974
1006
  type: de.COMMAND,
975
- handler: async (n, e) => {
976
- const t = n.get(Un), o = n.get(le);
1007
+ handler: async (t, e) => {
1008
+ const n = t.get(Ln), o = t.get(le);
977
1009
  switch (e.value) {
978
1010
  case "open":
979
- t.open({
1011
+ n.open({
980
1012
  header: { title: o.t("headerFooter.panel") },
981
- children: { label: _n },
1013
+ children: { label: gn },
982
1014
  onClose: () => {
983
1015
  },
984
1016
  width: 400
@@ -986,29 +1018,29 @@ const _n = "COMPONENT_DOC_HEADER_FOOTER_PANEL", Ui = "univer-panel", wi = "unive
986
1018
  break;
987
1019
  case "close":
988
1020
  default:
989
- t.close();
1021
+ n.close();
990
1022
  break;
991
1023
  }
992
1024
  return !0;
993
1025
  }
994
1026
  };
995
- var Wi = Object.defineProperty, ki = Object.getOwnPropertyDescriptor, zi = (n, e, t, o) => {
996
- for (var i = o > 1 ? void 0 : o ? ki(e, t) : e, r = n.length - 1, s; r >= 0; r--)
997
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
998
- return o && i && Wi(e, t, i), i;
999
- }, X = (n, e) => (t, o) => e(t, o, n);
1000
- const Vt = "rgba(58, 96, 247, 1)", jt = "rgba(58, 96, 247, 0.08)";
1001
- var U = /* @__PURE__ */ ((n) => (n[n.FIRST_PAGE_HEADER = 0] = "FIRST_PAGE_HEADER", n[n.FIRST_PAGE_FOOTER = 1] = "FIRST_PAGE_FOOTER", n[n.DEFAULT_HEADER = 2] = "DEFAULT_HEADER", n[n.DEFAULT_FOOTER = 3] = "DEFAULT_FOOTER", n[n.EVEN_PAGE_HEADER = 4] = "EVEN_PAGE_HEADER", n[n.EVEN_PAGE_FOOTER = 5] = "EVEN_PAGE_FOOTER", n))(U || {});
1002
- function Gi(n, e, t) {
1003
- const { documentStyle: o } = n.getDataModel().getSnapshot(), {
1004
- defaultHeaderId: i,
1005
- defaultFooterId: r,
1027
+ var Fr = Object.defineProperty, Ur = Object.getOwnPropertyDescriptor, Lr = (t, e, n, o) => {
1028
+ for (var r = o > 1 ? void 0 : o ? Ur(e, n) : e, i = t.length - 1, s; i >= 0; i--)
1029
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
1030
+ return o && r && Fr(e, n, r), r;
1031
+ }, X = (t, e) => (n, o) => e(n, o, t);
1032
+ const Ht = "rgba(58, 96, 247, 1)", Vt = "rgba(58, 96, 247, 0.08)";
1033
+ var U = /* @__PURE__ */ ((t) => (t[t.FIRST_PAGE_HEADER = 0] = "FIRST_PAGE_HEADER", t[t.FIRST_PAGE_FOOTER = 1] = "FIRST_PAGE_FOOTER", t[t.DEFAULT_HEADER = 2] = "DEFAULT_HEADER", t[t.DEFAULT_FOOTER = 3] = "DEFAULT_FOOTER", t[t.EVEN_PAGE_HEADER = 4] = "EVEN_PAGE_HEADER", t[t.EVEN_PAGE_FOOTER = 5] = "EVEN_PAGE_FOOTER", t))(U || {});
1034
+ function wr(t, e, n) {
1035
+ const { documentStyle: o } = t.getDataModel().getSnapshot(), {
1036
+ defaultHeaderId: r,
1037
+ defaultFooterId: i,
1006
1038
  evenPageHeaderId: s,
1007
1039
  evenPageFooterId: a,
1008
1040
  firstPageHeaderId: c,
1009
1041
  firstPageFooterId: d,
1010
- evenAndOddHeaders: p,
1011
- useFirstPageHeaderFooter: g
1042
+ evenAndOddHeaders: g,
1043
+ useFirstPageHeaderFooter: h
1012
1044
  } = o;
1013
1045
  switch (e) {
1014
1046
  case F.BODY:
@@ -1017,29 +1049,29 @@ function Gi(n, e, t) {
1017
1049
  headerFooterId: null
1018
1050
  };
1019
1051
  case F.HEADER:
1020
- return g === S.TRUE && !c ? {
1052
+ return h === S.TRUE && !c ? {
1021
1053
  createType: 0,
1022
1054
  headerFooterId: null
1023
- } : p === S.TRUE && t % 2 === 0 && !s ? {
1055
+ } : g === S.TRUE && n % 2 === 0 && !s ? {
1024
1056
  createType: 4,
1025
1057
  headerFooterId: null
1026
- } : i ? {
1058
+ } : r ? {
1027
1059
  createType: null,
1028
- headerFooterId: i
1060
+ headerFooterId: r
1029
1061
  } : {
1030
1062
  createType: 2,
1031
1063
  headerFooterId: null
1032
1064
  };
1033
1065
  case F.FOOTER:
1034
- return g === S.TRUE && !d ? {
1066
+ return h === S.TRUE && !d ? {
1035
1067
  createType: 1,
1036
1068
  headerFooterId: null
1037
- } : p === S.TRUE && t % 2 === 0 && !a ? {
1069
+ } : g === S.TRUE && n % 2 === 0 && !a ? {
1038
1070
  createType: 5,
1039
1071
  headerFooterId: null
1040
- } : r ? {
1072
+ } : i ? {
1041
1073
  createType: null,
1042
- headerFooterId: r
1074
+ headerFooterId: i
1043
1075
  } : {
1044
1076
  createType: 3,
1045
1077
  headerFooterId: null
@@ -1048,134 +1080,134 @@ function Gi(n, e, t) {
1048
1080
  throw new Error(`Invalid editArea: ${e}`);
1049
1081
  }
1050
1082
  }
1051
- let st = class extends K {
1052
- constructor(e, t, o, i, r, s, a, c, d) {
1083
+ let it = class extends Q {
1084
+ constructor(e, n, o, r, i, s, a, c, d) {
1053
1085
  super();
1054
- E(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
1055
- this._context = e, this._commandService = t, this._editorService = o, this._instanceSrv = i, this._renderManagerService = r, this._docSkeletonManagerService = s, this._textSelectionRenderManager = a, this._localeService = c, this._componentManager = d, this._initialize();
1086
+ C(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
1087
+ this._context = e, this._commandService = n, this._editorService = o, this._instanceSrv = r, this._renderManagerService = i, this._docSkeletonManagerService = s, this._textSelectionRenderManager = a, this._localeService = c, this._componentManager = d, this._initialize();
1056
1088
  }
1057
1089
  _initialize() {
1058
- this._context.unit.getSnapshot().documentStyle.documentFlavor === In.TRADITIONAL && (this._init(), this._drawHeaderFooterLabel(), this._registerCommands(), this._initCustomComponents());
1090
+ this._context.unit.getSnapshot().documentStyle.documentFlavor === bn.TRADITIONAL && (this._init(), this._drawHeaderFooterLabel(), this._registerCommands(), this._initCustomComponents());
1059
1091
  }
1060
1092
  _registerCommands() {
1061
1093
  [
1062
- kt,
1094
+ Wt,
1063
1095
  mn,
1064
1096
  fn
1065
1097
  ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
1066
1098
  }
1067
1099
  _initCustomComponents() {
1068
1100
  const e = this._componentManager;
1069
- this.disposeWithMe(e.register(_n, ji));
1101
+ this.disposeWithMe(e.register(gn, Nr));
1070
1102
  }
1071
1103
  _init() {
1072
- const { unitId: e } = this._context, t = Q(this._context);
1073
- t == null || t.document == null || this._loadedMap.has(t.document) || (this._initialMain(e), this._loadedMap.add(t.document));
1104
+ const { unitId: e } = this._context, n = J(this._context);
1105
+ n == null || n.document == null || this._loadedMap.has(n.document) || (this._initialMain(e), this._loadedMap.add(n.document));
1074
1106
  }
1075
1107
  _initialMain(e) {
1076
- const t = Q(this._context), { document: o } = t;
1077
- this.disposeWithMe(o.onDblclick$.subscribeEvent(async (i) => {
1108
+ const n = J(this._context), { document: o } = n;
1109
+ this.disposeWithMe(o.onDblclick$.subscribeEvent(async (r) => {
1078
1110
  if (this._isEditorReadOnly(e))
1079
1111
  return;
1080
- const { offsetX: r, offsetY: s } = i, {
1081
- pageLayoutType: a = De.VERTICAL,
1112
+ const { offsetX: i, offsetY: s } = r, {
1113
+ pageLayoutType: a = Ae.VERTICAL,
1082
1114
  pageMarginLeft: c,
1083
1115
  pageMarginTop: d
1084
- } = o.getOffsetConfig(), p = this._getTransformCoordForDocumentOffset(r, s);
1085
- if (p == null)
1116
+ } = o.getOffsetConfig(), g = this._getTransformCoordForDocumentOffset(i, s);
1117
+ if (g == null)
1086
1118
  return;
1087
- const g = this._docSkeletonManagerService.getViewModel(), h = this._docSkeletonManagerService.getSkeleton(), l = g.getEditArea(), { editArea: f, pageNumber: u } = h.findEditAreaByCoord(
1088
- p,
1119
+ const h = this._docSkeletonManagerService.getViewModel(), p = this._docSkeletonManagerService.getSkeleton(), l = h.getEditArea(), { editArea: _, pageNumber: u } = p.findEditAreaByCoord(
1120
+ g,
1089
1121
  a,
1090
1122
  c,
1091
1123
  d
1092
1124
  );
1093
- if (l === f)
1125
+ if (l === _)
1094
1126
  return;
1095
- g.setEditArea(f);
1096
- const { createType: _, headerFooterId: m } = Gi(g, f, u);
1097
- if (f === F.BODY)
1098
- this._textSelectionRenderManager.setSegment(""), this._textSelectionRenderManager.setSegmentPage(-1), this._textSelectionRenderManager.setCursorManually(r, s);
1099
- else if (_ != null) {
1100
- const M = ee.generateRandomId(6);
1101
- this._textSelectionRenderManager.setSegment(M), this._textSelectionRenderManager.setSegmentPage(u), await this._commandService.executeCommand(kt.id, {
1127
+ h.setEditArea(_);
1128
+ const { createType: f, headerFooterId: m } = wr(h, _, u);
1129
+ if (_ === F.BODY)
1130
+ this._textSelectionRenderManager.setSegment(""), this._textSelectionRenderManager.setSegmentPage(-1), this._textSelectionRenderManager.setCursorManually(i, s);
1131
+ else if (f != null) {
1132
+ const I = j.generateRandomId(6);
1133
+ this._textSelectionRenderManager.setSegment(I), this._textSelectionRenderManager.setSegmentPage(u), await this._commandService.executeCommand(Wt.id, {
1102
1134
  unitId: e,
1103
- createType: _,
1104
- segmentId: M
1135
+ createType: f,
1136
+ segmentId: I
1105
1137
  });
1106
- } else m != null && (this._textSelectionRenderManager.setSegment(m), this._textSelectionRenderManager.setSegmentPage(u), this._textSelectionRenderManager.setCursorManually(r, s));
1138
+ } else m != null && (this._textSelectionRenderManager.setSegment(m), this._textSelectionRenderManager.setSegmentPage(u), this._textSelectionRenderManager.setCursorManually(i, s));
1107
1139
  }));
1108
1140
  }
1109
- _getTransformCoordForDocumentOffset(e, t) {
1110
- const o = Q(this._context), { document: i, scene: r } = o, { documentTransform: s } = i.getOffsetConfig(), a = r.getViewports()[0];
1141
+ _getTransformCoordForDocumentOffset(e, n) {
1142
+ const o = J(this._context), { document: r, scene: i } = o, { documentTransform: s } = r.getOffsetConfig(), a = i.getViewports()[0];
1111
1143
  if (a == null)
1112
1144
  return;
1113
- const c = a.transformVector2SceneCoord(sn.FromArray([e, t]));
1145
+ const c = a.transformVector2SceneCoord(sn.FromArray([e, n]));
1114
1146
  return s.clone().invert().applyPoint(c);
1115
1147
  }
1116
1148
  // eslint-disable-next-line max-lines-per-function
1117
1149
  _drawHeaderFooterLabel() {
1118
1150
  const e = this._localeService;
1119
- this._renderManagerService.currentRender$.subscribe((t) => {
1120
- if (t == null)
1151
+ this._renderManagerService.currentRender$.subscribe((n) => {
1152
+ if (n == null)
1121
1153
  return;
1122
- const o = this._renderManagerService.getRenderById(t);
1123
- if (this._editorService.isEditor(t) || this._instanceSrv.getUniverDocInstance(t) == null || o == null)
1154
+ const o = this._renderManagerService.getRenderById(n);
1155
+ if (this._editorService.isEditor(n) || this._instanceSrv.getUniverDocInstance(n) == null || o == null)
1124
1156
  return;
1125
- const { mainComponent: i } = o, r = i;
1157
+ const { mainComponent: r } = o, i = r;
1126
1158
  this.disposeWithMe(
1127
- qt(
1159
+ Jt(
1128
1160
  // eslint-disable-next-line max-lines-per-function
1129
- r.pageRender$.subscribe((s) => {
1130
- if (this._editorService.isEditor(t))
1161
+ i.pageRender$.subscribe((s) => {
1162
+ if (this._editorService.isEditor(n))
1131
1163
  return;
1132
- const d = this._docSkeletonManagerService.getViewModel().getEditArea() === F.BODY, { page: p, pageLeft: g, pageTop: h, ctx: l } = s, { pageWidth: f, pageHeight: u, marginTop: _, marginBottom: m } = p;
1133
- if (l.save(), l.translate(g - 0.5, h - 0.5), d ? (Xe.drawWith(l, {
1164
+ const d = this._docSkeletonManagerService.getViewModel().getEditArea() === F.BODY, { page: g, pageLeft: h, pageTop: p, ctx: l } = s, { pageWidth: _, pageHeight: u, marginTop: f, marginBottom: m } = g;
1165
+ if (l.save(), l.translate(h - 0.5, p - 0.5), d ? (Xe.drawWith(l, {
1134
1166
  left: 0,
1135
1167
  top: 0,
1136
- width: f,
1137
- height: _,
1168
+ width: _,
1169
+ height: f,
1138
1170
  fill: "rgba(255, 255, 255, 0.5)"
1139
1171
  }), l.save(), l.translate(0, u - m), Xe.drawWith(l, {
1140
1172
  left: 0,
1141
1173
  top: 0,
1142
- width: f,
1174
+ width: _,
1143
1175
  height: m,
1144
1176
  fill: "rgba(255, 255, 255, 0.5)"
1145
- }), l.restore()) : (l.save(), l.translate(0, _), Xe.drawWith(l, {
1177
+ }), l.restore()) : (l.save(), l.translate(0, f), Xe.drawWith(l, {
1146
1178
  left: 0,
1147
- top: _,
1148
- width: f,
1149
- height: u - _ - m,
1179
+ top: f,
1180
+ width: _,
1181
+ height: u - f - m,
1150
1182
  fill: "rgba(255, 255, 255, 0.5)"
1151
1183
  }), l.restore()), !d) {
1152
- const O = {
1184
+ const R = {
1153
1185
  dataArray: [{
1154
1186
  command: "M",
1155
- points: [0, _]
1187
+ points: [0, f]
1156
1188
  }, {
1157
1189
  command: "L",
1158
- points: [f, _]
1190
+ points: [_, f]
1159
1191
  }],
1160
1192
  strokeWidth: 1,
1161
- stroke: Vt
1162
- }, M = {
1193
+ stroke: Ht
1194
+ }, I = {
1163
1195
  dataArray: [{
1164
1196
  command: "M",
1165
1197
  points: [0, u - m]
1166
1198
  }, {
1167
1199
  command: "L",
1168
- points: [f, u - m]
1200
+ points: [_, u - m]
1169
1201
  }],
1170
1202
  strokeWidth: 1,
1171
- stroke: Vt
1203
+ stroke: Ht
1172
1204
  };
1173
- bt.drawWith(l, O), bt.drawWith(l, M), l.translate(0, _ + 1), Ae.drawWith(l, {
1205
+ It.drawWith(l, R), It.drawWith(l, I), l.translate(0, f + 1), Ne.drawWith(l, {
1174
1206
  text: e.t("headerFooter.header"),
1175
- color: jt
1176
- }), l.translate(0, u - _ - m), Ae.drawWith(l, {
1207
+ color: Vt
1208
+ }), l.translate(0, u - f - m), Ne.drawWith(l, {
1177
1209
  text: e.t("headerFooter.footer"),
1178
- color: jt
1210
+ color: Vt
1179
1211
  });
1180
1212
  }
1181
1213
  l.restore();
@@ -1185,24 +1217,24 @@ let st = class extends K {
1185
1217
  });
1186
1218
  }
1187
1219
  _isEditorReadOnly(e) {
1188
- const t = this._editorService.getEditor(e);
1189
- return t ? t.isReadOnly() : !1;
1220
+ const n = this._editorService.getEditor(e);
1221
+ return n ? n.isReadOnly() : !1;
1190
1222
  }
1191
1223
  _getDocDataModel() {
1192
1224
  return this._context.unit;
1193
1225
  }
1194
1226
  };
1195
- st = zi([
1196
- X(1, C),
1197
- X(2, Y),
1198
- X(3, L),
1199
- X(4, k),
1200
- X(5, T(N)),
1201
- X(6, oe),
1202
- X(7, T(le)),
1203
- X(8, T(tn))
1204
- ], st);
1205
- function Wt() {
1227
+ it = Lr([
1228
+ X(1, O),
1229
+ X(2, ee),
1230
+ X(3, w),
1231
+ X(4, W),
1232
+ X(5, E(L)),
1233
+ X(6, ne),
1234
+ X(7, E(le)),
1235
+ X(8, E(tn))
1236
+ ], it);
1237
+ function jt() {
1206
1238
  return {
1207
1239
  dataStream: `\r
1208
1240
  `,
@@ -1214,12 +1246,15 @@ function Wt() {
1214
1246
  // The default header footer text size.
1215
1247
  }
1216
1248
  }],
1249
+ customBlocks: [],
1217
1250
  paragraphs: [
1218
1251
  {
1219
1252
  startIndex: 0,
1220
- spaceAbove: 0,
1221
- lineSpacing: 1.5,
1222
- spaceBelow: 0
1253
+ paragraphStyle: {
1254
+ spaceAbove: { v: 0 },
1255
+ lineSpacing: 1.5,
1256
+ spaceBelow: { v: 0 }
1257
+ }
1223
1258
  }
1224
1259
  ],
1225
1260
  sectionBreaks: [
@@ -1229,293 +1264,293 @@ function Wt() {
1229
1264
  ]
1230
1265
  };
1231
1266
  }
1232
- function qe(n, e, t, o) {
1233
- const i = et.getInstance(), r = 6, s = n != null ? n : ee.generateRandomId(r), a = e === U.DEFAULT_HEADER || e === U.FIRST_PAGE_HEADER || e === U.EVEN_PAGE_HEADER, c = i.insertOp([a ? "headers" : "footers", s], {
1267
+ function Je(t, e, n, o) {
1268
+ const r = Qe.getInstance(), i = 6, s = t != null ? t : j.generateRandomId(i), a = e === U.DEFAULT_HEADER || e === U.FIRST_PAGE_HEADER || e === U.EVEN_PAGE_HEADER, c = r.insertOp([a ? "headers" : "footers", s], {
1234
1269
  [a ? "headerId" : "footerId"]: s,
1235
- body: Wt()
1270
+ body: jt()
1236
1271
  });
1237
1272
  o.push(c);
1238
- const d = ee.generateRandomId(r), p = i.insertOp([a ? "footers" : "headers", d], {
1273
+ const d = j.generateRandomId(i), g = r.insertOp([a ? "footers" : "headers", d], {
1239
1274
  [a ? "footers" : "headers"]: d,
1240
- body: Wt()
1275
+ body: jt()
1241
1276
  });
1242
- o.push(p);
1243
- let g = "defaultHeaderId", h = "defaultFooterId";
1277
+ o.push(g);
1278
+ let h = "defaultHeaderId", p = "defaultFooterId";
1244
1279
  switch (e) {
1245
1280
  case U.DEFAULT_HEADER:
1246
- g = "defaultHeaderId", h = "defaultFooterId";
1281
+ h = "defaultHeaderId", p = "defaultFooterId";
1247
1282
  break;
1248
1283
  case U.DEFAULT_FOOTER:
1249
- g = "defaultFooterId", h = "defaultHeaderId";
1284
+ h = "defaultFooterId", p = "defaultHeaderId";
1250
1285
  break;
1251
1286
  case U.FIRST_PAGE_HEADER:
1252
- g = "firstPageHeaderId", h = "firstPageFooterId";
1287
+ h = "firstPageHeaderId", p = "firstPageFooterId";
1253
1288
  break;
1254
1289
  case U.FIRST_PAGE_FOOTER:
1255
- g = "firstPageFooterId", h = "firstPageHeaderId";
1290
+ h = "firstPageFooterId", p = "firstPageHeaderId";
1256
1291
  break;
1257
1292
  case U.EVEN_PAGE_HEADER:
1258
- g = "evenPageHeaderId", h = "evenPageFooterId";
1293
+ h = "evenPageHeaderId", p = "evenPageFooterId";
1259
1294
  break;
1260
1295
  case U.EVEN_PAGE_FOOTER:
1261
- g = "evenPageFooterId", h = "evenPageHeaderId";
1296
+ h = "evenPageFooterId", p = "evenPageHeaderId";
1262
1297
  break;
1263
1298
  default:
1264
1299
  throw new Error(`Unknown header footer type: ${e}`);
1265
1300
  }
1266
- for (const [l, f] of [[g, s], [h, d]])
1267
- if (t[l] != null) {
1268
- const u = i.replaceOp(["documentStyle", l], t[l], f);
1301
+ for (const [l, _] of [[h, s], [p, d]])
1302
+ if (n[l] != null) {
1303
+ const u = r.replaceOp(["documentStyle", l], n[l], _);
1269
1304
  o.push(u);
1270
1305
  } else {
1271
- const u = i.insertOp(["documentStyle", l], f);
1306
+ const u = r.insertOp(["documentStyle", l], _);
1272
1307
  o.push(u);
1273
1308
  }
1274
1309
  return o;
1275
1310
  }
1276
- const Me = "doc.command.core-header-footer", kt = {
1277
- id: Me,
1311
+ const be = "doc.command.core-header-footer", Wt = {
1312
+ id: be,
1278
1313
  type: de.COMMAND,
1279
1314
  // eslint-disable-next-line max-lines-per-function
1280
- handler: async (n, e) => {
1281
- var I;
1282
- const t = n.get(C), o = n.get(L), i = n.get(k), { unitId: r, segmentId: s, createType: a, headerFooterProps: c } = e, d = (I = i.getRenderById(r)) == null ? void 0 : I.with(N), p = o.getUniverDocInstance(r), g = d == null ? void 0 : d.getViewModel();
1283
- if (p == null || g == null)
1315
+ handler: async (t, e) => {
1316
+ var b;
1317
+ const n = t.get(O), o = t.get(w), r = t.get(W), { unitId: i, segmentId: s, createType: a, headerFooterProps: c } = e, d = (b = r.getRenderById(i)) == null ? void 0 : b.with(L), g = o.getUniverDocInstance(i), h = d == null ? void 0 : d.getViewModel();
1318
+ if (g == null || h == null)
1284
1319
  return !1;
1285
- const h = g.getEditArea(), { documentStyle: l } = p.getSnapshot(), f = (c == null ? void 0 : c.marginFooter) != null || (c == null ? void 0 : c.marginHeader) != null, u = [{
1320
+ const p = h.getEditArea(), { documentStyle: l } = g.getSnapshot(), _ = (c == null ? void 0 : c.marginFooter) != null || (c == null ? void 0 : c.marginHeader) != null, u = [{
1286
1321
  startOffset: 0,
1287
1322
  endOffset: 0,
1288
1323
  collapsed: !0
1289
- }], _ = {
1290
- id: Ve.id,
1324
+ }], f = {
1325
+ id: ht.id,
1291
1326
  params: {
1292
- unitId: r,
1327
+ unitId: i,
1293
1328
  actions: [],
1294
1329
  textRanges: u,
1295
1330
  debounce: !0
1296
1331
  }
1297
1332
  };
1298
- f && (_.params.noNeedSetTextRange = !0);
1299
- const m = et.getInstance(), O = [];
1300
- return a != null && qe(s, a, l, O), c != null && Object.keys(c).forEach((R) => {
1301
- const y = c[R], j = l[R];
1302
- if (y === j)
1333
+ _ && (f.params.noNeedSetTextRange = !0);
1334
+ const m = Qe.getInstance(), R = [];
1335
+ return a != null && Je(s, a, l, R), c != null && Object.keys(c).forEach((T) => {
1336
+ const A = c[T], N = l[T];
1337
+ if (A === N)
1303
1338
  return;
1304
- let W;
1305
- if (j === void 0 ? W = m.insertOp(["documentStyle", R], y) : W = m.replaceOp(["documentStyle", R], j, y), O.push(W), R === "useFirstPageHeaderFooter" && y === S.TRUE && !l.firstPageHeaderId) {
1306
- const $ = h === F.HEADER ? U.FIRST_PAGE_HEADER : U.FIRST_PAGE_FOOTER;
1307
- qe(s, $, l, O);
1308
- } else if (R === "evenAndOddHeaders" && y === S.TRUE && !l.evenPageHeaderId) {
1309
- const $ = h === F.HEADER ? U.EVEN_PAGE_HEADER : U.EVEN_PAGE_FOOTER;
1310
- qe(s, $, l, O);
1339
+ let Y;
1340
+ if (N === void 0 ? Y = m.insertOp(["documentStyle", T], A) : Y = m.replaceOp(["documentStyle", T], N, A), R.push(Y), T === "useFirstPageHeaderFooter" && A === S.TRUE && !l.firstPageHeaderId) {
1341
+ const G = p === F.HEADER ? U.FIRST_PAGE_HEADER : U.FIRST_PAGE_FOOTER;
1342
+ Je(s, G, l, R);
1343
+ } else if (T === "evenAndOddHeaders" && A === S.TRUE && !l.evenPageHeaderId) {
1344
+ const G = p === F.HEADER ? U.EVEN_PAGE_HEADER : U.EVEN_PAGE_FOOTER;
1345
+ Je(s, G, l, R);
1311
1346
  }
1312
- }), O.length === 0 ? !1 : (_.params.actions = O.reduce((R, y) => et.compose(R, y), null), !!t.syncExecuteCommand(_.id, _.params));
1347
+ }), R.length === 0 ? !1 : (f.params.actions = R.reduce((T, A) => Qe.compose(T, A), null), !!n.syncExecuteCommand(f.id, f.params));
1313
1348
  }
1314
1349
  }, mn = {
1315
1350
  id: "doc.command.open-header-footer-panel",
1316
1351
  type: de.COMMAND,
1317
- handler: async (n, e) => n.get(C).executeCommand(fn.id, { value: "open" })
1352
+ handler: async (t, e) => t.get(O).executeCommand(fn.id, { value: "open" })
1318
1353
  };
1319
- function Yi(n) {
1320
- const e = n.get(C);
1354
+ function Br(t) {
1355
+ const e = t.get(O);
1321
1356
  return {
1322
- id: no.id,
1323
- group: P.TOOLBAR_FORMAT,
1324
- type: x.BUTTON,
1357
+ id: Qn.id,
1358
+ group: x.TOOLBAR_FORMAT,
1359
+ type: y.BUTTON,
1325
1360
  icon: "BoldSingle",
1326
1361
  title: "Set bold",
1327
1362
  tooltip: "toolbar.bold",
1328
- positions: [D.TOOLBAR_START],
1329
- activated$: new w((t) => {
1330
- const o = e.onCommandExecuted((i) => {
1363
+ positions: [P.TOOLBAR_START],
1364
+ activated$: new B((n) => {
1365
+ const o = e.onCommandExecuted((r) => {
1331
1366
  var s;
1332
- const r = i.id;
1333
- if (r === V.id || r === ue.id) {
1334
- const a = q(n);
1367
+ const i = r.id;
1368
+ if (i === V.id || i === ue.id) {
1369
+ const a = Z(t);
1335
1370
  if (a == null)
1336
1371
  return;
1337
1372
  const c = (s = a.ts) == null ? void 0 : s.bl;
1338
- t.next(c === S.TRUE);
1373
+ n.next(c === S.TRUE);
1339
1374
  }
1340
1375
  });
1341
- return t.next(!1), o.dispose;
1376
+ return n.next(!1), o.dispose;
1342
1377
  }),
1343
- hidden$: A(n, v.UNIVER_DOC)
1378
+ hidden$: D(t, v.UNIVER_DOC)
1344
1379
  };
1345
1380
  }
1346
- function Xi(n) {
1347
- const e = n.get(C);
1381
+ function $r(t) {
1382
+ const e = t.get(O);
1348
1383
  return {
1349
- id: oo.id,
1350
- group: P.TOOLBAR_FORMAT,
1351
- type: x.BUTTON,
1384
+ id: eo.id,
1385
+ group: x.TOOLBAR_FORMAT,
1386
+ type: y.BUTTON,
1352
1387
  icon: "ItalicSingle",
1353
1388
  title: "Set italic",
1354
1389
  tooltip: "toolbar.italic",
1355
- positions: [D.TOOLBAR_START],
1356
- activated$: new w((t) => {
1357
- const o = e.onCommandExecuted((i) => {
1390
+ positions: [P.TOOLBAR_START],
1391
+ activated$: new B((n) => {
1392
+ const o = e.onCommandExecuted((r) => {
1358
1393
  var s;
1359
- const r = i.id;
1360
- if (r === V.id || r === ue.id) {
1361
- const a = q(n);
1394
+ const i = r.id;
1395
+ if (i === V.id || i === ue.id) {
1396
+ const a = Z(t);
1362
1397
  if (a == null)
1363
1398
  return;
1364
1399
  const c = (s = a.ts) == null ? void 0 : s.it;
1365
- t.next(c === S.TRUE);
1400
+ n.next(c === S.TRUE);
1366
1401
  }
1367
1402
  });
1368
- return t.next(!1), o.dispose;
1403
+ return n.next(!1), o.dispose;
1369
1404
  }),
1370
- hidden$: A(n, v.UNIVER_DOC)
1405
+ hidden$: D(t, v.UNIVER_DOC)
1371
1406
  };
1372
1407
  }
1373
- function Ki(n) {
1374
- const e = n.get(C);
1408
+ function Hr(t) {
1409
+ const e = t.get(O);
1375
1410
  return {
1376
- id: io.id,
1377
- group: P.TOOLBAR_FORMAT,
1378
- type: x.BUTTON,
1411
+ id: to.id,
1412
+ group: x.TOOLBAR_FORMAT,
1413
+ type: y.BUTTON,
1379
1414
  icon: "UnderlineSingle",
1380
1415
  title: "Set underline",
1381
1416
  tooltip: "toolbar.underline",
1382
- positions: [D.TOOLBAR_START],
1383
- activated$: new w((t) => {
1384
- const o = e.onCommandExecuted((i) => {
1417
+ positions: [P.TOOLBAR_START],
1418
+ activated$: new B((n) => {
1419
+ const o = e.onCommandExecuted((r) => {
1385
1420
  var s;
1386
- const r = i.id;
1387
- if (r === V.id || r === ue.id) {
1388
- const a = q(n);
1421
+ const i = r.id;
1422
+ if (i === V.id || i === ue.id) {
1423
+ const a = Z(t);
1389
1424
  if (a == null)
1390
1425
  return;
1391
1426
  const c = (s = a.ts) == null ? void 0 : s.ul;
1392
- t.next((c == null ? void 0 : c.s) === S.TRUE);
1427
+ n.next((c == null ? void 0 : c.s) === S.TRUE);
1393
1428
  }
1394
1429
  });
1395
- return t.next(!1), o.dispose;
1430
+ return n.next(!1), o.dispose;
1396
1431
  }),
1397
- hidden$: A(n, v.UNIVER_DOC)
1432
+ hidden$: D(t, v.UNIVER_DOC)
1398
1433
  };
1399
1434
  }
1400
- function Zi(n) {
1401
- const e = n.get(C);
1435
+ function Vr(t) {
1436
+ const e = t.get(O);
1402
1437
  return {
1403
- id: ro.id,
1404
- group: P.TOOLBAR_FORMAT,
1405
- type: x.BUTTON,
1438
+ id: no.id,
1439
+ group: x.TOOLBAR_FORMAT,
1440
+ type: y.BUTTON,
1406
1441
  icon: "StrikethroughSingle",
1407
1442
  title: "Set strike through",
1408
1443
  tooltip: "toolbar.strikethrough",
1409
- positions: [D.TOOLBAR_START],
1410
- activated$: new w((t) => {
1411
- const o = e.onCommandExecuted((i) => {
1444
+ positions: [P.TOOLBAR_START],
1445
+ activated$: new B((n) => {
1446
+ const o = e.onCommandExecuted((r) => {
1412
1447
  var s;
1413
- const r = i.id;
1414
- if (r === V.id || r === ue.id) {
1415
- const a = q(n);
1448
+ const i = r.id;
1449
+ if (i === V.id || i === ue.id) {
1450
+ const a = Z(t);
1416
1451
  if (a == null)
1417
1452
  return;
1418
1453
  const c = (s = a.ts) == null ? void 0 : s.st;
1419
- t.next((c == null ? void 0 : c.s) === S.TRUE);
1454
+ n.next((c == null ? void 0 : c.s) === S.TRUE);
1420
1455
  }
1421
1456
  });
1422
- return t.next(!1), o.dispose;
1457
+ return n.next(!1), o.dispose;
1423
1458
  }),
1424
- hidden$: A(n, v.UNIVER_DOC)
1459
+ hidden$: D(t, v.UNIVER_DOC)
1425
1460
  };
1426
1461
  }
1427
- function qi(n) {
1428
- const e = n.get(C);
1462
+ function jr(t) {
1463
+ const e = t.get(O);
1429
1464
  return {
1430
- id: so.id,
1431
- group: P.TOOLBAR_FORMAT,
1432
- type: x.BUTTON,
1465
+ id: oo.id,
1466
+ group: x.TOOLBAR_FORMAT,
1467
+ type: y.BUTTON,
1433
1468
  icon: "SubscriptSingle",
1434
1469
  tooltip: "toolbar.subscript",
1435
- positions: [D.TOOLBAR_START],
1436
- activated$: new w((t) => {
1437
- const o = e.onCommandExecuted((i) => {
1470
+ positions: [P.TOOLBAR_START],
1471
+ activated$: new B((n) => {
1472
+ const o = e.onCommandExecuted((r) => {
1438
1473
  var s;
1439
- const r = i.id;
1440
- if (r === V.id || r === ue.id) {
1441
- const a = q(n);
1474
+ const i = r.id;
1475
+ if (i === V.id || i === ue.id) {
1476
+ const a = Z(t);
1442
1477
  if (a == null)
1443
1478
  return;
1444
1479
  const c = (s = a.ts) == null ? void 0 : s.va;
1445
- t.next(c === ae.SUBSCRIPT);
1480
+ n.next(c === ae.SUBSCRIPT);
1446
1481
  }
1447
1482
  });
1448
- return t.next(!1), o.dispose;
1483
+ return n.next(!1), o.dispose;
1449
1484
  }),
1450
- hidden$: A(n, v.UNIVER_DOC)
1485
+ hidden$: D(t, v.UNIVER_DOC)
1451
1486
  };
1452
1487
  }
1453
- function Ji(n) {
1454
- const e = n.get(C);
1488
+ function Wr(t) {
1489
+ const e = t.get(O);
1455
1490
  return {
1456
- id: ao.id,
1457
- group: P.TOOLBAR_FORMAT,
1458
- type: x.BUTTON,
1491
+ id: ro.id,
1492
+ group: x.TOOLBAR_FORMAT,
1493
+ type: y.BUTTON,
1459
1494
  icon: "SuperscriptSingle",
1460
1495
  tooltip: "toolbar.superscript",
1461
- positions: [D.TOOLBAR_START],
1462
- activated$: new w((t) => {
1463
- const o = e.onCommandExecuted((i) => {
1496
+ positions: [P.TOOLBAR_START],
1497
+ activated$: new B((n) => {
1498
+ const o = e.onCommandExecuted((r) => {
1464
1499
  var s;
1465
- const r = i.id;
1466
- if (r === V.id || r === ue.id) {
1467
- const a = q(n);
1500
+ const i = r.id;
1501
+ if (i === V.id || i === ue.id) {
1502
+ const a = Z(t);
1468
1503
  if (a == null)
1469
1504
  return;
1470
1505
  const c = (s = a.ts) == null ? void 0 : s.va;
1471
- t.next(c === ae.SUPERSCRIPT);
1506
+ n.next(c === ae.SUPERSCRIPT);
1472
1507
  }
1473
1508
  });
1474
- return t.next(!1), o.dispose;
1509
+ return n.next(!1), o.dispose;
1475
1510
  }),
1476
- hidden$: A(n, v.UNIVER_DOC)
1511
+ hidden$: D(t, v.UNIVER_DOC)
1477
1512
  };
1478
1513
  }
1479
- function Qi(n) {
1480
- const e = n.get(C);
1514
+ function kr(t) {
1515
+ const e = t.get(O);
1481
1516
  return {
1482
1517
  id: Rt.id,
1483
1518
  tooltip: "toolbar.font",
1484
- group: P.TOOLBAR_FORMAT,
1485
- type: x.SELECTOR,
1519
+ group: x.TOOLBAR_FORMAT,
1520
+ type: y.SELECTOR,
1486
1521
  label: dn,
1487
- positions: [D.TOOLBAR_START],
1488
- selections: Ot.map((t) => ({
1522
+ positions: [P.TOOLBAR_START],
1523
+ selections: vt.map((n) => ({
1489
1524
  label: {
1490
1525
  name: un,
1491
1526
  hoverable: !0
1492
1527
  },
1493
- value: t.value
1528
+ value: n.value
1494
1529
  })),
1495
1530
  // disabled$: getCurrentSheetDisabled$(accessor),
1496
- value$: new w((t) => {
1497
- const o = Ot[0].value, i = e.onCommandExecuted((r) => {
1531
+ value$: new B((n) => {
1532
+ const o = vt[0].value, r = e.onCommandExecuted((i) => {
1498
1533
  var a;
1499
- const s = r.id;
1534
+ const s = i.id;
1500
1535
  if (s === V.id || s === Rt.id) {
1501
- const c = q(n);
1536
+ const c = Z(t);
1502
1537
  if (c == null)
1503
1538
  return;
1504
1539
  const d = (a = c.ts) == null ? void 0 : a.ff;
1505
- t.next(d != null ? d : o);
1540
+ n.next(d != null ? d : o);
1506
1541
  }
1507
1542
  });
1508
- return t.next(o), i.dispose;
1543
+ return n.next(o), r.dispose;
1509
1544
  }),
1510
- hidden$: A(n, v.UNIVER_DOC)
1545
+ hidden$: D(t, v.UNIVER_DOC)
1511
1546
  };
1512
1547
  }
1513
- function er(n) {
1514
- const e = n.get(C);
1548
+ function Gr(t) {
1549
+ const e = t.get(O);
1515
1550
  return {
1516
- id: Ct.id,
1517
- group: P.TOOLBAR_FORMAT,
1518
- type: x.SELECTOR,
1551
+ id: Ot.id,
1552
+ group: x.TOOLBAR_FORMAT,
1553
+ type: y.SELECTOR,
1519
1554
  tooltip: "toolbar.fontSize",
1520
1555
  label: {
1521
1556
  name: hn,
@@ -1525,423 +1560,412 @@ function er(n) {
1525
1560
  // disabled$,
1526
1561
  }
1527
1562
  },
1528
- positions: [D.TOOLBAR_START],
1563
+ positions: [P.TOOLBAR_START],
1529
1564
  selections: wn,
1530
1565
  // disabled$,
1531
- value$: new w((t) => {
1532
- const i = e.onCommandExecuted((r) => {
1566
+ value$: new B((n) => {
1567
+ const r = e.onCommandExecuted((i) => {
1533
1568
  var a;
1534
- const s = r.id;
1535
- if (s === V.id || s === Ct.id) {
1536
- const c = q(n);
1569
+ const s = i.id;
1570
+ if (s === V.id || s === Ot.id) {
1571
+ const c = Z(t);
1537
1572
  if (c == null)
1538
1573
  return;
1539
1574
  const d = (a = c.ts) == null ? void 0 : a.fs;
1540
- t.next(d != null ? d : 14);
1575
+ n.next(d != null ? d : 14);
1541
1576
  }
1542
1577
  });
1543
- return t.next(14), i.dispose;
1578
+ return n.next(14), r.dispose;
1544
1579
  }),
1545
- hidden$: A(n, v.UNIVER_DOC)
1580
+ hidden$: D(t, v.UNIVER_DOC)
1546
1581
  };
1547
1582
  }
1548
- function tr(n) {
1549
- const e = n.get(C), t = n.get(Qt);
1583
+ function zr(t) {
1584
+ const e = t.get(O), n = t.get(Qt);
1550
1585
  return {
1551
- id: Et.id,
1586
+ id: Ct.id,
1552
1587
  icon: "FontColor",
1553
1588
  tooltip: "toolbar.textColor.main",
1554
- group: P.TOOLBAR_FORMAT,
1555
- type: x.BUTTON_SELECTOR,
1556
- positions: [D.TOOLBAR_START],
1589
+ group: x.TOOLBAR_FORMAT,
1590
+ type: y.BUTTON_SELECTOR,
1591
+ positions: [P.TOOLBAR_START],
1557
1592
  selections: [
1558
1593
  {
1559
1594
  label: {
1560
- name: _t,
1595
+ name: pt,
1561
1596
  hoverable: !1
1562
1597
  }
1563
1598
  }
1564
1599
  ],
1565
- value$: new w((o) => {
1566
- const i = t.getCurrentTheme().textColor, r = e.onCommandExecuted((s) => {
1567
- if (s.id === Et.id) {
1600
+ value$: new B((o) => {
1601
+ const r = n.getCurrentTheme().textColor, i = e.onCommandExecuted((s) => {
1602
+ if (s.id === Ct.id) {
1568
1603
  const a = s.params.value;
1569
- o.next(a != null ? a : i);
1604
+ o.next(a != null ? a : r);
1570
1605
  }
1571
1606
  });
1572
- return o.next(i), r.dispose;
1607
+ return o.next(r), i.dispose;
1573
1608
  }),
1574
- hidden$: A(n, v.UNIVER_DOC)
1609
+ hidden$: D(t, v.UNIVER_DOC)
1575
1610
  // disabled$: getCurrentSheetDisabled$(accessor),
1576
1611
  };
1577
1612
  }
1578
- function nr(n) {
1613
+ function Yr(t) {
1579
1614
  return {
1580
1615
  id: mn.id,
1581
- group: P.TOOLBAR_OTHERS,
1582
- type: x.BUTTON,
1616
+ group: x.TOOLBAR_OTHERS,
1617
+ type: y.BUTTON,
1583
1618
  icon: "FreezeRowSingle",
1584
1619
  tooltip: "toolbar.headerFooter",
1585
- positions: [D.TOOLBAR_START],
1586
- hidden$: Ao(A(n, v.UNIVER_DOC), Bn(n), (e, t) => e || t)
1620
+ positions: [P.TOOLBAR_START],
1621
+ hidden$: yo(D(t, v.UNIVER_DOC), Bn(t), (e, n) => e || n)
1587
1622
  };
1588
1623
  }
1589
- function or(n) {
1590
- const e = n.get(C);
1624
+ function Xr(t) {
1625
+ const e = t.get(O);
1591
1626
  return {
1592
- id: co.id,
1593
- group: P.TOOLBAR_LAYOUT,
1594
- type: x.BUTTON,
1627
+ id: io.id,
1628
+ group: x.TOOLBAR_LAYOUT,
1629
+ type: y.BUTTON,
1595
1630
  icon: "LeftJustifyingSingle",
1596
1631
  tooltip: "toolbar.alignLeft",
1597
- positions: [D.TOOLBAR_START],
1598
- activated$: new w((t) => {
1599
- const o = e.onCommandExecuted((i) => {
1632
+ positions: [P.TOOLBAR_START],
1633
+ activated$: new B((n) => {
1634
+ const o = e.onCommandExecuted((r) => {
1600
1635
  var s;
1601
- const r = i.id;
1602
- if (r === V.id || r === je.id) {
1603
- const a = ze(n);
1636
+ const i = r.id;
1637
+ if (i === V.id || i === je.id) {
1638
+ const a = Ge(t);
1604
1639
  if (a == null)
1605
1640
  return;
1606
1641
  const c = (s = a.paragraphStyle) == null ? void 0 : s.horizontalAlign;
1607
- t.next(c === Le.LEFT);
1642
+ n.next(c === we.LEFT);
1608
1643
  }
1609
1644
  });
1610
- return t.next(!1), o.dispose;
1645
+ return n.next(!1), o.dispose;
1611
1646
  }),
1612
- hidden$: A(n, v.UNIVER_DOC)
1647
+ hidden$: D(t, v.UNIVER_DOC)
1613
1648
  };
1614
1649
  }
1615
- function ir(n) {
1616
- const e = n.get(C);
1650
+ function Kr(t) {
1651
+ const e = t.get(O);
1617
1652
  return {
1618
- id: lo.id,
1619
- group: P.TOOLBAR_LAYOUT,
1620
- type: x.BUTTON,
1653
+ id: so.id,
1654
+ group: x.TOOLBAR_LAYOUT,
1655
+ type: y.BUTTON,
1621
1656
  icon: "HorizontallySingle",
1622
1657
  tooltip: "toolbar.alignCenter",
1623
- positions: [D.TOOLBAR_START],
1624
- activated$: new w((t) => {
1625
- const o = e.onCommandExecuted((i) => {
1658
+ positions: [P.TOOLBAR_START],
1659
+ activated$: new B((n) => {
1660
+ const o = e.onCommandExecuted((r) => {
1626
1661
  var s;
1627
- const r = i.id;
1628
- if (r === V.id || r === je.id) {
1629
- const a = ze(n);
1662
+ const i = r.id;
1663
+ if (i === V.id || i === je.id) {
1664
+ const a = Ge(t);
1630
1665
  if (a == null)
1631
1666
  return;
1632
1667
  const c = (s = a.paragraphStyle) == null ? void 0 : s.horizontalAlign;
1633
- t.next(c === Le.CENTER);
1668
+ n.next(c === we.CENTER);
1634
1669
  }
1635
1670
  });
1636
- return t.next(!1), o.dispose;
1671
+ return n.next(!1), o.dispose;
1637
1672
  }),
1638
- hidden$: A(n, v.UNIVER_DOC)
1673
+ hidden$: D(t, v.UNIVER_DOC)
1639
1674
  };
1640
1675
  }
1641
- function rr(n) {
1642
- const e = n.get(C);
1676
+ function Zr(t) {
1677
+ const e = t.get(O);
1643
1678
  return {
1644
- id: uo.id,
1645
- group: P.TOOLBAR_LAYOUT,
1646
- type: x.BUTTON,
1679
+ id: ao.id,
1680
+ group: x.TOOLBAR_LAYOUT,
1681
+ type: y.BUTTON,
1647
1682
  icon: "RightJustifyingSingle",
1648
1683
  tooltip: "toolbar.alignRight",
1649
- positions: [D.TOOLBAR_START],
1650
- activated$: new w((t) => {
1651
- const o = e.onCommandExecuted((i) => {
1684
+ positions: [P.TOOLBAR_START],
1685
+ activated$: new B((n) => {
1686
+ const o = e.onCommandExecuted((r) => {
1652
1687
  var s;
1653
- const r = i.id;
1654
- if (r === V.id || r === je.id) {
1655
- const a = ze(n);
1688
+ const i = r.id;
1689
+ if (i === V.id || i === je.id) {
1690
+ const a = Ge(t);
1656
1691
  if (a == null)
1657
1692
  return;
1658
1693
  const c = (s = a.paragraphStyle) == null ? void 0 : s.horizontalAlign;
1659
- t.next(c === Le.RIGHT);
1694
+ n.next(c === we.RIGHT);
1660
1695
  }
1661
1696
  });
1662
- return t.next(!1), o.dispose;
1697
+ return n.next(!1), o.dispose;
1663
1698
  }),
1664
- hidden$: A(n, v.UNIVER_DOC)
1699
+ hidden$: D(t, v.UNIVER_DOC)
1665
1700
  };
1666
1701
  }
1667
- function sr(n) {
1668
- const e = n.get(C);
1702
+ function Jr(t) {
1703
+ const e = t.get(O);
1669
1704
  return {
1670
- id: ho.id,
1671
- group: P.TOOLBAR_LAYOUT,
1672
- type: x.BUTTON,
1705
+ id: co.id,
1706
+ group: x.TOOLBAR_LAYOUT,
1707
+ type: y.BUTTON,
1673
1708
  icon: "AlignTextBothSingle",
1674
1709
  tooltip: "toolbar.alignJustify",
1675
- positions: [D.TOOLBAR_START],
1676
- activated$: new w((t) => {
1677
- const o = e.onCommandExecuted((i) => {
1710
+ positions: [P.TOOLBAR_START],
1711
+ activated$: new B((n) => {
1712
+ const o = e.onCommandExecuted((r) => {
1678
1713
  var s;
1679
- const r = i.id;
1680
- if (r === V.id || r === je.id) {
1681
- const a = ze(n);
1714
+ const i = r.id;
1715
+ if (i === V.id || i === je.id) {
1716
+ const a = Ge(t);
1682
1717
  if (a == null)
1683
1718
  return;
1684
1719
  const c = (s = a.paragraphStyle) == null ? void 0 : s.horizontalAlign;
1685
- t.next(c === Le.JUSTIFIED);
1720
+ n.next(c === we.JUSTIFIED);
1686
1721
  }
1687
1722
  });
1688
- return t.next(!1), o.dispose;
1723
+ return n.next(!1), o.dispose;
1689
1724
  }),
1690
- hidden$: A(n, v.UNIVER_DOC)
1725
+ hidden$: D(t, v.UNIVER_DOC)
1691
1726
  };
1692
1727
  }
1693
- function ar(n) {
1728
+ function qr(t) {
1694
1729
  return {
1695
- id: go.id,
1696
- group: P.TOOLBAR_LAYOUT,
1697
- type: x.BUTTON,
1730
+ id: lo.id,
1731
+ group: x.TOOLBAR_LAYOUT,
1732
+ type: y.BUTTON,
1698
1733
  icon: "OrderSingle",
1699
1734
  tooltip: "toolbar.order",
1700
- positions: [D.TOOLBAR_START],
1701
- hidden$: A(n, v.UNIVER_DOC)
1735
+ positions: [P.TOOLBAR_START],
1736
+ hidden$: D(t, v.UNIVER_DOC)
1702
1737
  };
1703
1738
  }
1704
- function cr(n) {
1739
+ function Qr(t) {
1705
1740
  return {
1706
- id: po.id,
1707
- group: P.TOOLBAR_LAYOUT,
1708
- type: x.BUTTON,
1741
+ id: uo.id,
1742
+ group: x.TOOLBAR_LAYOUT,
1743
+ type: y.BUTTON,
1709
1744
  icon: "UnorderSingle",
1710
1745
  tooltip: "toolbar.unorder",
1711
- positions: [D.TOOLBAR_START],
1712
- hidden$: A(n, v.UNIVER_DOC)
1746
+ positions: [P.TOOLBAR_START],
1747
+ hidden$: D(t, v.UNIVER_DOC)
1713
1748
  };
1714
1749
  }
1715
- function lr(n) {
1750
+ function ei(t) {
1716
1751
  return {
1717
- id: _o.id,
1718
- type: x.BUTTON,
1752
+ id: ho.id,
1753
+ type: y.BUTTON,
1719
1754
  title: "toolbar.resetColor",
1720
1755
  icon: "NoColor",
1721
- positions: tt.id
1756
+ positions: et.id
1722
1757
  };
1723
1758
  }
1724
- function dr(n) {
1725
- const e = n.get(C), t = n.get(Qt);
1759
+ function ti(t) {
1760
+ const e = t.get(O), n = t.get(Qt);
1726
1761
  return {
1727
- id: tt.id,
1762
+ id: et.id,
1728
1763
  tooltip: "toolbar.fillColor.main",
1729
- group: P.TOOLBAR_FORMAT,
1730
- type: x.BUTTON_SELECTOR,
1731
- positions: [D.TOOLBAR_START],
1764
+ group: x.TOOLBAR_FORMAT,
1765
+ type: y.BUTTON_SELECTOR,
1766
+ positions: [P.TOOLBAR_START],
1732
1767
  icon: "PaintBucket",
1733
1768
  selections: [
1734
1769
  {
1735
1770
  label: {
1736
- name: _t,
1771
+ name: pt,
1737
1772
  hoverable: !1
1738
1773
  }
1739
1774
  }
1740
1775
  ],
1741
- value$: new w((o) => {
1742
- const i = t.getCurrentTheme().primaryColor, r = e.onCommandExecuted((s) => {
1743
- if (s.id === tt.id) {
1776
+ value$: new B((o) => {
1777
+ const r = n.getCurrentTheme().primaryColor, i = e.onCommandExecuted((s) => {
1778
+ if (s.id === et.id) {
1744
1779
  const a = s.params.value;
1745
- o.next(a != null ? a : i);
1780
+ o.next(a != null ? a : r);
1746
1781
  }
1747
1782
  });
1748
- return o.next(i), r.dispose;
1783
+ return o.next(r), i.dispose;
1749
1784
  }),
1750
- hidden$: A(n, v.UNIVER_DOC)
1785
+ hidden$: D(t, v.UNIVER_DOC)
1751
1786
  };
1752
1787
  }
1753
- function q(n) {
1788
+ function Z(t) {
1754
1789
  var d;
1755
- const e = n.get(L), t = n.get(ne), o = e.getCurrentUniverDocInstance(), i = t.getActiveRange();
1756
- if (o == null || i == null)
1790
+ const e = t.get(w), n = t.get(te), o = e.getCurrentUniverDocInstance(), r = n.getActiveRange();
1791
+ if (o == null || r == null)
1757
1792
  return;
1758
- const { startOffset: r, segmentId: s } = i, a = (d = o.getSelfOrHeaderFooterModel(s).getBody()) == null ? void 0 : d.textRuns;
1793
+ const { startOffset: i, segmentId: s } = r, a = (d = o.getSelfOrHeaderFooterModel(s).getBody()) == null ? void 0 : d.textRuns;
1759
1794
  if (a == null)
1760
1795
  return;
1761
1796
  let c;
1762
- for (let p = 0; p < a.length; p++) {
1763
- const g = a[p], h = a[p + 1];
1764
- if (h && h.st === h.ed && r === h.st) {
1765
- c = h;
1797
+ for (let g = 0; g < a.length; g++) {
1798
+ const h = a[g], p = a[g + 1];
1799
+ if (p && p.st === p.ed && i === p.st) {
1800
+ c = p;
1766
1801
  break;
1767
1802
  }
1768
- if (g.st <= r && r <= g.ed) {
1769
- c = g;
1803
+ if (h.st <= i && i <= h.ed) {
1804
+ c = h;
1770
1805
  break;
1771
1806
  }
1772
1807
  }
1773
1808
  return c;
1774
1809
  }
1775
- function ze(n) {
1810
+ function Ge(t) {
1776
1811
  var d;
1777
- const e = n.get(L), t = n.get(ne), o = e.getCurrentUniverDocInstance(), i = t.getActiveRange();
1778
- if (o == null || i == null)
1812
+ const e = t.get(w), n = t.get(te), o = e.getCurrentUniverDocInstance(), r = n.getActiveRange();
1813
+ if (o == null || r == null)
1779
1814
  return;
1780
- const { startOffset: r, segmentId: s } = i, a = (d = o.getSelfOrHeaderFooterModel(s).getBody()) == null ? void 0 : d.paragraphs;
1815
+ const { startOffset: i, segmentId: s } = r, a = (d = o.getSelfOrHeaderFooterModel(s).getBody()) == null ? void 0 : d.paragraphs;
1781
1816
  if (a == null)
1782
1817
  return;
1783
1818
  let c = -1;
1784
- for (const p of a) {
1785
- const { startIndex: g } = p;
1786
- if (r > c && r <= g)
1787
- return p;
1788
- c = g;
1819
+ for (const g of a) {
1820
+ const { startIndex: h } = g;
1821
+ if (i > c && i <= h)
1822
+ return g;
1823
+ c = h;
1789
1824
  }
1790
1825
  return null;
1791
1826
  }
1792
- var ur = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, gr = (n, e, t, o) => {
1793
- for (var i = o > 1 ? void 0 : o ? hr(e, t) : e, r = n.length - 1, s; r >= 0; r--)
1794
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
1795
- return o && i && ur(e, t, i), i;
1796
- }, J = (n, e) => (t, o) => e(t, o, n);
1797
- let Se = class extends K {
1798
- constructor(n, e, t, o, i, r, s, a) {
1799
- super(), this._config = n, this._injector = e, this._componentManager = t, this._layoutService = o, this._editorService = i, this._menuService = r, this._uiPartsService = s, this._univerInstanceService = a, this._init();
1827
+ var ni = Object.defineProperty, oi = Object.getOwnPropertyDescriptor, ri = (t, e, n, o) => {
1828
+ for (var r = o > 1 ? void 0 : o ? oi(e, n) : e, i = t.length - 1, s; i >= 0; i--)
1829
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
1830
+ return o && r && ni(e, n, r), r;
1831
+ }, Ee = (t, e) => (n, o) => e(n, o, t);
1832
+ let me = class extends Q {
1833
+ constructor(t, e, n, o, r) {
1834
+ super(), this._config = t, this._injector = e, this._componentManager = n, this._layoutService = o, this._menuService = r, this._init();
1800
1835
  }
1801
1836
  _initCustomComponents() {
1802
- const n = this._componentManager;
1803
- this.disposeWithMe(n.register(_t, wo)), this.disposeWithMe(n.register(dn, $n)), this.disposeWithMe(n.register(un, Hn)), this.disposeWithMe(n.register(hn, Vn));
1837
+ const t = this._componentManager;
1838
+ this.disposeWithMe(t.register(pt, Ao)), this.disposeWithMe(t.register(dn, $n)), this.disposeWithMe(t.register(un, Hn)), this.disposeWithMe(t.register(hn, Vn));
1804
1839
  }
1805
1840
  _initMenus() {
1806
- const { menu: n = {} } = this._config;
1841
+ const { menu: t = {} } = this._config;
1807
1842
  [
1808
- Yi,
1809
- Xi,
1810
- Ki,
1811
- Zi,
1812
- qi,
1813
- Ji,
1814
- er,
1815
- Qi,
1816
- tr,
1817
- nr,
1818
- or,
1819
- ir,
1820
- rr,
1821
- sr,
1822
- ar,
1823
- cr,
1824
- lr,
1825
- dr
1843
+ Br,
1844
+ $r,
1845
+ Hr,
1846
+ Vr,
1847
+ jr,
1848
+ Wr,
1849
+ Gr,
1850
+ kr,
1851
+ zr,
1852
+ Yr,
1853
+ Xr,
1854
+ Kr,
1855
+ Zr,
1856
+ Jr,
1857
+ qr,
1858
+ Qr,
1859
+ ei,
1860
+ ti
1826
1861
  ].forEach((e) => {
1827
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), n));
1862
+ this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), t));
1828
1863
  });
1829
1864
  }
1830
1865
  _init() {
1831
- this._initCustomComponents(), this._initMenus(), this._initDocBackground(), this._initFocusHandler();
1832
- }
1833
- _initDocBackground() {
1834
- const n = this._univerInstanceService.getAllUnitsForType(v.UNIVER_DOC)[0].getUnitId();
1835
- if (n == null)
1836
- return;
1837
- this._editorService.isEditor(n) || this.disposeWithMe(
1838
- this._uiPartsService.registerComponent(jn.CONTENT, () => No(Fi, this._injector))
1839
- );
1866
+ this._initCustomComponents(), this._initMenus(), this._initFocusHandler();
1840
1867
  }
1841
1868
  _initFocusHandler() {
1842
1869
  this.disposeWithMe(
1843
1870
  this._layoutService.registerFocusHandler(v.UNIVER_DOC, () => {
1844
- this._injector.get(oe).focus();
1871
+ this._injector.get(ne).focus();
1845
1872
  })
1846
1873
  );
1847
1874
  }
1848
1875
  };
1849
- Se = gr([
1850
- Ue(we.Rendered, Se),
1851
- J(1, T(Be)),
1852
- J(2, T(tn)),
1853
- J(3, en),
1854
- J(4, Y),
1855
- J(5, Wn),
1856
- J(6, kn),
1857
- J(7, L)
1858
- ], Se);
1859
- const pr = {
1860
- id: fo.id,
1861
- preconditions: $o,
1876
+ me = ri([
1877
+ Be($e.Rendered, me),
1878
+ Ee(1, E(Le)),
1879
+ Ee(2, E(tn)),
1880
+ Ee(3, en),
1881
+ Ee(4, jn)
1882
+ ], me);
1883
+ const ii = {
1884
+ id: go.id,
1885
+ preconditions: Fo,
1862
1886
  binding: H.ENTER
1863
- }, _r = {
1864
- id: mo.id,
1865
- preconditions: z,
1887
+ }, si = {
1888
+ id: po.id,
1889
+ preconditions: k,
1866
1890
  binding: H.BACKSPACE
1867
- }, fr = {
1868
- id: So.id,
1869
- preconditions: z,
1891
+ }, ai = {
1892
+ id: _o.id,
1893
+ preconditions: k,
1870
1894
  binding: H.DELETE
1871
1895
  };
1872
- function Ge(n) {
1873
- return n.getContextValue(Ne) || n.getContextValue(Jt);
1896
+ function ze(t) {
1897
+ return t.getContextValue(Ue) || t.getContextValue(qt);
1874
1898
  }
1875
- const ft = 999, mr = {
1876
- id: zn.id,
1899
+ const _t = 999, ci = {
1900
+ id: Wn.id,
1877
1901
  name: "doc.command.copy",
1878
1902
  type: de.COMMAND,
1879
1903
  multi: !0,
1880
- priority: ft,
1881
- preconditions: Ge,
1882
- handler: async (n) => n.get(Ce).copy()
1883
- }, Sr = {
1884
- id: Gn.id,
1904
+ priority: _t,
1905
+ preconditions: ze,
1906
+ handler: async (t) => t.get(Re).copy()
1907
+ }, li = {
1908
+ id: kn.id,
1885
1909
  name: "doc.command.cut",
1886
1910
  type: de.COMMAND,
1887
1911
  multi: !0,
1888
- priority: ft,
1889
- preconditions: Ge,
1890
- handler: async (n) => n.get(Ce).cut()
1891
- }, vr = {
1892
- id: Yn.id,
1912
+ priority: _t,
1913
+ preconditions: ze,
1914
+ handler: async (t) => t.get(Re).cut()
1915
+ }, di = {
1916
+ id: Gn.id,
1893
1917
  name: "doc.command.paste",
1894
1918
  type: de.COMMAND,
1895
1919
  multi: !0,
1896
- priority: ft,
1897
- preconditions: Ge,
1898
- handler: async (n) => {
1899
- const e = n.get(Ce), o = await n.get(gt).read();
1920
+ priority: _t,
1921
+ preconditions: ze,
1922
+ handler: async (t) => {
1923
+ const e = t.get(Re), o = await t.get(ut).read();
1900
1924
  return o.length === 0 ? !1 : e.paste(o);
1901
1925
  }
1902
1926
  };
1903
- var Or = Object.defineProperty, Rr = Object.getOwnPropertyDescriptor, Cr = (n, e, t, o) => {
1904
- for (var i = o > 1 ? void 0 : o ? Rr(e, t) : e, r = n.length - 1, s; r >= 0; r--)
1905
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
1906
- return o && i && Or(e, t, i), i;
1907
- }, ge = (n, e) => (t, o) => e(t, o, n);
1908
- let xe = class extends Oe {
1909
- constructor(n, e, t, o, i) {
1910
- super(), this._commandService = n, this._clipboardInterfaceService = e, this._docClipboardService = t, this._textSelectionRenderManager = o, this._contextService = i, this._init();
1927
+ var ui = Object.defineProperty, hi = Object.getOwnPropertyDescriptor, gi = (t, e, n, o) => {
1928
+ for (var r = o > 1 ? void 0 : o ? hi(e, n) : e, i = t.length - 1, s; i >= 0; i--)
1929
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
1930
+ return o && r && ui(e, n, r), r;
1931
+ }, he = (t, e) => (n, o) => e(n, o, t);
1932
+ let Me = class extends Se {
1933
+ constructor(t, e, n, o, r) {
1934
+ super(), this._commandService = t, this._clipboardInterfaceService = e, this._docClipboardService = n, this._textSelectionRenderManager = o, this._contextService = r, this._init();
1911
1935
  }
1912
1936
  _init() {
1913
- [mr, Sr, vr].forEach((n) => this.disposeWithMe(this._commandService.registerMultipleCommand(n))), [on, nn].forEach((n) => this.disposeWithMe(this._commandService.registerCommand(n))), this._initLegacyPasteCommand();
1937
+ [ci, li, di].forEach((t) => this.disposeWithMe(this._commandService.registerMultipleCommand(t))), [on, nn].forEach((t) => this.disposeWithMe(this._commandService.registerCommand(t))), this._initLegacyPasteCommand();
1914
1938
  }
1915
1939
  _initLegacyPasteCommand() {
1916
- var n;
1917
- (n = this._textSelectionRenderManager) == null || n.onPaste$.pipe(se(this.dispose$)).subscribe((e) => {
1918
- var r, s;
1919
- if (!Ge(this._contextService))
1940
+ var t;
1941
+ (t = this._textSelectionRenderManager) == null || t.onPaste$.pipe(se(this.dispose$)).subscribe((e) => {
1942
+ var i, s;
1943
+ if (!ze(this._contextService))
1920
1944
  return;
1921
1945
  e.event.preventDefault();
1922
- const t = e.event, o = (r = t.clipboardData) == null ? void 0 : r.getData("text/html"), i = (s = t.clipboardData) == null ? void 0 : s.getData("text/plain");
1923
- this._docClipboardService.legacyPaste(o, i);
1946
+ const n = e.event, o = (i = n.clipboardData) == null ? void 0 : i.getData("text/html"), r = (s = n.clipboardData) == null ? void 0 : s.getData("text/plain");
1947
+ this._docClipboardService.legacyPaste(o, r);
1924
1948
  });
1925
1949
  }
1926
1950
  };
1927
- xe = Cr([
1928
- Ue(we.Rendered, xe),
1929
- ge(0, C),
1930
- ge(1, gt),
1931
- ge(2, Ce),
1932
- ge(3, oe),
1933
- ge(4, bn)
1934
- ], xe);
1935
- var Er = Object.defineProperty, Tr = Object.getOwnPropertyDescriptor, Ir = (n, e, t, o) => {
1936
- for (var i = o > 1 ? void 0 : o ? Tr(e, t) : e, r = n.length - 1, s; r >= 0; r--)
1937
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
1938
- return o && i && Er(e, t, i), i;
1939
- }, pe = (n, e) => (t, o) => e(t, o, n);
1940
- let ye = class extends K {
1941
- constructor(e, t, o, i, r) {
1951
+ Me = gi([
1952
+ Be($e.Rendered, Me),
1953
+ he(0, O),
1954
+ he(1, ut),
1955
+ he(2, Re),
1956
+ he(3, ne),
1957
+ he(4, Mn)
1958
+ ], Me);
1959
+ var pi = Object.defineProperty, _i = Object.getOwnPropertyDescriptor, fi = (t, e, n, o) => {
1960
+ for (var r = o > 1 ? void 0 : o ? _i(e, n) : e, i = t.length - 1, s; i >= 0; i--)
1961
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
1962
+ return o && r && pi(e, n, r), r;
1963
+ }, ge = (t, e) => (n, o) => e(n, o, t);
1964
+ let ye = class extends Q {
1965
+ constructor(e, n, o, r, i) {
1942
1966
  super();
1943
- E(this, "_initialEditors", /* @__PURE__ */ new Set());
1944
- this._univerInstanceService = e, this._editorService = t, this._commandService = o, this._textSelectionRenderManager = i, this._renderManagerService = r, this._initialize();
1967
+ C(this, "_initialEditors", /* @__PURE__ */ new Set());
1968
+ this._univerInstanceService = e, this._editorService = n, this._commandService = o, this._textSelectionRenderManager = r, this._renderManagerService = i, this._initialize();
1945
1969
  }
1946
1970
  _initialize() {
1947
1971
  this.disposeWithMe(
@@ -1949,39 +1973,39 @@ let ye = class extends K {
1949
1973
  this._resize(e);
1950
1974
  })
1951
1975
  ), this._editorService.getAllEditor().forEach((e) => {
1952
- const t = e.editorUnitId;
1953
- this._initialEditors.has(t) || (this._initialEditors.add(t), this._resize(t));
1976
+ const n = e.editorUnitId;
1977
+ this._initialEditors.has(n) || (this._initialEditors.add(n), this._resize(n));
1954
1978
  }), this._commandExecutedListener(), this._initialSetValue(), this._initialBlur(), this._initialFocus(), this._initialValueChange();
1955
1979
  }
1956
1980
  _resize(e) {
1957
- var M, I, R;
1981
+ var I, b, T;
1958
1982
  if (e == null)
1959
1983
  return;
1960
- const t = this._editorService.getEditor(e);
1961
- if ((t == null ? void 0 : t.cancelDefaultResizeListener) === !0)
1984
+ const n = this._editorService.getEditor(e);
1985
+ if ((n == null ? void 0 : n.cancelDefaultResizeListener) === !0)
1962
1986
  return;
1963
1987
  const o = this._univerInstanceService.getUniverDocInstance(e);
1964
1988
  if (!o)
1965
1989
  return;
1966
- const i = (M = this._renderManagerService.getRenderById(o.getUnitId())) == null ? void 0 : M.with(N).getSkeleton();
1967
- if (t == null || t.render == null || i == null || o == null)
1990
+ const r = (I = this._renderManagerService.getRenderById(o.getUnitId())) == null ? void 0 : I.with(L).getSkeleton();
1991
+ if (n == null || n.render == null || r == null || o == null)
1968
1992
  return;
1969
- i.calculate();
1970
- const { marginTop: r = 0, marginBottom: s = 0, marginLeft: a = 0, marginRight: c = 0 } = o.getSnapshot().documentStyle, { scene: d, mainComponent: p } = t.render;
1971
- let { actualHeight: g, actualWidth: h } = i.getActualSize();
1972
- g += r + s, h += a + c;
1973
- const { width: l, height: f } = t.getBoundingClientRect(), u = d.getViewport(te.VIEW_MAIN);
1974
- let _ = u == null ? void 0 : u.getScrollBar();
1975
- const m = Math.max(h, l), O = Math.max(g, f);
1993
+ r.calculate();
1994
+ const { marginTop: i = 0, marginBottom: s = 0, marginLeft: a = 0, marginRight: c = 0 } = o.getSnapshot().documentStyle, { scene: d, mainComponent: g } = n.render;
1995
+ let { actualHeight: h, actualWidth: p } = r.getActualSize();
1996
+ h += i + s, p += a + c;
1997
+ const { width: l, height: _ } = n.getBoundingClientRect(), u = d.getViewport(q.VIEW_MAIN);
1998
+ let f = u == null ? void 0 : u.getScrollBar();
1999
+ const m = Math.max(p, l), R = Math.max(h, _);
1976
2000
  d.transformByState({
1977
2001
  width: m,
1978
- height: O
1979
- }), p == null || p.resize(m, O), t.isSingle() ? h > l ? _ == null ? u && new nt(u, { barSize: 8, enableVertical: !1 }) : u == null || u.resetCanvasSizeAndUpdateScrollBar() : (_ = null, u == null || u.scrollTo({ x: 0, y: 0 }), (R = u == null ? void 0 : u.getScrollBar()) == null || R.dispose()) : g > f ? _ == null ? u && new nt(u, { enableHorizontal: !1, barSize: 8 }) : u == null || u.resetCanvasSizeAndUpdateScrollBar() : (_ = null, u == null || u.scrollTo({ x: 0, y: 0 }), (I = u == null ? void 0 : u.getScrollBar()) == null || I.dispose());
2002
+ height: R
2003
+ }), g == null || g.resize(m, R), n.isSingle() ? p > l ? f == null ? u && new tt(u, { barSize: 8, enableVertical: !1 }) : u == null || u.resetCanvasSizeAndUpdateScrollBar() : (f = null, u == null || u.scrollTo({ x: 0, y: 0 }), (T = u == null ? void 0 : u.getScrollBar()) == null || T.dispose()) : h > _ ? f == null ? u && new tt(u, { enableHorizontal: !1, barSize: 8 }) : u == null || u.resetCanvasSizeAndUpdateScrollBar() : (f = null, u == null || u.scrollTo({ x: 0, y: 0 }), (b = u == null ? void 0 : u.getScrollBar()) == null || b.dispose());
1980
2004
  }
1981
2005
  _initialSetValue() {
1982
2006
  this.disposeWithMe(
1983
2007
  this._editorService.setValue$.subscribe((e) => {
1984
- this._commandService.executeCommand(vo.id, {
2008
+ this._commandService.executeCommand(fo.id, {
1985
2009
  unitId: e.editorUnitId,
1986
2010
  body: e.body,
1987
2011
  segmentId: null
@@ -1996,12 +2020,12 @@ let ye = class extends K {
1996
2020
  })
1997
2021
  ), this.disposeWithMe(
1998
2022
  this._textSelectionRenderManager.onBlur$.subscribe(() => {
1999
- var i;
2000
- const e = (i = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : i.getUnitId();
2023
+ var r;
2024
+ const e = (r = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : r.getUnitId();
2001
2025
  if (e == null)
2002
2026
  return;
2003
- const t = this._editorService.getEditor(e), o = this._editorService.getFocusEditor();
2004
- t == null || t.isSheetEditor() || o && o.editorUnitId === e || this._editorService.blur();
2027
+ const n = this._editorService.getEditor(e), o = this._editorService.getFocusEditor();
2028
+ n == null || n.isSheetEditor() || o && o.editorUnitId === e || this._editorService.blur();
2005
2029
  })
2006
2030
  );
2007
2031
  }
@@ -2019,15 +2043,15 @@ let ye = class extends K {
2019
2043
  ];
2020
2044
  this.disposeWithMe(
2021
2045
  yt(window, "mousedown").subscribe((o) => {
2022
- const r = o.target.classList[0] || "";
2023
- if (Mn(r, e)) {
2046
+ const i = o.target.classList[0] || "";
2047
+ if (yn(i, e)) {
2024
2048
  this._editorService.changeSpreadsheetFocusState(!0), o.stopPropagation();
2025
2049
  return;
2026
2050
  }
2027
2051
  this._editorService.changeSpreadsheetFocusState(!1);
2028
2052
  })
2029
2053
  ), this._univerInstanceService.getAllUnitsForType(v.UNIVER_SHEET).forEach((o) => {
2030
- const i = o.getUnitId(), r = this._renderManagerService.getRenderById(i), s = r == null ? void 0 : r.engine.getCanvas().getCanvasEle();
2054
+ const r = o.getUnitId(), i = this._renderManagerService.getRenderById(r), s = i == null ? void 0 : i.engine.getCanvas().getCanvasEle();
2031
2055
  s != null && yt(s, "mousedown").subscribe((a) => {
2032
2056
  this._editorService.changeSpreadsheetFocusState(!0), a.stopPropagation();
2033
2057
  });
@@ -2049,56 +2073,56 @@ let ye = class extends K {
2049
2073
  const e = (o = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : o.getUnitId();
2050
2074
  if (e == null)
2051
2075
  return;
2052
- const t = this._editorService.getEditor(e);
2053
- t == null || t.isSheetEditor() || this._editorService.refreshValueChange(e);
2076
+ const n = this._editorService.getEditor(e);
2077
+ n == null || n.isSheetEditor() || this._editorService.refreshValueChange(e);
2054
2078
  }
2055
2079
  /**
2056
2080
  * Listen to document edits to refresh the size of the formula editor.
2057
2081
  */
2058
2082
  _commandExecutedListener() {
2059
- const e = [Ve.id, Xn.id];
2083
+ const e = [ht.id, zn.id];
2060
2084
  this.disposeWithMe(
2061
- this._commandService.onCommandExecuted((t) => {
2062
- if (e.includes(t.id)) {
2063
- const o = t.params, { unitId: i } = o;
2064
- if (this._editorService.isSheetEditor(i))
2085
+ this._commandService.onCommandExecuted((n) => {
2086
+ if (e.includes(n.id)) {
2087
+ const o = n.params, { unitId: r } = o;
2088
+ if (this._editorService.isSheetEditor(r))
2065
2089
  return;
2066
- this._resize(i), this._valueChange();
2090
+ this._resize(r), this._valueChange();
2067
2091
  }
2068
2092
  })
2069
2093
  );
2070
2094
  }
2071
2095
  };
2072
- ye = Ir([
2073
- Ue(we.Rendered, ye),
2074
- pe(0, L),
2075
- pe(1, Y),
2076
- pe(2, C),
2077
- pe(3, oe),
2078
- pe(4, k)
2096
+ ye = fi([
2097
+ Be($e.Rendered, ye),
2098
+ ge(0, w),
2099
+ ge(1, ee),
2100
+ ge(2, O),
2101
+ ge(3, ne),
2102
+ ge(4, W)
2079
2103
  ], ye);
2080
- var br = Object.defineProperty, Mr = Object.getOwnPropertyDescriptor, xr = (n, e, t, o) => {
2081
- for (var i = o > 1 ? void 0 : o ? Mr(e, t) : e, r = n.length - 1, s; r >= 0; r--)
2082
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
2083
- return o && i && br(e, t, i), i;
2084
- }, _e = (n, e) => (t, o) => e(t, o, n);
2085
- let at = class extends Oe {
2086
- constructor(n, e, t, o, i, r) {
2087
- super(), this._context = n, this._commandService = e, this._docSkeletonManagerService = t, this._configService = o, this._editorService = i, this._renderManagerService = r, this._addNewRender(), this._initRenderRefresh(), this._initCommandListener();
2088
- }
2089
- reRender(n) {
2090
- var i, r;
2091
- const e = (i = this._renderManagerService.getRenderById(n)) == null ? void 0 : i.with(N), t = e == null ? void 0 : e.getSkeleton();
2092
- if (!(!t || t.getViewModel().getDataModel().getSnapshot().disabled)) {
2093
- if (t.calculate(), this._editorService.isEditor(n)) {
2094
- (r = this._context.mainComponent) == null || r.makeDirty();
2104
+ var mi = Object.defineProperty, Si = Object.getOwnPropertyDescriptor, vi = (t, e, n, o) => {
2105
+ for (var r = o > 1 ? void 0 : o ? Si(e, n) : e, i = t.length - 1, s; i >= 0; i--)
2106
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
2107
+ return o && r && mi(e, n, r), r;
2108
+ }, pe = (t, e) => (n, o) => e(n, o, t);
2109
+ let st = class extends Se {
2110
+ constructor(t, e, n, o, r, i) {
2111
+ super(), this._context = t, this._commandService = e, this._docSkeletonManagerService = n, this._configService = o, this._editorService = r, this._renderManagerService = i, this._addNewRender(), this._initRenderRefresh(), this._initCommandListener();
2112
+ }
2113
+ reRender(t) {
2114
+ var r, i;
2115
+ const e = (r = this._renderManagerService.getRenderById(t)) == null ? void 0 : r.with(L), n = e == null ? void 0 : e.getSkeleton();
2116
+ if (!(!n || n.getViewModel().getDataModel().getSnapshot().disabled)) {
2117
+ if (n.calculate(), this._editorService.isEditor(t)) {
2118
+ (i = this._context.mainComponent) == null || i.makeDirty();
2095
2119
  return;
2096
2120
  }
2097
- this._recalculateSizeBySkeleton(t);
2121
+ this._recalculateSizeBySkeleton(n);
2098
2122
  }
2099
2123
  }
2100
2124
  _addNewRender() {
2101
- const { scene: n, engine: e, unit: t } = this._context, o = new Mo(te.VIEW_MAIN, n, {
2125
+ const { scene: t, engine: e, unit: n } = this._context, o = new To(q.VIEW_MAIN, t, {
2102
2126
  left: 0,
2103
2127
  top: 0,
2104
2128
  bottom: 0,
@@ -2107,307 +2131,238 @@ let at = class extends Oe {
2107
2131
  isRelativeY: !0,
2108
2132
  isWheelPreventDefaultX: !0
2109
2133
  });
2110
- n.attachControl(), n.onMouseWheel$.subscribeEvent((s, a) => {
2134
+ t.attachControl(), t.onMouseWheel$.subscribeEvent((s, a) => {
2111
2135
  const c = s;
2112
2136
  if (c.ctrlKey) {
2113
2137
  const d = Math.abs(c.deltaX);
2114
- let p = d < 40 ? 0.2 : d < 80 ? 0.4 : 0.2;
2115
- p *= c.deltaY > 0 ? -1 : 1, n.scaleX < 1 && (p /= 2), n.scaleX + p > 4 ? n.scale(4, 4) : n.scaleX + p < 0.1 ? n.scale(0.1, 0.1) : c.preventDefault();
2138
+ let g = d < 40 ? 0.2 : d < 80 ? 0.4 : 0.2;
2139
+ g *= c.deltaY > 0 ? -1 : 1, t.scaleX < 1 && (g /= 2), t.scaleX + g > 4 ? t.scale(4, 4) : t.scaleX + g < 0.1 ? t.scale(0.1, 0.1) : c.preventDefault();
2116
2140
  } else
2117
2141
  o.onMouseWheel(c, a);
2118
- }), this._configService.getConfig("hasScroll") !== !1 && new nt(o), n.addLayer(
2119
- new Mt(n, [], Ye),
2120
- new Mt(n, [], Oo)
2121
- ), this._addComponent(), t.getShouldRenderLoopImmediately() && e.runRenderLoop(() => {
2122
- n.render();
2142
+ }), this._configService.getConfig("hasScroll") !== !1 && new tt(o), t.addLayer(
2143
+ new bt(t, [], Ye),
2144
+ new bt(t, [], mo)
2145
+ ), this._addComponent(), n.getShouldRenderLoopImmediately() && e.runRenderLoop(() => {
2146
+ t.render();
2123
2147
  });
2124
2148
  }
2125
2149
  _addComponent() {
2126
- const { scene: n, unit: e, components: t } = this._context, o = {
2150
+ const { scene: t, unit: e, components: n } = this._context, o = {
2127
2151
  pageMarginLeft: e.documentStyle.marginLeft || 0,
2128
2152
  pageMarginTop: e.documentStyle.marginTop || 0
2129
- }, i = new xo(ie.MAIN, void 0, o);
2130
- i.zIndex = Tt;
2131
- const r = new yo(ie.BACKGROUND, void 0, o);
2132
- r.zIndex = Tt, this._context.mainComponent = i, t.set(ie.MAIN, i), t.set(ie.BACKGROUND, r), n.addObjects([i], Ye), n.addObjects([r], Ro), this._editorService.getEditor(e.getUnitId()) == null && n.enableLayerCache(Ye);
2153
+ }, r = new Io(oe.MAIN, void 0, o);
2154
+ r.zIndex = Et;
2155
+ const i = new bo(oe.BACKGROUND, void 0, o);
2156
+ i.zIndex = Et, this._context.mainComponent = r, n.set(oe.MAIN, r), n.set(oe.BACKGROUND, i), t.addObjects([r], Ye), t.addObjects([i], So), this._editorService.getEditor(e.getUnitId()) == null && t.enableLayerCache(Ye);
2133
2157
  }
2134
2158
  _initRenderRefresh() {
2135
- this._docSkeletonManagerService.currentSkeletonBefore$.pipe(se(this.dispose$)).subscribe((n) => {
2136
- this._create(n);
2159
+ this._docSkeletonManagerService.currentSkeletonBefore$.pipe(se(this.dispose$)).subscribe((t) => {
2160
+ this._create(t);
2137
2161
  });
2138
2162
  }
2139
- _create(n) {
2140
- if (!n)
2163
+ _create(t) {
2164
+ if (!t)
2141
2165
  return;
2142
- const { mainComponent: e, components: t } = this._context, o = e, i = t.get(ie.BACKGROUND);
2143
- o.changeSkeleton(n), i.changeSkeleton(n), this._recalculateSizeBySkeleton(n);
2166
+ const { mainComponent: e, components: n } = this._context, o = e, r = n.get(oe.BACKGROUND);
2167
+ o.changeSkeleton(t), r.changeSkeleton(t), this._recalculateSizeBySkeleton(t);
2144
2168
  }
2145
2169
  _initCommandListener() {
2146
- const n = [Ve.id];
2170
+ const t = [ht.id];
2147
2171
  this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
2148
- if (n.includes(e.id)) {
2149
- const t = e.params, { unitId: o } = t;
2172
+ if (t.includes(e.id)) {
2173
+ const n = e.params, { unitId: o } = n;
2150
2174
  this.reRender(o);
2151
2175
  }
2152
2176
  }));
2153
2177
  }
2154
- _recalculateSizeBySkeleton(n) {
2155
- var p;
2156
- const { mainComponent: e, scene: t, unitId: o, components: i } = this._context, r = e, s = i.get(ie.BACKGROUND), a = (p = n.getSkeletonData()) == null ? void 0 : p.pages;
2178
+ _recalculateSizeBySkeleton(t) {
2179
+ var g;
2180
+ const { mainComponent: e, scene: n, unitId: o, components: r } = this._context, i = e, s = r.get(oe.BACKGROUND), a = (g = t.getSkeletonData()) == null ? void 0 : g.pages;
2157
2181
  if (a == null)
2158
2182
  return;
2159
2183
  let c = 0, d = 0;
2160
- for (let g = 0, h = a.length; g < h; g++) {
2161
- const l = a[g], { pageWidth: f, pageHeight: u } = l;
2162
- r.pageLayoutType === De.VERTICAL ? (d += u, d += r.pageMarginTop, g === h - 1 && (d += r.pageMarginTop), c = Math.max(c, f)) : r.pageLayoutType === De.HORIZONTAL && (c += f, g !== h - 1 && (c += r.pageMarginLeft), d = Math.max(d, u));
2184
+ for (let h = 0, p = a.length; h < p; h++) {
2185
+ const l = a[h], { pageWidth: _, pageHeight: u } = l;
2186
+ i.pageLayoutType === Ae.VERTICAL ? (d += u, d += i.pageMarginTop, h === p - 1 && (d += i.pageMarginTop), c = Math.max(c, _)) : i.pageLayoutType === Ae.HORIZONTAL && (c += _, h !== p - 1 && (c += i.pageMarginLeft), d = Math.max(d, u));
2163
2187
  }
2164
- r.resize(c, d), s.resize(c, d), this._editorService.isEditor(o) || t.resize(c, d);
2188
+ i.resize(c, d), s.resize(c, d), this._editorService.isEditor(o) || n.resize(c, d);
2165
2189
  }
2166
2190
  };
2167
- at = xr([
2168
- _e(1, C),
2169
- _e(2, T(N)),
2170
- _e(3, xn),
2171
- _e(4, Y),
2172
- _e(5, k)
2173
- ], at);
2174
- var yr = Object.defineProperty, Pr = Object.getOwnPropertyDescriptor, Dr = (n, e, t, o) => {
2175
- for (var i = o > 1 ? void 0 : o ? Pr(e, t) : e, r = n.length - 1, s; r >= 0; r--)
2176
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
2177
- return o && i && yr(e, t, i), i;
2178
- }, Je = (n, e) => (t, o) => e(t, o, n);
2179
- let ct = class extends K {
2180
- constructor(e, t, o, i) {
2181
- super();
2182
- E(this, "_liquid", new Po());
2183
- E(this, "_pageMarginCache", /* @__PURE__ */ new Map());
2184
- this._context = e, this._docSkeletonManagerService = t, this._commandService = o, this._editorService = i, this._initialize(), this._commandExecutedListener();
2185
- }
2186
- _initialize() {
2187
- this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
2188
- e != null && this._refreshDrawing(e);
2189
- });
2190
- }
2191
- _commandExecutedListener() {
2192
- const e = [Ve.id, ve.id];
2193
- this.disposeWithMe(
2194
- this._commandService.onCommandExecuted((t) => {
2195
- var o;
2196
- if (e.includes(t.id)) {
2197
- const i = t.params, { unitId: r } = i, s = this._docSkeletonManagerService.getSkeleton();
2198
- if (!s)
2199
- return;
2200
- if (this._editorService.isEditor(r)) {
2201
- (o = this._context.mainComponent) == null || o.makeDirty();
2202
- return;
2203
- }
2204
- this._refreshDrawing(s);
2205
- }
2206
- })
2207
- );
2208
- }
2209
- _refreshDrawing(e) {
2210
- const t = e == null ? void 0 : e.getSkeletonData(), { mainComponent: o, scene: i, unitId: r } = this._context, s = o;
2211
- if (!t)
2212
- return;
2213
- const { left: a, top: c, pageLayoutType: d, pageMarginLeft: p, pageMarginTop: g } = s, { pages: h } = t, l = [];
2214
- i.getAncestorScale(), this._liquid.reset(), this._pageMarginCache.clear();
2215
- for (let f = 0, u = h.length; f < u; f++) {
2216
- const _ = h[f], { skeDrawings: m, marginLeft: O, marginTop: M } = _;
2217
- this._liquid.translatePagePadding(_), m.forEach((I) => {
2218
- const { aLeft: R, aTop: y, height: j, width: W, drawingId: $, drawingOrigin: mt } = I, Sn = mt.layoutType === yn.WRAP_NONE && mt.behindDoc === S.TRUE;
2219
- l.push({
2220
- unitId: r,
2221
- subUnitId: Pn,
2222
- floatingObjectId: $,
2223
- behindText: Sn,
2224
- floatingObject: {
2225
- left: R + a + this._liquid.x,
2226
- top: y + c + this._liquid.y,
2227
- width: W,
2228
- height: j
2229
- }
2230
- }), this._pageMarginCache.set($, {
2231
- marginLeft: this._liquid.x,
2232
- marginTop: this._liquid.y
2233
- });
2234
- }), this._liquid.restorePagePadding(_), this._liquid.translatePage(_, d, p, g);
2235
- }
2236
- }
2237
- };
2238
- ct = Dr([
2239
- Je(1, T(N)),
2240
- Je(2, C),
2241
- Je(3, Y)
2242
- ], ct);
2243
- var Ar = Object.defineProperty, Fr = Object.getOwnPropertyDescriptor, Nr = (n, e, t, o) => {
2244
- for (var i = o > 1 ? void 0 : o ? Fr(e, t) : e, r = n.length - 1, s; r >= 0; r--)
2245
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
2246
- return o && i && Ar(e, t, i), i;
2247
- }, fe = (n, e) => (t, o) => e(t, o, n);
2248
- let lt = class extends K {
2249
- constructor(n, e, t, o, i, r) {
2250
- super(), this._context = n, this._docSkeletonManagerService = e, this._univerInstanceService = t, this._commandService = o, this._textSelectionManagerService = i, this._editorService = r, this._init();
2191
+ st = vi([
2192
+ pe(1, O),
2193
+ pe(2, E(L)),
2194
+ pe(3, xn),
2195
+ pe(4, ee),
2196
+ pe(5, W)
2197
+ ], st);
2198
+ var Ri = Object.defineProperty, Oi = Object.getOwnPropertyDescriptor, Ci = (t, e, n, o) => {
2199
+ for (var r = o > 1 ? void 0 : o ? Oi(e, n) : e, i = t.length - 1, s; i >= 0; i--)
2200
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
2201
+ return o && r && Ri(e, n, r), r;
2202
+ }, _e = (t, e) => (n, o) => e(n, o, t);
2203
+ let at = class extends Q {
2204
+ constructor(t, e, n, o, r, i) {
2205
+ super(), this._context = t, this._docSkeletonManagerService = e, this._univerInstanceService = n, this._commandService = o, this._textSelectionManagerService = r, this._editorService = i, this._init();
2251
2206
  }
2252
2207
  _init() {
2253
2208
  this._initSkeletonListener(), this._initCommandExecutedListener(), this._initRenderRefresher(), setTimeout(() => this._updateViewZoom(1, !0), 20);
2254
2209
  }
2255
2210
  _initRenderRefresher() {
2256
- this._docSkeletonManagerService.currentSkeleton$.subscribe((n) => {
2257
- if (n == null)
2211
+ this._docSkeletonManagerService.currentSkeleton$.subscribe((t) => {
2212
+ if (t == null)
2258
2213
  return;
2259
- const { unitId: e, scene: t } = this._context;
2260
- this._editorService.isEditor(e) || this.disposeWithMe(t.onMouseWheel$.subscribeEvent((o) => {
2214
+ const { unitId: e, scene: n } = this._context;
2215
+ this._editorService.isEditor(e) || this.disposeWithMe(n.onMouseWheel$.subscribeEvent((o) => {
2261
2216
  if (!o.ctrlKey)
2262
2217
  return;
2263
- const i = this._univerInstanceService.getCurrentUniverDocInstance();
2264
- if (!i)
2218
+ const r = this._univerInstanceService.getCurrentUniverDocInstance();
2219
+ if (!r)
2265
2220
  return;
2266
- const r = Math.abs(o.deltaX);
2267
- let s = r < 40 ? 0.2 : r < 80 ? 0.4 : 0.2;
2268
- s *= o.deltaY > 0 ? -1 : 1, t.scaleX < 1 && (s /= 2);
2269
- const a = i.zoomRatio;
2221
+ const i = Math.abs(o.deltaX);
2222
+ let s = i < 40 ? 0.2 : i < 80 ? 0.4 : 0.2;
2223
+ s *= o.deltaY > 0 ? -1 : 1, n.scaleX < 1 && (s /= 2);
2224
+ const a = r.zoomRatio;
2270
2225
  let c = +Number.parseFloat(`${a + s}`).toFixed(1);
2271
- c = c >= 4 ? 4 : c <= 0.1 ? 0.1 : c, this._commandService.executeCommand(Co.id, {
2226
+ c = c >= 4 ? 4 : c <= 0.1 ? 0.1 : c, this._commandService.executeCommand(vo.id, {
2272
2227
  zoomRatio: c,
2273
- unitId: i.getUnitId()
2228
+ unitId: r.getUnitId()
2274
2229
  }), o.preventDefault();
2275
2230
  }));
2276
2231
  });
2277
2232
  }
2278
2233
  _initSkeletonListener() {
2279
- this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe((n) => {
2280
- if (n == null)
2234
+ this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe((t) => {
2235
+ if (t == null)
2281
2236
  return;
2282
2237
  const e = this._univerInstanceService.getCurrentUniverDocInstance();
2283
2238
  if (!e) return;
2284
- const t = e.zoomRatio || 1;
2285
- this._updateViewZoom(t, !1);
2239
+ const n = e.zoomRatio || 1;
2240
+ this._updateViewZoom(n, !1);
2286
2241
  }));
2287
2242
  }
2288
2243
  _initCommandExecutedListener() {
2289
- const n = [ve.id];
2244
+ const t = [De.id];
2290
2245
  this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
2291
- if (n.includes(e.id)) {
2292
- const t = this._univerInstanceService.getCurrentUniverDocInstance();
2293
- if (!t) return;
2294
- const o = e.params, { unitId: i } = o;
2295
- if (i !== t.getUnitId())
2246
+ if (t.includes(e.id)) {
2247
+ const n = this._univerInstanceService.getCurrentUniverDocInstance();
2248
+ if (!n) return;
2249
+ const o = e.params, { unitId: r } = o;
2250
+ if (r !== n.getUnitId())
2296
2251
  return;
2297
- const r = t.zoomRatio || 1;
2298
- this._updateViewZoom(r);
2252
+ const i = n.zoomRatio || 1;
2253
+ this._updateViewZoom(i);
2299
2254
  }
2300
2255
  }));
2301
2256
  }
2302
- _updateViewZoom(n, e = !0) {
2257
+ _updateViewZoom(t, e = !0) {
2303
2258
  var o;
2304
- const t = Q(this._context);
2305
- t.scene.scale(n, n), this._calculatePagePosition(t, n), e && this._textSelectionManagerService.refreshSelection(), (o = t.scene.getTransformer()) == null || o.clearSelectedObjects();
2259
+ const n = J(this._context);
2260
+ n.scene.scale(t, t), this._calculatePagePosition(n, t), e && this._textSelectionManagerService.refreshSelection(), (o = n.scene.getTransformer()) == null || o.clearSelectedObjects();
2306
2261
  }
2307
- _calculatePagePosition(n, e) {
2308
- const { document: t, scene: o, docBackground: i } = n, r = o == null ? void 0 : o.getParent(), { width: s, height: a, pageMarginLeft: c, pageMarginTop: d } = t;
2309
- if (r == null || s === Number.POSITIVE_INFINITY || a === Number.POSITIVE_INFINITY)
2262
+ _calculatePagePosition(t, e) {
2263
+ const { document: n, scene: o, docBackground: r } = t, i = o == null ? void 0 : o.getParent(), { width: s, height: a, pageMarginLeft: c, pageMarginTop: d } = n;
2264
+ if (i == null || s === Number.POSITIVE_INFINITY || a === Number.POSITIVE_INFINITY)
2310
2265
  return;
2311
- const { width: p, height: g } = r;
2312
- let h = 0, l = 0, f = 0, u = 0, _ = Number.POSITIVE_INFINITY;
2313
- p > (s + c * 2) * e ? (h = p / 2 - s * e / 2, h /= e, f = (p - c * 2) / e, _ = 0) : (h = c, f = s + c * 2, _ = (f - p / e) / 2), g > a ? (l = g / 2 - a / 2, u = (g - d * 2) / e) : (l = d, u = a + d * 2), o.resize(f, u + 200), t.translate(h, l), i.translate(h, l);
2314
- const m = o.getViewport(te.VIEW_MAIN);
2315
- if (_ !== Number.POSITIVE_INFINITY && m != null) {
2316
- const O = m.transViewportScroll2ScrollValue(_, 0).x;
2266
+ const { width: g, height: h } = i;
2267
+ let p = 0, l = 0, _ = 0, u = 0, f = Number.POSITIVE_INFINITY;
2268
+ g > (s + c * 2) * e ? (p = g / 2 - s * e / 2, p /= e, _ = (g - c * 2) / e, f = 0) : (p = c, _ = s + c * 2, f = (_ - g / e) / 2), h > a ? (l = h / 2 - a / 2, u = (h - d * 2) / e) : (l = d, u = a + d * 2), o.resize(_, u + 200), n.translate(p, l), r.translate(p, l);
2269
+ const m = o.getViewport(q.VIEW_MAIN);
2270
+ if (f !== Number.POSITIVE_INFINITY && m != null) {
2271
+ const R = m.transViewportScroll2ScrollValue(f, 0).x;
2317
2272
  m.scrollTo({
2318
- x: O
2273
+ x: R
2319
2274
  });
2320
2275
  }
2321
2276
  return this;
2322
2277
  }
2323
2278
  };
2324
- lt = Nr([
2325
- fe(1, T(N)),
2326
- fe(2, L),
2327
- fe(3, C),
2328
- fe(4, T(ne)),
2329
- fe(5, Y)
2330
- ], lt);
2331
- var Lr = Object.defineProperty, Ur = Object.getOwnPropertyDescriptor, wr = (n, e, t, o) => {
2332
- for (var i = o > 1 ? void 0 : o ? Ur(e, t) : e, r = n.length - 1, s; r >= 0; r--)
2333
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
2334
- return o && i && Lr(e, t, i), i;
2335
- }, re = (n, e) => (t, o) => e(t, o, n);
2336
- let dt = class extends K {
2337
- constructor(e, t, o, i, r, s, a) {
2279
+ at = Ci([
2280
+ _e(1, E(L)),
2281
+ _e(2, w),
2282
+ _e(3, O),
2283
+ _e(4, E(te)),
2284
+ _e(5, ee)
2285
+ ], at);
2286
+ var Ei = Object.defineProperty, Ti = Object.getOwnPropertyDescriptor, Ii = (t, e, n, o) => {
2287
+ for (var r = o > 1 ? void 0 : o ? Ti(e, n) : e, i = t.length - 1, s; i >= 0; i--)
2288
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
2289
+ return o && r && Ei(e, n, r), r;
2290
+ }, ie = (t, e) => (n, o) => e(n, o, t);
2291
+ let ct = class extends Q {
2292
+ constructor(e, n, o, r, i, s, a) {
2338
2293
  super();
2339
- E(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
2340
- this._context = e, this._commandService = t, this._editorService = o, this._instanceSrv = i, this._textSelectionRenderManager = r, this._docSkeletonManagerService = s, this._textSelectionManagerService = a, this._initialize();
2294
+ C(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
2295
+ this._context = e, this._commandService = n, this._editorService = o, this._instanceSrv = r, this._textSelectionRenderManager = i, this._docSkeletonManagerService = s, this._textSelectionManagerService = a, this._initialize();
2341
2296
  }
2342
2297
  _initialize() {
2343
2298
  this._init(), this._skeletonListener(), this._commandExecutedListener();
2344
2299
  }
2345
2300
  _init() {
2346
- const { unitId: e } = this._context, t = Q(this._context);
2347
- t == null || t.document == null || this._loadedMap.has(t.document) || (this._initialMain(e), this._loadedMap.add(t.document));
2301
+ const { unitId: e } = this._context, n = J(this._context);
2302
+ n == null || n.document == null || this._loadedMap.has(n.document) || (this._initialMain(e), this._loadedMap.add(n.document));
2348
2303
  }
2349
2304
  // eslint-disable-next-line max-lines-per-function
2350
2305
  _initialMain(e) {
2351
- const t = Q(this._context), { document: o, scene: i } = t;
2306
+ const n = J(this._context), { document: o, scene: r } = n;
2352
2307
  this.disposeWithMe(o.onPointerEnter$.subscribeEvent(() => {
2353
- this._isEditorReadOnly(e) || (o.cursor = xt.TEXT);
2308
+ this._isEditorReadOnly(e) || (o.cursor = Mt.TEXT);
2354
2309
  })), this.disposeWithMe(o.onPointerLeave$.subscribeEvent(() => {
2355
- o.cursor = xt.DEFAULT, i.resetCursor();
2356
- })), this.disposeWithMe(o.onPointerDown$.subscribeEvent((r, s) => {
2310
+ o.cursor = Mt.DEFAULT, r.resetCursor();
2311
+ })), this.disposeWithMe(o.onPointerDown$.subscribeEvent((i, s) => {
2357
2312
  if (this._isEditorReadOnly(e))
2358
2313
  return;
2359
2314
  const a = this._instanceSrv.getCurrentUnitForType(v.UNIVER_DOC);
2360
2315
  (a == null ? void 0 : a.getUnitId()) !== e && this._instanceSrv.setCurrentUnitForType(e);
2361
- const c = this._docSkeletonManagerService.getSkeleton(), { offsetX: d, offsetY: p } = r, g = this._getTransformCoordForDocumentOffset(d, p);
2362
- if (g != null) {
2316
+ const c = this._docSkeletonManagerService.getSkeleton(), { offsetX: d, offsetY: g } = i, h = this._getTransformCoordForDocumentOffset(d, g);
2317
+ if (h != null) {
2363
2318
  const {
2364
- pageLayoutType: h = De.VERTICAL,
2319
+ pageLayoutType: p = Ae.VERTICAL,
2365
2320
  pageMarginLeft: l,
2366
- pageMarginTop: f
2321
+ pageMarginTop: _
2367
2322
  } = o.getOffsetConfig(), { editArea: u } = c.findEditAreaByCoord(
2368
- g,
2369
2323
  h,
2324
+ p,
2370
2325
  l,
2371
- f
2372
- ), _ = this._docSkeletonManagerService.getViewModel(), m = _.getEditArea();
2373
- m !== F.BODY && u !== F.BODY && u !== m && _.setEditArea(u);
2326
+ _
2327
+ ), f = this._docSkeletonManagerService.getViewModel(), m = f.getEditArea();
2328
+ m !== F.BODY && u !== F.BODY && u !== m && f.setEditArea(u);
2374
2329
  }
2375
- if (this._textSelectionRenderManager.eventTrigger(r), this._editorService.getEditor(e)) {
2330
+ if (this._textSelectionRenderManager.eventTrigger(i), this._editorService.getEditor(e)) {
2376
2331
  this._setEditorFocus(e);
2377
- const { offsetX: h, offsetY: l } = r;
2332
+ const { offsetX: p, offsetY: l } = i;
2378
2333
  setTimeout(() => {
2379
- this._setEditorFocus(e), this._textSelectionRenderManager.setCursorManually(h, l);
2334
+ this._setEditorFocus(e), this._textSelectionRenderManager.setCursorManually(p, l);
2380
2335
  }, 0);
2381
2336
  }
2382
- r.button !== 2 && s.stopPropagation();
2383
- })), this.disposeWithMe(o.onDblclick$.subscribeEvent((r) => {
2384
- this._isEditorReadOnly(e) || this._textSelectionRenderManager.handleDblClick(r);
2385
- })), this.disposeWithMe(o.onTripleClick$.subscribeEvent((r) => {
2386
- this._isEditorReadOnly(e) || this._textSelectionRenderManager.handleTripleClick(r);
2337
+ i.button !== 2 && s.stopPropagation();
2338
+ })), this.disposeWithMe(o.onDblclick$.subscribeEvent((i) => {
2339
+ this._isEditorReadOnly(e) || this._textSelectionRenderManager.handleDblClick(i);
2340
+ })), this.disposeWithMe(o.onTripleClick$.subscribeEvent((i) => {
2341
+ this._isEditorReadOnly(e) || this._textSelectionRenderManager.handleTripleClick(i);
2387
2342
  }));
2388
2343
  }
2389
- _getTransformCoordForDocumentOffset(e, t) {
2390
- const o = Q(this._context), { document: i, scene: r } = o, { documentTransform: s } = i.getOffsetConfig(), a = r.getViewports()[0];
2344
+ _getTransformCoordForDocumentOffset(e, n) {
2345
+ const o = J(this._context), { document: r, scene: i } = o, { documentTransform: s } = r.getOffsetConfig(), a = i.getViewports()[0];
2391
2346
  if (a == null)
2392
2347
  return;
2393
- const c = a.transformVector2SceneCoord(sn.FromArray([e, t]));
2348
+ const c = a.transformVector2SceneCoord(sn.FromArray([e, n]));
2394
2349
  return s.clone().invert().applyPoint(c);
2395
2350
  }
2396
2351
  _isEditorReadOnly(e) {
2397
- const t = this._editorService.getEditor(e);
2398
- return t ? t.isReadOnly() : !1;
2352
+ const n = this._editorService.getEditor(e);
2353
+ return n ? n.isReadOnly() : !1;
2399
2354
  }
2400
2355
  _setEditorFocus(e) {
2401
2356
  this._editorService.focusStyle(e);
2402
2357
  }
2403
2358
  _commandExecutedListener() {
2404
- const e = [ve.id];
2359
+ const e = [De.id];
2405
2360
  this.disposeWithMe(
2406
- this._commandService.onCommandExecuted((t) => {
2361
+ this._commandService.onCommandExecuted((n) => {
2407
2362
  var o;
2408
- if (e.includes(t.id)) {
2409
- const i = t.params, { unitId: r } = i, s = (o = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : o.unitId;
2410
- if (r !== s)
2363
+ if (e.includes(n.id)) {
2364
+ const r = n.params, { unitId: i } = r, s = (o = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : o.unitId;
2365
+ if (i !== s)
2411
2366
  return;
2412
2367
  this._textSelectionManagerService.refreshSelection();
2413
2368
  }
@@ -2419,11 +2374,11 @@ let dt = class extends K {
2419
2374
  this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
2420
2375
  if (e == null)
2421
2376
  return;
2422
- const { scene: t, mainComponent: o, unitId: i } = this._context;
2423
- this._textSelectionRenderManager.changeRuntime(e, t, o), this._textSelectionManagerService.setCurrentSelectionNotRefresh({
2424
- unitId: i,
2377
+ const { scene: n, mainComponent: o, unitId: r } = this._context;
2378
+ this._textSelectionRenderManager.changeRuntime(e, n, o), this._textSelectionManagerService.setCurrentSelectionNotRefresh({
2379
+ unitId: r,
2425
2380
  subUnitId: ""
2426
- }), this._editorService.isEditor(i) || this._textSelectionManagerService.replaceTextRanges([
2381
+ }), Pn(r) || this._textSelectionManagerService.replaceTextRanges([
2427
2382
  {
2428
2383
  startOffset: 0,
2429
2384
  endOffset: 0
@@ -2433,101 +2388,101 @@ let dt = class extends K {
2433
2388
  );
2434
2389
  }
2435
2390
  };
2436
- dt = wr([
2437
- re(1, C),
2438
- re(2, Y),
2439
- re(3, L),
2440
- re(4, oe),
2441
- re(5, T(N)),
2442
- re(6, T(ne))
2443
- ], dt);
2444
- var Br = Object.defineProperty, $r = Object.getOwnPropertyDescriptor, Hr = (n, e, t, o) => {
2445
- for (var i = o > 1 ? void 0 : o ? $r(e, t) : e, r = n.length - 1, s; r >= 0; r--)
2446
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
2447
- return o && i && Br(e, t, i), i;
2448
- }, Ie = (n, e) => (t, o) => e(t, o, n);
2449
- function zt(n, e) {
2450
- const t = Gt(n.left, n.top, e), o = Gt(n.right, n.bottom, e);
2391
+ ct = Ii([
2392
+ ie(1, O),
2393
+ ie(2, ee),
2394
+ ie(3, w),
2395
+ ie(4, ne),
2396
+ ie(5, E(L)),
2397
+ ie(6, E(te))
2398
+ ], ct);
2399
+ var bi = Object.defineProperty, Mi = Object.getOwnPropertyDescriptor, yi = (t, e, n, o) => {
2400
+ for (var r = o > 1 ? void 0 : o ? Mi(e, n) : e, i = t.length - 1, s; i >= 0; i--)
2401
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
2402
+ return o && r && bi(e, n, r), r;
2403
+ }, Te = (t, e) => (n, o) => e(n, o, t);
2404
+ function kt(t, e) {
2405
+ const n = Gt(t.left, t.top, e), o = Gt(t.right, t.bottom, e);
2451
2406
  return {
2452
- left: t.x,
2453
- top: t.y,
2407
+ left: n.x,
2408
+ top: n.y,
2454
2409
  right: o.x,
2455
2410
  bottom: o.y
2456
2411
  };
2457
2412
  }
2458
- function Gt(n, e, t) {
2459
- const { scaleX: o, scaleY: i } = t.getAncestorScale(), r = t.getViewport(te.VIEW_MAIN);
2460
- if (!r)
2413
+ function Gt(t, e, n) {
2414
+ const { scaleX: o, scaleY: r } = n.getAncestorScale(), i = n.getViewport(q.VIEW_MAIN);
2415
+ if (!i)
2461
2416
  return {
2462
- x: n,
2417
+ x: t,
2463
2418
  y: e
2464
2419
  };
2465
- const { viewportScrollX: s, viewportScrollY: a } = r, c = (n - s) * o, d = (e - a) * i;
2420
+ const { viewportScrollX: s, viewportScrollY: a } = i, c = (t - s) * o, d = (e - a) * r;
2466
2421
  return {
2467
2422
  x: c,
2468
2423
  y: d
2469
2424
  };
2470
2425
  }
2471
- let ut = class extends K {
2472
- constructor(n, e, t, o) {
2473
- super(), this._globalPopupManagerService = n, this._renderManagerService = e, this._univerInstanceService = t, this._commandService = o;
2426
+ let lt = class extends Q {
2427
+ constructor(t, e, n, o) {
2428
+ super(), this._globalPopupManagerService = t, this._renderManagerService = e, this._univerInstanceService = n, this._commandService = o;
2474
2429
  }
2475
2430
  // #region attach to object
2476
- _createObjectPositionObserver(n, e) {
2477
- const t = () => {
2478
- const { scene: a } = e, { left: c, top: d, width: p, height: g } = n, h = {
2479
- left: c,
2480
- right: c + p,
2481
- top: d,
2482
- bottom: d + g
2483
- }, l = zt(h, a);
2431
+ _createObjectPositionObserver(t, e) {
2432
+ const n = () => {
2433
+ const { scene: a, engine: c } = e, { left: d, top: g, width: h, height: p } = t, l = {
2434
+ left: d,
2435
+ right: d + h,
2436
+ top: g,
2437
+ bottom: g + p
2438
+ }, _ = kt(l, a), u = c.getCanvasElement().getBoundingClientRect().top;
2484
2439
  return {
2485
- left: l.left,
2486
- right: l.right,
2487
- top: l.top,
2488
- bottom: l.bottom
2440
+ left: _.left,
2441
+ right: _.right,
2442
+ top: _.top + u,
2443
+ bottom: _.bottom + u
2489
2444
  };
2490
- }, o = t(), i = new Pt(o), r = new vt();
2491
- r.add(this._commandService.onCommandExecuted((a) => {
2492
- a.id === ve.id && i.next(t());
2445
+ }, o = n(), r = new xt(o), i = new St();
2446
+ i.add(this._commandService.onCommandExecuted((a) => {
2447
+ a.id === De.id && r.next(n());
2493
2448
  }));
2494
- const s = e.scene.getViewport(te.VIEW_MAIN);
2495
- return s && r.add(s.onScrollAfter$.subscribeEvent(() => {
2496
- i.next(t());
2449
+ const s = e.scene.getViewport(q.VIEW_MAIN);
2450
+ return s && i.add(s.onScrollAfter$.subscribeEvent(() => {
2451
+ r.next(n());
2497
2452
  })), {
2498
2453
  position: o,
2499
- position$: i,
2500
- disposable: r
2454
+ position$: r,
2455
+ disposable: i
2501
2456
  };
2502
2457
  }
2503
- _createRangePositionObserver(n, e) {
2458
+ _createRangePositionObserver(t, e) {
2504
2459
  var a;
2505
- const t = () => {
2506
- const { scene: c, mainComponent: d } = e, p = e.with(N).getSkeleton(), g = p.findNodePositionByCharIndex(n.startOffset), h = p.findNodePositionByCharIndex(n.endOffset), l = d;
2507
- if (!h || !g)
2460
+ const n = () => {
2461
+ const { scene: c, mainComponent: d, engine: g } = e, h = e.with(L).getSkeleton(), p = h.findNodePositionByCharIndex(t.startOffset), l = h.findNodePositionByCharIndex(t.endOffset), _ = d;
2462
+ if (!l || !p)
2508
2463
  return;
2509
- const f = l.getOffsetConfig(), { docsLeft: u, docsTop: _ } = f, m = new rn(f, p), { borderBoxPointGroup: O } = m.getRangePointData(g, h);
2510
- return Do(O).map((R) => zt(R, c)).map((R) => ({
2511
- left: R.left + u,
2512
- right: R.right + u,
2513
- top: R.top + _,
2514
- bottom: R.bottom + _
2464
+ const u = _.getOffsetConfig(), { docsLeft: f, docsTop: m } = u, R = g.getCanvasElement().getBoundingClientRect().top, I = new rn(u, h), { borderBoxPointGroup: b } = I.getRangePointData(p, l);
2465
+ return Mo(b).map((N) => kt(N, c)).map((N) => ({
2466
+ left: N.left + f,
2467
+ right: N.right + f,
2468
+ top: N.top + m + R,
2469
+ bottom: N.bottom + m + R
2515
2470
  }));
2516
- }, o = (a = t()) != null ? a : [], i = new Pt(o), r = new vt();
2517
- r.add(this._commandService.onCommandExecuted((c) => {
2518
- if (c.id === ve.id) {
2519
- const d = t();
2520
- d && i.next(d);
2471
+ }, o = (a = n()) != null ? a : [], r = new xt(o), i = new St();
2472
+ i.add(this._commandService.onCommandExecuted((c) => {
2473
+ if (c.id === De.id) {
2474
+ const d = n();
2475
+ d && r.next(d);
2521
2476
  }
2522
2477
  }));
2523
- const s = e.scene.getViewport(te.VIEW_MAIN);
2524
- return s && r.add(s.onScrollAfter$.subscribeEvent(() => {
2525
- const c = t();
2526
- c && i.next(c);
2478
+ const s = e.scene.getViewport(q.VIEW_MAIN);
2479
+ return s && i.add(s.onScrollAfter$.subscribeEvent(() => {
2480
+ const c = n();
2481
+ c && r.next(c);
2527
2482
  })), {
2528
2483
  positions: o,
2529
- positions$: i,
2530
- disposable: r
2484
+ positions$: r,
2485
+ disposable: i
2531
2486
  };
2532
2487
  }
2533
2488
  /**
@@ -2536,18 +2491,18 @@ let ut = class extends K {
2536
2491
  * @param popup popup item
2537
2492
  * @returns disposable
2538
2493
  */
2539
- attachPopupToObject(n, e) {
2540
- const o = this._univerInstanceService.getCurrentUnitForType(v.UNIVER_DOC).getUnitId(), i = this._renderManagerService.getRenderById(o);
2541
- if (!i)
2494
+ attachPopupToObject(t, e) {
2495
+ const o = this._univerInstanceService.getCurrentUnitForType(v.UNIVER_DOC).getUnitId(), r = this._renderManagerService.getRenderById(o);
2496
+ if (!r)
2542
2497
  return {
2543
2498
  dispose: () => {
2544
2499
  }
2545
2500
  };
2546
- const { position: r, position$: s, disposable: a } = this._createObjectPositionObserver(n, i), c = this._globalPopupManagerService.addPopup({
2501
+ const { position: i, position$: s, disposable: a } = this._createObjectPositionObserver(t, r), c = this._globalPopupManagerService.addPopup({
2547
2502
  ...e,
2548
2503
  unitId: o,
2549
2504
  subUnitId: "default",
2550
- anchorRect: r,
2505
+ anchorRect: i,
2551
2506
  anchorRect$: s
2552
2507
  });
2553
2508
  return {
@@ -2556,73 +2511,73 @@ let ut = class extends K {
2556
2511
  }
2557
2512
  };
2558
2513
  }
2559
- attachPopupToRange(n, e) {
2560
- const o = this._univerInstanceService.getCurrentUnitForType(v.UNIVER_DOC).getUnitId(), { direction: i = "top" } = e, r = this._renderManagerService.getRenderById(o);
2561
- if (!r)
2514
+ attachPopupToRange(t, e) {
2515
+ const o = this._univerInstanceService.getCurrentUnitForType(v.UNIVER_DOC).getUnitId(), { direction: r = "top" } = e, i = this._renderManagerService.getRenderById(o);
2516
+ if (!i)
2562
2517
  return {
2563
2518
  dispose: () => {
2564
2519
  }
2565
2520
  };
2566
- const { positions: s, positions$: a, disposable: c } = this._createRangePositionObserver(n, r), d = a.pipe(Fo((g) => i === "top" ? g[0] : g[g.length - 1])), p = this._globalPopupManagerService.addPopup({
2521
+ const { positions: s, positions$: a, disposable: c } = this._createRangePositionObserver(t, i), d = a.pipe(xo((h) => r === "top" ? h[0] : h[h.length - 1])), g = this._globalPopupManagerService.addPopup({
2567
2522
  ...e,
2568
2523
  unitId: o,
2569
2524
  subUnitId: "default",
2570
- anchorRect: i === "top" ? s[0] : s[s.length - 1],
2525
+ anchorRect: r === "top" ? s[0] : s[s.length - 1],
2571
2526
  anchorRect$: d,
2572
2527
  excludeRects: s,
2573
2528
  excludeRects$: a,
2574
- direction: i === "top" ? "top" : "bottom"
2529
+ direction: r === "top" ? "top" : "bottom"
2575
2530
  });
2576
2531
  return {
2577
2532
  dispose: () => {
2578
- this._globalPopupManagerService.removePopup(p), a.complete(), c.dispose();
2533
+ this._globalPopupManagerService.removePopup(g), a.complete(), c.dispose();
2579
2534
  }
2580
2535
  };
2581
2536
  }
2582
2537
  };
2583
- ut = Hr([
2584
- Ie(0, T(Kn)),
2585
- Ie(1, k),
2586
- Ie(2, L),
2587
- Ie(3, C)
2588
- ], ut);
2589
- var Vr = Object.defineProperty, jr = Object.getOwnPropertyDescriptor, Wr = (n, e, t, o) => {
2590
- for (var i = o > 1 ? void 0 : o ? jr(e, t) : e, r = n.length - 1, s; r >= 0; r--)
2591
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
2592
- return o && i && Vr(e, t, i), i;
2593
- }, Yt = (n, e) => (t, o) => e(t, o, n);
2594
- let Pe = class extends Oe {
2595
- constructor(n, e) {
2596
- super(), this._instanceSrv = n, this._renderManagerService = e, this._init();
2538
+ lt = yi([
2539
+ Te(0, E(Yn)),
2540
+ Te(1, W),
2541
+ Te(2, w),
2542
+ Te(3, O)
2543
+ ], lt);
2544
+ var xi = Object.defineProperty, Pi = Object.getOwnPropertyDescriptor, Di = (t, e, n, o) => {
2545
+ for (var r = o > 1 ? void 0 : o ? Pi(e, n) : e, i = t.length - 1, s; i >= 0; i--)
2546
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
2547
+ return o && r && xi(e, n, r), r;
2548
+ }, zt = (t, e) => (n, o) => e(n, o, t);
2549
+ let xe = class extends Se {
2550
+ constructor(t, e) {
2551
+ super(), this._instanceSrv = t, this._renderManagerService = e, this._init();
2597
2552
  }
2598
2553
  _init() {
2599
- this._renderManagerService.createRender$.pipe(se(this.dispose$)).subscribe((n) => this._createRenderWithId(n)), this._instanceSrv.getTypeOfUnitAdded$(v.UNIVER_DOC).pipe(se(this.dispose$)).subscribe((n) => this._createRenderer(n)), this._instanceSrv.getAllUnitsForType(v.UNIVER_DOC).forEach((n) => this._createRenderer(n)), this._instanceSrv.getTypeOfUnitDisposed$(v.UNIVER_DOC).pipe(se(this.dispose$)).subscribe((n) => this._disposeRenderer(n));
2554
+ this._renderManagerService.createRender$.pipe(se(this.dispose$)).subscribe((t) => this._createRenderWithId(t)), this._instanceSrv.getTypeOfUnitAdded$(v.UNIVER_DOC).pipe(se(this.dispose$)).subscribe((t) => this._createRenderer(t)), this._instanceSrv.getAllUnitsForType(v.UNIVER_DOC).forEach((t) => this._createRenderer(t)), this._instanceSrv.getTypeOfUnitDisposed$(v.UNIVER_DOC).pipe(se(this.dispose$)).subscribe((t) => this._disposeRenderer(t));
2600
2555
  }
2601
- _createRenderer(n) {
2602
- const e = n.getUnitId();
2556
+ _createRenderer(t) {
2557
+ const e = t.getUnitId();
2603
2558
  this._renderManagerService.has(e) || (this._createRenderWithId(e), this._renderManagerService.setCurrent(e));
2604
2559
  }
2605
- _createRenderWithId(n) {
2606
- this._renderManagerService.createRender(n);
2560
+ _createRenderWithId(t) {
2561
+ this._renderManagerService.createRender(t);
2607
2562
  }
2608
- _disposeRenderer(n) {
2609
- const e = n.getUnitId();
2563
+ _disposeRenderer(t) {
2564
+ const e = t.getUnitId();
2610
2565
  this._renderManagerService.removeRender(e);
2611
2566
  }
2612
2567
  };
2613
- Pe = Wr([
2614
- Ue(we.Ready, Pe),
2615
- Yt(0, L),
2616
- Yt(1, k)
2617
- ], Pe);
2618
- var kr = Object.defineProperty, zr = Object.getOwnPropertyDescriptor, Gr = (n, e, t, o) => {
2619
- for (var i = o > 1 ? void 0 : o ? zr(e, t) : e, r = n.length - 1, s; r >= 0; r--)
2620
- (s = n[r]) && (i = (o ? s(e, t, i) : s(i)) || i);
2621
- return o && i && kr(e, t, i), i;
2622
- }, Qe = (n, e) => (t, o) => e(t, o, n), be;
2623
- let Xt = (be = class extends Dn {
2624
- constructor(n, e, t, o) {
2625
- super(), this._config = n, this._injector = e, this._renderManagerSrv = t, this._logService = o, this._config = ee.deepMerge({}, ci, this._config), this._initDependencies(e), this._initializeCommands();
2568
+ xe = Di([
2569
+ Be($e.Ready, xe),
2570
+ zt(0, w),
2571
+ zt(1, W)
2572
+ ], xe);
2573
+ var Ai = Object.defineProperty, Ni = Object.getOwnPropertyDescriptor, Fi = (t, e, n, o) => {
2574
+ for (var r = o > 1 ? void 0 : o ? Ni(e, n) : e, i = t.length - 1, s; i >= 0; i--)
2575
+ (s = t[i]) && (r = (o ? s(e, n, r) : s(r)) || r);
2576
+ return o && r && Ai(e, n, r), r;
2577
+ }, qe = (t, e) => (n, o) => e(n, o, t), Ie;
2578
+ let Yt = (Ie = class extends Dn {
2579
+ constructor(t, e, n, o) {
2580
+ super(), this._config = t, this._injector = e, this._renderManagerSrv = n, this._logService = o, this._config = j.deepMerge({}, nr, this._config), this._initDependencies(e), this._initializeCommands();
2626
2581
  }
2627
2582
  onReady() {
2628
2583
  this._initRenderBasics();
@@ -2632,116 +2587,115 @@ let Xt = (be = class extends Dn {
2632
2587
  }
2633
2588
  _initializeCommands() {
2634
2589
  [
2635
- di,
2636
- ui,
2637
- gi,
2638
- hi,
2639
- pi,
2640
- _i,
2641
- fi,
2642
- mi,
2643
- Si,
2644
- _r,
2645
- fr,
2646
- pr
2647
- ].forEach((n) => {
2648
- this._injector.get(Zn).registerShortcut(n);
2590
+ rr,
2591
+ ir,
2592
+ ar,
2593
+ sr,
2594
+ cr,
2595
+ lr,
2596
+ dr,
2597
+ ur,
2598
+ hr,
2599
+ si,
2600
+ ai,
2601
+ ii
2602
+ ].forEach((t) => {
2603
+ this._injector.get(Xn).registerShortcut(t);
2649
2604
  });
2650
2605
  }
2651
- _initDependencies(n) {
2606
+ _initDependencies(t) {
2652
2607
  [
2653
- [Se, { useFactory: () => this._injector.createInstance(Se, this._config) }],
2654
- [xe],
2655
- [ye],
2656
- [Pe],
2657
2608
  [me, { useFactory: () => this._injector.createInstance(me, this._config) }],
2658
- [Ce, { useClass: ot }],
2659
- [ut]
2660
- ].forEach((t) => n.add(t));
2609
+ [Me],
2610
+ [ye],
2611
+ [xe],
2612
+ [fe, { useFactory: () => this._injector.createInstance(fe, this._config) }],
2613
+ [Re, { useClass: nt }],
2614
+ [lt]
2615
+ ].forEach((n) => t.add(n));
2661
2616
  }
2662
2617
  _markDocAsFocused() {
2663
- const n = this._injector.get(L), e = this._injector.get(Y);
2618
+ const t = this._injector.get(w), e = this._injector.get(ee);
2664
2619
  try {
2665
- const t = n.getCurrentUnitForType(v.UNIVER_DOC);
2666
- if (!t) return;
2667
- const o = t.getUnitId();
2668
- e.isEditor(o) || n.focusUnit(t.getUnitId());
2669
- } catch (t) {
2670
- this._logService.warn(t);
2620
+ const n = t.getCurrentUnitForType(v.UNIVER_DOC);
2621
+ if (!n) return;
2622
+ const o = n.getUnitId();
2623
+ e.isEditor(o) || t.focusUnit(n.getUnitId());
2624
+ } catch (n) {
2625
+ this._logService.warn(n);
2671
2626
  }
2672
2627
  }
2673
2628
  _initUI() {
2674
- this._injector.get(me);
2629
+ this._injector.get(fe);
2675
2630
  }
2676
2631
  _initRenderBasics() {
2677
2632
  [
2678
- N,
2679
- Eo,
2680
- at,
2681
- lt
2682
- ].forEach((n) => {
2683
- this._renderManagerSrv.registerRenderModule(v.UNIVER_DOC, n);
2633
+ [L],
2634
+ [Ro],
2635
+ [st],
2636
+ [at]
2637
+ ].forEach((t) => {
2638
+ this._renderManagerSrv.registerRenderModule(v.UNIVER_DOC, t);
2684
2639
  });
2685
2640
  }
2686
2641
  _initRenderModules() {
2687
2642
  [
2688
- it,
2689
- ct,
2690
- dt,
2691
- st
2692
- ].forEach((n) => {
2693
- this._renderManagerSrv.registerRenderModule(v.UNIVER_DOC, n);
2643
+ [ot],
2644
+ [ct],
2645
+ [it]
2646
+ ].forEach((t) => {
2647
+ this._renderManagerSrv.registerRenderModule(v.UNIVER_DOC, t);
2694
2648
  });
2695
2649
  }
2696
- }, E(be, "pluginName", li), E(be, "type", v.UNIVER_DOC), be);
2697
- Xt = Gr([
2698
- Qe(1, T(Be)),
2699
- Qe(2, k),
2700
- Qe(3, Zt)
2701
- ], Xt);
2702
- function is(n) {
2650
+ }, C(Ie, "pluginName", or), C(Ie, "type", v.UNIVER_DOC), Ie);
2651
+ Yt = Fi([
2652
+ qe(1, E(Le)),
2653
+ qe(2, W),
2654
+ qe(3, Zt)
2655
+ ], Yt);
2656
+ function ki(t) {
2703
2657
  return {
2704
- left: n.positionH.posOffset,
2705
- top: n.positionV.posOffset,
2706
- width: n.size.width,
2707
- height: n.size.height
2658
+ left: t.positionH.posOffset,
2659
+ top: t.positionV.posOffset,
2660
+ width: t.size.width,
2661
+ height: t.size.height
2708
2662
  };
2709
2663
  }
2710
- function rs(n, e = 0, t = 0) {
2664
+ function Gi(t, e = 0, n = 0) {
2711
2665
  return {
2712
2666
  size: {
2713
- width: n.width,
2714
- height: n.height
2667
+ width: t.width,
2668
+ height: t.height
2715
2669
  },
2716
2670
  positionH: {
2717
2671
  relativeFrom: An.MARGIN,
2718
- posOffset: (n.left || 0) - e
2672
+ posOffset: (t.left || 0) - e
2719
2673
  },
2720
2674
  positionV: {
2721
- relativeFrom: Fn.PAGE,
2722
- posOffset: (n.top || 0) - t
2675
+ relativeFrom: Nn.PAGE,
2676
+ posOffset: (t.top || 0) - n
2723
2677
  },
2724
- angle: n.angle || 0
2678
+ angle: t.angle || 0
2725
2679
  };
2726
2680
  }
2727
2681
  export {
2728
- li as DOC_UI_PLUGIN_NAME,
2729
- ai as DefaultDocContainerConfig,
2730
- ci as DefaultDocUiConfig,
2731
- si as DefaultToolbarConfig,
2732
- it as DocBackScrollRenderController,
2733
- ut as DocCanvasPopManagerService,
2734
- mr as DocCopyCommand,
2735
- Sr as DocCutCommand,
2736
- vr as DocPasteCommand,
2737
- at as DocRenderController,
2738
- Pe as DocsRenderService,
2739
- Ce as IDocClipboardService,
2740
- Yo as PastePluginLark,
2741
- qo as PastePluginUniver,
2742
- Ko as PastePluginWord,
2743
- Xt as UniverDocsUIPlugin,
2744
- is as docDrawingPositionToTransform,
2745
- rs as transformToDocDrawingPosition,
2746
- z as whenDocAndEditorFocused
2682
+ or as DOC_UI_PLUGIN_NAME,
2683
+ tr as DefaultDocContainerConfig,
2684
+ nr as DefaultDocUiConfig,
2685
+ er as DefaultToolbarConfig,
2686
+ ot as DocBackScrollRenderController,
2687
+ lt as DocCanvasPopManagerService,
2688
+ ci as DocCopyCommand,
2689
+ li as DocCutCommand,
2690
+ di as DocPasteCommand,
2691
+ st as DocRenderController,
2692
+ xe as DocsRenderService,
2693
+ Re as IDocClipboardService,
2694
+ jo as PastePluginLark,
2695
+ zo as PastePluginUniver,
2696
+ ko as PastePluginWord,
2697
+ Yt as UniverDocsUIPlugin,
2698
+ ki as docDrawingPositionToTransform,
2699
+ Gi as transformToDocDrawingPosition,
2700
+ k as whenDocAndEditorFocused
2747
2701
  };