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