@univerjs/docs 0.1.7 → 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 +774 -724
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +1 -1
- 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/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 +10 -10
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:
|
|
15
|
+
const { mainComponent: r, scene: i, engine: a } = o;
|
|
13
16
|
return {
|
|
14
|
-
document:
|
|
17
|
+
document: r,
|
|
15
18
|
scene: i,
|
|
16
19
|
engine: a
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
|
-
function Gn(
|
|
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:
|
|
27
|
-
engine:
|
|
29
|
+
scene: o,
|
|
30
|
+
engine: r
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
|
-
var
|
|
31
|
-
const Hn = 0, Xn = 2, Yn = 10, Wn = "normalTextSelectionPluginName",
|
|
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 Gt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Xt = (
|
|
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,10 +86,10 @@ let T = class extends ue {
|
|
|
83
86
|
const e = this._getTextRanges(this._currentSelection);
|
|
84
87
|
if (e == null)
|
|
85
88
|
return;
|
|
86
|
-
const { textRanges: t, segmentId: n, style:
|
|
87
|
-
if (
|
|
89
|
+
const { textRanges: t, segmentId: n, style: o } = e, r = t.find((m) => m.isActive());
|
|
90
|
+
if (r == null)
|
|
88
91
|
return null;
|
|
89
|
-
const { startOffset: i, endOffset: a, collapsed: c, startNodePosition: d, endNodePosition: l, direction: u } =
|
|
92
|
+
const { startOffset: i, endOffset: a, collapsed: c, startNodePosition: d, endNodePosition: l, direction: u } = r;
|
|
90
93
|
return i == null || a == null ? null : {
|
|
91
94
|
startOffset: i,
|
|
92
95
|
endOffset: a,
|
|
@@ -95,7 +98,7 @@ let T = class extends ue {
|
|
|
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 ue {
|
|
|
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 ue {
|
|
|
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,67 +129,67 @@ let T = class extends ue {
|
|
|
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:
|
|
133
|
-
segmentId:
|
|
135
|
+
subUnitId: o,
|
|
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
164
|
T = Xt([
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
Je(0, fe),
|
|
166
|
+
Je(1, I)
|
|
164
167
|
], T);
|
|
165
|
-
function be(
|
|
166
|
-
const { startOffset: n, endOffset:
|
|
167
|
-
return i > 0 &&
|
|
168
|
-
t:
|
|
168
|
+
function be(s, e = "", t = 0) {
|
|
169
|
+
const { startOffset: n, endOffset: o } = s, r = [], i = n - t, a = o - t;
|
|
170
|
+
return i > 0 && r.push({
|
|
171
|
+
t: y.RETAIN,
|
|
169
172
|
len: i,
|
|
170
173
|
segmentId: e
|
|
171
|
-
}),
|
|
172
|
-
t:
|
|
174
|
+
}), r.push({
|
|
175
|
+
t: y.DELETE,
|
|
173
176
|
len: a - i,
|
|
174
177
|
line: 0,
|
|
175
178
|
segmentId: e
|
|
176
|
-
}),
|
|
179
|
+
}), r;
|
|
177
180
|
}
|
|
178
|
-
var Yt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, Zt = (
|
|
179
|
-
for (var
|
|
180
|
-
(i =
|
|
181
|
-
return n &&
|
|
182
|
-
}, Jt = (
|
|
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 te = class extends ue {
|
|
|
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,22 +221,22 @@ let te = class extends ue {
|
|
|
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
|
}
|
|
@@ -242,22 +245,22 @@ let te = class extends ue {
|
|
|
242
245
|
return new Pt(e);
|
|
243
246
|
}
|
|
244
247
|
};
|
|
245
|
-
|
|
248
|
+
ne = Zt([
|
|
246
249
|
Jt(0, E)
|
|
247
|
-
],
|
|
248
|
-
var qt = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Qt = (
|
|
249
|
-
for (var
|
|
250
|
-
(i =
|
|
251
|
-
return n &&
|
|
252
|
-
},
|
|
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);
|
|
253
256
|
const en = 300;
|
|
254
|
-
let
|
|
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 de = class extends ue {
|
|
|
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,14 +281,14 @@ let de = class extends ue {
|
|
|
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
|
-
const
|
|
285
|
-
|
|
287
|
+
const r = this._stateCache.get(n);
|
|
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
|
}
|
|
@@ -294,7 +297,7 @@ let de = class extends ue {
|
|
|
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
302
|
actions: n.reduce((l, u) => P.compose(l, u.redoState.actions), []),
|
|
300
303
|
textRanges: a.redoState.textRanges
|
|
@@ -306,21 +309,21 @@ let de = class extends ue {
|
|
|
306
309
|
};
|
|
307
310
|
t.pushUndoRedo({
|
|
308
311
|
unitID: e,
|
|
309
|
-
undoMutations: [{ id:
|
|
310
|
-
redoMutations: [{ id:
|
|
312
|
+
undoMutations: [{ id: r, params: d }],
|
|
313
|
+
redoMutations: [{ id: r, params: c }]
|
|
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 ge {
|
|
|
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,46 +366,46 @@ class ge {
|
|
|
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: (
|
|
372
|
+
handler: (s, e) => {
|
|
370
373
|
var B;
|
|
371
374
|
const {
|
|
372
375
|
unitId: t,
|
|
373
376
|
actions: n,
|
|
374
|
-
textRanges:
|
|
375
|
-
prevTextRanges:
|
|
377
|
+
textRanges: o,
|
|
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
|
-
textRanges:
|
|
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:
|
|
405
|
-
textRanges:
|
|
407
|
+
actions: M,
|
|
408
|
+
textRanges: r != null ? r : f
|
|
406
409
|
}
|
|
407
410
|
};
|
|
408
411
|
if (c) {
|
|
@@ -410,19 +413,19 @@ const Je = "doc.mutation.rich-text-editing", L = {
|
|
|
410
413
|
if (O == null)
|
|
411
414
|
throw new Error("historyParams is null in RichTextEditingMutation");
|
|
412
415
|
const { undoMutationParams: U, redoMutationParams: w, previousActiveRange: X } = O;
|
|
413
|
-
|
|
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:
|
|
418
|
-
textRanges:
|
|
420
|
+
actions: M,
|
|
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 =
|
|
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 = {
|
|
426
429
|
id: L.id,
|
|
427
430
|
params: {
|
|
428
431
|
unitId: i,
|
|
@@ -431,47 +434,47 @@ const Je = "doc.mutation.rich-text-editing", L = {
|
|
|
431
434
|
}
|
|
432
435
|
}, u = new P();
|
|
433
436
|
return d ? c > 0 && u.push({
|
|
434
|
-
t:
|
|
437
|
+
t: y.RETAIN,
|
|
435
438
|
len: c,
|
|
436
|
-
segmentId:
|
|
437
|
-
}) : u.push(...be(n,
|
|
438
|
-
t:
|
|
439
|
-
body:
|
|
440
|
-
len:
|
|
439
|
+
segmentId: o
|
|
440
|
+
}) : u.push(...be(n, o)), u.push({
|
|
441
|
+
t: y.INSERT,
|
|
442
|
+
body: r,
|
|
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 G = /* @__PURE__ */ ((
|
|
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 =
|
|
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 = {
|
|
452
455
|
id: L.id,
|
|
453
456
|
params: {
|
|
454
|
-
unitId:
|
|
457
|
+
unitId: r,
|
|
455
458
|
actions: [],
|
|
456
459
|
textRanges: a
|
|
457
460
|
}
|
|
458
461
|
}, u = new P();
|
|
459
462
|
return d > 0 && u.push({
|
|
460
|
-
t:
|
|
463
|
+
t: y.RETAIN,
|
|
461
464
|
len: i === 0 ? d - c : d,
|
|
462
|
-
segmentId:
|
|
465
|
+
segmentId: o
|
|
463
466
|
}), u.push({
|
|
464
|
-
t:
|
|
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:
|
|
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 = {
|
|
475
478
|
id: L.id,
|
|
476
479
|
params: {
|
|
477
480
|
unitId: i,
|
|
@@ -480,72 +483,75 @@ const fe = {
|
|
|
480
483
|
}
|
|
481
484
|
}, l = new P(), { startOffset: u, endOffset: m } = t;
|
|
482
485
|
return l.push({
|
|
483
|
-
t:
|
|
486
|
+
t: y.RETAIN,
|
|
484
487
|
len: u,
|
|
485
488
|
segmentId: n
|
|
486
489
|
}), l.push({
|
|
487
|
-
t:
|
|
488
|
-
body:
|
|
490
|
+
t: y.RETAIN,
|
|
491
|
+
body: o,
|
|
489
492
|
len: m - u,
|
|
490
493
|
segmentId: n,
|
|
491
|
-
coverType:
|
|
494
|
+
coverType: r
|
|
492
495
|
}), d.params.actions = l.serialize(), !!c.syncExecuteCommand(d.id, d.params);
|
|
493
496
|
}
|
|
494
497
|
};
|
|
495
|
-
function tn(
|
|
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
509
|
const nn = {
|
|
507
510
|
id: "doc.command.break-line",
|
|
508
511
|
type: v.COMMAND,
|
|
509
|
-
handler: async (
|
|
510
|
-
var p,
|
|
511
|
-
const e =
|
|
512
|
-
if (
|
|
512
|
+
handler: async (s) => {
|
|
513
|
+
var p, h;
|
|
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
|
-
], m = ((
|
|
521
|
-
return await n.executeCommand(
|
|
526
|
+
], m = ((h = (p = r.getBody()) == null ? void 0 : p.paragraphs) != null ? h : []).find((f) => f.startIndex >= a);
|
|
527
|
+
return await n.executeCommand(pe.id, {
|
|
522
528
|
unitId: i,
|
|
523
529
|
body: {
|
|
524
530
|
dataStream: xe.PARAGRAPH,
|
|
525
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 H = class extends
|
|
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 H = class extends ue {
|
|
|
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() {
|
|
@@ -597,52 +604,59 @@ let H = class extends ue {
|
|
|
597
604
|
return Ut.create(e, this._localeService);
|
|
598
605
|
}
|
|
599
606
|
};
|
|
600
|
-
H =
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
607
|
+
H = rn([
|
|
608
|
+
Re(0, V(Tt)),
|
|
609
|
+
Re(1, V(ne)),
|
|
610
|
+
Re(2, E)
|
|
604
611
|
], H);
|
|
605
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
|
|
619
|
+
const d = a.getCurrentUniverDocInstance();
|
|
620
|
+
if (!d)
|
|
621
|
+
return !1;
|
|
622
|
+
const l = d.getUnitId(), u = {
|
|
613
623
|
id: L.id,
|
|
614
624
|
params: {
|
|
615
625
|
unitId: l,
|
|
616
626
|
actions: [],
|
|
617
|
-
textRanges:
|
|
627
|
+
textRanges: o
|
|
618
628
|
}
|
|
619
629
|
}, m = new oe();
|
|
620
630
|
m.reset();
|
|
621
631
|
const g = new P();
|
|
622
|
-
for (const
|
|
623
|
-
const { startOffset:
|
|
632
|
+
for (const h of c) {
|
|
633
|
+
const { startOffset: f, endOffset: S, collapsed: _ } = h, R = f - m.cursor;
|
|
624
634
|
_ ? g.push({
|
|
625
|
-
t:
|
|
626
|
-
len:
|
|
635
|
+
t: y.RETAIN,
|
|
636
|
+
len: R,
|
|
627
637
|
segmentId: t
|
|
628
|
-
}) : g.push(...be(
|
|
629
|
-
t:
|
|
638
|
+
}) : g.push(...be(h, t, m.cursor)), g.push({
|
|
639
|
+
t: y.INSERT,
|
|
630
640
|
body: n,
|
|
631
641
|
len: n.dataStream.length,
|
|
632
642
|
line: 0,
|
|
633
643
|
segmentId: t
|
|
634
644
|
}), m.reset(), m.moveCursor(S);
|
|
635
645
|
}
|
|
636
|
-
return u.params.actions = g.serialize(), !!
|
|
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 = {
|
|
@@ -656,44 +670,44 @@ const Zn = {
|
|
|
656
670
|
m.reset();
|
|
657
671
|
const g = new P();
|
|
658
672
|
for (const f of a) {
|
|
659
|
-
const { startOffset:
|
|
660
|
-
|
|
661
|
-
t:
|
|
662
|
-
len:
|
|
673
|
+
const { startOffset: S, endOffset: _, collapsed: R } = f, M = S - m.cursor;
|
|
674
|
+
R ? g.push({
|
|
675
|
+
t: y.RETAIN,
|
|
676
|
+
len: M,
|
|
663
677
|
segmentId: t
|
|
664
|
-
}) : g.push(...an(f, l, t, m.cursor)), m.reset(), m.moveCursor(
|
|
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 an(
|
|
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({
|
|
674
|
-
t:
|
|
688
|
+
t: y.RETAIN,
|
|
675
689
|
len: c,
|
|
676
690
|
segmentId: t
|
|
677
691
|
}), l && l.startIndex - n > c) {
|
|
678
692
|
const u = l.startIndex - n;
|
|
679
693
|
i.push({
|
|
680
|
-
t:
|
|
694
|
+
t: y.DELETE,
|
|
681
695
|
len: u - c,
|
|
682
696
|
line: 0,
|
|
683
697
|
segmentId: t
|
|
684
698
|
}), i.push({
|
|
685
|
-
t:
|
|
699
|
+
t: y.RETAIN,
|
|
686
700
|
len: 1,
|
|
687
701
|
segmentId: t
|
|
688
702
|
}), d > u + 1 && i.push({
|
|
689
|
-
t:
|
|
703
|
+
t: y.DELETE,
|
|
690
704
|
len: d - u - 1,
|
|
691
705
|
line: 0,
|
|
692
706
|
segmentId: t
|
|
693
707
|
});
|
|
694
708
|
} else
|
|
695
709
|
i.push({
|
|
696
|
-
t:
|
|
710
|
+
t: y.DELETE,
|
|
697
711
|
len: d - c,
|
|
698
712
|
line: 0,
|
|
699
713
|
segmentId: t
|
|
@@ -703,30 +717,33 @@ function an(o, e, t = "", n = 0) {
|
|
|
703
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
|
-
if (
|
|
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 (Bt(p) && _ !== p && (
|
|
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 D =
|
|
720
|
-
if (
|
|
721
|
-
const O =
|
|
736
|
+
const D = C == null ? void 0 : C.startIndex, A = { startIndex: 0 }, b = C.paragraphStyle;
|
|
737
|
+
if (h === !0) {
|
|
738
|
+
const O = C.paragraphStyle;
|
|
722
739
|
if (O) {
|
|
723
740
|
A.paragraphStyle = O;
|
|
724
741
|
const { hanging: U } = O;
|
|
725
742
|
U && (A.paragraphStyle.indentStart = U, A.paragraphStyle.hanging = void 0);
|
|
726
743
|
}
|
|
727
|
-
} else if (
|
|
728
|
-
const O =
|
|
729
|
-
O && (A.bullet = O),
|
|
744
|
+
} else if (f === !0) {
|
|
745
|
+
const O = C.bullet;
|
|
746
|
+
O && (A.bullet = O), b != null && (A.paragraphStyle = { ...b }, delete A.paragraphStyle.hanging, delete A.paragraphStyle.indentStart);
|
|
730
747
|
}
|
|
731
748
|
const B = [
|
|
732
749
|
{
|
|
@@ -735,7 +752,7 @@ const cn = {
|
|
|
735
752
|
style: g
|
|
736
753
|
}
|
|
737
754
|
];
|
|
738
|
-
c = await
|
|
755
|
+
c = await o.executeCommand(ht.id, {
|
|
739
756
|
unitId: d.getUnitId(),
|
|
740
757
|
updateBody: {
|
|
741
758
|
dataStream: "",
|
|
@@ -746,40 +763,40 @@ const cn = {
|
|
|
746
763
|
endOffset: D + 1
|
|
747
764
|
},
|
|
748
765
|
textRanges: B,
|
|
749
|
-
coverType:
|
|
766
|
+
coverType: Ee.REPLACE,
|
|
750
767
|
segmentId: m
|
|
751
768
|
});
|
|
752
769
|
} else if (u === !0) {
|
|
753
770
|
if (_ == null)
|
|
754
771
|
return !0;
|
|
755
772
|
if (_.content === "\r")
|
|
756
|
-
c = await
|
|
773
|
+
c = await o.executeCommand(Pe.id, {
|
|
757
774
|
direction: G.LEFT,
|
|
758
|
-
range:
|
|
775
|
+
range: r
|
|
759
776
|
});
|
|
760
777
|
else {
|
|
761
778
|
S -= _.count;
|
|
762
|
-
const
|
|
779
|
+
const C = [
|
|
763
780
|
{
|
|
764
781
|
startOffset: S,
|
|
765
782
|
endOffset: S,
|
|
766
783
|
style: g
|
|
767
784
|
}
|
|
768
785
|
];
|
|
769
|
-
c = await
|
|
786
|
+
c = await o.executeCommand(Se.id, {
|
|
770
787
|
unitId: d.getUnitId(),
|
|
771
|
-
range:
|
|
788
|
+
range: r,
|
|
772
789
|
segmentId: m,
|
|
773
790
|
direction: G.LEFT,
|
|
774
791
|
len: _.count,
|
|
775
|
-
textRanges:
|
|
792
|
+
textRanges: C
|
|
776
793
|
});
|
|
777
794
|
}
|
|
778
795
|
} else {
|
|
779
|
-
const
|
|
780
|
-
c = await
|
|
796
|
+
const C = St(r, i);
|
|
797
|
+
c = await o.executeCommand(pt.id, {
|
|
781
798
|
segmentId: m,
|
|
782
|
-
textRanges:
|
|
799
|
+
textRanges: C
|
|
783
800
|
});
|
|
784
801
|
}
|
|
785
802
|
return c;
|
|
@@ -787,143 +804,149 @@ const cn = {
|
|
|
787
804
|
}, ln = {
|
|
788
805
|
id: "doc.command.delete-right",
|
|
789
806
|
type: v.COMMAND,
|
|
790
|
-
handler: async (
|
|
807
|
+
handler: async (s) => {
|
|
791
808
|
var p;
|
|
792
|
-
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;
|
|
793
810
|
let c;
|
|
794
|
-
if (
|
|
811
|
+
if (r == null || a == null || i == null)
|
|
812
|
+
return !1;
|
|
813
|
+
const d = n.getCurrentUniverDocInstance();
|
|
814
|
+
if (!d)
|
|
795
815
|
return !1;
|
|
796
|
-
const
|
|
816
|
+
const { startOffset: l, collapsed: u, segmentId: m, style: g } = r;
|
|
797
817
|
if (l === d.getBody().dataStream.length - 2 && u)
|
|
798
818
|
return !0;
|
|
799
819
|
if (u === !0) {
|
|
800
|
-
const
|
|
801
|
-
if (
|
|
802
|
-
c = await
|
|
820
|
+
const h = a.findNodeByCharIndex(l);
|
|
821
|
+
if (h.content === "\r")
|
|
822
|
+
c = await o.executeCommand(Pe.id, {
|
|
803
823
|
direction: G.RIGHT,
|
|
804
|
-
range:
|
|
824
|
+
range: r
|
|
805
825
|
});
|
|
806
826
|
else {
|
|
807
|
-
const
|
|
827
|
+
const f = [
|
|
808
828
|
{
|
|
809
829
|
startOffset: l,
|
|
810
830
|
endOffset: l,
|
|
811
831
|
style: g
|
|
812
832
|
}
|
|
813
833
|
];
|
|
814
|
-
c = await
|
|
834
|
+
c = await o.executeCommand(Se.id, {
|
|
815
835
|
unitId: d.getUnitId(),
|
|
816
|
-
range:
|
|
836
|
+
range: r,
|
|
817
837
|
segmentId: m,
|
|
818
838
|
direction: G.RIGHT,
|
|
819
|
-
textRanges:
|
|
820
|
-
len:
|
|
839
|
+
textRanges: f,
|
|
840
|
+
len: h.count
|
|
821
841
|
});
|
|
822
842
|
}
|
|
823
843
|
} else {
|
|
824
|
-
const
|
|
825
|
-
c = await
|
|
844
|
+
const h = St(r, i);
|
|
845
|
+
c = await o.executeCommand(pt.id, {
|
|
826
846
|
segmentId: m,
|
|
827
|
-
textRanges:
|
|
847
|
+
textRanges: h
|
|
828
848
|
});
|
|
829
849
|
}
|
|
830
850
|
return c;
|
|
831
851
|
}
|
|
832
|
-
},
|
|
852
|
+
}, Pe = {
|
|
833
853
|
id: "doc.command.merge-two-paragraph",
|
|
834
854
|
type: v.COMMAND,
|
|
835
|
-
handler: async (
|
|
836
|
-
var A,
|
|
837
|
-
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();
|
|
838
858
|
if (a == null || c == null)
|
|
839
859
|
return !1;
|
|
840
|
-
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;
|
|
841
864
|
if (!u)
|
|
842
865
|
return !1;
|
|
843
|
-
const p =
|
|
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 = [
|
|
844
867
|
{
|
|
845
868
|
startOffset: S,
|
|
846
869
|
endOffset: S,
|
|
847
870
|
style: g
|
|
848
871
|
}
|
|
849
|
-
],
|
|
872
|
+
], M = {
|
|
850
873
|
id: L.id,
|
|
851
874
|
params: {
|
|
852
875
|
unitId: _,
|
|
853
876
|
actions: [],
|
|
854
|
-
textRanges:
|
|
877
|
+
textRanges: R,
|
|
855
878
|
prevTextRanges: [i]
|
|
856
879
|
}
|
|
857
|
-
},
|
|
858
|
-
return
|
|
859
|
-
t:
|
|
860
|
-
len:
|
|
880
|
+
}, C = new P();
|
|
881
|
+
return C.push({
|
|
882
|
+
t: y.RETAIN,
|
|
883
|
+
len: r === G.LEFT ? l - 1 : l,
|
|
861
884
|
segmentId: m
|
|
862
|
-
}),
|
|
863
|
-
t:
|
|
864
|
-
body:
|
|
865
|
-
len:
|
|
885
|
+
}), f.dataStream.length && C.push({
|
|
886
|
+
t: y.INSERT,
|
|
887
|
+
body: f,
|
|
888
|
+
len: f.dataStream.length,
|
|
866
889
|
line: 0,
|
|
867
890
|
segmentId: m
|
|
868
|
-
}),
|
|
869
|
-
t:
|
|
891
|
+
}), C.push({
|
|
892
|
+
t: y.RETAIN,
|
|
870
893
|
len: 1,
|
|
871
894
|
segmentId: m
|
|
872
|
-
}),
|
|
873
|
-
t:
|
|
874
|
-
len:
|
|
895
|
+
}), C.push({
|
|
896
|
+
t: y.DELETE,
|
|
897
|
+
len: h + 1 - p,
|
|
875
898
|
line: 0,
|
|
876
899
|
segmentId: m
|
|
877
|
-
}),
|
|
900
|
+
}), M.params.actions = C.serialize(), !!o.syncExecuteCommand(M.id, M.params);
|
|
878
901
|
}
|
|
879
902
|
};
|
|
880
|
-
function dn(
|
|
881
|
-
const { textRuns: n } =
|
|
903
|
+
function dn(s, e, t) {
|
|
904
|
+
const { textRuns: n } = s, o = s.dataStream.substring(e, t);
|
|
882
905
|
if (n == null)
|
|
883
906
|
return {
|
|
884
|
-
dataStream:
|
|
907
|
+
dataStream: o
|
|
885
908
|
};
|
|
886
|
-
const
|
|
909
|
+
const r = [];
|
|
887
910
|
for (const i of n) {
|
|
888
911
|
const { st: a, ed: c } = i;
|
|
889
|
-
c <= e || a >= t || (a < e ?
|
|
912
|
+
c <= e || a >= t || (a < e ? r.push({
|
|
890
913
|
...i,
|
|
891
914
|
st: 0,
|
|
892
915
|
ed: c - e
|
|
893
|
-
}) : c > t ?
|
|
916
|
+
}) : c > t ? r.push({
|
|
894
917
|
...i,
|
|
895
918
|
st: a - e,
|
|
896
919
|
ed: t - e
|
|
897
|
-
}) :
|
|
920
|
+
}) : r.push({
|
|
898
921
|
...i,
|
|
899
922
|
st: a - e,
|
|
900
923
|
ed: c - e
|
|
901
924
|
}));
|
|
902
925
|
}
|
|
903
926
|
return {
|
|
904
|
-
dataStream:
|
|
905
|
-
textRuns:
|
|
927
|
+
dataStream: o,
|
|
928
|
+
textRuns: r
|
|
906
929
|
};
|
|
907
930
|
}
|
|
908
|
-
function
|
|
909
|
-
let t =
|
|
910
|
-
for (const
|
|
911
|
-
const { startOffset:
|
|
912
|
-
|
|
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);
|
|
913
936
|
}
|
|
914
937
|
return [
|
|
915
938
|
{
|
|
916
939
|
startOffset: t,
|
|
917
940
|
endOffset: t,
|
|
918
|
-
style:
|
|
941
|
+
style: s.style
|
|
919
942
|
}
|
|
920
943
|
];
|
|
921
944
|
}
|
|
922
|
-
const
|
|
945
|
+
const _t = {
|
|
923
946
|
id: "doc.command.ime-input",
|
|
924
947
|
type: v.COMMAND,
|
|
925
|
-
handler: async (
|
|
926
|
-
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();
|
|
927
950
|
if (d == null)
|
|
928
951
|
return !1;
|
|
929
952
|
const { startOffset: l, style: u, segmentId: m } = d, g = n.length, p = [
|
|
@@ -933,62 +956,50 @@ const St = {
|
|
|
933
956
|
collapsed: !0,
|
|
934
957
|
style: u
|
|
935
958
|
}
|
|
936
|
-
],
|
|
959
|
+
], h = {
|
|
937
960
|
id: L.id,
|
|
938
961
|
params: {
|
|
939
962
|
unitId: t,
|
|
940
963
|
actions: [],
|
|
941
964
|
textRanges: p
|
|
942
965
|
}
|
|
943
|
-
},
|
|
944
|
-
!d.collapsed && i ?
|
|
945
|
-
t:
|
|
966
|
+
}, f = new P();
|
|
967
|
+
!d.collapsed && i ? f.push(...be(d, m)) : f.push({
|
|
968
|
+
t: y.RETAIN,
|
|
946
969
|
len: l,
|
|
947
970
|
segmentId: m
|
|
948
|
-
}),
|
|
949
|
-
t:
|
|
950
|
-
len:
|
|
971
|
+
}), o > 0 && f.push({
|
|
972
|
+
t: y.DELETE,
|
|
973
|
+
len: o,
|
|
951
974
|
line: 0,
|
|
952
975
|
segmentId: m
|
|
953
|
-
}),
|
|
954
|
-
t:
|
|
976
|
+
}), f.push({
|
|
977
|
+
t: y.INSERT,
|
|
955
978
|
body: {
|
|
956
979
|
dataStream: n
|
|
957
980
|
},
|
|
958
981
|
len: n.length,
|
|
959
982
|
line: 0,
|
|
960
983
|
segmentId: m
|
|
961
|
-
}),
|
|
962
|
-
const S = a.syncExecuteCommand(
|
|
963
|
-
return c.pushUndoRedoMutationParams(S,
|
|
984
|
+
}), h.params.actions = f.serialize(), h.params.noHistory = !r, h.params.isCompositionEnd = r;
|
|
985
|
+
const S = a.syncExecuteCommand(h.id, h.params);
|
|
986
|
+
return c.pushUndoRedoMutationParams(S, h.params), !!S;
|
|
964
987
|
}
|
|
965
988
|
};
|
|
966
|
-
function F(
|
|
967
|
-
var
|
|
968
|
-
const { segmentId:
|
|
969
|
-
return
|
|
970
|
-
segmentId:
|
|
971
|
-
preCommandId:
|
|
989
|
+
function F(s, e, t, n) {
|
|
990
|
+
var r;
|
|
991
|
+
const { segmentId: o } = (r = t.getActiveRange()) != null ? r : {};
|
|
992
|
+
return o == null ? !1 : n.executeCommand(It.id, {
|
|
993
|
+
segmentId: o,
|
|
994
|
+
preCommandId: s,
|
|
972
995
|
...e != null ? e : {}
|
|
973
996
|
});
|
|
974
997
|
}
|
|
975
|
-
const
|
|
976
|
-
id: qe,
|
|
977
|
-
type: v.COMMAND,
|
|
978
|
-
handler: async (o, e) => {
|
|
979
|
-
const t = o.get(I), n = o.get(T);
|
|
980
|
-
return F(
|
|
981
|
-
qe,
|
|
982
|
-
e,
|
|
983
|
-
n,
|
|
984
|
-
t
|
|
985
|
-
);
|
|
986
|
-
}
|
|
987
|
-
}, Ke = "doc.command.set-inline-format-italic", Ue = {
|
|
998
|
+
const Ke = "doc.command.set-inline-format-bold", Ue = {
|
|
988
999
|
id: Ke,
|
|
989
1000
|
type: v.COMMAND,
|
|
990
|
-
handler: async (
|
|
991
|
-
const t =
|
|
1001
|
+
handler: async (s, e) => {
|
|
1002
|
+
const t = s.get(I), n = s.get(T);
|
|
992
1003
|
return F(
|
|
993
1004
|
Ke,
|
|
994
1005
|
e,
|
|
@@ -996,11 +1007,11 @@ const qe = "doc.command.set-inline-format-bold", Pe = {
|
|
|
996
1007
|
t
|
|
997
1008
|
);
|
|
998
1009
|
}
|
|
999
|
-
}, Qe = "doc.command.set-inline-format-
|
|
1010
|
+
}, Qe = "doc.command.set-inline-format-italic", we = {
|
|
1000
1011
|
id: Qe,
|
|
1001
1012
|
type: v.COMMAND,
|
|
1002
|
-
handler: async (
|
|
1003
|
-
const t =
|
|
1013
|
+
handler: async (s, e) => {
|
|
1014
|
+
const t = s.get(I), n = s.get(T);
|
|
1004
1015
|
return F(
|
|
1005
1016
|
Qe,
|
|
1006
1017
|
e,
|
|
@@ -1008,11 +1019,11 @@ const qe = "doc.command.set-inline-format-bold", Pe = {
|
|
|
1008
1019
|
t
|
|
1009
1020
|
);
|
|
1010
1021
|
}
|
|
1011
|
-
}, et = "doc.command.set-inline-format-
|
|
1022
|
+
}, et = "doc.command.set-inline-format-underline", Le = {
|
|
1012
1023
|
id: et,
|
|
1013
1024
|
type: v.COMMAND,
|
|
1014
|
-
handler: async (
|
|
1015
|
-
const t =
|
|
1025
|
+
handler: async (s, e) => {
|
|
1026
|
+
const t = s.get(I), n = s.get(T);
|
|
1016
1027
|
return F(
|
|
1017
1028
|
et,
|
|
1018
1029
|
e,
|
|
@@ -1020,11 +1031,11 @@ const qe = "doc.command.set-inline-format-bold", Pe = {
|
|
|
1020
1031
|
t
|
|
1021
1032
|
);
|
|
1022
1033
|
}
|
|
1023
|
-
}, tt = "doc.command.set-inline-format-
|
|
1034
|
+
}, tt = "doc.command.set-inline-format-strikethrough", Be = {
|
|
1024
1035
|
id: tt,
|
|
1025
1036
|
type: v.COMMAND,
|
|
1026
|
-
handler: async (
|
|
1027
|
-
const t =
|
|
1037
|
+
handler: async (s, e) => {
|
|
1038
|
+
const t = s.get(I), n = s.get(T);
|
|
1028
1039
|
return F(
|
|
1029
1040
|
tt,
|
|
1030
1041
|
e,
|
|
@@ -1032,11 +1043,11 @@ const qe = "doc.command.set-inline-format-bold", Pe = {
|
|
|
1032
1043
|
t
|
|
1033
1044
|
);
|
|
1034
1045
|
}
|
|
1035
|
-
}, nt = "doc.command.set-inline-format-
|
|
1046
|
+
}, nt = "doc.command.set-inline-format-subscript", se = {
|
|
1036
1047
|
id: nt,
|
|
1037
1048
|
type: v.COMMAND,
|
|
1038
|
-
handler: async (
|
|
1039
|
-
const t =
|
|
1049
|
+
handler: async (s, e) => {
|
|
1050
|
+
const t = s.get(I), n = s.get(T);
|
|
1040
1051
|
return F(
|
|
1041
1052
|
nt,
|
|
1042
1053
|
e,
|
|
@@ -1044,47 +1055,47 @@ const qe = "doc.command.set-inline-format-bold", Pe = {
|
|
|
1044
1055
|
t
|
|
1045
1056
|
);
|
|
1046
1057
|
}
|
|
1047
|
-
},
|
|
1048
|
-
id:
|
|
1058
|
+
}, st = "doc.command.set-inline-format-superscript", Fe = {
|
|
1059
|
+
id: st,
|
|
1049
1060
|
type: v.COMMAND,
|
|
1050
|
-
handler: async (
|
|
1051
|
-
const t =
|
|
1061
|
+
handler: async (s, e) => {
|
|
1062
|
+
const t = s.get(I), n = s.get(T);
|
|
1052
1063
|
return F(
|
|
1053
|
-
|
|
1064
|
+
st,
|
|
1054
1065
|
e,
|
|
1055
1066
|
n,
|
|
1056
1067
|
t
|
|
1057
1068
|
);
|
|
1058
1069
|
}
|
|
1059
|
-
},
|
|
1060
|
-
id:
|
|
1070
|
+
}, ot = "doc.command.set-inline-format-fontsize", $e = {
|
|
1071
|
+
id: ot,
|
|
1061
1072
|
type: v.COMMAND,
|
|
1062
|
-
handler: async (
|
|
1063
|
-
const t =
|
|
1073
|
+
handler: async (s, e) => {
|
|
1074
|
+
const t = s.get(I), n = s.get(T);
|
|
1064
1075
|
return F(
|
|
1065
|
-
|
|
1076
|
+
ot,
|
|
1066
1077
|
e,
|
|
1067
1078
|
n,
|
|
1068
1079
|
t
|
|
1069
1080
|
);
|
|
1070
1081
|
}
|
|
1071
|
-
},
|
|
1072
|
-
id:
|
|
1082
|
+
}, rt = "doc.command.set-inline-format-font-family", Ve = {
|
|
1083
|
+
id: rt,
|
|
1073
1084
|
type: v.COMMAND,
|
|
1074
|
-
handler: async (
|
|
1075
|
-
const t =
|
|
1085
|
+
handler: async (s, e) => {
|
|
1086
|
+
const t = s.get(I), n = s.get(T);
|
|
1076
1087
|
return F(
|
|
1077
|
-
|
|
1088
|
+
rt,
|
|
1078
1089
|
e,
|
|
1079
1090
|
n,
|
|
1080
1091
|
t
|
|
1081
1092
|
);
|
|
1082
1093
|
}
|
|
1083
|
-
}, it = "doc.command.set-inline-format-text-
|
|
1094
|
+
}, it = "doc.command.set-inline-format-text-color", ze = {
|
|
1084
1095
|
id: it,
|
|
1085
1096
|
type: v.COMMAND,
|
|
1086
|
-
handler: async (
|
|
1087
|
-
const t =
|
|
1097
|
+
handler: async (s, e) => {
|
|
1098
|
+
const t = s.get(I), n = s.get(T);
|
|
1088
1099
|
return F(
|
|
1089
1100
|
it,
|
|
1090
1101
|
e,
|
|
@@ -1092,11 +1103,11 @@ const qe = "doc.command.set-inline-format-bold", Pe = {
|
|
|
1092
1103
|
t
|
|
1093
1104
|
);
|
|
1094
1105
|
}
|
|
1095
|
-
}, at = "doc.command.
|
|
1106
|
+
}, at = "doc.command.set-inline-format-text-background-color", ke = {
|
|
1096
1107
|
id: at,
|
|
1097
1108
|
type: v.COMMAND,
|
|
1098
|
-
handler: async (
|
|
1099
|
-
const t =
|
|
1109
|
+
handler: async (s, e) => {
|
|
1110
|
+
const t = s.get(I), n = s.get(T);
|
|
1100
1111
|
return F(
|
|
1101
1112
|
at,
|
|
1102
1113
|
e,
|
|
@@ -1104,44 +1115,59 @@ const qe = "doc.command.set-inline-format-bold", Pe = {
|
|
|
1104
1115
|
t
|
|
1105
1116
|
);
|
|
1106
1117
|
}
|
|
1107
|
-
},
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
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",
|
|
1114
1137
|
[ze.id]: "cl",
|
|
1115
1138
|
[ke.id]: "bg",
|
|
1116
|
-
[
|
|
1117
|
-
[
|
|
1118
|
-
[
|
|
1119
|
-
},
|
|
1139
|
+
[je.id]: "bg",
|
|
1140
|
+
[se.id]: "va",
|
|
1141
|
+
[Fe.id]: "va"
|
|
1142
|
+
}, It = {
|
|
1120
1143
|
id: "doc.command.set-inline-format",
|
|
1121
1144
|
type: v.COMMAND,
|
|
1122
|
-
handler: async (
|
|
1123
|
-
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();
|
|
1124
1147
|
if (!Array.isArray(c) || c.length === 0)
|
|
1125
1148
|
return !1;
|
|
1126
|
-
let d = a.getCurrentUniverDocInstance()
|
|
1127
|
-
|
|
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());
|
|
1128
1154
|
let u;
|
|
1129
|
-
switch (
|
|
1130
|
-
case Pe.id:
|
|
1155
|
+
switch (o) {
|
|
1131
1156
|
case Ue.id:
|
|
1132
1157
|
case we.id:
|
|
1133
1158
|
case Le.id:
|
|
1134
|
-
case
|
|
1135
|
-
case
|
|
1159
|
+
case Be.id:
|
|
1160
|
+
case se.id:
|
|
1161
|
+
case Fe.id: {
|
|
1136
1162
|
u = mn(
|
|
1137
1163
|
d.getBody().textRuns,
|
|
1138
|
-
|
|
1164
|
+
o,
|
|
1139
1165
|
c
|
|
1140
1166
|
);
|
|
1141
1167
|
break;
|
|
1142
1168
|
}
|
|
1143
|
-
case
|
|
1144
|
-
case
|
|
1169
|
+
case $e.id:
|
|
1170
|
+
case Ve.id: {
|
|
1145
1171
|
u = n;
|
|
1146
1172
|
break;
|
|
1147
1173
|
}
|
|
@@ -1152,97 +1178,100 @@ const qe = "doc.command.set-inline-format-bold", Pe = {
|
|
|
1152
1178
|
};
|
|
1153
1179
|
break;
|
|
1154
1180
|
}
|
|
1155
|
-
case
|
|
1181
|
+
case je.id: {
|
|
1156
1182
|
u = {
|
|
1157
1183
|
rgb: null
|
|
1158
1184
|
};
|
|
1159
1185
|
break;
|
|
1160
1186
|
}
|
|
1161
1187
|
default:
|
|
1162
|
-
throw new Error(`Unknown command: ${
|
|
1188
|
+
throw new Error(`Unknown command: ${o} in handleInlineFormat`);
|
|
1163
1189
|
}
|
|
1164
1190
|
const m = {
|
|
1165
1191
|
id: L.id,
|
|
1166
1192
|
params: {
|
|
1167
1193
|
unitId: l,
|
|
1168
1194
|
actions: [],
|
|
1169
|
-
textRanges: c.map(
|
|
1195
|
+
textRanges: c.map(Z)
|
|
1170
1196
|
}
|
|
1171
1197
|
}, g = new P(), p = new oe();
|
|
1172
1198
|
p.reset();
|
|
1173
|
-
for (const
|
|
1174
|
-
const { startOffset: S, endOffset: _ } =
|
|
1199
|
+
for (const f of c) {
|
|
1200
|
+
const { startOffset: S, endOffset: _ } = f, R = {
|
|
1175
1201
|
dataStream: "",
|
|
1176
1202
|
textRuns: [
|
|
1177
1203
|
{
|
|
1178
1204
|
st: 0,
|
|
1179
1205
|
ed: _ - S,
|
|
1180
1206
|
ts: {
|
|
1181
|
-
[
|
|
1207
|
+
[vt[o]]: u
|
|
1182
1208
|
}
|
|
1183
1209
|
}
|
|
1184
1210
|
]
|
|
1185
|
-
},
|
|
1186
|
-
|
|
1187
|
-
t:
|
|
1188
|
-
len:
|
|
1211
|
+
}, M = S - p.cursor;
|
|
1212
|
+
M !== 0 && g.push({
|
|
1213
|
+
t: y.RETAIN,
|
|
1214
|
+
len: M,
|
|
1189
1215
|
segmentId: t
|
|
1190
1216
|
}), g.push({
|
|
1191
|
-
t:
|
|
1192
|
-
body:
|
|
1217
|
+
t: y.RETAIN,
|
|
1218
|
+
body: R,
|
|
1193
1219
|
len: _ - S,
|
|
1194
1220
|
segmentId: t
|
|
1195
1221
|
}), p.reset(), p.moveCursor(_);
|
|
1196
1222
|
}
|
|
1197
|
-
return m.params.actions = g.serialize(), !!
|
|
1223
|
+
return m.params.actions = g.serialize(), !!r.syncExecuteCommand(m.id, m.params);
|
|
1198
1224
|
}
|
|
1199
1225
|
};
|
|
1200
|
-
function un(
|
|
1201
|
-
return
|
|
1226
|
+
function un(s) {
|
|
1227
|
+
return s !== null && typeof s == "object";
|
|
1202
1228
|
}
|
|
1203
|
-
function mn(
|
|
1204
|
-
let n = 0,
|
|
1205
|
-
const
|
|
1206
|
-
for (; n !==
|
|
1207
|
-
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];
|
|
1208
1234
|
if (a <= c)
|
|
1209
|
-
|
|
1235
|
+
o++;
|
|
1210
1236
|
else if (d <= i)
|
|
1211
1237
|
n++;
|
|
1212
1238
|
else {
|
|
1213
|
-
if (/bl|it/.test(
|
|
1214
|
-
return (l == null ? void 0 : l[
|
|
1215
|
-
if (/ul|st/.test(
|
|
1216
|
-
return un(l == null ? void 0 : l[
|
|
1217
|
-
s:
|
|
1239
|
+
if (/bl|it/.test(r))
|
|
1240
|
+
return (l == null ? void 0 : l[r]) === k.TRUE ? k.FALSE : k.TRUE;
|
|
1241
|
+
if (/ul|st/.test(r))
|
|
1242
|
+
return un(l == null ? void 0 : l[r]) && (l == null ? void 0 : l[r]).s === k.TRUE ? {
|
|
1243
|
+
s: k.FALSE
|
|
1218
1244
|
} : {
|
|
1219
|
-
s:
|
|
1245
|
+
s: k.TRUE
|
|
1220
1246
|
};
|
|
1221
|
-
if (/va/.test(
|
|
1222
|
-
return e ===
|
|
1247
|
+
if (/va/.test(r))
|
|
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;
|
|
1223
1249
|
n++;
|
|
1224
1250
|
}
|
|
1225
1251
|
}
|
|
1226
|
-
return /bl|it/.test(
|
|
1227
|
-
s:
|
|
1228
|
-
} : 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;
|
|
1229
1255
|
}
|
|
1230
|
-
const
|
|
1256
|
+
const Ge = {
|
|
1231
1257
|
id: "doc.command.list-operation",
|
|
1232
1258
|
type: v.COMMAND,
|
|
1233
|
-
handler: (
|
|
1259
|
+
handler: (s, e) => {
|
|
1234
1260
|
var O, U, w, X;
|
|
1235
|
-
const t =
|
|
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);
|
|
1236
1265
|
if (a == null || d == null)
|
|
1237
1266
|
return !1;
|
|
1238
|
-
const u =
|
|
1267
|
+
const u = Mt(a, d), { segmentId: m } = a, g = i.getUnitId(), p = u.every((Y) => {
|
|
1239
1268
|
var $;
|
|
1240
|
-
return (($ = Y.bullet) == null ? void 0 : $.listType) ===
|
|
1269
|
+
return (($ = Y.bullet) == null ? void 0 : $.listType) === r;
|
|
1241
1270
|
});
|
|
1242
|
-
let
|
|
1271
|
+
let f = Q.generateRandomId(6);
|
|
1243
1272
|
if (u.length === 1) {
|
|
1244
|
-
const Y = d.indexOf(u[0]), $ = d[Y - 1],
|
|
1245
|
-
$ && $.bullet && $.bullet.listType ===
|
|
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);
|
|
1246
1275
|
}
|
|
1247
1276
|
const S = {
|
|
1248
1277
|
id: L.id,
|
|
@@ -1253,36 +1282,36 @@ const je = {
|
|
|
1253
1282
|
}
|
|
1254
1283
|
}, _ = new oe();
|
|
1255
1284
|
_.reset();
|
|
1256
|
-
const
|
|
1257
|
-
...
|
|
1258
|
-
...
|
|
1259
|
-
}, { charSpace: D, defaultTabStop: A = 36, gridType:
|
|
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;
|
|
1260
1289
|
for (const Y of u) {
|
|
1261
|
-
const { startIndex: $, paragraphStyle:
|
|
1262
|
-
|
|
1263
|
-
t:
|
|
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({
|
|
1292
|
+
t: y.RETAIN,
|
|
1264
1293
|
len: $ - _.cursor,
|
|
1265
1294
|
segmentId: m
|
|
1266
|
-
}),
|
|
1267
|
-
t:
|
|
1295
|
+
}), R.push({
|
|
1296
|
+
t: y.RETAIN,
|
|
1268
1297
|
len: 1,
|
|
1269
1298
|
body: {
|
|
1270
1299
|
dataStream: "",
|
|
1271
1300
|
paragraphs: [
|
|
1272
1301
|
p ? {
|
|
1273
1302
|
paragraphStyle: {
|
|
1274
|
-
...
|
|
1303
|
+
...z,
|
|
1275
1304
|
hanging: void 0,
|
|
1276
|
-
indentStart:
|
|
1305
|
+
indentStart: _e ? Math.max(0, Me(_e, Ie) + ve - He) : void 0
|
|
1277
1306
|
},
|
|
1278
1307
|
startIndex: 0
|
|
1279
1308
|
} : {
|
|
1280
1309
|
startIndex: 0,
|
|
1281
1310
|
paragraphStyle: {
|
|
1282
|
-
...
|
|
1311
|
+
...z,
|
|
1283
1312
|
indentFirstLine: void 0,
|
|
1284
|
-
hanging:
|
|
1285
|
-
indentStart:
|
|
1313
|
+
hanging: ve,
|
|
1314
|
+
indentStart: He - ve + Me(Rt, Ie) + Me(_e, Ie)
|
|
1286
1315
|
},
|
|
1287
1316
|
bullet: {
|
|
1288
1317
|
...(X = Y.bullet) != null ? X : {
|
|
@@ -1291,182 +1320,185 @@ const je = {
|
|
|
1291
1320
|
fs: 20
|
|
1292
1321
|
}
|
|
1293
1322
|
},
|
|
1294
|
-
listType:
|
|
1295
|
-
listId:
|
|
1323
|
+
listType: r,
|
|
1324
|
+
listId: f
|
|
1296
1325
|
}
|
|
1297
1326
|
}
|
|
1298
1327
|
]
|
|
1299
1328
|
},
|
|
1300
1329
|
segmentId: m,
|
|
1301
|
-
coverType:
|
|
1330
|
+
coverType: Ee.REPLACE
|
|
1302
1331
|
}), _.moveCursorTo($ + 1);
|
|
1303
1332
|
}
|
|
1304
|
-
return S.params.actions =
|
|
1333
|
+
return S.params.actions = R.serialize(), !!o.syncExecuteCommand(S.id, S.params);
|
|
1305
1334
|
}
|
|
1306
1335
|
}, gn = {
|
|
1307
1336
|
id: "doc.command.bullet-list",
|
|
1308
1337
|
type: v.COMMAND,
|
|
1309
|
-
handler: (
|
|
1310
|
-
listType:
|
|
1338
|
+
handler: (s) => s.get(I).syncExecuteCommand(Ge.id, {
|
|
1339
|
+
listType: ut.BULLET_LIST
|
|
1311
1340
|
})
|
|
1312
|
-
},
|
|
1341
|
+
}, fn = {
|
|
1313
1342
|
id: "doc.command.order-list",
|
|
1314
1343
|
type: v.COMMAND,
|
|
1315
|
-
handler: (
|
|
1316
|
-
listType:
|
|
1344
|
+
handler: (s) => s.get(I).syncExecuteCommand(Ge.id, {
|
|
1345
|
+
listType: ut.ORDER_LIST
|
|
1317
1346
|
})
|
|
1318
1347
|
};
|
|
1319
|
-
function
|
|
1320
|
-
const { startOffset: t, endOffset: n } =
|
|
1321
|
-
let
|
|
1348
|
+
function Mt(s, e) {
|
|
1349
|
+
const { startOffset: t, endOffset: n } = s, o = [];
|
|
1350
|
+
let r = -1;
|
|
1322
1351
|
for (const i of e) {
|
|
1323
1352
|
const { startIndex: a } = i;
|
|
1324
|
-
(t >
|
|
1353
|
+
(t > r && t <= a || n > r && n <= a || a >= t && a <= n) && o.push(i), r = a;
|
|
1325
1354
|
}
|
|
1326
|
-
return
|
|
1355
|
+
return o;
|
|
1327
1356
|
}
|
|
1328
|
-
const
|
|
1357
|
+
const ie = {
|
|
1329
1358
|
id: "doc.command.align-operation",
|
|
1330
1359
|
type: v.COMMAND,
|
|
1331
|
-
handler: (
|
|
1332
|
-
var
|
|
1333
|
-
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);
|
|
1334
1366
|
if (a == null || d == null)
|
|
1335
1367
|
return !1;
|
|
1336
|
-
const u =
|
|
1368
|
+
const u = Mt(a, d), { segmentId: m } = a, g = i.getUnitId(), p = u.every((C) => {
|
|
1337
1369
|
var D;
|
|
1338
|
-
return ((D =
|
|
1339
|
-
}),
|
|
1370
|
+
return ((D = C.paragraphStyle) == null ? void 0 : D.horizontalAlign) === r;
|
|
1371
|
+
}), h = {
|
|
1340
1372
|
id: L.id,
|
|
1341
1373
|
params: {
|
|
1342
1374
|
unitId: g,
|
|
1343
1375
|
actions: [],
|
|
1344
1376
|
textRanges: l
|
|
1345
1377
|
}
|
|
1346
|
-
},
|
|
1347
|
-
|
|
1378
|
+
}, f = new oe();
|
|
1379
|
+
f.reset();
|
|
1348
1380
|
const S = new P();
|
|
1349
|
-
for (const
|
|
1350
|
-
const { startIndex: D } =
|
|
1381
|
+
for (const C of u) {
|
|
1382
|
+
const { startIndex: D } = C;
|
|
1351
1383
|
S.push({
|
|
1352
|
-
t:
|
|
1353
|
-
len: D -
|
|
1384
|
+
t: y.RETAIN,
|
|
1385
|
+
len: D - f.cursor,
|
|
1354
1386
|
segmentId: m
|
|
1355
1387
|
});
|
|
1356
1388
|
const A = {
|
|
1357
|
-
...
|
|
1358
|
-
horizontalAlign: p ? re.UNSPECIFIED :
|
|
1389
|
+
...C.paragraphStyle,
|
|
1390
|
+
horizontalAlign: p ? re.UNSPECIFIED : r
|
|
1359
1391
|
};
|
|
1360
1392
|
S.push({
|
|
1361
|
-
t:
|
|
1393
|
+
t: y.RETAIN,
|
|
1362
1394
|
len: 1,
|
|
1363
1395
|
body: {
|
|
1364
1396
|
dataStream: "",
|
|
1365
1397
|
paragraphs: [
|
|
1366
1398
|
{
|
|
1367
|
-
...
|
|
1399
|
+
...C,
|
|
1368
1400
|
paragraphStyle: A,
|
|
1369
1401
|
startIndex: 0
|
|
1370
1402
|
}
|
|
1371
1403
|
]
|
|
1372
1404
|
},
|
|
1373
1405
|
segmentId: m,
|
|
1374
|
-
coverType:
|
|
1375
|
-
}),
|
|
1406
|
+
coverType: Ee.REPLACE
|
|
1407
|
+
}), f.moveCursorTo(D + 1);
|
|
1376
1408
|
}
|
|
1377
|
-
return
|
|
1409
|
+
return h.params.actions = S.serialize(), !!o.syncExecuteCommand(h.id, h.params);
|
|
1378
1410
|
}
|
|
1379
|
-
},
|
|
1411
|
+
}, hn = {
|
|
1380
1412
|
id: "doc.command.align-left",
|
|
1381
1413
|
type: v.COMMAND,
|
|
1382
|
-
handler: (
|
|
1414
|
+
handler: (s) => s.get(I).syncExecuteCommand(ie.id, {
|
|
1383
1415
|
alignType: re.LEFT
|
|
1384
1416
|
})
|
|
1385
1417
|
}, pn = {
|
|
1386
1418
|
id: "doc.command.align-center",
|
|
1387
1419
|
type: v.COMMAND,
|
|
1388
|
-
handler: (
|
|
1420
|
+
handler: (s) => s.get(I).syncExecuteCommand(ie.id, {
|
|
1389
1421
|
alignType: re.CENTER
|
|
1390
1422
|
})
|
|
1391
1423
|
}, Sn = {
|
|
1392
1424
|
id: "doc.command.align-right",
|
|
1393
1425
|
type: v.COMMAND,
|
|
1394
|
-
handler: (
|
|
1426
|
+
handler: (s) => s.get(I).syncExecuteCommand(ie.id, {
|
|
1395
1427
|
alignType: re.RIGHT
|
|
1396
1428
|
})
|
|
1397
1429
|
}, _n = {
|
|
1398
1430
|
id: "doc.command.align-justify",
|
|
1399
1431
|
type: v.COMMAND,
|
|
1400
|
-
handler: (
|
|
1432
|
+
handler: (s) => s.get(I).syncExecuteCommand(ie.id, {
|
|
1401
1433
|
alignType: re.JUSTIFIED
|
|
1402
1434
|
})
|
|
1403
1435
|
}, vn = {
|
|
1404
1436
|
id: "doc.command-replace-content",
|
|
1405
1437
|
type: v.COMMAND,
|
|
1406
|
-
handler: async (
|
|
1438
|
+
handler: async (s, e) => {
|
|
1407
1439
|
var g;
|
|
1408
|
-
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();
|
|
1409
1441
|
if (d == null || !Array.isArray(l) || l.length === 0)
|
|
1410
1442
|
return !1;
|
|
1411
|
-
const u =
|
|
1412
|
-
return u.params.textRanges =
|
|
1443
|
+
const u = Ct(t, r, d, n);
|
|
1444
|
+
return u.params.textRanges = o, !!a.syncExecuteCommand(u.id, u.params);
|
|
1413
1445
|
}
|
|
1414
1446
|
}, In = {
|
|
1415
1447
|
id: "doc.command-cover-content",
|
|
1416
1448
|
type: v.COMMAND,
|
|
1417
|
-
handler: async (
|
|
1449
|
+
handler: async (s, e) => {
|
|
1418
1450
|
var l;
|
|
1419
|
-
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;
|
|
1420
1452
|
if (c == null)
|
|
1421
1453
|
return !1;
|
|
1422
|
-
const d =
|
|
1454
|
+
const d = Ct(t, o, c, n);
|
|
1423
1455
|
return d.params.noNeedSetTextRange = !0, d.params.noHistory = !0, i.syncExecuteCommand(
|
|
1424
1456
|
d.id,
|
|
1425
1457
|
d.params
|
|
1426
1458
|
), a.clearUndoRedo(t), !0;
|
|
1427
1459
|
}
|
|
1428
1460
|
};
|
|
1429
|
-
function
|
|
1430
|
-
const
|
|
1461
|
+
function Ct(s, e, t, n) {
|
|
1462
|
+
const o = {
|
|
1431
1463
|
id: L.id,
|
|
1432
1464
|
params: {
|
|
1433
|
-
unitId:
|
|
1465
|
+
unitId: s,
|
|
1434
1466
|
actions: [],
|
|
1435
1467
|
textRanges: []
|
|
1436
1468
|
}
|
|
1437
|
-
},
|
|
1438
|
-
return i > 0 &&
|
|
1439
|
-
t:
|
|
1469
|
+
}, r = new P(), i = (t == null ? void 0 : t.dataStream.length) - 2;
|
|
1470
|
+
return i > 0 && r.push({
|
|
1471
|
+
t: y.DELETE,
|
|
1440
1472
|
len: i,
|
|
1441
1473
|
line: 0,
|
|
1442
1474
|
segmentId: e
|
|
1443
|
-
}), n.dataStream.length > 0 &&
|
|
1444
|
-
t:
|
|
1475
|
+
}), n.dataStream.length > 0 && r.push({
|
|
1476
|
+
t: y.INSERT,
|
|
1445
1477
|
body: n,
|
|
1446
1478
|
len: n.dataStream.length,
|
|
1447
1479
|
line: 0,
|
|
1448
1480
|
segmentId: e
|
|
1449
|
-
}),
|
|
1481
|
+
}), o.params.actions = r.serialize(), o;
|
|
1450
1482
|
}
|
|
1451
|
-
const
|
|
1483
|
+
const ye = {
|
|
1452
1484
|
id: "doc.operation.move-cursor",
|
|
1453
1485
|
type: v.OPERATION,
|
|
1454
|
-
handler: (
|
|
1455
|
-
},
|
|
1486
|
+
handler: (s, e) => !!e
|
|
1487
|
+
}, Oe = {
|
|
1456
1488
|
id: "doc.operation.move-selection",
|
|
1457
1489
|
type: v.OPERATION,
|
|
1458
|
-
handler: (
|
|
1459
|
-
}, Mn = (
|
|
1460
|
-
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;
|
|
1461
1493
|
return {
|
|
1462
|
-
...
|
|
1494
|
+
...Q.deepClone(e),
|
|
1463
1495
|
zoomRatio: n
|
|
1464
1496
|
};
|
|
1465
|
-
},
|
|
1497
|
+
}, ce = {
|
|
1466
1498
|
id: "doc.operation.set-zoom-ratio",
|
|
1467
1499
|
type: v.OPERATION,
|
|
1468
|
-
handler: (
|
|
1469
|
-
const t =
|
|
1500
|
+
handler: (s, e) => {
|
|
1501
|
+
const t = s.get(E).getUniverDocInstance(e.unitId);
|
|
1470
1502
|
if (!t)
|
|
1471
1503
|
return !1;
|
|
1472
1504
|
const n = t.getSnapshot();
|
|
@@ -1477,52 +1509,58 @@ const Re = {
|
|
|
1477
1509
|
}, Cn = {
|
|
1478
1510
|
type: v.COMMAND,
|
|
1479
1511
|
id: "doc.command.set-zoom-ratio",
|
|
1480
|
-
handler: async (
|
|
1481
|
-
var u, m;
|
|
1482
|
-
const t =
|
|
1483
|
-
let
|
|
1484
|
-
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))
|
|
1485
1520
|
return !1;
|
|
1486
1521
|
const c = {
|
|
1487
1522
|
zoomRatio: i,
|
|
1488
|
-
unitId:
|
|
1489
|
-
}, d = Mn(
|
|
1490
|
-
return t.syncExecuteCommand(
|
|
1491
|
-
unitID:
|
|
1492
|
-
undoMutations: [{ id:
|
|
1493
|
-
redoMutations: [{ id:
|
|
1523
|
+
unitId: r
|
|
1524
|
+
}, d = Mn(s, c);
|
|
1525
|
+
return t.syncExecuteCommand(ce.id, c) ? (n.pushUndoRedo({
|
|
1526
|
+
unitID: r,
|
|
1527
|
+
undoMutations: [{ id: ce.id, params: d }],
|
|
1528
|
+
redoMutations: [{ id: ce.id, params: c }]
|
|
1494
1529
|
}), !0) : !1;
|
|
1495
1530
|
}
|
|
1496
|
-
},
|
|
1531
|
+
}, Rn = {
|
|
1497
1532
|
id: "doc.operation.select-all",
|
|
1498
1533
|
type: v.COMMAND,
|
|
1499
|
-
handler: async (
|
|
1500
|
-
const e =
|
|
1501
|
-
if (n
|
|
1534
|
+
handler: async (s) => {
|
|
1535
|
+
const e = s.get(E), t = s.get(T), n = e.getCurrentUniverDocInstance();
|
|
1536
|
+
if (!n)
|
|
1537
|
+
return !1;
|
|
1538
|
+
const o = n.getSnapshot().body;
|
|
1539
|
+
if (o == null)
|
|
1502
1540
|
return !1;
|
|
1503
1541
|
const r = [
|
|
1504
1542
|
{
|
|
1505
1543
|
startOffset: 0,
|
|
1506
|
-
endOffset:
|
|
1544
|
+
endOffset: o.dataStream.length - 2
|
|
1507
1545
|
}
|
|
1508
1546
|
];
|
|
1509
1547
|
return t.replaceTextRanges(r, !1), !0;
|
|
1510
1548
|
}
|
|
1511
1549
|
};
|
|
1512
|
-
var
|
|
1513
|
-
for (var
|
|
1514
|
-
(i =
|
|
1515
|
-
return n &&
|
|
1516
|
-
},
|
|
1517
|
-
let
|
|
1518
|
-
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) {
|
|
1519
1557
|
super();
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
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();
|
|
1526
1564
|
}
|
|
1527
1565
|
dispose() {
|
|
1528
1566
|
var e, t, n;
|
|
@@ -1537,7 +1575,7 @@ let ae = class extends Ae {
|
|
|
1537
1575
|
return;
|
|
1538
1576
|
this._resetIME();
|
|
1539
1577
|
const { activeRange: t } = e;
|
|
1540
|
-
t != null && this._imeInputManagerService.setActiveRange(
|
|
1578
|
+
t != null && this._imeInputManagerService.setActiveRange(Q.deepClone(t));
|
|
1541
1579
|
});
|
|
1542
1580
|
}
|
|
1543
1581
|
_initialOnCompositionUpdate() {
|
|
@@ -1555,12 +1593,15 @@ let ae = class extends Ae {
|
|
|
1555
1593
|
const n = (d = this._docSkeletonManagerService.getCurrent()) == null ? void 0 : d.skeleton;
|
|
1556
1594
|
if (e == null || n == null)
|
|
1557
1595
|
return;
|
|
1558
|
-
const
|
|
1596
|
+
const o = this._univerInstanceService.getCurrentUniverDocInstance();
|
|
1597
|
+
if (!o)
|
|
1598
|
+
return;
|
|
1599
|
+
const { event: r, activeRange: i } = e;
|
|
1559
1600
|
if (n == null || i == null)
|
|
1560
1601
|
return;
|
|
1561
|
-
const c =
|
|
1562
|
-
c === this._previousIMEContent && t || (await this._commandService.executeCommand(
|
|
1563
|
-
unitId:
|
|
1602
|
+
const c = r.data;
|
|
1603
|
+
c === this._previousIMEContent && t || (await this._commandService.executeCommand(_t.id, {
|
|
1604
|
+
unitId: o.getUnitId(),
|
|
1564
1605
|
newText: c,
|
|
1565
1606
|
oldTextLen: this._previousIMEContent.length,
|
|
1566
1607
|
isCompositionStart: this._isCompositionStart,
|
|
@@ -1571,24 +1612,24 @@ let ae = class extends Ae {
|
|
|
1571
1612
|
this._previousIMEContent = "", this._isCompositionStart = !0, this._imeInputManagerService.clearUndoRedoMutationParamsCache(), this._imeInputManagerService.setActiveRange(null);
|
|
1572
1613
|
}
|
|
1573
1614
|
};
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
],
|
|
1582
|
-
var Tn = Object.defineProperty, En = Object.getOwnPropertyDescriptor, Dn = (
|
|
1583
|
-
for (var
|
|
1584
|
-
(i =
|
|
1585
|
-
return n &&
|
|
1586
|
-
},
|
|
1587
|
-
let
|
|
1588
|
-
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) {
|
|
1589
1630
|
super();
|
|
1590
|
-
|
|
1591
|
-
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();
|
|
1592
1633
|
}
|
|
1593
1634
|
dispose() {
|
|
1594
1635
|
var e;
|
|
@@ -1597,16 +1638,16 @@ let ce = class extends Ae {
|
|
|
1597
1638
|
_initialize() {
|
|
1598
1639
|
}
|
|
1599
1640
|
_commandExecutedListener() {
|
|
1600
|
-
const e = [
|
|
1641
|
+
const e = [ye.id, Oe.id];
|
|
1601
1642
|
this.disposeWithMe(
|
|
1602
1643
|
this._commandService.onCommandExecuted((t) => {
|
|
1603
1644
|
if (!e.includes(t.id))
|
|
1604
1645
|
return;
|
|
1605
1646
|
const n = t.params;
|
|
1606
1647
|
switch (t.id) {
|
|
1607
|
-
case Re.id:
|
|
1608
|
-
return this._handleMoveCursor(n.direction);
|
|
1609
1648
|
case ye.id:
|
|
1649
|
+
return this._handleMoveCursor(n.direction);
|
|
1650
|
+
case Oe.id:
|
|
1610
1651
|
return this._handleShiftMoveSelection(n.direction);
|
|
1611
1652
|
default:
|
|
1612
1653
|
throw new Error("Unknown command");
|
|
@@ -1615,30 +1656,33 @@ let ce = class extends Ae {
|
|
|
1615
1656
|
);
|
|
1616
1657
|
}
|
|
1617
1658
|
_handleShiftMoveSelection(e) {
|
|
1618
|
-
var
|
|
1619
|
-
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(),
|
|
1620
|
-
if (
|
|
1659
|
+
var h, f, S;
|
|
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();
|
|
1664
|
+
if (t == null || r == null || i == null)
|
|
1621
1665
|
return;
|
|
1622
1666
|
const { startOffset: a, endOffset: c, style: d, collapsed: l, direction: u } = t;
|
|
1623
1667
|
if (n.length > 1) {
|
|
1624
|
-
let _ = Number.POSITIVE_INFINITY,
|
|
1625
|
-
for (const
|
|
1626
|
-
_ = 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);
|
|
1627
1671
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1628
1672
|
{
|
|
1629
|
-
startOffset: e ===
|
|
1630
|
-
endOffset: e ===
|
|
1673
|
+
startOffset: e === N.LEFT || e === N.UP ? R : _,
|
|
1674
|
+
endOffset: e === N.LEFT || e === N.UP ? _ : R,
|
|
1631
1675
|
style: d
|
|
1632
1676
|
}
|
|
1633
1677
|
], !1);
|
|
1634
1678
|
return;
|
|
1635
1679
|
}
|
|
1636
|
-
const m = l || u ===
|
|
1637
|
-
let g = l || u ===
|
|
1638
|
-
const p = (
|
|
1639
|
-
if (e ===
|
|
1640
|
-
const _ =
|
|
1641
|
-
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([
|
|
1642
1686
|
{
|
|
1643
1687
|
startOffset: m,
|
|
1644
1688
|
endOffset: g,
|
|
@@ -1646,9 +1690,9 @@ let ce = class extends Ae {
|
|
|
1646
1690
|
}
|
|
1647
1691
|
], !1);
|
|
1648
1692
|
} else {
|
|
1649
|
-
const _ =
|
|
1650
|
-
if (
|
|
1651
|
-
const D = e ===
|
|
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;
|
|
1652
1696
|
if (D === g)
|
|
1653
1697
|
return;
|
|
1654
1698
|
this._textSelectionManagerService.replaceTextRanges([
|
|
@@ -1660,14 +1704,14 @@ let ce = class extends Ae {
|
|
|
1660
1704
|
], !1);
|
|
1661
1705
|
return;
|
|
1662
1706
|
}
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1665
|
-
|
|
1707
|
+
const C = new Ze(R, r).getRangePointData(
|
|
1708
|
+
M,
|
|
1709
|
+
M
|
|
1666
1710
|
).cursorList[0];
|
|
1667
1711
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1668
1712
|
{
|
|
1669
1713
|
startOffset: m,
|
|
1670
|
-
endOffset:
|
|
1714
|
+
endOffset: C.endOffset,
|
|
1671
1715
|
style: d
|
|
1672
1716
|
}
|
|
1673
1717
|
], !1);
|
|
@@ -1675,52 +1719,55 @@ let ce = class extends Ae {
|
|
|
1675
1719
|
}
|
|
1676
1720
|
_handleMoveCursor(e) {
|
|
1677
1721
|
var m, g, p;
|
|
1678
|
-
const t = this._textSelectionManagerService.getActiveRange(), n = this._textSelectionManagerService.getSelections(),
|
|
1679
|
-
if (
|
|
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();
|
|
1726
|
+
if (t == null || r == null || i == null || n == null)
|
|
1680
1727
|
return;
|
|
1681
|
-
const { startOffset: a, endOffset: c, style: d, collapsed: l } = t, u = (g =
|
|
1682
|
-
if (e ===
|
|
1683
|
-
let
|
|
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) {
|
|
1730
|
+
let h;
|
|
1684
1731
|
if (!t.collapsed || n.length > 1) {
|
|
1685
|
-
let
|
|
1732
|
+
let f = Number.POSITIVE_INFINITY, S = Number.NEGATIVE_INFINITY;
|
|
1686
1733
|
for (const _ of n)
|
|
1687
|
-
|
|
1688
|
-
|
|
1734
|
+
f = Math.min(f, _.startOffset), S = Math.max(S, _.endOffset);
|
|
1735
|
+
h = e === N.LEFT ? f : S;
|
|
1689
1736
|
} else {
|
|
1690
|
-
const
|
|
1691
|
-
e ===
|
|
1737
|
+
const f = r.findNodeByCharIndex(a - 1), S = r.findNodeByCharIndex(a);
|
|
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);
|
|
1692
1739
|
}
|
|
1693
1740
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1694
1741
|
{
|
|
1695
|
-
startOffset:
|
|
1696
|
-
endOffset:
|
|
1742
|
+
startOffset: h,
|
|
1743
|
+
endOffset: h,
|
|
1697
1744
|
style: d
|
|
1698
1745
|
}
|
|
1699
1746
|
], !1);
|
|
1700
1747
|
} else {
|
|
1701
|
-
const
|
|
1702
|
-
|
|
1703
|
-
e ===
|
|
1704
|
-
e ===
|
|
1748
|
+
const h = r.findNodeByCharIndex(a), f = r.findNodeByCharIndex(c), S = i.document.getOffsetConfig(), _ = this._getTopOrBottomPosition(
|
|
1749
|
+
r,
|
|
1750
|
+
e === N.UP ? h : f,
|
|
1751
|
+
e === N.DOWN
|
|
1705
1752
|
);
|
|
1706
1753
|
if (_ == null) {
|
|
1707
|
-
let
|
|
1708
|
-
l ?
|
|
1754
|
+
let M;
|
|
1755
|
+
l ? M = e === N.UP ? 0 : u - 2 : M = e === N.UP ? a : c, this._textSelectionManagerService.replaceTextRanges([
|
|
1709
1756
|
{
|
|
1710
|
-
startOffset:
|
|
1711
|
-
endOffset:
|
|
1757
|
+
startOffset: M,
|
|
1758
|
+
endOffset: M,
|
|
1712
1759
|
style: d
|
|
1713
1760
|
}
|
|
1714
1761
|
], !1);
|
|
1715
1762
|
return;
|
|
1716
1763
|
}
|
|
1717
|
-
const
|
|
1764
|
+
const R = new Ze(S, r).getRangePointData(
|
|
1718
1765
|
_,
|
|
1719
1766
|
_
|
|
1720
1767
|
).cursorList[0];
|
|
1721
1768
|
this._textSelectionManagerService.replaceTextRanges([
|
|
1722
1769
|
{
|
|
1723
|
-
...
|
|
1770
|
+
...R,
|
|
1724
1771
|
style: d
|
|
1725
1772
|
}
|
|
1726
1773
|
], !1);
|
|
@@ -1729,10 +1776,10 @@ let ce = class extends Ae {
|
|
|
1729
1776
|
_getTopOrBottomPosition(e, t, n) {
|
|
1730
1777
|
if (t == null)
|
|
1731
1778
|
return;
|
|
1732
|
-
const
|
|
1733
|
-
if (
|
|
1779
|
+
const o = this._getSpanLeftOffsetInLine(t), r = this._getNextOrPrevLine(t, n);
|
|
1780
|
+
if (r == null)
|
|
1734
1781
|
return;
|
|
1735
|
-
const i = this._matchPositionByLeftOffset(e,
|
|
1782
|
+
const i = this._matchPositionByLeftOffset(e, r, o);
|
|
1736
1783
|
if (i != null)
|
|
1737
1784
|
return { ...i, isBack: !0 };
|
|
1738
1785
|
}
|
|
@@ -1740,50 +1787,50 @@ let ce = class extends Ae {
|
|
|
1740
1787
|
const t = e.parent;
|
|
1741
1788
|
if (t == null)
|
|
1742
1789
|
return Number.NEGATIVE_INFINITY;
|
|
1743
|
-
const n = t.left, { left:
|
|
1744
|
-
return n +
|
|
1790
|
+
const n = t.left, { left: o } = e;
|
|
1791
|
+
return n + o;
|
|
1745
1792
|
}
|
|
1746
1793
|
_matchPositionByLeftOffset(e, t, n) {
|
|
1747
|
-
const
|
|
1794
|
+
const o = {
|
|
1748
1795
|
distance: Number.POSITIVE_INFINITY
|
|
1749
1796
|
};
|
|
1750
|
-
for (const
|
|
1751
|
-
const i =
|
|
1752
|
-
for (const a of
|
|
1797
|
+
for (const r of t.divides) {
|
|
1798
|
+
const i = r.left;
|
|
1799
|
+
for (const a of r.glyphGroup) {
|
|
1753
1800
|
const { left: c } = a, d = i + c, l = Math.abs(n - d);
|
|
1754
|
-
l <
|
|
1801
|
+
l < o.distance && (o.glyph = a, o.distance = l);
|
|
1755
1802
|
}
|
|
1756
1803
|
}
|
|
1757
|
-
if (
|
|
1758
|
-
return e.findPositionByGlyph(
|
|
1804
|
+
if (o.glyph != null)
|
|
1805
|
+
return e.findPositionByGlyph(o.glyph);
|
|
1759
1806
|
}
|
|
1760
1807
|
_getNextOrPrevLine(e, t) {
|
|
1761
|
-
var p,
|
|
1808
|
+
var p, h, f, S, _, R, M, C, D, A, b, B;
|
|
1762
1809
|
const n = e.parent;
|
|
1763
1810
|
if (n == null)
|
|
1764
1811
|
return;
|
|
1765
|
-
const
|
|
1766
|
-
if (
|
|
1812
|
+
const o = n.parent;
|
|
1813
|
+
if (o == null)
|
|
1767
1814
|
return;
|
|
1768
|
-
const
|
|
1769
|
-
if (
|
|
1815
|
+
const r = o.parent;
|
|
1816
|
+
if (r == null)
|
|
1770
1817
|
return;
|
|
1771
|
-
const i =
|
|
1818
|
+
const i = r.lines.indexOf(o);
|
|
1772
1819
|
if (i === -1)
|
|
1773
1820
|
return;
|
|
1774
1821
|
let a;
|
|
1775
|
-
if (t === !0 ? a =
|
|
1822
|
+
if (t === !0 ? a = r.lines[i + 1] : a = r.lines[i - 1], a != null)
|
|
1776
1823
|
return a;
|
|
1777
|
-
const c =
|
|
1824
|
+
const c = r.parent;
|
|
1778
1825
|
if (c == null)
|
|
1779
1826
|
return;
|
|
1780
|
-
const d = c.columns.indexOf(
|
|
1827
|
+
const d = c.columns.indexOf(r);
|
|
1781
1828
|
if (d === -1)
|
|
1782
1829
|
return;
|
|
1783
1830
|
if (t === !0)
|
|
1784
1831
|
a = (p = c.columns[d + 1]) == null ? void 0 : p.lines[0];
|
|
1785
1832
|
else {
|
|
1786
|
-
const O = (
|
|
1833
|
+
const O = (f = (h = c.columns) == null ? void 0 : h[d - 1]) == null ? void 0 : f.lines;
|
|
1787
1834
|
a = O == null ? void 0 : O[O.length - 1];
|
|
1788
1835
|
}
|
|
1789
1836
|
if (a != null)
|
|
@@ -1797,7 +1844,7 @@ let ce = class extends Ae {
|
|
|
1797
1844
|
if (t === !0)
|
|
1798
1845
|
a = (_ = (S = l.sections[u - 1]) == null ? void 0 : S.columns[0]) == null ? void 0 : _.lines[0];
|
|
1799
1846
|
else {
|
|
1800
|
-
const O = (
|
|
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;
|
|
1801
1848
|
a = w == null ? void 0 : w[w.length - 1];
|
|
1802
1849
|
}
|
|
1803
1850
|
if (a != null)
|
|
@@ -1808,9 +1855,9 @@ let ce = class extends Ae {
|
|
|
1808
1855
|
const g = m.pages.indexOf(l);
|
|
1809
1856
|
if (g !== -1) {
|
|
1810
1857
|
if (t === !0)
|
|
1811
|
-
a = (A = (D = (
|
|
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];
|
|
1812
1859
|
else {
|
|
1813
|
-
const O = (
|
|
1860
|
+
const O = (b = m.pages[g - 1]) == null ? void 0 : b.sections;
|
|
1814
1861
|
if (O == null)
|
|
1815
1862
|
return;
|
|
1816
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;
|
|
@@ -1821,27 +1868,27 @@ let ce = class extends Ae {
|
|
|
1821
1868
|
}
|
|
1822
1869
|
}
|
|
1823
1870
|
_getDocObject() {
|
|
1824
|
-
return
|
|
1871
|
+
return gt(this._univerInstanceService, this._renderManagerService);
|
|
1825
1872
|
}
|
|
1826
1873
|
};
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
],
|
|
1835
|
-
var An = Object.defineProperty,
|
|
1836
|
-
for (var
|
|
1837
|
-
(i =
|
|
1838
|
-
return n &&
|
|
1839
|
-
},
|
|
1840
|
-
let
|
|
1841
|
-
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) {
|
|
1842
1889
|
super();
|
|
1843
|
-
|
|
1844
|
-
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();
|
|
1845
1892
|
}
|
|
1846
1893
|
dispose() {
|
|
1847
1894
|
var e;
|
|
@@ -1855,20 +1902,23 @@ let le = class extends Ae {
|
|
|
1855
1902
|
var p;
|
|
1856
1903
|
if (e == null)
|
|
1857
1904
|
return;
|
|
1858
|
-
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;
|
|
1859
1909
|
if (a.data == null || c == null || !c || !i)
|
|
1860
1910
|
return;
|
|
1861
|
-
const { startOffset: d, segmentId: l, style: u } = i, m =
|
|
1911
|
+
const { startOffset: d, segmentId: l, style: u } = i, m = r.length, g = [
|
|
1862
1912
|
{
|
|
1863
1913
|
startOffset: d + m,
|
|
1864
1914
|
endOffset: d + m,
|
|
1865
1915
|
style: u
|
|
1866
1916
|
}
|
|
1867
1917
|
];
|
|
1868
|
-
await this._commandService.executeCommand(
|
|
1918
|
+
await this._commandService.executeCommand(pe.id, {
|
|
1869
1919
|
unitId: n,
|
|
1870
1920
|
body: {
|
|
1871
|
-
dataStream:
|
|
1921
|
+
dataStream: r
|
|
1872
1922
|
},
|
|
1873
1923
|
range: i,
|
|
1874
1924
|
textRanges: g,
|
|
@@ -1879,72 +1929,72 @@ let le = class extends Ae {
|
|
|
1879
1929
|
_commandExecutedListener() {
|
|
1880
1930
|
}
|
|
1881
1931
|
_getDocObject() {
|
|
1882
|
-
return
|
|
1932
|
+
return gt(this._univerInstanceService, this._renderManagerService);
|
|
1883
1933
|
}
|
|
1884
1934
|
};
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
],
|
|
1893
|
-
var Pn = Object.defineProperty, Un = Object.getOwnPropertyDescriptor, wn = (
|
|
1894
|
-
for (var
|
|
1895
|
-
(i =
|
|
1896
|
-
return n &&
|
|
1897
|
-
}, Ln = (
|
|
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);
|
|
1898
1948
|
const Bn = {
|
|
1899
1949
|
hasScroll: !0
|
|
1900
1950
|
}, Fn = "docs";
|
|
1901
|
-
var
|
|
1902
|
-
let
|
|
1951
|
+
var ae;
|
|
1952
|
+
let lt = (ae = class extends Nt {
|
|
1903
1953
|
constructor(e = {}, t) {
|
|
1904
|
-
super(
|
|
1905
|
-
|
|
1954
|
+
super();
|
|
1955
|
+
x(this, "_config");
|
|
1906
1956
|
this._injector = t, this._config = Object.assign(Bn, e), this._initializeDependencies(t), this._initializeCommands();
|
|
1907
1957
|
}
|
|
1908
1958
|
initialize() {
|
|
1909
1959
|
}
|
|
1910
1960
|
_initializeCommands() {
|
|
1911
1961
|
[
|
|
1912
|
-
Re,
|
|
1913
1962
|
ye,
|
|
1963
|
+
Oe,
|
|
1914
1964
|
cn,
|
|
1915
1965
|
ln,
|
|
1916
|
-
Pe,
|
|
1917
1966
|
Ue,
|
|
1918
1967
|
we,
|
|
1919
1968
|
Le,
|
|
1920
|
-
ne,
|
|
1921
1969
|
Be,
|
|
1970
|
+
se,
|
|
1922
1971
|
Fe,
|
|
1923
1972
|
$e,
|
|
1924
|
-
ze,
|
|
1925
1973
|
Ve,
|
|
1974
|
+
ze,
|
|
1975
|
+
je,
|
|
1926
1976
|
ke,
|
|
1927
|
-
|
|
1977
|
+
It,
|
|
1928
1978
|
nn,
|
|
1929
|
-
|
|
1930
|
-
|
|
1979
|
+
pe,
|
|
1980
|
+
Se,
|
|
1931
1981
|
ht,
|
|
1932
|
-
|
|
1933
|
-
|
|
1982
|
+
_t,
|
|
1983
|
+
Pe,
|
|
1934
1984
|
L,
|
|
1935
1985
|
vn,
|
|
1936
1986
|
In,
|
|
1937
1987
|
Cn,
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
hn,
|
|
1942
|
-
gn,
|
|
1943
|
-
je,
|
|
1988
|
+
ce,
|
|
1989
|
+
ft,
|
|
1990
|
+
Rn,
|
|
1944
1991
|
fn,
|
|
1992
|
+
gn,
|
|
1993
|
+
Ge,
|
|
1994
|
+
hn,
|
|
1945
1995
|
pn,
|
|
1946
1996
|
Sn,
|
|
1947
|
-
|
|
1997
|
+
ie,
|
|
1948
1998
|
_n
|
|
1949
1999
|
].forEach((e) => {
|
|
1950
2000
|
this._injector.get(I).registerCommand(e);
|
|
@@ -1957,77 +2007,77 @@ let ct = (Ce = class extends At {
|
|
|
1957
2007
|
[
|
|
1958
2008
|
// services
|
|
1959
2009
|
[H],
|
|
1960
|
-
[
|
|
1961
|
-
[
|
|
1962
|
-
[
|
|
2010
|
+
[ne],
|
|
2011
|
+
[me],
|
|
2012
|
+
[he],
|
|
1963
2013
|
[
|
|
1964
|
-
|
|
2014
|
+
fe,
|
|
1965
2015
|
{
|
|
1966
|
-
useClass:
|
|
2016
|
+
useClass: Vt
|
|
1967
2017
|
}
|
|
1968
2018
|
],
|
|
1969
2019
|
[T],
|
|
1970
2020
|
// controllers
|
|
2021
|
+
[ue],
|
|
1971
2022
|
[le],
|
|
1972
|
-
[
|
|
1973
|
-
[ce]
|
|
2023
|
+
[de]
|
|
1974
2024
|
].forEach((t) => e.add(t));
|
|
1975
2025
|
}
|
|
1976
|
-
},
|
|
1977
|
-
|
|
1978
|
-
Ln(1,
|
|
1979
|
-
],
|
|
2026
|
+
}, x(ae, "pluginName", Fn), x(ae, "type", W.UNIVER_DOC), ae);
|
|
2027
|
+
lt = wn([
|
|
2028
|
+
Ln(1, V(zt))
|
|
2029
|
+
], lt);
|
|
1980
2030
|
export {
|
|
1981
2031
|
pn as AlignCenterCommand,
|
|
1982
2032
|
_n as AlignJustifyCommand,
|
|
1983
|
-
|
|
1984
|
-
|
|
2033
|
+
hn as AlignLeftCommand,
|
|
2034
|
+
ie as AlignOperationCommand,
|
|
1985
2035
|
Sn as AlignRightCommand,
|
|
1986
2036
|
nn as BreakLineCommand,
|
|
1987
2037
|
gn as BulletListCommand,
|
|
1988
2038
|
In as CoverContentCommand,
|
|
1989
|
-
|
|
2039
|
+
pt as CutContentCommand,
|
|
1990
2040
|
Yn as DOCS_COMPONENT_DEFAULT_Z_INDEX,
|
|
1991
2041
|
Xn as DOCS_COMPONENT_HEADER_LAYER_INDEX,
|
|
1992
2042
|
Hn as DOCS_COMPONENT_MAIN_LAYER_INDEX,
|
|
1993
|
-
|
|
1994
|
-
|
|
2043
|
+
kt as DOCS_VIEW_KEY,
|
|
2044
|
+
Se as DeleteCommand,
|
|
1995
2045
|
cn as DeleteLeftCommand,
|
|
1996
2046
|
ln as DeleteRightCommand,
|
|
1997
2047
|
H as DocSkeletonManagerService,
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2048
|
+
me as DocStateChangeManagerService,
|
|
2049
|
+
ne as DocViewModelManagerService,
|
|
2050
|
+
_t as IMEInputCommand,
|
|
2051
|
+
he as IMEInputManagerService,
|
|
2002
2052
|
Zn as InnerPasteCommand,
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2053
|
+
pe as InsertCommand,
|
|
2054
|
+
ye as MoveCursorOperation,
|
|
2055
|
+
Oe as MoveSelectionOperation,
|
|
2006
2056
|
Wn as NORMAL_TEXT_SELECTION_PLUGIN_NAME,
|
|
2007
|
-
|
|
2057
|
+
fn as OrderListCommand,
|
|
2008
2058
|
vn as ReplaceContentCommand,
|
|
2009
|
-
|
|
2059
|
+
je as ResetInlineFormatTextBackgroundColorCommand,
|
|
2010
2060
|
L as RichTextEditingMutation,
|
|
2011
|
-
|
|
2061
|
+
Rn as SelectAllOperation,
|
|
2012
2062
|
Cn as SetDocZoomRatioCommand,
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
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,
|
|
2022
2072
|
ke as SetInlineFormatTextBackgroundColorCommand,
|
|
2023
2073
|
ze as SetInlineFormatTextColorCommand,
|
|
2024
|
-
|
|
2025
|
-
|
|
2074
|
+
Le as SetInlineFormatUnderlineCommand,
|
|
2075
|
+
ft as SetTextSelectionsOperation,
|
|
2026
2076
|
T as TextSelectionManagerService,
|
|
2027
|
-
|
|
2077
|
+
lt as UniverDocsPlugin,
|
|
2028
2078
|
ht as UpdateCommand,
|
|
2029
2079
|
jt as VIEWPORT_KEY,
|
|
2030
|
-
|
|
2080
|
+
gt as getDocObject,
|
|
2031
2081
|
Gn as getDocObjectById,
|
|
2032
|
-
|
|
2082
|
+
Z as serializeTextRange
|
|
2033
2083
|
};
|