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