@univerjs/docs 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +825 -728
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +1 -1
- package/lib/types/commands/commands/inline-format.command.d.ts +2 -0
- package/lib/types/controllers/ime-input.controller.d.ts +2 -2
- package/lib/types/controllers/move-cursor.controller.d.ts +2 -2
- package/lib/types/controllers/normal-input.controller.d.ts +2 -2
- package/lib/types/doc-plugin.d.ts +3 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/doc-skeleton-manager.service.d.ts +2 -2
- package/lib/types/services/doc-view-model-manager.service.d.ts +2 -2
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
package/lib/es/index.js
CHANGED
|
@@ -1,58 +1,61 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommandType as v, RxDisposable as
|
|
5
|
-
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as
|
|
6
|
-
import { BehaviorSubject as
|
|
7
|
-
import { Inject as
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
1
|
+
var yt = Object.defineProperty;
|
|
2
|
+
var Ot = (s, e, t) => e in s ? yt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var x = (s, e, t) => (Ot(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { UniverInstanceType as W, CommandType as v, RxDisposable as ge, ICommandService as I, TextXActionType as y, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as dt, IUniverInstanceService as E, IUndoRedoService as Te, UndoCommandId as Xe, RedoCommandId as Ye, TextX as P, DataStreamTreeTokenType as xe, Tools as Q, LocaleService as Tt, MemoryCursor as oe, getDocsUpdateBody as Et, UpdateDocsAttributeType as Ee, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Dt, BooleanNumber as k, BaselineOffset as j, PRESET_LIST_TYPE as At, PresetListType as ut, HorizontalAlign as re, OnLifecycle as De, LifecycleStages as Ae, Disposable as Ne, Direction as N, Plugin as Nt } from "@univerjs/core";
|
|
5
|
+
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as bt, ITextSelectionRenderManager as fe, DocumentViewModel as Pt, DocumentSkeleton as Ut, hasListGlyph as wt, isIndentByGlyph as Lt, isFirstGlyph as Bt, getParagraphByGlyph as Ft, getCharSpaceApply as $t, getNumberUnitValue as Me, RANGE_DIRECTION as We, NodePositionConvertToCursor as Ze, IRenderManagerService as mt, TextSelectionRenderManager as Vt } from "@univerjs/engine-render";
|
|
6
|
+
import { BehaviorSubject as ee, takeUntil as te } from "rxjs";
|
|
7
|
+
import { Inject as V, Injector as zt } from "@wendellhu/redi";
|
|
8
|
+
function gt(s, e) {
|
|
9
|
+
const t = s.getCurrentUnitForType(W.UNIVER_DOC);
|
|
10
|
+
if (!t)
|
|
11
|
+
return null;
|
|
12
|
+
const n = t.getUnitId(), o = e.getRenderById(n);
|
|
13
|
+
if (o == null)
|
|
11
14
|
return;
|
|
12
|
-
const { mainComponent: r, scene: i, engine: a } =
|
|
15
|
+
const { mainComponent: r, scene: i, engine: a } = o;
|
|
13
16
|
return {
|
|
14
17
|
document: r,
|
|
15
18
|
scene: i,
|
|
16
19
|
engine: a
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
|
-
function
|
|
20
|
-
const t = e.getRenderById(
|
|
22
|
+
function Gn(s, e) {
|
|
23
|
+
const t = e.getRenderById(s);
|
|
21
24
|
if (t == null)
|
|
22
25
|
return;
|
|
23
|
-
const { mainComponent: n, scene:
|
|
26
|
+
const { mainComponent: n, scene: o, engine: r } = t;
|
|
24
27
|
return {
|
|
25
28
|
document: n,
|
|
26
|
-
scene:
|
|
29
|
+
scene: o,
|
|
27
30
|
engine: r
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
|
-
var
|
|
31
|
-
const
|
|
33
|
+
var kt = /* @__PURE__ */ ((s) => (s.MAIN = "__Document_Render_Main__", s))(kt || {}), jt = /* @__PURE__ */ ((s) => (s.VIEW_MAIN = "viewMain", s.VIEW_TOP = "viewTop", s.VIEW_LEFT = "viewLeft", s.VIEW_LEFT_TOP = "viewLeftTop", s))(jt || {});
|
|
34
|
+
const Hn = 0, Xn = 2, Yn = 10, Wn = "normalTextSelectionPluginName", ft = {
|
|
32
35
|
id: "doc.operation.set-selections",
|
|
33
36
|
type: v.OPERATION,
|
|
34
|
-
handler: (
|
|
37
|
+
handler: (s, e) => !0
|
|
35
38
|
};
|
|
36
|
-
var
|
|
37
|
-
for (var
|
|
38
|
-
(i =
|
|
39
|
-
return n &&
|
|
40
|
-
},
|
|
41
|
-
function
|
|
42
|
-
const { startOffset: e, endOffset: t, collapsed: n } =
|
|
39
|
+
var Gt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Xt = (s, e, t, n) => {
|
|
40
|
+
for (var o = n > 1 ? void 0 : n ? Ht(e, t) : e, r = s.length - 1, i; r >= 0; r--)
|
|
41
|
+
(i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
|
|
42
|
+
return n && o && Gt(e, t, o), o;
|
|
43
|
+
}, Je = (s, e) => (t, n) => e(t, n, s);
|
|
44
|
+
function Z(s) {
|
|
45
|
+
const { startOffset: e, endOffset: t, collapsed: n } = s, o = {
|
|
43
46
|
startOffset: e,
|
|
44
47
|
endOffset: t,
|
|
45
48
|
collapsed: n
|
|
46
49
|
};
|
|
47
|
-
return typeof
|
|
50
|
+
return typeof s.isActive == "function" && (o.isActive = s.isActive()), o;
|
|
48
51
|
}
|
|
49
|
-
let T = class extends
|
|
52
|
+
let T = class extends ge {
|
|
50
53
|
constructor(e, t) {
|
|
51
54
|
super();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
x(this, "_currentSelection", null);
|
|
56
|
+
x(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
|
|
57
|
+
x(this, "_textSelection$", new ee(null));
|
|
58
|
+
x(this, "textSelection$", this._textSelection$.asObservable());
|
|
56
59
|
this._textSelectionRenderManager = e, this._commandService = t, this._syncSelectionFromRenderService();
|
|
57
60
|
}
|
|
58
61
|
getCurrentSelection() {
|
|
@@ -83,7 +86,7 @@ let T = class extends ce {
|
|
|
83
86
|
const e = this._getTextRanges(this._currentSelection);
|
|
84
87
|
if (e == null)
|
|
85
88
|
return;
|
|
86
|
-
const { textRanges: t, segmentId: n, style:
|
|
89
|
+
const { textRanges: t, segmentId: n, style: o } = e, r = t.find((m) => m.isActive());
|
|
87
90
|
if (r == null)
|
|
88
91
|
return null;
|
|
89
92
|
const { startOffset: i, endOffset: a, collapsed: c, startNodePosition: d, endNodePosition: l, direction: u } = r;
|
|
@@ -95,7 +98,7 @@ let T = class extends ce {
|
|
|
95
98
|
endNodePosition: l,
|
|
96
99
|
direction: u,
|
|
97
100
|
segmentId: n,
|
|
98
|
-
style:
|
|
101
|
+
style: o
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
104
|
// **Only used in test case** because this does not go through the render layer.
|
|
@@ -105,7 +108,7 @@ let T = class extends ce {
|
|
|
105
108
|
textRanges: e,
|
|
106
109
|
segmentId: "",
|
|
107
110
|
isEditing: t,
|
|
108
|
-
style:
|
|
111
|
+
style: bt
|
|
109
112
|
// mock style.
|
|
110
113
|
});
|
|
111
114
|
}
|
|
@@ -114,7 +117,7 @@ let T = class extends ce {
|
|
|
114
117
|
}
|
|
115
118
|
// All textRanges should be synchronized from the render layer.
|
|
116
119
|
_syncSelectionFromRenderService() {
|
|
117
|
-
this._textSelectionRenderManager.textSelectionInner$.pipe(
|
|
120
|
+
this._textSelectionRenderManager.textSelectionInner$.pipe(te(this.dispose$)).subscribe((e) => {
|
|
118
121
|
e != null && this._replaceTextRangesWithNoRefresh(e);
|
|
119
122
|
});
|
|
120
123
|
}
|
|
@@ -126,44 +129,44 @@ let T = class extends ce {
|
|
|
126
129
|
...e
|
|
127
130
|
};
|
|
128
131
|
this._replaceByParam(t), this._textSelection$.next(t);
|
|
129
|
-
const { unitId: n, subUnitId:
|
|
130
|
-
this._commandService.executeCommand(
|
|
132
|
+
const { unitId: n, subUnitId: o, segmentId: r, style: i, textRanges: a, isEditing: c } = t;
|
|
133
|
+
this._commandService.executeCommand(ft.id, {
|
|
131
134
|
unitId: n,
|
|
132
|
-
subUnitId:
|
|
135
|
+
subUnitId: o,
|
|
133
136
|
segmentId: r,
|
|
134
137
|
style: i,
|
|
135
138
|
isEditing: c,
|
|
136
|
-
ranges: a.map(
|
|
139
|
+
ranges: a.map(Z)
|
|
137
140
|
});
|
|
138
141
|
}
|
|
139
142
|
_getTextRanges(e) {
|
|
140
|
-
var
|
|
143
|
+
var o;
|
|
141
144
|
if (e == null)
|
|
142
145
|
return;
|
|
143
146
|
const { unitId: t, subUnitId: n = "" } = e;
|
|
144
|
-
return (
|
|
147
|
+
return (o = this._textSelectionInfo.get(t)) == null ? void 0 : o.get(n);
|
|
145
148
|
}
|
|
146
149
|
_refresh(e) {
|
|
147
150
|
const t = this._getTextRanges(e);
|
|
148
|
-
this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(
|
|
151
|
+
this._textSelectionRenderManager.removeAllTextRanges(), t && Array.isArray(t.textRanges) && t.textRanges.length && this._textSelectionRenderManager.addTextRanges(t.textRanges.map(Z));
|
|
149
152
|
}
|
|
150
153
|
_replaceByParam(e) {
|
|
151
|
-
const { unitId: t, subUnitId: n, style:
|
|
152
|
-
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map()), this._textSelectionInfo.get(t).set(n, { textRanges: i, style:
|
|
154
|
+
const { unitId: t, subUnitId: n, style: o, segmentId: r, textRanges: i, isEditing: a } = e;
|
|
155
|
+
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map()), this._textSelectionInfo.get(t).set(n, { textRanges: i, style: o, segmentId: r, isEditing: a });
|
|
153
156
|
}
|
|
154
157
|
_addByParam(e) {
|
|
155
|
-
const { unitId: t, subUnitId: n, textRanges:
|
|
158
|
+
const { unitId: t, subUnitId: n, textRanges: o, style: r, segmentId: i, isEditing: a } = e;
|
|
156
159
|
this._textSelectionInfo.has(t) || this._textSelectionInfo.set(t, /* @__PURE__ */ new Map());
|
|
157
160
|
const c = this._textSelectionInfo.get(t);
|
|
158
|
-
c.has(n) ? c.get(n).textRanges.push(...
|
|
161
|
+
c.has(n) ? c.get(n).textRanges.push(...o) : c.set(n, { textRanges: o, style: r, segmentId: i, isEditing: a });
|
|
159
162
|
}
|
|
160
163
|
};
|
|
161
|
-
T =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
T = Xt([
|
|
165
|
+
Je(0, fe),
|
|
166
|
+
Je(1, I)
|
|
164
167
|
], T);
|
|
165
|
-
function
|
|
166
|
-
const { startOffset: n, endOffset:
|
|
168
|
+
function be(s, e = "", t = 0) {
|
|
169
|
+
const { startOffset: n, endOffset: o } = s, r = [], i = n - t, a = o - t;
|
|
167
170
|
return i > 0 && r.push({
|
|
168
171
|
t: y.RETAIN,
|
|
169
172
|
len: i,
|
|
@@ -175,18 +178,18 @@ function xe(o, e = "", t = 0) {
|
|
|
175
178
|
segmentId: e
|
|
176
179
|
}), r;
|
|
177
180
|
}
|
|
178
|
-
var
|
|
179
|
-
for (var
|
|
180
|
-
(i =
|
|
181
|
-
return n &&
|
|
182
|
-
},
|
|
183
|
-
let
|
|
181
|
+
var Yt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, Zt = (s, e, t, n) => {
|
|
182
|
+
for (var o = n > 1 ? void 0 : n ? Wt(e, t) : e, r = s.length - 1, i; r >= 0; r--)
|
|
183
|
+
(i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
|
|
184
|
+
return n && o && Yt(e, t, o), o;
|
|
185
|
+
}, Jt = (s, e) => (t, n) => e(t, n, s);
|
|
186
|
+
let ne = class extends ge {
|
|
184
187
|
constructor(e) {
|
|
185
188
|
super();
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.
|
|
189
|
+
x(this, "_docViewModelMap", /* @__PURE__ */ new Map());
|
|
190
|
+
x(this, "_currentDocViewModel$", new ee(null));
|
|
191
|
+
x(this, "currentDocViewModel$", this._currentDocViewModel$.asObservable());
|
|
192
|
+
this._univerInstanceService = e, this._initialize();
|
|
190
193
|
}
|
|
191
194
|
_initialize() {
|
|
192
195
|
this._init();
|
|
@@ -195,11 +198,11 @@ let q = class extends ce {
|
|
|
195
198
|
this._currentDocViewModel$.complete(), this._docViewModelMap.clear();
|
|
196
199
|
}
|
|
197
200
|
_init() {
|
|
198
|
-
this.
|
|
201
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(W.UNIVER_DOC).pipe(te(this.dispose$)).subscribe((e) => {
|
|
199
202
|
this._create(e);
|
|
200
|
-
}), this.
|
|
203
|
+
}), this._univerInstanceService.getAllUnitsForType(W.UNIVER_DOC).forEach((e) => {
|
|
201
204
|
this._create(e);
|
|
202
|
-
}), this.
|
|
205
|
+
}), this._univerInstanceService.getTypeOfUnitDisposed$(W.UNIVER_DOC).pipe(te(this.dispose$)).subscribe((e) => {
|
|
203
206
|
this._docViewModelMap.delete(e.getUnitId());
|
|
204
207
|
});
|
|
205
208
|
}
|
|
@@ -218,46 +221,46 @@ let q = class extends ce {
|
|
|
218
221
|
}
|
|
219
222
|
_setCurrent(e) {
|
|
220
223
|
var n;
|
|
221
|
-
const t = this.
|
|
224
|
+
const t = this._univerInstanceService.getUniverDocInstance(e);
|
|
222
225
|
if (t == null)
|
|
223
226
|
throw new Error(`Document data model with id ${e} not found when build view model.`);
|
|
224
227
|
if (t.getBody() != null) {
|
|
225
228
|
if (!this._docViewModelMap.has(e)) {
|
|
226
|
-
const
|
|
229
|
+
const o = this._buildDocViewModel(t);
|
|
227
230
|
this._docViewModelMap.set(e, {
|
|
228
231
|
unitId: e,
|
|
229
|
-
docViewModel:
|
|
232
|
+
docViewModel: o
|
|
230
233
|
});
|
|
231
234
|
}
|
|
232
|
-
if (e ===
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
235
|
+
if (e === dt) {
|
|
236
|
+
const o = (n = this._docViewModelMap.get(e)) == null ? void 0 : n.docViewModel;
|
|
237
|
+
if (o == null)
|
|
235
238
|
return;
|
|
236
|
-
|
|
239
|
+
o.reset(t);
|
|
237
240
|
}
|
|
238
241
|
this._currentDocViewModel$.next(this._docViewModelMap.get(e));
|
|
239
242
|
}
|
|
240
243
|
}
|
|
241
244
|
_buildDocViewModel(e) {
|
|
242
|
-
return new
|
|
245
|
+
return new Pt(e);
|
|
243
246
|
}
|
|
244
247
|
};
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
],
|
|
248
|
-
var
|
|
249
|
-
for (var
|
|
250
|
-
(i =
|
|
251
|
-
return n &&
|
|
252
|
-
},
|
|
253
|
-
const
|
|
254
|
-
let
|
|
248
|
+
ne = Zt([
|
|
249
|
+
Jt(0, E)
|
|
250
|
+
], ne);
|
|
251
|
+
var qt = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Qt = (s, e, t, n) => {
|
|
252
|
+
for (var o = n > 1 ? void 0 : n ? Kt(e, t) : e, r = s.length - 1, i; r >= 0; r--)
|
|
253
|
+
(i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
|
|
254
|
+
return n && o && qt(e, t, o), o;
|
|
255
|
+
}, Ce = (s, e) => (t, n) => e(t, n, s);
|
|
256
|
+
const en = 300;
|
|
257
|
+
let me = class extends ge {
|
|
255
258
|
constructor(e, t, n) {
|
|
256
259
|
super();
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
x(this, "_docStateChange$", new ee(null));
|
|
261
|
+
x(this, "docStateChange$", this._docStateChange$.asObservable());
|
|
262
|
+
x(this, "_stateCache", /* @__PURE__ */ new Map());
|
|
263
|
+
x(this, "_timer", null);
|
|
261
264
|
this._undoRedoService = e, this._commandService = t, this._univerInstanceService = n, this._initialize();
|
|
262
265
|
}
|
|
263
266
|
setChangeState(e) {
|
|
@@ -267,7 +270,7 @@ let ae = class extends ce {
|
|
|
267
270
|
_initialize() {
|
|
268
271
|
this.disposeWithMe(
|
|
269
272
|
this._commandService.beforeCommandExecuted((e) => {
|
|
270
|
-
if (e.id ===
|
|
273
|
+
if (e.id === Xe || e.id === Ye) {
|
|
271
274
|
const t = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
272
275
|
if (t == null)
|
|
273
276
|
return;
|
|
@@ -278,30 +281,30 @@ let ae = class extends ce {
|
|
|
278
281
|
);
|
|
279
282
|
}
|
|
280
283
|
_cacheChangeState(e) {
|
|
281
|
-
const { trigger: t, unitId: n, noHistory:
|
|
282
|
-
if (!(t ===
|
|
284
|
+
const { trigger: t, unitId: n, noHistory: o } = e;
|
|
285
|
+
if (!(t === Ye || t === Xe || o)) {
|
|
283
286
|
if (this._stateCache.has(n)) {
|
|
284
287
|
const r = this._stateCache.get(n);
|
|
285
288
|
r == null || r.push(e);
|
|
286
289
|
} else
|
|
287
290
|
this._stateCache.set(n, [e]);
|
|
288
|
-
t ===
|
|
291
|
+
t === pe.id || t === Se.id ? (this._timer && clearTimeout(this._timer), this._timer = setTimeout(() => {
|
|
289
292
|
this._pushHistory(n);
|
|
290
|
-
},
|
|
293
|
+
}, en)) : this._pushHistory(n);
|
|
291
294
|
}
|
|
292
295
|
}
|
|
293
296
|
_pushHistory(e) {
|
|
294
297
|
const t = this._undoRedoService, n = this._stateCache.get(e);
|
|
295
298
|
if (!Array.isArray(n) || n.length === 0)
|
|
296
299
|
return;
|
|
297
|
-
const
|
|
300
|
+
const o = n.length, r = n[0].commandId, i = n[0], a = n[o - 1], c = {
|
|
298
301
|
unitId: e,
|
|
299
|
-
actions: n.reduce((l, u) =>
|
|
302
|
+
actions: n.reduce((l, u) => P.compose(l, u.redoState.actions), []),
|
|
300
303
|
textRanges: a.redoState.textRanges
|
|
301
304
|
}, d = {
|
|
302
305
|
unitId: e,
|
|
303
306
|
// Always need to put undoParams after redoParams, because `reverse` will change the `cacheStates` order.
|
|
304
|
-
actions: n.reverse().reduce((l, u) =>
|
|
307
|
+
actions: n.reverse().reduce((l, u) => P.compose(l, u.undoState.actions), []),
|
|
305
308
|
textRanges: i.undoState.textRanges
|
|
306
309
|
};
|
|
307
310
|
t.pushUndoRedo({
|
|
@@ -311,16 +314,16 @@ let ae = class extends ce {
|
|
|
311
314
|
}), n.length = 0;
|
|
312
315
|
}
|
|
313
316
|
};
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
],
|
|
319
|
-
class
|
|
317
|
+
me = Qt([
|
|
318
|
+
Ce(0, V(Te)),
|
|
319
|
+
Ce(1, I),
|
|
320
|
+
Ce(2, E)
|
|
321
|
+
], me);
|
|
322
|
+
class he {
|
|
320
323
|
constructor() {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
+
x(this, "_previousActiveRange", null);
|
|
325
|
+
x(this, "_undoMutationParamsCache", []);
|
|
326
|
+
x(this, "_redoMutationParamsCache", []);
|
|
324
327
|
}
|
|
325
328
|
clearUndoRedoMutationParamsCache() {
|
|
326
329
|
this._undoMutationParamsCache = [], this._redoMutationParamsCache = [];
|
|
@@ -348,13 +351,13 @@ class de {
|
|
|
348
351
|
return null;
|
|
349
352
|
const { unitId: e } = this._undoMutationParamsCache[0], t = {
|
|
350
353
|
unitId: e,
|
|
351
|
-
actions: this._undoMutationParamsCache.reverse().reduce((
|
|
354
|
+
actions: this._undoMutationParamsCache.reverse().reduce((o, r) => P.compose(o, r.actions), []),
|
|
352
355
|
textRanges: []
|
|
353
356
|
// Add empty array, will never use, just fix type error
|
|
354
357
|
};
|
|
355
358
|
return { redoMutationParams: {
|
|
356
359
|
unitId: e,
|
|
357
|
-
actions: this._redoMutationParamsCache.reduce((
|
|
360
|
+
actions: this._redoMutationParamsCache.reduce((o, r) => P.compose(o, r.actions), []),
|
|
358
361
|
textRanges: []
|
|
359
362
|
// Add empty array, will never use, just fix type error
|
|
360
363
|
}, undoMutationParams: t, previousActiveRange: this._previousActiveRange };
|
|
@@ -363,189 +366,192 @@ class de {
|
|
|
363
366
|
this._undoMutationParamsCache = [], this._redoMutationParamsCache = [], this._previousActiveRange = null;
|
|
364
367
|
}
|
|
365
368
|
}
|
|
366
|
-
const
|
|
367
|
-
id:
|
|
369
|
+
const qe = "doc.mutation.rich-text-editing", L = {
|
|
370
|
+
id: qe,
|
|
368
371
|
type: v.MUTATION,
|
|
369
|
-
handler: (
|
|
370
|
-
var
|
|
372
|
+
handler: (s, e) => {
|
|
373
|
+
var B;
|
|
371
374
|
const {
|
|
372
375
|
unitId: t,
|
|
373
376
|
actions: n,
|
|
374
|
-
textRanges:
|
|
377
|
+
textRanges: o,
|
|
375
378
|
prevTextRanges: r,
|
|
376
379
|
trigger: i,
|
|
377
380
|
noHistory: a,
|
|
378
381
|
isCompositionEnd: c,
|
|
379
382
|
noNeedSetTextRange: d
|
|
380
|
-
} = e, u =
|
|
383
|
+
} = e, u = s.get(E).getUniverDocInstance(t), g = s.get(ne).getViewModel(t), p = s.get(T), f = ((B = p.getSelections()) != null ? B : []).map(Z), S = s.get(me), _ = s.get(he);
|
|
381
384
|
if (u == null || g == null)
|
|
382
385
|
throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${t}`);
|
|
383
|
-
const
|
|
384
|
-
if (n.length === 0 ||
|
|
386
|
+
const R = !!u.getSnapshot().disabled;
|
|
387
|
+
if (n.length === 0 || R)
|
|
385
388
|
return {
|
|
386
389
|
unitId: t,
|
|
387
390
|
actions: [],
|
|
388
391
|
textRanges: f
|
|
389
392
|
};
|
|
390
|
-
const
|
|
391
|
-
g.getSelfOrHeaderFooterViewModel(
|
|
392
|
-
p.replaceTextRanges(
|
|
393
|
+
const M = u.apply(n), { segmentId: C } = n[0], D = u.getSelfOrHeaderFooterModel(C);
|
|
394
|
+
g.getSelfOrHeaderFooterViewModel(C).reset(D), !d && o && i != null && queueMicrotask(() => {
|
|
395
|
+
p.replaceTextRanges(o);
|
|
393
396
|
});
|
|
394
|
-
const
|
|
395
|
-
commandId:
|
|
397
|
+
const b = {
|
|
398
|
+
commandId: qe,
|
|
396
399
|
unitId: t,
|
|
397
400
|
trigger: i,
|
|
398
401
|
noHistory: a,
|
|
399
402
|
redoState: {
|
|
400
403
|
actions: n,
|
|
401
|
-
textRanges:
|
|
404
|
+
textRanges: o
|
|
402
405
|
},
|
|
403
406
|
undoState: {
|
|
404
|
-
actions:
|
|
407
|
+
actions: M,
|
|
405
408
|
textRanges: r != null ? r : f
|
|
406
409
|
}
|
|
407
410
|
};
|
|
408
411
|
if (c) {
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
412
|
+
const O = _.fetchComposedUndoRedoMutationParams();
|
|
413
|
+
if (O == null)
|
|
411
414
|
throw new Error("historyParams is null in RichTextEditingMutation");
|
|
412
|
-
const { undoMutationParams:
|
|
413
|
-
|
|
415
|
+
const { undoMutationParams: U, redoMutationParams: w, previousActiveRange: X } = O;
|
|
416
|
+
b.redoState.actions = w.actions, b.undoState.actions = U.actions, b.undoState.textRanges = [X];
|
|
414
417
|
}
|
|
415
|
-
return S.setChangeState(
|
|
418
|
+
return S.setChangeState(b), {
|
|
416
419
|
unitId: t,
|
|
417
|
-
actions:
|
|
420
|
+
actions: M,
|
|
418
421
|
textRanges: f
|
|
419
422
|
};
|
|
420
423
|
}
|
|
421
|
-
},
|
|
424
|
+
}, pe = {
|
|
422
425
|
id: "doc.command.insert-text",
|
|
423
426
|
type: v.COMMAND,
|
|
424
|
-
handler: async (
|
|
425
|
-
const t =
|
|
426
|
-
id:
|
|
427
|
+
handler: async (s, e) => {
|
|
428
|
+
const t = s.get(I), { range: n, segmentId: o, body: r, unitId: i, textRanges: a } = e, { startOffset: c, collapsed: d } = n, l = {
|
|
429
|
+
id: L.id,
|
|
427
430
|
params: {
|
|
428
431
|
unitId: i,
|
|
429
432
|
actions: [],
|
|
430
433
|
textRanges: a
|
|
431
434
|
}
|
|
432
|
-
}, u = new
|
|
435
|
+
}, u = new P();
|
|
433
436
|
return d ? c > 0 && u.push({
|
|
434
437
|
t: y.RETAIN,
|
|
435
438
|
len: c,
|
|
436
|
-
segmentId:
|
|
437
|
-
}) : u.push(...
|
|
439
|
+
segmentId: o
|
|
440
|
+
}) : u.push(...be(n, o)), u.push({
|
|
438
441
|
t: y.INSERT,
|
|
439
442
|
body: r,
|
|
440
443
|
len: r.dataStream.length,
|
|
441
444
|
line: 0,
|
|
442
|
-
segmentId:
|
|
445
|
+
segmentId: o
|
|
443
446
|
}), l.params.actions = u.serialize(), !!t.syncExecuteCommand(l.id, l.params);
|
|
444
447
|
}
|
|
445
448
|
};
|
|
446
|
-
var
|
|
447
|
-
const
|
|
449
|
+
var G = /* @__PURE__ */ ((s) => (s[s.LEFT = 0] = "LEFT", s[s.RIGHT = 1] = "RIGHT", s))(G || {});
|
|
450
|
+
const Se = {
|
|
448
451
|
id: "doc.command.delete-text",
|
|
449
452
|
type: v.COMMAND,
|
|
450
|
-
handler: async (
|
|
451
|
-
const t =
|
|
452
|
-
id:
|
|
453
|
+
handler: async (s, e) => {
|
|
454
|
+
const t = s.get(I), { range: n, segmentId: o, unitId: r, direction: i, textRanges: a, len: c = 1 } = e, { startOffset: d } = n, l = {
|
|
455
|
+
id: L.id,
|
|
453
456
|
params: {
|
|
454
457
|
unitId: r,
|
|
455
458
|
actions: [],
|
|
456
459
|
textRanges: a
|
|
457
460
|
}
|
|
458
|
-
}, u = new
|
|
461
|
+
}, u = new P();
|
|
459
462
|
return d > 0 && u.push({
|
|
460
463
|
t: y.RETAIN,
|
|
461
464
|
len: i === 0 ? d - c : d,
|
|
462
|
-
segmentId:
|
|
465
|
+
segmentId: o
|
|
463
466
|
}), u.push({
|
|
464
467
|
t: y.DELETE,
|
|
465
468
|
len: c,
|
|
466
469
|
line: 0,
|
|
467
|
-
segmentId:
|
|
470
|
+
segmentId: o
|
|
468
471
|
}), l.params.actions = u.serialize(), !!t.syncExecuteCommand(l.id, l.params);
|
|
469
472
|
}
|
|
470
|
-
},
|
|
473
|
+
}, ht = {
|
|
471
474
|
id: "doc.command.update-text",
|
|
472
475
|
type: v.COMMAND,
|
|
473
|
-
handler: async (
|
|
474
|
-
const { range: t, segmentId: n, updateBody:
|
|
475
|
-
id:
|
|
476
|
+
handler: async (s, e) => {
|
|
477
|
+
const { range: t, segmentId: n, updateBody: o, coverType: r, unitId: i, textRanges: a } = e, c = s.get(I), d = {
|
|
478
|
+
id: L.id,
|
|
476
479
|
params: {
|
|
477
480
|
unitId: i,
|
|
478
481
|
actions: [],
|
|
479
482
|
textRanges: a
|
|
480
483
|
}
|
|
481
|
-
}, l = new
|
|
484
|
+
}, l = new P(), { startOffset: u, endOffset: m } = t;
|
|
482
485
|
return l.push({
|
|
483
486
|
t: y.RETAIN,
|
|
484
487
|
len: u,
|
|
485
488
|
segmentId: n
|
|
486
489
|
}), l.push({
|
|
487
490
|
t: y.RETAIN,
|
|
488
|
-
body:
|
|
491
|
+
body: o,
|
|
489
492
|
len: m - u,
|
|
490
493
|
segmentId: n,
|
|
491
494
|
coverType: r
|
|
492
495
|
}), d.params.actions = l.serialize(), !!c.syncExecuteCommand(d.id, d.params);
|
|
493
496
|
}
|
|
494
497
|
};
|
|
495
|
-
function
|
|
498
|
+
function tn(s, e) {
|
|
496
499
|
const t = [];
|
|
497
|
-
for (let n = 0,
|
|
498
|
-
|
|
500
|
+
for (let n = 0, o = s.length; n < o; n++)
|
|
501
|
+
s[n] === xe.PARAGRAPH && t.push({
|
|
499
502
|
startIndex: n
|
|
500
503
|
});
|
|
501
504
|
if (e)
|
|
502
505
|
for (const n of t)
|
|
503
|
-
e.bullet && (n.bullet =
|
|
506
|
+
e.bullet && (n.bullet = Q.deepClone(e.bullet)), e.paragraphStyle && (n.paragraphStyle = Q.deepClone(e.paragraphStyle));
|
|
504
507
|
return t;
|
|
505
508
|
}
|
|
506
|
-
const
|
|
509
|
+
const nn = {
|
|
507
510
|
id: "doc.command.break-line",
|
|
508
511
|
type: v.COMMAND,
|
|
509
|
-
handler: async (
|
|
512
|
+
handler: async (s) => {
|
|
510
513
|
var p, h;
|
|
511
|
-
const e =
|
|
512
|
-
if (
|
|
514
|
+
const e = s.get(T), t = s.get(E), n = s.get(I), o = e.getActiveRange();
|
|
515
|
+
if (o == null)
|
|
516
|
+
return !1;
|
|
517
|
+
const r = t.getCurrentUniverDocInstance();
|
|
518
|
+
if (!r)
|
|
513
519
|
return !1;
|
|
514
|
-
const
|
|
520
|
+
const i = r.getUnitId(), { startOffset: a, segmentId: c, style: d } = o, l = [
|
|
515
521
|
{
|
|
516
522
|
startOffset: a + 1,
|
|
517
523
|
endOffset: a + 1,
|
|
518
524
|
style: d
|
|
519
525
|
}
|
|
520
526
|
], m = ((h = (p = r.getBody()) == null ? void 0 : p.paragraphs) != null ? h : []).find((f) => f.startIndex >= a);
|
|
521
|
-
return await n.executeCommand(
|
|
527
|
+
return await n.executeCommand(pe.id, {
|
|
522
528
|
unitId: i,
|
|
523
529
|
body: {
|
|
524
|
-
dataStream:
|
|
525
|
-
paragraphs:
|
|
530
|
+
dataStream: xe.PARAGRAPH,
|
|
531
|
+
paragraphs: tn(xe.PARAGRAPH, m)
|
|
526
532
|
},
|
|
527
|
-
range:
|
|
533
|
+
range: o,
|
|
528
534
|
textRanges: l,
|
|
529
535
|
segmentId: c
|
|
530
536
|
});
|
|
531
537
|
}
|
|
532
538
|
};
|
|
533
|
-
var
|
|
534
|
-
for (var
|
|
535
|
-
(i =
|
|
536
|
-
return n &&
|
|
537
|
-
},
|
|
538
|
-
let
|
|
539
|
+
var sn = Object.defineProperty, on = Object.getOwnPropertyDescriptor, rn = (s, e, t, n) => {
|
|
540
|
+
for (var o = n > 1 ? void 0 : n ? on(e, t) : e, r = s.length - 1, i; r >= 0; r--)
|
|
541
|
+
(i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
|
|
542
|
+
return n && o && sn(e, t, o), o;
|
|
543
|
+
}, Re = (s, e) => (t, n) => e(t, n, s);
|
|
544
|
+
let H = class extends ge {
|
|
539
545
|
constructor(e, t, n) {
|
|
540
546
|
super();
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
547
|
+
x(this, "_currentSkeletonUnitId", "");
|
|
548
|
+
x(this, "_docSkeletonMap", /* @__PURE__ */ new Map());
|
|
549
|
+
x(this, "_currentSkeleton$", new ee(null));
|
|
550
|
+
x(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
|
|
545
551
|
// CurrentSkeletonBefore for pre-triggered logic during registration
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
this._localeService = e, this._docViewModelManagerService = t, this.
|
|
552
|
+
x(this, "_currentSkeletonBefore$", new ee(null));
|
|
553
|
+
x(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
|
|
554
|
+
this._localeService = e, this._docViewModelManagerService = t, this._univerInstanceService = n, this._initialize();
|
|
549
555
|
}
|
|
550
556
|
_initialize() {
|
|
551
557
|
this._init();
|
|
@@ -554,12 +560,13 @@ let j = class extends ce {
|
|
|
554
560
|
this._currentSkeletonBefore$.complete(), this._currentSkeleton$.complete(), this._docSkeletonMap.clear();
|
|
555
561
|
}
|
|
556
562
|
_init() {
|
|
557
|
-
this._docViewModelManagerService.currentDocViewModel$.pipe(
|
|
563
|
+
this._docViewModelManagerService.currentDocViewModel$.pipe(te(this.dispose$)).subscribe((e) => {
|
|
558
564
|
e != null && this._setCurrent(e);
|
|
559
565
|
}), this._docViewModelManagerService.getAllModel().forEach((e) => {
|
|
560
566
|
e != null && this._setCurrent(e);
|
|
561
|
-
}), this.
|
|
562
|
-
|
|
567
|
+
}), this._univerInstanceService.getTypeOfUnitDisposed$(W.UNIVER_DOC).pipe(te(this.dispose$)).subscribe((e) => {
|
|
568
|
+
var t, n;
|
|
569
|
+
this._docSkeletonMap.delete(e.getUnitId()), this._currentSkeletonUnitId = (n = (t = this._univerInstanceService.getCurrentUnitForType(W.UNIVER_DOC)) == null ? void 0 : t.getUnitId()) != null ? n : "";
|
|
563
570
|
});
|
|
564
571
|
}
|
|
565
572
|
getCurrent() {
|
|
@@ -594,38 +601,41 @@ let j = class extends ce {
|
|
|
594
601
|
return this._currentSkeletonUnitId = t, this._currentSkeletonBefore$.next(this.getCurrent()), this._currentSkeleton$.next(this.getCurrent()), this.getCurrent();
|
|
595
602
|
}
|
|
596
603
|
_buildSkeleton(e) {
|
|
597
|
-
return
|
|
604
|
+
return Ut.create(e, this._localeService);
|
|
598
605
|
}
|
|
599
606
|
};
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
],
|
|
605
|
-
const
|
|
607
|
+
H = rn([
|
|
608
|
+
Re(0, V(Tt)),
|
|
609
|
+
Re(1, V(ne)),
|
|
610
|
+
Re(2, E)
|
|
611
|
+
], H);
|
|
612
|
+
const Zn = {
|
|
606
613
|
id: "doc.command.inner-paste",
|
|
607
614
|
type: v.COMMAND,
|
|
608
|
-
handler: async (
|
|
609
|
-
const { segmentId: t, body: n, textRanges:
|
|
615
|
+
handler: async (s, e) => {
|
|
616
|
+
const { segmentId: t, body: n, textRanges: o } = e, r = s.get(I), i = s.get(T), a = s.get(E), c = i.getSelections();
|
|
610
617
|
if (!Array.isArray(c) || c.length === 0)
|
|
611
618
|
return !1;
|
|
612
|
-
const
|
|
613
|
-
|
|
619
|
+
const d = a.getCurrentUniverDocInstance();
|
|
620
|
+
if (!d)
|
|
621
|
+
return !1;
|
|
622
|
+
const l = d.getUnitId(), u = {
|
|
623
|
+
id: L.id,
|
|
614
624
|
params: {
|
|
615
625
|
unitId: l,
|
|
616
626
|
actions: [],
|
|
617
|
-
textRanges:
|
|
627
|
+
textRanges: o
|
|
618
628
|
}
|
|
619
|
-
}, m = new
|
|
629
|
+
}, m = new oe();
|
|
620
630
|
m.reset();
|
|
621
|
-
const g = new
|
|
631
|
+
const g = new P();
|
|
622
632
|
for (const h of c) {
|
|
623
|
-
const { startOffset: f, endOffset: S, collapsed: _ } = h,
|
|
633
|
+
const { startOffset: f, endOffset: S, collapsed: _ } = h, R = f - m.cursor;
|
|
624
634
|
_ ? g.push({
|
|
625
635
|
t: y.RETAIN,
|
|
626
|
-
len:
|
|
636
|
+
len: R,
|
|
627
637
|
segmentId: t
|
|
628
|
-
}) : g.push(...
|
|
638
|
+
}) : g.push(...be(h, t, m.cursor)), g.push({
|
|
629
639
|
t: y.INSERT,
|
|
630
640
|
body: n,
|
|
631
641
|
len: n.dataStream.length,
|
|
@@ -635,39 +645,43 @@ const Un = {
|
|
|
635
645
|
}
|
|
636
646
|
return u.params.actions = g.serialize(), !!r.syncExecuteCommand(u.id, u.params);
|
|
637
647
|
}
|
|
638
|
-
},
|
|
648
|
+
}, pt = {
|
|
639
649
|
id: "doc.command.inner-cut",
|
|
640
650
|
type: v.COMMAND,
|
|
641
|
-
handler: async (
|
|
642
|
-
|
|
651
|
+
handler: async (s, e) => {
|
|
652
|
+
var h;
|
|
653
|
+
const { segmentId: t, textRanges: n } = e, o = s.get(I), r = s.get(T), i = s.get(E), a = r.getSelections();
|
|
643
654
|
if (!Array.isArray(a) || a.length === 0)
|
|
644
655
|
return !1;
|
|
645
|
-
const c = i.getCurrentUniverDocInstance()
|
|
656
|
+
const c = (h = i.getCurrentUniverDocInstance()) == null ? void 0 : h.getUnitId();
|
|
657
|
+
if (!c)
|
|
658
|
+
return !1;
|
|
659
|
+
const d = i.getUniverDocInstance(c), l = Et(d.snapshot, t);
|
|
646
660
|
if (l == null)
|
|
647
661
|
return !1;
|
|
648
662
|
const u = {
|
|
649
|
-
id:
|
|
663
|
+
id: L.id,
|
|
650
664
|
params: {
|
|
651
665
|
unitId: c,
|
|
652
666
|
actions: [],
|
|
653
667
|
textRanges: n
|
|
654
668
|
}
|
|
655
|
-
}, m = new
|
|
669
|
+
}, m = new oe();
|
|
656
670
|
m.reset();
|
|
657
|
-
const g = new
|
|
658
|
-
for (const
|
|
659
|
-
const { startOffset:
|
|
660
|
-
|
|
671
|
+
const g = new P();
|
|
672
|
+
for (const f of a) {
|
|
673
|
+
const { startOffset: S, endOffset: _, collapsed: R } = f, M = S - m.cursor;
|
|
674
|
+
R ? g.push({
|
|
661
675
|
t: y.RETAIN,
|
|
662
|
-
len:
|
|
676
|
+
len: M,
|
|
663
677
|
segmentId: t
|
|
664
|
-
}) : g.push(...
|
|
678
|
+
}) : g.push(...an(f, l, t, m.cursor)), m.reset(), m.moveCursor(_);
|
|
665
679
|
}
|
|
666
|
-
return u.params.actions = g.serialize(), !!
|
|
680
|
+
return u.params.actions = g.serialize(), !!o.syncExecuteCommand(u.id, u.params);
|
|
667
681
|
}
|
|
668
682
|
};
|
|
669
|
-
function
|
|
670
|
-
const { startOffset:
|
|
683
|
+
function an(s, e, t = "", n = 0) {
|
|
684
|
+
const { startOffset: o, endOffset: r } = s, i = [], { paragraphs: a = [] } = e, c = o - n, d = r - n, l = a == null ? void 0 : a.find(
|
|
671
685
|
(u) => u.startIndex - n >= c && u.startIndex - n <= d
|
|
672
686
|
);
|
|
673
687
|
if (c > 0 && i.push({
|
|
@@ -700,103 +714,113 @@ function Gt(o, e, t = "", n = 0) {
|
|
|
700
714
|
});
|
|
701
715
|
return i;
|
|
702
716
|
}
|
|
703
|
-
const
|
|
717
|
+
const cn = {
|
|
704
718
|
id: "doc.command.delete-left",
|
|
705
719
|
type: v.COMMAND,
|
|
706
|
-
handler: async (
|
|
707
|
-
var
|
|
708
|
-
const e =
|
|
720
|
+
handler: async (s) => {
|
|
721
|
+
var M;
|
|
722
|
+
const e = s.get(T), t = s.get(H), n = s.get(E), o = s.get(I), r = e.getActiveRange(), i = e.getSelections(), a = (M = t.getCurrent()) == null ? void 0 : M.skeleton;
|
|
709
723
|
let c = !0;
|
|
710
724
|
if (r == null || a == null || i == null)
|
|
711
725
|
return !1;
|
|
712
|
-
const d = n.getCurrentUniverDocInstance()
|
|
726
|
+
const d = n.getCurrentUniverDocInstance();
|
|
727
|
+
if (!d)
|
|
728
|
+
return !1;
|
|
729
|
+
const { startOffset: l, collapsed: u, segmentId: m, style: g } = r, p = a.findNodeByCharIndex(l), h = wt(p), f = Lt(p, d.getBody());
|
|
713
730
|
let S = l;
|
|
714
731
|
const _ = a.findNodeByCharIndex(l - 1);
|
|
715
|
-
if (
|
|
716
|
-
const
|
|
717
|
-
if (
|
|
732
|
+
if (Bt(p) && _ !== p && (h === !0 || f === !0)) {
|
|
733
|
+
const C = Ft(p, d.getBody());
|
|
734
|
+
if (C == null)
|
|
718
735
|
return !1;
|
|
719
|
-
const
|
|
736
|
+
const D = C == null ? void 0 : C.startIndex, A = { startIndex: 0 }, b = C.paragraphStyle;
|
|
720
737
|
if (h === !0) {
|
|
721
|
-
const
|
|
722
|
-
|
|
738
|
+
const O = C.paragraphStyle;
|
|
739
|
+
if (O) {
|
|
740
|
+
A.paragraphStyle = O;
|
|
741
|
+
const { hanging: U } = O;
|
|
742
|
+
U && (A.paragraphStyle.indentStart = U, A.paragraphStyle.hanging = void 0);
|
|
743
|
+
}
|
|
723
744
|
} else if (f === !0) {
|
|
724
|
-
const
|
|
725
|
-
|
|
745
|
+
const O = C.bullet;
|
|
746
|
+
O && (A.bullet = O), b != null && (A.paragraphStyle = { ...b }, delete A.paragraphStyle.hanging, delete A.paragraphStyle.indentStart);
|
|
726
747
|
}
|
|
727
|
-
const
|
|
748
|
+
const B = [
|
|
728
749
|
{
|
|
729
750
|
startOffset: S,
|
|
730
751
|
endOffset: S,
|
|
731
752
|
style: g
|
|
732
753
|
}
|
|
733
754
|
];
|
|
734
|
-
c = await
|
|
755
|
+
c = await o.executeCommand(ht.id, {
|
|
735
756
|
unitId: d.getUnitId(),
|
|
736
757
|
updateBody: {
|
|
737
758
|
dataStream: "",
|
|
738
|
-
paragraphs: [{ ...
|
|
759
|
+
paragraphs: [{ ...A }]
|
|
739
760
|
},
|
|
740
761
|
range: {
|
|
741
|
-
startOffset:
|
|
742
|
-
endOffset:
|
|
762
|
+
startOffset: D,
|
|
763
|
+
endOffset: D + 1
|
|
743
764
|
},
|
|
744
|
-
textRanges:
|
|
745
|
-
coverType:
|
|
765
|
+
textRanges: B,
|
|
766
|
+
coverType: Ee.REPLACE,
|
|
746
767
|
segmentId: m
|
|
747
768
|
});
|
|
748
769
|
} else if (u === !0) {
|
|
749
770
|
if (_ == null)
|
|
750
771
|
return !0;
|
|
751
772
|
if (_.content === "\r")
|
|
752
|
-
c = await
|
|
753
|
-
direction:
|
|
773
|
+
c = await o.executeCommand(Pe.id, {
|
|
774
|
+
direction: G.LEFT,
|
|
754
775
|
range: r
|
|
755
776
|
});
|
|
756
777
|
else {
|
|
757
778
|
S -= _.count;
|
|
758
|
-
const
|
|
779
|
+
const C = [
|
|
759
780
|
{
|
|
760
781
|
startOffset: S,
|
|
761
782
|
endOffset: S,
|
|
762
783
|
style: g
|
|
763
784
|
}
|
|
764
785
|
];
|
|
765
|
-
c = await
|
|
786
|
+
c = await o.executeCommand(Se.id, {
|
|
766
787
|
unitId: d.getUnitId(),
|
|
767
788
|
range: r,
|
|
768
789
|
segmentId: m,
|
|
769
|
-
direction:
|
|
790
|
+
direction: G.LEFT,
|
|
770
791
|
len: _.count,
|
|
771
|
-
textRanges:
|
|
792
|
+
textRanges: C
|
|
772
793
|
});
|
|
773
794
|
}
|
|
774
795
|
} else {
|
|
775
|
-
const
|
|
776
|
-
c = await
|
|
796
|
+
const C = St(r, i);
|
|
797
|
+
c = await o.executeCommand(pt.id, {
|
|
777
798
|
segmentId: m,
|
|
778
|
-
textRanges:
|
|
799
|
+
textRanges: C
|
|
779
800
|
});
|
|
780
801
|
}
|
|
781
802
|
return c;
|
|
782
803
|
}
|
|
783
|
-
},
|
|
804
|
+
}, ln = {
|
|
784
805
|
id: "doc.command.delete-right",
|
|
785
806
|
type: v.COMMAND,
|
|
786
|
-
handler: async (
|
|
807
|
+
handler: async (s) => {
|
|
787
808
|
var p;
|
|
788
|
-
const e =
|
|
809
|
+
const e = s.get(T), t = s.get(H), n = s.get(E), o = s.get(I), r = e.getActiveRange(), i = e.getSelections(), a = (p = t.getCurrent()) == null ? void 0 : p.skeleton;
|
|
789
810
|
let c;
|
|
790
811
|
if (r == null || a == null || i == null)
|
|
791
812
|
return !1;
|
|
792
|
-
const d = n.getCurrentUniverDocInstance()
|
|
813
|
+
const d = n.getCurrentUniverDocInstance();
|
|
814
|
+
if (!d)
|
|
815
|
+
return !1;
|
|
816
|
+
const { startOffset: l, collapsed: u, segmentId: m, style: g } = r;
|
|
793
817
|
if (l === d.getBody().dataStream.length - 2 && u)
|
|
794
818
|
return !0;
|
|
795
819
|
if (u === !0) {
|
|
796
820
|
const h = a.findNodeByCharIndex(l);
|
|
797
821
|
if (h.content === "\r")
|
|
798
|
-
c = await
|
|
799
|
-
direction:
|
|
822
|
+
c = await o.executeCommand(Pe.id, {
|
|
823
|
+
direction: G.RIGHT,
|
|
800
824
|
range: r
|
|
801
825
|
});
|
|
802
826
|
else {
|
|
@@ -807,77 +831,80 @@ const Ht = {
|
|
|
807
831
|
style: g
|
|
808
832
|
}
|
|
809
833
|
];
|
|
810
|
-
c = await
|
|
834
|
+
c = await o.executeCommand(Se.id, {
|
|
811
835
|
unitId: d.getUnitId(),
|
|
812
836
|
range: r,
|
|
813
837
|
segmentId: m,
|
|
814
|
-
direction:
|
|
838
|
+
direction: G.RIGHT,
|
|
815
839
|
textRanges: f,
|
|
816
840
|
len: h.count
|
|
817
841
|
});
|
|
818
842
|
}
|
|
819
843
|
} else {
|
|
820
|
-
const h =
|
|
821
|
-
c = await
|
|
844
|
+
const h = St(r, i);
|
|
845
|
+
c = await o.executeCommand(pt.id, {
|
|
822
846
|
segmentId: m,
|
|
823
847
|
textRanges: h
|
|
824
848
|
});
|
|
825
849
|
}
|
|
826
850
|
return c;
|
|
827
851
|
}
|
|
828
|
-
},
|
|
852
|
+
}, Pe = {
|
|
829
853
|
id: "doc.command.merge-two-paragraph",
|
|
830
854
|
type: v.COMMAND,
|
|
831
|
-
handler: async (
|
|
832
|
-
var
|
|
833
|
-
const t =
|
|
855
|
+
handler: async (s, e) => {
|
|
856
|
+
var A, b, B;
|
|
857
|
+
const t = s.get(T), n = s.get(E), o = s.get(I), { direction: r, range: i } = e, a = t.getActiveRange(), c = t.getSelections();
|
|
834
858
|
if (a == null || c == null)
|
|
835
859
|
return !1;
|
|
836
|
-
const d = n.getCurrentUniverDocInstance()
|
|
860
|
+
const d = n.getCurrentUniverDocInstance();
|
|
861
|
+
if (!d)
|
|
862
|
+
return !1;
|
|
863
|
+
const { startOffset: l, collapsed: u, segmentId: m, style: g } = a;
|
|
837
864
|
if (!u)
|
|
838
865
|
return !1;
|
|
839
|
-
const p = r ===
|
|
866
|
+
const p = r === G.LEFT ? l : l + 1, h = (B = (b = (A = d.getBody()) == null ? void 0 : A.paragraphs) == null ? void 0 : b.find((O) => O.startIndex >= p)) == null ? void 0 : B.startIndex, f = dn(d.getBody(), p, h), S = r === G.LEFT ? l - 1 : l, _ = d.getUnitId(), R = [
|
|
840
867
|
{
|
|
841
868
|
startOffset: S,
|
|
842
869
|
endOffset: S,
|
|
843
870
|
style: g
|
|
844
871
|
}
|
|
845
|
-
],
|
|
846
|
-
id:
|
|
872
|
+
], M = {
|
|
873
|
+
id: L.id,
|
|
847
874
|
params: {
|
|
848
875
|
unitId: _,
|
|
849
876
|
actions: [],
|
|
850
|
-
textRanges:
|
|
877
|
+
textRanges: R,
|
|
851
878
|
prevTextRanges: [i]
|
|
852
879
|
}
|
|
853
|
-
},
|
|
854
|
-
return
|
|
880
|
+
}, C = new P();
|
|
881
|
+
return C.push({
|
|
855
882
|
t: y.RETAIN,
|
|
856
|
-
len: r ===
|
|
883
|
+
len: r === G.LEFT ? l - 1 : l,
|
|
857
884
|
segmentId: m
|
|
858
|
-
}), f.dataStream.length &&
|
|
885
|
+
}), f.dataStream.length && C.push({
|
|
859
886
|
t: y.INSERT,
|
|
860
887
|
body: f,
|
|
861
888
|
len: f.dataStream.length,
|
|
862
889
|
line: 0,
|
|
863
890
|
segmentId: m
|
|
864
|
-
}),
|
|
891
|
+
}), C.push({
|
|
865
892
|
t: y.RETAIN,
|
|
866
893
|
len: 1,
|
|
867
894
|
segmentId: m
|
|
868
|
-
}),
|
|
895
|
+
}), C.push({
|
|
869
896
|
t: y.DELETE,
|
|
870
897
|
len: h + 1 - p,
|
|
871
898
|
line: 0,
|
|
872
899
|
segmentId: m
|
|
873
|
-
}),
|
|
900
|
+
}), M.params.actions = C.serialize(), !!o.syncExecuteCommand(M.id, M.params);
|
|
874
901
|
}
|
|
875
902
|
};
|
|
876
|
-
function
|
|
877
|
-
const { textRuns: n } =
|
|
903
|
+
function dn(s, e, t) {
|
|
904
|
+
const { textRuns: n } = s, o = s.dataStream.substring(e, t);
|
|
878
905
|
if (n == null)
|
|
879
906
|
return {
|
|
880
|
-
dataStream:
|
|
907
|
+
dataStream: o
|
|
881
908
|
};
|
|
882
909
|
const r = [];
|
|
883
910
|
for (const i of n) {
|
|
@@ -897,29 +924,29 @@ function Yt(o, e, t) {
|
|
|
897
924
|
}));
|
|
898
925
|
}
|
|
899
926
|
return {
|
|
900
|
-
dataStream:
|
|
927
|
+
dataStream: o,
|
|
901
928
|
textRuns: r
|
|
902
929
|
};
|
|
903
930
|
}
|
|
904
|
-
function
|
|
905
|
-
let t =
|
|
906
|
-
for (const
|
|
907
|
-
const { startOffset: r, endOffset: i } =
|
|
908
|
-
r == null || i == null || i <=
|
|
931
|
+
function St(s, e) {
|
|
932
|
+
let t = s.endOffset;
|
|
933
|
+
for (const o of e) {
|
|
934
|
+
const { startOffset: r, endOffset: i } = o;
|
|
935
|
+
r == null || i == null || i <= s.endOffset && (t -= i - r);
|
|
909
936
|
}
|
|
910
937
|
return [
|
|
911
938
|
{
|
|
912
939
|
startOffset: t,
|
|
913
940
|
endOffset: t,
|
|
914
|
-
style:
|
|
941
|
+
style: s.style
|
|
915
942
|
}
|
|
916
943
|
];
|
|
917
944
|
}
|
|
918
|
-
const
|
|
945
|
+
const _t = {
|
|
919
946
|
id: "doc.command.ime-input",
|
|
920
947
|
type: v.COMMAND,
|
|
921
|
-
handler: async (
|
|
922
|
-
const { unitId: t, newText: n, oldTextLen:
|
|
948
|
+
handler: async (s, e) => {
|
|
949
|
+
const { unitId: t, newText: n, oldTextLen: o, isCompositionEnd: r, isCompositionStart: i } = e, a = s.get(I), c = s.get(he), d = c.getActiveRange();
|
|
923
950
|
if (d == null)
|
|
924
951
|
return !1;
|
|
925
952
|
const { startOffset: l, style: u, segmentId: m } = d, g = n.length, p = [
|
|
@@ -930,20 +957,20 @@ const rt = {
|
|
|
930
957
|
style: u
|
|
931
958
|
}
|
|
932
959
|
], h = {
|
|
933
|
-
id:
|
|
960
|
+
id: L.id,
|
|
934
961
|
params: {
|
|
935
962
|
unitId: t,
|
|
936
963
|
actions: [],
|
|
937
964
|
textRanges: p
|
|
938
965
|
}
|
|
939
|
-
}, f = new
|
|
940
|
-
!d.collapsed && i ? f.push(...
|
|
966
|
+
}, f = new P();
|
|
967
|
+
!d.collapsed && i ? f.push(...be(d, m)) : f.push({
|
|
941
968
|
t: y.RETAIN,
|
|
942
969
|
len: l,
|
|
943
970
|
segmentId: m
|
|
944
|
-
}),
|
|
971
|
+
}), o > 0 && f.push({
|
|
945
972
|
t: y.DELETE,
|
|
946
|
-
len:
|
|
973
|
+
len: o,
|
|
947
974
|
line: 0,
|
|
948
975
|
segmentId: m
|
|
949
976
|
}), f.push({
|
|
@@ -959,200 +986,236 @@ const rt = {
|
|
|
959
986
|
return c.pushUndoRedoMutationParams(S, h.params), !!S;
|
|
960
987
|
}
|
|
961
988
|
};
|
|
962
|
-
function F(
|
|
989
|
+
function F(s, e, t, n) {
|
|
963
990
|
var r;
|
|
964
|
-
const { segmentId:
|
|
965
|
-
return
|
|
966
|
-
segmentId:
|
|
967
|
-
preCommandId:
|
|
991
|
+
const { segmentId: o } = (r = t.getActiveRange()) != null ? r : {};
|
|
992
|
+
return o == null ? !1 : n.executeCommand(It.id, {
|
|
993
|
+
segmentId: o,
|
|
994
|
+
preCommandId: s,
|
|
968
995
|
...e != null ? e : {}
|
|
969
996
|
});
|
|
970
997
|
}
|
|
971
|
-
const
|
|
972
|
-
id:
|
|
998
|
+
const Ke = "doc.command.set-inline-format-bold", Ue = {
|
|
999
|
+
id: Ke,
|
|
973
1000
|
type: v.COMMAND,
|
|
974
|
-
handler: async (
|
|
975
|
-
const t =
|
|
1001
|
+
handler: async (s, e) => {
|
|
1002
|
+
const t = s.get(I), n = s.get(T);
|
|
976
1003
|
return F(
|
|
977
|
-
|
|
1004
|
+
Ke,
|
|
978
1005
|
e,
|
|
979
1006
|
n,
|
|
980
1007
|
t
|
|
981
1008
|
);
|
|
982
1009
|
}
|
|
983
|
-
},
|
|
984
|
-
id:
|
|
1010
|
+
}, Qe = "doc.command.set-inline-format-italic", we = {
|
|
1011
|
+
id: Qe,
|
|
985
1012
|
type: v.COMMAND,
|
|
986
|
-
handler: async (
|
|
987
|
-
const t =
|
|
1013
|
+
handler: async (s, e) => {
|
|
1014
|
+
const t = s.get(I), n = s.get(T);
|
|
988
1015
|
return F(
|
|
989
|
-
|
|
1016
|
+
Qe,
|
|
990
1017
|
e,
|
|
991
1018
|
n,
|
|
992
1019
|
t
|
|
993
1020
|
);
|
|
994
1021
|
}
|
|
995
|
-
},
|
|
996
|
-
id:
|
|
1022
|
+
}, et = "doc.command.set-inline-format-underline", Le = {
|
|
1023
|
+
id: et,
|
|
997
1024
|
type: v.COMMAND,
|
|
998
|
-
handler: async (
|
|
999
|
-
const t =
|
|
1025
|
+
handler: async (s, e) => {
|
|
1026
|
+
const t = s.get(I), n = s.get(T);
|
|
1000
1027
|
return F(
|
|
1001
|
-
|
|
1028
|
+
et,
|
|
1002
1029
|
e,
|
|
1003
1030
|
n,
|
|
1004
1031
|
t
|
|
1005
1032
|
);
|
|
1006
1033
|
}
|
|
1007
|
-
},
|
|
1008
|
-
id:
|
|
1034
|
+
}, tt = "doc.command.set-inline-format-strikethrough", Be = {
|
|
1035
|
+
id: tt,
|
|
1009
1036
|
type: v.COMMAND,
|
|
1010
|
-
handler: async (
|
|
1011
|
-
const t =
|
|
1037
|
+
handler: async (s, e) => {
|
|
1038
|
+
const t = s.get(I), n = s.get(T);
|
|
1012
1039
|
return F(
|
|
1013
|
-
|
|
1040
|
+
tt,
|
|
1014
1041
|
e,
|
|
1015
1042
|
n,
|
|
1016
1043
|
t
|
|
1017
1044
|
);
|
|
1018
1045
|
}
|
|
1019
|
-
},
|
|
1020
|
-
id:
|
|
1046
|
+
}, nt = "doc.command.set-inline-format-subscript", se = {
|
|
1047
|
+
id: nt,
|
|
1021
1048
|
type: v.COMMAND,
|
|
1022
|
-
handler: async (
|
|
1023
|
-
const t =
|
|
1049
|
+
handler: async (s, e) => {
|
|
1050
|
+
const t = s.get(I), n = s.get(T);
|
|
1024
1051
|
return F(
|
|
1025
|
-
|
|
1052
|
+
nt,
|
|
1026
1053
|
e,
|
|
1027
1054
|
n,
|
|
1028
1055
|
t
|
|
1029
1056
|
);
|
|
1030
1057
|
}
|
|
1031
|
-
},
|
|
1032
|
-
id:
|
|
1058
|
+
}, st = "doc.command.set-inline-format-superscript", Fe = {
|
|
1059
|
+
id: st,
|
|
1033
1060
|
type: v.COMMAND,
|
|
1034
|
-
handler: async (
|
|
1035
|
-
const t =
|
|
1061
|
+
handler: async (s, e) => {
|
|
1062
|
+
const t = s.get(I), n = s.get(T);
|
|
1036
1063
|
return F(
|
|
1037
|
-
|
|
1064
|
+
st,
|
|
1038
1065
|
e,
|
|
1039
1066
|
n,
|
|
1040
1067
|
t
|
|
1041
1068
|
);
|
|
1042
1069
|
}
|
|
1043
|
-
},
|
|
1044
|
-
id:
|
|
1070
|
+
}, ot = "doc.command.set-inline-format-fontsize", $e = {
|
|
1071
|
+
id: ot,
|
|
1045
1072
|
type: v.COMMAND,
|
|
1046
|
-
handler: async (
|
|
1047
|
-
const t =
|
|
1073
|
+
handler: async (s, e) => {
|
|
1074
|
+
const t = s.get(I), n = s.get(T);
|
|
1048
1075
|
return F(
|
|
1049
|
-
|
|
1076
|
+
ot,
|
|
1050
1077
|
e,
|
|
1051
1078
|
n,
|
|
1052
1079
|
t
|
|
1053
1080
|
);
|
|
1054
1081
|
}
|
|
1055
|
-
},
|
|
1056
|
-
id:
|
|
1082
|
+
}, rt = "doc.command.set-inline-format-font-family", Ve = {
|
|
1083
|
+
id: rt,
|
|
1057
1084
|
type: v.COMMAND,
|
|
1058
|
-
handler: async (
|
|
1059
|
-
const t =
|
|
1085
|
+
handler: async (s, e) => {
|
|
1086
|
+
const t = s.get(I), n = s.get(T);
|
|
1060
1087
|
return F(
|
|
1061
|
-
|
|
1088
|
+
rt,
|
|
1062
1089
|
e,
|
|
1063
1090
|
n,
|
|
1064
1091
|
t
|
|
1065
1092
|
);
|
|
1066
1093
|
}
|
|
1067
|
-
},
|
|
1068
|
-
id:
|
|
1094
|
+
}, it = "doc.command.set-inline-format-text-color", ze = {
|
|
1095
|
+
id: it,
|
|
1069
1096
|
type: v.COMMAND,
|
|
1070
|
-
handler: async (
|
|
1071
|
-
const t =
|
|
1097
|
+
handler: async (s, e) => {
|
|
1098
|
+
const t = s.get(I), n = s.get(T);
|
|
1072
1099
|
return F(
|
|
1073
|
-
|
|
1100
|
+
it,
|
|
1074
1101
|
e,
|
|
1075
1102
|
n,
|
|
1076
1103
|
t
|
|
1077
1104
|
);
|
|
1078
1105
|
}
|
|
1079
|
-
},
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1106
|
+
}, at = "doc.command.set-inline-format-text-background-color", ke = {
|
|
1107
|
+
id: at,
|
|
1108
|
+
type: v.COMMAND,
|
|
1109
|
+
handler: async (s, e) => {
|
|
1110
|
+
const t = s.get(I), n = s.get(T);
|
|
1111
|
+
return F(
|
|
1112
|
+
at,
|
|
1113
|
+
e,
|
|
1114
|
+
n,
|
|
1115
|
+
t
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
}, ct = "doc.command.reset-inline-format-text-background-color", je = {
|
|
1119
|
+
id: ct,
|
|
1120
|
+
type: v.COMMAND,
|
|
1121
|
+
handler: async (s, e) => {
|
|
1122
|
+
const t = s.get(I), n = s.get(T);
|
|
1123
|
+
return F(
|
|
1124
|
+
ct,
|
|
1125
|
+
e,
|
|
1126
|
+
n,
|
|
1127
|
+
t
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
}, vt = {
|
|
1131
|
+
[Ue.id]: "bl",
|
|
1132
|
+
[we.id]: "it",
|
|
1133
|
+
[Le.id]: "ul",
|
|
1134
|
+
[Be.id]: "st",
|
|
1135
|
+
[$e.id]: "fs",
|
|
1136
|
+
[Ve.id]: "ff",
|
|
1137
|
+
[ze.id]: "cl",
|
|
1138
|
+
[ke.id]: "bg",
|
|
1139
|
+
[je.id]: "bg",
|
|
1140
|
+
[se.id]: "va",
|
|
1141
|
+
[Fe.id]: "va"
|
|
1142
|
+
}, It = {
|
|
1090
1143
|
id: "doc.command.set-inline-format",
|
|
1091
1144
|
type: v.COMMAND,
|
|
1092
|
-
handler: async (
|
|
1093
|
-
const { segmentId: t, value: n, preCommandId:
|
|
1145
|
+
handler: async (s, e) => {
|
|
1146
|
+
const { segmentId: t, value: n, preCommandId: o } = e, r = s.get(I), i = s.get(T), a = s.get(E), c = i.getSelections();
|
|
1094
1147
|
if (!Array.isArray(c) || c.length === 0)
|
|
1095
1148
|
return !1;
|
|
1096
|
-
let d = a.getCurrentUniverDocInstance()
|
|
1097
|
-
|
|
1149
|
+
let d = a.getCurrentUniverDocInstance();
|
|
1150
|
+
if (!d)
|
|
1151
|
+
return !1;
|
|
1152
|
+
let l = d.getUnitId();
|
|
1153
|
+
l === Dt && (d = a.getUniverDocInstance(dt), l = d.getUnitId());
|
|
1098
1154
|
let u;
|
|
1099
|
-
switch (
|
|
1100
|
-
case
|
|
1101
|
-
case
|
|
1102
|
-
case
|
|
1103
|
-
case
|
|
1104
|
-
case
|
|
1105
|
-
case
|
|
1106
|
-
u =
|
|
1155
|
+
switch (o) {
|
|
1156
|
+
case Ue.id:
|
|
1157
|
+
case we.id:
|
|
1158
|
+
case Le.id:
|
|
1159
|
+
case Be.id:
|
|
1160
|
+
case se.id:
|
|
1161
|
+
case Fe.id: {
|
|
1162
|
+
u = mn(
|
|
1107
1163
|
d.getBody().textRuns,
|
|
1108
|
-
|
|
1164
|
+
o,
|
|
1109
1165
|
c
|
|
1110
1166
|
);
|
|
1111
1167
|
break;
|
|
1112
1168
|
}
|
|
1113
|
-
case
|
|
1114
|
-
case
|
|
1169
|
+
case $e.id:
|
|
1170
|
+
case Ve.id: {
|
|
1115
1171
|
u = n;
|
|
1116
1172
|
break;
|
|
1117
1173
|
}
|
|
1118
|
-
case
|
|
1174
|
+
case ze.id:
|
|
1175
|
+
case ke.id: {
|
|
1119
1176
|
u = {
|
|
1120
1177
|
rgb: n
|
|
1121
1178
|
};
|
|
1122
1179
|
break;
|
|
1123
1180
|
}
|
|
1181
|
+
case je.id: {
|
|
1182
|
+
u = {
|
|
1183
|
+
rgb: null
|
|
1184
|
+
};
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1124
1187
|
default:
|
|
1125
|
-
throw new Error(`Unknown command: ${
|
|
1188
|
+
throw new Error(`Unknown command: ${o} in handleInlineFormat`);
|
|
1126
1189
|
}
|
|
1127
1190
|
const m = {
|
|
1128
|
-
id:
|
|
1191
|
+
id: L.id,
|
|
1129
1192
|
params: {
|
|
1130
1193
|
unitId: l,
|
|
1131
1194
|
actions: [],
|
|
1132
|
-
textRanges: c.map(
|
|
1195
|
+
textRanges: c.map(Z)
|
|
1133
1196
|
}
|
|
1134
|
-
}, g = new
|
|
1197
|
+
}, g = new P(), p = new oe();
|
|
1135
1198
|
p.reset();
|
|
1136
1199
|
for (const f of c) {
|
|
1137
|
-
const { startOffset: S, endOffset: _ } = f,
|
|
1200
|
+
const { startOffset: S, endOffset: _ } = f, R = {
|
|
1138
1201
|
dataStream: "",
|
|
1139
1202
|
textRuns: [
|
|
1140
1203
|
{
|
|
1141
1204
|
st: 0,
|
|
1142
1205
|
ed: _ - S,
|
|
1143
1206
|
ts: {
|
|
1144
|
-
[
|
|
1207
|
+
[vt[o]]: u
|
|
1145
1208
|
}
|
|
1146
1209
|
}
|
|
1147
1210
|
]
|
|
1148
|
-
},
|
|
1149
|
-
|
|
1211
|
+
}, M = S - p.cursor;
|
|
1212
|
+
M !== 0 && g.push({
|
|
1150
1213
|
t: y.RETAIN,
|
|
1151
|
-
len:
|
|
1214
|
+
len: M,
|
|
1152
1215
|
segmentId: t
|
|
1153
1216
|
}), g.push({
|
|
1154
1217
|
t: y.RETAIN,
|
|
1155
|
-
body:
|
|
1218
|
+
body: R,
|
|
1156
1219
|
len: _ - S,
|
|
1157
1220
|
segmentId: t
|
|
1158
1221
|
}), p.reset(), p.moveCursor(_);
|
|
@@ -1160,89 +1223,98 @@ const Ve = "doc.command.set-inline-format-bold", Oe = {
|
|
|
1160
1223
|
return m.params.actions = g.serialize(), !!r.syncExecuteCommand(m.id, m.params);
|
|
1161
1224
|
}
|
|
1162
1225
|
};
|
|
1163
|
-
function
|
|
1164
|
-
return
|
|
1226
|
+
function un(s) {
|
|
1227
|
+
return s !== null && typeof s == "object";
|
|
1165
1228
|
}
|
|
1166
|
-
function
|
|
1167
|
-
let n = 0,
|
|
1168
|
-
const r =
|
|
1169
|
-
for (; n !==
|
|
1170
|
-
const { startOffset: i, endOffset: a } = t[
|
|
1229
|
+
function mn(s, e, t) {
|
|
1230
|
+
let n = 0, o = 0;
|
|
1231
|
+
const r = vt[e];
|
|
1232
|
+
for (; n !== s.length && o !== t.length; ) {
|
|
1233
|
+
const { startOffset: i, endOffset: a } = t[o], { st: c, ed: d, ts: l } = s[n];
|
|
1171
1234
|
if (a <= c)
|
|
1172
|
-
|
|
1235
|
+
o++;
|
|
1173
1236
|
else if (d <= i)
|
|
1174
1237
|
n++;
|
|
1175
1238
|
else {
|
|
1176
1239
|
if (/bl|it/.test(r))
|
|
1177
|
-
return (l == null ? void 0 : l[r]) ===
|
|
1240
|
+
return (l == null ? void 0 : l[r]) === k.TRUE ? k.FALSE : k.TRUE;
|
|
1178
1241
|
if (/ul|st/.test(r))
|
|
1179
|
-
return
|
|
1180
|
-
s:
|
|
1242
|
+
return un(l == null ? void 0 : l[r]) && (l == null ? void 0 : l[r]).s === k.TRUE ? {
|
|
1243
|
+
s: k.FALSE
|
|
1181
1244
|
} : {
|
|
1182
|
-
s:
|
|
1245
|
+
s: k.TRUE
|
|
1183
1246
|
};
|
|
1184
1247
|
if (/va/.test(r))
|
|
1185
|
-
return e ===
|
|
1248
|
+
return e === se.id ? (l == null ? void 0 : l[r]) === j.SUBSCRIPT ? j.NORMAL : j.SUBSCRIPT : (l == null ? void 0 : l[r]) === j.SUPERSCRIPT ? j.NORMAL : j.SUPERSCRIPT;
|
|
1186
1249
|
n++;
|
|
1187
1250
|
}
|
|
1188
1251
|
}
|
|
1189
|
-
return /bl|it/.test(r) ?
|
|
1190
|
-
s:
|
|
1191
|
-
} : e ===
|
|
1252
|
+
return /bl|it/.test(r) ? k.TRUE : /ul|st/.test(r) ? {
|
|
1253
|
+
s: k.TRUE
|
|
1254
|
+
} : e === se.id ? j.SUBSCRIPT : j.SUPERSCRIPT;
|
|
1192
1255
|
}
|
|
1193
|
-
const
|
|
1256
|
+
const Ge = {
|
|
1194
1257
|
id: "doc.command.list-operation",
|
|
1195
1258
|
type: v.COMMAND,
|
|
1196
|
-
handler: (
|
|
1197
|
-
var
|
|
1198
|
-
const t =
|
|
1259
|
+
handler: (s, e) => {
|
|
1260
|
+
var O, U, w, X;
|
|
1261
|
+
const t = s.get(T), n = s.get(E), o = s.get(I), { listType: r } = e, i = n.getCurrentUniverDocInstance();
|
|
1262
|
+
if (!i)
|
|
1263
|
+
return !1;
|
|
1264
|
+
const a = t.getActiveRange(), c = (O = t.getSelections()) != null ? O : [], d = (U = i.getBody()) == null ? void 0 : U.paragraphs, l = c.map(Z);
|
|
1199
1265
|
if (a == null || d == null)
|
|
1200
1266
|
return !1;
|
|
1201
|
-
const u =
|
|
1202
|
-
var
|
|
1203
|
-
return ((
|
|
1267
|
+
const u = Mt(a, d), { segmentId: m } = a, g = i.getUnitId(), p = u.every((Y) => {
|
|
1268
|
+
var $;
|
|
1269
|
+
return (($ = Y.bullet) == null ? void 0 : $.listType) === r;
|
|
1204
1270
|
});
|
|
1205
|
-
let f =
|
|
1271
|
+
let f = Q.generateRandomId(6);
|
|
1206
1272
|
if (u.length === 1) {
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1273
|
+
const Y = d.indexOf(u[0]), $ = d[Y - 1], z = d[Y + 1];
|
|
1274
|
+
$ && $.bullet && $.bullet.listType === r ? f = $.bullet.listId : z && z.bullet && z.bullet.listType === r && (f = z.bullet.listId);
|
|
1209
1275
|
}
|
|
1210
1276
|
const S = {
|
|
1211
|
-
id:
|
|
1277
|
+
id: L.id,
|
|
1212
1278
|
params: {
|
|
1213
1279
|
unitId: g,
|
|
1214
1280
|
actions: [],
|
|
1215
1281
|
textRanges: l
|
|
1216
1282
|
}
|
|
1217
|
-
}, _ = new
|
|
1283
|
+
}, _ = new oe();
|
|
1218
1284
|
_.reset();
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1285
|
+
const R = new P(), M = (w = i.getSnapshot().lists) != null ? w : {}, C = {
|
|
1286
|
+
...At,
|
|
1287
|
+
...M
|
|
1288
|
+
}, { charSpace: D, defaultTabStop: A = 36, gridType: b } = i.getSnapshot().documentStyle;
|
|
1289
|
+
for (const Y of u) {
|
|
1290
|
+
const { startIndex: $, paragraphStyle: z = {} } = Y, { indentFirstLine: Rt = 0, snapToGrid: xt, indentStart: _e = 0 } = z, { hanging: ve, indentStart: He } = C[r].nestingLevel[0], Ie = $t(D, A, b, xt);
|
|
1291
|
+
R.push({
|
|
1223
1292
|
t: y.RETAIN,
|
|
1224
|
-
len:
|
|
1293
|
+
len: $ - _.cursor,
|
|
1225
1294
|
segmentId: m
|
|
1226
|
-
})
|
|
1227
|
-
const x = {
|
|
1228
|
-
...E.paragraphStyle,
|
|
1229
|
-
hanging: void 0,
|
|
1230
|
-
indentStart: void 0
|
|
1231
|
-
};
|
|
1232
|
-
C.push({
|
|
1295
|
+
}), R.push({
|
|
1233
1296
|
t: y.RETAIN,
|
|
1234
1297
|
len: 1,
|
|
1235
1298
|
body: {
|
|
1236
1299
|
dataStream: "",
|
|
1237
1300
|
paragraphs: [
|
|
1238
1301
|
p ? {
|
|
1239
|
-
paragraphStyle:
|
|
1302
|
+
paragraphStyle: {
|
|
1303
|
+
...z,
|
|
1304
|
+
hanging: void 0,
|
|
1305
|
+
indentStart: _e ? Math.max(0, Me(_e, Ie) + ve - He) : void 0
|
|
1306
|
+
},
|
|
1240
1307
|
startIndex: 0
|
|
1241
1308
|
} : {
|
|
1242
|
-
...E,
|
|
1243
1309
|
startIndex: 0,
|
|
1310
|
+
paragraphStyle: {
|
|
1311
|
+
...z,
|
|
1312
|
+
indentFirstLine: void 0,
|
|
1313
|
+
hanging: ve,
|
|
1314
|
+
indentStart: He - ve + Me(Rt, Ie) + Me(_e, Ie)
|
|
1315
|
+
},
|
|
1244
1316
|
bullet: {
|
|
1245
|
-
...(
|
|
1317
|
+
...(X = Y.bullet) != null ? X : {
|
|
1246
1318
|
nestingLevel: 0,
|
|
1247
1319
|
textStyle: {
|
|
1248
1320
|
fs: 20
|
|
@@ -1255,64 +1327,67 @@ const be = {
|
|
|
1255
1327
|
]
|
|
1256
1328
|
},
|
|
1257
1329
|
segmentId: m,
|
|
1258
|
-
coverType:
|
|
1259
|
-
}), _.moveCursorTo(
|
|
1330
|
+
coverType: Ee.REPLACE
|
|
1331
|
+
}), _.moveCursorTo($ + 1);
|
|
1260
1332
|
}
|
|
1261
|
-
return S.params.actions =
|
|
1333
|
+
return S.params.actions = R.serialize(), !!o.syncExecuteCommand(S.id, S.params);
|
|
1262
1334
|
}
|
|
1263
|
-
},
|
|
1335
|
+
}, gn = {
|
|
1264
1336
|
id: "doc.command.bullet-list",
|
|
1265
1337
|
type: v.COMMAND,
|
|
1266
|
-
handler: (
|
|
1267
|
-
listType:
|
|
1338
|
+
handler: (s) => s.get(I).syncExecuteCommand(Ge.id, {
|
|
1339
|
+
listType: ut.BULLET_LIST
|
|
1268
1340
|
})
|
|
1269
|
-
},
|
|
1341
|
+
}, fn = {
|
|
1270
1342
|
id: "doc.command.order-list",
|
|
1271
1343
|
type: v.COMMAND,
|
|
1272
|
-
handler: (
|
|
1273
|
-
listType:
|
|
1344
|
+
handler: (s) => s.get(I).syncExecuteCommand(Ge.id, {
|
|
1345
|
+
listType: ut.ORDER_LIST
|
|
1274
1346
|
})
|
|
1275
1347
|
};
|
|
1276
|
-
function
|
|
1277
|
-
const { startOffset: t, endOffset: n } =
|
|
1348
|
+
function Mt(s, e) {
|
|
1349
|
+
const { startOffset: t, endOffset: n } = s, o = [];
|
|
1278
1350
|
let r = -1;
|
|
1279
1351
|
for (const i of e) {
|
|
1280
1352
|
const { startIndex: a } = i;
|
|
1281
|
-
(t > r && t <= a || n > r && n <= a || a >= t && a <= n) &&
|
|
1353
|
+
(t > r && t <= a || n > r && n <= a || a >= t && a <= n) && o.push(i), r = a;
|
|
1282
1354
|
}
|
|
1283
|
-
return
|
|
1355
|
+
return o;
|
|
1284
1356
|
}
|
|
1285
|
-
const
|
|
1357
|
+
const ie = {
|
|
1286
1358
|
id: "doc.command.align-operation",
|
|
1287
1359
|
type: v.COMMAND,
|
|
1288
|
-
handler: (
|
|
1289
|
-
var
|
|
1290
|
-
const t =
|
|
1360
|
+
handler: (s, e) => {
|
|
1361
|
+
var R, M;
|
|
1362
|
+
const t = s.get(T), n = s.get(E), o = s.get(I), { alignType: r } = e, i = n.getCurrentUniverDocInstance();
|
|
1363
|
+
if (!i)
|
|
1364
|
+
return !1;
|
|
1365
|
+
const a = t.getActiveRange(), c = (R = t.getSelections()) != null ? R : [], d = (M = i.getBody()) == null ? void 0 : M.paragraphs, l = c.map(Z);
|
|
1291
1366
|
if (a == null || d == null)
|
|
1292
1367
|
return !1;
|
|
1293
|
-
const u =
|
|
1294
|
-
var
|
|
1295
|
-
return ((
|
|
1368
|
+
const u = Mt(a, d), { segmentId: m } = a, g = i.getUnitId(), p = u.every((C) => {
|
|
1369
|
+
var D;
|
|
1370
|
+
return ((D = C.paragraphStyle) == null ? void 0 : D.horizontalAlign) === r;
|
|
1296
1371
|
}), h = {
|
|
1297
|
-
id:
|
|
1372
|
+
id: L.id,
|
|
1298
1373
|
params: {
|
|
1299
1374
|
unitId: g,
|
|
1300
1375
|
actions: [],
|
|
1301
1376
|
textRanges: l
|
|
1302
1377
|
}
|
|
1303
|
-
}, f = new
|
|
1378
|
+
}, f = new oe();
|
|
1304
1379
|
f.reset();
|
|
1305
|
-
const S = new
|
|
1306
|
-
for (const
|
|
1307
|
-
const { startIndex:
|
|
1380
|
+
const S = new P();
|
|
1381
|
+
for (const C of u) {
|
|
1382
|
+
const { startIndex: D } = C;
|
|
1308
1383
|
S.push({
|
|
1309
1384
|
t: y.RETAIN,
|
|
1310
|
-
len:
|
|
1385
|
+
len: D - f.cursor,
|
|
1311
1386
|
segmentId: m
|
|
1312
1387
|
});
|
|
1313
|
-
const
|
|
1314
|
-
...
|
|
1315
|
-
horizontalAlign: p ?
|
|
1388
|
+
const A = {
|
|
1389
|
+
...C.paragraphStyle,
|
|
1390
|
+
horizontalAlign: p ? re.UNSPECIFIED : r
|
|
1316
1391
|
};
|
|
1317
1392
|
S.push({
|
|
1318
1393
|
t: y.RETAIN,
|
|
@@ -1321,77 +1396,77 @@ const te = {
|
|
|
1321
1396
|
dataStream: "",
|
|
1322
1397
|
paragraphs: [
|
|
1323
1398
|
{
|
|
1324
|
-
...
|
|
1325
|
-
paragraphStyle:
|
|
1399
|
+
...C,
|
|
1400
|
+
paragraphStyle: A,
|
|
1326
1401
|
startIndex: 0
|
|
1327
1402
|
}
|
|
1328
1403
|
]
|
|
1329
1404
|
},
|
|
1330
1405
|
segmentId: m,
|
|
1331
|
-
coverType:
|
|
1332
|
-
}), f.moveCursorTo(
|
|
1406
|
+
coverType: Ee.REPLACE
|
|
1407
|
+
}), f.moveCursorTo(D + 1);
|
|
1333
1408
|
}
|
|
1334
|
-
return h.params.actions = S.serialize(), !!
|
|
1409
|
+
return h.params.actions = S.serialize(), !!o.syncExecuteCommand(h.id, h.params);
|
|
1335
1410
|
}
|
|
1336
|
-
},
|
|
1411
|
+
}, hn = {
|
|
1337
1412
|
id: "doc.command.align-left",
|
|
1338
1413
|
type: v.COMMAND,
|
|
1339
|
-
handler: (
|
|
1340
|
-
alignType:
|
|
1414
|
+
handler: (s) => s.get(I).syncExecuteCommand(ie.id, {
|
|
1415
|
+
alignType: re.LEFT
|
|
1341
1416
|
})
|
|
1342
|
-
},
|
|
1417
|
+
}, pn = {
|
|
1343
1418
|
id: "doc.command.align-center",
|
|
1344
1419
|
type: v.COMMAND,
|
|
1345
|
-
handler: (
|
|
1346
|
-
alignType:
|
|
1420
|
+
handler: (s) => s.get(I).syncExecuteCommand(ie.id, {
|
|
1421
|
+
alignType: re.CENTER
|
|
1347
1422
|
})
|
|
1348
|
-
},
|
|
1423
|
+
}, Sn = {
|
|
1349
1424
|
id: "doc.command.align-right",
|
|
1350
1425
|
type: v.COMMAND,
|
|
1351
|
-
handler: (
|
|
1352
|
-
alignType:
|
|
1426
|
+
handler: (s) => s.get(I).syncExecuteCommand(ie.id, {
|
|
1427
|
+
alignType: re.RIGHT
|
|
1353
1428
|
})
|
|
1354
|
-
},
|
|
1429
|
+
}, _n = {
|
|
1355
1430
|
id: "doc.command.align-justify",
|
|
1356
1431
|
type: v.COMMAND,
|
|
1357
|
-
handler: (
|
|
1358
|
-
alignType:
|
|
1432
|
+
handler: (s) => s.get(I).syncExecuteCommand(ie.id, {
|
|
1433
|
+
alignType: re.JUSTIFIED
|
|
1359
1434
|
})
|
|
1360
|
-
},
|
|
1435
|
+
}, vn = {
|
|
1361
1436
|
id: "doc.command-replace-content",
|
|
1362
1437
|
type: v.COMMAND,
|
|
1363
|
-
handler: async (
|
|
1438
|
+
handler: async (s, e) => {
|
|
1364
1439
|
var g;
|
|
1365
|
-
const { unitId: t, body: n, textRanges:
|
|
1440
|
+
const { unitId: t, body: n, textRanges: o, segmentId: r = "" } = e, i = s.get(E), a = s.get(I), c = s.get(T), d = (g = i.getUniverDocInstance(t)) == null ? void 0 : g.getSnapshot().body, l = c.getSelections();
|
|
1366
1441
|
if (d == null || !Array.isArray(l) || l.length === 0)
|
|
1367
1442
|
return !1;
|
|
1368
|
-
const u =
|
|
1369
|
-
return u.params.textRanges =
|
|
1443
|
+
const u = Ct(t, r, d, n);
|
|
1444
|
+
return u.params.textRanges = o, !!a.syncExecuteCommand(u.id, u.params);
|
|
1370
1445
|
}
|
|
1371
|
-
},
|
|
1446
|
+
}, In = {
|
|
1372
1447
|
id: "doc.command-cover-content",
|
|
1373
1448
|
type: v.COMMAND,
|
|
1374
|
-
handler: async (
|
|
1449
|
+
handler: async (s, e) => {
|
|
1375
1450
|
var l;
|
|
1376
|
-
const { unitId: t, body: n, segmentId:
|
|
1451
|
+
const { unitId: t, body: n, segmentId: o = "" } = e, r = s.get(E), i = s.get(I), a = s.get(Te), c = (l = r.getUniverDocInstance(t)) == null ? void 0 : l.getSnapshot().body;
|
|
1377
1452
|
if (c == null)
|
|
1378
1453
|
return !1;
|
|
1379
|
-
const d =
|
|
1454
|
+
const d = Ct(t, o, c, n);
|
|
1380
1455
|
return d.params.noNeedSetTextRange = !0, d.params.noHistory = !0, i.syncExecuteCommand(
|
|
1381
1456
|
d.id,
|
|
1382
1457
|
d.params
|
|
1383
1458
|
), a.clearUndoRedo(t), !0;
|
|
1384
1459
|
}
|
|
1385
1460
|
};
|
|
1386
|
-
function
|
|
1387
|
-
const
|
|
1388
|
-
id:
|
|
1461
|
+
function Ct(s, e, t, n) {
|
|
1462
|
+
const o = {
|
|
1463
|
+
id: L.id,
|
|
1389
1464
|
params: {
|
|
1390
|
-
unitId:
|
|
1465
|
+
unitId: s,
|
|
1391
1466
|
actions: [],
|
|
1392
1467
|
textRanges: []
|
|
1393
1468
|
}
|
|
1394
|
-
}, r = new
|
|
1469
|
+
}, r = new P(), i = (t == null ? void 0 : t.dataStream.length) - 2;
|
|
1395
1470
|
return i > 0 && r.push({
|
|
1396
1471
|
t: y.DELETE,
|
|
1397
1472
|
len: i,
|
|
@@ -1403,27 +1478,27 @@ function lt(o, e, t, n) {
|
|
|
1403
1478
|
len: n.dataStream.length,
|
|
1404
1479
|
line: 0,
|
|
1405
1480
|
segmentId: e
|
|
1406
|
-
}),
|
|
1481
|
+
}), o.params.actions = r.serialize(), o;
|
|
1407
1482
|
}
|
|
1408
|
-
const
|
|
1483
|
+
const ye = {
|
|
1409
1484
|
id: "doc.operation.move-cursor",
|
|
1410
1485
|
type: v.OPERATION,
|
|
1411
|
-
handler: (
|
|
1412
|
-
},
|
|
1486
|
+
handler: (s, e) => !!e
|
|
1487
|
+
}, Oe = {
|
|
1413
1488
|
id: "doc.operation.move-selection",
|
|
1414
1489
|
type: v.OPERATION,
|
|
1415
|
-
handler: (
|
|
1416
|
-
},
|
|
1417
|
-
const t =
|
|
1490
|
+
handler: (s, e) => !!e
|
|
1491
|
+
}, Mn = (s, e) => {
|
|
1492
|
+
const t = s.get(E).getUniverDocInstance(e.unitId), n = (t == null ? void 0 : t.zoomRatio) || 1;
|
|
1418
1493
|
return {
|
|
1419
|
-
...
|
|
1494
|
+
...Q.deepClone(e),
|
|
1420
1495
|
zoomRatio: n
|
|
1421
1496
|
};
|
|
1422
|
-
},
|
|
1497
|
+
}, ce = {
|
|
1423
1498
|
id: "doc.operation.set-zoom-ratio",
|
|
1424
1499
|
type: v.OPERATION,
|
|
1425
|
-
handler: (
|
|
1426
|
-
const t =
|
|
1500
|
+
handler: (s, e) => {
|
|
1501
|
+
const t = s.get(E).getUniverDocInstance(e.unitId);
|
|
1427
1502
|
if (!t)
|
|
1428
1503
|
return !1;
|
|
1429
1504
|
const n = t.getSnapshot();
|
|
@@ -1431,55 +1506,61 @@ const Se = {
|
|
|
1431
1506
|
zoomRatio: e.zoomRatio
|
|
1432
1507
|
} : n.settings.zoomRatio = e.zoomRatio, !0;
|
|
1433
1508
|
}
|
|
1434
|
-
},
|
|
1509
|
+
}, Cn = {
|
|
1435
1510
|
type: v.COMMAND,
|
|
1436
1511
|
id: "doc.command.set-zoom-ratio",
|
|
1437
|
-
handler: async (
|
|
1438
|
-
var u, m;
|
|
1439
|
-
const t =
|
|
1440
|
-
let r =
|
|
1441
|
-
if (
|
|
1512
|
+
handler: async (s, e) => {
|
|
1513
|
+
var u, m, g;
|
|
1514
|
+
const t = s.get(I), n = s.get(Te), o = s.get(E);
|
|
1515
|
+
let r = (u = o.getCurrentUniverDocInstance()) == null ? void 0 : u.getUnitId();
|
|
1516
|
+
if (!r)
|
|
1517
|
+
return !1;
|
|
1518
|
+
let i = 1;
|
|
1519
|
+
if (e && (r = (m = e.documentId) != null ? m : r, i = (g = e.zoomRatio) != null ? g : i), !o.getUniverDocInstance(r))
|
|
1442
1520
|
return !1;
|
|
1443
1521
|
const c = {
|
|
1444
1522
|
zoomRatio: i,
|
|
1445
1523
|
unitId: r
|
|
1446
|
-
}, d =
|
|
1447
|
-
return t.syncExecuteCommand(
|
|
1524
|
+
}, d = Mn(s, c);
|
|
1525
|
+
return t.syncExecuteCommand(ce.id, c) ? (n.pushUndoRedo({
|
|
1448
1526
|
unitID: r,
|
|
1449
|
-
undoMutations: [{ id:
|
|
1450
|
-
redoMutations: [{ id:
|
|
1527
|
+
undoMutations: [{ id: ce.id, params: d }],
|
|
1528
|
+
redoMutations: [{ id: ce.id, params: c }]
|
|
1451
1529
|
}), !0) : !1;
|
|
1452
1530
|
}
|
|
1453
|
-
},
|
|
1531
|
+
}, Rn = {
|
|
1454
1532
|
id: "doc.operation.select-all",
|
|
1455
1533
|
type: v.COMMAND,
|
|
1456
|
-
handler: async (
|
|
1457
|
-
const e =
|
|
1458
|
-
if (n
|
|
1534
|
+
handler: async (s) => {
|
|
1535
|
+
const e = s.get(E), t = s.get(T), n = e.getCurrentUniverDocInstance();
|
|
1536
|
+
if (!n)
|
|
1459
1537
|
return !1;
|
|
1460
|
-
const
|
|
1538
|
+
const o = n.getSnapshot().body;
|
|
1539
|
+
if (o == null)
|
|
1540
|
+
return !1;
|
|
1541
|
+
const r = [
|
|
1461
1542
|
{
|
|
1462
1543
|
startOffset: 0,
|
|
1463
|
-
endOffset:
|
|
1544
|
+
endOffset: o.dataStream.length - 2
|
|
1464
1545
|
}
|
|
1465
1546
|
];
|
|
1466
|
-
return t.replaceTextRanges(
|
|
1547
|
+
return t.replaceTextRanges(r, !1), !0;
|
|
1467
1548
|
}
|
|
1468
1549
|
};
|
|
1469
|
-
var
|
|
1470
|
-
for (var
|
|
1471
|
-
(i =
|
|
1472
|
-
return n &&
|
|
1473
|
-
},
|
|
1474
|
-
let
|
|
1475
|
-
constructor(e, t, n,
|
|
1550
|
+
var xn = Object.defineProperty, yn = Object.getOwnPropertyDescriptor, On = (s, e, t, n) => {
|
|
1551
|
+
for (var o = n > 1 ? void 0 : n ? yn(e, t) : e, r = s.length - 1, i; r >= 0; r--)
|
|
1552
|
+
(i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
|
|
1553
|
+
return n && o && xn(e, t, o), o;
|
|
1554
|
+
}, J = (s, e) => (t, n) => e(t, n, s);
|
|
1555
|
+
let le = class extends Ne {
|
|
1556
|
+
constructor(e, t, n, o, r) {
|
|
1476
1557
|
super();
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
this._docSkeletonManagerService = e, this.
|
|
1558
|
+
x(this, "_previousIMEContent", "");
|
|
1559
|
+
x(this, "_isCompositionStart", !0);
|
|
1560
|
+
x(this, "_onStartSubscription");
|
|
1561
|
+
x(this, "_onUpdateSubscription");
|
|
1562
|
+
x(this, "_onEndSubscription");
|
|
1563
|
+
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._textSelectionRenderManager = n, this._imeInputManagerService = o, this._commandService = r, this._initialize();
|
|
1483
1564
|
}
|
|
1484
1565
|
dispose() {
|
|
1485
1566
|
var e, t, n;
|
|
@@ -1494,7 +1575,7 @@ let se = class extends Re {
|
|
|
1494
1575
|
return;
|
|
1495
1576
|
this._resetIME();
|
|
1496
1577
|
const { activeRange: t } = e;
|
|
1497
|
-
t != null && this._imeInputManagerService.setActiveRange(
|
|
1578
|
+
t != null && this._imeInputManagerService.setActiveRange(Q.deepClone(t));
|
|
1498
1579
|
});
|
|
1499
1580
|
}
|
|
1500
1581
|
_initialOnCompositionUpdate() {
|
|
@@ -1512,12 +1593,15 @@ let se = class extends Re {
|
|
|
1512
1593
|
const n = (d = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : d.skeleton;
|
|
1513
1594
|
if (e == null || n == null)
|
|
1514
1595
|
return;
|
|
1515
|
-
const
|
|
1596
|
+
const o = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1597
|
+
if (!o)
|
|
1598
|
+
return;
|
|
1599
|
+
const { event: r, activeRange: i } = e;
|
|
1516
1600
|
if (n == null || i == null)
|
|
1517
1601
|
return;
|
|
1518
1602
|
const c = r.data;
|
|
1519
|
-
c === this._previousIMEContent && t || (await this._commandService.executeCommand(
|
|
1520
|
-
unitId:
|
|
1603
|
+
c === this._previousIMEContent && t || (await this._commandService.executeCommand(_t.id, {
|
|
1604
|
+
unitId: o.getUnitId(),
|
|
1521
1605
|
newText: c,
|
|
1522
1606
|
oldTextLen: this._previousIMEContent.length,
|
|
1523
1607
|
isCompositionStart: this._isCompositionStart,
|
|
@@ -1528,24 +1612,24 @@ let se = class extends Re {
|
|
|
1528
1612
|
this._previousIMEContent = "", this._isCompositionStart = !0, this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(null);
|
|
1529
1613
|
}
|
|
1530
1614
|
};
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
],
|
|
1539
|
-
var
|
|
1540
|
-
for (var
|
|
1541
|
-
(i =
|
|
1542
|
-
return n &&
|
|
1543
|
-
},
|
|
1544
|
-
let
|
|
1545
|
-
constructor(e, t, n,
|
|
1615
|
+
le = On([
|
|
1616
|
+
De(Ae.Rendered, le),
|
|
1617
|
+
J(0, V(H)),
|
|
1618
|
+
J(1, E),
|
|
1619
|
+
J(2, fe),
|
|
1620
|
+
J(3, V(he)),
|
|
1621
|
+
J(4, I)
|
|
1622
|
+
], le);
|
|
1623
|
+
var Tn = Object.defineProperty, En = Object.getOwnPropertyDescriptor, Dn = (s, e, t, n) => {
|
|
1624
|
+
for (var o = n > 1 ? void 0 : n ? En(e, t) : e, r = s.length - 1, i; r >= 0; r--)
|
|
1625
|
+
(i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
|
|
1626
|
+
return n && o && Tn(e, t, o), o;
|
|
1627
|
+
}, q = (s, e) => (t, n) => e(t, n, s);
|
|
1628
|
+
let de = class extends Ne {
|
|
1629
|
+
constructor(e, t, n, o, r) {
|
|
1546
1630
|
super();
|
|
1547
|
-
|
|
1548
|
-
this._docSkeletonManagerService = e, this.
|
|
1631
|
+
x(this, "_onInputSubscription");
|
|
1632
|
+
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionManagerService = o, this._commandService = r, this._initialize(), this._commandExecutedListener();
|
|
1549
1633
|
}
|
|
1550
1634
|
dispose() {
|
|
1551
1635
|
var e;
|
|
@@ -1554,16 +1638,16 @@ let re = class extends Re {
|
|
|
1554
1638
|
_initialize() {
|
|
1555
1639
|
}
|
|
1556
1640
|
_commandExecutedListener() {
|
|
1557
|
-
const e = [
|
|
1641
|
+
const e = [ye.id, Oe.id];
|
|
1558
1642
|
this.disposeWithMe(
|
|
1559
1643
|
this._commandService.onCommandExecuted((t) => {
|
|
1560
1644
|
if (!e.includes(t.id))
|
|
1561
1645
|
return;
|
|
1562
1646
|
const n = t.params;
|
|
1563
1647
|
switch (t.id) {
|
|
1564
|
-
case
|
|
1648
|
+
case ye.id:
|
|
1565
1649
|
return this._handleMoveCursor(n.direction);
|
|
1566
|
-
case
|
|
1650
|
+
case Oe.id:
|
|
1567
1651
|
return this._handleShiftMoveSelection(n.direction);
|
|
1568
1652
|
default:
|
|
1569
1653
|
throw new Error("Unknown command");
|
|
@@ -1573,29 +1657,32 @@ let re = class extends Re {
|
|
|
1573
1657
|
}
|
|
1574
1658
|
_handleShiftMoveSelection(e) {
|
|
1575
1659
|
var h, f, S;
|
|
1576
|
-
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(),
|
|
1660
|
+
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), o = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1661
|
+
if (!o)
|
|
1662
|
+
return;
|
|
1663
|
+
const r = (h = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : h.skeleton, i = this._getDocObject();
|
|
1577
1664
|
if (t == null || r == null || i == null)
|
|
1578
1665
|
return;
|
|
1579
1666
|
const { startOffset: a, endOffset: c, style: d, collapsed: l, direction: u } = t;
|
|
1580
1667
|
if (n.length > 1) {
|
|
1581
|
-
let _ = Number.POSITIVE_INFINITY,
|
|
1582
|
-
for (const
|
|
1583
|
-
_ = Math.min(_,
|
|
1668
|
+
let _ = Number.POSITIVE_INFINITY, R = Number.NEGATIVE_INFINITY;
|
|
1669
|
+
for (const M of n)
|
|
1670
|
+
_ = Math.min(_, M.startOffset), R = Math.max(R, M.endOffset);
|
|
1584
1671
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1585
1672
|
{
|
|
1586
|
-
startOffset: e ===
|
|
1587
|
-
endOffset: e ===
|
|
1673
|
+
startOffset: e === N.LEFT || e === N.UP ? R : _,
|
|
1674
|
+
endOffset: e === N.LEFT || e === N.UP ? _ : R,
|
|
1588
1675
|
style: d
|
|
1589
1676
|
}
|
|
1590
1677
|
], !1);
|
|
1591
1678
|
return;
|
|
1592
1679
|
}
|
|
1593
|
-
const m = l || u ===
|
|
1594
|
-
let g = l || u ===
|
|
1595
|
-
const p = (f =
|
|
1596
|
-
if (e ===
|
|
1597
|
-
const _ = r.findNodeByCharIndex(g - 1),
|
|
1598
|
-
g = e ===
|
|
1680
|
+
const m = l || u === We.FORWARD ? a : c;
|
|
1681
|
+
let g = l || u === We.FORWARD ? c : a;
|
|
1682
|
+
const p = (f = o.getBody().dataStream.length) != null ? f : Number.POSITIVE_INFINITY;
|
|
1683
|
+
if (e === N.LEFT || e === N.RIGHT) {
|
|
1684
|
+
const _ = r.findNodeByCharIndex(g - 1), R = r.findNodeByCharIndex(g);
|
|
1685
|
+
g = e === N.RIGHT ? g + R.count : g - ((S = _ == null ? void 0 : _.count) != null ? S : 0), g = Math.min(p - 2, Math.max(0, g)), this._textSelectionManagerService.replaceTextRanges([
|
|
1599
1686
|
{
|
|
1600
1687
|
startOffset: m,
|
|
1601
1688
|
endOffset: g,
|
|
@@ -1603,28 +1690,28 @@ let re = class extends Re {
|
|
|
1603
1690
|
}
|
|
1604
1691
|
], !1);
|
|
1605
1692
|
} else {
|
|
1606
|
-
const _ = r.findNodeByCharIndex(g),
|
|
1607
|
-
if (
|
|
1608
|
-
const
|
|
1609
|
-
if (
|
|
1693
|
+
const _ = r.findNodeByCharIndex(g), R = i.document.getOffsetConfig(), M = this._getTopOrBottomPosition(r, _, e === N.DOWN);
|
|
1694
|
+
if (M == null) {
|
|
1695
|
+
const D = e === N.UP ? 0 : p - 2;
|
|
1696
|
+
if (D === g)
|
|
1610
1697
|
return;
|
|
1611
1698
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1612
1699
|
{
|
|
1613
1700
|
startOffset: m,
|
|
1614
|
-
endOffset:
|
|
1701
|
+
endOffset: D,
|
|
1615
1702
|
style: d
|
|
1616
1703
|
}
|
|
1617
1704
|
], !1);
|
|
1618
1705
|
return;
|
|
1619
1706
|
}
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
|
|
1707
|
+
const C = new Ze(R, r).getRangePointData(
|
|
1708
|
+
M,
|
|
1709
|
+
M
|
|
1623
1710
|
).cursorList[0];
|
|
1624
1711
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1625
1712
|
{
|
|
1626
1713
|
startOffset: m,
|
|
1627
|
-
endOffset:
|
|
1714
|
+
endOffset: C.endOffset,
|
|
1628
1715
|
style: d
|
|
1629
1716
|
}
|
|
1630
1717
|
], !1);
|
|
@@ -1632,20 +1719,23 @@ let re = class extends Re {
|
|
|
1632
1719
|
}
|
|
1633
1720
|
_handleMoveCursor(e) {
|
|
1634
1721
|
var m, g, p;
|
|
1635
|
-
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(),
|
|
1722
|
+
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(), o = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1723
|
+
if (!o)
|
|
1724
|
+
return !1;
|
|
1725
|
+
const r = (m = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : m.skeleton, i = this._getDocObject();
|
|
1636
1726
|
if (t == null || r == null || i == null || n == null)
|
|
1637
1727
|
return;
|
|
1638
|
-
const { startOffset: a, endOffset: c, style: d, collapsed: l } = t, u = (g =
|
|
1639
|
-
if (e ===
|
|
1728
|
+
const { startOffset: a, endOffset: c, style: d, collapsed: l } = t, u = (g = o.getBody().dataStream.length) != null ? g : Number.POSITIVE_INFINITY;
|
|
1729
|
+
if (e === N.LEFT || e === N.RIGHT) {
|
|
1640
1730
|
let h;
|
|
1641
1731
|
if (!t.collapsed || n.length > 1) {
|
|
1642
1732
|
let f = Number.POSITIVE_INFINITY, S = Number.NEGATIVE_INFINITY;
|
|
1643
1733
|
for (const _ of n)
|
|
1644
1734
|
f = Math.min(f, _.startOffset), S = Math.max(S, _.endOffset);
|
|
1645
|
-
h = e ===
|
|
1735
|
+
h = e === N.LEFT ? f : S;
|
|
1646
1736
|
} else {
|
|
1647
1737
|
const f = r.findNodeByCharIndex(a - 1), S = r.findNodeByCharIndex(a);
|
|
1648
|
-
e ===
|
|
1738
|
+
e === N.LEFT ? h = Math.max(0, a - ((p = f == null ? void 0 : f.count) != null ? p : 0)) : h = Math.min(u - 2, c + S.count);
|
|
1649
1739
|
}
|
|
1650
1740
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1651
1741
|
{
|
|
@@ -1657,27 +1747,27 @@ let re = class extends Re {
|
|
|
1657
1747
|
} else {
|
|
1658
1748
|
const h = r.findNodeByCharIndex(a), f = r.findNodeByCharIndex(c), S = i.document.getOffsetConfig(), _ = this._getTopOrBottomPosition(
|
|
1659
1749
|
r,
|
|
1660
|
-
e ===
|
|
1661
|
-
e ===
|
|
1750
|
+
e === N.UP ? h : f,
|
|
1751
|
+
e === N.DOWN
|
|
1662
1752
|
);
|
|
1663
1753
|
if (_ == null) {
|
|
1664
|
-
let
|
|
1665
|
-
l ?
|
|
1754
|
+
let M;
|
|
1755
|
+
l ? M = e === N.UP ? 0 : u - 2 : M = e === N.UP ? a : c, this._textSelectionManagerService.replaceTextRanges([
|
|
1666
1756
|
{
|
|
1667
|
-
startOffset:
|
|
1668
|
-
endOffset:
|
|
1757
|
+
startOffset: M,
|
|
1758
|
+
endOffset: M,
|
|
1669
1759
|
style: d
|
|
1670
1760
|
}
|
|
1671
1761
|
], !1);
|
|
1672
1762
|
return;
|
|
1673
1763
|
}
|
|
1674
|
-
const
|
|
1764
|
+
const R = new Ze(S, r).getRangePointData(
|
|
1675
1765
|
_,
|
|
1676
1766
|
_
|
|
1677
1767
|
).cursorList[0];
|
|
1678
1768
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1679
1769
|
{
|
|
1680
|
-
...
|
|
1770
|
+
...R,
|
|
1681
1771
|
style: d
|
|
1682
1772
|
}
|
|
1683
1773
|
], !1);
|
|
@@ -1686,10 +1776,10 @@ let re = class extends Re {
|
|
|
1686
1776
|
_getTopOrBottomPosition(e, t, n) {
|
|
1687
1777
|
if (t == null)
|
|
1688
1778
|
return;
|
|
1689
|
-
const
|
|
1779
|
+
const o = this._getSpanLeftOffsetInLine(t), r = this._getNextOrPrevLine(t, n);
|
|
1690
1780
|
if (r == null)
|
|
1691
1781
|
return;
|
|
1692
|
-
const i = this._matchPositionByLeftOffset(e, r,
|
|
1782
|
+
const i = this._matchPositionByLeftOffset(e, r, o);
|
|
1693
1783
|
if (i != null)
|
|
1694
1784
|
return { ...i, isBack: !0 };
|
|
1695
1785
|
}
|
|
@@ -1697,35 +1787,35 @@ let re = class extends Re {
|
|
|
1697
1787
|
const t = e.parent;
|
|
1698
1788
|
if (t == null)
|
|
1699
1789
|
return Number.NEGATIVE_INFINITY;
|
|
1700
|
-
const n = t.left, { left:
|
|
1701
|
-
return n +
|
|
1790
|
+
const n = t.left, { left: o } = e;
|
|
1791
|
+
return n + o;
|
|
1702
1792
|
}
|
|
1703
1793
|
_matchPositionByLeftOffset(e, t, n) {
|
|
1704
|
-
const
|
|
1794
|
+
const o = {
|
|
1705
1795
|
distance: Number.POSITIVE_INFINITY
|
|
1706
1796
|
};
|
|
1707
1797
|
for (const r of t.divides) {
|
|
1708
1798
|
const i = r.left;
|
|
1709
1799
|
for (const a of r.glyphGroup) {
|
|
1710
1800
|
const { left: c } = a, d = i + c, l = Math.abs(n - d);
|
|
1711
|
-
l <
|
|
1801
|
+
l < o.distance && (o.glyph = a, o.distance = l);
|
|
1712
1802
|
}
|
|
1713
1803
|
}
|
|
1714
|
-
if (
|
|
1715
|
-
return e.findPositionByGlyph(
|
|
1804
|
+
if (o.glyph != null)
|
|
1805
|
+
return e.findPositionByGlyph(o.glyph);
|
|
1716
1806
|
}
|
|
1717
1807
|
_getNextOrPrevLine(e, t) {
|
|
1718
|
-
var p, h, f, S, _,
|
|
1808
|
+
var p, h, f, S, _, R, M, C, D, A, b, B;
|
|
1719
1809
|
const n = e.parent;
|
|
1720
1810
|
if (n == null)
|
|
1721
1811
|
return;
|
|
1722
|
-
const
|
|
1723
|
-
if (
|
|
1812
|
+
const o = n.parent;
|
|
1813
|
+
if (o == null)
|
|
1724
1814
|
return;
|
|
1725
|
-
const r =
|
|
1815
|
+
const r = o.parent;
|
|
1726
1816
|
if (r == null)
|
|
1727
1817
|
return;
|
|
1728
|
-
const i = r.lines.indexOf(
|
|
1818
|
+
const i = r.lines.indexOf(o);
|
|
1729
1819
|
if (i === -1)
|
|
1730
1820
|
return;
|
|
1731
1821
|
let a;
|
|
@@ -1740,8 +1830,8 @@ let re = class extends Re {
|
|
|
1740
1830
|
if (t === !0)
|
|
1741
1831
|
a = (p = c.columns[d + 1]) == null ? void 0 : p.lines[0];
|
|
1742
1832
|
else {
|
|
1743
|
-
const
|
|
1744
|
-
a =
|
|
1833
|
+
const O = (f = (h = c.columns) == null ? void 0 : h[d - 1]) == null ? void 0 : f.lines;
|
|
1834
|
+
a = O == null ? void 0 : O[O.length - 1];
|
|
1745
1835
|
}
|
|
1746
1836
|
if (a != null)
|
|
1747
1837
|
return a;
|
|
@@ -1754,8 +1844,8 @@ let re = class extends Re {
|
|
|
1754
1844
|
if (t === !0)
|
|
1755
1845
|
a = (_ = (S = l.sections[u - 1]) == null ? void 0 : S.columns[0]) == null ? void 0 : _.lines[0];
|
|
1756
1846
|
else {
|
|
1757
|
-
const
|
|
1758
|
-
a =
|
|
1847
|
+
const O = (M = (R = l.sections) == null ? void 0 : R[u - 1]) == null ? void 0 : M.columns, U = O == null ? void 0 : O[O.length - 1], w = U == null ? void 0 : U.lines;
|
|
1848
|
+
a = w == null ? void 0 : w[w.length - 1];
|
|
1759
1849
|
}
|
|
1760
1850
|
if (a != null)
|
|
1761
1851
|
return a;
|
|
@@ -1765,40 +1855,40 @@ let re = class extends Re {
|
|
|
1765
1855
|
const g = m.pages.indexOf(l);
|
|
1766
1856
|
if (g !== -1) {
|
|
1767
1857
|
if (t === !0)
|
|
1768
|
-
a = (
|
|
1858
|
+
a = (A = (D = (C = m.pages[g + 1]) == null ? void 0 : C.sections[0]) == null ? void 0 : D.columns[0]) == null ? void 0 : A.lines[0];
|
|
1769
1859
|
else {
|
|
1770
|
-
const
|
|
1771
|
-
if (
|
|
1860
|
+
const O = (b = m.pages[g - 1]) == null ? void 0 : b.sections;
|
|
1861
|
+
if (O == null)
|
|
1772
1862
|
return;
|
|
1773
|
-
const
|
|
1774
|
-
a =
|
|
1863
|
+
const U = (B = O[O.length - 1]) == null ? void 0 : B.columns, w = U[U.length - 1], X = w == null ? void 0 : w.lines;
|
|
1864
|
+
a = X[X.length - 1];
|
|
1775
1865
|
}
|
|
1776
1866
|
if (a != null)
|
|
1777
1867
|
return a;
|
|
1778
1868
|
}
|
|
1779
1869
|
}
|
|
1780
1870
|
_getDocObject() {
|
|
1781
|
-
return
|
|
1871
|
+
return gt(this._univerInstanceService, this._renderManagerService);
|
|
1782
1872
|
}
|
|
1783
1873
|
};
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
],
|
|
1792
|
-
var
|
|
1793
|
-
for (var
|
|
1794
|
-
(i =
|
|
1795
|
-
return n &&
|
|
1796
|
-
},
|
|
1797
|
-
let
|
|
1798
|
-
constructor(e, t, n,
|
|
1874
|
+
de = Dn([
|
|
1875
|
+
De(Ae.Rendered, de),
|
|
1876
|
+
q(0, V(H)),
|
|
1877
|
+
q(1, E),
|
|
1878
|
+
q(2, mt),
|
|
1879
|
+
q(3, V(T)),
|
|
1880
|
+
q(4, I)
|
|
1881
|
+
], de);
|
|
1882
|
+
var An = Object.defineProperty, Nn = Object.getOwnPropertyDescriptor, bn = (s, e, t, n) => {
|
|
1883
|
+
for (var o = n > 1 ? void 0 : n ? Nn(e, t) : e, r = s.length - 1, i; r >= 0; r--)
|
|
1884
|
+
(i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
|
|
1885
|
+
return n && o && An(e, t, o), o;
|
|
1886
|
+
}, K = (s, e) => (t, n) => e(t, n, s);
|
|
1887
|
+
let ue = class extends Ne {
|
|
1888
|
+
constructor(e, t, n, o, r) {
|
|
1799
1889
|
super();
|
|
1800
|
-
|
|
1801
|
-
this._docSkeletonManagerService = e, this.
|
|
1890
|
+
x(this, "_onInputSubscription");
|
|
1891
|
+
this._docSkeletonManagerService = e, this._univerInstanceService = t, this._renderManagerService = n, this._textSelectionRenderManager = o, this._commandService = r, this._initialize(), this._commandExecutedListener();
|
|
1802
1892
|
}
|
|
1803
1893
|
dispose() {
|
|
1804
1894
|
var e;
|
|
@@ -1812,7 +1902,10 @@ let ie = class extends Re {
|
|
|
1812
1902
|
var p;
|
|
1813
1903
|
if (e == null)
|
|
1814
1904
|
return;
|
|
1815
|
-
const
|
|
1905
|
+
const t = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1906
|
+
if (!t)
|
|
1907
|
+
return;
|
|
1908
|
+
const n = t.getUnitId(), { event: o, content: r = "", activeRange: i } = e, a = o, c = (p = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : p.skeleton;
|
|
1816
1909
|
if (a.data == null || c == null || !c || !i)
|
|
1817
1910
|
return;
|
|
1818
1911
|
const { startOffset: d, segmentId: l, style: u } = i, m = r.length, g = [
|
|
@@ -1822,7 +1915,7 @@ let ie = class extends Re {
|
|
|
1822
1915
|
style: u
|
|
1823
1916
|
}
|
|
1824
1917
|
];
|
|
1825
|
-
await this._commandService.executeCommand(
|
|
1918
|
+
await this._commandService.executeCommand(pe.id, {
|
|
1826
1919
|
unitId: n,
|
|
1827
1920
|
body: {
|
|
1828
1921
|
dataStream: r
|
|
@@ -1836,71 +1929,73 @@ let ie = class extends Re {
|
|
|
1836
1929
|
_commandExecutedListener() {
|
|
1837
1930
|
}
|
|
1838
1931
|
_getDocObject() {
|
|
1839
|
-
return
|
|
1932
|
+
return gt(this._univerInstanceService, this._renderManagerService);
|
|
1840
1933
|
}
|
|
1841
1934
|
};
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
],
|
|
1850
|
-
var
|
|
1851
|
-
for (var
|
|
1852
|
-
(i =
|
|
1853
|
-
return n &&
|
|
1854
|
-
},
|
|
1855
|
-
const
|
|
1935
|
+
ue = bn([
|
|
1936
|
+
De(Ae.Rendered, ue),
|
|
1937
|
+
K(0, V(H)),
|
|
1938
|
+
K(1, E),
|
|
1939
|
+
K(2, mt),
|
|
1940
|
+
K(3, fe),
|
|
1941
|
+
K(4, I)
|
|
1942
|
+
], ue);
|
|
1943
|
+
var Pn = Object.defineProperty, Un = Object.getOwnPropertyDescriptor, wn = (s, e, t, n) => {
|
|
1944
|
+
for (var o = n > 1 ? void 0 : n ? Un(e, t) : e, r = s.length - 1, i; r >= 0; r--)
|
|
1945
|
+
(i = s[r]) && (o = (n ? i(e, t, o) : i(o)) || o);
|
|
1946
|
+
return n && o && Pn(e, t, o), o;
|
|
1947
|
+
}, Ln = (s, e) => (t, n) => e(t, n, s);
|
|
1948
|
+
const Bn = {
|
|
1856
1949
|
hasScroll: !0
|
|
1857
|
-
},
|
|
1858
|
-
var
|
|
1859
|
-
let
|
|
1950
|
+
}, Fn = "docs";
|
|
1951
|
+
var ae;
|
|
1952
|
+
let lt = (ae = class extends Nt {
|
|
1860
1953
|
constructor(e = {}, t) {
|
|
1861
|
-
super(
|
|
1862
|
-
|
|
1863
|
-
this._injector = t, this._config = Object.assign(
|
|
1954
|
+
super();
|
|
1955
|
+
x(this, "_config");
|
|
1956
|
+
this._injector = t, this._config = Object.assign(Bn, e), this._initializeDependencies(t), this._initializeCommands();
|
|
1864
1957
|
}
|
|
1865
1958
|
initialize() {
|
|
1866
1959
|
}
|
|
1867
1960
|
_initializeCommands() {
|
|
1868
1961
|
[
|
|
1869
|
-
|
|
1870
|
-
_e,
|
|
1871
|
-
Ht,
|
|
1872
|
-
Xt,
|
|
1962
|
+
ye,
|
|
1873
1963
|
Oe,
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
De,
|
|
1877
|
-
K,
|
|
1878
|
-
Ae,
|
|
1879
|
-
Pe,
|
|
1880
|
-
Ne,
|
|
1964
|
+
cn,
|
|
1965
|
+
ln,
|
|
1881
1966
|
Ue,
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1967
|
+
we,
|
|
1968
|
+
Le,
|
|
1969
|
+
Be,
|
|
1970
|
+
se,
|
|
1971
|
+
Fe,
|
|
1972
|
+
$e,
|
|
1973
|
+
Ve,
|
|
1974
|
+
ze,
|
|
1975
|
+
je,
|
|
1976
|
+
ke,
|
|
1977
|
+
It,
|
|
1890
1978
|
nn,
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1979
|
+
pe,
|
|
1980
|
+
Se,
|
|
1981
|
+
ht,
|
|
1982
|
+
_t,
|
|
1983
|
+
Pe,
|
|
1984
|
+
L,
|
|
1985
|
+
vn,
|
|
1986
|
+
In,
|
|
1987
|
+
Cn,
|
|
1988
|
+
ce,
|
|
1989
|
+
ft,
|
|
1990
|
+
Rn,
|
|
1991
|
+
fn,
|
|
1992
|
+
gn,
|
|
1993
|
+
Ge,
|
|
1994
|
+
hn,
|
|
1995
|
+
pn,
|
|
1996
|
+
Sn,
|
|
1997
|
+
ie,
|
|
1998
|
+
_n
|
|
1904
1999
|
].forEach((e) => {
|
|
1905
2000
|
this._injector.get(I).registerCommand(e);
|
|
1906
2001
|
});
|
|
@@ -1911,76 +2006,78 @@ let Je = (he = class extends ht {
|
|
|
1911
2006
|
_initializeDependencies(e) {
|
|
1912
2007
|
[
|
|
1913
2008
|
// services
|
|
1914
|
-
[
|
|
1915
|
-
[
|
|
1916
|
-
[
|
|
1917
|
-
[
|
|
2009
|
+
[H],
|
|
2010
|
+
[ne],
|
|
2011
|
+
[me],
|
|
2012
|
+
[he],
|
|
1918
2013
|
[
|
|
1919
|
-
|
|
2014
|
+
fe,
|
|
1920
2015
|
{
|
|
1921
|
-
useClass:
|
|
2016
|
+
useClass: Vt
|
|
1922
2017
|
}
|
|
1923
2018
|
],
|
|
1924
2019
|
[T],
|
|
1925
2020
|
// controllers
|
|
1926
|
-
[
|
|
1927
|
-
[
|
|
1928
|
-
[
|
|
2021
|
+
[ue],
|
|
2022
|
+
[le],
|
|
2023
|
+
[de]
|
|
1929
2024
|
].forEach((t) => e.add(t));
|
|
1930
2025
|
}
|
|
1931
|
-
},
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
],
|
|
2026
|
+
}, x(ae, "pluginName", Fn), x(ae, "type", W.UNIVER_DOC), ae);
|
|
2027
|
+
lt = wn([
|
|
2028
|
+
Ln(1, V(zt))
|
|
2029
|
+
], lt);
|
|
1935
2030
|
export {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2031
|
+
pn as AlignCenterCommand,
|
|
2032
|
+
_n as AlignJustifyCommand,
|
|
2033
|
+
hn as AlignLeftCommand,
|
|
2034
|
+
ie as AlignOperationCommand,
|
|
2035
|
+
Sn as AlignRightCommand,
|
|
2036
|
+
nn as BreakLineCommand,
|
|
2037
|
+
gn as BulletListCommand,
|
|
2038
|
+
In as CoverContentCommand,
|
|
2039
|
+
pt as CutContentCommand,
|
|
2040
|
+
Yn as DOCS_COMPONENT_DEFAULT_Z_INDEX,
|
|
2041
|
+
Xn as DOCS_COMPONENT_HEADER_LAYER_INDEX,
|
|
2042
|
+
Hn as DOCS_COMPONENT_MAIN_LAYER_INDEX,
|
|
2043
|
+
kt as DOCS_VIEW_KEY,
|
|
2044
|
+
Se as DeleteCommand,
|
|
2045
|
+
cn as DeleteLeftCommand,
|
|
2046
|
+
ln as DeleteRightCommand,
|
|
2047
|
+
H as DocSkeletonManagerService,
|
|
2048
|
+
me as DocStateChangeManagerService,
|
|
2049
|
+
ne as DocViewModelManagerService,
|
|
2050
|
+
_t as IMEInputCommand,
|
|
2051
|
+
he as IMEInputManagerService,
|
|
2052
|
+
Zn as InnerPasteCommand,
|
|
2053
|
+
pe as InsertCommand,
|
|
2054
|
+
ye as MoveCursorOperation,
|
|
2055
|
+
Oe as MoveSelectionOperation,
|
|
2056
|
+
Wn as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
|
|
2057
|
+
fn as OrderListCommand,
|
|
2058
|
+
vn as ReplaceContentCommand,
|
|
2059
|
+
je as ResetInlineFormatTextBackgroundColorCommand,
|
|
2060
|
+
L as RichTextEditingMutation,
|
|
2061
|
+
Rn as SelectAllOperation,
|
|
2062
|
+
Cn as SetDocZoomRatioCommand,
|
|
2063
|
+
ce as SetDocZoomRatioOperation,
|
|
2064
|
+
Ue as SetInlineFormatBoldCommand,
|
|
2065
|
+
It as SetInlineFormatCommand,
|
|
2066
|
+
Ve as SetInlineFormatFontFamilyCommand,
|
|
2067
|
+
$e as SetInlineFormatFontSizeCommand,
|
|
2068
|
+
we as SetInlineFormatItalicCommand,
|
|
2069
|
+
Be as SetInlineFormatStrikethroughCommand,
|
|
2070
|
+
se as SetInlineFormatSubscriptCommand,
|
|
2071
|
+
Fe as SetInlineFormatSuperscriptCommand,
|
|
2072
|
+
ke as SetInlineFormatTextBackgroundColorCommand,
|
|
2073
|
+
ze as SetInlineFormatTextColorCommand,
|
|
2074
|
+
Le as SetInlineFormatUnderlineCommand,
|
|
2075
|
+
ft as SetTextSelectionsOperation,
|
|
1979
2076
|
T as TextSelectionManagerService,
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
2077
|
+
lt as UniverDocsPlugin,
|
|
2078
|
+
ht as UpdateCommand,
|
|
2079
|
+
jt as VIEWPORT_KEY,
|
|
2080
|
+
gt as getDocObject,
|
|
2081
|
+
Gn as getDocObjectById,
|
|
2082
|
+
Z as serializeTextRange
|
|
1986
2083
|
};
|