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