@univerjs/sheets-zen-editor 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +178 -0
- package/README.md +16 -0
- package/lib/cjs/index.js +9 -0
- package/lib/es/index.js +2448 -0
- package/lib/index.css +1 -0
- package/lib/types/commands/commands/zen-editor.command.d.ts +18 -0
- package/lib/types/commands/operations/zen-editor.operation.d.ts +17 -0
- package/lib/types/controllers/zen-editor-ui.controller.d.ts +29 -0
- package/lib/types/controllers/zen-editor.controller.d.ts +44 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/plugin.d.ts +27 -0
- package/lib/types/services/zen-editor.service.d.ts +34 -0
- package/lib/types/views/menu.d.ts +17 -0
- package/lib/types/views/zen-editor/ZenEditor.d.ts +18 -0
- package/lib/types/views/zen-editor/index.d.ts +16 -0
- package/lib/umd/index.js +9 -0
- package/package.json +76 -0
package/lib/es/index.js
ADDED
|
@@ -0,0 +1,2448 @@
|
|
|
1
|
+
var Rt = Object.defineProperty;
|
|
2
|
+
var Et = (i, e, t) => e in i ? Rt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var c = (i, e, t) => (Et(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { LocaleService as bt, IUniverInstanceService as Ce, RANGE_TYPE as $, makeCellToSelection as De, ColorKit as Me, ThemeService as at, createInterceptorKey as ct, Disposable as dt, toDisposable as xe, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ae, InterceptorManager as It, CommandType as Ve, OnLifecycle as ht, LifecycleStages as _t, RxDisposable as Ot, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Je, ICommandService as ze, IUndoRedoService as Mt, DEFAULT_EMPTY_DOCUMENT_VALUE as yt, Plugin as Wt, PluginType as Tt } from "@univerjs/core";
|
|
5
|
+
import { Inject as F, Injector as $e, createIdentifier as Fe } from "@wendellhu/redi";
|
|
6
|
+
import { TextSelectionManagerService as kt, DocSkeletonManagerService as Lt, DocViewModelManagerService as Pt, VIEWPORT_KEY as Ht, RichTextEditingMutation as Bt, getDocObject as xt } from "@univerjs/docs";
|
|
7
|
+
import { SpreadsheetSkeleton as Xt, Rect as P, Group as Xe, DEFAULT_SELECTION_LAYER_INDEX as Yt, FIX_ONE_PIXEL_BLUR_OFFSET as Nt, CURSOR_TYPE as L, Vector2 as X, ScrollTimer as be, ScrollTimerType as q, isRectIntersect as At, DeviceInputEventType as We, getCanvasOffsetByEngine as Dt, fixLineWidthByScale as ve, IRenderManagerService as ut } from "@univerjs/engine-render";
|
|
8
|
+
import { BehaviorSubject as J, Subject as ie, takeUntil as Vt } from "rxjs";
|
|
9
|
+
import { SELECTION_CONTROL_BORDER_BUFFER_COLOR as pe, getNormalSelectionStyle as Se, SELECTION_CONTROL_BORDER_BUFFER_WIDTH as ye } from "@univerjs/sheets";
|
|
10
|
+
import { IShortcutService as zt, IZenZoneService as Te, KeyCode as $t, MenuGroup as Ft, MenuItemType as Ut, MenuPosition as jt, IMenuService as Zt } from "@univerjs/ui";
|
|
11
|
+
import Gt, { forwardRef as Ue, useRef as gt, createElement as je, useEffect as Kt } from "react";
|
|
12
|
+
import { useDependency as Ye } from "@wendellhu/redi/react-bindings";
|
|
13
|
+
import Qe from "clsx";
|
|
14
|
+
function qt(i, e) {
|
|
15
|
+
if (i == null)
|
|
16
|
+
return;
|
|
17
|
+
const t = e.getRenderById(i);
|
|
18
|
+
if (t == null)
|
|
19
|
+
return;
|
|
20
|
+
const { mainComponent: o, scene: n, engine: r } = t;
|
|
21
|
+
return {
|
|
22
|
+
document: o,
|
|
23
|
+
scene: n,
|
|
24
|
+
engine: r
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var b = /* @__PURE__ */ ((i) => (i.VIEW_MAIN = "viewMain", i.VIEW_MAIN_LEFT_TOP = "viewMainLeftTop", i.VIEW_MAIN_TOP = "viewMainTop", i.VIEW_MAIN_LEFT = "viewMainLeft", i.VIEW_ROW_TOP = "viewRowTop", i.VIEW_ROW_BOTTOM = "viewRowBottom", i.VIEW_COLUMN_LEFT = "viewColumnLeft", i.VIEW_COLUMN_RIGHT = "viewColumnRight", i.VIEW_LEFT_TOP = "viewLeftTop", i))(b || {});
|
|
28
|
+
const Jt = 3;
|
|
29
|
+
var Qt = Object.defineProperty, eo = Object.getOwnPropertyDescriptor, to = (i, e, t, o) => {
|
|
30
|
+
for (var n = o > 1 ? void 0 : o ? eo(e, t) : e, r = i.length - 1, s; r >= 0; r--)
|
|
31
|
+
(s = i[r]) && (n = (o ? s(e, t, n) : s(n)) || n);
|
|
32
|
+
return o && n && Qt(e, t, n), n;
|
|
33
|
+
}, et = (i, e) => (t, o) => e(t, o, i);
|
|
34
|
+
let me = class {
|
|
35
|
+
constructor(i, e) {
|
|
36
|
+
c(this, "_currentSkeleton", {
|
|
37
|
+
unitId: "",
|
|
38
|
+
sheetId: ""
|
|
39
|
+
});
|
|
40
|
+
c(this, "_sheetSkeletonParam", []);
|
|
41
|
+
c(this, "_currentSkeleton$", new J(null));
|
|
42
|
+
c(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
|
|
43
|
+
/**
|
|
44
|
+
* CurrentSkeletonBefore for pre-triggered logic during registration
|
|
45
|
+
*/
|
|
46
|
+
c(this, "_currentSkeletonBefore$", new J(null));
|
|
47
|
+
c(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
|
|
48
|
+
this._currentUniverService = i, this._localeService = e;
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
this._currentSkeletonBefore$.complete(), this._currentSkeleton$.complete(), this._sheetSkeletonParam = [];
|
|
52
|
+
}
|
|
53
|
+
getCurrent() {
|
|
54
|
+
return this._getCurrentBySearch(this._currentSkeleton);
|
|
55
|
+
}
|
|
56
|
+
setCurrent(i) {
|
|
57
|
+
const e = this._getCurrentBySearch(i);
|
|
58
|
+
if (e != null)
|
|
59
|
+
this._reCalculate(e);
|
|
60
|
+
else {
|
|
61
|
+
const { unitId: o, sheetId: n } = i, r = this._currentUniverService.getUniverSheetInstance(i.unitId), s = r == null ? void 0 : r.getSheetBySheetId(i.sheetId);
|
|
62
|
+
if (s == null || r == null)
|
|
63
|
+
return;
|
|
64
|
+
const d = this._buildSkeleton(s, r);
|
|
65
|
+
this._sheetSkeletonParam.push({
|
|
66
|
+
unitId: o,
|
|
67
|
+
sheetId: n,
|
|
68
|
+
skeleton: d,
|
|
69
|
+
dirty: !1
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
this._currentSkeleton = i;
|
|
73
|
+
const t = this.getCurrent();
|
|
74
|
+
return this._currentSkeletonBefore$.next(t), this._currentSkeleton$.next(t), this.getCurrent();
|
|
75
|
+
}
|
|
76
|
+
reCalculate() {
|
|
77
|
+
const i = this.getCurrent();
|
|
78
|
+
i != null && this._reCalculate(i);
|
|
79
|
+
}
|
|
80
|
+
_reCalculate(i) {
|
|
81
|
+
i.dirty && (i.skeleton.makeDirty(!0), i.dirty = !1), i.skeleton.calculate();
|
|
82
|
+
}
|
|
83
|
+
makeDirtyCurrent(i = !0) {
|
|
84
|
+
this.makeDirty(this._currentSkeleton, i);
|
|
85
|
+
}
|
|
86
|
+
makeDirty(i, e = !0) {
|
|
87
|
+
const t = this._getCurrentBySearch(i);
|
|
88
|
+
t != null && (t.dirty = e);
|
|
89
|
+
}
|
|
90
|
+
_getCurrentBySearch(i) {
|
|
91
|
+
const e = this._sheetSkeletonParam.find(
|
|
92
|
+
(t) => t.unitId === i.unitId && t.sheetId === i.sheetId
|
|
93
|
+
);
|
|
94
|
+
return e != null && (e.commandId = i.commandId), e;
|
|
95
|
+
}
|
|
96
|
+
_buildSkeleton(i, e) {
|
|
97
|
+
const t = i.getConfig();
|
|
98
|
+
return Xt.create(
|
|
99
|
+
i,
|
|
100
|
+
t,
|
|
101
|
+
i.getCellMatrix(),
|
|
102
|
+
e.getStyles(),
|
|
103
|
+
this._localeService
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
me = to([
|
|
108
|
+
et(0, Ce),
|
|
109
|
+
et(1, F(bt))
|
|
110
|
+
], me);
|
|
111
|
+
class oo {
|
|
112
|
+
constructor() {
|
|
113
|
+
c(this, "_startColumn", -1);
|
|
114
|
+
c(this, "_startRow", -1);
|
|
115
|
+
c(this, "_endColumn", -1);
|
|
116
|
+
c(this, "_endRow", -1);
|
|
117
|
+
c(this, "_startX", 0);
|
|
118
|
+
c(this, "_startY", 0);
|
|
119
|
+
c(this, "_endX", 0);
|
|
120
|
+
c(this, "_endY", 0);
|
|
121
|
+
c(this, "_currentCell");
|
|
122
|
+
c(this, "_rangeType", $.NORMAL);
|
|
123
|
+
}
|
|
124
|
+
get startColumn() {
|
|
125
|
+
return this._startColumn;
|
|
126
|
+
}
|
|
127
|
+
get startRow() {
|
|
128
|
+
return this._startRow;
|
|
129
|
+
}
|
|
130
|
+
get endColumn() {
|
|
131
|
+
return this._endColumn;
|
|
132
|
+
}
|
|
133
|
+
get endRow() {
|
|
134
|
+
return this._endRow;
|
|
135
|
+
}
|
|
136
|
+
get startX() {
|
|
137
|
+
return this._startX;
|
|
138
|
+
}
|
|
139
|
+
get startY() {
|
|
140
|
+
return this._startY;
|
|
141
|
+
}
|
|
142
|
+
get endX() {
|
|
143
|
+
return this._endX;
|
|
144
|
+
}
|
|
145
|
+
get endY() {
|
|
146
|
+
return this._endY;
|
|
147
|
+
}
|
|
148
|
+
get currentCell() {
|
|
149
|
+
return this._currentCell;
|
|
150
|
+
}
|
|
151
|
+
get rangeType() {
|
|
152
|
+
return this._rangeType;
|
|
153
|
+
}
|
|
154
|
+
isEqual(e) {
|
|
155
|
+
const { startColumn: t, startRow: o, endColumn: n, endRow: r } = this, {
|
|
156
|
+
startColumn: s,
|
|
157
|
+
startRow: d,
|
|
158
|
+
endColumn: a,
|
|
159
|
+
endRow: l
|
|
160
|
+
} = e;
|
|
161
|
+
return t === s && o === d && n === a && r === l;
|
|
162
|
+
}
|
|
163
|
+
isInclude(e) {
|
|
164
|
+
const { startColumn: t, startRow: o, endColumn: n, endRow: r } = this, {
|
|
165
|
+
startColumn: s,
|
|
166
|
+
startRow: d,
|
|
167
|
+
endColumn: a,
|
|
168
|
+
endRow: l
|
|
169
|
+
} = e;
|
|
170
|
+
return !(a < t || s > n || d > r || l < o);
|
|
171
|
+
}
|
|
172
|
+
highlightToSelection() {
|
|
173
|
+
return De(this._currentCell);
|
|
174
|
+
}
|
|
175
|
+
getRange() {
|
|
176
|
+
return {
|
|
177
|
+
startColumn: this._startColumn,
|
|
178
|
+
startRow: this._startRow,
|
|
179
|
+
endColumn: this._endColumn,
|
|
180
|
+
endRow: this._endRow,
|
|
181
|
+
startX: this._startX,
|
|
182
|
+
startY: this._startY,
|
|
183
|
+
endX: this._endX,
|
|
184
|
+
endY: this._endY,
|
|
185
|
+
rangeType: this.rangeType
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
getCell() {
|
|
189
|
+
return this._currentCell;
|
|
190
|
+
}
|
|
191
|
+
getRangeType() {
|
|
192
|
+
return this._rangeType;
|
|
193
|
+
}
|
|
194
|
+
getValue() {
|
|
195
|
+
return {
|
|
196
|
+
rangeWithCoord: {
|
|
197
|
+
startColumn: this._startColumn,
|
|
198
|
+
startRow: this._startRow,
|
|
199
|
+
endColumn: this._endColumn,
|
|
200
|
+
endRow: this._endRow,
|
|
201
|
+
startX: this._startX,
|
|
202
|
+
startY: this._startY,
|
|
203
|
+
endX: this._endX,
|
|
204
|
+
endY: this._endY,
|
|
205
|
+
rangeType: this._rangeType
|
|
206
|
+
},
|
|
207
|
+
primaryWithCoord: this._currentCell
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
setValue(e, t) {
|
|
211
|
+
const {
|
|
212
|
+
startColumn: o,
|
|
213
|
+
startRow: n,
|
|
214
|
+
endColumn: r,
|
|
215
|
+
endRow: s,
|
|
216
|
+
startX: d,
|
|
217
|
+
startY: a,
|
|
218
|
+
endX: l,
|
|
219
|
+
endY: g,
|
|
220
|
+
rangeType: S
|
|
221
|
+
} = e;
|
|
222
|
+
this._startColumn = o, this._startRow = n, this._endColumn = r, this._endRow = s, this._startX = d, this._startY = a, this._endX = l, this._endY = g, S != null && (this._rangeType = S), this.setCurrentCell(t);
|
|
223
|
+
}
|
|
224
|
+
setCurrentCell(e) {
|
|
225
|
+
e && (this._currentCell = e);
|
|
226
|
+
}
|
|
227
|
+
clearCurrentCell() {
|
|
228
|
+
this._currentCell = null;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const tt = 0.3;
|
|
232
|
+
class ot {
|
|
233
|
+
constructor(e, t, o = !0, n) {
|
|
234
|
+
c(this, "_leftControl");
|
|
235
|
+
c(this, "_rightControl");
|
|
236
|
+
c(this, "_topControl");
|
|
237
|
+
c(this, "_bottomControl");
|
|
238
|
+
c(this, "_backgroundControlTop");
|
|
239
|
+
c(this, "_backgroundControlBottom");
|
|
240
|
+
c(this, "_backgroundControlMiddleLeft");
|
|
241
|
+
c(this, "_backgroundControlMiddleRight");
|
|
242
|
+
c(this, "_fillControl");
|
|
243
|
+
c(this, "_selectionShape");
|
|
244
|
+
c(this, "_rowHeaderBackground");
|
|
245
|
+
c(this, "_rowHeaderBorder");
|
|
246
|
+
c(this, "_rowHeaderGroup");
|
|
247
|
+
c(this, "_rowHeaderHighlight");
|
|
248
|
+
c(this, "_columnHeaderBackground");
|
|
249
|
+
c(this, "_columnHeaderBorder");
|
|
250
|
+
c(this, "_columnHeaderGroup");
|
|
251
|
+
c(this, "_columnHeaderHighlight");
|
|
252
|
+
c(this, "_topLeftWidget");
|
|
253
|
+
c(this, "_topCenterWidget");
|
|
254
|
+
c(this, "_topRightWidget");
|
|
255
|
+
c(this, "_middleLeftWidget");
|
|
256
|
+
c(this, "_middleRightWidget");
|
|
257
|
+
c(this, "_bottomLeftWidget");
|
|
258
|
+
c(this, "_bottomCenterWidget");
|
|
259
|
+
c(this, "_bottomRightWidget");
|
|
260
|
+
c(this, "_dashRect");
|
|
261
|
+
c(this, "_selectionModel");
|
|
262
|
+
c(this, "_selectionStyle");
|
|
263
|
+
c(this, "_rowHeaderWidth", 0);
|
|
264
|
+
c(this, "_columnHeaderHeight", 0);
|
|
265
|
+
c(this, "_widgetRects", []);
|
|
266
|
+
c(this, "_dispose$", new J(this));
|
|
267
|
+
c(this, "dispose$", this._dispose$.asObservable());
|
|
268
|
+
c(this, "selectionMoving$", new ie());
|
|
269
|
+
c(this, "selectionMoved$", new ie());
|
|
270
|
+
c(this, "selectionScaling$", new ie());
|
|
271
|
+
c(this, "selectionScaled$", new ie());
|
|
272
|
+
c(this, "selectionFilling$", new ie());
|
|
273
|
+
c(this, "_selectionFilled$", new ie());
|
|
274
|
+
c(this, "selectionFilled$", this._selectionFilled$.asObservable());
|
|
275
|
+
c(this, "_defaultStyle");
|
|
276
|
+
c(this, "_isHelperSelection", !0);
|
|
277
|
+
this._scene = e, this._zIndex = t, this._isHeaderHighlight = o, this._themeService = n, this._initialize();
|
|
278
|
+
}
|
|
279
|
+
get zIndex() {
|
|
280
|
+
return this._zIndex;
|
|
281
|
+
}
|
|
282
|
+
get leftControl() {
|
|
283
|
+
return this._leftControl;
|
|
284
|
+
}
|
|
285
|
+
get rightControl() {
|
|
286
|
+
return this._rightControl;
|
|
287
|
+
}
|
|
288
|
+
get topControl() {
|
|
289
|
+
return this._topControl;
|
|
290
|
+
}
|
|
291
|
+
get bottomControl() {
|
|
292
|
+
return this._bottomControl;
|
|
293
|
+
}
|
|
294
|
+
get fillControl() {
|
|
295
|
+
return this._fillControl;
|
|
296
|
+
}
|
|
297
|
+
get backgroundControlTop() {
|
|
298
|
+
return this._backgroundControlTop;
|
|
299
|
+
}
|
|
300
|
+
get backgroundControlBottom() {
|
|
301
|
+
return this._backgroundControlBottom;
|
|
302
|
+
}
|
|
303
|
+
get backgroundControlMiddleLeft() {
|
|
304
|
+
return this._backgroundControlMiddleLeft;
|
|
305
|
+
}
|
|
306
|
+
get backgroundControlMiddleRight() {
|
|
307
|
+
return this._backgroundControlMiddleRight;
|
|
308
|
+
}
|
|
309
|
+
get selectionShape() {
|
|
310
|
+
return this._selectionShape;
|
|
311
|
+
}
|
|
312
|
+
get model() {
|
|
313
|
+
return this._selectionModel;
|
|
314
|
+
}
|
|
315
|
+
get topLeftWidget() {
|
|
316
|
+
return this._topLeftWidget;
|
|
317
|
+
}
|
|
318
|
+
get topCenterWidget() {
|
|
319
|
+
return this._topCenterWidget;
|
|
320
|
+
}
|
|
321
|
+
get topRightWidget() {
|
|
322
|
+
return this._topRightWidget;
|
|
323
|
+
}
|
|
324
|
+
get middleLeftWidget() {
|
|
325
|
+
return this._middleLeftWidget;
|
|
326
|
+
}
|
|
327
|
+
get middleRightWidget() {
|
|
328
|
+
return this._middleRightWidget;
|
|
329
|
+
}
|
|
330
|
+
get bottomLeftWidget() {
|
|
331
|
+
return this._bottomLeftWidget;
|
|
332
|
+
}
|
|
333
|
+
get bottomCenterWidget() {
|
|
334
|
+
return this._bottomCenterWidget;
|
|
335
|
+
}
|
|
336
|
+
get bottomRightWidget() {
|
|
337
|
+
return this._bottomRightWidget;
|
|
338
|
+
}
|
|
339
|
+
get selectionStyle() {
|
|
340
|
+
return this._selectionStyle;
|
|
341
|
+
}
|
|
342
|
+
get dashRect() {
|
|
343
|
+
return this._dashRect;
|
|
344
|
+
}
|
|
345
|
+
get isHelperSelection() {
|
|
346
|
+
return this._isHelperSelection;
|
|
347
|
+
}
|
|
348
|
+
setEvent(e) {
|
|
349
|
+
this.leftControl.evented = e, this.rightControl.evented = e, this.topControl.evented = e, this.bottomControl.evented = e;
|
|
350
|
+
}
|
|
351
|
+
enableHeaderHighlight() {
|
|
352
|
+
this._isHelperSelection = !0;
|
|
353
|
+
}
|
|
354
|
+
disableHeaderHighlight() {
|
|
355
|
+
this._isHeaderHighlight = !1;
|
|
356
|
+
}
|
|
357
|
+
refreshSelectionFilled(e) {
|
|
358
|
+
this._selectionFilled$.next(e);
|
|
359
|
+
}
|
|
360
|
+
updateStyle(e) {
|
|
361
|
+
this._updateControl(e, this._rowHeaderWidth, this._columnHeaderHeight);
|
|
362
|
+
}
|
|
363
|
+
update(e, t = 0, o = 0, n, r) {
|
|
364
|
+
this._selectionModel.setValue(e, r), n == null && (n = this._selectionStyle), this._updateControl(n, t, o);
|
|
365
|
+
}
|
|
366
|
+
clearHighlight() {
|
|
367
|
+
this._selectionModel.clearCurrentCell(), this._updateControl(this._selectionStyle, this._rowHeaderWidth, this._columnHeaderHeight);
|
|
368
|
+
}
|
|
369
|
+
getScene() {
|
|
370
|
+
return this._scene;
|
|
371
|
+
}
|
|
372
|
+
dispose() {
|
|
373
|
+
var e, t, o, n, r, s, d, a, l, g, S, _, u, h, f, m, C, v, w, p, E, I, T, M, k;
|
|
374
|
+
(e = this._leftControl) == null || e.dispose(), (t = this._rightControl) == null || t.dispose(), (o = this._topControl) == null || o.dispose(), (n = this._bottomControl) == null || n.dispose(), (r = this._backgroundControlTop) == null || r.dispose(), (s = this._backgroundControlMiddleLeft) == null || s.dispose(), (d = this._backgroundControlMiddleRight) == null || d.dispose(), (a = this._backgroundControlBottom) == null || a.dispose(), (l = this._fillControl) == null || l.dispose(), (g = this._selectionShape) == null || g.dispose(), (S = this._rowHeaderBackground) == null || S.dispose(), (_ = this._rowHeaderBorder) == null || _.dispose(), (u = this._rowHeaderGroup) == null || u.dispose(), (h = this._rowHeaderBackground) == null || h.dispose(), (f = this._columnHeaderBackground) == null || f.dispose(), (m = this._columnHeaderBorder) == null || m.dispose(), (C = this._columnHeaderGroup) == null || C.dispose(), (v = this._topLeftWidget) == null || v.dispose(), (w = this._topCenterWidget) == null || w.dispose(), (p = this._topRightWidget) == null || p.dispose(), (E = this._middleLeftWidget) == null || E.dispose(), (I = this._middleRightWidget) == null || I.dispose(), (T = this._bottomLeftWidget) == null || T.dispose(), (M = this._bottomCenterWidget) == null || M.dispose(), (k = this._bottomRightWidget) == null || k.dispose(), this._dispose$.next(this), this._dispose$.complete();
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Get the cell information of the current selection, considering the case of merging cells
|
|
378
|
+
*/
|
|
379
|
+
getCurrentCellInfo() {
|
|
380
|
+
const e = this.model.currentCell;
|
|
381
|
+
if (e) {
|
|
382
|
+
let t;
|
|
383
|
+
if (e.isMerged) {
|
|
384
|
+
const o = e.mergeInfo;
|
|
385
|
+
t = {
|
|
386
|
+
startRow: o.startRow,
|
|
387
|
+
endRow: o.endRow,
|
|
388
|
+
startColumn: o.startColumn,
|
|
389
|
+
endColumn: o.endColumn,
|
|
390
|
+
startX: o.startX,
|
|
391
|
+
endX: o.endX,
|
|
392
|
+
startY: o.startY,
|
|
393
|
+
endY: o.endY
|
|
394
|
+
};
|
|
395
|
+
} else {
|
|
396
|
+
const { actualRow: o, actualColumn: n, startX: r, endX: s, startY: d, endY: a } = e;
|
|
397
|
+
t = {
|
|
398
|
+
startRow: o,
|
|
399
|
+
endRow: o,
|
|
400
|
+
startColumn: n,
|
|
401
|
+
endColumn: n,
|
|
402
|
+
startX: r,
|
|
403
|
+
endX: s,
|
|
404
|
+
startY: d,
|
|
405
|
+
endY: a
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
return t;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
getValue() {
|
|
412
|
+
return {
|
|
413
|
+
...this._selectionModel.getValue(),
|
|
414
|
+
style: this._selectionStyle
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
getRange() {
|
|
418
|
+
return this._selectionModel.getValue().rangeWithCoord;
|
|
419
|
+
}
|
|
420
|
+
enableHelperSelection() {
|
|
421
|
+
this._isHelperSelection = !0;
|
|
422
|
+
}
|
|
423
|
+
disableHelperSelection() {
|
|
424
|
+
this._isHelperSelection = !1;
|
|
425
|
+
}
|
|
426
|
+
updateStyleId(e) {
|
|
427
|
+
this._selectionStyle != null && (this._selectionStyle.id = e);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* just handle the view
|
|
431
|
+
*
|
|
432
|
+
* inner update
|
|
433
|
+
*/
|
|
434
|
+
_updateControl(e, t, o) {
|
|
435
|
+
const { startX: n, startY: r, endX: s, endY: d } = this._selectionModel, a = this._defaultStyle;
|
|
436
|
+
e == null && (e = a);
|
|
437
|
+
const {
|
|
438
|
+
stroke: l = a.stroke,
|
|
439
|
+
widgets: g = a.widgets,
|
|
440
|
+
hasAutoFill: S = a.hasAutoFill,
|
|
441
|
+
AutofillStroke: _ = a.AutofillStroke,
|
|
442
|
+
strokeDash: u
|
|
443
|
+
} = e;
|
|
444
|
+
let {
|
|
445
|
+
strokeWidth: h = a.strokeWidth,
|
|
446
|
+
AutofillSize: f = a.AutofillSize,
|
|
447
|
+
AutofillStrokeWidth: m = a.AutofillStrokeWidth
|
|
448
|
+
} = e;
|
|
449
|
+
const C = this._getScale(), v = (h + ye) / 2 / C;
|
|
450
|
+
h /= C, f /= C, m /= C < 1 ? 1 : C;
|
|
451
|
+
const w = ye / C, p = Nt / C;
|
|
452
|
+
this.leftControl.transformByState({
|
|
453
|
+
height: d - r,
|
|
454
|
+
left: -v + p,
|
|
455
|
+
width: h,
|
|
456
|
+
strokeWidth: w,
|
|
457
|
+
top: -w / 2 + p
|
|
458
|
+
}), this.leftControl.setProps({
|
|
459
|
+
fill: l,
|
|
460
|
+
stroke: pe
|
|
461
|
+
}), this.rightControl.transformByState({
|
|
462
|
+
height: d - r,
|
|
463
|
+
left: s - n - v + p,
|
|
464
|
+
width: h,
|
|
465
|
+
strokeWidth: w,
|
|
466
|
+
top: -w / 2 + p
|
|
467
|
+
}), this.rightControl.setProps({
|
|
468
|
+
fill: l,
|
|
469
|
+
stroke: pe
|
|
470
|
+
}), this.topControl.transformByState({
|
|
471
|
+
width: s - n + h,
|
|
472
|
+
top: -v + p,
|
|
473
|
+
left: -v + p,
|
|
474
|
+
height: h,
|
|
475
|
+
strokeWidth: w
|
|
476
|
+
}), this.topControl.setProps({
|
|
477
|
+
fill: l,
|
|
478
|
+
stroke: pe
|
|
479
|
+
}), this.bottomControl.transformByState({
|
|
480
|
+
width: s - n + h,
|
|
481
|
+
top: d - r - v + p,
|
|
482
|
+
height: h,
|
|
483
|
+
left: -v + p,
|
|
484
|
+
strokeWidth: w
|
|
485
|
+
}), this.bottomControl.setProps({
|
|
486
|
+
fill: l,
|
|
487
|
+
stroke: pe
|
|
488
|
+
}), u == null ? this.dashRect.hide() : (this.dashRect.transformByState({
|
|
489
|
+
height: d - r - h / 2,
|
|
490
|
+
width: s - n - h / 2,
|
|
491
|
+
strokeWidth: h,
|
|
492
|
+
left: h / 2 - 1 / C,
|
|
493
|
+
top: h / 2 - 1 / C
|
|
494
|
+
}), this.dashRect.setProps({
|
|
495
|
+
strokeDashArray: [0, u]
|
|
496
|
+
}), this.dashRect.show()), S === !0 && !this._hasWidgets(g) ? (this.fillControl.setProps({
|
|
497
|
+
fill: l,
|
|
498
|
+
stroke: _,
|
|
499
|
+
strokeScaleEnabled: !1
|
|
500
|
+
}), this.fillControl.transformByState({
|
|
501
|
+
width: f - m,
|
|
502
|
+
height: f - m,
|
|
503
|
+
left: s - n - f / 2 + m / 2,
|
|
504
|
+
top: d - r - f / 2 + m / 2,
|
|
505
|
+
strokeWidth: m
|
|
506
|
+
}), this.fillControl.show()) : this.fillControl.hide(), this._updateBackgroundControl(e), this._updateBackgroundTitle(e, t, o), this._updateWidgets(e), this.selectionShape.show(), this.selectionShape.translate(n, r), this._selectionStyle = e, this._rowHeaderWidth = t || 0, this._columnHeaderHeight = o || 0, this.selectionShape.makeDirtyNoDebounce(!0);
|
|
507
|
+
}
|
|
508
|
+
_initialize() {
|
|
509
|
+
this._defaultStyle = Se(this._themeService), this._selectionModel = new oo();
|
|
510
|
+
const e = this._zIndex;
|
|
511
|
+
this._leftControl = new P("__SpreadsheetSelectionShapeLeftControl__" + e, {
|
|
512
|
+
zIndex: e
|
|
513
|
+
}), this._rightControl = new P("__SpreadsheetSelectionShapeRightControl__" + e, {
|
|
514
|
+
zIndex: e
|
|
515
|
+
}), this._topControl = new P("__SpreadsheetSelectionTopControl__" + e, {
|
|
516
|
+
zIndex: e
|
|
517
|
+
}), this._bottomControl = new P("__SpreadsheetSelectionBottomControl__" + e, {
|
|
518
|
+
zIndex: e
|
|
519
|
+
}), this._backgroundControlTop = new P("__SpreadsheetSelectionBackgroundControlTop__" + e, {
|
|
520
|
+
zIndex: e - 1,
|
|
521
|
+
evented: !1
|
|
522
|
+
}), this._backgroundControlBottom = new P("__SpreadsheetSelectionBackgroundControlBottom__" + e, {
|
|
523
|
+
zIndex: e - 1,
|
|
524
|
+
evented: !1
|
|
525
|
+
}), this._backgroundControlMiddleLeft = new P("__SpreadsheetSelectionBackgroundControlMiddleLeft__" + e, {
|
|
526
|
+
zIndex: e - 1,
|
|
527
|
+
evented: !1
|
|
528
|
+
}), this._backgroundControlMiddleRight = new P("__SpreadsheetSelectionBackgroundControlMiddleRight__" + e, {
|
|
529
|
+
zIndex: e - 1,
|
|
530
|
+
evented: !1
|
|
531
|
+
}), this._fillControl = new P("__SpreadsheetSelectionFillControl__" + e, {
|
|
532
|
+
zIndex: e + 1
|
|
533
|
+
}), this._dashRect = new P("__SpreadsheetDragDashControl__" + e, {
|
|
534
|
+
zIndex: e + 2,
|
|
535
|
+
evented: !1,
|
|
536
|
+
stroke: "#fff"
|
|
537
|
+
});
|
|
538
|
+
const t = [
|
|
539
|
+
this._fillControl,
|
|
540
|
+
this._leftControl,
|
|
541
|
+
this._rightControl,
|
|
542
|
+
this._topControl,
|
|
543
|
+
this._bottomControl,
|
|
544
|
+
this._backgroundControlTop,
|
|
545
|
+
this._backgroundControlMiddleLeft,
|
|
546
|
+
this._backgroundControlMiddleRight,
|
|
547
|
+
this._backgroundControlBottom,
|
|
548
|
+
this._dashRect
|
|
549
|
+
];
|
|
550
|
+
this._widgetRects = this._initialWidget(), this._selectionShape = new Xe("__SpreadsheetSelectionShape__" + e, ...t, ...this._widgetRects), this._selectionShape.hide(), this._selectionShape.evented = !1, this._selectionShape.zIndex = e, this.getScene().addObject(this._selectionShape, Jt), this._initialTitle();
|
|
551
|
+
}
|
|
552
|
+
_initialTitle() {
|
|
553
|
+
const e = this._zIndex;
|
|
554
|
+
this._rowHeaderBackground = new P("__SpreadSheetSelectionRowHeaderBackground__" + e, {
|
|
555
|
+
zIndex: e - 1,
|
|
556
|
+
evented: !1
|
|
557
|
+
}), this._rowHeaderBorder = new P("__SpreadSheetSelectionRowHeaderBorder__" + e, {
|
|
558
|
+
zIndex: e - 1,
|
|
559
|
+
evented: !1
|
|
560
|
+
}), this._rowHeaderGroup = new Xe(
|
|
561
|
+
"__SpreadSheetSelectionRowHeaderGroup__" + e,
|
|
562
|
+
this._rowHeaderBackground,
|
|
563
|
+
this._rowHeaderBorder
|
|
564
|
+
), this._rowHeaderGroup.hide(), this._rowHeaderGroup.evented = !1, this._rowHeaderGroup.zIndex = e, this._columnHeaderBackground = new P("__SpreadSheetSelectionColumnHeaderBackground__" + e, {
|
|
565
|
+
zIndex: e - 1,
|
|
566
|
+
evented: !1
|
|
567
|
+
}), this._columnHeaderBorder = new P("__SpreadSheetSelectionColumnHeaderBorder__" + e, {
|
|
568
|
+
zIndex: e - 1,
|
|
569
|
+
evented: !1
|
|
570
|
+
}), this._columnHeaderGroup = new Xe(
|
|
571
|
+
"__SpreadSheetSelectionColumnHeaderGroup__" + e,
|
|
572
|
+
this._columnHeaderBackground,
|
|
573
|
+
this._columnHeaderBorder
|
|
574
|
+
), this._columnHeaderGroup.hide(), this._columnHeaderGroup.evented = !1, this._columnHeaderGroup.zIndex = e, this.getScene().addObjects([this._rowHeaderGroup, this._columnHeaderGroup], Yt);
|
|
575
|
+
}
|
|
576
|
+
_initialWidget() {
|
|
577
|
+
const e = this._zIndex;
|
|
578
|
+
return this._topLeftWidget = new P("__SpreadSheetSelectionTopLeftWidget__" + e, {
|
|
579
|
+
zIndex: e + 1
|
|
580
|
+
}), this._topCenterWidget = new P("__SpreadSheetSelectionTopCenterWidget__" + e, {
|
|
581
|
+
zIndex: e + 1
|
|
582
|
+
}), this._topRightWidget = new P("__SpreadSheetSelectionTopRightWidget__" + e, {
|
|
583
|
+
zIndex: e + 1
|
|
584
|
+
}), this._middleLeftWidget = new P("__SpreadSheetSelectionMiddleLeftWidget__" + e, {
|
|
585
|
+
zIndex: e + 1
|
|
586
|
+
}), this._middleRightWidget = new P("__SpreadSheetSelectionMiddleRightWidget__" + e, {
|
|
587
|
+
zIndex: e + 1
|
|
588
|
+
}), this._bottomLeftWidget = new P("__SpreadSheetSelectionBottomLeftWidget__" + e, {
|
|
589
|
+
zIndex: e + 1
|
|
590
|
+
}), this._bottomCenterWidget = new P("__SpreadSheetSelectionBottomCenterWidget__" + e, {
|
|
591
|
+
zIndex: e + 1
|
|
592
|
+
}), this._bottomRightWidget = new P("__SpreadSheetSelectionBottomRightWidget__" + e, {
|
|
593
|
+
zIndex: e + 1
|
|
594
|
+
}), [
|
|
595
|
+
this._topLeftWidget,
|
|
596
|
+
this._topCenterWidget,
|
|
597
|
+
this._topRightWidget,
|
|
598
|
+
this._middleLeftWidget,
|
|
599
|
+
this._middleRightWidget,
|
|
600
|
+
this._bottomLeftWidget,
|
|
601
|
+
this._bottomCenterWidget,
|
|
602
|
+
this._bottomRightWidget
|
|
603
|
+
];
|
|
604
|
+
}
|
|
605
|
+
_updateBackgroundTitle(e, t, o) {
|
|
606
|
+
const { startX: n, startY: r, endX: s, endY: d, rangeType: a } = this._selectionModel, l = this._defaultStyle;
|
|
607
|
+
e == null && (e = l);
|
|
608
|
+
const g = this._getScale(), {
|
|
609
|
+
stroke: S,
|
|
610
|
+
hasRowHeader: _,
|
|
611
|
+
rowHeaderFill: u = l.rowHeaderFill,
|
|
612
|
+
rowHeaderStroke: h = l.rowHeaderStroke,
|
|
613
|
+
hasColumnHeader: f,
|
|
614
|
+
columnHeaderFill: m = l.columnHeaderFill,
|
|
615
|
+
columnHeaderStroke: C = l.columnHeaderStroke
|
|
616
|
+
} = e;
|
|
617
|
+
let {
|
|
618
|
+
rowHeaderStrokeWidth: v = l.rowHeaderStrokeWidth,
|
|
619
|
+
columnHeaderStrokeWidth: w = l.columnHeaderStrokeWidth
|
|
620
|
+
} = e;
|
|
621
|
+
if (v /= g, w /= g, f === !0) {
|
|
622
|
+
let p = m;
|
|
623
|
+
this._isHeaderHighlight && a === $.COLUMN && (p = new Me(S).setAlpha(tt).toString()), this._columnHeaderBackground.setProps({
|
|
624
|
+
fill: p
|
|
625
|
+
}), this._columnHeaderBackground.resize(s - n, o), this._columnHeaderBorder.setProps({
|
|
626
|
+
fill: C
|
|
627
|
+
}), this._columnHeaderBorder.transformByState({
|
|
628
|
+
width: s - n,
|
|
629
|
+
height: w,
|
|
630
|
+
top: o - w + 1 / g
|
|
631
|
+
}), this._columnHeaderGroup.show(), this._columnHeaderGroup.translate(n, 0);
|
|
632
|
+
} else
|
|
633
|
+
this._columnHeaderGroup.hide();
|
|
634
|
+
if (this._columnHeaderGroup.makeDirty(!0), _ === !0) {
|
|
635
|
+
let p = u;
|
|
636
|
+
this._isHeaderHighlight && a === $.ROW && (p = new Me(S).setAlpha(tt).toString()), this._rowHeaderBackground.setProps({
|
|
637
|
+
fill: p
|
|
638
|
+
}), this._rowHeaderBackground.resize(t, d - r), this._rowHeaderBorder.setProps({
|
|
639
|
+
fill: h
|
|
640
|
+
}), this._rowHeaderBorder.transformByState({
|
|
641
|
+
width: v,
|
|
642
|
+
height: d - r,
|
|
643
|
+
left: t - v + 1 / g
|
|
644
|
+
}), this._rowHeaderGroup.show(), this._rowHeaderGroup.translate(0, r);
|
|
645
|
+
} else
|
|
646
|
+
this._rowHeaderGroup.hide();
|
|
647
|
+
this._rowHeaderGroup.makeDirty(!0);
|
|
648
|
+
}
|
|
649
|
+
_updateBackgroundControl(e) {
|
|
650
|
+
const { startX: t, startY: o, endX: n, endY: r } = this._selectionModel, s = this._defaultStyle;
|
|
651
|
+
e == null && (e = s);
|
|
652
|
+
const d = this._getScale(), { fill: a = s.fill } = e;
|
|
653
|
+
let { strokeWidth: l = s.strokeWidth } = e;
|
|
654
|
+
l /= d;
|
|
655
|
+
const g = this._selectionModel.highlightToSelection();
|
|
656
|
+
if (!g) {
|
|
657
|
+
this._backgroundControlTop.resize(n - t, r - o), this._backgroundControlTop.setProps({ fill: a }), this._backgroundControlBottom.resize(0, 0), this._backgroundControlMiddleLeft.resize(0, 0), this._backgroundControlMiddleRight.resize(0, 0);
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
const { startX: S, startY: _, endX: u, endY: h } = g, f = l / 2, m = {
|
|
661
|
+
left: -f,
|
|
662
|
+
top: -f,
|
|
663
|
+
width: n - t + f * 2,
|
|
664
|
+
height: _ - o + f
|
|
665
|
+
};
|
|
666
|
+
m.height < 0 && (m.width = 0, m.height = 0), this._backgroundControlTop.transformByState(m);
|
|
667
|
+
const C = {
|
|
668
|
+
left: -f,
|
|
669
|
+
top: _ - o,
|
|
670
|
+
width: S - t + f,
|
|
671
|
+
height: h - _
|
|
672
|
+
};
|
|
673
|
+
C.width < 0 && (C.width = 0, C.height = 0), this._backgroundControlMiddleLeft.transformByState(C);
|
|
674
|
+
const v = {
|
|
675
|
+
left: u - t - f,
|
|
676
|
+
top: _ - o,
|
|
677
|
+
width: n - u + f * 2,
|
|
678
|
+
height: h - _
|
|
679
|
+
};
|
|
680
|
+
v.width < 0 && (v.width = 0, v.height = 0), this._backgroundControlMiddleRight.transformByState(v);
|
|
681
|
+
const w = {
|
|
682
|
+
left: -f,
|
|
683
|
+
top: h - o,
|
|
684
|
+
width: n - t + f * 2,
|
|
685
|
+
height: r - h + f
|
|
686
|
+
};
|
|
687
|
+
w.height < 0 && (w.width = 0, w.height = 0), this._backgroundControlBottom.transformByState(w), this._backgroundControlTop.setProps({ fill: a }), this._backgroundControlMiddleLeft.setProps({ fill: a }), this._backgroundControlMiddleRight.setProps({ fill: a }), this._backgroundControlBottom.setProps({ fill: a });
|
|
688
|
+
}
|
|
689
|
+
_updateWidgets(e) {
|
|
690
|
+
const { startX: t, startY: o, endX: n, endY: r } = this._selectionModel, s = this._defaultStyle;
|
|
691
|
+
e == null && (e = s);
|
|
692
|
+
const {
|
|
693
|
+
stroke: d = s.stroke,
|
|
694
|
+
widgets: a = s.widgets,
|
|
695
|
+
widgetStroke: l = s.widgetStroke
|
|
696
|
+
} = e, g = this._getScale();
|
|
697
|
+
let { widgetSize: S = s.widgetSize, widgetStrokeWidth: _ = s.widgetStrokeWidth } = e;
|
|
698
|
+
S /= g, _ /= g;
|
|
699
|
+
const u = {
|
|
700
|
+
left: -S / 2 + _ / 2,
|
|
701
|
+
center: (n - t) / 2 - S / 2 + _ / 2,
|
|
702
|
+
right: n - t - S / 2 + _ / 2,
|
|
703
|
+
top: -S / 2,
|
|
704
|
+
middle: (r - o) / 2 - S / 2,
|
|
705
|
+
bottom: r - o - S / 2 + _ / 2
|
|
706
|
+
}, h = S - _;
|
|
707
|
+
this._widgetRects.forEach((f) => {
|
|
708
|
+
f.setProps({
|
|
709
|
+
fill: d,
|
|
710
|
+
stroke: l
|
|
711
|
+
});
|
|
712
|
+
}), a.tl === !0 ? (this._topLeftWidget.transformByState({
|
|
713
|
+
height: h,
|
|
714
|
+
width: h,
|
|
715
|
+
left: u.left,
|
|
716
|
+
top: u.top,
|
|
717
|
+
strokeWidth: _
|
|
718
|
+
}), this._topLeftWidget.show()) : this._topLeftWidget.hide(), a.tc === !0 ? (this._topCenterWidget.transformByState({
|
|
719
|
+
height: h,
|
|
720
|
+
width: h,
|
|
721
|
+
left: u.center,
|
|
722
|
+
top: u.top,
|
|
723
|
+
strokeWidth: _
|
|
724
|
+
}), this._topCenterWidget.show()) : this._topCenterWidget.hide(), a.tr === !0 ? (this._topRightWidget.transformByState({
|
|
725
|
+
height: h,
|
|
726
|
+
width: h,
|
|
727
|
+
left: u.right,
|
|
728
|
+
top: u.top,
|
|
729
|
+
strokeWidth: _
|
|
730
|
+
}), this._topRightWidget.show()) : this._topRightWidget.hide(), a.ml === !0 ? (this._middleLeftWidget.transformByState({
|
|
731
|
+
height: h,
|
|
732
|
+
width: h,
|
|
733
|
+
left: u.left,
|
|
734
|
+
top: u.middle,
|
|
735
|
+
strokeWidth: _
|
|
736
|
+
}), this._middleLeftWidget.show()) : this._middleLeftWidget.hide(), a.mr === !0 ? (this._middleRightWidget.transformByState({
|
|
737
|
+
height: h,
|
|
738
|
+
width: h,
|
|
739
|
+
left: u.right,
|
|
740
|
+
top: u.middle,
|
|
741
|
+
strokeWidth: _
|
|
742
|
+
}), this._middleRightWidget.show()) : this._middleRightWidget.hide(), a.bl === !0 ? (this._bottomLeftWidget.transformByState({
|
|
743
|
+
height: h,
|
|
744
|
+
width: h,
|
|
745
|
+
left: u.left,
|
|
746
|
+
top: u.bottom,
|
|
747
|
+
strokeWidth: _
|
|
748
|
+
}), this._bottomLeftWidget.show()) : this._bottomLeftWidget.hide(), a.bc === !0 ? (this._bottomCenterWidget.transformByState({
|
|
749
|
+
height: h,
|
|
750
|
+
width: h,
|
|
751
|
+
left: u.center,
|
|
752
|
+
top: u.bottom,
|
|
753
|
+
strokeWidth: _
|
|
754
|
+
}), this._bottomCenterWidget.show()) : this._bottomCenterWidget.hide(), a.br === !0 ? (this._bottomRightWidget.transformByState({
|
|
755
|
+
height: h,
|
|
756
|
+
width: h,
|
|
757
|
+
left: u.right,
|
|
758
|
+
top: u.bottom,
|
|
759
|
+
strokeWidth: _
|
|
760
|
+
}), this._bottomRightWidget.show()) : this._bottomRightWidget.hide();
|
|
761
|
+
}
|
|
762
|
+
_hasWidgets(e) {
|
|
763
|
+
if (e == null)
|
|
764
|
+
return !1;
|
|
765
|
+
const t = Object.keys(e);
|
|
766
|
+
if (t.length === 0)
|
|
767
|
+
return !1;
|
|
768
|
+
for (const o of t)
|
|
769
|
+
if (e[o] === !0)
|
|
770
|
+
return !0;
|
|
771
|
+
return !0;
|
|
772
|
+
}
|
|
773
|
+
_getScale() {
|
|
774
|
+
const { scaleX: e, scaleY: t } = this._scene.getAncestorScale();
|
|
775
|
+
return Math.max(e, t);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
const it = "__SpreadsheetHelperSelectionTempRect", io = 35;
|
|
779
|
+
class nt {
|
|
780
|
+
constructor(e, t, o, n, r) {
|
|
781
|
+
c(this, "_startOffsetX", 0);
|
|
782
|
+
c(this, "_startOffsetY", 0);
|
|
783
|
+
c(this, "_relativeSelectionPositionRow", 0);
|
|
784
|
+
c(this, "_relativeSelectionPositionColumn", 0);
|
|
785
|
+
c(this, "_relativeSelectionRowLength", 0);
|
|
786
|
+
c(this, "_relativeSelectionColumnLength", 0);
|
|
787
|
+
c(this, "_moveObserver");
|
|
788
|
+
c(this, "_upObserver");
|
|
789
|
+
c(this, "_helperSelection");
|
|
790
|
+
c(this, "_scrollTimer");
|
|
791
|
+
c(this, "_activeViewport");
|
|
792
|
+
c(this, "_targetSelection", {
|
|
793
|
+
startY: 0,
|
|
794
|
+
endY: 0,
|
|
795
|
+
startX: 0,
|
|
796
|
+
endX: 0,
|
|
797
|
+
startRow: -1,
|
|
798
|
+
endRow: -1,
|
|
799
|
+
startColumn: -1,
|
|
800
|
+
endColumn: -1
|
|
801
|
+
});
|
|
802
|
+
c(this, "_isInMergeState", !1);
|
|
803
|
+
c(this, "_fillControlColors", []);
|
|
804
|
+
this._control = e, this._skeleton = t, this._scene = o, this._themeService = n, this._injector = r, this._initialControl(), this._initialWidget(), this._initialFill(), this._control.dispose$.subscribe(() => {
|
|
805
|
+
this.dispose();
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
get isHelperSelection() {
|
|
809
|
+
return this._control.isHelperSelection;
|
|
810
|
+
}
|
|
811
|
+
dispose() {
|
|
812
|
+
var e, t;
|
|
813
|
+
(e = this._scrollTimer) == null || e.dispose(), this._fillControlColors = [], this._clearObserverEvent(), (t = this._helperSelection) == null || t.dispose();
|
|
814
|
+
}
|
|
815
|
+
_getFreeze() {
|
|
816
|
+
var t;
|
|
817
|
+
return (t = this._injector.get(me).getCurrent()) == null ? void 0 : t.skeleton.getWorksheetConfig().freeze;
|
|
818
|
+
}
|
|
819
|
+
_isSelectionInViewport(e, t) {
|
|
820
|
+
const o = this._getFreeze() || {
|
|
821
|
+
startRow: -1,
|
|
822
|
+
startColumn: -1,
|
|
823
|
+
xSplit: 0,
|
|
824
|
+
ySplit: 0
|
|
825
|
+
};
|
|
826
|
+
switch (t.viewPortKey) {
|
|
827
|
+
case b.VIEW_MAIN:
|
|
828
|
+
return e.endRow >= o.startRow && e.endColumn >= o.startColumn;
|
|
829
|
+
case b.VIEW_MAIN_TOP:
|
|
830
|
+
case b.VIEW_COLUMN_RIGHT:
|
|
831
|
+
return e.endColumn >= o.startColumn && e.startRow < o.startRow;
|
|
832
|
+
case b.VIEW_MAIN_LEFT:
|
|
833
|
+
case b.VIEW_ROW_BOTTOM:
|
|
834
|
+
return e.endRow >= o.startRow && e.startColumn < o.startColumn;
|
|
835
|
+
case b.VIEW_MAIN_LEFT_TOP:
|
|
836
|
+
case b.VIEW_COLUMN_LEFT:
|
|
837
|
+
case b.VIEW_ROW_TOP:
|
|
838
|
+
case b.VIEW_LEFT_TOP:
|
|
839
|
+
return e.startRow < o.startRow && e.startColumn < o.startColumn;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
_clearObserverEvent() {
|
|
843
|
+
this._scene.onPointerMoveObserver.remove(this._moveObserver), this._scene.onPointerUpObserver.remove(this._upObserver), this._moveObserver = null, this._upObserver = null;
|
|
844
|
+
}
|
|
845
|
+
_initialControl() {
|
|
846
|
+
const { leftControl: e, rightControl: t, topControl: o, bottomControl: n } = this._control;
|
|
847
|
+
[e, t, o, n].forEach((r) => {
|
|
848
|
+
r.onPointerEnterObserver.add(() => {
|
|
849
|
+
r.setCursor(L.MOVE);
|
|
850
|
+
}), r.onPointerLeaveObserver.add(() => {
|
|
851
|
+
r.resetCursor();
|
|
852
|
+
}), r.onPointerDownObserver.add(this._controlEvent.bind(this));
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
_controlMoving(e, t) {
|
|
856
|
+
var I;
|
|
857
|
+
const o = this._scene, n = o.getScrollXYByRelativeCoords(X.FromArray([e, t])), { scaleX: r, scaleY: s } = o.getAncestorScale(), d = this._skeleton.getCellPositionByOffset(
|
|
858
|
+
e,
|
|
859
|
+
t,
|
|
860
|
+
r,
|
|
861
|
+
s,
|
|
862
|
+
n
|
|
863
|
+
), { row: a, column: l } = d, g = this._skeleton.getRowCount() - 1, S = this._skeleton.getColumnCount() - 1;
|
|
864
|
+
let _ = a + this._relativeSelectionPositionRow;
|
|
865
|
+
_ < 0 && (_ = 0);
|
|
866
|
+
let u = _ + this._relativeSelectionRowLength;
|
|
867
|
+
u > g && (u = g, u - _ < this._relativeSelectionRowLength && (_ = u - this._relativeSelectionRowLength));
|
|
868
|
+
let h = l + this._relativeSelectionPositionColumn;
|
|
869
|
+
h < 0 && (h = 0);
|
|
870
|
+
let f = h + this._relativeSelectionColumnLength;
|
|
871
|
+
f > S && (f = S, f - h < this._relativeSelectionColumnLength && (h = f - this._relativeSelectionColumnLength));
|
|
872
|
+
const m = this._skeleton.getNoMergeCellPositionByIndex(_, h), C = this._skeleton.getNoMergeCellPositionByIndex(u, f), v = (m == null ? void 0 : m.startY) || 0, w = (C == null ? void 0 : C.endY) || 0, p = (m == null ? void 0 : m.startX) || 0, E = (C == null ? void 0 : C.endX) || 0;
|
|
873
|
+
(I = this._helperSelection) == null || I.transformByState({
|
|
874
|
+
left: p,
|
|
875
|
+
top: v,
|
|
876
|
+
width: E - p,
|
|
877
|
+
height: w - v
|
|
878
|
+
}), this._targetSelection = {
|
|
879
|
+
startY: v,
|
|
880
|
+
endY: w,
|
|
881
|
+
startX: p,
|
|
882
|
+
endX: E,
|
|
883
|
+
startRow: _,
|
|
884
|
+
endRow: u,
|
|
885
|
+
startColumn: h,
|
|
886
|
+
endColumn: f
|
|
887
|
+
}, this._control.selectionMoving$.next(this._targetSelection);
|
|
888
|
+
}
|
|
889
|
+
_controlEvent(e) {
|
|
890
|
+
const { offsetX: t, offsetY: o } = e, n = this._scene, r = n.getRelativeCoord(X.FromArray([t, o])), { x: s, y: d } = r, a = n.getScrollXYByRelativeCoords(r), { scaleX: l, scaleY: g } = n.getAncestorScale(), S = this._skeleton.getCellPositionByOffset(
|
|
891
|
+
s,
|
|
892
|
+
d,
|
|
893
|
+
l,
|
|
894
|
+
g,
|
|
895
|
+
a
|
|
896
|
+
);
|
|
897
|
+
this._startOffsetX = s, this._startOffsetY = d;
|
|
898
|
+
const { row: _, column: u } = S, {
|
|
899
|
+
startRow: h,
|
|
900
|
+
startColumn: f,
|
|
901
|
+
endRow: m,
|
|
902
|
+
endColumn: C
|
|
903
|
+
} = this._control.model;
|
|
904
|
+
let v = 0, w = 0;
|
|
905
|
+
_ < h ? v -= 1 : _ > m && (v += 1), u < f ? w -= 1 : u > C && (w += 1), this._relativeSelectionPositionRow = h - _ + v, this._relativeSelectionPositionColumn = f - u + w, this._relativeSelectionRowLength = m - h, this._relativeSelectionColumnLength = C - f;
|
|
906
|
+
const p = this._control.selectionStyle, E = this._getScale();
|
|
907
|
+
this.isHelperSelection && (this._helperSelection = new P(it, {
|
|
908
|
+
stroke: p.stroke,
|
|
909
|
+
strokeWidth: p.strokeWidth / E
|
|
910
|
+
}), n.addObject(this._helperSelection));
|
|
911
|
+
const I = n.getViewport(b.VIEW_MAIN), T = be.create(n);
|
|
912
|
+
T.startScroll(s, d, I), this._scrollTimer = T, n.disableEvent(), this._moveObserver = n.onPointerMoveObserver.add((M) => {
|
|
913
|
+
const { offsetX: k, offsetY: y } = M, { x: O, y: B } = n.getRelativeCoord(
|
|
914
|
+
X.FromArray([k, y])
|
|
915
|
+
);
|
|
916
|
+
this._controlMoving(O, B), n.setCursor(L.MOVE), T.scrolling(O, B, () => {
|
|
917
|
+
this._controlMoving(O, B);
|
|
918
|
+
});
|
|
919
|
+
}), this._upObserver = n.onPointerUpObserver.add(() => {
|
|
920
|
+
var k, y;
|
|
921
|
+
(k = this._helperSelection) == null || k.dispose();
|
|
922
|
+
const M = this._scene;
|
|
923
|
+
M.resetCursor(), this._clearObserverEvent(), M.enableEvent(), (y = this._scrollTimer) == null || y.dispose(), this._control.selectionMoved$.next(this._targetSelection);
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
_initialWidget() {
|
|
927
|
+
const {
|
|
928
|
+
topLeftWidget: e,
|
|
929
|
+
topCenterWidget: t,
|
|
930
|
+
topRightWidget: o,
|
|
931
|
+
middleLeftWidget: n,
|
|
932
|
+
middleRightWidget: r,
|
|
933
|
+
bottomLeftWidget: s,
|
|
934
|
+
bottomCenterWidget: d,
|
|
935
|
+
bottomRightWidget: a
|
|
936
|
+
} = this._control, l = [
|
|
937
|
+
L.NORTH_WEST_RESIZE,
|
|
938
|
+
L.NORTH_RESIZE,
|
|
939
|
+
L.NORTH_EAST_RESIZE,
|
|
940
|
+
L.WEST_RESIZE,
|
|
941
|
+
L.EAST_RESIZE,
|
|
942
|
+
L.SOUTH_WEST_RESIZE,
|
|
943
|
+
L.SOUTH_RESIZE,
|
|
944
|
+
L.SOUTH_EAST_RESIZE
|
|
945
|
+
];
|
|
946
|
+
[
|
|
947
|
+
e,
|
|
948
|
+
t,
|
|
949
|
+
o,
|
|
950
|
+
n,
|
|
951
|
+
r,
|
|
952
|
+
s,
|
|
953
|
+
d,
|
|
954
|
+
a
|
|
955
|
+
].forEach((g, S) => {
|
|
956
|
+
g.onPointerEnterObserver.add(() => {
|
|
957
|
+
g.setCursor(l[S]);
|
|
958
|
+
}), g.onPointerLeaveObserver.add(() => {
|
|
959
|
+
g.resetCursor();
|
|
960
|
+
}), g.onPointerDownObserver.add((_) => {
|
|
961
|
+
this._widgetEvent(_, l[S]);
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
_widgetMoving(e, t, o) {
|
|
966
|
+
const n = this._scene, r = n.getScrollXYByRelativeCoords(X.FromArray([this._startOffsetX, this._startOffsetY])), { scaleX: s, scaleY: d } = n.getAncestorScale(), a = this._skeleton.getCellPositionByOffset(
|
|
967
|
+
e,
|
|
968
|
+
t,
|
|
969
|
+
s,
|
|
970
|
+
d,
|
|
971
|
+
r
|
|
972
|
+
), { row: l, column: g } = a, { rowHeaderWidth: S, columnHeaderHeight: _ } = this._skeleton;
|
|
973
|
+
let u = this._relativeSelectionPositionRow, h = this._relativeSelectionPositionColumn, f = l, m = g;
|
|
974
|
+
o === L.NORTH_WEST_RESIZE ? (u = l, h = g, f = this._relativeSelectionPositionRow, m = this._relativeSelectionPositionColumn) : o === L.NORTH_RESIZE ? (u = l, h = this._relativeSelectionPositionColumn, f = this._relativeSelectionPositionRow, m = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength) : o === L.NORTH_EAST_RESIZE ? (u = l, h = this._relativeSelectionPositionColumn, f = this._relativeSelectionPositionRow, m = g) : o === L.WEST_RESIZE ? (u = this._relativeSelectionPositionRow, h = g, f = this._relativeSelectionPositionRow + this._relativeSelectionRowLength, m = this._relativeSelectionPositionColumn) : o === L.EAST_RESIZE ? f = this._relativeSelectionPositionRow + this._relativeSelectionRowLength : o === L.SOUTH_WEST_RESIZE ? (u = this._relativeSelectionPositionRow, h = g, f = l, m = this._relativeSelectionPositionColumn) : o === L.SOUTH_RESIZE && (u = this._relativeSelectionPositionRow, h = this._relativeSelectionPositionColumn, f = l, m = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength);
|
|
975
|
+
const {
|
|
976
|
+
startRow: C,
|
|
977
|
+
startColumn: v,
|
|
978
|
+
endRow: w,
|
|
979
|
+
endColumn: p
|
|
980
|
+
} = this._swapPositions(u, h, f, m), E = this._skeleton.getNoMergeCellPositionByIndex(C, v), I = this._skeleton.getNoMergeCellPositionByIndex(w, p), T = (E == null ? void 0 : E.startY) || 0, M = (I == null ? void 0 : I.endY) || 0, k = (E == null ? void 0 : E.startX) || 0, y = (I == null ? void 0 : I.endX) || 0;
|
|
981
|
+
this._targetSelection = {
|
|
982
|
+
startY: T,
|
|
983
|
+
endY: M,
|
|
984
|
+
startX: k,
|
|
985
|
+
endX: y,
|
|
986
|
+
startRow: u,
|
|
987
|
+
endRow: f,
|
|
988
|
+
startColumn: h,
|
|
989
|
+
endColumn: m
|
|
990
|
+
}, this._control.update(this._targetSelection, S, _, this._control.selectionStyle), this._control.clearHighlight(), this._control.selectionScaling$.next(this._targetSelection);
|
|
991
|
+
}
|
|
992
|
+
_widgetEvent(e, t) {
|
|
993
|
+
const { offsetX: o, offsetY: n } = e, r = this._scene, s = r.getRelativeCoord(X.FromArray([o, n])), { x: d, y: a } = s;
|
|
994
|
+
this._startOffsetX = o, this._startOffsetY = n;
|
|
995
|
+
const {
|
|
996
|
+
startRow: l,
|
|
997
|
+
startColumn: g,
|
|
998
|
+
endRow: S,
|
|
999
|
+
endColumn: _
|
|
1000
|
+
} = this._control.model;
|
|
1001
|
+
this._relativeSelectionPositionRow = l, this._relativeSelectionPositionColumn = g, this._relativeSelectionRowLength = S - l, this._relativeSelectionColumnLength = _ - g, t === L.NORTH_WEST_RESIZE ? (this._relativeSelectionPositionRow = S, this._relativeSelectionPositionColumn = _) : t === L.NORTH_RESIZE ? this._relativeSelectionPositionRow = S : t === L.NORTH_EAST_RESIZE ? this._relativeSelectionPositionRow = S : t === L.WEST_RESIZE ? this._relativeSelectionPositionColumn = _ : t === L.SOUTH_WEST_RESIZE && (this._relativeSelectionPositionColumn = _);
|
|
1002
|
+
const u = be.create(r);
|
|
1003
|
+
u.startScroll(d, a), this._scrollTimer = u, r.disableEvent(), this._moveObserver = r.onPointerMoveObserver.add((h) => {
|
|
1004
|
+
const { offsetX: f, offsetY: m } = h, { x: C, y: v } = r.getRelativeCoord(
|
|
1005
|
+
X.FromArray([f, m])
|
|
1006
|
+
);
|
|
1007
|
+
this._widgetMoving(C, v, t), r.setCursor(t), u.scrolling(C, v, () => {
|
|
1008
|
+
this._widgetMoving(C, v, t);
|
|
1009
|
+
});
|
|
1010
|
+
}), this._upObserver = r.onPointerUpObserver.add(() => {
|
|
1011
|
+
var f;
|
|
1012
|
+
const h = this._scene;
|
|
1013
|
+
h.resetCursor(), this._clearObserverEvent(), h.enableEvent(), (f = this._scrollTimer) == null || f.dispose(), this._control.selectionScaled$.next(this._targetSelection);
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
_initialFill() {
|
|
1017
|
+
const { fillControl: e } = this._control;
|
|
1018
|
+
e.onPointerEnterObserver.add(() => {
|
|
1019
|
+
e.setCursor(L.CROSSHAIR);
|
|
1020
|
+
}), e.onPointerLeaveObserver.add(() => {
|
|
1021
|
+
e.resetCursor();
|
|
1022
|
+
}), e.onPointerDownObserver.add(this._fillEvent.bind(this));
|
|
1023
|
+
}
|
|
1024
|
+
_fillMoving(e, t) {
|
|
1025
|
+
var y, O, B;
|
|
1026
|
+
const o = this._scene, n = o.getScrollXY(this._activeViewport), { scaleX: r, scaleY: s } = o.getAncestorScale(), d = this._skeleton.getCellPositionByOffset(
|
|
1027
|
+
e,
|
|
1028
|
+
t,
|
|
1029
|
+
r,
|
|
1030
|
+
s,
|
|
1031
|
+
n
|
|
1032
|
+
), { row: a, column: l } = d, g = o.getRelativeCoord(X.FromArray([e, t])), S = this._skeleton.getRowCount() - 1, _ = this._skeleton.getColumnCount() - 1;
|
|
1033
|
+
let u = this._relativeSelectionPositionRow, h = this._relativeSelectionPositionColumn, f = this._relativeSelectionPositionRow + this._relativeSelectionRowLength, m = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength, C = !1, v = !0;
|
|
1034
|
+
if ((l < h || l > m) && a >= u && a <= f) {
|
|
1035
|
+
const R = this._fillRuler(
|
|
1036
|
+
l,
|
|
1037
|
+
h,
|
|
1038
|
+
m,
|
|
1039
|
+
this._relativeSelectionColumnLength,
|
|
1040
|
+
_
|
|
1041
|
+
);
|
|
1042
|
+
h = R.startRowOrColumn, m = R.endRowOrColumn, C = R.isLighten, v = !1;
|
|
1043
|
+
} else if ((a < u || a > f) && l >= h && l <= m) {
|
|
1044
|
+
const R = this._fillRuler(a, u, f, this._relativeSelectionRowLength, S);
|
|
1045
|
+
u = R.startRowOrColumn, f = R.endRowOrColumn, C = R.isLighten;
|
|
1046
|
+
} else if (Math.abs(this._startOffsetX - g.x - n.x) / 2 > Math.abs(this._startOffsetY - g.y - n.y)) {
|
|
1047
|
+
const R = this._fillRuler(
|
|
1048
|
+
l,
|
|
1049
|
+
h,
|
|
1050
|
+
m,
|
|
1051
|
+
this._relativeSelectionColumnLength,
|
|
1052
|
+
_
|
|
1053
|
+
);
|
|
1054
|
+
h = R.startRowOrColumn, m = R.endRowOrColumn, C = R.isLighten, v = !1;
|
|
1055
|
+
} else {
|
|
1056
|
+
const R = this._fillRuler(a, u, f, this._relativeSelectionRowLength, S);
|
|
1057
|
+
u = R.startRowOrColumn, f = R.endRowOrColumn, C = R.isLighten;
|
|
1058
|
+
}
|
|
1059
|
+
const w = this._skeleton.getNoMergeCellPositionByIndex(u, h), p = this._skeleton.getNoMergeCellPositionByIndex(f, m), E = (w == null ? void 0 : w.startY) || 0, I = (p == null ? void 0 : p.endY) || 0, T = (w == null ? void 0 : w.startX) || 0, M = (p == null ? void 0 : p.endX) || 0;
|
|
1060
|
+
C ? this._controlHandler((R, W) => {
|
|
1061
|
+
const N = new Me(this._fillControlColors[W]).lighten(io).toRgbString();
|
|
1062
|
+
R.setProps({
|
|
1063
|
+
fill: N
|
|
1064
|
+
});
|
|
1065
|
+
}) : this._controlHandler((R, W) => {
|
|
1066
|
+
R.setProps({
|
|
1067
|
+
fill: this._fillControlColors[W]
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
const k = ye / this._getScale();
|
|
1071
|
+
u === f && v === !0 || h === m && v === !1 ? (y = this._helperSelection) == null || y.hide() : ((O = this._helperSelection) == null || O.transformByState({
|
|
1072
|
+
left: T - k / 2,
|
|
1073
|
+
top: E - k / 2,
|
|
1074
|
+
width: M - T,
|
|
1075
|
+
height: I - E
|
|
1076
|
+
}), (B = this._helperSelection) == null || B.show()), this._targetSelection = {
|
|
1077
|
+
startY: E,
|
|
1078
|
+
endY: I,
|
|
1079
|
+
startX: T,
|
|
1080
|
+
endX: M,
|
|
1081
|
+
startRow: u,
|
|
1082
|
+
endRow: f,
|
|
1083
|
+
startColumn: h,
|
|
1084
|
+
endColumn: m
|
|
1085
|
+
}, this._control.selectionFilling$.next(this._targetSelection);
|
|
1086
|
+
}
|
|
1087
|
+
_fillEvent(e) {
|
|
1088
|
+
const { offsetX: t, offsetY: o } = e, n = this._scene, r = n.getRelativeCoord(X.FromArray([t, o])), { x: s, y: d } = r;
|
|
1089
|
+
this._startOffsetX = s, this._startOffsetY = d;
|
|
1090
|
+
const {
|
|
1091
|
+
startRow: a,
|
|
1092
|
+
startColumn: l,
|
|
1093
|
+
endRow: g,
|
|
1094
|
+
endColumn: S
|
|
1095
|
+
} = this._control.model;
|
|
1096
|
+
this._isInMergeState = this._hasMergeInRange(a, l, g, S), this._relativeSelectionPositionRow = a, this._relativeSelectionPositionColumn = l, this._relativeSelectionRowLength = g - a, this._relativeSelectionColumnLength = S - l;
|
|
1097
|
+
const _ = this._control.selectionStyle;
|
|
1098
|
+
let u = _ == null ? void 0 : _.stroke, h = _ == null ? void 0 : _.strokeWidth;
|
|
1099
|
+
const f = Se(this._themeService);
|
|
1100
|
+
u == null && (u = f.stroke), h == null && (h = f.strokeWidth);
|
|
1101
|
+
const m = this._getScale();
|
|
1102
|
+
h /= m;
|
|
1103
|
+
const C = ye / m, v = new Me(u).darken(2).toRgbString();
|
|
1104
|
+
this.isHelperSelection && (this._helperSelection = new P(it, {
|
|
1105
|
+
stroke: v,
|
|
1106
|
+
strokeWidth: h + C / 2
|
|
1107
|
+
}), n.addObject(this._helperSelection)), this._activeViewport = n.getActiveViewportByCoord(X.FromArray([t, o]));
|
|
1108
|
+
const w = n.getViewport(b.VIEW_MAIN), p = be.create(
|
|
1109
|
+
n,
|
|
1110
|
+
this._activeViewport.viewPortKey === b.VIEW_MAIN ? q.ALL : q.NONE
|
|
1111
|
+
);
|
|
1112
|
+
p.startScroll(s, d, w), this._scrollTimer = p, n.disableEvent(), this._controlHandler((E) => {
|
|
1113
|
+
this._fillControlColors.push(E.fill);
|
|
1114
|
+
}), this._moveObserver = n.onPointerMoveObserver.add((E) => {
|
|
1115
|
+
var B;
|
|
1116
|
+
const { offsetX: I, offsetY: T } = E, M = n.getActiveViewportByCoord(X.FromArray([I, T])), { x: k, y } = n.getRelativeCoord(
|
|
1117
|
+
X.FromArray([I, T])
|
|
1118
|
+
);
|
|
1119
|
+
this._fillMoving(k, y), n.setCursor(L.CROSSHAIR);
|
|
1120
|
+
const O = this._targetSelection;
|
|
1121
|
+
if (w && M && ((B = this._activeViewport) == null ? void 0 : B.viewPortKey) !== (M == null ? void 0 : M.viewPortKey)) {
|
|
1122
|
+
let R;
|
|
1123
|
+
O.startRow !== a ? (p.scrollTimerType = q.Y, R = {
|
|
1124
|
+
...O,
|
|
1125
|
+
endRow: O.startRow
|
|
1126
|
+
}) : O.endRow !== g ? (p.scrollTimerType = q.Y, R = {
|
|
1127
|
+
...O,
|
|
1128
|
+
startRow: O.endRow
|
|
1129
|
+
}) : O.startColumn !== l ? (p.scrollTimerType = q.X, R = {
|
|
1130
|
+
...O,
|
|
1131
|
+
endColumn: O.startColumn
|
|
1132
|
+
}) : (p.scrollTimerType = q.X, R = {
|
|
1133
|
+
...O,
|
|
1134
|
+
startColumn: O.endColumn
|
|
1135
|
+
}), this._isSelectionInViewport(R, M) && (w.scrollTo({
|
|
1136
|
+
x: p.scrollTimerType === q.X ? 0 : void 0,
|
|
1137
|
+
y: p.scrollTimerType === q.Y ? 0 : void 0
|
|
1138
|
+
}), this._activeViewport = M);
|
|
1139
|
+
}
|
|
1140
|
+
p.scrolling(k, y, () => {
|
|
1141
|
+
this._fillMoving(k, y);
|
|
1142
|
+
});
|
|
1143
|
+
}), this._upObserver = n.onPointerUpObserver.add(() => {
|
|
1144
|
+
var I, T;
|
|
1145
|
+
(I = this._helperSelection) == null || I.dispose();
|
|
1146
|
+
const E = this._scene;
|
|
1147
|
+
E.resetCursor(), this._clearObserverEvent(), E.enableEvent(), (T = this._scrollTimer) == null || T.dispose(), this._control.refreshSelectionFilled(this._targetSelection), this._isInMergeState = !1, this._controlHandler((M, k) => {
|
|
1148
|
+
M.setProps({
|
|
1149
|
+
fill: this._fillControlColors[k]
|
|
1150
|
+
});
|
|
1151
|
+
}), this._fillControlColors = [];
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
_hasMergeInRange(e, t, o, n) {
|
|
1155
|
+
const r = this._skeleton.mergeData;
|
|
1156
|
+
if (!r)
|
|
1157
|
+
return !1;
|
|
1158
|
+
for (const s of r) {
|
|
1159
|
+
const {
|
|
1160
|
+
startRow: d,
|
|
1161
|
+
startColumn: a,
|
|
1162
|
+
endRow: l,
|
|
1163
|
+
endColumn: g
|
|
1164
|
+
} = s;
|
|
1165
|
+
if (At({
|
|
1166
|
+
left: t,
|
|
1167
|
+
top: e,
|
|
1168
|
+
right: n,
|
|
1169
|
+
bottom: o
|
|
1170
|
+
}, {
|
|
1171
|
+
left: a,
|
|
1172
|
+
top: d,
|
|
1173
|
+
right: g,
|
|
1174
|
+
bottom: l
|
|
1175
|
+
}))
|
|
1176
|
+
return !0;
|
|
1177
|
+
}
|
|
1178
|
+
return !1;
|
|
1179
|
+
}
|
|
1180
|
+
_swapPositions(e, t, o, n) {
|
|
1181
|
+
const r = Math.min(e, o), s = Math.min(t, n), d = Math.max(e, o), a = Math.max(t, n);
|
|
1182
|
+
return {
|
|
1183
|
+
startRow: r,
|
|
1184
|
+
startColumn: s,
|
|
1185
|
+
endRow: d,
|
|
1186
|
+
endColumn: a
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
_controlHandler(e) {
|
|
1190
|
+
const {
|
|
1191
|
+
leftControl: t,
|
|
1192
|
+
rightControl: o,
|
|
1193
|
+
topControl: n,
|
|
1194
|
+
bottomControl: r,
|
|
1195
|
+
backgroundControlTop: s,
|
|
1196
|
+
backgroundControlMiddleLeft: d,
|
|
1197
|
+
backgroundControlMiddleRight: a,
|
|
1198
|
+
backgroundControlBottom: l,
|
|
1199
|
+
fillControl: g
|
|
1200
|
+
} = this._control, S = [
|
|
1201
|
+
t,
|
|
1202
|
+
o,
|
|
1203
|
+
n,
|
|
1204
|
+
r,
|
|
1205
|
+
s,
|
|
1206
|
+
d,
|
|
1207
|
+
a,
|
|
1208
|
+
l,
|
|
1209
|
+
g
|
|
1210
|
+
];
|
|
1211
|
+
for (let _ = 0, u = S.length; _ < u; _++) {
|
|
1212
|
+
const h = S[_];
|
|
1213
|
+
e(h, _);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
_fillRuler(e, t, o, n, r) {
|
|
1217
|
+
let s = !1;
|
|
1218
|
+
if (e < t)
|
|
1219
|
+
if (this._isInMergeState && e < t) {
|
|
1220
|
+
const d = t - e, a = n + 1, l = Math.ceil(d / a);
|
|
1221
|
+
let g = t - l * a;
|
|
1222
|
+
g < 0 && (g = t - (l - 1) * a), t = g;
|
|
1223
|
+
} else
|
|
1224
|
+
t = e;
|
|
1225
|
+
else if (e >= t && e <= o)
|
|
1226
|
+
s = !0, o = e;
|
|
1227
|
+
else if (this._isInMergeState && e > o) {
|
|
1228
|
+
const d = e - o, a = n + 1, l = Math.ceil(d / a);
|
|
1229
|
+
let g = o + l * a;
|
|
1230
|
+
g > r && (g = o + (l - 1) * a), o = g;
|
|
1231
|
+
} else
|
|
1232
|
+
o = e;
|
|
1233
|
+
return {
|
|
1234
|
+
rowOrColumn: e,
|
|
1235
|
+
startRowOrColumn: t,
|
|
1236
|
+
endRowOrColumn: o,
|
|
1237
|
+
isLighten: s
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
_getScale() {
|
|
1241
|
+
const { scaleX: e, scaleY: t } = this._scene.getAncestorScale();
|
|
1242
|
+
return Math.max(e, t);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
var no = Object.defineProperty, ro = Object.getOwnPropertyDescriptor, so = (i, e, t, o) => {
|
|
1246
|
+
for (var n = o > 1 ? void 0 : o ? ro(e, t) : e, r = i.length - 1, s; r >= 0; r--)
|
|
1247
|
+
(s = i[r]) && (n = (o ? s(e, t, n) : s(n)) || n);
|
|
1248
|
+
return o && n && no(e, t, n), n;
|
|
1249
|
+
}, we = (i, e) => (t, o) => e(t, o, i);
|
|
1250
|
+
let rt = class {
|
|
1251
|
+
constructor(i, e, t, o) {
|
|
1252
|
+
c(this, "hasSelection", !1);
|
|
1253
|
+
c(this, "_downObserver");
|
|
1254
|
+
c(this, "_moveObserver");
|
|
1255
|
+
c(this, "_upObserver");
|
|
1256
|
+
c(this, "_controlFillConfig$", new J(null));
|
|
1257
|
+
c(this, "controlFillConfig$", this._controlFillConfig$.asObservable());
|
|
1258
|
+
c(this, "_selectionControls", []);
|
|
1259
|
+
// sheetID:Controls
|
|
1260
|
+
c(this, "_startSelectionRange", {
|
|
1261
|
+
startY: 0,
|
|
1262
|
+
endY: 0,
|
|
1263
|
+
startX: 0,
|
|
1264
|
+
endX: 0,
|
|
1265
|
+
startRow: -1,
|
|
1266
|
+
endRow: -1,
|
|
1267
|
+
startColumn: -1,
|
|
1268
|
+
endColumn: -1
|
|
1269
|
+
});
|
|
1270
|
+
c(this, "_startOffsetX", 0);
|
|
1271
|
+
c(this, "_startOffsetY", 0);
|
|
1272
|
+
c(this, "_scrollTimer");
|
|
1273
|
+
c(this, "_cancelDownObserver");
|
|
1274
|
+
c(this, "_cancelUpObserver");
|
|
1275
|
+
c(this, "_skeleton");
|
|
1276
|
+
c(this, "_scene");
|
|
1277
|
+
// The type of selector determines the type of data range and the highlighting style of the title bar
|
|
1278
|
+
c(this, "_isHeaderHighlight", !0);
|
|
1279
|
+
// If true, the selector will respond to the range of merged cells and automatically extend the selected range. If false, it will ignore the merged cells.
|
|
1280
|
+
c(this, "_isDetectMergedCell", !0);
|
|
1281
|
+
// The style of the selection area, including dashed lines, color, thickness, autofill, other points for modifying the range of the selection area, title highlighting, and so on, can all be customized.
|
|
1282
|
+
c(this, "_selectionStyle");
|
|
1283
|
+
// Whether to enable the selection area. If set to false, the user cannot draw a selection area in the content area by clicking with the mouse.
|
|
1284
|
+
c(this, "_isSelectionEnabled", !0);
|
|
1285
|
+
// Used in the format painter feature, similar to ctrl, it can retain the previous selection.
|
|
1286
|
+
c(this, "_isShowPreviousEnable", 0);
|
|
1287
|
+
//Used in the formula selection feature, a new selection string is added by drawing a box with the mouse.
|
|
1288
|
+
c(this, "_isRemainLastEnable", !0);
|
|
1289
|
+
c(this, "_isSkipRemainLastEnable", !1);
|
|
1290
|
+
c(this, "_selectionMoveEnd$", new J([]));
|
|
1291
|
+
// When the user draws a selection area in the canvas content area, this event is broadcasted when the drawing ends.
|
|
1292
|
+
c(this, "selectionMoveEnd$", this._selectionMoveEnd$.asObservable());
|
|
1293
|
+
c(this, "_selectionMoving$", new ie());
|
|
1294
|
+
/**
|
|
1295
|
+
* Triggered during the drawing of the selection area.
|
|
1296
|
+
*/
|
|
1297
|
+
c(this, "selectionMoving$", this._selectionMoving$.asObservable());
|
|
1298
|
+
c(this, "_selectionMoveStart$", new ie());
|
|
1299
|
+
/**
|
|
1300
|
+
* Triggered during the start draw the selection area.
|
|
1301
|
+
*/
|
|
1302
|
+
c(this, "selectionMoveStart$", this._selectionMoveStart$.asObservable());
|
|
1303
|
+
c(this, "_activeViewport");
|
|
1304
|
+
this._themeService = i, this._shortcutService = e, this._sheetSkeletonManagerService = t, this._injector = o, this._selectionStyle = Se(this._themeService);
|
|
1305
|
+
}
|
|
1306
|
+
enableHeaderHighlight() {
|
|
1307
|
+
this._isHeaderHighlight = !0;
|
|
1308
|
+
}
|
|
1309
|
+
disableHeaderHighlight() {
|
|
1310
|
+
this._isHeaderHighlight = !1;
|
|
1311
|
+
}
|
|
1312
|
+
enableDetectMergedCell() {
|
|
1313
|
+
this._isDetectMergedCell = !0;
|
|
1314
|
+
}
|
|
1315
|
+
disableDetectMergedCell() {
|
|
1316
|
+
this._isDetectMergedCell = !1;
|
|
1317
|
+
}
|
|
1318
|
+
setStyle(i) {
|
|
1319
|
+
this._selectionStyle = i;
|
|
1320
|
+
}
|
|
1321
|
+
resetStyle() {
|
|
1322
|
+
this.setStyle(Se(this._themeService));
|
|
1323
|
+
}
|
|
1324
|
+
enableSelection() {
|
|
1325
|
+
this._isSelectionEnabled = !0;
|
|
1326
|
+
}
|
|
1327
|
+
disableSelection() {
|
|
1328
|
+
this._isSelectionEnabled = !1;
|
|
1329
|
+
}
|
|
1330
|
+
enableShowPrevious() {
|
|
1331
|
+
this._isShowPreviousEnable = !0;
|
|
1332
|
+
}
|
|
1333
|
+
disableShowPrevious() {
|
|
1334
|
+
this._isShowPreviousEnable = !1;
|
|
1335
|
+
}
|
|
1336
|
+
enableRemainLast() {
|
|
1337
|
+
this._isRemainLastEnable = !0;
|
|
1338
|
+
}
|
|
1339
|
+
disableRemainLast() {
|
|
1340
|
+
this._isRemainLastEnable = !1;
|
|
1341
|
+
}
|
|
1342
|
+
enableSkipRemainLast() {
|
|
1343
|
+
this._isSkipRemainLastEnable = !0;
|
|
1344
|
+
}
|
|
1345
|
+
disableSkipRemainLast() {
|
|
1346
|
+
this._isSkipRemainLastEnable = !1;
|
|
1347
|
+
}
|
|
1348
|
+
getViewPort() {
|
|
1349
|
+
return this._activeViewport;
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* add a selection
|
|
1353
|
+
* @param selectionRange
|
|
1354
|
+
* @param curCellRange
|
|
1355
|
+
* @returns
|
|
1356
|
+
*/
|
|
1357
|
+
addControlToCurrentByRangeData(i) {
|
|
1358
|
+
const e = this.getCurrentControls();
|
|
1359
|
+
if (!e)
|
|
1360
|
+
return;
|
|
1361
|
+
const { rangeWithCoord: t, primaryWithCoord: o } = i, n = this._skeleton;
|
|
1362
|
+
let r = i.style;
|
|
1363
|
+
r == null && (r = Se(this._themeService));
|
|
1364
|
+
const s = this._scene;
|
|
1365
|
+
if (s == null || n == null)
|
|
1366
|
+
return;
|
|
1367
|
+
const d = new ot(s, e.length, this._isHeaderHighlight, this._themeService);
|
|
1368
|
+
new nt(d, n, s, this._themeService, this._injector);
|
|
1369
|
+
const { rowHeaderWidth: a, columnHeaderHeight: l } = n;
|
|
1370
|
+
d.update(t, a, l, r, o), this._isHeaderHighlight ? d.enableHeaderHighlight() : d.disableHeaderHighlight(), e.push(d);
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* update selection
|
|
1374
|
+
* @param selectionRange
|
|
1375
|
+
* @param curCellRange
|
|
1376
|
+
* @returns
|
|
1377
|
+
*/
|
|
1378
|
+
updateControlForCurrentByRangeData(i) {
|
|
1379
|
+
const e = this.getCurrentControls();
|
|
1380
|
+
if (!e)
|
|
1381
|
+
return;
|
|
1382
|
+
const t = this._skeleton;
|
|
1383
|
+
if (t == null)
|
|
1384
|
+
return;
|
|
1385
|
+
const { rowHeaderWidth: o, columnHeaderHeight: n } = t;
|
|
1386
|
+
for (let r = 0, s = i.length; r < s; r++) {
|
|
1387
|
+
const { rangeWithCoord: d, primaryWithCoord: a, style: l } = i[r];
|
|
1388
|
+
e[r].update(d, o, n, l, a);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
refreshSelectionMoveStart() {
|
|
1392
|
+
this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
|
|
1393
|
+
}
|
|
1394
|
+
changeRuntime(i, e, t) {
|
|
1395
|
+
this._skeleton = i, this._scene = e, this._activeViewport = t || e.getViewports()[0];
|
|
1396
|
+
}
|
|
1397
|
+
getSelectionDataWithStyle() {
|
|
1398
|
+
return this._selectionControls.map((e) => e.getValue());
|
|
1399
|
+
}
|
|
1400
|
+
getCurrentControls() {
|
|
1401
|
+
return this._selectionControls;
|
|
1402
|
+
}
|
|
1403
|
+
// private _getCurrentControl() {
|
|
1404
|
+
// const controls = this.getCurrentControls();
|
|
1405
|
+
// if (controls && controls.length > 0) {
|
|
1406
|
+
// for (const control of controls) {
|
|
1407
|
+
// const currentCell = control.model.currentCell;
|
|
1408
|
+
// if (currentCell) {
|
|
1409
|
+
// return control;
|
|
1410
|
+
// }
|
|
1411
|
+
// }
|
|
1412
|
+
// }
|
|
1413
|
+
// }
|
|
1414
|
+
_clearSelectionControls() {
|
|
1415
|
+
const i = this.getCurrentControls();
|
|
1416
|
+
if (i.length > 0) {
|
|
1417
|
+
for (const e of i)
|
|
1418
|
+
e.dispose();
|
|
1419
|
+
i.length = 0;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
_getFreeze() {
|
|
1423
|
+
var e;
|
|
1424
|
+
return (e = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : e.skeleton.getWorksheetConfig().freeze;
|
|
1425
|
+
}
|
|
1426
|
+
_getViewportByCell(i, e) {
|
|
1427
|
+
if (!this._scene || i === void 0 || e === void 0)
|
|
1428
|
+
return null;
|
|
1429
|
+
const t = this._getFreeze();
|
|
1430
|
+
if (!t || t.startRow <= 0 && t.startColumn <= 0)
|
|
1431
|
+
return this._scene.getViewport(b.VIEW_MAIN);
|
|
1432
|
+
if (i > t.startRow && e > t.startColumn)
|
|
1433
|
+
return this._scene.getViewport(b.VIEW_MAIN);
|
|
1434
|
+
if (i <= t.startRow && e <= t.startColumn)
|
|
1435
|
+
return this._scene.getViewport(b.VIEW_MAIN_LEFT_TOP);
|
|
1436
|
+
if (i <= t.startRow && e > t.startColumn)
|
|
1437
|
+
return this._scene.getViewport(b.VIEW_MAIN_TOP);
|
|
1438
|
+
if (i > t.startRow && e <= t.startColumn)
|
|
1439
|
+
return this._scene.getViewport(b.VIEW_MAIN_LEFT);
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Returns the list of active ranges in the active sheet or null if there are no active ranges.
|
|
1443
|
+
* If there is a single range selected, this behaves as a getActiveRange() call.
|
|
1444
|
+
*
|
|
1445
|
+
* @returns
|
|
1446
|
+
*/
|
|
1447
|
+
getActiveSelections() {
|
|
1448
|
+
const i = this.getCurrentControls();
|
|
1449
|
+
if (i && i.length > 0)
|
|
1450
|
+
return i == null ? void 0 : i.map((t) => {
|
|
1451
|
+
const o = t.model, n = o.currentCell;
|
|
1452
|
+
let r = null;
|
|
1453
|
+
return n && (r = {
|
|
1454
|
+
actualRow: n.actualRow,
|
|
1455
|
+
actualColumn: n.actualColumn,
|
|
1456
|
+
isMerged: n.isMerged,
|
|
1457
|
+
isMergedMainCell: n.isMergedMainCell,
|
|
1458
|
+
startRow: n.mergeInfo.startRow,
|
|
1459
|
+
startColumn: n.mergeInfo.startColumn,
|
|
1460
|
+
endRow: n.mergeInfo.endRow,
|
|
1461
|
+
endColumn: n.mergeInfo.endColumn
|
|
1462
|
+
}), {
|
|
1463
|
+
range: {
|
|
1464
|
+
startRow: o.startRow,
|
|
1465
|
+
startColumn: o.startColumn,
|
|
1466
|
+
endRow: o.endRow,
|
|
1467
|
+
endColumn: o.endColumn
|
|
1468
|
+
},
|
|
1469
|
+
primary: r
|
|
1470
|
+
};
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Returns the selected range in the active sheet, or null if there is no active range. If multiple ranges are selected this method returns only the last selected range.
|
|
1475
|
+
* TODO: 默认最后一个选区为当前激活选区,或者当前激活单元格所在选区为激活选区
|
|
1476
|
+
* @returns
|
|
1477
|
+
*/
|
|
1478
|
+
getActiveRange() {
|
|
1479
|
+
const i = this.getCurrentControls(), e = i && i[i.length - 1].model;
|
|
1480
|
+
return e && {
|
|
1481
|
+
startRow: e.startRow,
|
|
1482
|
+
startColumn: e.startColumn,
|
|
1483
|
+
endRow: e.endRow,
|
|
1484
|
+
endColumn: e.endColumn
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* get active selection control
|
|
1489
|
+
* @returns
|
|
1490
|
+
*/
|
|
1491
|
+
getActiveSelection() {
|
|
1492
|
+
const i = this.getCurrentControls();
|
|
1493
|
+
return i && i[i.length - 1];
|
|
1494
|
+
}
|
|
1495
|
+
endSelection() {
|
|
1496
|
+
this._endSelection();
|
|
1497
|
+
}
|
|
1498
|
+
reset() {
|
|
1499
|
+
this._clearSelectionControls(), this._moveObserver = null, this._upObserver = null, this._downObserver = null;
|
|
1500
|
+
}
|
|
1501
|
+
resetAndEndSelection() {
|
|
1502
|
+
this.endSelection(), this.reset();
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
*
|
|
1506
|
+
* @param evt component point event
|
|
1507
|
+
* @param style selection style, Styles for user-customized selectors
|
|
1508
|
+
* @param zIndex Stacking order of the selection object
|
|
1509
|
+
* @param rangeType Determines whether the selection is made normally according to the range or by rows and columns
|
|
1510
|
+
* @returns
|
|
1511
|
+
*/
|
|
1512
|
+
eventTrigger(i, e = 0, t = $.NORMAL, o, n = q.ALL) {
|
|
1513
|
+
if (this._isSelectionEnabled === !1)
|
|
1514
|
+
return;
|
|
1515
|
+
const r = this._skeleton, { offsetX: s, offsetY: d } = i, a = this._scene;
|
|
1516
|
+
if (a == null || r == null)
|
|
1517
|
+
return;
|
|
1518
|
+
o != null && (this._activeViewport = o);
|
|
1519
|
+
const l = a.getViewport(b.VIEW_MAIN), g = a.getRelativeCoord(X.FromArray([s, d]));
|
|
1520
|
+
let { x: S, y: _ } = g;
|
|
1521
|
+
this._startOffsetX = S, this._startOffsetY = _;
|
|
1522
|
+
const u = a.getScrollXYByRelativeCoords(g), { scaleX: h, scaleY: f } = a.getAncestorScale();
|
|
1523
|
+
t === $.ROW ? S = 0 : t === $.COLUMN && (_ = 0);
|
|
1524
|
+
const m = this._getSelectedRangeWithMerge(S, _, h, f, u);
|
|
1525
|
+
if (!m)
|
|
1526
|
+
return !1;
|
|
1527
|
+
const { rangeWithCoord: C, primaryWithCoord: v } = m, { startRow: w, startColumn: p, endColumn: E, endRow: I, startY: T, endY: M, startX: k, endX: y } = C, { rowHeaderWidth: O, columnHeaderHeight: B } = r, R = {
|
|
1528
|
+
startColumn: p,
|
|
1529
|
+
startRow: w,
|
|
1530
|
+
endColumn: E,
|
|
1531
|
+
endRow: I,
|
|
1532
|
+
startY: T,
|
|
1533
|
+
endY: M,
|
|
1534
|
+
startX: k,
|
|
1535
|
+
endX: y,
|
|
1536
|
+
rangeType: t
|
|
1537
|
+
};
|
|
1538
|
+
this._startSelectionRange = R;
|
|
1539
|
+
let W = this.getActiveSelection();
|
|
1540
|
+
const N = this.getCurrentControls();
|
|
1541
|
+
if (!N)
|
|
1542
|
+
return !1;
|
|
1543
|
+
for (const x of N) {
|
|
1544
|
+
if (i.button === 2 && x.model.isInclude(R)) {
|
|
1545
|
+
W = x;
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1548
|
+
if (x.model.isEqual(R)) {
|
|
1549
|
+
W = x;
|
|
1550
|
+
break;
|
|
1551
|
+
}
|
|
1552
|
+
i.shiftKey || x.clearHighlight();
|
|
1553
|
+
}
|
|
1554
|
+
if (N.length > 0 && !i.ctrlKey && !i.shiftKey && !this._isShowPreviousEnable && !this._isRemainLastEnable) {
|
|
1555
|
+
for (const x of N)
|
|
1556
|
+
x.dispose();
|
|
1557
|
+
N.length = 0;
|
|
1558
|
+
}
|
|
1559
|
+
const ne = W && W.model.currentCell;
|
|
1560
|
+
if (W && i.shiftKey && ne) {
|
|
1561
|
+
const { actualRow: x, actualColumn: ae, mergeInfo: ee } = ne, te = Math.min(x, R.startRow, ee.startRow), oe = Math.max(x, R.endRow, ee.endRow), ce = Math.min(ae, R.startColumn, ee.startColumn), de = Math.max(ae, R.endColumn, ee.endColumn), A = r.getMergeBounding(te, ce, oe, de), Y = r.getNoMergeCellPositionByIndex(A.startRow, A.startColumn), H = r.getNoMergeCellPositionByIndex(A.endRow, A.endColumn), ge = {
|
|
1562
|
+
startColumn: A.startColumn,
|
|
1563
|
+
startRow: A.startRow,
|
|
1564
|
+
endColumn: A.endColumn,
|
|
1565
|
+
endRow: A.endRow,
|
|
1566
|
+
startY: Y.startY,
|
|
1567
|
+
endY: H.endY,
|
|
1568
|
+
startX: Y.startX,
|
|
1569
|
+
endX: H.endX,
|
|
1570
|
+
rangeType: t
|
|
1571
|
+
}, z = r.getCellByIndex(x, ae);
|
|
1572
|
+
this._startSelectionRange = {
|
|
1573
|
+
startColumn: z.mergeInfo.startColumn,
|
|
1574
|
+
startRow: z.mergeInfo.startRow,
|
|
1575
|
+
endColumn: z.mergeInfo.endColumn,
|
|
1576
|
+
endRow: z.mergeInfo.endRow,
|
|
1577
|
+
startY: z.mergeInfo.startY || 0,
|
|
1578
|
+
endY: z.mergeInfo.endY || 0,
|
|
1579
|
+
startX: z.mergeInfo.startX || 0,
|
|
1580
|
+
endX: z.mergeInfo.endX || 0,
|
|
1581
|
+
rangeType: t
|
|
1582
|
+
}, W.update(
|
|
1583
|
+
ge,
|
|
1584
|
+
O,
|
|
1585
|
+
B,
|
|
1586
|
+
this._selectionStyle,
|
|
1587
|
+
ne
|
|
1588
|
+
);
|
|
1589
|
+
} else
|
|
1590
|
+
this._isRemainLastEnable && W && !i.ctrlKey && !i.shiftKey && !this._isSkipRemainLastEnable ? W.update(
|
|
1591
|
+
R,
|
|
1592
|
+
O,
|
|
1593
|
+
B,
|
|
1594
|
+
this._selectionStyle,
|
|
1595
|
+
v
|
|
1596
|
+
) : (W = new ot(
|
|
1597
|
+
a,
|
|
1598
|
+
N.length + e,
|
|
1599
|
+
this._isHeaderHighlight,
|
|
1600
|
+
this._themeService
|
|
1601
|
+
), new nt(W, r, a, this._themeService, this._injector), W.update(
|
|
1602
|
+
R,
|
|
1603
|
+
O,
|
|
1604
|
+
B,
|
|
1605
|
+
this._selectionStyle,
|
|
1606
|
+
v
|
|
1607
|
+
), N.push(W));
|
|
1608
|
+
this._selectionMoveStart$.next(this.getSelectionDataWithStyle()), this.hasSelection = !0, this._endSelection(), a.disableEvent();
|
|
1609
|
+
const Q = a.getActiveViewportByCoord(X.FromArray([S, _])), re = be.create(this._scene, n);
|
|
1610
|
+
re.startScroll((l == null ? void 0 : l.left) ?? 0, (l == null ? void 0 : l.top) ?? 0, l), this._scrollTimer = re, this._addCancelObserver(), (t === $.ROW || t === $.COLUMN) && this._moving(S, _, W, t);
|
|
1611
|
+
let se = 0, le = 0, U = S, j = _;
|
|
1612
|
+
this._moveObserver = a.onPointerMoveObserver.add((x) => {
|
|
1613
|
+
var z;
|
|
1614
|
+
const { offsetX: ae, offsetY: ee } = x, { x: te, y: oe } = a.getRelativeCoord(
|
|
1615
|
+
X.FromArray([ae, ee])
|
|
1616
|
+
);
|
|
1617
|
+
this._moving(te, oe, W, t);
|
|
1618
|
+
let ce = te, de = oe;
|
|
1619
|
+
const A = this.getActiveSelection(), Y = (z = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : z.skeleton.getWorksheetConfig().freeze, H = A == null ? void 0 : A.model, ge = a.getActiveViewportByCoord(X.FromArray([ae, ee])) ?? this._getViewportByCell(H == null ? void 0 : H.endRow, H == null ? void 0 : H.endColumn);
|
|
1620
|
+
if (Q && ge && l) {
|
|
1621
|
+
const Le = U < l.left && te > l.left || U > l.left && te < l.left, Pe = j < l.top && oe > l.top || j > l.top && oe < l.top;
|
|
1622
|
+
Le && (se += 1), Pe && (le += 1);
|
|
1623
|
+
const Z = Q.viewPortKey, fe = ge.viewPortKey;
|
|
1624
|
+
if (Z === b.VIEW_ROW_TOP)
|
|
1625
|
+
ee < l.top && ((H == null ? void 0 : H.endRow) ?? 0) < ((Y == null ? void 0 : Y.startRow) ?? 0) ? de = l.top : Pe && le % 2 === 1 && l.scrollTo({
|
|
1626
|
+
y: 0
|
|
1627
|
+
});
|
|
1628
|
+
else if (Z === b.VIEW_COLUMN_LEFT)
|
|
1629
|
+
ae < l.left && ((H == null ? void 0 : H.endColumn) ?? 0) < ((Y == null ? void 0 : Y.startColumn) ?? 0) ? ce = l.left : Le && se % 2 === 1 && l.scrollTo({
|
|
1630
|
+
x: 0
|
|
1631
|
+
});
|
|
1632
|
+
else if (Z === fe) {
|
|
1633
|
+
let K = !1, he = !1;
|
|
1634
|
+
Z === b.VIEW_MAIN_LEFT_TOP ? (K = !0, he = !0) : Z === b.VIEW_MAIN_TOP ? he = !0 : Z === b.VIEW_MAIN_LEFT && (K = !0), ((H == null ? void 0 : H.endRow) ?? 0) > ((Y == null ? void 0 : Y.startRow) ?? 0) && (he = !1), ((H == null ? void 0 : H.endColumn) ?? 0) > ((Y == null ? void 0 : Y.startColumn) ?? 0) && (K = !1), K && (ce = l.left), he && (de = l.top);
|
|
1635
|
+
} else {
|
|
1636
|
+
const K = {
|
|
1637
|
+
x: Q.scrollX,
|
|
1638
|
+
y: Q.scrollY
|
|
1639
|
+
}, he = {
|
|
1640
|
+
x: ge.scrollX,
|
|
1641
|
+
y: ge.scrollY
|
|
1642
|
+
}, He = K.x !== he.x && Le && se % 2 === 1, Be = K.y !== he.y && Pe && le % 2 === 1;
|
|
1643
|
+
(He || Be) && (l.scrollTo({
|
|
1644
|
+
x: He ? K.x : void 0,
|
|
1645
|
+
y: Be ? K.y : void 0
|
|
1646
|
+
}), He || (ce = l.left), Be || (de = l.top)), (Z === b.VIEW_MAIN_LEFT_TOP && fe === b.VIEW_MAIN_LEFT || fe === b.VIEW_MAIN_LEFT_TOP && Z === b.VIEW_MAIN_LEFT) && (ce = l.left), (Z === b.VIEW_MAIN_LEFT_TOP && fe === b.VIEW_MAIN_TOP || fe === b.VIEW_MAIN_LEFT_TOP && Z === b.VIEW_MAIN_TOP) && (de = l.top);
|
|
1647
|
+
}
|
|
1648
|
+
U = te, j = oe;
|
|
1649
|
+
}
|
|
1650
|
+
re.scrolling(ce, de, () => {
|
|
1651
|
+
this._moving(te, oe, W, t);
|
|
1652
|
+
});
|
|
1653
|
+
}), this._upObserver = a.onPointerUpObserver.add((x) => {
|
|
1654
|
+
this._endSelection(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()), this._shortcutService.setDisable(!1);
|
|
1655
|
+
}), this._shortcutService.setDisable(!0);
|
|
1656
|
+
}
|
|
1657
|
+
convertSelectionRangeToData(i) {
|
|
1658
|
+
const { range: e, primary: t, style: o } = i;
|
|
1659
|
+
let n = this.convertRangeDataToSelection(e);
|
|
1660
|
+
return n == null && (n = {
|
|
1661
|
+
startRow: -1,
|
|
1662
|
+
startColumn: -1,
|
|
1663
|
+
endRow: -1,
|
|
1664
|
+
endColumn: -1,
|
|
1665
|
+
startY: 0,
|
|
1666
|
+
endY: 0,
|
|
1667
|
+
startX: 0,
|
|
1668
|
+
endX: 0,
|
|
1669
|
+
rangeType: $.NORMAL
|
|
1670
|
+
}), {
|
|
1671
|
+
rangeWithCoord: n,
|
|
1672
|
+
primaryWithCoord: this.convertCellRangeToInfo(t),
|
|
1673
|
+
style: o
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
convertRangeDataToSelection(i) {
|
|
1677
|
+
const { startRow: e, startColumn: t, endRow: o, endColumn: n, rangeType: r } = i, s = this._scene, d = this._skeleton;
|
|
1678
|
+
if (s == null || d == null)
|
|
1679
|
+
return;
|
|
1680
|
+
s.getAncestorScale();
|
|
1681
|
+
const a = d.getNoMergeCellPositionByIndex(e, t), l = d.getNoMergeCellPositionByIndex(o, n);
|
|
1682
|
+
return {
|
|
1683
|
+
startRow: e,
|
|
1684
|
+
startColumn: t,
|
|
1685
|
+
endRow: o,
|
|
1686
|
+
endColumn: n,
|
|
1687
|
+
rangeType: r,
|
|
1688
|
+
startY: (a == null ? void 0 : a.startY) || 0,
|
|
1689
|
+
endY: (l == null ? void 0 : l.endY) || 0,
|
|
1690
|
+
startX: (a == null ? void 0 : a.startX) || 0,
|
|
1691
|
+
endX: (l == null ? void 0 : l.endX) || 0
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
convertCellRangeToInfo(i) {
|
|
1695
|
+
if (i == null)
|
|
1696
|
+
return;
|
|
1697
|
+
const e = this._scene, t = this._skeleton;
|
|
1698
|
+
if (e == null || t == null)
|
|
1699
|
+
return;
|
|
1700
|
+
const { actualRow: o, actualColumn: n, isMerged: r, isMergedMainCell: s, startRow: d, startColumn: a, endRow: l, endColumn: g } = i, S = t.getNoMergeCellPositionByIndex(o, n), _ = t.getNoMergeCellPositionByIndex(d, a), u = t.getNoMergeCellPositionByIndex(l, g);
|
|
1701
|
+
return {
|
|
1702
|
+
actualRow: o,
|
|
1703
|
+
actualColumn: n,
|
|
1704
|
+
isMerged: r,
|
|
1705
|
+
isMergedMainCell: s,
|
|
1706
|
+
startX: S.startX,
|
|
1707
|
+
startY: S.startY,
|
|
1708
|
+
endX: S.endX,
|
|
1709
|
+
endY: S.endY,
|
|
1710
|
+
mergeInfo: {
|
|
1711
|
+
startRow: d,
|
|
1712
|
+
startColumn: a,
|
|
1713
|
+
endRow: l,
|
|
1714
|
+
endColumn: g,
|
|
1715
|
+
startY: (_ == null ? void 0 : _.startY) || 0,
|
|
1716
|
+
endY: (u == null ? void 0 : u.endY) || 0,
|
|
1717
|
+
startX: (_ == null ? void 0 : _.startX) || 0,
|
|
1718
|
+
endX: (u == null ? void 0 : u.endX) || 0
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* When mousedown and mouseup need to go to the coordination and undo stack, when mousemove does not need to go to the coordination and undo stack
|
|
1724
|
+
* @param moveEvt
|
|
1725
|
+
* @param selectionControl
|
|
1726
|
+
* @returns
|
|
1727
|
+
*/
|
|
1728
|
+
_moving(i, e, t, o) {
|
|
1729
|
+
const n = this._skeleton, r = this._scene;
|
|
1730
|
+
if (r == null || n == null)
|
|
1731
|
+
return !1;
|
|
1732
|
+
const { startRow: s, startColumn: d, endRow: a, endColumn: l } = this._startSelectionRange, {
|
|
1733
|
+
startRow: g,
|
|
1734
|
+
endRow: S,
|
|
1735
|
+
startColumn: _,
|
|
1736
|
+
endColumn: u
|
|
1737
|
+
} = (t == null ? void 0 : t.model) || { startRow: -1, endRow: -1, startColumn: -1, endColumn: -1 }, h = r.getViewport(b.VIEW_MAIN), f = this._getViewportByCell(S, u) ?? h, m = r.getScrollXYByRelativeCoords(
|
|
1738
|
+
X.FromArray([this._startOffsetX, this._startOffsetY]),
|
|
1739
|
+
f
|
|
1740
|
+
), { scaleX: C, scaleY: v } = r.getAncestorScale(), { rowHeaderWidth: w, columnHeaderHeight: p } = n;
|
|
1741
|
+
o === $.ROW ? i = 1 / 0 : o === $.COLUMN && (e = 1 / 0);
|
|
1742
|
+
const E = this._getSelectedRangeWithMerge(i, e, C, v, m);
|
|
1743
|
+
if (!E)
|
|
1744
|
+
return !1;
|
|
1745
|
+
const { rangeWithCoord: I, primaryWithCoord: T } = E, {
|
|
1746
|
+
startRow: M,
|
|
1747
|
+
startColumn: k,
|
|
1748
|
+
endColumn: y,
|
|
1749
|
+
endRow: O
|
|
1750
|
+
} = I, B = Math.min(M, s), R = Math.min(k, d), W = Math.max(O, a), N = Math.max(y, l);
|
|
1751
|
+
let ne = {
|
|
1752
|
+
startRow: B,
|
|
1753
|
+
startColumn: R,
|
|
1754
|
+
endRow: W,
|
|
1755
|
+
endColumn: N
|
|
1756
|
+
};
|
|
1757
|
+
if (this._isDetectMergedCell && (ne = n.getSelectionBounding(B, R, W, N)), !ne)
|
|
1758
|
+
return !1;
|
|
1759
|
+
const {
|
|
1760
|
+
startRow: Q,
|
|
1761
|
+
startColumn: re,
|
|
1762
|
+
endRow: se,
|
|
1763
|
+
endColumn: le
|
|
1764
|
+
} = ne, U = n.getNoMergeCellPositionByIndex(Q, re), j = n.getNoMergeCellPositionByIndex(se, le), x = {
|
|
1765
|
+
startColumn: re,
|
|
1766
|
+
startRow: Q,
|
|
1767
|
+
endColumn: le,
|
|
1768
|
+
endRow: se,
|
|
1769
|
+
startY: (U == null ? void 0 : U.startY) || 0,
|
|
1770
|
+
endY: (j == null ? void 0 : j.endY) || 0,
|
|
1771
|
+
startX: (U == null ? void 0 : U.startX) || 0,
|
|
1772
|
+
endX: (j == null ? void 0 : j.endX) || 0
|
|
1773
|
+
};
|
|
1774
|
+
(_ !== re || g !== Q || u !== le || S !== se) && t != null && (t.update(x, w, p), this._selectionMoving$.next(this.getSelectionDataWithStyle()));
|
|
1775
|
+
}
|
|
1776
|
+
_endSelection() {
|
|
1777
|
+
var t, o;
|
|
1778
|
+
const i = this._scene;
|
|
1779
|
+
if (i == null)
|
|
1780
|
+
return;
|
|
1781
|
+
i.onPointerMoveObserver.remove(this._moveObserver), i.onPointerUpObserver.remove(this._upObserver), i.enableEvent(), (t = this._scrollTimer) == null || t.dispose();
|
|
1782
|
+
const e = (o = i.getEngine()) == null ? void 0 : o.activeScene;
|
|
1783
|
+
e == null || e.onPointerDownObserver.remove(this._cancelDownObserver), e == null || e.onPointerUpObserver.remove(this._cancelUpObserver);
|
|
1784
|
+
}
|
|
1785
|
+
_addCancelObserver() {
|
|
1786
|
+
var t;
|
|
1787
|
+
const i = this._scene;
|
|
1788
|
+
if (i == null)
|
|
1789
|
+
return;
|
|
1790
|
+
const e = (t = i.getEngine()) == null ? void 0 : t.activeScene;
|
|
1791
|
+
e == null || e === i || (e.onPointerDownObserver.remove(this._cancelDownObserver), e.onPointerUpObserver.remove(this._cancelUpObserver), this._cancelDownObserver = e.onPointerDownObserver.add((o) => {
|
|
1792
|
+
this._endSelection();
|
|
1793
|
+
}), this._cancelUpObserver = e.onPointerUpObserver.add((o) => {
|
|
1794
|
+
this._endSelection();
|
|
1795
|
+
}));
|
|
1796
|
+
}
|
|
1797
|
+
_getSelectedRangeWithMerge(i, e, t, o, n) {
|
|
1798
|
+
var m;
|
|
1799
|
+
if (this._isDetectMergedCell) {
|
|
1800
|
+
const C = (m = this._skeleton) == null ? void 0 : m.calculateCellIndexByPosition(
|
|
1801
|
+
i,
|
|
1802
|
+
e,
|
|
1803
|
+
t,
|
|
1804
|
+
o,
|
|
1805
|
+
n
|
|
1806
|
+
), v = De(C);
|
|
1807
|
+
return v == null ? void 0 : {
|
|
1808
|
+
primaryWithCoord: C,
|
|
1809
|
+
rangeWithCoord: v
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
const r = this._skeleton;
|
|
1813
|
+
if (r == null)
|
|
1814
|
+
return;
|
|
1815
|
+
const s = r.getCellPositionByOffset(i, e, t, o, n), { row: d, column: a } = s, l = r.getNoMergeCellPositionByIndex(d, a), { startX: g, startY: S, endX: _, endY: u } = l, h = {
|
|
1816
|
+
startY: S,
|
|
1817
|
+
endY: u,
|
|
1818
|
+
startX: g,
|
|
1819
|
+
endX: _,
|
|
1820
|
+
startRow: d,
|
|
1821
|
+
endRow: d,
|
|
1822
|
+
startColumn: a,
|
|
1823
|
+
endColumn: a
|
|
1824
|
+
};
|
|
1825
|
+
return {
|
|
1826
|
+
primaryWithCoord: {
|
|
1827
|
+
actualRow: d,
|
|
1828
|
+
actualColumn: a,
|
|
1829
|
+
isMerged: !1,
|
|
1830
|
+
isMergedMainCell: !1,
|
|
1831
|
+
startY: S,
|
|
1832
|
+
endY: u,
|
|
1833
|
+
startX: g,
|
|
1834
|
+
endX: _,
|
|
1835
|
+
mergeInfo: h
|
|
1836
|
+
},
|
|
1837
|
+
rangeWithCoord: h
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
};
|
|
1841
|
+
rt = so([
|
|
1842
|
+
we(0, F(at)),
|
|
1843
|
+
we(1, zt),
|
|
1844
|
+
we(2, F(me)),
|
|
1845
|
+
we(3, F($e))
|
|
1846
|
+
], rt);
|
|
1847
|
+
const lo = Fe(
|
|
1848
|
+
"deprecated.univer.sheet.selection-render-service"
|
|
1849
|
+
);
|
|
1850
|
+
var ao = Object.defineProperty, co = Object.getOwnPropertyDescriptor, ho = (i, e, t, o) => {
|
|
1851
|
+
for (var n = o > 1 ? void 0 : o ? co(e, t) : e, r = i.length - 1, s; r >= 0; r--)
|
|
1852
|
+
(s = i[r]) && (n = (o ? s(e, t, n) : s(n)) || n);
|
|
1853
|
+
return o && n && ao(e, t, n), n;
|
|
1854
|
+
}, Re = (i, e) => (t, o) => e(t, o, i);
|
|
1855
|
+
const _o = ct("BEFORE_CELL_EDIT"), uo = ct("AFTER_CELL_EDIT");
|
|
1856
|
+
let st = class extends dt {
|
|
1857
|
+
constructor(e, t, o, n) {
|
|
1858
|
+
super();
|
|
1859
|
+
c(this, "_editorUnitId", Ae);
|
|
1860
|
+
c(this, "_isForceKeepVisible", !1);
|
|
1861
|
+
c(this, "_editorIsDirty", !1);
|
|
1862
|
+
c(this, "_visible", {
|
|
1863
|
+
visible: !1,
|
|
1864
|
+
eventType: We.Dblclick
|
|
1865
|
+
});
|
|
1866
|
+
c(this, "_currentEditCell", null);
|
|
1867
|
+
c(this, "_currentEditCellState", null);
|
|
1868
|
+
c(this, "_currentEditCellState$", new J(null));
|
|
1869
|
+
c(this, "currentEditCellState$", this._currentEditCellState$.asObservable());
|
|
1870
|
+
c(this, "_visible$", new J(this._visible));
|
|
1871
|
+
c(this, "visible$", this._visible$.asObservable());
|
|
1872
|
+
c(this, "_afterVisible$", new J(this._visible));
|
|
1873
|
+
c(this, "afterVisible$", this._afterVisible$.asObservable());
|
|
1874
|
+
c(this, "interceptor", new It({
|
|
1875
|
+
BEFORE_CELL_EDIT: _o,
|
|
1876
|
+
AFTER_CELL_EDIT: uo
|
|
1877
|
+
}));
|
|
1878
|
+
this._sheetSkeletonManagerService = e, this._selectionRenderService = t, this._themeService = o, this._currentUniverService = n, this.disposeWithMe(
|
|
1879
|
+
xe(() => {
|
|
1880
|
+
this._currentEditCellState$.complete(), this._currentEditCell = null;
|
|
1881
|
+
})
|
|
1882
|
+
), this.disposeWithMe(
|
|
1883
|
+
xe(
|
|
1884
|
+
this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT, {
|
|
1885
|
+
priority: -1,
|
|
1886
|
+
handler: (r) => r
|
|
1887
|
+
})
|
|
1888
|
+
)
|
|
1889
|
+
), this.disposeWithMe(
|
|
1890
|
+
xe(
|
|
1891
|
+
this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT, {
|
|
1892
|
+
priority: -1,
|
|
1893
|
+
handler: (r) => r
|
|
1894
|
+
})
|
|
1895
|
+
)
|
|
1896
|
+
);
|
|
1897
|
+
}
|
|
1898
|
+
refreshEditCellState() {
|
|
1899
|
+
const e = this.getLatestEditCellState();
|
|
1900
|
+
this._currentEditCellState = e, this._currentEditCellState$.next(e);
|
|
1901
|
+
}
|
|
1902
|
+
setEditCell(e) {
|
|
1903
|
+
this._currentEditCell = e;
|
|
1904
|
+
const t = this.getLatestEditCellState();
|
|
1905
|
+
this._currentEditCellState = t, this._currentEditCellState$.next(t);
|
|
1906
|
+
}
|
|
1907
|
+
getEditCellState() {
|
|
1908
|
+
return this._currentEditCellState;
|
|
1909
|
+
}
|
|
1910
|
+
getLatestEditCellState() {
|
|
1911
|
+
var B, R;
|
|
1912
|
+
const e = this._currentEditCell;
|
|
1913
|
+
if (e == null)
|
|
1914
|
+
return;
|
|
1915
|
+
const t = this._sheetSkeletonManagerService.getCurrent();
|
|
1916
|
+
if (t == null)
|
|
1917
|
+
return;
|
|
1918
|
+
const { skeleton: o } = t, { primary: n, unitId: r, sheetId: s, scene: d, engine: a } = e, { startRow: l, startColumn: g } = n, S = this._selectionRenderService.convertCellRangeToInfo(n);
|
|
1919
|
+
if (S == null)
|
|
1920
|
+
return;
|
|
1921
|
+
const _ = De(S);
|
|
1922
|
+
if (_ == null)
|
|
1923
|
+
return;
|
|
1924
|
+
const u = Dt(a);
|
|
1925
|
+
let { startX: h, startY: f, endX: m, endY: C } = _;
|
|
1926
|
+
const { scaleX: v, scaleY: w } = d.getAncestorScale(), { scaleX: p, scaleY: E } = d.getPrecisionScale(), I = d.getScrollXY(this._selectionRenderService.getViewPort());
|
|
1927
|
+
h = ve(o.convertTransformToOffsetX(h, v, I), p), f = ve(o.convertTransformToOffsetY(f, w, I), E), m = ve(o.convertTransformToOffsetX(m, v, I), p), C = ve(o.convertTransformToOffsetY(C, w, I), E);
|
|
1928
|
+
const T = this._currentUniverService.getCurrentUniverSheetInstance(), M = T.getActiveSheet(), k = {
|
|
1929
|
+
workbook: T,
|
|
1930
|
+
worksheet: M,
|
|
1931
|
+
unitId: T.getUnitId(),
|
|
1932
|
+
subUnitId: M.getSheetId(),
|
|
1933
|
+
row: l,
|
|
1934
|
+
col: g
|
|
1935
|
+
}, y = this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(
|
|
1936
|
+
M.getCell(l, g),
|
|
1937
|
+
k
|
|
1938
|
+
);
|
|
1939
|
+
let O = y && o.getCellDocumentModelWithFormula(y);
|
|
1940
|
+
if ((!O || O.documentModel == null) && (O = o.getBlankCellDocumentModel(y)), (B = O.documentModel) == null || B.setZoomRatio(Math.max(v, w)), (y == null ? void 0 : y.isInArrayFormulaRange) === !0) {
|
|
1941
|
+
const W = (R = O.documentModel) == null ? void 0 : R.getBody();
|
|
1942
|
+
W && (W.textRuns = [
|
|
1943
|
+
{
|
|
1944
|
+
st: 0,
|
|
1945
|
+
ed: W.dataStream.length - 2,
|
|
1946
|
+
ts: {
|
|
1947
|
+
cl: {
|
|
1948
|
+
rgb: this._themeService.getCurrentTheme().textColorSecondary
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
]);
|
|
1953
|
+
}
|
|
1954
|
+
return {
|
|
1955
|
+
position: {
|
|
1956
|
+
startX: h,
|
|
1957
|
+
startY: f,
|
|
1958
|
+
endX: m,
|
|
1959
|
+
endY: C
|
|
1960
|
+
},
|
|
1961
|
+
scaleX: v,
|
|
1962
|
+
scaleY: w,
|
|
1963
|
+
canvasOffset: u,
|
|
1964
|
+
row: l,
|
|
1965
|
+
column: g,
|
|
1966
|
+
unitId: r,
|
|
1967
|
+
sheetId: s,
|
|
1968
|
+
documentLayoutObject: O,
|
|
1969
|
+
editorUnitId: this._editorUnitId,
|
|
1970
|
+
isInArrayFormulaRange: y == null ? void 0 : y.isInArrayFormulaRange
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
getCurrentEditorId() {
|
|
1974
|
+
return this._editorUnitId;
|
|
1975
|
+
}
|
|
1976
|
+
changeVisible(e) {
|
|
1977
|
+
this._visible = e, e.visible && (this._editorIsDirty = !1), this._visible$.next(this._visible), this._afterVisible$.next(this._visible);
|
|
1978
|
+
}
|
|
1979
|
+
isVisible() {
|
|
1980
|
+
return this._visible;
|
|
1981
|
+
}
|
|
1982
|
+
enableForceKeepVisible() {
|
|
1983
|
+
this._isForceKeepVisible = !0;
|
|
1984
|
+
}
|
|
1985
|
+
disableForceKeepVisible() {
|
|
1986
|
+
this._isForceKeepVisible = !1;
|
|
1987
|
+
}
|
|
1988
|
+
isForceKeepVisible() {
|
|
1989
|
+
return this._isForceKeepVisible;
|
|
1990
|
+
}
|
|
1991
|
+
changeEditorDirty(e) {
|
|
1992
|
+
this._editorIsDirty = e;
|
|
1993
|
+
}
|
|
1994
|
+
getEditorDirty() {
|
|
1995
|
+
return this._editorIsDirty;
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
st = ho([
|
|
1999
|
+
Re(0, F(me)),
|
|
2000
|
+
Re(1, lo),
|
|
2001
|
+
Re(2, F(at)),
|
|
2002
|
+
Re(3, Ce)
|
|
2003
|
+
], st);
|
|
2004
|
+
const Ze = Fe("univer.sheet-editor-bridge.service");
|
|
2005
|
+
var ft = { exports: {} }, ke = {};
|
|
2006
|
+
/**
|
|
2007
|
+
* @license React
|
|
2008
|
+
* react-jsx-runtime.production.min.js
|
|
2009
|
+
*
|
|
2010
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2011
|
+
*
|
|
2012
|
+
* This source code is licensed under the MIT license found in the
|
|
2013
|
+
* LICENSE file in the root directory of this source tree.
|
|
2014
|
+
*/
|
|
2015
|
+
var go = Gt, fo = Symbol.for("react.element"), So = Symbol.for("react.fragment"), mo = Object.prototype.hasOwnProperty, Co = go.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, vo = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
2016
|
+
function St(i, e, t) {
|
|
2017
|
+
var o, n = {}, r = null, s = null;
|
|
2018
|
+
t !== void 0 && (r = "" + t), e.key !== void 0 && (r = "" + e.key), e.ref !== void 0 && (s = e.ref);
|
|
2019
|
+
for (o in e)
|
|
2020
|
+
mo.call(e, o) && !vo.hasOwnProperty(o) && (n[o] = e[o]);
|
|
2021
|
+
if (i && i.defaultProps)
|
|
2022
|
+
for (o in e = i.defaultProps, e)
|
|
2023
|
+
n[o] === void 0 && (n[o] = e[o]);
|
|
2024
|
+
return { $$typeof: fo, type: i, key: r, ref: s, props: n, _owner: Co.current };
|
|
2025
|
+
}
|
|
2026
|
+
ke.Fragment = So;
|
|
2027
|
+
ke.jsx = St;
|
|
2028
|
+
ke.jsxs = St;
|
|
2029
|
+
ft.exports = ke;
|
|
2030
|
+
var _e = ft.exports, V = function() {
|
|
2031
|
+
return V = Object.assign || function(i) {
|
|
2032
|
+
for (var e, t = 1, o = arguments.length; t < o; t++) {
|
|
2033
|
+
e = arguments[t];
|
|
2034
|
+
for (var n in e)
|
|
2035
|
+
Object.prototype.hasOwnProperty.call(e, n) && (i[n] = e[n]);
|
|
2036
|
+
}
|
|
2037
|
+
return i;
|
|
2038
|
+
}, V.apply(this, arguments);
|
|
2039
|
+
}, po = function(i, e) {
|
|
2040
|
+
var t = {};
|
|
2041
|
+
for (var o in i)
|
|
2042
|
+
Object.prototype.hasOwnProperty.call(i, o) && e.indexOf(o) < 0 && (t[o] = i[o]);
|
|
2043
|
+
if (i != null && typeof Object.getOwnPropertySymbols == "function")
|
|
2044
|
+
for (var n = 0, o = Object.getOwnPropertySymbols(i); n < o.length; n++)
|
|
2045
|
+
e.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(i, o[n]) && (t[o[n]] = i[o[n]]);
|
|
2046
|
+
return t;
|
|
2047
|
+
}, Ge = Ue(function(i, e) {
|
|
2048
|
+
var t = i.icon, o = i.id, n = i.className, r = i.extend, s = po(i, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(o, " ").concat(n || "").trim(), a = gt("_".concat(Eo()));
|
|
2049
|
+
return mt(t, "".concat(o), { defIds: t.defIds, idSuffix: a.current }, V({ ref: e, className: d }, s), r);
|
|
2050
|
+
});
|
|
2051
|
+
function mt(i, e, t, o, n) {
|
|
2052
|
+
return je(i.tag, V(V({ key: e }, wo(i, t, n)), o), (Ro(i, t).children || []).map(function(r, s) {
|
|
2053
|
+
return mt(r, "".concat(e, "-").concat(i.tag, "-").concat(s), t, void 0, n);
|
|
2054
|
+
}));
|
|
2055
|
+
}
|
|
2056
|
+
function wo(i, e, t) {
|
|
2057
|
+
var o = V({}, i.attrs);
|
|
2058
|
+
t != null && t.colorChannel1 && o.fill === "colorChannel1" && (o.fill = t.colorChannel1);
|
|
2059
|
+
var n = e.defIds;
|
|
2060
|
+
return !n || n.length === 0 || (i.tag === "use" && o["xlink:href"] && (o["xlink:href"] = o["xlink:href"] + e.idSuffix), Object.entries(o).forEach(function(r) {
|
|
2061
|
+
var s = r[0], d = r[1];
|
|
2062
|
+
typeof d == "string" && (o[s] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
2063
|
+
})), o;
|
|
2064
|
+
}
|
|
2065
|
+
function Ro(i, e) {
|
|
2066
|
+
var t, o = e.defIds;
|
|
2067
|
+
return !o || o.length === 0 ? i : i.tag === "defs" && (!((t = i.children) === null || t === void 0) && t.length) ? V(V({}, i), { children: i.children.map(function(n) {
|
|
2068
|
+
return typeof n.attrs.id == "string" && o && o.indexOf(n.attrs.id) > -1 ? V(V({}, n), { attrs: V(V({}, n.attrs), { id: n.attrs.id + e.idSuffix }) }) : n;
|
|
2069
|
+
}) }) : i;
|
|
2070
|
+
}
|
|
2071
|
+
function Eo() {
|
|
2072
|
+
return Math.random().toString(36).substring(2, 8);
|
|
2073
|
+
}
|
|
2074
|
+
Ge.displayName = "UniverIcon";
|
|
2075
|
+
var bo = {
|
|
2076
|
+
tag: "svg",
|
|
2077
|
+
attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" },
|
|
2078
|
+
children: [
|
|
2079
|
+
{
|
|
2080
|
+
tag: "path",
|
|
2081
|
+
attrs: {
|
|
2082
|
+
fill: "currentColor",
|
|
2083
|
+
d: "M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",
|
|
2084
|
+
fillRule: "evenodd",
|
|
2085
|
+
clipRule: "evenodd"
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
]
|
|
2089
|
+
}, Ct = Ue(function(i, e) {
|
|
2090
|
+
return je(Ge, Object.assign({}, i, {
|
|
2091
|
+
id: "check-mark-single",
|
|
2092
|
+
ref: e,
|
|
2093
|
+
icon: bo
|
|
2094
|
+
}));
|
|
2095
|
+
});
|
|
2096
|
+
Ct.displayName = "CheckMarkSingle";
|
|
2097
|
+
const Io = Ct;
|
|
2098
|
+
var Oo = {
|
|
2099
|
+
tag: "svg",
|
|
2100
|
+
attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" },
|
|
2101
|
+
children: [
|
|
2102
|
+
{
|
|
2103
|
+
tag: "path",
|
|
2104
|
+
attrs: {
|
|
2105
|
+
fill: "currentColor",
|
|
2106
|
+
d: "M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
]
|
|
2110
|
+
}, vt = Ue(function(i, e) {
|
|
2111
|
+
return je(Ge, Object.assign({}, i, {
|
|
2112
|
+
id: "close-single",
|
|
2113
|
+
ref: e,
|
|
2114
|
+
icon: Oo
|
|
2115
|
+
}));
|
|
2116
|
+
});
|
|
2117
|
+
vt.displayName = "CloseSingle";
|
|
2118
|
+
const Mo = vt, Ke = {
|
|
2119
|
+
id: "zen-editor.operation.open-zen-editor",
|
|
2120
|
+
type: Ve.OPERATION,
|
|
2121
|
+
handler: (i) => !0
|
|
2122
|
+
};
|
|
2123
|
+
class yo {
|
|
2124
|
+
constructor() {
|
|
2125
|
+
c(this, "_position", null);
|
|
2126
|
+
c(this, "_position$", new J(null));
|
|
2127
|
+
c(this, "position$", this._position$.asObservable());
|
|
2128
|
+
}
|
|
2129
|
+
dispose() {
|
|
2130
|
+
this._position$.complete(), this._position = null;
|
|
2131
|
+
}
|
|
2132
|
+
setPosition(e) {
|
|
2133
|
+
this._position = e, this._refresh(e);
|
|
2134
|
+
}
|
|
2135
|
+
getPosition() {
|
|
2136
|
+
return this._position;
|
|
2137
|
+
}
|
|
2138
|
+
_refresh(e) {
|
|
2139
|
+
this._position$.next(e);
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
const qe = Fe(
|
|
2143
|
+
"univer.sheet-zen-editor-manager.service"
|
|
2144
|
+
);
|
|
2145
|
+
var Wo = Object.defineProperty, To = Object.getOwnPropertyDescriptor, ko = (i, e, t, o) => {
|
|
2146
|
+
for (var n = o > 1 ? void 0 : o ? To(e, t) : e, r = i.length - 1, s; r >= 0; r--)
|
|
2147
|
+
(s = i[r]) && (n = (o ? s(e, t, n) : s(n)) || n);
|
|
2148
|
+
return o && n && Wo(e, t, n), n;
|
|
2149
|
+
}, G = (i, e) => (t, o) => e(t, o, i);
|
|
2150
|
+
const D = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
|
|
2151
|
+
let Ie = class extends Ot {
|
|
2152
|
+
constructor(i, e, t, o, n, r, s, d, a, l) {
|
|
2153
|
+
super(), this._currentUniverService = i, this._zenEditorManagerService = e, this._renderManagerService = t, this._commandService = o, this._zenZoneService = n, this._editorBridgeService = r, this._undoRedoService = s, this._textSelectionManagerService = d, this._docSkeletonManagerService = a, this._docViewModelManagerService = l, this._initialize();
|
|
2154
|
+
}
|
|
2155
|
+
_initialize() {
|
|
2156
|
+
this._syncZenEditorSize(), this._commandExecutedListener(), this._createZenEditorInstance();
|
|
2157
|
+
}
|
|
2158
|
+
_createZenEditorInstance() {
|
|
2159
|
+
const i = {
|
|
2160
|
+
id: D,
|
|
2161
|
+
body: {
|
|
2162
|
+
dataStream: `${yt}`,
|
|
2163
|
+
textRuns: [],
|
|
2164
|
+
paragraphs: [
|
|
2165
|
+
{
|
|
2166
|
+
startIndex: 0
|
|
2167
|
+
}
|
|
2168
|
+
]
|
|
2169
|
+
},
|
|
2170
|
+
documentStyle: {
|
|
2171
|
+
pageSize: {
|
|
2172
|
+
width: 595,
|
|
2173
|
+
height: 842
|
|
2174
|
+
},
|
|
2175
|
+
marginTop: 50,
|
|
2176
|
+
marginBottom: 50,
|
|
2177
|
+
marginRight: 40,
|
|
2178
|
+
marginLeft: 40,
|
|
2179
|
+
renderConfig: {
|
|
2180
|
+
vertexAngle: 0,
|
|
2181
|
+
centerAngle: 0
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2185
|
+
this._currentUniverService.createDoc(i);
|
|
2186
|
+
}
|
|
2187
|
+
// Listen to changes in the size of the zen editor container to set the size of the editor.
|
|
2188
|
+
_syncZenEditorSize() {
|
|
2189
|
+
this._zenEditorManagerService.position$.pipe(Vt(this.dispose$)).subscribe((i) => {
|
|
2190
|
+
var d;
|
|
2191
|
+
if (i == null)
|
|
2192
|
+
return;
|
|
2193
|
+
const e = qt(D, this._renderManagerService), t = this._currentUniverService.getUniverDocInstance(D);
|
|
2194
|
+
if (e == null || t == null)
|
|
2195
|
+
return;
|
|
2196
|
+
const { width: o, height: n } = i, { engine: r } = e, s = (d = this._docSkeletonManagerService.getSkeletonByUnitId(D)) == null ? void 0 : d.skeleton;
|
|
2197
|
+
requestIdleCallback(() => {
|
|
2198
|
+
r.resizeBySize(o, n), this._calculatePagePosition(e), s && this._textSelectionManagerService.refreshSelection();
|
|
2199
|
+
});
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
_handleOpenZenEditor() {
|
|
2203
|
+
this._zenZoneService.open(), this._undoRedoService.clearUndoRedo(D), this._currentUniverService.focusUniverInstance(D), this._currentUniverService.setCurrentUniverDocInstance(D), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
|
|
2204
|
+
visible: !0,
|
|
2205
|
+
eventType: We.PointerDown
|
|
2206
|
+
});
|
|
2207
|
+
const e = this._editorBridgeService.getLatestEditCellState();
|
|
2208
|
+
if (e == null)
|
|
2209
|
+
return;
|
|
2210
|
+
this._editorSyncHandler(e);
|
|
2211
|
+
const t = [
|
|
2212
|
+
{
|
|
2213
|
+
startOffset: 0,
|
|
2214
|
+
endOffset: 0
|
|
2215
|
+
}
|
|
2216
|
+
];
|
|
2217
|
+
this._textSelectionManagerService.replaceTextRanges(t);
|
|
2218
|
+
}
|
|
2219
|
+
_editorSyncHandler(i) {
|
|
2220
|
+
var r, s;
|
|
2221
|
+
const e = (r = i.documentLayoutObject.documentModel) == null ? void 0 : r.getBody(), t = e == null ? void 0 : e.dataStream, o = e == null ? void 0 : e.paragraphs;
|
|
2222
|
+
let n = [];
|
|
2223
|
+
t == null || o == null || ((s = e == null ? void 0 : e.textRuns) != null && s.length && (n = e == null ? void 0 : e.textRuns), this._syncContentAndRender(D, t, o, n));
|
|
2224
|
+
}
|
|
2225
|
+
_syncContentAndRender(i, e, t, o = []) {
|
|
2226
|
+
const n = [
|
|
2227
|
+
D,
|
|
2228
|
+
Ae,
|
|
2229
|
+
Je
|
|
2230
|
+
], r = this._docSkeletonManagerService.getSkeletonByUnitId(i), s = this._currentUniverService.getUniverDocInstance(i), d = this._docViewModelManagerService.getViewModel(i);
|
|
2231
|
+
if (s == null || d == null || r == null)
|
|
2232
|
+
return;
|
|
2233
|
+
const a = s.getBody();
|
|
2234
|
+
a.dataStream = e, a.paragraphs = t, i === Je && (a.textRuns = []), o.length > 0 && (a.textRuns = o), d.reset(s);
|
|
2235
|
+
const { skeleton: l } = r, g = this._getDocObject();
|
|
2236
|
+
g != null && (l.calculate(), n.includes(i) && g.document.makeDirty());
|
|
2237
|
+
}
|
|
2238
|
+
_calculatePagePosition(i) {
|
|
2239
|
+
const { document: e, scene: t } = i, o = t == null ? void 0 : t.getParent(), { width: n, height: r, pageMarginLeft: s, pageMarginTop: d } = e;
|
|
2240
|
+
if (o == null || n === 1 / 0 || r === 1 / 0)
|
|
2241
|
+
return;
|
|
2242
|
+
const { width: a, height: l } = o;
|
|
2243
|
+
let g = 0, S = 0, _ = 0, u = 0, h = 1 / 0;
|
|
2244
|
+
const { scaleX: f, scaleY: m } = t.getAncestorScale();
|
|
2245
|
+
a > (n + s * 2) * f ? (g = a / 2 - n * f / 2, g /= f, _ = (a - s * 2) / f, h = 0) : (g = s, _ = n + s * 2, h = (_ - a / f) / 2), l > r ? (S = l / 2 - r / 2, u = (l - d * 2) / m) : (S = d, u = r + d * 2), t.resize(_, u + 200), e.translate(g, S);
|
|
2246
|
+
const C = t.getViewport(Ht.VIEW_MAIN);
|
|
2247
|
+
if (h !== 1 / 0 && C != null) {
|
|
2248
|
+
const v = C.getBarScroll(h, 0).x;
|
|
2249
|
+
C.scrollTo({
|
|
2250
|
+
x: v
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
return this;
|
|
2254
|
+
}
|
|
2255
|
+
_commandExecutedListener() {
|
|
2256
|
+
const i = [Ke.id];
|
|
2257
|
+
this.disposeWithMe(
|
|
2258
|
+
this._commandService.onCommandExecuted((t) => {
|
|
2259
|
+
i.includes(t.id) && this._handleOpenZenEditor();
|
|
2260
|
+
})
|
|
2261
|
+
);
|
|
2262
|
+
const e = [Bt.id];
|
|
2263
|
+
this.disposeWithMe(
|
|
2264
|
+
this._commandService.onCommandExecuted((t) => {
|
|
2265
|
+
if (e.includes(t.id)) {
|
|
2266
|
+
const o = t.params, { unitId: n } = o;
|
|
2267
|
+
if (n === D) {
|
|
2268
|
+
const r = this._currentUniverService.getUniverDocInstance(n), s = r == null ? void 0 : r.getBody(), d = s == null ? void 0 : s.dataStream, a = s == null ? void 0 : s.paragraphs, l = s == null ? void 0 : s.textRuns;
|
|
2269
|
+
if (d == null || a == null)
|
|
2270
|
+
return;
|
|
2271
|
+
this._syncContentAndRender(Ae, d, a, l);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
})
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2277
|
+
_getDocObject() {
|
|
2278
|
+
return xt(this._currentUniverService, this._renderManagerService);
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
Ie = ko([
|
|
2282
|
+
ht(_t.Steady, Ie),
|
|
2283
|
+
G(0, Ce),
|
|
2284
|
+
G(1, qe),
|
|
2285
|
+
G(2, ut),
|
|
2286
|
+
G(3, ze),
|
|
2287
|
+
G(4, Te),
|
|
2288
|
+
G(5, Ze),
|
|
2289
|
+
G(6, Mt),
|
|
2290
|
+
G(7, F(kt)),
|
|
2291
|
+
G(8, F(Lt)),
|
|
2292
|
+
G(9, F(Pt))
|
|
2293
|
+
], Ie);
|
|
2294
|
+
const pt = {
|
|
2295
|
+
id: "zen-editor.command.cancel-zen-edit",
|
|
2296
|
+
type: Ve.COMMAND,
|
|
2297
|
+
handler: async (i) => {
|
|
2298
|
+
const e = i.get(Te), t = i.get(Ze), o = i.get(Ce);
|
|
2299
|
+
t.isVisible().visible && t.changeVisible({
|
|
2300
|
+
visible: !1,
|
|
2301
|
+
eventType: We.Keyboard,
|
|
2302
|
+
keycode: $t.ESC
|
|
2303
|
+
}), e.close();
|
|
2304
|
+
const r = o.getCurrentUniverSheetInstance();
|
|
2305
|
+
return o.focusUniverInstance(r.getUnitId()), t.refreshEditCellState(), !0;
|
|
2306
|
+
}
|
|
2307
|
+
}, wt = {
|
|
2308
|
+
id: "zen-editor.command.confirm-zen-edit",
|
|
2309
|
+
type: Ve.COMMAND,
|
|
2310
|
+
handler: async (i) => {
|
|
2311
|
+
const e = i.get(Te), t = i.get(Ze), o = i.get(Ce);
|
|
2312
|
+
t.isVisible().visible && t.changeVisible({
|
|
2313
|
+
visible: !1,
|
|
2314
|
+
eventType: We.PointerDown
|
|
2315
|
+
}), e.close();
|
|
2316
|
+
const r = o.getCurrentUniverSheetInstance();
|
|
2317
|
+
return o.focusUniverInstance(r.getUnitId()), t.refreshEditCellState(), !0;
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
function Lo() {
|
|
2321
|
+
return {
|
|
2322
|
+
id: Ke.id,
|
|
2323
|
+
group: Ft.CONTEXT_MENU_OTHERS,
|
|
2324
|
+
type: Ut.BUTTON,
|
|
2325
|
+
title: "rightClick.zenEditor",
|
|
2326
|
+
icon: "AmplifySingle",
|
|
2327
|
+
positions: [jt.CONTEXT_MENU]
|
|
2328
|
+
};
|
|
2329
|
+
}
|
|
2330
|
+
const Po = "univer-zen-editor", Ho = "univer-zen-editor-icon-wrapper", Bo = "univer-zen-editor-icon-container", xo = "univer-zen-editor-icon-success", Xo = "univer-zen-editor-icon-error", Yo = "univer-zen-editor-canvas-container", ue = {
|
|
2331
|
+
zenEditor: Po,
|
|
2332
|
+
zenEditorIconWrapper: Ho,
|
|
2333
|
+
zenEditorIconContainer: Bo,
|
|
2334
|
+
zenEditorIconSuccess: xo,
|
|
2335
|
+
zenEditorIconError: Xo,
|
|
2336
|
+
zenEditorCanvasContainer: Yo
|
|
2337
|
+
}, No = "ZEN_EDITOR_PLUGIN_", Ao = `${No}ZEN_EDITOR_COMPONENT`;
|
|
2338
|
+
function Do() {
|
|
2339
|
+
const i = gt(null), e = Ye(ut), t = Ye(qe), o = Ye(ze);
|
|
2340
|
+
Kt(() => {
|
|
2341
|
+
const s = i.current;
|
|
2342
|
+
if (!s)
|
|
2343
|
+
return;
|
|
2344
|
+
const d = e.currentRender$.subscribe((l) => {
|
|
2345
|
+
var S;
|
|
2346
|
+
if (l !== D)
|
|
2347
|
+
return;
|
|
2348
|
+
const g = (S = e.getRenderById(D)) == null ? void 0 : S.engine;
|
|
2349
|
+
g == null || g.setContainer(s);
|
|
2350
|
+
}), a = new ResizeObserver(() => {
|
|
2351
|
+
const l = s.getBoundingClientRect();
|
|
2352
|
+
t.setPosition(l);
|
|
2353
|
+
});
|
|
2354
|
+
return a.observe(s), () => {
|
|
2355
|
+
a.unobserve(s), d.unsubscribe();
|
|
2356
|
+
};
|
|
2357
|
+
}, []);
|
|
2358
|
+
function n() {
|
|
2359
|
+
o.executeCommand(pt.id);
|
|
2360
|
+
}
|
|
2361
|
+
function r() {
|
|
2362
|
+
o.executeCommand(wt.id);
|
|
2363
|
+
}
|
|
2364
|
+
return /* @__PURE__ */ _e.jsxs("div", { className: ue.zenEditor, children: [
|
|
2365
|
+
/* @__PURE__ */ _e.jsxs("div", { className: ue.zenEditorIconWrapper, children: [
|
|
2366
|
+
/* @__PURE__ */ _e.jsx(
|
|
2367
|
+
"span",
|
|
2368
|
+
{
|
|
2369
|
+
className: Qe(ue.zenEditorIconContainer, ue.zenEditorIconError),
|
|
2370
|
+
onClick: n,
|
|
2371
|
+
children: /* @__PURE__ */ _e.jsx(Mo, { style: { fontSize: "22px" } })
|
|
2372
|
+
}
|
|
2373
|
+
),
|
|
2374
|
+
/* @__PURE__ */ _e.jsx(
|
|
2375
|
+
"span",
|
|
2376
|
+
{
|
|
2377
|
+
className: Qe(ue.zenEditorIconContainer, ue.zenEditorIconSuccess),
|
|
2378
|
+
onClick: r,
|
|
2379
|
+
children: /* @__PURE__ */ _e.jsx(Io, { style: { fontSize: "22px" } })
|
|
2380
|
+
}
|
|
2381
|
+
)
|
|
2382
|
+
] }),
|
|
2383
|
+
/* @__PURE__ */ _e.jsx("div", { className: ue.zenEditorCanvasContainer, ref: i })
|
|
2384
|
+
] });
|
|
2385
|
+
}
|
|
2386
|
+
var Vo = Object.defineProperty, zo = Object.getOwnPropertyDescriptor, $o = (i, e, t, o) => {
|
|
2387
|
+
for (var n = o > 1 ? void 0 : o ? zo(e, t) : e, r = i.length - 1, s; r >= 0; r--)
|
|
2388
|
+
(s = i[r]) && (n = (o ? s(e, t, n) : s(n)) || n);
|
|
2389
|
+
return o && n && Vo(e, t, n), n;
|
|
2390
|
+
}, Ee = (i, e) => (t, o) => e(t, o, i);
|
|
2391
|
+
let Oe = class extends dt {
|
|
2392
|
+
constructor(i, e, t, o) {
|
|
2393
|
+
super(), this._injector = i, this._zenZoneService = e, this._commandService = t, this._menuService = o, this._initialize();
|
|
2394
|
+
}
|
|
2395
|
+
_initialize() {
|
|
2396
|
+
this._initCustomComponents(), this._initCommands(), this._initMenus();
|
|
2397
|
+
}
|
|
2398
|
+
_initCustomComponents() {
|
|
2399
|
+
this.disposeWithMe(this._zenZoneService.set(Ao, Do));
|
|
2400
|
+
}
|
|
2401
|
+
_initCommands() {
|
|
2402
|
+
[Ke, pt, wt].forEach((i) => {
|
|
2403
|
+
this.disposeWithMe(this._commandService.registerCommand(i));
|
|
2404
|
+
});
|
|
2405
|
+
}
|
|
2406
|
+
_initMenus() {
|
|
2407
|
+
[
|
|
2408
|
+
// context menu
|
|
2409
|
+
Lo
|
|
2410
|
+
].forEach((i) => {
|
|
2411
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)));
|
|
2412
|
+
});
|
|
2413
|
+
}
|
|
2414
|
+
};
|
|
2415
|
+
Oe = $o([
|
|
2416
|
+
ht(_t.Ready, Oe),
|
|
2417
|
+
Ee(0, F($e)),
|
|
2418
|
+
Ee(1, Te),
|
|
2419
|
+
Ee(2, ze),
|
|
2420
|
+
Ee(3, Zt)
|
|
2421
|
+
], Oe);
|
|
2422
|
+
var Fo = Object.defineProperty, Uo = Object.getOwnPropertyDescriptor, jo = (i, e, t, o) => {
|
|
2423
|
+
for (var n = o > 1 ? void 0 : o ? Uo(e, t) : e, r = i.length - 1, s; r >= 0; r--)
|
|
2424
|
+
(s = i[r]) && (n = (o ? s(e, t, n) : s(n)) || n);
|
|
2425
|
+
return o && n && Fo(e, t, n), n;
|
|
2426
|
+
}, Zo = (i, e) => (t, o) => e(t, o, i), Ne;
|
|
2427
|
+
let lt = (Ne = class extends Wt {
|
|
2428
|
+
constructor(i, e) {
|
|
2429
|
+
super("zen-editor"), this._injector = e, this._initializeDependencies(this._injector);
|
|
2430
|
+
}
|
|
2431
|
+
_initializeDependencies(i) {
|
|
2432
|
+
[
|
|
2433
|
+
[Oe],
|
|
2434
|
+
[Ie],
|
|
2435
|
+
[qe, { useClass: yo }]
|
|
2436
|
+
].forEach((t) => i.add(t));
|
|
2437
|
+
}
|
|
2438
|
+
onRendered() {
|
|
2439
|
+
}
|
|
2440
|
+
onDestroy() {
|
|
2441
|
+
}
|
|
2442
|
+
}, c(Ne, "type", Tt.Doc), Ne);
|
|
2443
|
+
lt = jo([
|
|
2444
|
+
Zo(1, F($e))
|
|
2445
|
+
], lt);
|
|
2446
|
+
export {
|
|
2447
|
+
lt as UniverSheetsZenEditorPlugin
|
|
2448
|
+
};
|