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