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