@univerjs/docs 0.1.0-alpha.2 → 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +1840 -1763
- package/lib/types/commands/commands/__tests__/mock-text-selection-render-manager.d.ts +24 -0
- package/lib/types/{basics/demo-data.d.ts → commands/commands/break-line.command.d.ts} +2 -2
- package/lib/types/commands/commands/core-editing.command.d.ts +2 -5
- package/lib/types/commands/commands/delete.command.d.ts +26 -0
- package/lib/types/commands/commands/inline-format.command.d.ts +2 -0
- package/lib/types/commands/commands/list.command.d.ts +28 -0
- package/lib/types/commands/operations/text-selection.operation.d.ts +4 -2
- package/lib/types/controllers/clipboard.controller.d.ts +3 -3
- package/lib/types/controllers/doc-render.controller.d.ts +2 -2
- package/lib/types/controllers/ime-input.controller.d.ts +1 -3
- package/lib/types/controllers/inline-format.controller.d.ts +2 -5
- package/lib/types/controllers/move-cursor.controller.d.ts +2 -3
- package/lib/types/controllers/normal-input.controller.d.ts +1 -3
- package/lib/types/controllers/page-render.controller.d.ts +3 -2
- package/lib/types/controllers/text-selection.controller.d.ts +5 -5
- package/lib/types/index.d.ts +7 -2
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts +5 -5
- package/lib/types/services/text-selection-manager.service.d.ts +33 -31
- package/lib/types/views/doc-canvas-view.d.ts +5 -2
- package/lib/umd/index.js +2 -2
- package/package.json +12 -14
- package/lib/types/controllers/delete.controller.d.ts +0 -30
- package/lib/types/controllers/line-break-input.controller.d.ts +0 -34
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import {
|
|
6
|
-
import { BehaviorSubject as
|
|
7
|
-
import {
|
|
8
|
-
import { createIdentifier as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const n = r.getCurrentUniverDocInstance().getUnitId(), s = e.getRenderById(n);
|
|
1
|
+
var Ft = Object.defineProperty;
|
|
2
|
+
var kt = (n, e, t) => e in n ? Ft(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var S = (n, e, t) => (kt(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { CommandType as R, RxDisposable as Ze, ICommandService as x, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as K, IUniverInstanceService as O, IUndoRedoService as N, DataStreamTreeTokenType as He, Tools as H, FOCUSING_DOC as w, FOCUSING_EDITOR as me, LocaleService as It, MemoryCursor as we, getDocsUpdateBody as zt, UpdateDocsAttributeType as xt, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as J, BooleanNumber as D, BaselineOffset as j, PresetListType as Ot, LRUMap as Wt, ColorKit as it, Disposable as W, toDisposable as Ge, OnLifecycle as V, LifecycleStages as F, ILogService as Ht, IContextService as Gt, DEFAULT_DOCUMENT_SUB_COMPONENT_ID as Xt, IFloatingObjectManagerService as qt, Direction as b, IConfigService as yt, Plugin as Yt, PluginType as Zt } from "@univerjs/core";
|
|
5
|
+
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as Kt, ITextSelectionRenderManager as fe, DocumentViewModel as Jt, DocumentSkeleton as Qt, hasListSpan as en, isIndentBySpan as tn, isFirstSpan as nn, getParagraphBySpan as rn, PageLayoutType as ot, IRenderManagerService as G, Liquid as sn, RANGE_DIRECTION as at, NodePositionConvertToCursor as ct, Rect as on, CURSOR_TYPE as lt, Viewport as an, EVENT_TYPE as cn, ScrollBar as ln, Layer as dt, Documents as dn, TextSelectionRenderManager as un } from "@univerjs/engine-render";
|
|
6
|
+
import { BehaviorSubject as de, takeUntil as bt } from "rxjs";
|
|
7
|
+
import { CopyCommand as hn, CutCommand as pn, PasteCommand as gn, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as mn, HTML_CLIPBOARD_MIME_TYPE as fn, IClipboardInterfaceService as _n, LayoutService as Sn, KeyCode as $, MetaKeys as _e, IShortcutService as vn } from "@univerjs/ui";
|
|
8
|
+
import { Inject as U, createIdentifier as Mn, Optional as Cn, Injector as Rn } from "@wendellhu/redi";
|
|
9
|
+
function Le(n, e) {
|
|
10
|
+
const r = n.getCurrentUniverDocInstance().getUnitId(), s = e.getRenderById(r);
|
|
12
11
|
if (s == null)
|
|
13
12
|
return;
|
|
14
13
|
const { mainComponent: i, scene: o, engine: a } = s;
|
|
@@ -18,189 +17,175 @@ function pe(r, e) {
|
|
|
18
17
|
engine: a
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
|
-
function
|
|
22
|
-
const t = e.getRenderById(
|
|
20
|
+
function In(n, e) {
|
|
21
|
+
const t = e.getRenderById(n);
|
|
23
22
|
if (t == null)
|
|
24
23
|
return;
|
|
25
|
-
const {
|
|
24
|
+
const { mainComponent: r, scene: s, engine: i } = t;
|
|
26
25
|
return {
|
|
27
|
-
document:
|
|
28
|
-
scene:
|
|
29
|
-
engine:
|
|
26
|
+
document: r,
|
|
27
|
+
scene: s,
|
|
28
|
+
engine: i
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
|
-
var
|
|
33
|
-
const
|
|
34
|
-
id:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
multi: !0,
|
|
38
|
-
priority: 999,
|
|
39
|
-
preconditions: (r) => r.getContextValue(T) || r.getContextValue(ge),
|
|
40
|
-
handler: async () => !0
|
|
41
|
-
}, Xe = {
|
|
42
|
-
id: Gt.id,
|
|
43
|
-
name: "doc.command.cut",
|
|
44
|
-
type: C.COMMAND,
|
|
45
|
-
multi: !0,
|
|
46
|
-
priority: 999,
|
|
47
|
-
preconditions: (r) => r.getContextValue(T) || r.getContextValue(ge),
|
|
48
|
-
handler: async () => !0
|
|
49
|
-
}, qe = {
|
|
50
|
-
id: Xt.id,
|
|
51
|
-
name: "doc.command.paste",
|
|
52
|
-
type: C.COMMAND,
|
|
53
|
-
multi: !0,
|
|
54
|
-
priority: 999,
|
|
55
|
-
preconditions: (r) => r.getContextValue(T) || r.getContextValue(ge),
|
|
56
|
-
handler: async () => !0
|
|
31
|
+
var Xe = /* @__PURE__ */ ((n) => (n.MAIN = "__Document_Render_Main__", n))(Xe || {}), Ke = /* @__PURE__ */ ((n) => (n.VIEW_MAIN = "viewMain", n.VIEW_TOP = "viewTop", n.VIEW_LEFT = "viewLeft", n.VIEW_LEFT_TOP = "viewLeftTop", n))(Ke || {});
|
|
32
|
+
const ut = 0, xn = 2, On = 10, hs = "normalTextSelectionPluginName", Dt = {
|
|
33
|
+
id: "doc.operation.set-selections",
|
|
34
|
+
type: R.OPERATION,
|
|
35
|
+
handler: (n, e) => !0
|
|
57
36
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
37
|
+
var yn = Object.defineProperty, bn = Object.getOwnPropertyDescriptor, Dn = (n, e, t, r) => {
|
|
38
|
+
for (var s = r > 1 ? void 0 : r ? bn(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
39
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
40
|
+
return r && s && yn(e, t, s), s;
|
|
41
|
+
}, ht = (n, e) => (t, r) => e(t, r, n);
|
|
42
|
+
function pt(n) {
|
|
43
|
+
const { startOffset: e, endOffset: t, collapsed: r } = n;
|
|
44
|
+
return {
|
|
45
|
+
startOffset: e,
|
|
46
|
+
endOffset: t,
|
|
47
|
+
collapsed: r
|
|
48
|
+
};
|
|
70
49
|
}
|
|
71
|
-
|
|
72
|
-
constructor() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
50
|
+
let P = class extends Ze {
|
|
51
|
+
constructor(e, t) {
|
|
52
|
+
super();
|
|
53
|
+
S(this, "_currentSelection", null);
|
|
54
|
+
S(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
|
|
55
|
+
S(this, "_textSelection$", new de(null));
|
|
56
|
+
S(this, "textSelection$", this._textSelection$.asObservable());
|
|
57
|
+
this._textSelectionRenderManager = e, this._commandService = t, this._syncSelectionFromRenderService();
|
|
77
58
|
}
|
|
78
59
|
getCurrentSelection() {
|
|
79
60
|
return this._currentSelection;
|
|
80
61
|
}
|
|
62
|
+
// Get textRanges, style, segmentId
|
|
63
|
+
getCurrentSelectionInfo() {
|
|
64
|
+
return this._getTextRanges(this._currentSelection);
|
|
65
|
+
}
|
|
81
66
|
dispose() {
|
|
82
|
-
this.
|
|
67
|
+
this._textSelection$.complete();
|
|
83
68
|
}
|
|
84
69
|
refreshSelection() {
|
|
85
70
|
this._currentSelection != null && this._refresh(this._currentSelection);
|
|
86
71
|
}
|
|
72
|
+
// **Only used in test case** because this does not go through the render layer.
|
|
87
73
|
setCurrentSelection(e) {
|
|
88
74
|
this._currentSelection = e, this._refresh(e);
|
|
89
75
|
}
|
|
90
76
|
setCurrentSelectionNotRefresh(e) {
|
|
91
77
|
this._currentSelection = e;
|
|
92
78
|
}
|
|
93
|
-
getTextSelectionInfo() {
|
|
94
|
-
return this._textSelectionInfo;
|
|
95
|
-
}
|
|
96
|
-
getTextRangesByParam(e) {
|
|
97
|
-
return this._getTextRanges(e);
|
|
98
|
-
}
|
|
99
79
|
getSelections() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
getFirst() {
|
|
103
|
-
return this._getFirstByParam(this._currentSelection);
|
|
80
|
+
var e;
|
|
81
|
+
return (e = this._getTextRanges(this._currentSelection)) == null ? void 0 : e.textRanges;
|
|
104
82
|
}
|
|
105
|
-
|
|
106
|
-
|
|
83
|
+
getActiveRange() {
|
|
84
|
+
const e = this._getTextRanges(this._currentSelection);
|
|
85
|
+
if (e == null)
|
|
86
|
+
return;
|
|
87
|
+
const { textRanges: t, segmentId: r, style: s } = e, i = t.find((p) => p.isActive());
|
|
88
|
+
if (i == null)
|
|
89
|
+
return null;
|
|
90
|
+
const { startOffset: o, endOffset: a, collapsed: c, startNodePosition: d, endNodePosition: l, direction: h } = i;
|
|
91
|
+
return o == null || a == null ? null : {
|
|
92
|
+
startOffset: o,
|
|
93
|
+
endOffset: a,
|
|
94
|
+
collapsed: c,
|
|
95
|
+
startNodePosition: d,
|
|
96
|
+
endNodePosition: l,
|
|
97
|
+
direction: h,
|
|
98
|
+
segmentId: r,
|
|
99
|
+
style: s
|
|
100
|
+
};
|
|
107
101
|
}
|
|
108
|
-
// Only used in
|
|
102
|
+
// **Only used in test case** because this does not go through the render layer.
|
|
109
103
|
add(e) {
|
|
110
104
|
this._currentSelection != null && this._addByParam({
|
|
111
105
|
...this._currentSelection,
|
|
112
|
-
textRanges: e
|
|
106
|
+
textRanges: e,
|
|
107
|
+
segmentId: "",
|
|
108
|
+
style: Kt
|
|
109
|
+
// mock style.
|
|
113
110
|
});
|
|
114
111
|
}
|
|
115
112
|
replaceTextRanges(e) {
|
|
116
|
-
this._currentSelection != null && this.
|
|
113
|
+
this._currentSelection != null && (this._textSelectionRenderManager.removeAllTextRanges(), this._textSelectionRenderManager.addTextRanges(e));
|
|
117
114
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
// All textRanges should be synchronized from the render layer.
|
|
116
|
+
_syncSelectionFromRenderService() {
|
|
117
|
+
this._textSelectionRenderManager.textSelectionInner$.pipe(bt(this.dispose$)).subscribe((e) => {
|
|
118
|
+
e != null && this._replaceTextRangesWithNoRefresh(e);
|
|
122
119
|
});
|
|
123
120
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var e;
|
|
141
|
-
this._currentSelection != null && (this._currentSelection = {
|
|
142
|
-
pluginName: Ne,
|
|
143
|
-
unitId: (e = this._currentSelection) == null ? void 0 : e.unitId
|
|
144
|
-
}, this._textSelectionInfo.clear(), this._refresh(this._currentSelection));
|
|
145
|
-
}
|
|
146
|
-
// It is will being opened when it needs to be used
|
|
147
|
-
_resetPlugin() {
|
|
148
|
-
this._currentSelection != null && (this._currentSelection.pluginName = Ne, this._refresh(this._currentSelection));
|
|
121
|
+
_replaceTextRangesWithNoRefresh(e) {
|
|
122
|
+
if (this._currentSelection == null)
|
|
123
|
+
return;
|
|
124
|
+
const t = {
|
|
125
|
+
...this._currentSelection,
|
|
126
|
+
...e
|
|
127
|
+
};
|
|
128
|
+
this._replaceByParam(t), this._textSelection$.next(t);
|
|
129
|
+
const { unitId: r, subUnitId: s, segmentId: i, style: o, textRanges: a } = t;
|
|
130
|
+
this._commandService.executeCommand(Dt.id, {
|
|
131
|
+
unitId: r,
|
|
132
|
+
subUnitId: s,
|
|
133
|
+
segmentId: i,
|
|
134
|
+
style: o,
|
|
135
|
+
ranges: a.map(pt)
|
|
136
|
+
});
|
|
149
137
|
}
|
|
150
138
|
_getTextRanges(e) {
|
|
151
139
|
var s;
|
|
152
140
|
if (e == null)
|
|
153
141
|
return;
|
|
154
|
-
const {
|
|
155
|
-
return (s = this._textSelectionInfo.get(t)) == null ? void 0 : s.get(
|
|
142
|
+
const { unitId: t, subUnitId: r = "" } = e;
|
|
143
|
+
return (s = this._textSelectionInfo.get(t)) == null ? void 0 : s.get(r);
|
|
156
144
|
}
|
|
157
145
|
_refresh(e) {
|
|
158
|
-
const t = this._getTextRanges(e) ?? [];
|
|
159
|
-
this._textSelectionInfo$.next(
|
|
160
|
-
t.map((n) => {
|
|
161
|
-
const s = n.startOffset, i = n.endOffset, o = n.collapsed, a = n.style;
|
|
162
|
-
return {
|
|
163
|
-
startOffset: s,
|
|
164
|
-
endOffset: i,
|
|
165
|
-
collapsed: o,
|
|
166
|
-
style: a
|
|
167
|
-
};
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
_getFirstByParam(e) {
|
|
172
|
-
const t = this._getTextRanges(e);
|
|
173
|
-
return t == null ? void 0 : t[0];
|
|
174
|
-
}
|
|
175
|
-
_getLastByParam(e) {
|
|
176
146
|
const t = this._getTextRanges(e);
|
|
177
|
-
|
|
147
|
+
this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(pt));
|
|
178
148
|
}
|
|
179
149
|
_replaceByParam(e) {
|
|
180
|
-
const {
|
|
181
|
-
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map()), this._textSelectionInfo.get(t).set(
|
|
182
|
-
}
|
|
183
|
-
_clearByParam(e) {
|
|
184
|
-
const t = this._getTextRanges(e);
|
|
185
|
-
t == null || t.splice(0), this._refresh(e);
|
|
150
|
+
const { unitId: t, subUnitId: r, style: s, segmentId: i, textRanges: o } = e;
|
|
151
|
+
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map()), this._textSelectionInfo.get(t).set(r, { textRanges: o, style: s, segmentId: i });
|
|
186
152
|
}
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
153
|
+
_addByParam(e) {
|
|
154
|
+
const { unitId: t, subUnitId: r, textRanges: s, style: i, segmentId: o } = e;
|
|
155
|
+
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map());
|
|
156
|
+
const a = this._textSelectionInfo.get(t);
|
|
157
|
+
a.has(r) ? a.get(r).textRanges.push(...s) : a.set(r, { textRanges: s, style: i, segmentId: o });
|
|
190
158
|
}
|
|
159
|
+
};
|
|
160
|
+
P = Dn([
|
|
161
|
+
ht(0, fe),
|
|
162
|
+
ht(1, x)
|
|
163
|
+
], P);
|
|
164
|
+
function Ae(n, e = "", t = 0) {
|
|
165
|
+
const { startOffset: r, endOffset: s } = n, i = [], o = r - t, a = s - t;
|
|
166
|
+
return o > 0 && i.push({
|
|
167
|
+
t: "r",
|
|
168
|
+
len: o,
|
|
169
|
+
segmentId: e
|
|
170
|
+
}), i.push({
|
|
171
|
+
t: "d",
|
|
172
|
+
len: a - o,
|
|
173
|
+
line: 0,
|
|
174
|
+
segmentId: e
|
|
175
|
+
}), i;
|
|
191
176
|
}
|
|
192
|
-
var
|
|
193
|
-
for (var s =
|
|
194
|
-
(o =
|
|
195
|
-
return
|
|
196
|
-
},
|
|
197
|
-
let
|
|
198
|
-
constructor(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this._currentUniverService =
|
|
177
|
+
var Tn = Object.defineProperty, Pn = Object.getOwnPropertyDescriptor, En = (n, e, t, r) => {
|
|
178
|
+
for (var s = r > 1 ? void 0 : r ? Pn(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
179
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
180
|
+
return r && s && Tn(e, t, s), s;
|
|
181
|
+
}, Un = (n, e) => (t, r) => e(t, r, n);
|
|
182
|
+
let se = class {
|
|
183
|
+
constructor(n) {
|
|
184
|
+
S(this, "_currentViewModelUnitId", "");
|
|
185
|
+
S(this, "_docViewModelMap", /* @__PURE__ */ new Map());
|
|
186
|
+
S(this, "_currentDocViewModel$", new de(null));
|
|
187
|
+
S(this, "currentDocViewModel$", this._currentDocViewModel$.asObservable());
|
|
188
|
+
this._currentUniverService = n;
|
|
204
189
|
}
|
|
205
190
|
dispose() {
|
|
206
191
|
this._currentDocViewModel$.complete(), this._docViewModelMap = /* @__PURE__ */ new Map();
|
|
@@ -208,195 +193,634 @@ let ee = class {
|
|
|
208
193
|
getCurrent() {
|
|
209
194
|
return this._docViewModelMap.get(this._currentViewModelUnitId);
|
|
210
195
|
}
|
|
211
|
-
getViewModel(
|
|
196
|
+
getViewModel(n) {
|
|
212
197
|
var e;
|
|
213
|
-
return (e = this._docViewModelMap.get(
|
|
198
|
+
return (e = this._docViewModelMap.get(n)) == null ? void 0 : e.docViewModel;
|
|
214
199
|
}
|
|
215
|
-
setCurrent(
|
|
200
|
+
setCurrent(n) {
|
|
216
201
|
var t;
|
|
217
|
-
const e = this._currentUniverService.getUniverDocInstance(
|
|
202
|
+
const e = this._currentUniverService.getUniverDocInstance(n);
|
|
218
203
|
if (e == null)
|
|
219
|
-
throw new Error(`Document data model with id ${
|
|
204
|
+
throw new Error(`Document data model with id ${n} not found when build view model.`);
|
|
220
205
|
if (e.getBody() != null) {
|
|
221
|
-
if (!this._docViewModelMap.has(
|
|
222
|
-
const
|
|
223
|
-
this._docViewModelMap.set(
|
|
224
|
-
unitId:
|
|
225
|
-
docViewModel:
|
|
206
|
+
if (!this._docViewModelMap.has(n)) {
|
|
207
|
+
const r = this._buildDocViewModel(e);
|
|
208
|
+
this._docViewModelMap.set(n, {
|
|
209
|
+
unitId: n,
|
|
210
|
+
docViewModel: r
|
|
226
211
|
});
|
|
227
212
|
}
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
213
|
+
if (n === K) {
|
|
214
|
+
const r = (t = this._docViewModelMap.get(n)) == null ? void 0 : t.docViewModel;
|
|
215
|
+
if (r == null)
|
|
231
216
|
return;
|
|
232
|
-
|
|
217
|
+
r.reset(e);
|
|
233
218
|
}
|
|
234
|
-
this._currentViewModelUnitId =
|
|
219
|
+
this._currentViewModelUnitId = n, this._currentDocViewModel$.next(this.getCurrent());
|
|
235
220
|
}
|
|
236
221
|
}
|
|
237
|
-
_buildDocViewModel(
|
|
238
|
-
return new Jt(
|
|
222
|
+
_buildDocViewModel(n) {
|
|
223
|
+
return new Jt(n);
|
|
239
224
|
}
|
|
240
225
|
};
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
],
|
|
244
|
-
const
|
|
226
|
+
se = En([
|
|
227
|
+
Un(0, O)
|
|
228
|
+
], se);
|
|
229
|
+
const _ = {
|
|
245
230
|
id: "doc.mutation.rich-text-editing",
|
|
246
|
-
type:
|
|
247
|
-
handler: (
|
|
248
|
-
const { unitId: t, mutations:
|
|
249
|
-
if (
|
|
250
|
-
throw new Error(`DocumentDataModel not found for unitId: ${t}`);
|
|
251
|
-
const c =
|
|
252
|
-
|
|
253
|
-
const { segmentId: f, len: h } = d, u = a == null ? void 0 : a.getSelfOrHeaderFooterViewModel(f);
|
|
254
|
-
if (d.t === "r") {
|
|
255
|
-
const { len: g } = d;
|
|
256
|
-
c.moveCursor(g);
|
|
257
|
-
} else if (d.t === "i") {
|
|
258
|
-
const { body: g } = d;
|
|
259
|
-
if (g.dataStream.length > 1 && /\r/.test(g.dataStream)) {
|
|
260
|
-
const p = i.getSelfOrHeaderFooterModel(f);
|
|
261
|
-
u.reset(p);
|
|
262
|
-
} else
|
|
263
|
-
u.insert(g, c.cursor);
|
|
264
|
-
c.moveCursor(h);
|
|
265
|
-
} else if (d.t === "d")
|
|
266
|
-
u.delete(c.cursor, h);
|
|
267
|
-
else
|
|
268
|
-
throw new Error(`Unknown mutation type for mutation: ${d}.`);
|
|
269
|
-
});
|
|
270
|
-
const l = i.apply(n);
|
|
271
|
-
return {
|
|
231
|
+
type: R.MUTATION,
|
|
232
|
+
handler: (n, e) => {
|
|
233
|
+
const { unitId: t, mutations: r } = e, i = n.get(O).getUniverDocInstance(t), a = n.get(se).getViewModel(t);
|
|
234
|
+
if (i == null || a == null)
|
|
235
|
+
throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${t}`);
|
|
236
|
+
const c = i.apply(r), d = r[0].segmentId, l = i.getSelfOrHeaderFooterModel(d);
|
|
237
|
+
return a.getSelfOrHeaderFooterViewModel(d).reset(l), {
|
|
272
238
|
unitId: t,
|
|
273
|
-
mutations:
|
|
239
|
+
mutations: c
|
|
274
240
|
};
|
|
275
241
|
}
|
|
276
|
-
},
|
|
277
|
-
id: "doc.command.delete-left",
|
|
278
|
-
type: C.COMMAND,
|
|
279
|
-
handler: async () => !0
|
|
280
|
-
}, Be = {
|
|
281
|
-
id: "doc.command.delete-right",
|
|
282
|
-
type: C.COMMAND,
|
|
283
|
-
handler: async () => !0
|
|
284
|
-
}, st = {
|
|
285
|
-
id: "doc.command.break-line",
|
|
286
|
-
type: C.COMMAND,
|
|
287
|
-
handler: async () => !0
|
|
288
|
-
}, it = {
|
|
242
|
+
}, Je = {
|
|
289
243
|
id: "doc.command.insert-text",
|
|
290
|
-
type:
|
|
291
|
-
handler: async (
|
|
292
|
-
const t =
|
|
293
|
-
id:
|
|
244
|
+
type: R.COMMAND,
|
|
245
|
+
handler: async (n, e) => {
|
|
246
|
+
const t = n.get(N), r = n.get(x), s = n.get(P), { range: i, segmentId: o, body: a, unitId: c, textRanges: d } = e, { startOffset: l, collapsed: h } = i, p = {
|
|
247
|
+
id: _.id,
|
|
294
248
|
params: {
|
|
295
249
|
unitId: c,
|
|
296
250
|
mutations: []
|
|
297
251
|
}
|
|
298
252
|
};
|
|
299
|
-
|
|
253
|
+
h ? l > 0 && p.params.mutations.push({
|
|
300
254
|
t: "r",
|
|
301
|
-
len:
|
|
255
|
+
len: l,
|
|
302
256
|
segmentId: o
|
|
303
|
-
}) :
|
|
257
|
+
}) : p.params.mutations.push(...Ae(i, o)), p.params.mutations.push({
|
|
304
258
|
t: "i",
|
|
305
259
|
body: a,
|
|
306
260
|
len: a.dataStream.length,
|
|
307
261
|
line: 0,
|
|
308
262
|
segmentId: o
|
|
309
263
|
});
|
|
310
|
-
const u =
|
|
311
|
-
return s.replaceTextRanges(
|
|
264
|
+
const u = r.syncExecuteCommand(p.id, p.params);
|
|
265
|
+
return s.replaceTextRanges(d), u ? (t.pushUndoRedo({
|
|
312
266
|
unitID: c,
|
|
313
|
-
undoMutations: [{ id:
|
|
314
|
-
redoMutations: [{ id:
|
|
267
|
+
undoMutations: [{ id: _.id, params: u }],
|
|
268
|
+
redoMutations: [{ id: _.id, params: p.params }],
|
|
315
269
|
undo() {
|
|
316
|
-
return
|
|
270
|
+
return r.syncExecuteCommand(_.id, u), s.replaceTextRanges([i]), !0;
|
|
317
271
|
},
|
|
318
272
|
redo() {
|
|
319
|
-
return
|
|
273
|
+
return r.syncExecuteCommand(_.id, p.params), s.replaceTextRanges(d), !0;
|
|
320
274
|
}
|
|
321
275
|
}), !0) : !1;
|
|
322
276
|
}
|
|
323
277
|
};
|
|
324
|
-
var
|
|
325
|
-
const
|
|
278
|
+
var q = /* @__PURE__ */ ((n) => (n[n.LEFT = 0] = "LEFT", n[n.RIGHT = 1] = "RIGHT", n))(q || {});
|
|
279
|
+
const Qe = {
|
|
326
280
|
id: "doc.command.delete-text",
|
|
327
|
-
type:
|
|
328
|
-
handler: async (
|
|
329
|
-
const t =
|
|
330
|
-
id:
|
|
281
|
+
type: R.COMMAND,
|
|
282
|
+
handler: async (n, e) => {
|
|
283
|
+
const t = n.get(x), r = n.get(N), s = n.get(P), { range: i, segmentId: o, unitId: a, direction: c, textRanges: d, len: l = 1 } = e, { startOffset: h } = i, p = {
|
|
284
|
+
id: _.id,
|
|
331
285
|
params: {
|
|
332
286
|
unitId: a,
|
|
333
287
|
mutations: []
|
|
334
288
|
}
|
|
335
289
|
};
|
|
336
|
-
|
|
290
|
+
h > 0 && p.params.mutations.push({
|
|
337
291
|
t: "r",
|
|
338
|
-
len: c === 0 ? h -
|
|
292
|
+
len: c === 0 ? h - l : h,
|
|
339
293
|
segmentId: o
|
|
340
|
-
}),
|
|
294
|
+
}), p.params.mutations.push({
|
|
341
295
|
t: "d",
|
|
342
|
-
len:
|
|
296
|
+
len: l,
|
|
343
297
|
line: 0,
|
|
344
298
|
segmentId: o
|
|
345
|
-
})
|
|
346
|
-
const
|
|
347
|
-
return s.replaceTextRanges(
|
|
299
|
+
});
|
|
300
|
+
const u = t.syncExecuteCommand(p.id, p.params);
|
|
301
|
+
return s.replaceTextRanges(d), u && r.pushUndoRedo({
|
|
348
302
|
unitID: a,
|
|
349
|
-
undoMutations: [{ id:
|
|
350
|
-
redoMutations: [{ id:
|
|
303
|
+
undoMutations: [{ id: _.id, params: u }],
|
|
304
|
+
redoMutations: [{ id: _.id, params: p.params }],
|
|
351
305
|
undo() {
|
|
352
|
-
return t.syncExecuteCommand(
|
|
306
|
+
return t.syncExecuteCommand(_.id, u), s.replaceTextRanges([i]), !0;
|
|
353
307
|
},
|
|
354
308
|
redo() {
|
|
355
|
-
return t.syncExecuteCommand(
|
|
309
|
+
return t.syncExecuteCommand(_.id, p.params), s.replaceTextRanges(d), !0;
|
|
356
310
|
}
|
|
357
311
|
}), !1;
|
|
358
312
|
}
|
|
359
|
-
},
|
|
313
|
+
}, Tt = {
|
|
360
314
|
id: "doc.command.update-text",
|
|
361
|
-
type:
|
|
362
|
-
handler: async (
|
|
363
|
-
const { range: t, segmentId:
|
|
364
|
-
id:
|
|
315
|
+
type: R.COMMAND,
|
|
316
|
+
handler: async (n, e) => {
|
|
317
|
+
const { range: t, segmentId: r, updateBody: s, coverType: i, unitId: o, textRanges: a } = e, c = n.get(x), d = n.get(N), l = n.get(P), h = {
|
|
318
|
+
id: _.id,
|
|
365
319
|
params: {
|
|
366
320
|
unitId: o,
|
|
367
321
|
mutations: []
|
|
368
322
|
}
|
|
369
|
-
}, { startOffset:
|
|
370
|
-
|
|
323
|
+
}, { startOffset: p, endOffset: u } = t;
|
|
324
|
+
h.params.mutations.push({
|
|
371
325
|
t: "r",
|
|
372
|
-
len:
|
|
373
|
-
segmentId:
|
|
374
|
-
}),
|
|
326
|
+
len: p,
|
|
327
|
+
segmentId: r
|
|
328
|
+
}), h.params.mutations.push({
|
|
375
329
|
t: "r",
|
|
376
330
|
body: s,
|
|
377
|
-
len: u -
|
|
378
|
-
segmentId:
|
|
331
|
+
len: u - p,
|
|
332
|
+
segmentId: r,
|
|
379
333
|
coverType: i
|
|
380
334
|
});
|
|
381
|
-
const g = c.syncExecuteCommand(
|
|
382
|
-
return
|
|
335
|
+
const g = c.syncExecuteCommand(h.id, h.params);
|
|
336
|
+
return l.replaceTextRanges(a), g ? (d.pushUndoRedo({
|
|
383
337
|
unitID: o,
|
|
384
|
-
undoMutations: [{ id:
|
|
385
|
-
redoMutations: [{ id:
|
|
338
|
+
undoMutations: [{ id: _.id, params: g }],
|
|
339
|
+
redoMutations: [{ id: _.id, params: h.params }],
|
|
340
|
+
undo() {
|
|
341
|
+
return c.syncExecuteCommand(_.id, g), l.replaceTextRanges(a), !0;
|
|
342
|
+
},
|
|
343
|
+
redo() {
|
|
344
|
+
return c.syncExecuteCommand(_.id, h.params), l.replaceTextRanges(a), !0;
|
|
345
|
+
}
|
|
346
|
+
}), !0) : !1;
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
function wn(n, e) {
|
|
350
|
+
const t = [];
|
|
351
|
+
for (let r = 0, s = n.length; r < s; r++)
|
|
352
|
+
n[r] === He.PARAGRAPH && t.push({
|
|
353
|
+
startIndex: r
|
|
354
|
+
});
|
|
355
|
+
if (e)
|
|
356
|
+
for (const r of t)
|
|
357
|
+
e.bullet && (r.bullet = H.deepClone(e.bullet)), e.paragraphStyle && (r.paragraphStyle = H.deepClone(e.paragraphStyle));
|
|
358
|
+
return t;
|
|
359
|
+
}
|
|
360
|
+
const Pt = {
|
|
361
|
+
id: "doc.command.break-line",
|
|
362
|
+
type: R.COMMAND,
|
|
363
|
+
handler: async (n) => {
|
|
364
|
+
var g;
|
|
365
|
+
const e = n.get(P), t = n.get(O), r = n.get(x), s = e.getActiveRange();
|
|
366
|
+
if (s == null)
|
|
367
|
+
return !1;
|
|
368
|
+
const i = t.getCurrentUniverDocInstance(), o = i.getUnitId(), { startOffset: a, segmentId: c, style: d } = s, l = [
|
|
369
|
+
{
|
|
370
|
+
startOffset: a + 1,
|
|
371
|
+
endOffset: a + 1,
|
|
372
|
+
style: d
|
|
373
|
+
}
|
|
374
|
+
], p = (((g = i.getBody()) == null ? void 0 : g.paragraphs) ?? []).find((m) => m.startIndex >= a);
|
|
375
|
+
return await r.executeCommand(Je.id, {
|
|
376
|
+
unitId: o,
|
|
377
|
+
body: {
|
|
378
|
+
dataStream: He.PARAGRAPH,
|
|
379
|
+
paragraphs: wn(He.PARAGRAPH, p)
|
|
380
|
+
},
|
|
381
|
+
range: s,
|
|
382
|
+
textRanges: l,
|
|
383
|
+
segmentId: c
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}, Ve = {
|
|
387
|
+
id: hn.id,
|
|
388
|
+
name: "doc.command.copy",
|
|
389
|
+
type: R.COMMAND,
|
|
390
|
+
multi: !0,
|
|
391
|
+
priority: 999,
|
|
392
|
+
preconditions: (n) => n.getContextValue(w) || n.getContextValue(me),
|
|
393
|
+
handler: async () => !0
|
|
394
|
+
}, Fe = {
|
|
395
|
+
id: pn.id,
|
|
396
|
+
name: "doc.command.cut",
|
|
397
|
+
type: R.COMMAND,
|
|
398
|
+
multi: !0,
|
|
399
|
+
priority: 999,
|
|
400
|
+
preconditions: (n) => n.getContextValue(w) || n.getContextValue(me),
|
|
401
|
+
handler: async () => !0
|
|
402
|
+
}, ke = {
|
|
403
|
+
id: gn.id,
|
|
404
|
+
name: "doc.command.paste",
|
|
405
|
+
type: R.COMMAND,
|
|
406
|
+
multi: !0,
|
|
407
|
+
priority: 999,
|
|
408
|
+
preconditions: (n) => n.getContextValue(w) || n.getContextValue(me),
|
|
409
|
+
handler: async () => !0
|
|
410
|
+
};
|
|
411
|
+
var Ln = Object.defineProperty, An = Object.getOwnPropertyDescriptor, Nn = (n, e, t, r) => {
|
|
412
|
+
for (var s = r > 1 ? void 0 : r ? An(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
413
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
414
|
+
return r && s && Ln(e, t, s), s;
|
|
415
|
+
}, gt = (n, e) => (t, r) => e(t, r, n);
|
|
416
|
+
let A = class {
|
|
417
|
+
constructor(n, e) {
|
|
418
|
+
S(this, "_currentSkeletonUnitId", "");
|
|
419
|
+
S(this, "_docSkeletonMap", /* @__PURE__ */ new Map());
|
|
420
|
+
S(this, "_currentSkeleton$", new de(null));
|
|
421
|
+
S(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
|
|
422
|
+
/**
|
|
423
|
+
* CurrentSkeletonBefore for pre-triggered logic during registration
|
|
424
|
+
*/
|
|
425
|
+
S(this, "_currentSkeletonBefore$", new de(null));
|
|
426
|
+
S(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
|
|
427
|
+
this._localeService = n, this._docViewModelManagerService = e, this.initialize();
|
|
428
|
+
}
|
|
429
|
+
initialize() {
|
|
430
|
+
this._docViewModelManagerService.currentDocViewModel$.subscribe((n) => {
|
|
431
|
+
n != null && this._setCurrent(n);
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
dispose() {
|
|
435
|
+
this._currentSkeletonBefore$.complete(), this._currentSkeleton$.complete(), this._docSkeletonMap = /* @__PURE__ */ new Map();
|
|
436
|
+
}
|
|
437
|
+
getCurrent() {
|
|
438
|
+
return this.getSkeletonByUnitId(this._currentSkeletonUnitId);
|
|
439
|
+
}
|
|
440
|
+
makeDirtyCurrent(n = !0) {
|
|
441
|
+
this.makeDirty(this._currentSkeletonUnitId, n);
|
|
442
|
+
}
|
|
443
|
+
makeDirty(n, e = !0) {
|
|
444
|
+
const t = this.getSkeletonByUnitId(n);
|
|
445
|
+
t != null && (t.dirty = e);
|
|
446
|
+
}
|
|
447
|
+
_setCurrent(n) {
|
|
448
|
+
const { unitId: e } = n;
|
|
449
|
+
if (this._docSkeletonMap.has(e)) {
|
|
450
|
+
const t = this.getSkeletonByUnitId(e);
|
|
451
|
+
t.skeleton.calculate(), t.dirty = !0;
|
|
452
|
+
} else {
|
|
453
|
+
const t = this._buildSkeleton(n.docViewModel);
|
|
454
|
+
t.calculate(), this._docSkeletonMap.set(e, {
|
|
455
|
+
unitId: e,
|
|
456
|
+
skeleton: t,
|
|
457
|
+
dirty: !1
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
return this._currentSkeletonUnitId = e, this._currentSkeletonBefore$.next(this.getCurrent()), this._currentSkeleton$.next(this.getCurrent()), this.getCurrent();
|
|
461
|
+
}
|
|
462
|
+
getSkeletonByUnitId(n) {
|
|
463
|
+
return this._docSkeletonMap.get(n);
|
|
464
|
+
}
|
|
465
|
+
_buildSkeleton(n) {
|
|
466
|
+
return Qt.create(n, this._localeService);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
A = Nn([
|
|
470
|
+
gt(0, U(It)),
|
|
471
|
+
gt(1, U(se))
|
|
472
|
+
], A);
|
|
473
|
+
const mt = {
|
|
474
|
+
id: "doc.command.inner-paste",
|
|
475
|
+
type: R.COMMAND,
|
|
476
|
+
handler: async (n, e) => {
|
|
477
|
+
const { segmentId: t, body: r, textRanges: s } = e, i = n.get(N), o = n.get(x), a = n.get(P), c = n.get(O), d = a.getSelections();
|
|
478
|
+
if (!Array.isArray(d) || d.length === 0)
|
|
479
|
+
return !1;
|
|
480
|
+
const h = c.getCurrentUniverDocInstance().getUnitId(), p = {
|
|
481
|
+
id: _.id,
|
|
482
|
+
params: {
|
|
483
|
+
unitId: h,
|
|
484
|
+
mutations: []
|
|
485
|
+
}
|
|
486
|
+
}, u = new we();
|
|
487
|
+
u.reset();
|
|
488
|
+
for (const m of d) {
|
|
489
|
+
const { startOffset: f, endOffset: v, collapsed: M } = m, T = f - u.cursor;
|
|
490
|
+
M ? p.params.mutations.push({
|
|
491
|
+
t: "r",
|
|
492
|
+
len: T,
|
|
493
|
+
segmentId: t
|
|
494
|
+
}) : p.params.mutations.push(
|
|
495
|
+
...Ae(m, t, u.cursor)
|
|
496
|
+
), p.params.mutations.push({
|
|
497
|
+
t: "i",
|
|
498
|
+
body: r,
|
|
499
|
+
len: r.dataStream.length,
|
|
500
|
+
line: 0,
|
|
501
|
+
segmentId: t
|
|
502
|
+
}), u.reset(), u.moveCursor(v);
|
|
503
|
+
}
|
|
504
|
+
const g = o.syncExecuteCommand(p.id, p.params);
|
|
505
|
+
return a.replaceTextRanges(s), g ? (i.pushUndoRedo({
|
|
506
|
+
unitID: h,
|
|
507
|
+
undoMutations: [{ id: _.id, params: g }],
|
|
508
|
+
redoMutations: [{ id: _.id, params: p.params }],
|
|
509
|
+
undo() {
|
|
510
|
+
return o.syncExecuteCommand(_.id, g), a.replaceTextRanges(d), !0;
|
|
511
|
+
},
|
|
512
|
+
redo() {
|
|
513
|
+
return o.syncExecuteCommand(_.id, p.params), a.replaceTextRanges(s), !0;
|
|
514
|
+
}
|
|
515
|
+
}), !0) : !1;
|
|
516
|
+
}
|
|
517
|
+
}, Ee = {
|
|
518
|
+
id: "doc.command.inner-cut",
|
|
519
|
+
type: R.COMMAND,
|
|
520
|
+
handler: async (n, e) => {
|
|
521
|
+
const { segmentId: t, textRanges: r } = e, s = n.get(N), i = n.get(x), o = n.get(P), a = n.get(O), c = o.getSelections();
|
|
522
|
+
if (!Array.isArray(c) || c.length === 0)
|
|
523
|
+
return !1;
|
|
524
|
+
const d = a.getCurrentUniverDocInstance().getUnitId(), l = a.getUniverDocInstance(d), h = zt(l.snapshot, t);
|
|
525
|
+
if (h == null)
|
|
526
|
+
return !1;
|
|
527
|
+
const p = {
|
|
528
|
+
id: _.id,
|
|
529
|
+
params: {
|
|
530
|
+
unitId: d,
|
|
531
|
+
mutations: []
|
|
532
|
+
}
|
|
533
|
+
}, u = new we();
|
|
534
|
+
u.reset();
|
|
535
|
+
for (const m of c) {
|
|
536
|
+
const { startOffset: f, endOffset: v, collapsed: M } = m, T = f - u.cursor;
|
|
537
|
+
M ? p.params.mutations.push({
|
|
538
|
+
t: "r",
|
|
539
|
+
len: T,
|
|
540
|
+
segmentId: t
|
|
541
|
+
}) : p.params.mutations.push(
|
|
542
|
+
...$n(m, h, t, u.cursor)
|
|
543
|
+
), u.reset(), u.moveCursor(v);
|
|
544
|
+
}
|
|
545
|
+
const g = i.syncExecuteCommand(p.id, p.params);
|
|
546
|
+
return o.replaceTextRanges(r), g ? (s.pushUndoRedo({
|
|
547
|
+
unitID: d,
|
|
548
|
+
undoMutations: [{ id: _.id, params: g }],
|
|
549
|
+
redoMutations: [{ id: _.id, params: p.params }],
|
|
550
|
+
undo() {
|
|
551
|
+
return i.syncExecuteCommand(_.id, g), o.replaceTextRanges(c), !0;
|
|
552
|
+
},
|
|
553
|
+
redo() {
|
|
554
|
+
return i.syncExecuteCommand(_.id, p.params), o.replaceTextRanges(r), !0;
|
|
555
|
+
}
|
|
556
|
+
}), !0) : !1;
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
function $n(n, e, t = "", r = 0) {
|
|
560
|
+
const { startOffset: s, endOffset: i } = n, o = [], { paragraphs: a = [] } = e, c = s - r, d = i - r, l = a == null ? void 0 : a.find(
|
|
561
|
+
(h) => h.startIndex - r >= c && h.startIndex - r <= d
|
|
562
|
+
);
|
|
563
|
+
if (c > 0 && o.push({
|
|
564
|
+
t: "r",
|
|
565
|
+
len: c,
|
|
566
|
+
segmentId: t
|
|
567
|
+
}), l && l.startIndex - r > c) {
|
|
568
|
+
const h = l.startIndex - r;
|
|
569
|
+
o.push({
|
|
570
|
+
t: "d",
|
|
571
|
+
len: h - c,
|
|
572
|
+
line: 0,
|
|
573
|
+
segmentId: t
|
|
574
|
+
}), o.push({
|
|
575
|
+
t: "r",
|
|
576
|
+
len: 1,
|
|
577
|
+
segmentId: t
|
|
578
|
+
}), d > h + 1 && o.push({
|
|
579
|
+
t: "d",
|
|
580
|
+
len: d - h - 1,
|
|
581
|
+
line: 0,
|
|
582
|
+
segmentId: t
|
|
583
|
+
});
|
|
584
|
+
} else
|
|
585
|
+
o.push({
|
|
586
|
+
t: "d",
|
|
587
|
+
len: d - c,
|
|
588
|
+
line: 0,
|
|
589
|
+
segmentId: t
|
|
590
|
+
});
|
|
591
|
+
return o;
|
|
592
|
+
}
|
|
593
|
+
const Et = {
|
|
594
|
+
id: "doc.command.delete-left",
|
|
595
|
+
type: R.COMMAND,
|
|
596
|
+
handler: async (n) => {
|
|
597
|
+
var y;
|
|
598
|
+
const e = n.get(P), t = n.get(A), r = n.get(O), s = n.get(x), i = e.getActiveRange(), o = e.getSelections(), a = (y = t.getCurrent()) == null ? void 0 : y.skeleton;
|
|
599
|
+
let c;
|
|
600
|
+
if (i == null || a == null || o == null)
|
|
601
|
+
return !1;
|
|
602
|
+
const d = r.getCurrentUniverDocInstance(), { startOffset: l, collapsed: h, segmentId: p, style: u } = i;
|
|
603
|
+
if (l === 0 && h)
|
|
604
|
+
return !0;
|
|
605
|
+
const g = a.findNodeByCharIndex(l), m = en(g), f = tn(g, d.body);
|
|
606
|
+
let v = l;
|
|
607
|
+
const M = a.findNodeByCharIndex(l - 1);
|
|
608
|
+
if (nn(g) && M !== g && (m === !0 || f === !0)) {
|
|
609
|
+
const C = rn(g, d.body);
|
|
610
|
+
if (C == null)
|
|
611
|
+
return !1;
|
|
612
|
+
const E = C == null ? void 0 : C.startIndex, L = { startIndex: 0 }, B = C.paragraphStyle;
|
|
613
|
+
if (m === !0) {
|
|
614
|
+
const I = C.paragraphStyle;
|
|
615
|
+
I && (L.paragraphStyle = I);
|
|
616
|
+
} else if (f === !0) {
|
|
617
|
+
const I = C.bullet;
|
|
618
|
+
I && (L.bullet = I), B != null && (L.paragraphStyle = { ...B }, delete L.paragraphStyle.hanging, delete L.paragraphStyle.indentStart);
|
|
619
|
+
}
|
|
620
|
+
const k = [
|
|
621
|
+
{
|
|
622
|
+
startOffset: v,
|
|
623
|
+
endOffset: v,
|
|
624
|
+
style: u
|
|
625
|
+
}
|
|
626
|
+
];
|
|
627
|
+
c = await s.executeCommand(Tt.id, {
|
|
628
|
+
unitId: d.getUnitId(),
|
|
629
|
+
updateBody: {
|
|
630
|
+
dataStream: "",
|
|
631
|
+
paragraphs: [{ ...L }]
|
|
632
|
+
},
|
|
633
|
+
range: {
|
|
634
|
+
startOffset: E,
|
|
635
|
+
endOffset: E + 1
|
|
636
|
+
},
|
|
637
|
+
textRanges: k,
|
|
638
|
+
coverType: xt.REPLACE,
|
|
639
|
+
segmentId: p
|
|
640
|
+
});
|
|
641
|
+
} else if (h === !0)
|
|
642
|
+
if (M.content === "\r")
|
|
643
|
+
c = await s.executeCommand(et.id, {
|
|
644
|
+
direction: q.LEFT,
|
|
645
|
+
range: i
|
|
646
|
+
});
|
|
647
|
+
else {
|
|
648
|
+
v -= M.count;
|
|
649
|
+
const C = [
|
|
650
|
+
{
|
|
651
|
+
startOffset: v,
|
|
652
|
+
endOffset: v,
|
|
653
|
+
style: u
|
|
654
|
+
}
|
|
655
|
+
];
|
|
656
|
+
c = await s.executeCommand(Qe.id, {
|
|
657
|
+
unitId: d.getUnitId(),
|
|
658
|
+
range: i,
|
|
659
|
+
segmentId: p,
|
|
660
|
+
direction: q.LEFT,
|
|
661
|
+
len: M.count,
|
|
662
|
+
textRanges: C
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
666
|
+
const C = wt(i, o);
|
|
667
|
+
c = await s.executeCommand(Ee.id, {
|
|
668
|
+
segmentId: p,
|
|
669
|
+
textRanges: C
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
return c;
|
|
673
|
+
}
|
|
674
|
+
}, Ut = {
|
|
675
|
+
id: "doc.command.delete-right",
|
|
676
|
+
type: R.COMMAND,
|
|
677
|
+
handler: async (n) => {
|
|
678
|
+
var g;
|
|
679
|
+
const e = n.get(P), t = n.get(A), r = n.get(O), s = n.get(x), i = e.getActiveRange(), o = e.getSelections(), a = (g = t.getCurrent()) == null ? void 0 : g.skeleton;
|
|
680
|
+
let c;
|
|
681
|
+
if (i == null || a == null || o == null)
|
|
682
|
+
return !1;
|
|
683
|
+
const d = r.getCurrentUniverDocInstance(), { startOffset: l, collapsed: h, segmentId: p, style: u } = i;
|
|
684
|
+
if (l === d.getBody().dataStream.length - 2 && h)
|
|
685
|
+
return !0;
|
|
686
|
+
if (h === !0) {
|
|
687
|
+
const m = a.findNodeByCharIndex(l);
|
|
688
|
+
if (m.content === "\r")
|
|
689
|
+
c = await s.executeCommand(et.id, {
|
|
690
|
+
direction: q.RIGHT,
|
|
691
|
+
range: i
|
|
692
|
+
});
|
|
693
|
+
else {
|
|
694
|
+
const f = [
|
|
695
|
+
{
|
|
696
|
+
startOffset: l,
|
|
697
|
+
endOffset: l,
|
|
698
|
+
style: u
|
|
699
|
+
}
|
|
700
|
+
];
|
|
701
|
+
c = await s.executeCommand(Qe.id, {
|
|
702
|
+
unitId: d.getUnitId(),
|
|
703
|
+
range: i,
|
|
704
|
+
segmentId: p,
|
|
705
|
+
direction: q.RIGHT,
|
|
706
|
+
textRanges: f,
|
|
707
|
+
len: m.count
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
} else {
|
|
711
|
+
const m = wt(i, o);
|
|
712
|
+
c = await s.executeCommand(Ee.id, {
|
|
713
|
+
segmentId: p,
|
|
714
|
+
textRanges: m
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
return c;
|
|
718
|
+
}
|
|
719
|
+
}, et = {
|
|
720
|
+
id: "doc.command.merge-two-paragraph",
|
|
721
|
+
type: R.COMMAND,
|
|
722
|
+
handler: async (n, e) => {
|
|
723
|
+
var L, B, k;
|
|
724
|
+
const t = n.get(P), r = n.get(O), s = n.get(x), i = n.get(N), { direction: o, range: a } = e, c = t.getActiveRange(), d = t.getSelections();
|
|
725
|
+
if (c == null || d == null)
|
|
726
|
+
return !1;
|
|
727
|
+
const l = r.getCurrentUniverDocInstance(), { startOffset: h, collapsed: p, segmentId: u, style: g } = c;
|
|
728
|
+
if (!p)
|
|
729
|
+
return !1;
|
|
730
|
+
const m = o === q.LEFT ? h : h + 1, f = (k = (B = (L = l.getBody()) == null ? void 0 : L.paragraphs) == null ? void 0 : B.find((I) => I.startIndex >= m)) == null ? void 0 : k.startIndex, v = Bn(l.getBody(), m, f), M = o === q.LEFT ? h - 1 : h, T = l.getUnitId(), y = [
|
|
731
|
+
{
|
|
732
|
+
startOffset: M,
|
|
733
|
+
endOffset: M,
|
|
734
|
+
style: g
|
|
735
|
+
}
|
|
736
|
+
], C = {
|
|
737
|
+
id: _.id,
|
|
738
|
+
params: {
|
|
739
|
+
unitId: T,
|
|
740
|
+
mutations: []
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
C.params.mutations.push({
|
|
744
|
+
t: "r",
|
|
745
|
+
len: o === q.LEFT ? h - 1 : h,
|
|
746
|
+
segmentId: u
|
|
747
|
+
}), v.dataStream.length && C.params.mutations.push({
|
|
748
|
+
t: "i",
|
|
749
|
+
body: v,
|
|
750
|
+
len: v.dataStream.length,
|
|
751
|
+
line: 0,
|
|
752
|
+
segmentId: u
|
|
753
|
+
}), C.params.mutations.push({
|
|
754
|
+
t: "r",
|
|
755
|
+
len: 1,
|
|
756
|
+
segmentId: u
|
|
757
|
+
}), C.params.mutations.push({
|
|
758
|
+
t: "d",
|
|
759
|
+
len: f + 1 - m,
|
|
760
|
+
line: 0,
|
|
761
|
+
segmentId: u
|
|
762
|
+
});
|
|
763
|
+
const E = s.syncExecuteCommand(C.id, C.params);
|
|
764
|
+
return t.replaceTextRanges(y), E ? (i.pushUndoRedo({
|
|
765
|
+
unitID: T,
|
|
766
|
+
undoMutations: [{ id: _.id, params: E }],
|
|
767
|
+
redoMutations: [{ id: _.id, params: C.params }],
|
|
386
768
|
undo() {
|
|
387
|
-
return
|
|
769
|
+
return s.syncExecuteCommand(_.id, E), t.replaceTextRanges([a]), !0;
|
|
388
770
|
},
|
|
389
771
|
redo() {
|
|
390
|
-
return
|
|
772
|
+
return s.syncExecuteCommand(_.id, C.params), t.replaceTextRanges(y), !0;
|
|
391
773
|
}
|
|
392
774
|
}), !0) : !1;
|
|
393
775
|
}
|
|
394
776
|
};
|
|
395
|
-
|
|
777
|
+
function Bn(n, e, t) {
|
|
778
|
+
const { textRuns: r } = n, s = n.dataStream.substring(e, t);
|
|
779
|
+
if (r == null)
|
|
780
|
+
return {
|
|
781
|
+
dataStream: s
|
|
782
|
+
};
|
|
783
|
+
const i = [];
|
|
784
|
+
for (const o of r) {
|
|
785
|
+
const { st: a, ed: c } = o;
|
|
786
|
+
c <= e || a >= t || (a < e ? i.push({
|
|
787
|
+
...o,
|
|
788
|
+
st: 0,
|
|
789
|
+
ed: c - e
|
|
790
|
+
}) : c > t ? i.push({
|
|
791
|
+
...o,
|
|
792
|
+
st: a - e,
|
|
793
|
+
ed: t - e
|
|
794
|
+
}) : i.push({
|
|
795
|
+
...o,
|
|
796
|
+
st: a - e,
|
|
797
|
+
ed: c - e
|
|
798
|
+
}));
|
|
799
|
+
}
|
|
800
|
+
return {
|
|
801
|
+
dataStream: s,
|
|
802
|
+
textRuns: i
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function wt(n, e) {
|
|
806
|
+
let t = n.endOffset;
|
|
807
|
+
for (const s of e) {
|
|
808
|
+
const { startOffset: i, endOffset: o } = s;
|
|
809
|
+
i == null || o == null || o <= n.endOffset && (t -= o - i);
|
|
810
|
+
}
|
|
811
|
+
return [
|
|
812
|
+
{
|
|
813
|
+
startOffset: t,
|
|
814
|
+
endOffset: t,
|
|
815
|
+
style: n.style
|
|
816
|
+
}
|
|
817
|
+
];
|
|
818
|
+
}
|
|
819
|
+
class tt {
|
|
396
820
|
constructor() {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
821
|
+
S(this, "_previousActiveRange", null);
|
|
822
|
+
S(this, "_undoMutationParamsCache", []);
|
|
823
|
+
S(this, "_redoMutationParamsCache", []);
|
|
400
824
|
}
|
|
401
825
|
clearUndoRedoMutationParamsCache() {
|
|
402
826
|
this._undoMutationParamsCache = [], this._redoMutationParamsCache = [];
|
|
@@ -410,7 +834,7 @@ class ot {
|
|
|
410
834
|
fetchComposedUndoRedoMutationParams(e) {
|
|
411
835
|
if (this._undoMutationParamsCache.length === 0 || this._previousActiveRange == null)
|
|
412
836
|
return null;
|
|
413
|
-
const { unitId: t } = this._undoMutationParamsCache[0], { segmentId:
|
|
837
|
+
const { unitId: t } = this._undoMutationParamsCache[0], { segmentId: r, startOffset: s, collapsed: i } = this._previousActiveRange, o = {
|
|
414
838
|
unitId: t,
|
|
415
839
|
mutations: []
|
|
416
840
|
}, a = {
|
|
@@ -420,20 +844,20 @@ class ot {
|
|
|
420
844
|
return i ? (o.mutations.push({
|
|
421
845
|
t: "r",
|
|
422
846
|
len: s,
|
|
423
|
-
segmentId:
|
|
847
|
+
segmentId: r
|
|
424
848
|
}), a.mutations.push({
|
|
425
849
|
t: "r",
|
|
426
850
|
len: s,
|
|
427
|
-
segmentId:
|
|
851
|
+
segmentId: r
|
|
428
852
|
})) : (s > 0 && o.mutations.push({
|
|
429
853
|
t: "r",
|
|
430
854
|
len: s,
|
|
431
|
-
segmentId:
|
|
432
|
-
}), o.mutations.push(this._undoMutationParamsCache[0].mutations.find((c) => c.t === "i")), a.mutations.push(...
|
|
855
|
+
segmentId: r
|
|
856
|
+
}), o.mutations.push(this._undoMutationParamsCache[0].mutations.find((c) => c.t === "i")), a.mutations.push(...Ae(this._previousActiveRange, r))), e.length && (o.mutations.push({
|
|
433
857
|
t: "d",
|
|
434
858
|
len: e.length,
|
|
435
859
|
line: 0,
|
|
436
|
-
segmentId:
|
|
860
|
+
segmentId: r
|
|
437
861
|
}), a.mutations.push({
|
|
438
862
|
t: "i",
|
|
439
863
|
body: {
|
|
@@ -441,19 +865,19 @@ class ot {
|
|
|
441
865
|
},
|
|
442
866
|
len: e.length,
|
|
443
867
|
line: 0,
|
|
444
|
-
segmentId:
|
|
868
|
+
segmentId: r
|
|
445
869
|
})), { redoMutationParams: a, undoMutationParams: o, previousActiveRange: this._previousActiveRange };
|
|
446
870
|
}
|
|
447
871
|
dispose() {
|
|
448
872
|
this._undoMutationParamsCache = [], this._redoMutationParamsCache = [], this._previousActiveRange = null;
|
|
449
873
|
}
|
|
450
874
|
}
|
|
451
|
-
const
|
|
875
|
+
const Lt = {
|
|
452
876
|
id: "doc.command.ime-input",
|
|
453
|
-
type:
|
|
454
|
-
handler: async (
|
|
455
|
-
const { unitId: t, newText:
|
|
456
|
-
id:
|
|
877
|
+
type: R.COMMAND,
|
|
878
|
+
handler: async (n, e) => {
|
|
879
|
+
const { unitId: t, newText: r, oldTextLen: s, range: i, segmentId: o, textRanges: a, isCompositionEnd: c } = e, d = n.get(x), l = n.get(N), h = n.get(P), p = n.get(tt), u = {
|
|
880
|
+
id: _.id,
|
|
457
881
|
params: {
|
|
458
882
|
unitId: t,
|
|
459
883
|
mutations: []
|
|
@@ -463,7 +887,7 @@ const bt = {
|
|
|
463
887
|
t: "r",
|
|
464
888
|
len: i.startOffset,
|
|
465
889
|
segmentId: o
|
|
466
|
-
}) : u.params.mutations.push(...
|
|
890
|
+
}) : u.params.mutations.push(...Ae(i, o)), s > 0 && u.params.mutations.push({
|
|
467
891
|
t: "d",
|
|
468
892
|
len: s,
|
|
469
893
|
line: 0,
|
|
@@ -471,28 +895,28 @@ const bt = {
|
|
|
471
895
|
}), u.params.mutations.push({
|
|
472
896
|
t: "i",
|
|
473
897
|
body: {
|
|
474
|
-
dataStream:
|
|
898
|
+
dataStream: r
|
|
475
899
|
},
|
|
476
|
-
len:
|
|
900
|
+
len: r.length,
|
|
477
901
|
line: 0,
|
|
478
902
|
segmentId: o
|
|
479
903
|
});
|
|
480
|
-
const g =
|
|
481
|
-
if (
|
|
904
|
+
const g = d.syncExecuteCommand(u.id, u.params);
|
|
905
|
+
if (p.pushUndoRedoMutationParams(g, u.params), h.replaceTextRanges(a), c) {
|
|
482
906
|
if (g) {
|
|
483
|
-
const
|
|
484
|
-
if (
|
|
907
|
+
const m = p.fetchComposedUndoRedoMutationParams(r);
|
|
908
|
+
if (m == null)
|
|
485
909
|
return !1;
|
|
486
|
-
const { undoMutationParams:
|
|
487
|
-
return
|
|
910
|
+
const { undoMutationParams: f, redoMutationParams: v, previousActiveRange: M } = m;
|
|
911
|
+
return l.pushUndoRedo({
|
|
488
912
|
unitID: t,
|
|
489
|
-
undoMutations: [{ id:
|
|
490
|
-
redoMutations: [{ id:
|
|
913
|
+
undoMutations: [{ id: _.id, params: f }],
|
|
914
|
+
redoMutations: [{ id: _.id, params: v }],
|
|
491
915
|
undo() {
|
|
492
|
-
return
|
|
916
|
+
return d.syncExecuteCommand(_.id, f), h.replaceTextRanges([M]), !0;
|
|
493
917
|
},
|
|
494
918
|
redo() {
|
|
495
|
-
return
|
|
919
|
+
return d.syncExecuteCommand(_.id, v), h.replaceTextRanges(a), !0;
|
|
496
920
|
}
|
|
497
921
|
}), !0;
|
|
498
922
|
}
|
|
@@ -500,199 +924,324 @@ const bt = {
|
|
|
500
924
|
return !!g;
|
|
501
925
|
return !1;
|
|
502
926
|
}
|
|
503
|
-
},
|
|
927
|
+
}, ue = {
|
|
504
928
|
id: "doc.command.set-inline-format-bold",
|
|
505
|
-
type:
|
|
929
|
+
type: R.COMMAND,
|
|
506
930
|
handler: async () => !0
|
|
507
|
-
},
|
|
931
|
+
}, Ne = {
|
|
508
932
|
id: "doc.command.set-inline-format-italic",
|
|
509
|
-
type:
|
|
933
|
+
type: R.COMMAND,
|
|
510
934
|
handler: async () => !0
|
|
511
|
-
},
|
|
935
|
+
}, $e = {
|
|
512
936
|
id: "doc.command.set-inline-format-underline",
|
|
513
|
-
type:
|
|
937
|
+
type: R.COMMAND,
|
|
514
938
|
handler: async () => !0
|
|
515
|
-
},
|
|
939
|
+
}, Be = {
|
|
516
940
|
id: "doc.command.set-inline-format-strikethrough",
|
|
517
|
-
type:
|
|
941
|
+
type: R.COMMAND,
|
|
518
942
|
handler: async () => !0
|
|
519
|
-
},
|
|
943
|
+
}, Q = {
|
|
944
|
+
id: "doc.command.set-inline-format-subscript",
|
|
945
|
+
type: R.COMMAND,
|
|
946
|
+
handler: async () => !0
|
|
947
|
+
}, ie = {
|
|
948
|
+
id: "doc.command.set-inline-format-superscript",
|
|
949
|
+
type: R.COMMAND,
|
|
950
|
+
handler: async () => !0
|
|
951
|
+
}, he = {
|
|
520
952
|
id: "doc.command.set-inline-format-fontsize",
|
|
521
|
-
type:
|
|
953
|
+
type: R.COMMAND,
|
|
522
954
|
handler: async () => !0
|
|
523
|
-
},
|
|
955
|
+
}, pe = {
|
|
524
956
|
id: "doc.command.set-inline-format-font-family",
|
|
525
|
-
type:
|
|
957
|
+
type: R.COMMAND,
|
|
526
958
|
handler: async () => !0
|
|
527
|
-
},
|
|
959
|
+
}, je = {
|
|
528
960
|
id: "doc.command.set-inline-format-text-color",
|
|
529
|
-
type:
|
|
961
|
+
type: R.COMMAND,
|
|
530
962
|
handler: async () => !0
|
|
531
|
-
},
|
|
963
|
+
}, At = {
|
|
964
|
+
[ue.id]: "bl",
|
|
965
|
+
[Ne.id]: "it",
|
|
966
|
+
[$e.id]: "ul",
|
|
967
|
+
[Be.id]: "st",
|
|
968
|
+
[he.id]: "fs",
|
|
969
|
+
[pe.id]: "ff",
|
|
970
|
+
[je.id]: "cl",
|
|
971
|
+
[Q.id]: "va",
|
|
972
|
+
[ie.id]: "va"
|
|
973
|
+
}, Nt = {
|
|
532
974
|
id: "doc.command.set-inline-format",
|
|
533
|
-
type:
|
|
534
|
-
handler: async (
|
|
535
|
-
const { segmentId: t, value:
|
|
536
|
-
if (!Array.isArray(
|
|
975
|
+
type: R.COMMAND,
|
|
976
|
+
handler: async (n, e) => {
|
|
977
|
+
const { segmentId: t, value: r, preCommandId: s } = e, i = n.get(N), o = n.get(x), a = n.get(P), c = n.get(O), d = a.getSelections();
|
|
978
|
+
if (!Array.isArray(d) || d.length === 0)
|
|
537
979
|
return !1;
|
|
538
|
-
let
|
|
539
|
-
|
|
540
|
-
let
|
|
541
|
-
const u = {
|
|
542
|
-
[ce.id]: "bl",
|
|
543
|
-
[je.id]: "it",
|
|
544
|
-
[Ve.id]: "ul",
|
|
545
|
-
[ke.id]: "st",
|
|
546
|
-
[le.id]: "fs",
|
|
547
|
-
[de.id]: "ff",
|
|
548
|
-
[Fe.id]: "cl"
|
|
549
|
-
};
|
|
980
|
+
let l = c.getCurrentUniverDocInstance(), h = l.getUnitId();
|
|
981
|
+
h === J && (l = c.getUniverDocInstance(K), h = l.getUnitId());
|
|
982
|
+
let p;
|
|
550
983
|
switch (s) {
|
|
551
|
-
case
|
|
552
|
-
case
|
|
553
|
-
case
|
|
554
|
-
case
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
l
|
|
984
|
+
case ue.id:
|
|
985
|
+
case Ne.id:
|
|
986
|
+
case $e.id:
|
|
987
|
+
case Be.id:
|
|
988
|
+
case Q.id:
|
|
989
|
+
case ie.id: {
|
|
990
|
+
p = Vn(
|
|
991
|
+
l.getBody().textRuns,
|
|
992
|
+
s,
|
|
993
|
+
d
|
|
559
994
|
);
|
|
560
995
|
break;
|
|
561
996
|
}
|
|
562
|
-
case
|
|
563
|
-
case
|
|
564
|
-
|
|
997
|
+
case he.id:
|
|
998
|
+
case pe.id: {
|
|
999
|
+
p = r;
|
|
565
1000
|
break;
|
|
566
1001
|
}
|
|
567
|
-
case
|
|
568
|
-
|
|
569
|
-
rgb:
|
|
1002
|
+
case je.id: {
|
|
1003
|
+
p = {
|
|
1004
|
+
rgb: r
|
|
570
1005
|
};
|
|
571
1006
|
break;
|
|
572
1007
|
}
|
|
573
1008
|
default:
|
|
574
1009
|
throw new Error(`Unknown command: ${s} in handleInlineFormat`);
|
|
575
1010
|
}
|
|
576
|
-
const
|
|
577
|
-
id:
|
|
1011
|
+
const u = {
|
|
1012
|
+
id: _.id,
|
|
578
1013
|
params: {
|
|
579
|
-
unitId:
|
|
1014
|
+
unitId: h,
|
|
580
1015
|
mutations: []
|
|
581
1016
|
}
|
|
582
|
-
},
|
|
583
|
-
|
|
584
|
-
for (const
|
|
585
|
-
const { startOffset:
|
|
1017
|
+
}, g = new we();
|
|
1018
|
+
g.reset();
|
|
1019
|
+
for (const v of d) {
|
|
1020
|
+
const { startOffset: M, endOffset: T } = v, y = {
|
|
586
1021
|
dataStream: "",
|
|
587
1022
|
textRuns: [
|
|
588
1023
|
{
|
|
589
1024
|
st: 0,
|
|
590
|
-
ed:
|
|
1025
|
+
ed: T - M,
|
|
591
1026
|
ts: {
|
|
592
|
-
[
|
|
1027
|
+
[At[s]]: p
|
|
593
1028
|
}
|
|
594
1029
|
}
|
|
595
1030
|
]
|
|
596
|
-
},
|
|
597
|
-
|
|
1031
|
+
}, C = M - g.cursor;
|
|
1032
|
+
C !== 0 && u.params.mutations.push({
|
|
598
1033
|
t: "r",
|
|
599
|
-
len:
|
|
1034
|
+
len: C,
|
|
600
1035
|
segmentId: t
|
|
601
|
-
}),
|
|
1036
|
+
}), u.params.mutations.push({
|
|
602
1037
|
t: "r",
|
|
603
|
-
body:
|
|
604
|
-
len:
|
|
1038
|
+
body: y,
|
|
1039
|
+
len: T - M,
|
|
605
1040
|
segmentId: t
|
|
606
|
-
}),
|
|
1041
|
+
}), g.reset(), g.moveCursor(T);
|
|
607
1042
|
}
|
|
608
|
-
const m = o.syncExecuteCommand(
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
1043
|
+
const m = o.syncExecuteCommand(u.id, u.params), f = [
|
|
1044
|
+
ue.id,
|
|
1045
|
+
he.id,
|
|
1046
|
+
pe.id,
|
|
1047
|
+
Q.id,
|
|
1048
|
+
ie.id
|
|
612
1049
|
];
|
|
613
|
-
return
|
|
614
|
-
unitID:
|
|
615
|
-
undoMutations: [{ id:
|
|
616
|
-
redoMutations: [{ id:
|
|
1050
|
+
return f.includes(s) && a.refreshSelection(), m ? (i.pushUndoRedo({
|
|
1051
|
+
unitID: h,
|
|
1052
|
+
undoMutations: [{ id: _.id, params: m }],
|
|
1053
|
+
redoMutations: [{ id: _.id, params: u.params }],
|
|
617
1054
|
undo() {
|
|
618
|
-
return o.syncExecuteCommand(
|
|
1055
|
+
return o.syncExecuteCommand(_.id, m), f.includes(s) && a.refreshSelection(), !0;
|
|
619
1056
|
},
|
|
620
1057
|
redo() {
|
|
621
|
-
return o.syncExecuteCommand(
|
|
1058
|
+
return o.syncExecuteCommand(_.id, u.params), f.includes(s) && a.refreshSelection(), !0;
|
|
622
1059
|
}
|
|
623
1060
|
}), !0) : !1;
|
|
624
1061
|
}
|
|
625
1062
|
};
|
|
626
|
-
function
|
|
627
|
-
return
|
|
1063
|
+
function jn(n) {
|
|
1064
|
+
return n !== null && typeof n == "object";
|
|
628
1065
|
}
|
|
629
|
-
function
|
|
630
|
-
let
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
1066
|
+
function Vn(n, e, t) {
|
|
1067
|
+
let r = 0, s = 0;
|
|
1068
|
+
const i = At[e];
|
|
1069
|
+
for (; r !== n.length && s !== t.length; ) {
|
|
1070
|
+
const { startOffset: o, endOffset: a } = t[s], { st: c, ed: d, ts: l } = n[r];
|
|
1071
|
+
if (a <= c)
|
|
634
1072
|
s++;
|
|
635
|
-
else if (
|
|
636
|
-
|
|
1073
|
+
else if (d <= o)
|
|
1074
|
+
r++;
|
|
637
1075
|
else {
|
|
638
|
-
if ((l == null ? void 0 : l[
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
1076
|
+
if ((l == null ? void 0 : l[i]) == null) {
|
|
1077
|
+
if (/bl|it/.test(i))
|
|
1078
|
+
return D.TRUE;
|
|
1079
|
+
if (/ul|st/.test(i))
|
|
1080
|
+
return {
|
|
1081
|
+
s: D.TRUE
|
|
1082
|
+
};
|
|
1083
|
+
if (/va/.test(i))
|
|
1084
|
+
return e === Q.id ? j.SUBSCRIPT : j.SUPERSCRIPT;
|
|
1085
|
+
}
|
|
1086
|
+
if (jn(l == null ? void 0 : l[i]) && l[i].s === D.FALSE)
|
|
645
1087
|
return {
|
|
646
|
-
s:
|
|
1088
|
+
s: D.TRUE
|
|
647
1089
|
};
|
|
648
|
-
|
|
1090
|
+
if (e === Q.id && (l == null ? void 0 : l[i]) !== j.SUBSCRIPT)
|
|
1091
|
+
return j.SUBSCRIPT;
|
|
1092
|
+
if (e === ie.id && (l == null ? void 0 : l[i]) !== j.SUPERSCRIPT)
|
|
1093
|
+
return j.SUPERSCRIPT;
|
|
1094
|
+
if ((l == null ? void 0 : l[i]) === D.FALSE)
|
|
1095
|
+
return D.TRUE;
|
|
1096
|
+
r++;
|
|
649
1097
|
}
|
|
650
1098
|
}
|
|
651
|
-
return /bl|it/.test(
|
|
652
|
-
s:
|
|
653
|
-
};
|
|
1099
|
+
return /bl|it/.test(i) ? D.FALSE : /ul|st/.test(i) ? {
|
|
1100
|
+
s: D.FALSE
|
|
1101
|
+
} : j.NORMAL;
|
|
1102
|
+
}
|
|
1103
|
+
const Fn = {
|
|
1104
|
+
id: "doc.command.bullet-list",
|
|
1105
|
+
type: R.COMMAND,
|
|
1106
|
+
handler: (n) => n.get(x).syncExecuteCommand(nt.id, {
|
|
1107
|
+
listType: Ot.BULLET_LIST
|
|
1108
|
+
})
|
|
1109
|
+
}, kn = {
|
|
1110
|
+
id: "doc.command.order-list",
|
|
1111
|
+
type: R.COMMAND,
|
|
1112
|
+
handler: (n) => n.get(x).syncExecuteCommand(nt.id, {
|
|
1113
|
+
listType: Ot.ORDER_LIST
|
|
1114
|
+
})
|
|
1115
|
+
}, nt = {
|
|
1116
|
+
id: "doc.command.list-operation",
|
|
1117
|
+
type: R.COMMAND,
|
|
1118
|
+
handler: (n, e) => {
|
|
1119
|
+
var T;
|
|
1120
|
+
const t = n.get(P), r = n.get(O), s = n.get(x), i = n.get(N), { listType: o } = e, a = r.getCurrentUniverDocInstance(), c = t.getActiveRange(), d = (T = a.getBody()) == null ? void 0 : T.paragraphs;
|
|
1121
|
+
if (c == null || d == null)
|
|
1122
|
+
return !1;
|
|
1123
|
+
const l = zn(c, d), { segmentId: h } = c, p = a.getUnitId(), u = l.every((y) => {
|
|
1124
|
+
var C;
|
|
1125
|
+
return ((C = y.bullet) == null ? void 0 : C.listType) === o;
|
|
1126
|
+
}), g = 6;
|
|
1127
|
+
let m = H.generateRandomId(g);
|
|
1128
|
+
if (l.length === 1) {
|
|
1129
|
+
const y = d.indexOf(l[0]), C = d[y - 1], E = d[y + 1];
|
|
1130
|
+
C && C.bullet && C.bullet.listType === o ? m = C.bullet.listId : E && E.bullet && E.bullet.listType === o && (m = E.bullet.listId);
|
|
1131
|
+
}
|
|
1132
|
+
const f = {
|
|
1133
|
+
id: _.id,
|
|
1134
|
+
params: {
|
|
1135
|
+
unitId: p,
|
|
1136
|
+
mutations: []
|
|
1137
|
+
}
|
|
1138
|
+
}, v = new we();
|
|
1139
|
+
v.reset();
|
|
1140
|
+
for (const y of l) {
|
|
1141
|
+
const { startIndex: C } = y;
|
|
1142
|
+
f.params.mutations.push({
|
|
1143
|
+
t: "r",
|
|
1144
|
+
len: C - v.cursor,
|
|
1145
|
+
segmentId: h
|
|
1146
|
+
});
|
|
1147
|
+
const E = {
|
|
1148
|
+
...y.paragraphStyle,
|
|
1149
|
+
hanging: void 0,
|
|
1150
|
+
indentStart: void 0
|
|
1151
|
+
};
|
|
1152
|
+
f.params.mutations.push({
|
|
1153
|
+
t: "r",
|
|
1154
|
+
len: 1,
|
|
1155
|
+
body: {
|
|
1156
|
+
dataStream: "",
|
|
1157
|
+
paragraphs: [
|
|
1158
|
+
u ? {
|
|
1159
|
+
paragraphStyle: E,
|
|
1160
|
+
startIndex: 0
|
|
1161
|
+
} : {
|
|
1162
|
+
...y,
|
|
1163
|
+
startIndex: 0,
|
|
1164
|
+
bullet: {
|
|
1165
|
+
...y.bullet ?? {
|
|
1166
|
+
nestingLevel: 0,
|
|
1167
|
+
textStyle: {
|
|
1168
|
+
fs: 20
|
|
1169
|
+
}
|
|
1170
|
+
},
|
|
1171
|
+
listType: o,
|
|
1172
|
+
listId: m
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
]
|
|
1176
|
+
},
|
|
1177
|
+
segmentId: h,
|
|
1178
|
+
coverType: xt.REPLACE
|
|
1179
|
+
}), v.moveCursorTo(C + 1);
|
|
1180
|
+
}
|
|
1181
|
+
const M = s.syncExecuteCommand(f.id, f.params);
|
|
1182
|
+
return t.refreshSelection(), M && i.pushUndoRedo({
|
|
1183
|
+
unitID: p,
|
|
1184
|
+
undoMutations: [{ id: _.id, params: M }],
|
|
1185
|
+
redoMutations: [{ id: _.id, params: f.params }],
|
|
1186
|
+
undo() {
|
|
1187
|
+
return s.syncExecuteCommand(_.id, M), t.refreshSelection(), !0;
|
|
1188
|
+
},
|
|
1189
|
+
redo() {
|
|
1190
|
+
return s.syncExecuteCommand(_.id, f.params), t.refreshSelection(), !0;
|
|
1191
|
+
}
|
|
1192
|
+
}), !0;
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
function zn(n, e) {
|
|
1196
|
+
const { startOffset: t, endOffset: r } = n, s = [];
|
|
1197
|
+
let i = 0;
|
|
1198
|
+
for (const o of e) {
|
|
1199
|
+
const { startIndex: a } = o;
|
|
1200
|
+
(t > i && t <= a || r > i && r <= a || a >= t && a <= r) && s.push(o), i = a;
|
|
1201
|
+
}
|
|
1202
|
+
return s;
|
|
654
1203
|
}
|
|
655
|
-
const
|
|
1204
|
+
const Wn = {
|
|
656
1205
|
id: "doc.command-replace-content",
|
|
657
|
-
type:
|
|
658
|
-
handler: async (
|
|
1206
|
+
type: R.COMMAND,
|
|
1207
|
+
handler: async (n, e) => {
|
|
659
1208
|
var g;
|
|
660
|
-
const { unitId: t, body:
|
|
661
|
-
if (
|
|
1209
|
+
const { unitId: t, body: r, textRanges: s, segmentId: i = "" } = e, o = n.get(O), a = n.get(x), c = n.get(P), d = n.get(N), l = (g = o.getUniverDocInstance(t)) == null ? void 0 : g.getSnapshot().body, h = c.getSelections();
|
|
1210
|
+
if (l == null || !Array.isArray(h) || h.length === 0)
|
|
662
1211
|
return !1;
|
|
663
|
-
const
|
|
664
|
-
return c.replaceTextRanges(s), u ? (
|
|
1212
|
+
const p = $t(t, i, l, r), u = a.syncExecuteCommand(p.id, p.params);
|
|
1213
|
+
return c.replaceTextRanges(s), u ? (d.pushUndoRedo({
|
|
665
1214
|
unitID: t,
|
|
666
|
-
undoMutations: [{ id:
|
|
667
|
-
redoMutations: [{ id:
|
|
1215
|
+
undoMutations: [{ id: _.id, params: u }],
|
|
1216
|
+
redoMutations: [{ id: _.id, params: p.params }],
|
|
668
1217
|
undo() {
|
|
669
|
-
return a.syncExecuteCommand(
|
|
1218
|
+
return a.syncExecuteCommand(_.id, u), c.replaceTextRanges(h), !0;
|
|
670
1219
|
},
|
|
671
1220
|
redo() {
|
|
672
|
-
return a.syncExecuteCommand(
|
|
1221
|
+
return a.syncExecuteCommand(_.id, p.params), c.replaceTextRanges(s), !0;
|
|
673
1222
|
}
|
|
674
1223
|
}), !0) : !1;
|
|
675
1224
|
}
|
|
676
|
-
},
|
|
1225
|
+
}, Hn = {
|
|
677
1226
|
id: "doc.command-cover-content",
|
|
678
|
-
type:
|
|
679
|
-
handler: async (
|
|
680
|
-
var
|
|
681
|
-
const { unitId: t, body:
|
|
1227
|
+
type: R.COMMAND,
|
|
1228
|
+
handler: async (n, e) => {
|
|
1229
|
+
var l;
|
|
1230
|
+
const { unitId: t, body: r, segmentId: s = "" } = e, i = n.get(O), o = n.get(x), a = n.get(N), c = (l = i.getUniverDocInstance(t)) == null ? void 0 : l.getSnapshot().body;
|
|
682
1231
|
if (c == null)
|
|
683
1232
|
return !1;
|
|
684
|
-
const
|
|
1233
|
+
const d = $t(t, s, c, r);
|
|
685
1234
|
return o.syncExecuteCommand(
|
|
686
|
-
|
|
687
|
-
|
|
1235
|
+
d.id,
|
|
1236
|
+
d.params
|
|
688
1237
|
), a.clearUndoRedo(t), !0;
|
|
689
1238
|
}
|
|
690
1239
|
};
|
|
691
|
-
function
|
|
1240
|
+
function $t(n, e, t, r) {
|
|
692
1241
|
const s = {
|
|
693
|
-
id:
|
|
1242
|
+
id: _.id,
|
|
694
1243
|
params: {
|
|
695
|
-
unitId:
|
|
1244
|
+
unitId: n,
|
|
696
1245
|
mutations: []
|
|
697
1246
|
}
|
|
698
1247
|
}, i = (t == null ? void 0 : t.dataStream.length) - 2;
|
|
@@ -701,209 +1250,84 @@ function Pt(r, e, t, n) {
|
|
|
701
1250
|
len: i,
|
|
702
1251
|
line: 0,
|
|
703
1252
|
segmentId: e
|
|
704
|
-
}),
|
|
1253
|
+
}), r.dataStream.length > 0 && s.params.mutations.push({
|
|
705
1254
|
t: "i",
|
|
706
|
-
body:
|
|
707
|
-
len:
|
|
1255
|
+
body: r,
|
|
1256
|
+
len: r.dataStream.length,
|
|
708
1257
|
line: 0,
|
|
709
1258
|
segmentId: e
|
|
710
1259
|
}), s;
|
|
711
1260
|
}
|
|
712
|
-
const
|
|
1261
|
+
const ee = {
|
|
713
1262
|
id: "doc.operation.move-cursor",
|
|
714
|
-
type:
|
|
715
|
-
handler: (
|
|
716
|
-
},
|
|
1263
|
+
type: R.OPERATION,
|
|
1264
|
+
handler: (n, e) => !!e
|
|
1265
|
+
}, te = {
|
|
717
1266
|
id: "doc.operation.move-selection",
|
|
718
|
-
type:
|
|
719
|
-
handler: (
|
|
720
|
-
},
|
|
721
|
-
|
|
722
|
-
type: C.OPERATION,
|
|
723
|
-
handler: (r, e) => (r.get(P).replaceTextRangesWithNoRefresh(e.ranges), !0)
|
|
724
|
-
}, On = (r, e) => {
|
|
725
|
-
const t = r.get(I).getUniverDocInstance(e.unitId), n = (t == null ? void 0 : t.zoomRatio) || 1;
|
|
1267
|
+
type: R.OPERATION,
|
|
1268
|
+
handler: (n, e) => !!e
|
|
1269
|
+
}, Gn = (n, e) => {
|
|
1270
|
+
const t = n.get(O).getUniverDocInstance(e.unitId), r = (t == null ? void 0 : t.zoomRatio) || 1;
|
|
726
1271
|
return {
|
|
727
|
-
...
|
|
728
|
-
zoomRatio:
|
|
1272
|
+
...H.deepClone(e),
|
|
1273
|
+
zoomRatio: r
|
|
729
1274
|
};
|
|
730
|
-
},
|
|
1275
|
+
}, Z = {
|
|
731
1276
|
id: "doc.operation.set-zoom-ratio",
|
|
732
|
-
type:
|
|
733
|
-
handler: (
|
|
734
|
-
const t =
|
|
1277
|
+
type: R.OPERATION,
|
|
1278
|
+
handler: (n, e) => {
|
|
1279
|
+
const t = n.get(O).getUniverDocInstance(e.unitId);
|
|
735
1280
|
if (!t)
|
|
736
1281
|
return !1;
|
|
737
|
-
const
|
|
738
|
-
return
|
|
1282
|
+
const r = t.getSnapshot();
|
|
1283
|
+
return r.settings == null ? r.settings = {
|
|
739
1284
|
zoomRatio: e.zoomRatio
|
|
740
|
-
} :
|
|
1285
|
+
} : r.settings.zoomRatio = e.zoomRatio, !0;
|
|
741
1286
|
}
|
|
742
|
-
},
|
|
743
|
-
type:
|
|
1287
|
+
}, Bt = {
|
|
1288
|
+
type: R.COMMAND,
|
|
744
1289
|
id: "doc.command.set-zoom-ratio",
|
|
745
|
-
handler: async (
|
|
746
|
-
const t =
|
|
1290
|
+
handler: async (n, e) => {
|
|
1291
|
+
const t = n.get(x), r = n.get(N), s = n.get(O);
|
|
747
1292
|
let i = s.getCurrentUniverDocInstance().getUnitId(), o = 1;
|
|
748
1293
|
if (e && (i = e.documentId ?? i, o = e.zoomRatio ?? o), !s.getUniverDocInstance(i))
|
|
749
1294
|
return !1;
|
|
750
|
-
const c = {
|
|
751
|
-
zoomRatio: o,
|
|
752
|
-
unitId: i
|
|
753
|
-
},
|
|
754
|
-
return t.syncExecuteCommand(
|
|
755
|
-
unitID: i,
|
|
756
|
-
undoMutations: [{ id:
|
|
757
|
-
redoMutations: [{ id:
|
|
758
|
-
}), !0) : !1;
|
|
759
|
-
}
|
|
760
|
-
}, wt = {
|
|
761
|
-
id: "doc.operation.select-all",
|
|
762
|
-
type: C.COMMAND,
|
|
763
|
-
handler: async (r) => {
|
|
764
|
-
const e = r.get(I), t = r.get(P), n = e.getCurrentUniverDocInstance().getSnapshot().body;
|
|
765
|
-
if (n == null)
|
|
766
|
-
return !1;
|
|
767
|
-
const s = [
|
|
768
|
-
{
|
|
769
|
-
startOffset: 0,
|
|
770
|
-
endOffset: n.dataStream.length - 2,
|
|
771
|
-
collapsed: !1
|
|
772
|
-
}
|
|
773
|
-
];
|
|
774
|
-
return t.replaceTextRanges(s), !0;
|
|
775
|
-
}
|
|
776
|
-
}, _t = {
|
|
777
|
-
id: "doc.command.inner-paste",
|
|
778
|
-
type: C.COMMAND,
|
|
779
|
-
handler: async (r, e) => {
|
|
780
|
-
const { segmentId: t, body: n, textRanges: s } = e, i = r.get(B), o = r.get(D), a = r.get(P), c = r.get(I), l = a.getSelections();
|
|
781
|
-
if (!Array.isArray(l) || l.length === 0)
|
|
782
|
-
return !1;
|
|
783
|
-
const f = c.getCurrentUniverDocInstance().getUnitId(), h = {
|
|
784
|
-
id: S.id,
|
|
785
|
-
params: {
|
|
786
|
-
unitId: f,
|
|
787
|
-
mutations: []
|
|
788
|
-
}
|
|
789
|
-
}, u = new He();
|
|
790
|
-
u.reset();
|
|
791
|
-
for (const p of l) {
|
|
792
|
-
const { startOffset: m, endOffset: v, collapsed: M } = p, y = m - u.cursor;
|
|
793
|
-
M ? h.params.mutations.push({
|
|
794
|
-
t: "r",
|
|
795
|
-
len: y,
|
|
796
|
-
segmentId: t
|
|
797
|
-
}) : h.params.mutations.push(
|
|
798
|
-
...me(p, t, u.cursor)
|
|
799
|
-
), h.params.mutations.push({
|
|
800
|
-
t: "i",
|
|
801
|
-
body: n,
|
|
802
|
-
len: n.dataStream.length,
|
|
803
|
-
line: 0,
|
|
804
|
-
segmentId: t
|
|
805
|
-
}), u.reset(), u.moveCursor(v);
|
|
806
|
-
}
|
|
807
|
-
const g = o.syncExecuteCommand(h.id, h.params);
|
|
808
|
-
return a.replaceTextRanges(s), g ? (i.pushUndoRedo({
|
|
809
|
-
unitID: f,
|
|
810
|
-
undoMutations: [{ id: S.id, params: g }],
|
|
811
|
-
redoMutations: [{ id: S.id, params: h.params }],
|
|
812
|
-
undo() {
|
|
813
|
-
return o.syncExecuteCommand(S.id, g), a.replaceTextRanges(l), !0;
|
|
814
|
-
},
|
|
815
|
-
redo() {
|
|
816
|
-
return o.syncExecuteCommand(S.id, h.params), a.replaceTextRanges(s), !0;
|
|
817
|
-
}
|
|
818
|
-
}), !0) : !1;
|
|
819
|
-
}
|
|
820
|
-
}, ze = {
|
|
821
|
-
id: "doc.command.inner-cut",
|
|
822
|
-
type: C.COMMAND,
|
|
823
|
-
handler: async (r, e) => {
|
|
824
|
-
const { segmentId: t, textRanges: n } = e, s = r.get(B), i = r.get(D), o = r.get(P), a = r.get(I), c = o.getSelections();
|
|
825
|
-
if (!Array.isArray(c) || c.length === 0)
|
|
826
|
-
return !1;
|
|
827
|
-
const l = a.getCurrentUniverDocInstance().getUnitId(), d = a.getUniverDocInstance(l), f = Nt(d.snapshot, t);
|
|
828
|
-
if (f == null)
|
|
829
|
-
return !1;
|
|
830
|
-
const h = {
|
|
831
|
-
id: S.id,
|
|
832
|
-
params: {
|
|
833
|
-
unitId: l,
|
|
834
|
-
mutations: []
|
|
835
|
-
}
|
|
836
|
-
}, u = new He();
|
|
837
|
-
u.reset();
|
|
838
|
-
for (const p of c) {
|
|
839
|
-
const { startOffset: m, endOffset: v, collapsed: M } = p, y = m - u.cursor;
|
|
840
|
-
M ? h.params.mutations.push({
|
|
841
|
-
t: "r",
|
|
842
|
-
len: y,
|
|
843
|
-
segmentId: t
|
|
844
|
-
}) : h.params.mutations.push(
|
|
845
|
-
...yn(p, f, t, u.cursor)
|
|
846
|
-
), u.reset(), u.moveCursor(v);
|
|
847
|
-
}
|
|
848
|
-
const g = i.syncExecuteCommand(h.id, h.params);
|
|
849
|
-
return o.replaceTextRanges(n), g ? (s.pushUndoRedo({
|
|
850
|
-
unitID: l,
|
|
851
|
-
undoMutations: [{ id: S.id, params: g }],
|
|
852
|
-
redoMutations: [{ id: S.id, params: h.params }],
|
|
853
|
-
undo() {
|
|
854
|
-
return i.syncExecuteCommand(S.id, g), o.replaceTextRanges(c), !0;
|
|
855
|
-
},
|
|
856
|
-
redo() {
|
|
857
|
-
return i.syncExecuteCommand(S.id, h.params), o.replaceTextRanges(n), !0;
|
|
858
|
-
}
|
|
1295
|
+
const c = {
|
|
1296
|
+
zoomRatio: o,
|
|
1297
|
+
unitId: i
|
|
1298
|
+
}, d = Gn(n, c);
|
|
1299
|
+
return t.syncExecuteCommand(Z.id, c) ? (r.pushUndoRedo({
|
|
1300
|
+
unitID: i,
|
|
1301
|
+
undoMutations: [{ id: Z.id, params: d }],
|
|
1302
|
+
redoMutations: [{ id: Z.id, params: c }]
|
|
859
1303
|
}), !0) : !1;
|
|
860
1304
|
}
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
len: 1,
|
|
880
|
-
segmentId: t
|
|
881
|
-
}), l > f + 1 && o.push({
|
|
882
|
-
t: "d",
|
|
883
|
-
len: l - f - 1,
|
|
884
|
-
line: 0,
|
|
885
|
-
segmentId: t
|
|
886
|
-
});
|
|
887
|
-
} else
|
|
888
|
-
o.push({
|
|
889
|
-
t: "d",
|
|
890
|
-
len: l - c,
|
|
891
|
-
line: 0,
|
|
892
|
-
segmentId: t
|
|
893
|
-
});
|
|
894
|
-
return o;
|
|
895
|
-
}
|
|
896
|
-
const bn = 10, Dn = 6;
|
|
897
|
-
function Pn() {
|
|
898
|
-
return Q.generateRandomId(Dn);
|
|
1305
|
+
}, jt = {
|
|
1306
|
+
id: "doc.operation.select-all",
|
|
1307
|
+
type: R.COMMAND,
|
|
1308
|
+
handler: async (n) => {
|
|
1309
|
+
const e = n.get(O), t = n.get(P), r = e.getCurrentUniverDocInstance().getSnapshot().body;
|
|
1310
|
+
if (r == null)
|
|
1311
|
+
return !1;
|
|
1312
|
+
const s = [
|
|
1313
|
+
{
|
|
1314
|
+
startOffset: 0,
|
|
1315
|
+
endOffset: r.dataStream.length - 2
|
|
1316
|
+
}
|
|
1317
|
+
];
|
|
1318
|
+
return t.replaceTextRanges(s), !0;
|
|
1319
|
+
}
|
|
1320
|
+
}, Xn = 10, qn = 6;
|
|
1321
|
+
function Yn() {
|
|
1322
|
+
return H.generateRandomId(qn);
|
|
899
1323
|
}
|
|
900
|
-
function
|
|
901
|
-
const e =
|
|
1324
|
+
function Zn(n) {
|
|
1325
|
+
const e = n.match(/data-copy-id="([^\s]+)"/);
|
|
902
1326
|
return e && e[1] ? e[1] : null;
|
|
903
1327
|
}
|
|
904
|
-
class
|
|
1328
|
+
class Kn {
|
|
905
1329
|
constructor() {
|
|
906
|
-
|
|
1330
|
+
S(this, "_cache", new Wt(Xn));
|
|
907
1331
|
}
|
|
908
1332
|
set(e, t) {
|
|
909
1333
|
this._cache.set(e, t);
|
|
@@ -915,57 +1339,57 @@ class En {
|
|
|
915
1339
|
this._cache.clear();
|
|
916
1340
|
}
|
|
917
1341
|
}
|
|
918
|
-
const
|
|
919
|
-
function
|
|
920
|
-
const e =
|
|
921
|
-
for (let
|
|
922
|
-
const s = e[
|
|
1342
|
+
const ft = new Kn();
|
|
1343
|
+
function Jn(n) {
|
|
1344
|
+
const e = n.style, t = {};
|
|
1345
|
+
for (let r = 0; r < e.length; r++) {
|
|
1346
|
+
const s = e[r], i = e.getPropertyValue(s);
|
|
923
1347
|
switch (s) {
|
|
924
1348
|
case "margin-top": {
|
|
925
1349
|
const o = parseInt(i);
|
|
926
|
-
t.spaceAbove = /pt/.test(i) ?
|
|
1350
|
+
t.spaceAbove = /pt/.test(i) ? qe(o) : o;
|
|
927
1351
|
break;
|
|
928
1352
|
}
|
|
929
1353
|
case "margin-bottom": {
|
|
930
1354
|
const o = parseInt(i);
|
|
931
|
-
t.spaceBelow = /pt/.test(i) ?
|
|
1355
|
+
t.spaceBelow = /pt/.test(i) ? qe(o) : o;
|
|
932
1356
|
break;
|
|
933
1357
|
}
|
|
934
1358
|
}
|
|
935
1359
|
}
|
|
936
1360
|
return Object.getOwnPropertyNames(t).length ? t : null;
|
|
937
1361
|
}
|
|
938
|
-
function
|
|
939
|
-
return
|
|
1362
|
+
function qe(n) {
|
|
1363
|
+
return n / 0.75;
|
|
940
1364
|
}
|
|
941
|
-
function
|
|
942
|
-
const e =
|
|
943
|
-
switch (
|
|
1365
|
+
function rt(n) {
|
|
1366
|
+
const e = n.style, t = {}, r = n.tagName.toLowerCase();
|
|
1367
|
+
switch (r) {
|
|
944
1368
|
case "b":
|
|
945
1369
|
case "em":
|
|
946
1370
|
case "strong": {
|
|
947
|
-
t.bl =
|
|
1371
|
+
t.bl = D.TRUE;
|
|
948
1372
|
break;
|
|
949
1373
|
}
|
|
950
1374
|
case "s": {
|
|
951
1375
|
t.st = {
|
|
952
|
-
s:
|
|
1376
|
+
s: D.TRUE
|
|
953
1377
|
};
|
|
954
1378
|
break;
|
|
955
1379
|
}
|
|
956
1380
|
case "u": {
|
|
957
1381
|
t.ul = {
|
|
958
|
-
s:
|
|
1382
|
+
s: D.TRUE
|
|
959
1383
|
};
|
|
960
1384
|
break;
|
|
961
1385
|
}
|
|
962
1386
|
case "i": {
|
|
963
|
-
t.it =
|
|
1387
|
+
t.it = D.TRUE;
|
|
964
1388
|
break;
|
|
965
1389
|
}
|
|
966
1390
|
case "sub":
|
|
967
1391
|
case "sup": {
|
|
968
|
-
t.va =
|
|
1392
|
+
t.va = r === "sup" ? j.SUPERSCRIPT : j.SUBSCRIPT;
|
|
969
1393
|
break;
|
|
970
1394
|
}
|
|
971
1395
|
}
|
|
@@ -978,36 +1402,36 @@ function at(r) {
|
|
|
978
1402
|
}
|
|
979
1403
|
case "font-size": {
|
|
980
1404
|
const a = parseInt(o);
|
|
981
|
-
Number.isNaN(a) || (t.fs = /pt$/.test(o) ?
|
|
1405
|
+
Number.isNaN(a) || (t.fs = /pt$/.test(o) ? qe(a) : a);
|
|
982
1406
|
break;
|
|
983
1407
|
}
|
|
984
1408
|
case "font-style": {
|
|
985
|
-
o === "italic" && (t.it =
|
|
1409
|
+
o === "italic" && (t.it = D.TRUE);
|
|
986
1410
|
break;
|
|
987
1411
|
}
|
|
988
1412
|
case "font-weight": {
|
|
989
|
-
Number(o) > 400 && (t.bl =
|
|
1413
|
+
Number(o) > 400 && (t.bl = D.TRUE);
|
|
990
1414
|
break;
|
|
991
1415
|
}
|
|
992
1416
|
case "text-decoration": {
|
|
993
1417
|
/underline/.test(o) ? t.ul = {
|
|
994
|
-
s:
|
|
1418
|
+
s: D.TRUE
|
|
995
1419
|
} : /overline/.test(o) ? t.ol = {
|
|
996
|
-
s:
|
|
1420
|
+
s: D.TRUE
|
|
997
1421
|
} : /line-through/.test(o) && (t.st = {
|
|
998
|
-
s:
|
|
1422
|
+
s: D.TRUE
|
|
999
1423
|
});
|
|
1000
1424
|
break;
|
|
1001
1425
|
}
|
|
1002
1426
|
case "color": {
|
|
1003
|
-
const a = new
|
|
1427
|
+
const a = new it(o);
|
|
1004
1428
|
a.isValid && (t.cl = {
|
|
1005
1429
|
rgb: a.toRgbString()
|
|
1006
1430
|
});
|
|
1007
1431
|
break;
|
|
1008
1432
|
}
|
|
1009
1433
|
case "background-color": {
|
|
1010
|
-
const a = new
|
|
1434
|
+
const a = new it(o);
|
|
1011
1435
|
a.isValid && (t.bg = {
|
|
1012
1436
|
rgb: a.toRgbString()
|
|
1013
1437
|
});
|
|
@@ -1017,71 +1441,71 @@ function at(r) {
|
|
|
1017
1441
|
}
|
|
1018
1442
|
return t;
|
|
1019
1443
|
}
|
|
1020
|
-
function
|
|
1021
|
-
const e = new DOMParser(), t = `<x-univer id="univer-root">${
|
|
1444
|
+
function Qn(n) {
|
|
1445
|
+
const e = new DOMParser(), t = `<x-univer id="univer-root">${n}</x-univer>`;
|
|
1022
1446
|
return e.parseFromString(t, "text/html").querySelector("#univer-root");
|
|
1023
1447
|
}
|
|
1024
|
-
function
|
|
1025
|
-
const t =
|
|
1026
|
-
return typeof e == "string" ? t === e : Array.isArray(e) ? e.some((
|
|
1448
|
+
function _t(n, e) {
|
|
1449
|
+
const t = n.tagName.toLowerCase();
|
|
1450
|
+
return typeof e == "string" ? t === e : Array.isArray(e) ? e.some((r) => r === t) : e(n);
|
|
1027
1451
|
}
|
|
1028
|
-
const
|
|
1452
|
+
const Ue = class Ue {
|
|
1029
1453
|
constructor() {
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1454
|
+
S(this, "_styleCache", /* @__PURE__ */ new Map());
|
|
1455
|
+
S(this, "_styleRules", []);
|
|
1456
|
+
S(this, "_afterProcessRules", []);
|
|
1033
1457
|
}
|
|
1034
1458
|
static use(e) {
|
|
1035
|
-
if (this.
|
|
1459
|
+
if (this._pluginList.includes(e))
|
|
1036
1460
|
throw new Error(`Univer paste plugin ${e.name} already added`);
|
|
1037
|
-
this.
|
|
1461
|
+
this._pluginList.push(e);
|
|
1038
1462
|
}
|
|
1039
1463
|
convert(e) {
|
|
1040
|
-
const t =
|
|
1464
|
+
const t = Ue._pluginList.find((i) => i.checkPasteType(e)), r = Qn(e), s = {
|
|
1041
1465
|
dataStream: "",
|
|
1042
1466
|
textRuns: []
|
|
1043
1467
|
};
|
|
1044
|
-
return t && (this.
|
|
1468
|
+
return t && (this._styleRules = [...t.stylesRules], this._afterProcessRules = [...t.afterProcessRules]), this._styleCache.clear(), this._process(null, r == null ? void 0 : r.childNodes, s), this._styleCache.clear(), this._styleRules = [], this._afterProcessRules = [], s;
|
|
1045
1469
|
}
|
|
1046
|
-
|
|
1470
|
+
_process(e, t, r) {
|
|
1047
1471
|
var s;
|
|
1048
1472
|
for (const i of t)
|
|
1049
1473
|
if (i.nodeType === Node.TEXT_NODE) {
|
|
1050
1474
|
const o = (s = i.nodeValue) == null ? void 0 : s.replace(/[\r\n]/g, "");
|
|
1051
1475
|
let a;
|
|
1052
|
-
e && this.
|
|
1053
|
-
st:
|
|
1054
|
-
ed:
|
|
1476
|
+
e && this._styleCache.has(e) && (a = this._styleCache.get(e)), r.dataStream += o, a && Object.getOwnPropertyNames(a).length && r.textRuns.push({
|
|
1477
|
+
st: r.dataStream.length - o.length,
|
|
1478
|
+
ed: r.dataStream.length,
|
|
1055
1479
|
ts: a
|
|
1056
1480
|
});
|
|
1057
1481
|
} else if (i.nodeType === Node.ELEMENT_NODE) {
|
|
1058
|
-
const o = e ? this.
|
|
1059
|
-
this.
|
|
1060
|
-
const { childNodes:
|
|
1061
|
-
this.
|
|
1062
|
-
const
|
|
1063
|
-
({ filter:
|
|
1482
|
+
const o = e ? this._styleCache.get(e) : {}, a = this._styleRules.find(({ filter: h }) => _t(i, h)), c = a ? a.getStyle(i) : rt(i);
|
|
1483
|
+
this._styleCache.set(i, { ...o, ...c });
|
|
1484
|
+
const { childNodes: d } = i;
|
|
1485
|
+
this._process(i, d, r);
|
|
1486
|
+
const l = this._afterProcessRules.find(
|
|
1487
|
+
({ filter: h }) => _t(i, h)
|
|
1064
1488
|
);
|
|
1065
|
-
|
|
1489
|
+
l && l.handler(r, i);
|
|
1066
1490
|
}
|
|
1067
1491
|
}
|
|
1068
1492
|
};
|
|
1069
|
-
|
|
1070
|
-
let
|
|
1071
|
-
const
|
|
1493
|
+
S(Ue, "_pluginList", []);
|
|
1494
|
+
let ge = Ue;
|
|
1495
|
+
const er = {
|
|
1072
1496
|
name: "univer-doc-paste-plugin-lark",
|
|
1073
|
-
checkPasteType(
|
|
1074
|
-
return /lark-record-clipboard/i.test(
|
|
1497
|
+
checkPasteType(n) {
|
|
1498
|
+
return /lark-record-clipboard/i.test(n);
|
|
1075
1499
|
},
|
|
1076
1500
|
// TODO: @JOCS, support inline code copy from lark.
|
|
1077
1501
|
stylesRules: [
|
|
1078
1502
|
{
|
|
1079
1503
|
filter: ["s"],
|
|
1080
|
-
getStyle(
|
|
1081
|
-
const e =
|
|
1504
|
+
getStyle(n) {
|
|
1505
|
+
const e = rt(n);
|
|
1082
1506
|
return {
|
|
1083
1507
|
st: {
|
|
1084
|
-
s:
|
|
1508
|
+
s: D.TRUE
|
|
1085
1509
|
},
|
|
1086
1510
|
...e
|
|
1087
1511
|
};
|
|
@@ -1090,163 +1514,177 @@ const Ln = {
|
|
|
1090
1514
|
],
|
|
1091
1515
|
afterProcessRules: [
|
|
1092
1516
|
{
|
|
1093
|
-
filter(
|
|
1094
|
-
return
|
|
1517
|
+
filter(n) {
|
|
1518
|
+
return n.tagName === "DIV" && /ace-line/i.test(n.className);
|
|
1095
1519
|
},
|
|
1096
|
-
handler(
|
|
1097
|
-
|
|
1098
|
-
startIndex:
|
|
1099
|
-
}),
|
|
1520
|
+
handler(n) {
|
|
1521
|
+
n.paragraphs == null && (n.paragraphs = []), n.paragraphs.push({
|
|
1522
|
+
startIndex: n.dataStream.length
|
|
1523
|
+
}), n.dataStream += "\r";
|
|
1100
1524
|
}
|
|
1101
1525
|
}
|
|
1102
1526
|
]
|
|
1103
|
-
},
|
|
1527
|
+
}, tr = {
|
|
1104
1528
|
name: "univer-doc-paste-plugin-word",
|
|
1105
|
-
checkPasteType(
|
|
1106
|
-
return /word|mso/i.test(
|
|
1529
|
+
checkPasteType(n) {
|
|
1530
|
+
return /word|mso/i.test(n);
|
|
1107
1531
|
},
|
|
1108
1532
|
stylesRules: [
|
|
1109
1533
|
{
|
|
1110
1534
|
filter: ["b"],
|
|
1111
|
-
getStyle(
|
|
1112
|
-
const e =
|
|
1113
|
-
return { bl:
|
|
1535
|
+
getStyle(n) {
|
|
1536
|
+
const e = rt(n);
|
|
1537
|
+
return { bl: D.TRUE, ...e };
|
|
1114
1538
|
}
|
|
1115
1539
|
}
|
|
1116
1540
|
],
|
|
1117
1541
|
afterProcessRules: [
|
|
1118
1542
|
{
|
|
1119
|
-
filter(
|
|
1120
|
-
return
|
|
1543
|
+
filter(n) {
|
|
1544
|
+
return n.tagName === "P" && /mso/i.test(n.className);
|
|
1121
1545
|
},
|
|
1122
|
-
handler(
|
|
1123
|
-
|
|
1546
|
+
handler(n, e) {
|
|
1547
|
+
n.paragraphs == null && (n.paragraphs = []);
|
|
1124
1548
|
const t = {
|
|
1125
|
-
startIndex:
|
|
1126
|
-
},
|
|
1127
|
-
|
|
1549
|
+
startIndex: n.dataStream.length
|
|
1550
|
+
}, r = Jn(e);
|
|
1551
|
+
r && (t.paragraphStyle = r), n.paragraphs.push(t), n.dataStream += "\r";
|
|
1128
1552
|
}
|
|
1129
1553
|
}
|
|
1130
1554
|
]
|
|
1131
1555
|
};
|
|
1132
|
-
function
|
|
1133
|
-
const { st: t, ed:
|
|
1134
|
-
let
|
|
1135
|
-
const
|
|
1136
|
-
return a ===
|
|
1556
|
+
function nr(n, e) {
|
|
1557
|
+
const { st: t, ed: r, ts: s = {} } = e, { ff: i, fs: o, it: a, bl: c, ul: d, st: l, ol: h, bg: p, cl: u, va: g } = s;
|
|
1558
|
+
let m = n.slice(t, r);
|
|
1559
|
+
const f = [];
|
|
1560
|
+
return a === D.TRUE && (m = `<i>${m}</i>`), g === j.SUPERSCRIPT ? m = `<sup>${m}</sup>` : g === j.SUBSCRIPT && (m = `<sub>${m}</sub>`), (d == null ? void 0 : d.s) === D.TRUE && (m = `<u>${m}</u>`), (l == null ? void 0 : l.s) === D.TRUE && (m = `<s>${m}</s>`), c === D.TRUE && (m = `<strong>${m}</strong>`), i && f.push(`font-family: ${i}`), u && f.push(`color: ${u.rgb}`), o && f.push(`font-size: ${o}px`), h && f.push("text-decoration: overline"), p && f.push(`background: ${p.rgb}`), f.length ? `<span style="${f.join(";")}">${m}</span>` : m;
|
|
1137
1561
|
}
|
|
1138
|
-
function
|
|
1139
|
-
const { dataStream: t, textRuns:
|
|
1562
|
+
function St(n, e = !0) {
|
|
1563
|
+
const { dataStream: t, textRuns: r = [], paragraphs: s = [] } = n;
|
|
1140
1564
|
let i = 0;
|
|
1141
1565
|
const o = [], a = [];
|
|
1142
|
-
for (const c of
|
|
1143
|
-
const { st:
|
|
1144
|
-
if (
|
|
1145
|
-
for (const
|
|
1146
|
-
const { startIndex:
|
|
1147
|
-
if (
|
|
1148
|
-
const { spaceAbove: g, spaceBelow:
|
|
1149
|
-
g != null && (typeof g == "number" ?
|
|
1150
|
-
`<p className="UniverNormal" ${
|
|
1566
|
+
for (const c of r) {
|
|
1567
|
+
const { st: d, ed: l } = c;
|
|
1568
|
+
if (d !== i && o.push(t.slice(i, d)), o.push(nr(t, c)), i = l, e)
|
|
1569
|
+
for (const h of s) {
|
|
1570
|
+
const { startIndex: p, paragraphStyle: u = {} } = h;
|
|
1571
|
+
if (p >= d && p <= l) {
|
|
1572
|
+
const { spaceAbove: g, spaceBelow: m } = u, f = [];
|
|
1573
|
+
g != null && (typeof g == "number" ? f.push(`margin-top: ${g}px`) : f.push(`margin-top: ${g.v}px`)), m != null && (typeof m == "number" ? f.push(`margin-bottom: ${m}px`) : f.push(`margin-bottom: ${m.v}px`)), a.push(
|
|
1574
|
+
`<p className="UniverNormal" ${f.length ? `style="${f.join(";")}"` : ""}>${o.join("")}</p>`
|
|
1151
1575
|
), o.length = 0;
|
|
1152
1576
|
}
|
|
1153
1577
|
}
|
|
1154
1578
|
}
|
|
1155
1579
|
return a.join("") + o.join("");
|
|
1156
1580
|
}
|
|
1157
|
-
class
|
|
1581
|
+
class rr {
|
|
1158
1582
|
convert(e) {
|
|
1159
1583
|
if (e.length === 0)
|
|
1160
1584
|
throw new Error("The bodyList length at least to be 1");
|
|
1161
1585
|
if (e.length === 1)
|
|
1162
|
-
return
|
|
1586
|
+
return St(e[0]);
|
|
1163
1587
|
let t = "";
|
|
1164
|
-
for (const
|
|
1165
|
-
t += '<p className="UniverNormal">', t +=
|
|
1588
|
+
for (const r of e)
|
|
1589
|
+
t += '<p className="UniverNormal">', t += St(r, !1), t += "</p>";
|
|
1166
1590
|
return t;
|
|
1167
1591
|
}
|
|
1168
1592
|
}
|
|
1169
|
-
var
|
|
1170
|
-
for (var s =
|
|
1171
|
-
(o =
|
|
1172
|
-
return
|
|
1173
|
-
},
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1593
|
+
var sr = Object.defineProperty, ir = Object.getOwnPropertyDescriptor, or = (n, e, t, r) => {
|
|
1594
|
+
for (var s = r > 1 ? void 0 : r ? ir(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
1595
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1596
|
+
return r && s && sr(e, t, s), s;
|
|
1597
|
+
}, vt = (n, e) => (t, r) => e(t, r, n);
|
|
1598
|
+
ge.use(tr);
|
|
1599
|
+
ge.use(er);
|
|
1600
|
+
function ar(n) {
|
|
1601
|
+
const e = n.replace(/\n/g, "\r"), t = [];
|
|
1602
|
+
for (let r = 0; r < e.length; r++)
|
|
1603
|
+
e[r] === "\r" && t.push({ startIndex: r });
|
|
1604
|
+
return {
|
|
1605
|
+
dataStream: e,
|
|
1606
|
+
paragraphs: t
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
const Vt = Mn("doc.clipboard-service");
|
|
1610
|
+
let Ye = class extends W {
|
|
1178
1611
|
constructor(e, t) {
|
|
1179
1612
|
super();
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1613
|
+
S(this, "_clipboardHooks", []);
|
|
1614
|
+
S(this, "_htmlToUDM", new ge());
|
|
1615
|
+
S(this, "_umdToHtml", new rr());
|
|
1183
1616
|
this._currentUniverService = e, this._clipboardInterfaceService = t;
|
|
1184
1617
|
}
|
|
1185
1618
|
async queryClipboardData() {
|
|
1186
1619
|
const e = await this._clipboardInterfaceService.read();
|
|
1187
1620
|
if (e.length === 0)
|
|
1188
1621
|
return Promise.reject();
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
const
|
|
1197
|
-
if (
|
|
1198
|
-
|
|
1622
|
+
try {
|
|
1623
|
+
let t = "", r = "";
|
|
1624
|
+
for (const i of e)
|
|
1625
|
+
for (const o of i.types)
|
|
1626
|
+
o === mn ? r = await i.getType(o).then((a) => a && a.text()) : o === fn && (t = await i.getType(o).then((a) => a && a.text()));
|
|
1627
|
+
if (!t)
|
|
1628
|
+
return ar(r);
|
|
1629
|
+
const s = Zn(t);
|
|
1630
|
+
if (s) {
|
|
1631
|
+
const i = ft.get(s);
|
|
1632
|
+
if (i)
|
|
1633
|
+
return i;
|
|
1634
|
+
}
|
|
1635
|
+
return this._htmlToUDM.convert(t);
|
|
1636
|
+
} catch (t) {
|
|
1637
|
+
return Promise.reject(t);
|
|
1199
1638
|
}
|
|
1200
|
-
return this._htmlToUDM.convert(s);
|
|
1201
1639
|
}
|
|
1202
1640
|
async setClipboardData(e) {
|
|
1203
|
-
const t =
|
|
1641
|
+
const t = Yn(), r = e.length > 1 ? e.map((i) => i.dataStream).join(`
|
|
1204
1642
|
`) : e[0].dataStream;
|
|
1205
1643
|
let s = this._umdToHtml.convert(e);
|
|
1206
|
-
return e.length === 1 && (s = s.replace(/(<[a-z]+)/, (i, o) => `${o} data-copy-id="${t}"`),
|
|
1644
|
+
return e.length === 1 && (s = s.replace(/(<[a-z]+)/, (i, o) => `${o} data-copy-id="${t}"`), ft.set(t, e[0])), this._clipboardInterfaceService.write(r, s);
|
|
1207
1645
|
}
|
|
1208
1646
|
addClipboardHook(e) {
|
|
1209
|
-
return this._clipboardHooks.push(e),
|
|
1647
|
+
return this._clipboardHooks.push(e), Ge(() => {
|
|
1210
1648
|
const t = this._clipboardHooks.indexOf(e);
|
|
1211
1649
|
t > -1 && this._clipboardHooks.splice(t, 1);
|
|
1212
1650
|
});
|
|
1213
1651
|
}
|
|
1214
1652
|
};
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
],
|
|
1219
|
-
var
|
|
1220
|
-
for (var s =
|
|
1221
|
-
(o =
|
|
1222
|
-
return
|
|
1223
|
-
},
|
|
1224
|
-
let
|
|
1225
|
-
constructor(
|
|
1226
|
-
super(), this._logService =
|
|
1653
|
+
Ye = or([
|
|
1654
|
+
vt(0, O),
|
|
1655
|
+
vt(1, _n)
|
|
1656
|
+
], Ye);
|
|
1657
|
+
var cr = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, dr = (n, e, t, r) => {
|
|
1658
|
+
for (var s = r > 1 ? void 0 : r ? lr(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
1659
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1660
|
+
return r && s && cr(e, t, s), s;
|
|
1661
|
+
}, ne = (n, e) => (t, r) => e(t, r, n);
|
|
1662
|
+
let Me = class extends W {
|
|
1663
|
+
constructor(n, e, t, r, s, i) {
|
|
1664
|
+
super(), this._logService = n, this._commandService = e, this._currentUniverService = t, this._docClipboardService = r, this._textSelectionManagerService = s, this._contextService = i, this._commandExecutedListener(), this.initialize();
|
|
1227
1665
|
}
|
|
1228
1666
|
initialize() {
|
|
1229
|
-
[
|
|
1230
|
-
(
|
|
1231
|
-
), [
|
|
1232
|
-
(
|
|
1667
|
+
[Ve, Fe, ke].forEach(
|
|
1668
|
+
(n) => this.disposeWithMe(this._commandService.registerAsMultipleCommand(n))
|
|
1669
|
+
), [mt, Ee].forEach(
|
|
1670
|
+
(n) => this.disposeWithMe(this._commandService.registerCommand(n))
|
|
1233
1671
|
);
|
|
1234
1672
|
}
|
|
1235
1673
|
_commandExecutedListener() {
|
|
1236
|
-
const
|
|
1674
|
+
const n = [Fe.id, Ve.id, ke.id];
|
|
1237
1675
|
this.disposeWithMe(
|
|
1238
1676
|
this._commandService.onCommandExecuted((e) => {
|
|
1239
|
-
if (
|
|
1677
|
+
if (n.includes(e.id) && !(!this._contextService.getContextValue(w) && !this._contextService.getContextValue(me)))
|
|
1240
1678
|
switch (e.id) {
|
|
1241
|
-
case
|
|
1679
|
+
case ke.id: {
|
|
1242
1680
|
this._handlePaste();
|
|
1243
1681
|
break;
|
|
1244
1682
|
}
|
|
1245
|
-
case
|
|
1683
|
+
case Ve.id: {
|
|
1246
1684
|
this._handleCopy();
|
|
1247
1685
|
break;
|
|
1248
1686
|
}
|
|
1249
|
-
case
|
|
1687
|
+
case Fe.id: {
|
|
1250
1688
|
this._handleCut();
|
|
1251
1689
|
break;
|
|
1252
1690
|
}
|
|
@@ -1257,92 +1695,93 @@ let Ce = class extends w {
|
|
|
1257
1695
|
);
|
|
1258
1696
|
}
|
|
1259
1697
|
async _handlePaste() {
|
|
1260
|
-
const { _docClipboardService:
|
|
1698
|
+
const { _docClipboardService: n } = this, {
|
|
1261
1699
|
segmentId: e,
|
|
1262
1700
|
endOffset: t,
|
|
1263
|
-
style:
|
|
1264
|
-
} = this.
|
|
1265
|
-
if (e == null && this._logService.error("[DocClipboardController] segmentId is not existed"), t
|
|
1701
|
+
style: r
|
|
1702
|
+
} = this._textSelectionManagerService.getActiveRange() ?? {}, s = this._textSelectionManagerService.getSelections();
|
|
1703
|
+
if (e == null && this._logService.error("[DocClipboardController] segmentId is not existed"), !(t == null || s == null))
|
|
1266
1704
|
try {
|
|
1267
|
-
const i = await
|
|
1705
|
+
const i = await n.queryClipboardData();
|
|
1268
1706
|
let o = t;
|
|
1269
1707
|
for (const c of s) {
|
|
1270
|
-
const { startOffset:
|
|
1271
|
-
|
|
1708
|
+
const { startOffset: d, endOffset: l } = c;
|
|
1709
|
+
d == null || l == null || l <= t && (o += i.dataStream.length - (l - d));
|
|
1272
1710
|
}
|
|
1273
1711
|
const a = [
|
|
1274
1712
|
{
|
|
1275
1713
|
startOffset: o,
|
|
1276
1714
|
endOffset: o,
|
|
1277
|
-
|
|
1278
|
-
style: n
|
|
1715
|
+
style: r
|
|
1279
1716
|
}
|
|
1280
1717
|
];
|
|
1281
|
-
this._commandService.executeCommand(
|
|
1718
|
+
this._commandService.executeCommand(mt.id, { body: i, segmentId: e, textRanges: a });
|
|
1282
1719
|
} catch {
|
|
1283
1720
|
this._logService.error("[DocClipboardController] clipboard is empty");
|
|
1284
1721
|
}
|
|
1285
1722
|
}
|
|
1286
1723
|
_getDocumentBodyInRanges() {
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1724
|
+
const n = this._textSelectionManagerService.getSelections(), e = this._currentUniverService.getCurrentUniverDocInstance(), { dataStream: t, textRuns: r = [], paragraphs: s = [] } = e.getBody(), i = [];
|
|
1725
|
+
if (n == null)
|
|
1726
|
+
return i;
|
|
1727
|
+
for (const o of n) {
|
|
1728
|
+
const { startOffset: a, endOffset: c, collapsed: d } = o;
|
|
1729
|
+
if (d || a == null || c == null)
|
|
1291
1730
|
continue;
|
|
1292
|
-
const
|
|
1731
|
+
const l = {
|
|
1293
1732
|
dataStream: t.slice(a, c)
|
|
1294
|
-
},
|
|
1295
|
-
for (const u of
|
|
1296
|
-
const g =
|
|
1297
|
-
|
|
1733
|
+
}, h = [];
|
|
1734
|
+
for (const u of r) {
|
|
1735
|
+
const g = H.deepClone(u), { st: m, ed: f } = g;
|
|
1736
|
+
H.hasIntersectionBetweenTwoRanges(m, f, a, c) && (a >= m && a <= f ? h.push({
|
|
1298
1737
|
...g,
|
|
1299
1738
|
st: a,
|
|
1300
|
-
ed: Math.min(c,
|
|
1301
|
-
}) : c >=
|
|
1739
|
+
ed: Math.min(c, f)
|
|
1740
|
+
}) : c >= m && c <= f ? h.push({
|
|
1302
1741
|
...g,
|
|
1303
|
-
st: Math.max(a,
|
|
1742
|
+
st: Math.max(a, m),
|
|
1304
1743
|
ed: c
|
|
1305
|
-
}) :
|
|
1744
|
+
}) : h.push(g));
|
|
1306
1745
|
}
|
|
1307
|
-
|
|
1308
|
-
const { st: g, ed:
|
|
1746
|
+
h.length && (l.textRuns = h.map((u) => {
|
|
1747
|
+
const { st: g, ed: m } = u;
|
|
1309
1748
|
return {
|
|
1310
1749
|
...u,
|
|
1311
1750
|
st: g - a,
|
|
1312
|
-
ed:
|
|
1751
|
+
ed: m - a
|
|
1313
1752
|
};
|
|
1314
1753
|
}));
|
|
1315
|
-
const
|
|
1754
|
+
const p = [];
|
|
1316
1755
|
for (const u of s) {
|
|
1317
1756
|
const { startIndex: g } = u;
|
|
1318
|
-
g >= a && g <= c &&
|
|
1757
|
+
g >= a && g <= c && p.push(H.deepClone(u));
|
|
1319
1758
|
}
|
|
1320
|
-
|
|
1759
|
+
p.length && (l.paragraphs = p.map((u) => ({
|
|
1321
1760
|
...u,
|
|
1322
1761
|
startIndex: u.startIndex - a
|
|
1323
|
-
}))), i.push(
|
|
1762
|
+
}))), i.push(l);
|
|
1324
1763
|
}
|
|
1325
1764
|
return i;
|
|
1326
1765
|
}
|
|
1327
1766
|
async _handleCopy() {
|
|
1328
|
-
const { _docClipboardService:
|
|
1767
|
+
const { _docClipboardService: n } = this, e = this._getDocumentBodyInRanges();
|
|
1329
1768
|
try {
|
|
1330
|
-
|
|
1769
|
+
n.setClipboardData(e);
|
|
1331
1770
|
} catch {
|
|
1332
1771
|
this._logService.error("[DocClipboardController] set clipboard failed");
|
|
1333
1772
|
}
|
|
1334
1773
|
}
|
|
1335
1774
|
async _handleCut() {
|
|
1336
1775
|
const {
|
|
1337
|
-
segmentId:
|
|
1776
|
+
segmentId: n,
|
|
1338
1777
|
endOffset: e,
|
|
1339
1778
|
style: t
|
|
1340
|
-
} = this.
|
|
1341
|
-
if (
|
|
1779
|
+
} = this._textSelectionManagerService.getActiveRange() ?? {}, r = this._textSelectionManagerService.getSelections();
|
|
1780
|
+
if (n == null && this._logService.error("[DocClipboardController] segmentId is not existed"), !(e == null || r == null)) {
|
|
1342
1781
|
this._handleCopy();
|
|
1343
1782
|
try {
|
|
1344
1783
|
let s = e;
|
|
1345
|
-
for (const o of
|
|
1784
|
+
for (const o of r) {
|
|
1346
1785
|
const { startOffset: a, endOffset: c } = o;
|
|
1347
1786
|
a == null || c == null || c <= e && (s -= c - a);
|
|
1348
1787
|
}
|
|
@@ -1350,329 +1789,63 @@ let Ce = class extends w {
|
|
|
1350
1789
|
{
|
|
1351
1790
|
startOffset: s,
|
|
1352
1791
|
endOffset: s,
|
|
1353
|
-
collapsed: !0,
|
|
1354
1792
|
style: t
|
|
1355
1793
|
}
|
|
1356
1794
|
];
|
|
1357
|
-
this._commandService.executeCommand(
|
|
1795
|
+
this._commandService.executeCommand(Ee.id, { segmentId: n, textRanges: i });
|
|
1358
1796
|
} catch {
|
|
1359
1797
|
this._logService.error("[DocClipboardController] cut content failed");
|
|
1360
1798
|
}
|
|
1361
1799
|
}
|
|
1362
1800
|
}
|
|
1363
1801
|
};
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
],
|
|
1373
|
-
var
|
|
1374
|
-
for (var s =
|
|
1375
|
-
(o =
|
|
1376
|
-
return
|
|
1377
|
-
},
|
|
1378
|
-
let
|
|
1379
|
-
constructor(
|
|
1380
|
-
|
|
1381
|
-
_(this, "_docSkeletonMap", /* @__PURE__ */ new Map());
|
|
1382
|
-
_(this, "_currentSkeleton$", new Ae(null));
|
|
1383
|
-
_(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
|
|
1384
|
-
/**
|
|
1385
|
-
* CurrentSkeletonBefore for pre-triggered logic during registration
|
|
1386
|
-
*/
|
|
1387
|
-
_(this, "_currentSkeletonBefore$", new Ae(null));
|
|
1388
|
-
_(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
|
|
1389
|
-
this._localeService = r, this._docViewModelManagerService = e, this.initialize();
|
|
1390
|
-
}
|
|
1391
|
-
initialize() {
|
|
1392
|
-
this._docViewModelManagerService.currentDocViewModel$.subscribe((r) => {
|
|
1393
|
-
r != null && this._setCurrent(r);
|
|
1394
|
-
});
|
|
1395
|
-
}
|
|
1396
|
-
dispose() {
|
|
1397
|
-
this._currentSkeletonBefore$.complete(), this._currentSkeleton$.complete(), this._docSkeletonMap = /* @__PURE__ */ new Map();
|
|
1398
|
-
}
|
|
1399
|
-
getCurrent() {
|
|
1400
|
-
return this.getSkeletonByUnitId(this._currentSkeletonUnitId);
|
|
1401
|
-
}
|
|
1402
|
-
makeDirtyCurrent(r = !0) {
|
|
1403
|
-
this.makeDirty(this._currentSkeletonUnitId, r);
|
|
1404
|
-
}
|
|
1405
|
-
makeDirty(r, e = !0) {
|
|
1406
|
-
const t = this.getSkeletonByUnitId(r);
|
|
1407
|
-
t != null && (t.dirty = e);
|
|
1408
|
-
}
|
|
1409
|
-
_setCurrent(r) {
|
|
1410
|
-
const { unitId: e } = r;
|
|
1411
|
-
if (this._docSkeletonMap.has(e)) {
|
|
1412
|
-
const t = this.getSkeletonByUnitId(e);
|
|
1413
|
-
t.skeleton.calculate(), t.dirty = !0;
|
|
1414
|
-
} else {
|
|
1415
|
-
const t = this._buildSkeleton(r.docViewModel);
|
|
1416
|
-
t.calculate(), this._docSkeletonMap.set(e, {
|
|
1417
|
-
unitId: e,
|
|
1418
|
-
skeleton: t,
|
|
1419
|
-
dirty: !1
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
|
-
return this._currentSkeletonUnitId = e, this._currentSkeletonBefore$.next(this.getCurrent()), this._currentSkeleton$.next(this.getCurrent()), this.getCurrent();
|
|
1423
|
-
}
|
|
1424
|
-
getSkeletonByUnitId(r) {
|
|
1425
|
-
return this._docSkeletonMap.get(r);
|
|
1426
|
-
}
|
|
1427
|
-
_buildSkeleton(r) {
|
|
1428
|
-
return Qt.create(r, this._localeService);
|
|
1429
|
-
}
|
|
1430
|
-
};
|
|
1431
|
-
A = Gn([
|
|
1432
|
-
Rt(0, b(xt)),
|
|
1433
|
-
Rt(1, b(ee))
|
|
1434
|
-
], A);
|
|
1435
|
-
var Xn = Object.defineProperty, qn = Object.getOwnPropertyDescriptor, Yn = (r, e, t, n) => {
|
|
1436
|
-
for (var s = n > 1 ? void 0 : n ? qn(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
1437
|
-
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
1438
|
-
return n && s && Xn(e, t, s), s;
|
|
1439
|
-
}, _e = (r, e) => (t, n) => e(t, n, r);
|
|
1440
|
-
let Re = class extends w {
|
|
1441
|
-
constructor(r, e, t, n) {
|
|
1442
|
-
super(), this._docSkeletonManagerService = r, this._currentUniverService = e, this._textSelectionRenderManager = t, this._commandService = n, this._initialize(), this._commandExecutedListener();
|
|
1443
|
-
}
|
|
1444
|
-
_initialize() {
|
|
1445
|
-
}
|
|
1446
|
-
_commandExecutedListener() {
|
|
1447
|
-
const r = [$e.id, Be.id];
|
|
1448
|
-
this.disposeWithMe(
|
|
1449
|
-
this._commandService.onCommandExecuted((e) => {
|
|
1450
|
-
if (r.includes(e.id))
|
|
1451
|
-
switch (e.id) {
|
|
1452
|
-
case $e.id:
|
|
1453
|
-
this._handleDeleteLeft();
|
|
1454
|
-
break;
|
|
1455
|
-
case Be.id:
|
|
1456
|
-
this._handleDeleteRight();
|
|
1457
|
-
break;
|
|
1458
|
-
default:
|
|
1459
|
-
throw new Error("Unknown command");
|
|
1460
|
-
}
|
|
1461
|
-
})
|
|
1462
|
-
);
|
|
1463
|
-
}
|
|
1464
|
-
// Use BACKSPACE to delete left.
|
|
1465
|
-
_handleDeleteLeft() {
|
|
1466
|
-
var u;
|
|
1467
|
-
const r = this._textSelectionRenderManager.getActiveRange(), e = (u = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : u.skeleton;
|
|
1468
|
-
if (r == null || e == null)
|
|
1469
|
-
return;
|
|
1470
|
-
const t = this._currentUniverService.getCurrentUniverDocInstance(), { startOffset: n, collapsed: s, segmentId: i, style: o } = r;
|
|
1471
|
-
if (n === 0 && s)
|
|
1472
|
-
return;
|
|
1473
|
-
const a = e.findNodeByCharIndex(n), c = lt(a), l = en(a, t.body);
|
|
1474
|
-
let d = n;
|
|
1475
|
-
const f = e.findNodeByCharIndex(n - 1);
|
|
1476
|
-
if (tn(a) && f !== a && (c === !0 || l === !0)) {
|
|
1477
|
-
const g = nn(a, t.body);
|
|
1478
|
-
if (g == null)
|
|
1479
|
-
return;
|
|
1480
|
-
const p = g == null ? void 0 : g.startIndex, m = { startIndex: 0 }, v = g.paragraphStyle;
|
|
1481
|
-
if (c === !0) {
|
|
1482
|
-
const y = g.paragraphStyle;
|
|
1483
|
-
y && (m.paragraphStyle = y);
|
|
1484
|
-
} else if (l === !0) {
|
|
1485
|
-
const y = g.bullet;
|
|
1486
|
-
y && (m.bullet = y), v != null && (m.paragraphStyle = { ...v }, delete m.paragraphStyle.hanging, delete m.paragraphStyle.indentStart);
|
|
1487
|
-
}
|
|
1488
|
-
const M = [
|
|
1489
|
-
{
|
|
1490
|
-
startOffset: d,
|
|
1491
|
-
endOffset: d,
|
|
1492
|
-
collapsed: !0,
|
|
1493
|
-
style: o
|
|
1494
|
-
}
|
|
1495
|
-
];
|
|
1496
|
-
this._commandService.executeCommand(yt.id, {
|
|
1497
|
-
unitId: t.getUnitId(),
|
|
1498
|
-
updateBody: {
|
|
1499
|
-
dataStream: "",
|
|
1500
|
-
paragraphs: [{ ...m }]
|
|
1501
|
-
},
|
|
1502
|
-
range: {
|
|
1503
|
-
startOffset: p,
|
|
1504
|
-
endOffset: p + 1,
|
|
1505
|
-
collapsed: !1
|
|
1506
|
-
},
|
|
1507
|
-
textRanges: M,
|
|
1508
|
-
coverType: Vt.REPLACE,
|
|
1509
|
-
segmentId: i
|
|
1510
|
-
});
|
|
1511
|
-
} else {
|
|
1512
|
-
const { endNodePosition: g } = r;
|
|
1513
|
-
if (g != null) {
|
|
1514
|
-
const p = e.findSpanByPosition(g);
|
|
1515
|
-
lt(p) && !rn(a, p) && (r.endOffset -= 1);
|
|
1516
|
-
}
|
|
1517
|
-
if (s === !0) {
|
|
1518
|
-
d -= f.count;
|
|
1519
|
-
const p = [
|
|
1520
|
-
{
|
|
1521
|
-
startOffset: d,
|
|
1522
|
-
endOffset: d,
|
|
1523
|
-
collapsed: !0,
|
|
1524
|
-
style: o
|
|
1525
|
-
}
|
|
1526
|
-
];
|
|
1527
|
-
this._commandService.executeCommand(tt.id, {
|
|
1528
|
-
unitId: t.getUnitId(),
|
|
1529
|
-
range: r,
|
|
1530
|
-
segmentId: i,
|
|
1531
|
-
direction: et.LEFT,
|
|
1532
|
-
len: f.count,
|
|
1533
|
-
textRanges: p
|
|
1534
|
-
});
|
|
1535
|
-
} else {
|
|
1536
|
-
const p = this._getTextRangesWhenDelete();
|
|
1537
|
-
this._commandService.executeCommand(ze.id, {
|
|
1538
|
-
segmentId: i,
|
|
1539
|
-
textRanges: p
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
e == null || e.calculate();
|
|
1544
|
-
}
|
|
1545
|
-
// Use DELETE to delete right.
|
|
1546
|
-
_handleDeleteRight() {
|
|
1547
|
-
var a;
|
|
1548
|
-
const r = this._textSelectionRenderManager.getActiveRange(), e = (a = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : a.skeleton;
|
|
1549
|
-
if (r == null || e == null)
|
|
1550
|
-
return;
|
|
1551
|
-
const t = this._currentUniverService.getCurrentUniverDocInstance(), { startOffset: n, collapsed: s, segmentId: i, style: o } = r;
|
|
1552
|
-
if (!(n === t.getBody().dataStream.length - 2 && s)) {
|
|
1553
|
-
if (s === !0) {
|
|
1554
|
-
const c = [
|
|
1555
|
-
{
|
|
1556
|
-
startOffset: n,
|
|
1557
|
-
endOffset: n,
|
|
1558
|
-
collapsed: !0,
|
|
1559
|
-
style: o
|
|
1560
|
-
}
|
|
1561
|
-
], l = e.findNodeByCharIndex(n);
|
|
1562
|
-
this._commandService.executeCommand(tt.id, {
|
|
1563
|
-
unitId: t.getUnitId(),
|
|
1564
|
-
range: r,
|
|
1565
|
-
segmentId: i,
|
|
1566
|
-
direction: et.RIGHT,
|
|
1567
|
-
textRanges: c,
|
|
1568
|
-
len: l.count
|
|
1569
|
-
});
|
|
1570
|
-
} else {
|
|
1571
|
-
const c = this._getTextRangesWhenDelete();
|
|
1572
|
-
this._commandService.executeCommand(ze.id, {
|
|
1573
|
-
segmentId: i,
|
|
1574
|
-
textRanges: c
|
|
1575
|
-
});
|
|
1576
|
-
}
|
|
1577
|
-
e == null || e.calculate();
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
// get cursor position when BACKSPACE/DELETE excuse the CutContentCommand.
|
|
1581
|
-
_getTextRangesWhenDelete() {
|
|
1582
|
-
const r = this._textSelectionRenderManager.getActiveRange(), e = this._textSelectionRenderManager.getAllTextRanges();
|
|
1583
|
-
let t = r.endOffset;
|
|
1584
|
-
for (const s of e) {
|
|
1585
|
-
const { startOffset: i, endOffset: o } = s;
|
|
1586
|
-
i == null || o == null || o <= r.endOffset && (t -= o - i);
|
|
1587
|
-
}
|
|
1588
|
-
return [
|
|
1589
|
-
{
|
|
1590
|
-
startOffset: t,
|
|
1591
|
-
endOffset: t,
|
|
1592
|
-
collapsed: !0,
|
|
1593
|
-
style: r.style
|
|
1594
|
-
}
|
|
1595
|
-
];
|
|
1596
|
-
}
|
|
1597
|
-
};
|
|
1598
|
-
Re = Yn([
|
|
1599
|
-
U(L.Rendered, Re),
|
|
1600
|
-
_e(0, b(A)),
|
|
1601
|
-
_e(1, I),
|
|
1602
|
-
_e(2, V),
|
|
1603
|
-
_e(3, D)
|
|
1604
|
-
], Re);
|
|
1605
|
-
var Zn = Object.defineProperty, Kn = Object.getOwnPropertyDescriptor, Jn = (r, e, t, n) => {
|
|
1606
|
-
for (var s = n > 1 ? void 0 : n ? Kn(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
1607
|
-
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
1608
|
-
return n && s && Zn(e, t, s), s;
|
|
1609
|
-
}, Ye = (r, e) => (t, n) => e(t, n, r);
|
|
1610
|
-
let Ie = class extends w {
|
|
1611
|
-
constructor(r, e, t) {
|
|
1612
|
-
super(), this._docSkeletonManagerService = r, this._renderManagerService = e, this._commandService = t, this._initialRenderRefresh(), this._commandExecutedListener();
|
|
1802
|
+
Me = dr([
|
|
1803
|
+
V(F.Rendered, Me),
|
|
1804
|
+
ne(0, Ht),
|
|
1805
|
+
ne(1, x),
|
|
1806
|
+
ne(2, O),
|
|
1807
|
+
ne(3, Vt),
|
|
1808
|
+
ne(4, U(P)),
|
|
1809
|
+
ne(5, Gt)
|
|
1810
|
+
], Me);
|
|
1811
|
+
var ur = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, pr = (n, e, t, r) => {
|
|
1812
|
+
for (var s = r > 1 ? void 0 : r ? hr(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
1813
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1814
|
+
return r && s && ur(e, t, s), s;
|
|
1815
|
+
}, ze = (n, e) => (t, r) => e(t, r, n);
|
|
1816
|
+
let Ce = class extends Ze {
|
|
1817
|
+
constructor(n, e, t) {
|
|
1818
|
+
super(), this._docSkeletonManagerService = n, this._renderManagerService = e, this._commandService = t, this._initialRenderRefresh(), this._commandExecutedListener();
|
|
1613
1819
|
}
|
|
1614
1820
|
_initialRenderRefresh() {
|
|
1615
|
-
this._docSkeletonManagerService.currentSkeletonBefore$.subscribe((
|
|
1616
|
-
if (r == null)
|
|
1617
|
-
return;
|
|
1618
|
-
const { skeleton: e, unitId: t } = r, n = this._renderManagerService.getRenderById(t);
|
|
1821
|
+
this._docSkeletonManagerService.currentSkeletonBefore$.pipe(bt(this.dispose$)).subscribe((n) => {
|
|
1619
1822
|
if (n == null)
|
|
1620
1823
|
return;
|
|
1621
|
-
const {
|
|
1622
|
-
|
|
1824
|
+
const { skeleton: e, unitId: t } = n, r = this._renderManagerService.getRenderById(t);
|
|
1825
|
+
if (r == null)
|
|
1826
|
+
return;
|
|
1827
|
+
const { mainComponent: s } = r;
|
|
1828
|
+
s.changeSkeleton(e), this._recalculateSizeBySkeleton(r, e);
|
|
1623
1829
|
});
|
|
1624
1830
|
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
// const { width: docsWidth, height: docsHeight, pageMarginLeft, pageMarginTop } = docsComponent;
|
|
1630
|
-
// if (parent == null || docsWidth === Infinity || docsHeight === Infinity) {
|
|
1631
|
-
// return;
|
|
1632
|
-
// }
|
|
1633
|
-
// const { width: engineWidth, height: engineHeight } = parent;
|
|
1634
|
-
// let docsLeft = 0;
|
|
1635
|
-
// let docsTop = 0;
|
|
1636
|
-
// let sceneWidth = 0;
|
|
1637
|
-
// let sceneHeight = 0;
|
|
1638
|
-
// if (engineWidth > docsWidth) {
|
|
1639
|
-
// docsLeft = engineWidth / 2 - docsWidth / 2;
|
|
1640
|
-
// sceneWidth = engineWidth - 34;
|
|
1641
|
-
// } else {
|
|
1642
|
-
// docsLeft = pageMarginLeft;
|
|
1643
|
-
// sceneWidth = docsWidth + pageMarginLeft * 2;
|
|
1644
|
-
// }
|
|
1645
|
-
// if (engineHeight > docsHeight) {
|
|
1646
|
-
// docsTop = engineHeight / 2 - docsHeight / 2;
|
|
1647
|
-
// sceneHeight = engineHeight - 34;
|
|
1648
|
-
// } else {
|
|
1649
|
-
// docsTop = pageMarginTop;
|
|
1650
|
-
// sceneHeight = docsHeight + pageMarginTop * 2;
|
|
1651
|
-
// }
|
|
1652
|
-
// // this.docsLeft = docsLeft;
|
|
1653
|
-
// // this.docsTop = docsTop;
|
|
1654
|
-
// scene.resize(sceneWidth, sceneHeight + 200);
|
|
1655
|
-
// docsComponent.translate(docsLeft, docsTop);
|
|
1656
|
-
// return this;
|
|
1657
|
-
// }
|
|
1658
|
-
_recalculateSizeBySkeleton(r, e) {
|
|
1659
|
-
var a;
|
|
1660
|
-
const { mainComponent: t } = r, n = t, s = (a = e.getSkeletonData()) == null ? void 0 : a.pages;
|
|
1661
|
-
if (s == null)
|
|
1831
|
+
_recalculateSizeBySkeleton(n, e) {
|
|
1832
|
+
var d;
|
|
1833
|
+
const { mainComponent: t, scene: r } = n, s = t, i = (d = e.getSkeletonData()) == null ? void 0 : d.pages;
|
|
1834
|
+
if (i == null)
|
|
1662
1835
|
return;
|
|
1663
|
-
let
|
|
1664
|
-
for (let
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1836
|
+
let o = 0, a = 0;
|
|
1837
|
+
for (let l = 0, h = i.length; l < h; l++) {
|
|
1838
|
+
const p = i[l], { pageWidth: u, pageHeight: g } = p;
|
|
1839
|
+
s.pageLayoutType === ot.VERTICAL ? (a += g, a += s.pageMarginTop, l === h - 1 && (a += s.pageMarginTop), o = Math.max(o, u)) : s.pageLayoutType === ot.HORIZONTAL && (o += u, l !== h - 1 && (o += s.pageMarginLeft), a = Math.max(a, g));
|
|
1667
1840
|
}
|
|
1668
|
-
n.resize(
|
|
1841
|
+
s.resize(o, a), [K, J].includes(n.unitId) || r.resize(o, a);
|
|
1669
1842
|
}
|
|
1670
1843
|
_commandExecutedListener() {
|
|
1671
|
-
const
|
|
1844
|
+
const n = [_.id], e = [K, J];
|
|
1672
1845
|
this.disposeWithMe(
|
|
1673
1846
|
this._commandService.onCommandExecuted((t) => {
|
|
1674
|
-
var
|
|
1675
|
-
if (
|
|
1847
|
+
var r;
|
|
1848
|
+
if (n.includes(t.id)) {
|
|
1676
1849
|
const s = t.params, { unitId: i } = s, o = this._docSkeletonManagerService.getSkeletonByUnitId(i);
|
|
1677
1850
|
if (o == null)
|
|
1678
1851
|
return;
|
|
@@ -1680,7 +1853,7 @@ let Ie = class extends w {
|
|
|
1680
1853
|
if (c == null)
|
|
1681
1854
|
return;
|
|
1682
1855
|
if (a.calculate(), e.includes(i)) {
|
|
1683
|
-
(
|
|
1856
|
+
(r = c.mainComponent) == null || r.makeDirty();
|
|
1684
1857
|
return;
|
|
1685
1858
|
}
|
|
1686
1859
|
this._recalculateSizeBySkeleton(c, a);
|
|
@@ -1689,23 +1862,23 @@ let Ie = class extends w {
|
|
|
1689
1862
|
);
|
|
1690
1863
|
}
|
|
1691
1864
|
};
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
],
|
|
1698
|
-
var
|
|
1699
|
-
for (var s =
|
|
1700
|
-
(o =
|
|
1701
|
-
return
|
|
1702
|
-
}, oe = (
|
|
1703
|
-
let
|
|
1704
|
-
constructor(e, t,
|
|
1865
|
+
Ce = pr([
|
|
1866
|
+
V(F.Rendered, Ce),
|
|
1867
|
+
ze(0, U(A)),
|
|
1868
|
+
ze(1, G),
|
|
1869
|
+
ze(2, x)
|
|
1870
|
+
], Ce);
|
|
1871
|
+
var gr = Object.defineProperty, mr = Object.getOwnPropertyDescriptor, fr = (n, e, t, r) => {
|
|
1872
|
+
for (var s = r > 1 ? void 0 : r ? mr(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
1873
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1874
|
+
return r && s && gr(e, t, s), s;
|
|
1875
|
+
}, oe = (n, e) => (t, r) => e(t, r, n);
|
|
1876
|
+
let Re = class extends W {
|
|
1877
|
+
constructor(e, t, r, s, i) {
|
|
1705
1878
|
super();
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService =
|
|
1879
|
+
S(this, "_liquid", new sn());
|
|
1880
|
+
S(this, "_pageMarginCache", /* @__PURE__ */ new Map());
|
|
1881
|
+
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService = r, this._commandService = s, this._floatingObjectManagerService = i, this._initialize(), this._commandExecutedListener();
|
|
1709
1882
|
}
|
|
1710
1883
|
_initialize() {
|
|
1711
1884
|
this._initialRenderRefresh(), this._updateOnPluginChange();
|
|
@@ -1715,17 +1888,17 @@ let xe = class extends w {
|
|
|
1715
1888
|
const t = this._docSkeletonManagerService.getCurrent();
|
|
1716
1889
|
if (t == null)
|
|
1717
1890
|
return;
|
|
1718
|
-
const { unitId:
|
|
1891
|
+
const { unitId: r, skeleton: s } = t, i = this._renderManagerService.getRenderById(r);
|
|
1719
1892
|
if (i == null)
|
|
1720
1893
|
return;
|
|
1721
|
-
const { mainComponent: o, components: a, scene: c } = i,
|
|
1722
|
-
e.forEach((
|
|
1723
|
-
const { unitId: u, subComponentId: g, floatingObjectId:
|
|
1724
|
-
s == null || s.getViewModel().getDataModel().updateDrawing(
|
|
1725
|
-
left: v -
|
|
1726
|
-
top: M -
|
|
1727
|
-
height:
|
|
1728
|
-
width:
|
|
1894
|
+
const { mainComponent: o, components: a, scene: c } = i, d = o, { left: l, top: h } = d;
|
|
1895
|
+
e.forEach((p) => {
|
|
1896
|
+
const { unitId: u, subComponentId: g, floatingObjectId: m, floatingObject: f } = p, { left: v = 0, top: M = 0, width: T = 0, height: y = 0, angle: C, flipX: E, flipY: L, skewX: B, skewY: k } = f, I = this._pageMarginCache.get(m), X = (I == null ? void 0 : I.marginLeft) || 0, z = (I == null ? void 0 : I.marginTop) || 0;
|
|
1897
|
+
s == null || s.getViewModel().getDataModel().updateDrawing(m, {
|
|
1898
|
+
left: v - l - X,
|
|
1899
|
+
top: M - h - z,
|
|
1900
|
+
height: y,
|
|
1901
|
+
width: T
|
|
1729
1902
|
});
|
|
1730
1903
|
}), s == null || s.calculate(), o == null || o.makeDirty();
|
|
1731
1904
|
});
|
|
@@ -1734,92 +1907,92 @@ let xe = class extends w {
|
|
|
1734
1907
|
this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
|
|
1735
1908
|
if (e == null)
|
|
1736
1909
|
return;
|
|
1737
|
-
const { skeleton: t, unitId:
|
|
1910
|
+
const { skeleton: t, unitId: r } = e, s = this._renderManagerService.getRenderById(r);
|
|
1738
1911
|
if (s == null)
|
|
1739
1912
|
return;
|
|
1740
1913
|
const { mainComponent: i } = s;
|
|
1741
|
-
i.changeSkeleton(t), this._refreshFloatingObject(
|
|
1914
|
+
i.changeSkeleton(t), this._refreshFloatingObject(r, t, s);
|
|
1742
1915
|
});
|
|
1743
1916
|
}
|
|
1744
1917
|
_commandExecutedListener() {
|
|
1745
|
-
const e = [
|
|
1918
|
+
const e = [_.id, Z.id], t = [K, J];
|
|
1746
1919
|
this.disposeWithMe(
|
|
1747
|
-
this._commandService.onCommandExecuted((
|
|
1920
|
+
this._commandService.onCommandExecuted((r) => {
|
|
1748
1921
|
var s;
|
|
1749
|
-
if (e.includes(
|
|
1750
|
-
const i =
|
|
1922
|
+
if (e.includes(r.id)) {
|
|
1923
|
+
const i = r.params, { unitId: o } = i, a = this._docSkeletonManagerService.getCurrent();
|
|
1751
1924
|
if (a == null)
|
|
1752
1925
|
return;
|
|
1753
|
-
const { unitId: c, skeleton:
|
|
1926
|
+
const { unitId: c, skeleton: d } = a;
|
|
1754
1927
|
if (o !== c)
|
|
1755
1928
|
return;
|
|
1756
|
-
const
|
|
1757
|
-
if (
|
|
1929
|
+
const l = this._renderManagerService.getRenderById(c);
|
|
1930
|
+
if (l == null)
|
|
1758
1931
|
return;
|
|
1759
1932
|
if (t.includes(c)) {
|
|
1760
|
-
(s =
|
|
1933
|
+
(s = l.mainComponent) == null || s.makeDirty();
|
|
1761
1934
|
return;
|
|
1762
1935
|
}
|
|
1763
|
-
this._refreshFloatingObject(c,
|
|
1936
|
+
this._refreshFloatingObject(c, d, l);
|
|
1764
1937
|
}
|
|
1765
1938
|
})
|
|
1766
1939
|
);
|
|
1767
1940
|
}
|
|
1768
|
-
_refreshFloatingObject(e, t,
|
|
1769
|
-
const s = t == null ? void 0 : t.getSkeletonData(), { mainComponent: i, scene: o } =
|
|
1941
|
+
_refreshFloatingObject(e, t, r) {
|
|
1942
|
+
const s = t == null ? void 0 : t.getSkeletonData(), { mainComponent: i, scene: o } = r, a = i;
|
|
1770
1943
|
if (!s)
|
|
1771
1944
|
return;
|
|
1772
|
-
const { left: c, top:
|
|
1945
|
+
const { left: c, top: d, pageLayoutType: l, pageMarginLeft: h, pageMarginTop: p } = a, { pages: u } = s, g = [];
|
|
1773
1946
|
o.getAncestorScale(), this._liquid.reset(), this._pageMarginCache.clear();
|
|
1774
|
-
for (let
|
|
1775
|
-
const v = u[
|
|
1776
|
-
this._liquid.translatePagePadding(v), M.forEach((
|
|
1777
|
-
const { aLeft:
|
|
1947
|
+
for (let m = 0, f = u.length; m < f; m++) {
|
|
1948
|
+
const v = u[m], { skeDrawings: M, marginLeft: T, marginTop: y } = v;
|
|
1949
|
+
this._liquid.translatePagePadding(v), M.forEach((C) => {
|
|
1950
|
+
const { aLeft: E, aTop: L, height: B, width: k, objectId: I } = C;
|
|
1778
1951
|
g.push({
|
|
1779
1952
|
unitId: e,
|
|
1780
|
-
subComponentId:
|
|
1781
|
-
floatingObjectId:
|
|
1953
|
+
subComponentId: Xt,
|
|
1954
|
+
floatingObjectId: I,
|
|
1782
1955
|
floatingObject: {
|
|
1783
|
-
left:
|
|
1784
|
-
top:
|
|
1785
|
-
width:
|
|
1786
|
-
height:
|
|
1956
|
+
left: E + c + this._liquid.x,
|
|
1957
|
+
top: L + d + this._liquid.y,
|
|
1958
|
+
width: k,
|
|
1959
|
+
height: B
|
|
1787
1960
|
}
|
|
1788
|
-
}), this._pageMarginCache.set(
|
|
1961
|
+
}), this._pageMarginCache.set(I, {
|
|
1789
1962
|
marginLeft: this._liquid.x,
|
|
1790
1963
|
marginTop: this._liquid.y
|
|
1791
1964
|
});
|
|
1792
|
-
}), this._liquid.translatePage(v,
|
|
1965
|
+
}), this._liquid.translatePage(v, l, h, p);
|
|
1793
1966
|
}
|
|
1794
1967
|
this._floatingObjectManagerService.BatchAddOrUpdate(g);
|
|
1795
1968
|
}
|
|
1796
1969
|
};
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
oe(0,
|
|
1800
|
-
oe(1,
|
|
1801
|
-
oe(2,
|
|
1802
|
-
oe(3,
|
|
1803
|
-
oe(4,
|
|
1804
|
-
],
|
|
1805
|
-
var
|
|
1806
|
-
for (var s =
|
|
1807
|
-
(o =
|
|
1808
|
-
return
|
|
1809
|
-
},
|
|
1810
|
-
let
|
|
1811
|
-
constructor(e, t,
|
|
1970
|
+
Re = fr([
|
|
1971
|
+
V(F.Steady, Re),
|
|
1972
|
+
oe(0, U(A)),
|
|
1973
|
+
oe(1, O),
|
|
1974
|
+
oe(2, G),
|
|
1975
|
+
oe(3, x),
|
|
1976
|
+
oe(4, qt)
|
|
1977
|
+
], Re);
|
|
1978
|
+
var _r = Object.defineProperty, Sr = Object.getOwnPropertyDescriptor, vr = (n, e, t, r) => {
|
|
1979
|
+
for (var s = r > 1 ? void 0 : r ? Sr(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
1980
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1981
|
+
return r && s && _r(e, t, s), s;
|
|
1982
|
+
}, re = (n, e) => (t, r) => e(t, r, n);
|
|
1983
|
+
let Ie = class extends W {
|
|
1984
|
+
constructor(e, t, r, s, i, o) {
|
|
1812
1985
|
super();
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService =
|
|
1986
|
+
S(this, "_previousIMEContent", "");
|
|
1987
|
+
S(this, "_previousIMERange");
|
|
1988
|
+
S(this, "_onStartSubscription");
|
|
1989
|
+
S(this, "_onUpdateSubscription");
|
|
1990
|
+
S(this, "_onEndSubscription");
|
|
1991
|
+
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService = r, this._textSelectionRenderManager = s, this._imeInputManagerService = i, this._commandService = o, this._initialize();
|
|
1819
1992
|
}
|
|
1820
1993
|
dispose() {
|
|
1821
|
-
var e, t,
|
|
1822
|
-
(e = this._onStartSubscription) == null || e.unsubscribe(), (t = this._onUpdateSubscription) == null || t.unsubscribe(), (
|
|
1994
|
+
var e, t, r;
|
|
1995
|
+
(e = this._onStartSubscription) == null || e.unsubscribe(), (t = this._onUpdateSubscription) == null || t.unsubscribe(), (r = this._onEndSubscription) == null || r.unsubscribe();
|
|
1823
1996
|
}
|
|
1824
1997
|
_initialize() {
|
|
1825
1998
|
this._initialOnCompositionstart(), this._initialOnCompositionUpdate(), this._initialOnCompositionend();
|
|
@@ -1829,7 +2002,7 @@ let Oe = class extends w {
|
|
|
1829
2002
|
if (e == null)
|
|
1830
2003
|
return;
|
|
1831
2004
|
const { activeRange: t } = e;
|
|
1832
|
-
t != null && (this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(
|
|
2005
|
+
t != null && (this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(H.deepClone(t)), this._previousIMERange = t);
|
|
1833
2006
|
});
|
|
1834
2007
|
}
|
|
1835
2008
|
_initialOnCompositionUpdate() {
|
|
@@ -1844,171 +2017,99 @@ let Oe = class extends w {
|
|
|
1844
2017
|
}
|
|
1845
2018
|
async _updateContent(e, t) {
|
|
1846
2019
|
var g;
|
|
1847
|
-
const
|
|
1848
|
-
if (this._previousIMERange == null || e == null ||
|
|
2020
|
+
const r = (g = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : g.skeleton;
|
|
2021
|
+
if (this._previousIMERange == null || e == null || r == null)
|
|
1849
2022
|
return;
|
|
1850
|
-
const s = this._currentUniverService.getCurrentUniverDocInstance(), { event: i, activeRange: o } = e, { startOffset: a, segmentId: c, style:
|
|
1851
|
-
if (
|
|
2023
|
+
const s = this._currentUniverService.getCurrentUniverDocInstance(), { event: i, activeRange: o } = e, { startOffset: a, segmentId: c, style: d } = this._previousIMERange;
|
|
2024
|
+
if (r == null || o == null)
|
|
1852
2025
|
return;
|
|
1853
|
-
const
|
|
1854
|
-
if (
|
|
2026
|
+
const h = i.data;
|
|
2027
|
+
if (h === this._previousIMEContent && t)
|
|
1855
2028
|
return;
|
|
1856
|
-
const
|
|
2029
|
+
const p = h.length, u = [
|
|
1857
2030
|
{
|
|
1858
|
-
startOffset: a +
|
|
1859
|
-
endOffset: a +
|
|
1860
|
-
|
|
1861
|
-
style: l
|
|
2031
|
+
startOffset: a + p,
|
|
2032
|
+
endOffset: a + p,
|
|
2033
|
+
style: d
|
|
1862
2034
|
}
|
|
1863
2035
|
];
|
|
1864
|
-
await this._commandService.executeCommand(
|
|
2036
|
+
await this._commandService.executeCommand(Lt.id, {
|
|
1865
2037
|
unitId: s.getUnitId(),
|
|
1866
|
-
newText:
|
|
2038
|
+
newText: h,
|
|
1867
2039
|
oldTextLen: this._previousIMEContent.length,
|
|
1868
2040
|
range: this._previousIMERange,
|
|
1869
2041
|
textRanges: u,
|
|
1870
2042
|
isCompositionEnd: !t,
|
|
1871
2043
|
segmentId: c
|
|
1872
|
-
}),
|
|
2044
|
+
}), r.calculate(), t ? (this._previousIMERange.collapsed || (this._previousIMERange.collapsed = !0), this._previousIMEContent = h) : this._resetIME();
|
|
1873
2045
|
}
|
|
1874
2046
|
_resetIME() {
|
|
1875
2047
|
this._previousIMEContent = "", this._previousIMERange = null, this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(null);
|
|
1876
2048
|
}
|
|
1877
2049
|
_getDocObject() {
|
|
1878
|
-
return
|
|
2050
|
+
return Le(this._currentUniverService, this._renderManagerService);
|
|
1879
2051
|
}
|
|
1880
2052
|
};
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
var
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
super(), this._currentUniverService = r, this._textSelectionRenderManager = e, this._textSelectionManagerService = t, this._commandService = n, this._commandExecutedListener();
|
|
2053
|
+
Ie = vr([
|
|
2054
|
+
V(F.Rendered, Ie),
|
|
2055
|
+
re(0, U(A)),
|
|
2056
|
+
re(1, O),
|
|
2057
|
+
re(2, G),
|
|
2058
|
+
re(3, fe),
|
|
2059
|
+
re(4, U(tt)),
|
|
2060
|
+
re(5, x)
|
|
2061
|
+
], Ie);
|
|
2062
|
+
var Mr = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, Rr = (n, e, t, r) => {
|
|
2063
|
+
for (var s = r > 1 ? void 0 : r ? Cr(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
2064
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
2065
|
+
return r && s && Mr(e, t, s), s;
|
|
2066
|
+
}, Mt = (n, e) => (t, r) => e(t, r, n);
|
|
2067
|
+
let xe = class extends W {
|
|
2068
|
+
constructor(n, e) {
|
|
2069
|
+
super(), this._textSelectionManagerService = n, this._commandService = e, this._commandExecutedListener();
|
|
1899
2070
|
}
|
|
1900
2071
|
_commandExecutedListener() {
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2072
|
+
const n = [
|
|
2073
|
+
ue.id,
|
|
2074
|
+
Ne.id,
|
|
2075
|
+
$e.id,
|
|
2076
|
+
Be.id,
|
|
2077
|
+
Q.id,
|
|
2078
|
+
ie.id,
|
|
2079
|
+
he.id,
|
|
2080
|
+
pe.id,
|
|
2081
|
+
je.id
|
|
1909
2082
|
];
|
|
1910
2083
|
this.disposeWithMe(
|
|
1911
2084
|
this._commandService.onCommandExecuted((e) => {
|
|
1912
|
-
|
|
2085
|
+
n.includes(e.id) && this._handleInlineFormat(e);
|
|
1913
2086
|
})
|
|
1914
2087
|
);
|
|
1915
2088
|
}
|
|
1916
|
-
_handleInlineFormat(
|
|
1917
|
-
const { segmentId: e } = this.
|
|
1918
|
-
e != null && this._commandService.executeCommand(
|
|
2089
|
+
_handleInlineFormat(n) {
|
|
2090
|
+
const { segmentId: e } = this._textSelectionManagerService.getActiveRange() ?? {};
|
|
2091
|
+
e != null && this._commandService.executeCommand(Nt.id, {
|
|
1919
2092
|
segmentId: e,
|
|
1920
|
-
preCommandId:
|
|
1921
|
-
...
|
|
1922
|
-
});
|
|
1923
|
-
}
|
|
1924
|
-
};
|
|
1925
|
-
ye = ar([
|
|
1926
|
-
U(L.Rendered, ye),
|
|
1927
|
-
Se(0, I),
|
|
1928
|
-
Se(1, V),
|
|
1929
|
-
Se(2, b(P)),
|
|
1930
|
-
Se(3, D)
|
|
1931
|
-
], ye);
|
|
1932
|
-
var cr = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, dr = (r, e, t, n) => {
|
|
1933
|
-
for (var s = n > 1 ? void 0 : n ? lr(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
1934
|
-
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
1935
|
-
return n && s && cr(e, t, s), s;
|
|
1936
|
-
}, Y = (r, e) => (t, n) => e(t, n, r);
|
|
1937
|
-
function ur(r) {
|
|
1938
|
-
const e = [];
|
|
1939
|
-
for (let t = 0, n = r.length; t < n; t++)
|
|
1940
|
-
r[t] === Je.PARAGRAPH && e.push({
|
|
1941
|
-
startIndex: t
|
|
2093
|
+
preCommandId: n.id,
|
|
2094
|
+
...n.params ?? {}
|
|
1942
2095
|
});
|
|
1943
|
-
return e;
|
|
1944
|
-
}
|
|
1945
|
-
let be = class extends w {
|
|
1946
|
-
constructor(e, t, n, s, i, o) {
|
|
1947
|
-
super();
|
|
1948
|
-
_(this, "_onInputSubscription");
|
|
1949
|
-
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService = n, this._textSelectionRenderManager = s, this._textSelectionManagerService = i, this._commandService = o, this._initialize(), this._commandExecutedListener();
|
|
1950
|
-
}
|
|
1951
|
-
dispose() {
|
|
1952
|
-
var e;
|
|
1953
|
-
(e = this._onInputSubscription) == null || e.unsubscribe();
|
|
1954
|
-
}
|
|
1955
|
-
_initialize() {
|
|
1956
|
-
}
|
|
1957
|
-
_commandExecutedListener() {
|
|
1958
|
-
const e = [st.id];
|
|
1959
|
-
this.disposeWithMe(
|
|
1960
|
-
this._commandService.onCommandExecuted((t) => {
|
|
1961
|
-
e.includes(t.id) && this._handleBreakLine();
|
|
1962
|
-
})
|
|
1963
|
-
);
|
|
1964
|
-
}
|
|
1965
|
-
_handleBreakLine() {
|
|
1966
|
-
var l;
|
|
1967
|
-
const e = (l = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : l.skeleton, t = this._textSelectionRenderManager.getActiveRange();
|
|
1968
|
-
if (t == null || e == null)
|
|
1969
|
-
return;
|
|
1970
|
-
const s = this._currentUniverService.getCurrentUniverDocInstance().getUnitId(), { startOffset: i, segmentId: o, style: a } = t, c = [
|
|
1971
|
-
{
|
|
1972
|
-
startOffset: i + 1,
|
|
1973
|
-
endOffset: i + 1,
|
|
1974
|
-
collapsed: !0,
|
|
1975
|
-
style: a
|
|
1976
|
-
}
|
|
1977
|
-
];
|
|
1978
|
-
this._commandService.executeCommand(it.id, {
|
|
1979
|
-
unitId: s,
|
|
1980
|
-
body: {
|
|
1981
|
-
dataStream: Je.PARAGRAPH,
|
|
1982
|
-
paragraphs: ur(Je.PARAGRAPH)
|
|
1983
|
-
},
|
|
1984
|
-
range: t,
|
|
1985
|
-
textRanges: c,
|
|
1986
|
-
segmentId: o
|
|
1987
|
-
}), e == null || e.calculate();
|
|
1988
|
-
}
|
|
1989
|
-
_getDocObject() {
|
|
1990
|
-
return pe(this._currentUniverService, this._renderManagerService);
|
|
1991
2096
|
}
|
|
1992
2097
|
};
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
return n && s && hr(e, t, s), s;
|
|
2006
|
-
}, Z = (r, e) => (t, n) => e(t, n, r);
|
|
2007
|
-
let De = class extends w {
|
|
2008
|
-
constructor(e, t, n, s, i, o) {
|
|
2098
|
+
xe = Rr([
|
|
2099
|
+
V(F.Rendered, xe),
|
|
2100
|
+
Mt(0, U(P)),
|
|
2101
|
+
Mt(1, x)
|
|
2102
|
+
], xe);
|
|
2103
|
+
var Ir = Object.defineProperty, xr = Object.getOwnPropertyDescriptor, Or = (n, e, t, r) => {
|
|
2104
|
+
for (var s = r > 1 ? void 0 : r ? xr(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
2105
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
2106
|
+
return r && s && Ir(e, t, s), s;
|
|
2107
|
+
}, ae = (n, e) => (t, r) => e(t, r, n);
|
|
2108
|
+
let Oe = class extends W {
|
|
2109
|
+
constructor(e, t, r, s, i) {
|
|
2009
2110
|
super();
|
|
2010
|
-
|
|
2011
|
-
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService =
|
|
2111
|
+
S(this, "_onInputSubscription");
|
|
2112
|
+
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService = r, this._textSelectionManagerService = s, this._commandService = i, this._initialize(), this._commandExecutedListener();
|
|
2012
2113
|
}
|
|
2013
2114
|
dispose() {
|
|
2014
2115
|
var e;
|
|
@@ -2017,17 +2118,17 @@ let De = class extends w {
|
|
|
2017
2118
|
_initialize() {
|
|
2018
2119
|
}
|
|
2019
2120
|
_commandExecutedListener() {
|
|
2020
|
-
const e = [
|
|
2121
|
+
const e = [ee.id, te.id];
|
|
2021
2122
|
this.disposeWithMe(
|
|
2022
2123
|
this._commandService.onCommandExecuted((t) => {
|
|
2023
2124
|
if (!e.includes(t.id))
|
|
2024
2125
|
return;
|
|
2025
|
-
const
|
|
2126
|
+
const r = t.params;
|
|
2026
2127
|
switch (t.id) {
|
|
2027
|
-
case
|
|
2028
|
-
return this._handleMoveCursor(
|
|
2029
|
-
case
|
|
2030
|
-
return this._handleShiftMoveSelection(
|
|
2128
|
+
case ee.id:
|
|
2129
|
+
return this._handleMoveCursor(r.direction);
|
|
2130
|
+
case te.id:
|
|
2131
|
+
return this._handleShiftMoveSelection(r.direction);
|
|
2031
2132
|
default:
|
|
2032
2133
|
throw new Error("Unknown command");
|
|
2033
2134
|
}
|
|
@@ -2035,127 +2136,121 @@ let De = class extends w {
|
|
|
2035
2136
|
);
|
|
2036
2137
|
}
|
|
2037
2138
|
_handleShiftMoveSelection(e) {
|
|
2038
|
-
var
|
|
2039
|
-
const t = this.
|
|
2139
|
+
var m;
|
|
2140
|
+
const t = this._textSelectionManagerService.getActiveRange(), r = this._textSelectionManagerService.getSelections(), s = this._currentUniverService.getCurrentUniverDocInstance(), i = (m = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : m.skeleton, o = this._getDocObject();
|
|
2040
2141
|
if (t == null || i == null || o == null)
|
|
2041
2142
|
return;
|
|
2042
|
-
const { startOffset: a, endOffset: c, style:
|
|
2043
|
-
if (
|
|
2044
|
-
let
|
|
2045
|
-
for (const M of
|
|
2046
|
-
|
|
2143
|
+
const { startOffset: a, endOffset: c, style: d, collapsed: l, direction: h } = t;
|
|
2144
|
+
if (r.length > 1) {
|
|
2145
|
+
let f = 1 / 0, v = -1 / 0;
|
|
2146
|
+
for (const M of r)
|
|
2147
|
+
f = Math.min(f, M.startOffset), v = Math.max(v, M.endOffset);
|
|
2047
2148
|
this._textSelectionManagerService.replaceTextRanges([
|
|
2048
2149
|
{
|
|
2049
|
-
startOffset: e ===
|
|
2050
|
-
endOffset: e ===
|
|
2051
|
-
|
|
2052
|
-
style: l
|
|
2150
|
+
startOffset: e === b.LEFT || e === b.UP ? v : f,
|
|
2151
|
+
endOffset: e === b.LEFT || e === b.UP ? f : v,
|
|
2152
|
+
style: d
|
|
2053
2153
|
}
|
|
2054
2154
|
]);
|
|
2055
2155
|
return;
|
|
2056
2156
|
}
|
|
2057
|
-
const
|
|
2058
|
-
let u =
|
|
2157
|
+
const p = l || h === at.FORWARD ? a : c;
|
|
2158
|
+
let u = l || h === at.FORWARD ? c : a;
|
|
2059
2159
|
const g = s.getBody().dataStream.length ?? 1 / 0;
|
|
2060
|
-
if (e ===
|
|
2061
|
-
const
|
|
2062
|
-
u = e ===
|
|
2160
|
+
if (e === b.LEFT || e === b.RIGHT) {
|
|
2161
|
+
const f = i.findNodeByCharIndex(u - 1), v = i.findNodeByCharIndex(u);
|
|
2162
|
+
u = e === b.RIGHT ? u + v.count : u - ((f == null ? void 0 : f.count) ?? 0), u = Math.min(g - 2, Math.max(0, u)), this._textSelectionManagerService.replaceTextRanges([
|
|
2063
2163
|
{
|
|
2064
|
-
startOffset:
|
|
2164
|
+
startOffset: p,
|
|
2065
2165
|
endOffset: u,
|
|
2066
|
-
|
|
2067
|
-
style: l
|
|
2166
|
+
style: d
|
|
2068
2167
|
}
|
|
2069
2168
|
]);
|
|
2070
2169
|
} else {
|
|
2071
|
-
const
|
|
2170
|
+
const f = i.findNodeByCharIndex(u), v = o.document.getOffsetConfig(), M = this._getTopOrBottomPosition(i, f, e === b.DOWN);
|
|
2072
2171
|
if (M == null) {
|
|
2073
|
-
const
|
|
2074
|
-
if (
|
|
2172
|
+
const y = e === b.UP ? 0 : g - 2;
|
|
2173
|
+
if (y === u)
|
|
2075
2174
|
return;
|
|
2076
2175
|
this._textSelectionManagerService.replaceTextRanges([
|
|
2077
2176
|
{
|
|
2078
|
-
startOffset:
|
|
2079
|
-
endOffset:
|
|
2080
|
-
|
|
2081
|
-
style: l
|
|
2177
|
+
startOffset: p,
|
|
2178
|
+
endOffset: y,
|
|
2179
|
+
style: d
|
|
2082
2180
|
}
|
|
2083
2181
|
]);
|
|
2084
2182
|
return;
|
|
2085
2183
|
}
|
|
2086
|
-
const
|
|
2184
|
+
const T = new ct(v, i).getRangePointData(
|
|
2087
2185
|
M,
|
|
2088
2186
|
M
|
|
2089
2187
|
).cursorList[0];
|
|
2090
2188
|
this._textSelectionManagerService.replaceTextRanges([
|
|
2091
2189
|
{
|
|
2092
|
-
startOffset:
|
|
2093
|
-
endOffset:
|
|
2094
|
-
|
|
2095
|
-
style: l
|
|
2190
|
+
startOffset: p,
|
|
2191
|
+
endOffset: T.endOffset,
|
|
2192
|
+
style: d
|
|
2096
2193
|
}
|
|
2097
2194
|
]);
|
|
2098
2195
|
}
|
|
2099
2196
|
}
|
|
2100
2197
|
_handleMoveCursor(e) {
|
|
2101
|
-
var
|
|
2102
|
-
const t = this.
|
|
2103
|
-
if (t == null || i == null || o == null)
|
|
2198
|
+
var p;
|
|
2199
|
+
const t = this._textSelectionManagerService.getActiveRange(), r = this._textSelectionManagerService.getSelections(), s = this._currentUniverService.getCurrentUniverDocInstance(), i = (p = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : p.skeleton, o = this._getDocObject();
|
|
2200
|
+
if (t == null || i == null || o == null || r == null)
|
|
2104
2201
|
return;
|
|
2105
|
-
const { startOffset: a, endOffset: c, style:
|
|
2106
|
-
if (e ===
|
|
2202
|
+
const { startOffset: a, endOffset: c, style: d, collapsed: l } = t, h = s.getBody().dataStream.length ?? 1 / 0;
|
|
2203
|
+
if (e === b.LEFT || e === b.RIGHT) {
|
|
2107
2204
|
let u;
|
|
2108
|
-
if (!t.collapsed ||
|
|
2109
|
-
let g = 1 / 0,
|
|
2110
|
-
for (const
|
|
2111
|
-
g = Math.min(g,
|
|
2112
|
-
u = e ===
|
|
2205
|
+
if (!t.collapsed || r.length > 1) {
|
|
2206
|
+
let g = 1 / 0, m = -1 / 0;
|
|
2207
|
+
for (const f of r)
|
|
2208
|
+
g = Math.min(g, f.startOffset), m = Math.max(m, f.endOffset);
|
|
2209
|
+
u = e === b.LEFT ? g : m;
|
|
2113
2210
|
} else {
|
|
2114
|
-
const g = i.findNodeByCharIndex(a - 1),
|
|
2115
|
-
e ===
|
|
2211
|
+
const g = i.findNodeByCharIndex(a - 1), m = i.findNodeByCharIndex(a);
|
|
2212
|
+
e === b.LEFT ? u = Math.max(0, a - ((g == null ? void 0 : g.count) ?? 0)) : u = Math.min(h - 2, c + m.count);
|
|
2116
2213
|
}
|
|
2117
2214
|
this._textSelectionManagerService.replaceTextRanges([
|
|
2118
2215
|
{
|
|
2119
2216
|
startOffset: u,
|
|
2120
2217
|
endOffset: u,
|
|
2121
|
-
|
|
2122
|
-
style: l
|
|
2218
|
+
style: d
|
|
2123
2219
|
}
|
|
2124
2220
|
]);
|
|
2125
2221
|
} else {
|
|
2126
|
-
const u = i.findNodeByCharIndex(a), g = i.findNodeByCharIndex(c),
|
|
2222
|
+
const u = i.findNodeByCharIndex(a), g = i.findNodeByCharIndex(c), m = o.document.getOffsetConfig(), f = this._getTopOrBottomPosition(
|
|
2127
2223
|
i,
|
|
2128
|
-
e ===
|
|
2129
|
-
e ===
|
|
2224
|
+
e === b.UP ? u : g,
|
|
2225
|
+
e === b.DOWN
|
|
2130
2226
|
);
|
|
2131
|
-
if (
|
|
2227
|
+
if (f == null) {
|
|
2132
2228
|
let M;
|
|
2133
|
-
|
|
2229
|
+
l ? M = e === b.UP ? 0 : h - 2 : M = e === b.UP ? a : c, this._textSelectionManagerService.replaceTextRanges([
|
|
2134
2230
|
{
|
|
2135
2231
|
startOffset: M,
|
|
2136
2232
|
endOffset: M,
|
|
2137
|
-
|
|
2138
|
-
style: l
|
|
2233
|
+
style: d
|
|
2139
2234
|
}
|
|
2140
2235
|
]);
|
|
2141
2236
|
return;
|
|
2142
2237
|
}
|
|
2143
|
-
const v = new
|
|
2144
|
-
|
|
2145
|
-
|
|
2238
|
+
const v = new ct(m, i).getRangePointData(
|
|
2239
|
+
f,
|
|
2240
|
+
f
|
|
2146
2241
|
).cursorList[0];
|
|
2147
2242
|
this._textSelectionManagerService.replaceTextRanges([
|
|
2148
2243
|
{
|
|
2149
2244
|
...v,
|
|
2150
|
-
style:
|
|
2245
|
+
style: d
|
|
2151
2246
|
}
|
|
2152
2247
|
]);
|
|
2153
2248
|
}
|
|
2154
2249
|
}
|
|
2155
|
-
_getTopOrBottomPosition(e, t,
|
|
2250
|
+
_getTopOrBottomPosition(e, t, r) {
|
|
2156
2251
|
if (t == null)
|
|
2157
2252
|
return;
|
|
2158
|
-
const s = this._getSpanLeftOffsetInLine(t), i = this._getNextOrPrevLine(t,
|
|
2253
|
+
const s = this._getSpanLeftOffsetInLine(t), i = this._getNextOrPrevLine(t, r);
|
|
2159
2254
|
if (i == null)
|
|
2160
2255
|
return;
|
|
2161
2256
|
const o = this._matchPositionByLeftOffset(e, i, s);
|
|
@@ -2166,29 +2261,29 @@ let De = class extends w {
|
|
|
2166
2261
|
const t = e.parent;
|
|
2167
2262
|
if (t == null)
|
|
2168
2263
|
return -1 / 0;
|
|
2169
|
-
const
|
|
2170
|
-
return
|
|
2264
|
+
const r = t.left, { left: s } = e;
|
|
2265
|
+
return r + s;
|
|
2171
2266
|
}
|
|
2172
|
-
_matchPositionByLeftOffset(e, t,
|
|
2267
|
+
_matchPositionByLeftOffset(e, t, r) {
|
|
2173
2268
|
const s = {
|
|
2174
2269
|
distance: 1 / 0
|
|
2175
2270
|
};
|
|
2176
2271
|
for (const i of t.divides) {
|
|
2177
2272
|
const o = i.left;
|
|
2178
2273
|
for (const a of i.spanGroup) {
|
|
2179
|
-
const { left: c } = a,
|
|
2180
|
-
|
|
2274
|
+
const { left: c } = a, d = o + c, l = Math.abs(r - d);
|
|
2275
|
+
l < s.distance && (s.span = a, s.distance = l);
|
|
2181
2276
|
}
|
|
2182
2277
|
}
|
|
2183
2278
|
if (s.span != null)
|
|
2184
2279
|
return e.findPositionBySpan(s.span);
|
|
2185
2280
|
}
|
|
2186
2281
|
_getNextOrPrevLine(e, t) {
|
|
2187
|
-
var g,
|
|
2188
|
-
const
|
|
2189
|
-
if (
|
|
2282
|
+
var g, m, f, v, M, T, y, C, E, L, B, k;
|
|
2283
|
+
const r = e.parent;
|
|
2284
|
+
if (r == null)
|
|
2190
2285
|
return;
|
|
2191
|
-
const s =
|
|
2286
|
+
const s = r.parent;
|
|
2192
2287
|
if (s == null)
|
|
2193
2288
|
return;
|
|
2194
2289
|
const i = s.parent;
|
|
@@ -2203,72 +2298,71 @@ let De = class extends w {
|
|
|
2203
2298
|
const c = i.parent;
|
|
2204
2299
|
if (c == null)
|
|
2205
2300
|
return;
|
|
2206
|
-
const
|
|
2207
|
-
if (
|
|
2301
|
+
const d = c.columns.indexOf(i);
|
|
2302
|
+
if (d === -1)
|
|
2208
2303
|
return;
|
|
2209
2304
|
if (t === !0)
|
|
2210
|
-
a = (g = c.columns[
|
|
2305
|
+
a = (g = c.columns[d + 1]) == null ? void 0 : g.lines[0];
|
|
2211
2306
|
else {
|
|
2212
|
-
const
|
|
2213
|
-
a =
|
|
2307
|
+
const I = (f = (m = c.columns) == null ? void 0 : m[d - 1]) == null ? void 0 : f.lines;
|
|
2308
|
+
a = I == null ? void 0 : I[I.length - 1];
|
|
2214
2309
|
}
|
|
2215
2310
|
if (a != null)
|
|
2216
2311
|
return a;
|
|
2217
|
-
const
|
|
2218
|
-
if (
|
|
2312
|
+
const l = c.parent;
|
|
2313
|
+
if (l == null)
|
|
2219
2314
|
return;
|
|
2220
|
-
const
|
|
2221
|
-
if (
|
|
2315
|
+
const h = l.sections.indexOf(c);
|
|
2316
|
+
if (h === -1)
|
|
2222
2317
|
return;
|
|
2223
2318
|
if (t === !0)
|
|
2224
|
-
a = (M = (v =
|
|
2319
|
+
a = (M = (v = l.sections[h - 1]) == null ? void 0 : v.columns[0]) == null ? void 0 : M.lines[0];
|
|
2225
2320
|
else {
|
|
2226
|
-
const
|
|
2227
|
-
a =
|
|
2321
|
+
const I = (y = (T = l.sections) == null ? void 0 : T[h - 1]) == null ? void 0 : y.columns, X = I == null ? void 0 : I[I.length - 1], z = X == null ? void 0 : X.lines;
|
|
2322
|
+
a = z == null ? void 0 : z[z.length - 1];
|
|
2228
2323
|
}
|
|
2229
2324
|
if (a != null)
|
|
2230
2325
|
return a;
|
|
2231
|
-
const
|
|
2232
|
-
if (
|
|
2326
|
+
const p = l.parent;
|
|
2327
|
+
if (p == null)
|
|
2233
2328
|
return;
|
|
2234
|
-
const u =
|
|
2329
|
+
const u = p.pages.indexOf(l);
|
|
2235
2330
|
if (u !== -1) {
|
|
2236
2331
|
if (t === !0)
|
|
2237
|
-
a = (
|
|
2332
|
+
a = (L = (E = (C = p.pages[u + 1]) == null ? void 0 : C.sections[0]) == null ? void 0 : E.columns[0]) == null ? void 0 : L.lines[0];
|
|
2238
2333
|
else {
|
|
2239
|
-
const
|
|
2240
|
-
if (
|
|
2334
|
+
const I = (B = p.pages[u - 1]) == null ? void 0 : B.sections;
|
|
2335
|
+
if (I == null)
|
|
2241
2336
|
return;
|
|
2242
|
-
const
|
|
2243
|
-
a =
|
|
2337
|
+
const X = (k = I[I.length - 1]) == null ? void 0 : k.columns, z = X[X.length - 1], st = z == null ? void 0 : z.lines;
|
|
2338
|
+
a = st[st.length - 1];
|
|
2244
2339
|
}
|
|
2245
2340
|
if (a != null)
|
|
2246
2341
|
return a;
|
|
2247
2342
|
}
|
|
2248
2343
|
}
|
|
2249
2344
|
_getDocObject() {
|
|
2250
|
-
return
|
|
2345
|
+
return Le(this._currentUniverService, this._renderManagerService);
|
|
2251
2346
|
}
|
|
2252
2347
|
};
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
var
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
constructor(e, t, n, s, i, o) {
|
|
2348
|
+
Oe = Or([
|
|
2349
|
+
V(F.Rendered, Oe),
|
|
2350
|
+
ae(0, U(A)),
|
|
2351
|
+
ae(1, O),
|
|
2352
|
+
ae(2, G),
|
|
2353
|
+
ae(3, U(P)),
|
|
2354
|
+
ae(4, x)
|
|
2355
|
+
], Oe);
|
|
2356
|
+
var yr = Object.defineProperty, br = Object.getOwnPropertyDescriptor, Dr = (n, e, t, r) => {
|
|
2357
|
+
for (var s = r > 1 ? void 0 : r ? br(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
2358
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
2359
|
+
return r && s && yr(e, t, s), s;
|
|
2360
|
+
}, ce = (n, e) => (t, r) => e(t, r, n);
|
|
2361
|
+
let ye = class extends W {
|
|
2362
|
+
constructor(e, t, r, s, i) {
|
|
2269
2363
|
super();
|
|
2270
|
-
|
|
2271
|
-
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService =
|
|
2364
|
+
S(this, "_onInputSubscription");
|
|
2365
|
+
this._docSkeletonManagerService = e, this._currentUniverService = t, this._renderManagerService = r, this._textSelectionRenderManager = s, this._commandService = i, this._initialize(), this._commandExecutedListener();
|
|
2272
2366
|
}
|
|
2273
2367
|
dispose() {
|
|
2274
2368
|
var e;
|
|
@@ -2279,174 +2373,142 @@ let Pe = class extends w {
|
|
|
2279
2373
|
}
|
|
2280
2374
|
_initialNormalInput() {
|
|
2281
2375
|
this._onInputSubscription = this._textSelectionRenderManager.onInput$.subscribe(async (e) => {
|
|
2282
|
-
var
|
|
2376
|
+
var g;
|
|
2283
2377
|
if (e == null)
|
|
2284
2378
|
return;
|
|
2285
|
-
const
|
|
2286
|
-
if (
|
|
2379
|
+
const r = this._currentUniverService.getCurrentUniverDocInstance().getUnitId(), { event: s, content: i = "", activeRange: o } = e, a = s, c = (g = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : g.skeleton;
|
|
2380
|
+
if (a.data == null || c == null || !c || !o)
|
|
2287
2381
|
return;
|
|
2288
|
-
const { startOffset:
|
|
2382
|
+
const { startOffset: d, segmentId: l, style: h } = o, p = i.length, u = [
|
|
2289
2383
|
{
|
|
2290
|
-
startOffset:
|
|
2291
|
-
endOffset:
|
|
2292
|
-
|
|
2293
|
-
style: d
|
|
2384
|
+
startOffset: d + p,
|
|
2385
|
+
endOffset: d + p,
|
|
2386
|
+
style: h
|
|
2294
2387
|
}
|
|
2295
2388
|
];
|
|
2296
|
-
await this._commandService.executeCommand(
|
|
2297
|
-
unitId:
|
|
2389
|
+
await this._commandService.executeCommand(Je.id, {
|
|
2390
|
+
unitId: r,
|
|
2298
2391
|
body: {
|
|
2299
|
-
dataStream:
|
|
2392
|
+
dataStream: i
|
|
2300
2393
|
},
|
|
2301
|
-
range:
|
|
2302
|
-
textRanges:
|
|
2394
|
+
range: o,
|
|
2395
|
+
textRanges: u,
|
|
2303
2396
|
segmentId: l
|
|
2304
|
-
})
|
|
2397
|
+
});
|
|
2305
2398
|
});
|
|
2306
2399
|
}
|
|
2307
2400
|
_commandExecutedListener() {
|
|
2308
2401
|
}
|
|
2309
2402
|
_getDocObject() {
|
|
2310
|
-
return
|
|
2403
|
+
return Le(this._currentUniverService, this._renderManagerService);
|
|
2311
2404
|
}
|
|
2312
2405
|
};
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
var
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
super(), this._renderManagerService = r, this._initialize(), this._commandExecutedListener();
|
|
2406
|
+
ye = Dr([
|
|
2407
|
+
V(F.Rendered, ye),
|
|
2408
|
+
ce(0, U(A)),
|
|
2409
|
+
ce(1, O),
|
|
2410
|
+
ce(2, G),
|
|
2411
|
+
ce(3, fe),
|
|
2412
|
+
ce(4, x)
|
|
2413
|
+
], ye);
|
|
2414
|
+
var Tr = Object.defineProperty, Pr = Object.getOwnPropertyDescriptor, Er = (n, e, t, r) => {
|
|
2415
|
+
for (var s = r > 1 ? void 0 : r ? Pr(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
2416
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
2417
|
+
return r && s && Tr(e, t, s), s;
|
|
2418
|
+
}, Ct = (n, e) => (t, r) => e(t, r, n);
|
|
2419
|
+
const Ur = "rgba(198, 198, 198, 1)", wr = "rgba(255, 255, 255, 1)";
|
|
2420
|
+
let be = class extends W {
|
|
2421
|
+
constructor(n, e) {
|
|
2422
|
+
super(), this._renderManagerService = n, this._currentUniverService = e, this._initialize(), this._commandExecutedListener();
|
|
2331
2423
|
}
|
|
2332
2424
|
_initialize() {
|
|
2333
2425
|
this._initialRenderRefresh();
|
|
2334
2426
|
}
|
|
2335
2427
|
_initialRenderRefresh() {
|
|
2336
|
-
this._renderManagerService.currentRender$.subscribe((
|
|
2428
|
+
this._renderManagerService.currentRender$.subscribe((n) => {
|
|
2337
2429
|
var i;
|
|
2338
|
-
if (
|
|
2430
|
+
if (n == null || this._currentUniverService.getUniverDocInstance(n) == null)
|
|
2339
2431
|
return;
|
|
2340
|
-
const e = this._renderManagerService.getRenderById(
|
|
2432
|
+
const e = this._renderManagerService.getRenderById(n);
|
|
2341
2433
|
if (e == null)
|
|
2342
2434
|
return;
|
|
2343
|
-
const { mainComponent: t } = e,
|
|
2344
|
-
|
|
2345
|
-
if ([
|
|
2435
|
+
const { mainComponent: t } = e, r = t, s = (i = r.getSkeleton()) == null ? void 0 : i.getPageSize();
|
|
2436
|
+
r.onPageRenderObservable.add((o) => {
|
|
2437
|
+
if ([K, J].includes(n))
|
|
2346
2438
|
return;
|
|
2347
|
-
const { page: a, pageLeft: c, pageTop:
|
|
2348
|
-
|
|
2349
|
-
width: (s == null ? void 0 : s.width)
|
|
2350
|
-
height: (s == null ? void 0 : s.height)
|
|
2439
|
+
const { page: a, pageLeft: c, pageTop: d, ctx: l } = o, { width: h, pageWidth: p, height: u, pageHeight: g } = a;
|
|
2440
|
+
l.save(), l.translate(c - 0.5, d - 0.5), on.drawWith(l, {
|
|
2441
|
+
width: (s == null ? void 0 : s.width) ?? p ?? h,
|
|
2442
|
+
height: (s == null ? void 0 : s.height) ?? g ?? u,
|
|
2351
2443
|
strokeWidth: 1,
|
|
2352
|
-
stroke:
|
|
2353
|
-
fill:
|
|
2444
|
+
stroke: Ur,
|
|
2445
|
+
fill: wr,
|
|
2354
2446
|
zIndex: 3
|
|
2355
|
-
}),
|
|
2447
|
+
}), l.restore();
|
|
2356
2448
|
});
|
|
2357
2449
|
});
|
|
2358
2450
|
}
|
|
2359
2451
|
_commandExecutedListener() {
|
|
2360
2452
|
}
|
|
2361
2453
|
};
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2454
|
+
be = Er([
|
|
2455
|
+
V(F.Rendered, be),
|
|
2456
|
+
Ct(0, G),
|
|
2457
|
+
Ct(1, U(O))
|
|
2458
|
+
], be);
|
|
2459
|
+
var Lr = Object.defineProperty, Ar = Object.getOwnPropertyDescriptor, Nr = (n, e, t, r) => {
|
|
2460
|
+
for (var s = r > 1 ? void 0 : r ? Ar(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
2461
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
2462
|
+
return r && s && Lr(e, t, s), s;
|
|
2463
|
+
}, Y = (n, e) => (t, r) => e(t, r, n);
|
|
2464
|
+
let De = class extends W {
|
|
2465
|
+
constructor(e, t, r, s, i, o, a) {
|
|
2373
2466
|
super();
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
this._docSkeletonManagerService = e, this._currentUniverService = t, this._commandService =
|
|
2381
|
-
|
|
2467
|
+
S(this, "_moveInObserver");
|
|
2468
|
+
S(this, "_moveOutObserver");
|
|
2469
|
+
S(this, "_downObserver");
|
|
2470
|
+
S(this, "_dblClickObserver");
|
|
2471
|
+
S(this, "_tripleClickObserver");
|
|
2472
|
+
S(this, "_loadedMap", /* @__PURE__ */ new Set());
|
|
2473
|
+
this._docSkeletonManagerService = e, this._currentUniverService = t, this._commandService = r, this._renderManagerService = s, this._textSelectionRenderManager = i, this._textSelectionManagerService = o, this._layoutService = a, this._renderManagerService.currentRender$.subscribe((c) => {
|
|
2474
|
+
c != null && this._currentUniverService.getUniverDocInstance(c) != null && (this._loadedMap.has(c) || (this._initialMain(c), this._loadedMap.add(c)));
|
|
2382
2475
|
}), this._initialize();
|
|
2383
2476
|
}
|
|
2477
|
+
_initialize() {
|
|
2478
|
+
this._skeletonListener(), this._commandExecutedListener(), this._layoutService && this.disposeWithMe(
|
|
2479
|
+
this._layoutService.registerContainer(this._textSelectionRenderManager.__getEditorContainer())
|
|
2480
|
+
);
|
|
2481
|
+
}
|
|
2384
2482
|
dispose() {
|
|
2385
2483
|
this._renderManagerService.getRenderAll().forEach((e) => {
|
|
2386
2484
|
const { mainComponent: t } = e;
|
|
2387
2485
|
t != null && (t.onPointerEnterObserver.remove(this._moveInObserver), t.onPointerLeaveObserver.remove(this._moveOutObserver), t.onPointerDownObserver.remove(this._downObserver), t.onDblclickObserver.remove(this._dblClickObserver), t.onTripleClickObserver.remove(this._tripleClickObserver));
|
|
2388
2486
|
});
|
|
2389
2487
|
}
|
|
2390
|
-
_initialize() {
|
|
2391
|
-
this._onChangeListener(), this._skeletonListener(), this._userActionSyncListener(), this._commandExecutedListener();
|
|
2392
|
-
}
|
|
2393
2488
|
_initialMain(e) {
|
|
2394
2489
|
const t = this._getDocObjectById(e);
|
|
2395
2490
|
if (t == null)
|
|
2396
2491
|
return;
|
|
2397
|
-
const { document:
|
|
2398
|
-
this._moveInObserver =
|
|
2399
|
-
|
|
2400
|
-
}), this._moveOutObserver =
|
|
2401
|
-
|
|
2402
|
-
}), this._downObserver =
|
|
2403
|
-
this._currentUniverService.getCurrentUniverDocInstance().getUnitId() !== e && this._currentUniverService.setCurrentUniverDocInstance(e), this._textSelectionRenderManager.eventTrigger(
|
|
2404
|
-
}), this._dblClickObserver =
|
|
2405
|
-
this._textSelectionRenderManager.handleDblClick(
|
|
2406
|
-
}), this._tripleClickObserver =
|
|
2407
|
-
this._textSelectionRenderManager.handleTripleClick(
|
|
2408
|
-
});
|
|
2409
|
-
}
|
|
2410
|
-
_onChangeListener() {
|
|
2411
|
-
this._textSelectionManagerService.textSelectionInfo$.subscribe((e) => {
|
|
2412
|
-
var a, c;
|
|
2413
|
-
const t = (a = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : a.unitId;
|
|
2414
|
-
if (this._textSelectionRenderManager.removeAllTextRanges(), e == null || t == null)
|
|
2415
|
-
return;
|
|
2416
|
-
const n = (c = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : c.skeleton, s = this._getDocObjectById(t);
|
|
2417
|
-
if (s == null || n == null)
|
|
2418
|
-
return;
|
|
2419
|
-
const { scene: i, document: o } = s;
|
|
2420
|
-
this._textSelectionRenderManager.addTextRanges(e, {
|
|
2421
|
-
scene: i,
|
|
2422
|
-
skeleton: n,
|
|
2423
|
-
documentOffsetConfig: o.getOffsetConfig()
|
|
2424
|
-
});
|
|
2425
|
-
});
|
|
2426
|
-
}
|
|
2427
|
-
_userActionSyncListener() {
|
|
2428
|
-
this._textSelectionRenderManager.textSelection$.subscribe((e) => {
|
|
2429
|
-
const t = this._docSkeletonManagerService.getCurrent();
|
|
2430
|
-
if (t == null)
|
|
2431
|
-
return;
|
|
2432
|
-
const { unitId: n } = t;
|
|
2433
|
-
this._commandService.executeCommand(Tt.id, {
|
|
2434
|
-
unitId: n,
|
|
2435
|
-
pluginName: Ne,
|
|
2436
|
-
ranges: e
|
|
2437
|
-
});
|
|
2492
|
+
const { document: r, scene: s } = t;
|
|
2493
|
+
this._moveInObserver = r.onPointerEnterObserver.add(() => {
|
|
2494
|
+
r.cursor = lt.TEXT;
|
|
2495
|
+
}), this._moveOutObserver = r.onPointerLeaveObserver.add(() => {
|
|
2496
|
+
r.cursor = lt.DEFAULT, s.resetCursor();
|
|
2497
|
+
}), this._downObserver = r == null ? void 0 : r.onPointerDownObserver.add((i, o) => {
|
|
2498
|
+
this._currentUniverService.getCurrentUniverDocInstance().getUnitId() !== e && this._currentUniverService.setCurrentUniverDocInstance(e), this._textSelectionRenderManager.eventTrigger(i), i.button !== 2 && o.stopPropagation();
|
|
2499
|
+
}), this._dblClickObserver = r == null ? void 0 : r.onDblclickObserver.add((i) => {
|
|
2500
|
+
this._textSelectionRenderManager.handleDblClick(i);
|
|
2501
|
+
}), this._tripleClickObserver = r == null ? void 0 : r.onTripleClickObserver.add((i) => {
|
|
2502
|
+
this._textSelectionRenderManager.handleTripleClick(i);
|
|
2438
2503
|
});
|
|
2439
2504
|
}
|
|
2440
|
-
_getDocObjectById(e) {
|
|
2441
|
-
return fn(e, this._renderManagerService);
|
|
2442
|
-
}
|
|
2443
2505
|
_commandExecutedListener() {
|
|
2444
|
-
const e = [
|
|
2506
|
+
const e = [Z.id];
|
|
2445
2507
|
this.disposeWithMe(
|
|
2446
2508
|
this._commandService.onCommandExecuted((t) => {
|
|
2447
|
-
var
|
|
2509
|
+
var r;
|
|
2448
2510
|
if (e.includes(t.id)) {
|
|
2449
|
-
const s = t.params, { unitId: i } = s, o = (
|
|
2511
|
+
const s = t.params, { unitId: i } = s, o = (r = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : r.unitId;
|
|
2450
2512
|
if (i !== o)
|
|
2451
2513
|
return;
|
|
2452
2514
|
this._textSelectionManagerService.refreshSelection();
|
|
@@ -2458,41 +2520,40 @@ let Ee = class extends w {
|
|
|
2458
2520
|
this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
|
|
2459
2521
|
if (e == null)
|
|
2460
2522
|
return;
|
|
2461
|
-
const { unitId: t, skeleton:
|
|
2523
|
+
const { unitId: t, skeleton: r } = e, s = this._renderManagerService.getRenderById(t);
|
|
2462
2524
|
if (s == null)
|
|
2463
2525
|
return;
|
|
2464
|
-
const { scene: i, mainComponent: o } = s
|
|
2465
|
-
this._textSelectionRenderManager.changeRuntime(
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
a,
|
|
2469
|
-
o.getOffsetConfig()
|
|
2470
|
-
), this._textSelectionManagerService.setCurrentSelectionNotRefresh({
|
|
2471
|
-
pluginName: Ne,
|
|
2472
|
-
unitId: t
|
|
2526
|
+
const { scene: i, mainComponent: o } = s;
|
|
2527
|
+
this._textSelectionRenderManager.changeRuntime(r, i, o), this._textSelectionManagerService.setCurrentSelectionNotRefresh({
|
|
2528
|
+
unitId: t,
|
|
2529
|
+
subUnitId: ""
|
|
2473
2530
|
});
|
|
2474
2531
|
});
|
|
2475
2532
|
}
|
|
2533
|
+
_getDocObjectById(e) {
|
|
2534
|
+
return In(e, this._renderManagerService);
|
|
2535
|
+
}
|
|
2476
2536
|
};
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2537
|
+
De = Nr([
|
|
2538
|
+
V(F.Rendered, De),
|
|
2539
|
+
Y(0, U(A)),
|
|
2540
|
+
Y(1, O),
|
|
2541
|
+
Y(2, x),
|
|
2542
|
+
Y(3, G),
|
|
2543
|
+
Y(4, fe),
|
|
2544
|
+
Y(5, U(P)),
|
|
2545
|
+
Y(6, Cn(Sn))
|
|
2546
|
+
], De);
|
|
2547
|
+
var $r = Object.defineProperty, Br = Object.getOwnPropertyDescriptor, jr = (n, e, t, r) => {
|
|
2548
|
+
for (var s = r > 1 ? void 0 : r ? Br(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
2549
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
2550
|
+
return r && s && $r(e, t, s), s;
|
|
2551
|
+
}, le = (n, e) => (t, r) => e(t, r, n);
|
|
2552
|
+
let Te = class extends W {
|
|
2553
|
+
constructor(e, t, r, s, i) {
|
|
2493
2554
|
super();
|
|
2494
|
-
|
|
2495
|
-
this._docSkeletonManagerService = e, this._currentUniverService = t, this._commandService =
|
|
2555
|
+
S(this, "_initializedRender", /* @__PURE__ */ new Set());
|
|
2556
|
+
this._docSkeletonManagerService = e, this._currentUniverService = t, this._commandService = r, this._renderManagerService = s, this._textSelectionManagerService = i, this._initialize();
|
|
2496
2557
|
}
|
|
2497
2558
|
dispose() {
|
|
2498
2559
|
super.dispose();
|
|
@@ -2504,24 +2565,24 @@ let we = class extends w {
|
|
|
2504
2565
|
this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
|
|
2505
2566
|
if (e == null)
|
|
2506
2567
|
return;
|
|
2507
|
-
const { unitId: t } = e,
|
|
2508
|
-
if (
|
|
2568
|
+
const { unitId: t } = e, r = this._renderManagerService.getRenderById(t);
|
|
2569
|
+
if (r == null || this._initializedRender.has(t) || [K, J].includes(t))
|
|
2509
2570
|
return;
|
|
2510
2571
|
this._initializedRender.add(t);
|
|
2511
|
-
const { scene: s } =
|
|
2572
|
+
const { scene: s } = r;
|
|
2512
2573
|
this.disposeWithMe(
|
|
2513
|
-
|
|
2574
|
+
Ge(
|
|
2514
2575
|
s.onMouseWheelObserver.add((i) => {
|
|
2515
2576
|
if (!i.ctrlKey)
|
|
2516
2577
|
return;
|
|
2517
2578
|
const o = Math.abs(i.deltaX);
|
|
2518
2579
|
let a = o < 40 ? 0.2 : o < 80 ? 0.4 : 0.2;
|
|
2519
2580
|
a *= i.deltaY > 0 ? -1 : 1, s.scaleX < 1 && (a /= 2);
|
|
2520
|
-
const c = this._currentUniverService.getCurrentUniverDocInstance(),
|
|
2521
|
-
let
|
|
2522
|
-
|
|
2523
|
-
zoomRatio:
|
|
2524
|
-
|
|
2581
|
+
const c = this._currentUniverService.getCurrentUniverDocInstance(), d = c.zoomRatio;
|
|
2582
|
+
let l = +parseFloat(`${d + a}`).toFixed(1);
|
|
2583
|
+
l = l >= 4 ? 4 : l <= 0.1 ? 0.1 : l, this._commandService.executeCommand(Bt.id, {
|
|
2584
|
+
zoomRatio: l,
|
|
2585
|
+
unitId: c.getUnitId()
|
|
2525
2586
|
}), i.preventDefault();
|
|
2526
2587
|
})
|
|
2527
2588
|
)
|
|
@@ -2537,25 +2598,25 @@ let we = class extends w {
|
|
|
2537
2598
|
// }
|
|
2538
2599
|
_skeletonListener() {
|
|
2539
2600
|
this.disposeWithMe(
|
|
2540
|
-
|
|
2601
|
+
Ge(
|
|
2541
2602
|
this._docSkeletonManagerService.currentSkeletonBefore$.subscribe((e) => {
|
|
2542
2603
|
if (e == null)
|
|
2543
2604
|
return;
|
|
2544
|
-
const
|
|
2545
|
-
this._updateViewZoom(
|
|
2605
|
+
const r = this._currentUniverService.getCurrentUniverDocInstance().zoomRatio || 1;
|
|
2606
|
+
this._updateViewZoom(r, !1);
|
|
2546
2607
|
})
|
|
2547
2608
|
)
|
|
2548
2609
|
);
|
|
2549
2610
|
}
|
|
2550
2611
|
_commandExecutedListener() {
|
|
2551
|
-
const e = [
|
|
2612
|
+
const e = [Z.id];
|
|
2552
2613
|
this.disposeWithMe(
|
|
2553
2614
|
this._commandService.onCommandExecuted((t) => {
|
|
2554
2615
|
if (e.includes(t.id)) {
|
|
2555
|
-
const
|
|
2556
|
-
if (i !==
|
|
2616
|
+
const r = this._currentUniverService.getCurrentUniverDocInstance(), s = t.params, { unitId: i } = s;
|
|
2617
|
+
if (i !== r.getUnitId())
|
|
2557
2618
|
return;
|
|
2558
|
-
const o =
|
|
2619
|
+
const o = r.zoomRatio || 1;
|
|
2559
2620
|
this._updateViewZoom(o);
|
|
2560
2621
|
}
|
|
2561
2622
|
})
|
|
@@ -2563,19 +2624,19 @@ let we = class extends w {
|
|
|
2563
2624
|
}
|
|
2564
2625
|
_updateViewZoom(e, t = !0) {
|
|
2565
2626
|
var s;
|
|
2566
|
-
const
|
|
2567
|
-
|
|
2627
|
+
const r = this._getDocObject();
|
|
2628
|
+
r != null && (r.scene.scale(e, e), this._calculatePagePosition(r, e), t && this._textSelectionManagerService.refreshSelection(), (s = r.scene.getTransformer()) == null || s.hideControl());
|
|
2568
2629
|
}
|
|
2569
2630
|
_calculatePagePosition(e, t) {
|
|
2570
|
-
const { document:
|
|
2631
|
+
const { document: r, scene: s } = e, i = s == null ? void 0 : s.getParent(), { width: o, height: a, pageMarginLeft: c, pageMarginTop: d } = r;
|
|
2571
2632
|
if (i == null || o === 1 / 0 || a === 1 / 0)
|
|
2572
2633
|
return;
|
|
2573
|
-
const { width:
|
|
2574
|
-
let
|
|
2575
|
-
|
|
2576
|
-
const v = s.getViewport(
|
|
2577
|
-
if (
|
|
2578
|
-
const M = v.getBarScroll(
|
|
2634
|
+
const { width: l, height: h } = i;
|
|
2635
|
+
let p = 0, u = 0, g = 0, m = 0, f = 1 / 0;
|
|
2636
|
+
l > (o + c * 2) * t ? (p = l / 2 - o * t / 2, p /= t, g = (l - c * 2) / t, f = 0) : (p = c, g = o + c * 2, f = (g - l / t) / 2), h > a ? (u = h / 2 - a / 2, m = (h - d * 2) / t) : (u = d, m = a + d * 2), s.resize(g, m + 200), r.translate(p, u);
|
|
2637
|
+
const v = s.getViewport(Ke.VIEW_MAIN);
|
|
2638
|
+
if (f !== 1 / 0 && v != null) {
|
|
2639
|
+
const M = v.getBarScroll(f, 0).x;
|
|
2579
2640
|
v.scrollTo({
|
|
2580
2641
|
x: M
|
|
2581
2642
|
});
|
|
@@ -2583,218 +2644,230 @@ let we = class extends w {
|
|
|
2583
2644
|
return this;
|
|
2584
2645
|
}
|
|
2585
2646
|
_getDocObject() {
|
|
2586
|
-
return
|
|
2647
|
+
return Le(this._currentUniverService, this._renderManagerService);
|
|
2587
2648
|
}
|
|
2588
2649
|
};
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
],
|
|
2597
|
-
const
|
|
2598
|
-
id:
|
|
2599
|
-
preconditions: (
|
|
2600
|
-
binding:
|
|
2601
|
-
},
|
|
2602
|
-
id:
|
|
2603
|
-
preconditions: (
|
|
2604
|
-
binding:
|
|
2605
|
-
},
|
|
2606
|
-
id:
|
|
2607
|
-
preconditions: (
|
|
2608
|
-
binding:
|
|
2609
|
-
},
|
|
2610
|
-
id:
|
|
2611
|
-
binding:
|
|
2612
|
-
preconditions: (
|
|
2650
|
+
Te = jr([
|
|
2651
|
+
V(F.Rendered, Te),
|
|
2652
|
+
le(0, U(A)),
|
|
2653
|
+
le(1, O),
|
|
2654
|
+
le(2, x),
|
|
2655
|
+
le(3, G),
|
|
2656
|
+
le(4, U(P))
|
|
2657
|
+
], Te);
|
|
2658
|
+
const Vr = {
|
|
2659
|
+
id: Pt.id,
|
|
2660
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2661
|
+
binding: $.ENTER
|
|
2662
|
+
}, Fr = {
|
|
2663
|
+
id: Et.id,
|
|
2664
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2665
|
+
binding: $.BACKSPACE
|
|
2666
|
+
}, kr = {
|
|
2667
|
+
id: Ut.id,
|
|
2668
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2669
|
+
binding: $.DELETE
|
|
2670
|
+
}, zr = {
|
|
2671
|
+
id: ee.id,
|
|
2672
|
+
binding: $.ARROW_UP,
|
|
2673
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2613
2674
|
staticParameters: {
|
|
2614
|
-
direction:
|
|
2675
|
+
direction: b.UP
|
|
2615
2676
|
}
|
|
2616
|
-
},
|
|
2617
|
-
id:
|
|
2618
|
-
binding:
|
|
2619
|
-
preconditions: (
|
|
2677
|
+
}, Wr = {
|
|
2678
|
+
id: ee.id,
|
|
2679
|
+
binding: $.ARROW_DOWN,
|
|
2680
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2620
2681
|
staticParameters: {
|
|
2621
|
-
direction:
|
|
2682
|
+
direction: b.DOWN
|
|
2622
2683
|
}
|
|
2623
|
-
},
|
|
2624
|
-
id:
|
|
2625
|
-
binding:
|
|
2626
|
-
preconditions: (
|
|
2684
|
+
}, Hr = {
|
|
2685
|
+
id: ee.id,
|
|
2686
|
+
binding: $.ARROW_LEFT,
|
|
2687
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2627
2688
|
staticParameters: {
|
|
2628
|
-
direction:
|
|
2689
|
+
direction: b.LEFT
|
|
2629
2690
|
}
|
|
2630
|
-
},
|
|
2631
|
-
id:
|
|
2632
|
-
binding:
|
|
2633
|
-
preconditions: (
|
|
2691
|
+
}, Gr = {
|
|
2692
|
+
id: ee.id,
|
|
2693
|
+
binding: $.ARROW_RIGHT,
|
|
2694
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2634
2695
|
staticParameters: {
|
|
2635
|
-
direction:
|
|
2696
|
+
direction: b.RIGHT
|
|
2636
2697
|
}
|
|
2637
|
-
},
|
|
2638
|
-
id:
|
|
2639
|
-
binding:
|
|
2640
|
-
preconditions: (
|
|
2698
|
+
}, Xr = {
|
|
2699
|
+
id: te.id,
|
|
2700
|
+
binding: $.ARROW_UP | _e.SHIFT,
|
|
2701
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2641
2702
|
staticParameters: {
|
|
2642
|
-
direction:
|
|
2703
|
+
direction: b.UP
|
|
2643
2704
|
}
|
|
2644
|
-
},
|
|
2645
|
-
id:
|
|
2646
|
-
binding:
|
|
2647
|
-
preconditions: (
|
|
2705
|
+
}, qr = {
|
|
2706
|
+
id: te.id,
|
|
2707
|
+
binding: $.ARROW_DOWN | _e.SHIFT,
|
|
2708
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2648
2709
|
staticParameters: {
|
|
2649
|
-
direction:
|
|
2710
|
+
direction: b.DOWN
|
|
2650
2711
|
}
|
|
2651
|
-
},
|
|
2652
|
-
id:
|
|
2653
|
-
binding:
|
|
2654
|
-
preconditions: (
|
|
2712
|
+
}, Yr = {
|
|
2713
|
+
id: te.id,
|
|
2714
|
+
binding: $.ARROW_LEFT | _e.SHIFT,
|
|
2715
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2655
2716
|
staticParameters: {
|
|
2656
|
-
direction:
|
|
2717
|
+
direction: b.LEFT
|
|
2657
2718
|
}
|
|
2658
|
-
},
|
|
2659
|
-
id:
|
|
2660
|
-
binding:
|
|
2661
|
-
preconditions: (
|
|
2719
|
+
}, Zr = {
|
|
2720
|
+
id: te.id,
|
|
2721
|
+
binding: $.ARROW_RIGHT | _e.SHIFT,
|
|
2722
|
+
preconditions: (n) => n.getContextValue(w),
|
|
2662
2723
|
staticParameters: {
|
|
2663
|
-
direction:
|
|
2724
|
+
direction: b.RIGHT
|
|
2664
2725
|
}
|
|
2665
|
-
},
|
|
2666
|
-
id:
|
|
2667
|
-
binding:
|
|
2668
|
-
preconditions: (
|
|
2726
|
+
}, Kr = {
|
|
2727
|
+
id: jt.id,
|
|
2728
|
+
binding: $.A | _e.CTRL_COMMAND,
|
|
2729
|
+
preconditions: (n) => n.getContextValue(w) || n.getContextValue(me)
|
|
2669
2730
|
};
|
|
2670
|
-
var
|
|
2671
|
-
for (var s =
|
|
2672
|
-
(o =
|
|
2673
|
-
return
|
|
2674
|
-
},
|
|
2675
|
-
let
|
|
2676
|
-
constructor(
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
this
|
|
2731
|
+
var Jr = Object.defineProperty, Qr = Object.getOwnPropertyDescriptor, es = (n, e, t, r) => {
|
|
2732
|
+
for (var s = r > 1 ? void 0 : r ? Qr(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
2733
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
2734
|
+
return r && s && Jr(e, t, s), s;
|
|
2735
|
+
}, Se = (n, e) => (t, r) => e(t, r, n);
|
|
2736
|
+
let Pe = class extends Ze {
|
|
2737
|
+
constructor(e, t, r, s) {
|
|
2738
|
+
super();
|
|
2739
|
+
S(this, "_scene");
|
|
2740
|
+
S(this, "_currentDocumentModel");
|
|
2741
|
+
S(this, "_loadedMap", /* @__PURE__ */ new Set());
|
|
2742
|
+
S(this, "_fps$", new de(""));
|
|
2743
|
+
S(this, "fps$", this._fps$.asObservable());
|
|
2744
|
+
this._renderManagerService = e, this._configService = t, this._currentUniverService = r, this._docViewModelManagerService = s, this._initialize();
|
|
2681
2745
|
}
|
|
2682
2746
|
_initialize() {
|
|
2683
|
-
this._currentUniverService.currentDoc$.subscribe((
|
|
2684
|
-
if (
|
|
2747
|
+
this._currentUniverService.currentDoc$.subscribe((e) => {
|
|
2748
|
+
if (e == null)
|
|
2685
2749
|
return;
|
|
2686
|
-
this._currentDocumentModel =
|
|
2687
|
-
const
|
|
2688
|
-
this._docViewModelManagerService.setCurrent(
|
|
2750
|
+
this._currentDocumentModel = e;
|
|
2751
|
+
const t = e.getUnitId();
|
|
2752
|
+
this._docViewModelManagerService.setCurrent(t), this._loadedMap.has(t) || (this._addNewRender(), this._loadedMap.add(t));
|
|
2689
2753
|
});
|
|
2690
2754
|
}
|
|
2755
|
+
dispose() {
|
|
2756
|
+
this._fps$.complete();
|
|
2757
|
+
}
|
|
2691
2758
|
_addNewRender() {
|
|
2692
|
-
const
|
|
2693
|
-
if (
|
|
2759
|
+
const e = this._currentDocumentModel, t = e.getUnitId(), r = e.getContainer(), s = e.getParentRenderUnitId();
|
|
2760
|
+
if (r != null && s != null)
|
|
2694
2761
|
throw new Error("container or parentRenderUnitId can only exist one");
|
|
2695
|
-
|
|
2696
|
-
const
|
|
2697
|
-
if (
|
|
2762
|
+
r == null && s != null ? this._renderManagerService.createRenderWithParent(t, s) : this._renderManagerService.createRender(t);
|
|
2763
|
+
const i = this._renderManagerService.getRenderById(t);
|
|
2764
|
+
if (i == null)
|
|
2698
2765
|
return;
|
|
2699
|
-
const { scene:
|
|
2700
|
-
|
|
2701
|
-
const
|
|
2766
|
+
const { scene: o, engine: a } = i;
|
|
2767
|
+
o.openTransformer(), this._scene = o;
|
|
2768
|
+
const c = new an(Ke.VIEW_MAIN, o, {
|
|
2702
2769
|
left: 0,
|
|
2703
2770
|
top: 0,
|
|
2704
2771
|
bottom: 0,
|
|
2705
2772
|
right: 0,
|
|
2706
2773
|
isWheelPreventDefaultX: !0
|
|
2707
2774
|
});
|
|
2708
|
-
|
|
2709
|
-
const
|
|
2710
|
-
if (
|
|
2711
|
-
const
|
|
2712
|
-
let
|
|
2713
|
-
|
|
2775
|
+
o.addViewport(c).attachControl(), o.on(cn.wheel, (h, p) => {
|
|
2776
|
+
const u = h;
|
|
2777
|
+
if (u.ctrlKey) {
|
|
2778
|
+
const g = Math.abs(u.deltaX);
|
|
2779
|
+
let m = g < 40 ? 0.2 : g < 80 ? 0.4 : 0.2;
|
|
2780
|
+
m *= u.deltaY > 0 ? -1 : 1, o.scaleX < 1 && (m /= 2), o.scaleX + m > 4 ? o.scale(4, 4) : o.scaleX + m < 0.1 ? o.scale(0.1, 0.1) : u.preventDefault();
|
|
2714
2781
|
} else
|
|
2715
|
-
|
|
2716
|
-
}), this._configService.getConfig("hasScroll") !== !1 &&
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
), this._addComponent(
|
|
2720
|
-
|
|
2721
|
-
}), this._renderManagerService.setCurrent(
|
|
2722
|
-
}
|
|
2723
|
-
_addComponent(
|
|
2724
|
-
const
|
|
2725
|
-
pageMarginLeft:
|
|
2726
|
-
pageMarginTop:
|
|
2782
|
+
c.onMouseWheel(u, p);
|
|
2783
|
+
}), this._configService.getConfig("hasScroll") !== !1 && t !== J && new ln(c), o.addLayer(
|
|
2784
|
+
new dt(o, [], ut),
|
|
2785
|
+
new dt(o, [], xn)
|
|
2786
|
+
), this._addComponent(i), this._currentDocumentModel.getShouldRenderLoopImmediately() && a.runRenderLoop(() => {
|
|
2787
|
+
o.render(), this._fps$.next(Math.round(a.getFps()).toString());
|
|
2788
|
+
}), this._renderManagerService.setCurrent(t);
|
|
2789
|
+
}
|
|
2790
|
+
_addComponent(e) {
|
|
2791
|
+
const t = this._scene, r = this._currentDocumentModel, s = new dn(Xe.MAIN, void 0, {
|
|
2792
|
+
pageMarginLeft: r.documentStyle.marginLeft || 0,
|
|
2793
|
+
pageMarginTop: r.documentStyle.marginTop || 0
|
|
2727
2794
|
});
|
|
2728
|
-
|
|
2795
|
+
s.zIndex = On, e.mainComponent = s, e.components.set(Xe.MAIN, s), t.addObjects([s], ut);
|
|
2729
2796
|
}
|
|
2730
2797
|
};
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
],
|
|
2738
|
-
var
|
|
2739
|
-
for (var s =
|
|
2740
|
-
(o =
|
|
2741
|
-
return
|
|
2742
|
-
},
|
|
2743
|
-
const
|
|
2798
|
+
Pe = es([
|
|
2799
|
+
V(F.Ready, Pe),
|
|
2800
|
+
Se(0, G),
|
|
2801
|
+
Se(1, yt),
|
|
2802
|
+
Se(2, O),
|
|
2803
|
+
Se(3, U(se))
|
|
2804
|
+
], Pe);
|
|
2805
|
+
var ts = Object.defineProperty, ns = Object.getOwnPropertyDescriptor, rs = (n, e, t, r) => {
|
|
2806
|
+
for (var s = r > 1 ? void 0 : r ? ns(e, t) : e, i = n.length - 1, o; i >= 0; i--)
|
|
2807
|
+
(o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
2808
|
+
return r && s && ts(e, t, s), s;
|
|
2809
|
+
}, ve = (n, e) => (t, r) => e(t, r, n);
|
|
2810
|
+
const ss = {
|
|
2744
2811
|
hasScroll: !0
|
|
2745
|
-
},
|
|
2746
|
-
var
|
|
2747
|
-
let
|
|
2748
|
-
constructor(e = {}, t,
|
|
2749
|
-
super(
|
|
2750
|
-
|
|
2751
|
-
this._injector = t, this._localeService =
|
|
2812
|
+
}, is = "docs";
|
|
2813
|
+
var We;
|
|
2814
|
+
let Rt = (We = class extends Yt {
|
|
2815
|
+
constructor(e = {}, t, r, s, i) {
|
|
2816
|
+
super(is);
|
|
2817
|
+
S(this, "_config");
|
|
2818
|
+
this._injector = t, this._localeService = r, this._configService = s, this._currentUniverService = i, this._config = Object.assign(ss, e), this._initializeDependencies(t), this._initializeCommands();
|
|
2752
2819
|
}
|
|
2753
2820
|
initialize() {
|
|
2754
2821
|
}
|
|
2755
2822
|
_initializeCommands() {
|
|
2756
2823
|
[
|
|
2757
|
-
|
|
2758
|
-
|
|
2824
|
+
ee,
|
|
2825
|
+
te,
|
|
2826
|
+
Et,
|
|
2827
|
+
Ut,
|
|
2828
|
+
ue,
|
|
2829
|
+
Ne,
|
|
2759
2830
|
$e,
|
|
2760
2831
|
Be,
|
|
2761
|
-
|
|
2832
|
+
Q,
|
|
2833
|
+
ie,
|
|
2834
|
+
he,
|
|
2835
|
+
pe,
|
|
2762
2836
|
je,
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
Fe,
|
|
2768
|
-
Dt,
|
|
2769
|
-
st,
|
|
2770
|
-
it,
|
|
2771
|
-
tt,
|
|
2772
|
-
yt,
|
|
2773
|
-
bt,
|
|
2774
|
-
S,
|
|
2775
|
-
In,
|
|
2776
|
-
xn,
|
|
2777
|
-
Et,
|
|
2778
|
-
H,
|
|
2837
|
+
Nt,
|
|
2838
|
+
Pt,
|
|
2839
|
+
Je,
|
|
2840
|
+
Qe,
|
|
2779
2841
|
Tt,
|
|
2780
|
-
|
|
2842
|
+
Lt,
|
|
2843
|
+
et,
|
|
2844
|
+
_,
|
|
2845
|
+
Wn,
|
|
2846
|
+
Hn,
|
|
2847
|
+
Bt,
|
|
2848
|
+
Z,
|
|
2849
|
+
Dt,
|
|
2850
|
+
jt,
|
|
2851
|
+
kn,
|
|
2852
|
+
Fn,
|
|
2853
|
+
nt
|
|
2781
2854
|
].forEach((e) => {
|
|
2782
|
-
this._injector.get(
|
|
2855
|
+
this._injector.get(x).registerCommand(e);
|
|
2783
2856
|
}), [
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2857
|
+
zr,
|
|
2858
|
+
Wr,
|
|
2859
|
+
Gr,
|
|
2860
|
+
Hr,
|
|
2861
|
+
Xr,
|
|
2862
|
+
qr,
|
|
2863
|
+
Yr,
|
|
2864
|
+
Zr,
|
|
2865
|
+
Kr,
|
|
2866
|
+
Fr,
|
|
2792
2867
|
kr,
|
|
2793
|
-
|
|
2794
|
-
wr,
|
|
2795
|
-
Tr
|
|
2868
|
+
Vr
|
|
2796
2869
|
].forEach((e) => {
|
|
2797
|
-
this._injector.get(
|
|
2870
|
+
this._injector.get(vn).registerShortcut(e);
|
|
2798
2871
|
});
|
|
2799
2872
|
}
|
|
2800
2873
|
onReady() {
|
|
@@ -2807,79 +2880,83 @@ let It = (Ze = class extends zt {
|
|
|
2807
2880
|
// { useFactory: () => docInjector.createInstance(CanvasView, this._config.standalone ?? true) },
|
|
2808
2881
|
// ], // FIXME: CanvasView shouldn't be a dependency of UniverDocs. Because it maybe created dynamically.
|
|
2809
2882
|
//views
|
|
2810
|
-
[
|
|
2883
|
+
[Pe],
|
|
2811
2884
|
// services
|
|
2812
2885
|
[A],
|
|
2813
|
-
[
|
|
2814
|
-
[
|
|
2886
|
+
[se],
|
|
2887
|
+
[tt],
|
|
2815
2888
|
[
|
|
2816
|
-
|
|
2889
|
+
Vt,
|
|
2817
2890
|
{
|
|
2818
|
-
useClass:
|
|
2891
|
+
useClass: Ye
|
|
2819
2892
|
}
|
|
2820
2893
|
],
|
|
2821
2894
|
[
|
|
2822
|
-
|
|
2895
|
+
fe,
|
|
2823
2896
|
{
|
|
2824
2897
|
useClass: un
|
|
2825
2898
|
}
|
|
2826
2899
|
],
|
|
2827
2900
|
[P],
|
|
2828
2901
|
// controllers
|
|
2829
|
-
[Ie],
|
|
2830
|
-
[Te],
|
|
2831
|
-
[Ee],
|
|
2832
|
-
[Pe],
|
|
2833
|
-
[Oe],
|
|
2834
|
-
[Re],
|
|
2835
|
-
[ye],
|
|
2836
2902
|
[Ce],
|
|
2837
2903
|
[be],
|
|
2838
2904
|
[De],
|
|
2839
|
-
[
|
|
2840
|
-
[
|
|
2905
|
+
[ye],
|
|
2906
|
+
[Ie],
|
|
2907
|
+
[xe],
|
|
2908
|
+
[Me],
|
|
2909
|
+
[Oe],
|
|
2910
|
+
[Te],
|
|
2911
|
+
[Re]
|
|
2841
2912
|
].forEach((t) => e.add(t));
|
|
2842
2913
|
}
|
|
2843
|
-
},
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
],
|
|
2914
|
+
}, S(We, "type", Zt.Doc), We);
|
|
2915
|
+
Rt = rs([
|
|
2916
|
+
ve(1, U(Rn)),
|
|
2917
|
+
ve(2, U(It)),
|
|
2918
|
+
ve(3, yt),
|
|
2919
|
+
ve(4, O)
|
|
2920
|
+
], Rt);
|
|
2850
2921
|
export {
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2922
|
+
Pt as BreakLineCommand,
|
|
2923
|
+
Fn as BulletListCommand,
|
|
2924
|
+
Hn as CoverContentCommand,
|
|
2925
|
+
On as DOCS_COMPONENT_DEFAULT_Z_INDEX,
|
|
2926
|
+
xn as DOCS_COMPONENT_HEADER_LAYER_INDEX,
|
|
2927
|
+
ut as DOCS_COMPONENT_MAIN_LAYER_INDEX,
|
|
2928
|
+
Xe as DOCS_VIEW_KEY,
|
|
2929
|
+
Qe as DeleteCommand,
|
|
2930
|
+
Et as DeleteLeftCommand,
|
|
2931
|
+
Ut as DeleteRightCommand,
|
|
2932
|
+
Pe as DocCanvasView,
|
|
2933
|
+
Ve as DocCopyCommand,
|
|
2934
|
+
Fe as DocCutCommand,
|
|
2935
|
+
ke as DocPasteCommand,
|
|
2862
2936
|
A as DocSkeletonManagerService,
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2937
|
+
se as DocViewModelManagerService,
|
|
2938
|
+
Lt as IMEInputCommand,
|
|
2939
|
+
Je as InsertCommand,
|
|
2940
|
+
ee as MoveCursorOperation,
|
|
2941
|
+
te as MoveSelectionOperation,
|
|
2942
|
+
hs as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
|
|
2943
|
+
kn as OrderListCommand,
|
|
2944
|
+
Wn as ReplaceContentCommand,
|
|
2945
|
+
_ as RichTextEditingMutation,
|
|
2946
|
+
ue as SetInlineFormatBoldCommand,
|
|
2947
|
+
Nt as SetInlineFormatCommand,
|
|
2948
|
+
pe as SetInlineFormatFontFamilyCommand,
|
|
2949
|
+
he as SetInlineFormatFontSizeCommand,
|
|
2950
|
+
Ne as SetInlineFormatItalicCommand,
|
|
2951
|
+
Be as SetInlineFormatStrikethroughCommand,
|
|
2952
|
+
Q as SetInlineFormatSubscriptCommand,
|
|
2953
|
+
ie as SetInlineFormatSuperscriptCommand,
|
|
2954
|
+
je as SetInlineFormatTextColorCommand,
|
|
2955
|
+
$e as SetInlineFormatUnderlineCommand,
|
|
2956
|
+
Dt as SetTextSelectionsOperation,
|
|
2880
2957
|
P as TextSelectionManagerService,
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2958
|
+
Rt as UniverDocsPlugin,
|
|
2959
|
+
Tt as UpdateCommand,
|
|
2960
|
+
Ke as VIEWPORT_KEY,
|
|
2961
|
+
Le as getDocObject
|
|
2885
2962
|
};
|