@univerjs/sheets-ui 0.6.6 → 0.6.7-nightly.202503261607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +33 -33
- package/lib/es/index.js +5524 -5497
- package/lib/facade.js +1165 -0
- package/lib/index.js +24231 -0
- package/lib/locale/en-US.js +456 -0
- package/lib/locale/fa-IR.js +456 -0
- package/lib/locale/fr-FR.js +456 -0
- package/lib/locale/ru-RU.js +454 -0
- package/lib/locale/vi-VN.js +454 -0
- package/lib/locale/zh-CN.js +455 -0
- package/lib/locale/zh-TW.js +455 -0
- package/lib/types/controllers/auto-height.controller.d.ts +4 -10
- package/lib/types/controllers/config.schema.d.ts +2 -0
- package/lib/types/controllers/editor/editing.render-controller.d.ts +1 -0
- package/lib/types/controllers/render-controllers/sheet.render-controller.d.ts +3 -2
- package/lib/types/services/auto-fill/type.d.ts +1 -1
- package/lib/types/services/hover-manager.service.d.ts +12 -3
- package/lib/types/services/utils/doc-skeleton-util.d.ts +1 -0
- package/lib/types/views/formula-bar/FormulaBar.d.ts +1 -0
- package/lib/umd/index.js +33 -33
- package/package.json +16 -16
- package/LICENSE +0 -176
package/lib/facade.js
ADDED
|
@@ -0,0 +1,1165 @@
|
|
|
1
|
+
import { ICommandService as I, CanceledError as E, IUniverInstanceService as $, RichTextValue as j, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as D, LifecycleService as ie, DisposableCollection as B, LifecycleStages as O, UniverInstanceType as oe, ILogService as U, toDisposable as C, awaitTime as se, InterceptorEffectEnum as ae, generateRandomId as ce } from "@univerjs/core";
|
|
2
|
+
import { FUniver as q, FEventName as de } from "@univerjs/core/facade";
|
|
3
|
+
import { RichTextEditingMutation as he } from "@univerjs/docs";
|
|
4
|
+
import { IRenderManagerService as S, DeviceInputEventType as z, SHEET_VIEWPORT_KEY as le, sheetContentViewportKeys as ge } from "@univerjs/engine-render";
|
|
5
|
+
import { SheetsSelectionsService as ue, COMMAND_LISTENER_SKELETON_CHANGE as ve, getSkeletonChangedEffectedRange as Se, SetWorksheetRowIsAutoHeightCommand as Ce, InterceptCellContentPriority as me, SheetInterceptorService as be, INTERCEPTOR_POINT as Ee } from "@univerjs/sheets";
|
|
6
|
+
import { SetCellEditVisibleOperation as f, IEditorBridgeService as R, SetZoomRatioCommand as A, HoverManagerService as p, DragManagerService as M, SheetScrollManagerService as x, SheetPasteShortKeyCommand as L, ISheetClipboardService as Q, SheetSkeletonManagerService as _, SHEET_VIEW_KEY as w, ISheetSelectionRenderService as y, SheetsScrollRenderController as pe, SetWorksheetColAutoWidthCommand as we, SetColumnHeaderHeightCommand as fe, SetRowHeaderWidthCommand as ke, SheetCanvasPopManagerService as N, CellAlertManagerService as Ie, IMarkSelectionService as _e } from "@univerjs/sheets-ui";
|
|
7
|
+
import { FSheetHooks as W, FWorkbook as ee, FWorksheet as te, FPermission as re, FRange as ne } from "@univerjs/sheets/facade";
|
|
8
|
+
import { KeyCode as T, CutCommand as F, CopyCommand as V, PasteCommand as Z, IClipboardInterfaceService as Pe, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as K, HTML_CLIPBOARD_MIME_TYPE as Y, supportClipboardAPI as X, ISidebarService as Re, IDialogService as He, ComponentManager as J } from "@univerjs/ui";
|
|
9
|
+
import { filter as u, combineLatest as Me } from "rxjs";
|
|
10
|
+
class ye extends q {
|
|
11
|
+
// eslint-disable-next-line max-lines-per-function
|
|
12
|
+
_initSheetUIEvent(e) {
|
|
13
|
+
const r = e.get(I);
|
|
14
|
+
this.registerEventHandler(
|
|
15
|
+
this.Event.BeforeSheetEditStart,
|
|
16
|
+
() => r.beforeCommandExecuted((t) => {
|
|
17
|
+
if (t.id !== f.id) return;
|
|
18
|
+
const i = this.getActiveSheet();
|
|
19
|
+
if (!i) return;
|
|
20
|
+
const { workbook: o, worksheet: a } = i, d = e.get(R), l = t.params, { visible: h, keycode: g, eventType: s } = l, n = d.getEditLocation();
|
|
21
|
+
if (h) {
|
|
22
|
+
const c = {
|
|
23
|
+
row: n.row,
|
|
24
|
+
column: n.column,
|
|
25
|
+
eventType: s,
|
|
26
|
+
keycode: g,
|
|
27
|
+
workbook: o,
|
|
28
|
+
worksheet: a,
|
|
29
|
+
isZenEditor: !1
|
|
30
|
+
};
|
|
31
|
+
if (this.fireEvent(this.Event.BeforeSheetEditStart, c), c.cancel)
|
|
32
|
+
throw new E();
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
), this.registerEventHandler(
|
|
36
|
+
this.Event.BeforeSheetEditEnd,
|
|
37
|
+
() => r.beforeCommandExecuted((t) => {
|
|
38
|
+
if (t.id !== f.id) return;
|
|
39
|
+
const i = this.getActiveSheet();
|
|
40
|
+
if (!i) return;
|
|
41
|
+
const { workbook: o, worksheet: a } = i, d = e.get(R), l = e.get($), h = t.params, { visible: g, keycode: s, eventType: n } = h, c = d.getEditLocation();
|
|
42
|
+
if (!g) {
|
|
43
|
+
const P = {
|
|
44
|
+
row: c.row,
|
|
45
|
+
column: c.column,
|
|
46
|
+
eventType: n,
|
|
47
|
+
keycode: s,
|
|
48
|
+
workbook: o,
|
|
49
|
+
worksheet: a,
|
|
50
|
+
isZenEditor: !1,
|
|
51
|
+
value: j.create(l.getUnit(D).getSnapshot()),
|
|
52
|
+
isConfirm: s !== T.ESC
|
|
53
|
+
};
|
|
54
|
+
if (this.fireEvent(this.Event.BeforeSheetEditEnd, P), P.cancel)
|
|
55
|
+
throw new E();
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
), this.registerEventHandler(
|
|
59
|
+
this.Event.SheetEditStarted,
|
|
60
|
+
() => r.onCommandExecuted((t) => {
|
|
61
|
+
if (t.id !== f.id) return;
|
|
62
|
+
const i = this.getCommandSheetTarget(t);
|
|
63
|
+
if (!i) return;
|
|
64
|
+
const { workbook: o, worksheet: a } = i, d = e.get(R), l = t.params, { visible: h, keycode: g, eventType: s } = l, n = d.getEditLocation();
|
|
65
|
+
if (h) {
|
|
66
|
+
const c = {
|
|
67
|
+
row: n.row,
|
|
68
|
+
column: n.column,
|
|
69
|
+
eventType: s,
|
|
70
|
+
keycode: g,
|
|
71
|
+
workbook: o,
|
|
72
|
+
worksheet: a,
|
|
73
|
+
isZenEditor: !1
|
|
74
|
+
};
|
|
75
|
+
this.fireEvent(this.Event.SheetEditStarted, c);
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
), this.registerEventHandler(
|
|
79
|
+
this.Event.SheetEditEnded,
|
|
80
|
+
() => r.onCommandExecuted((t) => {
|
|
81
|
+
if (t.id !== f.id) return;
|
|
82
|
+
const i = this.getCommandSheetTarget(t);
|
|
83
|
+
if (!i) return;
|
|
84
|
+
const { workbook: o, worksheet: a } = i, d = e.get(R), l = t.params, { visible: h, keycode: g, eventType: s } = l, n = d.getEditLocation();
|
|
85
|
+
if (!h) {
|
|
86
|
+
const c = {
|
|
87
|
+
row: n.row,
|
|
88
|
+
column: n.column,
|
|
89
|
+
eventType: s,
|
|
90
|
+
keycode: g,
|
|
91
|
+
workbook: o,
|
|
92
|
+
worksheet: a,
|
|
93
|
+
isZenEditor: !1,
|
|
94
|
+
isConfirm: g !== T.ESC
|
|
95
|
+
};
|
|
96
|
+
this.fireEvent(this.Event.SheetEditEnded, c);
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
), this.registerEventHandler(
|
|
100
|
+
this.Event.SheetEditChanging,
|
|
101
|
+
() => r.onCommandExecuted((t) => {
|
|
102
|
+
if (t.id !== he.id) return;
|
|
103
|
+
const i = this.getActiveSheet();
|
|
104
|
+
if (!i) return;
|
|
105
|
+
const { workbook: o, worksheet: a } = i, d = e.get(R), l = e.get($), h = t.params;
|
|
106
|
+
if (!d.isVisible().visible) return;
|
|
107
|
+
const { unitId: g } = h;
|
|
108
|
+
if (g === D) {
|
|
109
|
+
const { row: s, column: n } = d.getEditLocation(), c = {
|
|
110
|
+
workbook: o,
|
|
111
|
+
worksheet: a,
|
|
112
|
+
row: s,
|
|
113
|
+
column: n,
|
|
114
|
+
value: j.create(l.getUnit(D).getSnapshot()),
|
|
115
|
+
isZenEditor: !1
|
|
116
|
+
};
|
|
117
|
+
this.fireEvent(this.Event.SheetEditChanging, c);
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
), this.registerEventHandler(
|
|
121
|
+
this.Event.BeforeSheetZoomChange,
|
|
122
|
+
() => r.beforeCommandExecuted((t) => {
|
|
123
|
+
if (t.id !== A.id) return;
|
|
124
|
+
const i = this.getCommandSheetTarget(t);
|
|
125
|
+
if (!i) return;
|
|
126
|
+
const { workbook: o, worksheet: a } = i, d = {
|
|
127
|
+
zoom: t.params.zoomRatio,
|
|
128
|
+
workbook: o,
|
|
129
|
+
worksheet: a
|
|
130
|
+
};
|
|
131
|
+
if (this.fireEvent(this.Event.BeforeSheetZoomChange, d), d.cancel)
|
|
132
|
+
throw new E();
|
|
133
|
+
})
|
|
134
|
+
), this.registerEventHandler(
|
|
135
|
+
this.Event.SheetZoomChanged,
|
|
136
|
+
() => r.onCommandExecuted((t) => {
|
|
137
|
+
if (t.id !== A.id) return;
|
|
138
|
+
const i = this.getCommandSheetTarget(t);
|
|
139
|
+
if (!i) return;
|
|
140
|
+
const { workbook: o, worksheet: a } = i;
|
|
141
|
+
this.fireEvent(this.Event.SheetZoomChanged, {
|
|
142
|
+
zoom: a.getZoom(),
|
|
143
|
+
workbook: o,
|
|
144
|
+
worksheet: a
|
|
145
|
+
});
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
// eslint-disable-next-line max-lines-per-function
|
|
150
|
+
_initObserverListener(e) {
|
|
151
|
+
const r = e.get(S), t = e.get(ie), i = new B();
|
|
152
|
+
this.disposeWithMe(t.lifecycle$.subscribe((l) => {
|
|
153
|
+
if (l !== O.Rendered) return;
|
|
154
|
+
i.dispose();
|
|
155
|
+
const h = e.get(p), g = e.get(M);
|
|
156
|
+
h && (this.registerEventHandler(
|
|
157
|
+
this.Event.CellClicked,
|
|
158
|
+
() => {
|
|
159
|
+
var s;
|
|
160
|
+
return (s = h.currentClickedCell$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
161
|
+
const c = this.getSheetTarget(n.location.unitId, n.location.subUnitId);
|
|
162
|
+
c && this.fireEvent(this.Event.CellClicked, {
|
|
163
|
+
...c,
|
|
164
|
+
...n,
|
|
165
|
+
row: n.location.row,
|
|
166
|
+
column: n.location.col
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
), this.registerEventHandler(
|
|
171
|
+
this.Event.CellHover,
|
|
172
|
+
() => {
|
|
173
|
+
var s;
|
|
174
|
+
return (s = h.currentRichText$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
175
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
176
|
+
c && this.fireEvent(this.Event.CellHover, {
|
|
177
|
+
...c,
|
|
178
|
+
...n,
|
|
179
|
+
row: n.row,
|
|
180
|
+
column: n.col
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
), this.registerEventHandler(
|
|
185
|
+
this.Event.CellPointerDown,
|
|
186
|
+
() => {
|
|
187
|
+
var s;
|
|
188
|
+
return (s = h.currentPointerDownCell$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
189
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
190
|
+
c && this.fireEvent(this.Event.CellPointerDown, {
|
|
191
|
+
...c,
|
|
192
|
+
...n,
|
|
193
|
+
row: n.row,
|
|
194
|
+
column: n.col
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
), this.registerEventHandler(
|
|
199
|
+
this.Event.CellPointerUp,
|
|
200
|
+
() => {
|
|
201
|
+
var s;
|
|
202
|
+
return (s = h.currentPointerUpCell$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
203
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
204
|
+
c && this.fireEvent(this.Event.CellPointerUp, {
|
|
205
|
+
...c,
|
|
206
|
+
...n,
|
|
207
|
+
row: n.row,
|
|
208
|
+
column: n.col
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
), this.registerEventHandler(
|
|
213
|
+
this.Event.CellPointerMove,
|
|
214
|
+
() => {
|
|
215
|
+
var s;
|
|
216
|
+
return (s = h.currentCellPosWithEvent$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
217
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
218
|
+
c && this.fireEvent(this.Event.CellPointerMove, {
|
|
219
|
+
...c,
|
|
220
|
+
...n,
|
|
221
|
+
row: n.row,
|
|
222
|
+
column: n.col
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
), this.registerEventHandler(
|
|
227
|
+
this.Event.DragOver,
|
|
228
|
+
() => {
|
|
229
|
+
var s;
|
|
230
|
+
return (s = g.currentCell$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
231
|
+
const c = this.getSheetTarget(n.location.unitId, n.location.subUnitId);
|
|
232
|
+
c && this.fireEvent(this.Event.DragOver, {
|
|
233
|
+
...c,
|
|
234
|
+
...n,
|
|
235
|
+
row: n.location.row,
|
|
236
|
+
column: n.location.col
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
), this.registerEventHandler(
|
|
241
|
+
this.Event.Drop,
|
|
242
|
+
() => {
|
|
243
|
+
var s;
|
|
244
|
+
return (s = g.endCell$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
245
|
+
const c = this.getSheetTarget(n.location.unitId, n.location.subUnitId);
|
|
246
|
+
c && this.fireEvent(this.Event.Drop, {
|
|
247
|
+
...c,
|
|
248
|
+
...n,
|
|
249
|
+
row: n.location.row,
|
|
250
|
+
column: n.location.col
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
), this.registerEventHandler(
|
|
255
|
+
this.Event.RowHeaderClick,
|
|
256
|
+
() => {
|
|
257
|
+
var s;
|
|
258
|
+
return (s = h.currentRowHeaderClick$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
259
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
260
|
+
c && this.fireEvent(this.Event.RowHeaderClick, {
|
|
261
|
+
...c,
|
|
262
|
+
row: n.index
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
), this.registerEventHandler(
|
|
267
|
+
this.Event.RowHeaderPointerDown,
|
|
268
|
+
() => {
|
|
269
|
+
var s;
|
|
270
|
+
return (s = h.currentRowHeaderPointerDown$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
271
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
272
|
+
c && this.fireEvent(this.Event.RowHeaderPointerDown, {
|
|
273
|
+
...c,
|
|
274
|
+
row: n.index
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
), this.registerEventHandler(
|
|
279
|
+
this.Event.RowHeaderPointerUp,
|
|
280
|
+
() => {
|
|
281
|
+
var s;
|
|
282
|
+
return (s = h.currentRowHeaderPointerUp$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
283
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
284
|
+
c && this.fireEvent(this.Event.RowHeaderPointerUp, {
|
|
285
|
+
...c,
|
|
286
|
+
row: n.index
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
), this.registerEventHandler(
|
|
291
|
+
this.Event.RowHeaderHover,
|
|
292
|
+
() => {
|
|
293
|
+
var s;
|
|
294
|
+
return (s = h.currentHoveredRowHeader$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
295
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
296
|
+
c && this.fireEvent(this.Event.RowHeaderHover, {
|
|
297
|
+
...c,
|
|
298
|
+
row: n.index
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
), this.registerEventHandler(
|
|
303
|
+
this.Event.ColumnHeaderClick,
|
|
304
|
+
() => {
|
|
305
|
+
var s;
|
|
306
|
+
return (s = h.currentColHeaderClick$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
307
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
308
|
+
c && this.fireEvent(this.Event.ColumnHeaderClick, {
|
|
309
|
+
...c,
|
|
310
|
+
column: n.index
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
), this.registerEventHandler(
|
|
315
|
+
this.Event.ColumnHeaderPointerDown,
|
|
316
|
+
() => {
|
|
317
|
+
var s;
|
|
318
|
+
return (s = h.currentColHeaderPointerDown$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
319
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
320
|
+
c && this.fireEvent(this.Event.ColumnHeaderPointerDown, {
|
|
321
|
+
...c,
|
|
322
|
+
column: n.index
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
), this.registerEventHandler(
|
|
327
|
+
this.Event.ColumnHeaderPointerUp,
|
|
328
|
+
() => {
|
|
329
|
+
var s;
|
|
330
|
+
return (s = h.currentColHeaderPointerUp$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
331
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
332
|
+
c && this.fireEvent(this.Event.ColumnHeaderPointerUp, {
|
|
333
|
+
...c,
|
|
334
|
+
column: n.index
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
), this.registerEventHandler(
|
|
339
|
+
this.Event.ColumnHeaderHover,
|
|
340
|
+
() => {
|
|
341
|
+
var s;
|
|
342
|
+
return (s = h.currentHoveredColHeader$) == null ? void 0 : s.pipe(u((n) => !!n)).subscribe((n) => {
|
|
343
|
+
const c = this.getSheetTarget(n.unitId, n.subUnitId);
|
|
344
|
+
c && this.fireEvent(this.Event.ColumnHeaderHover, {
|
|
345
|
+
...c,
|
|
346
|
+
column: n.index
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
));
|
|
351
|
+
})), this.disposeWithMe(i);
|
|
352
|
+
const o = /* @__PURE__ */ new Map();
|
|
353
|
+
let a;
|
|
354
|
+
const d = Me([
|
|
355
|
+
r.created$,
|
|
356
|
+
t.lifecycle$
|
|
357
|
+
]);
|
|
358
|
+
this.disposeWithMe(d.subscribe(([l, h]) => {
|
|
359
|
+
var P;
|
|
360
|
+
if (l.type === oe.UNIVER_SHEET && (a = l), h <= O.Rendered || !a) return;
|
|
361
|
+
const g = new B(), s = this.getWorkbook(a.unitId);
|
|
362
|
+
if (!s) return;
|
|
363
|
+
o.get(a.unitId) && ((P = o.get(a.unitId)) == null || P.dispose()), o.set(a.unitId, g);
|
|
364
|
+
const n = a.with(x), c = a.with(ue);
|
|
365
|
+
g.add(this.registerEventHandler(
|
|
366
|
+
this.Event.Scroll,
|
|
367
|
+
() => n.validViewportScrollInfo$.subscribe((v) => {
|
|
368
|
+
v && this.fireEvent(this.Event.Scroll, {
|
|
369
|
+
workbook: s,
|
|
370
|
+
worksheet: s.getActiveSheet(),
|
|
371
|
+
...v
|
|
372
|
+
});
|
|
373
|
+
})
|
|
374
|
+
)), g.add(this.registerEventHandler(
|
|
375
|
+
this.Event.SelectionMoveStart,
|
|
376
|
+
() => c.selectionMoveStart$.subscribe((v) => {
|
|
377
|
+
var m;
|
|
378
|
+
this.fireEvent(this.Event.SelectionMoveStart, {
|
|
379
|
+
workbook: s,
|
|
380
|
+
worksheet: s.getActiveSheet(),
|
|
381
|
+
selections: (m = v == null ? void 0 : v.map((k) => k.range)) != null ? m : []
|
|
382
|
+
});
|
|
383
|
+
})
|
|
384
|
+
)), g.add(this.registerEventHandler(
|
|
385
|
+
this.Event.SelectionMoving,
|
|
386
|
+
() => c.selectionMoving$.subscribe((v) => {
|
|
387
|
+
var m;
|
|
388
|
+
this.fireEvent(this.Event.SelectionMoving, {
|
|
389
|
+
workbook: s,
|
|
390
|
+
worksheet: s.getActiveSheet(),
|
|
391
|
+
selections: (m = v == null ? void 0 : v.map((k) => k.range)) != null ? m : []
|
|
392
|
+
});
|
|
393
|
+
})
|
|
394
|
+
)), g.add(this.registerEventHandler(
|
|
395
|
+
this.Event.SelectionMoveEnd,
|
|
396
|
+
() => c.selectionMoveEnd$.subscribe((v) => {
|
|
397
|
+
var m;
|
|
398
|
+
this.fireEvent(this.Event.SelectionMoveEnd, {
|
|
399
|
+
workbook: s,
|
|
400
|
+
worksheet: s.getActiveSheet(),
|
|
401
|
+
selections: (m = v == null ? void 0 : v.map((k) => k.range)) != null ? m : []
|
|
402
|
+
});
|
|
403
|
+
})
|
|
404
|
+
)), g.add(this.registerEventHandler(
|
|
405
|
+
this.Event.SelectionChanged,
|
|
406
|
+
() => c.selectionChanged$.subscribe((v) => {
|
|
407
|
+
var m;
|
|
408
|
+
this.fireEvent(this.Event.SelectionChanged, {
|
|
409
|
+
workbook: s,
|
|
410
|
+
worksheet: s.getActiveSheet(),
|
|
411
|
+
selections: (m = v == null ? void 0 : v.map((k) => k.range)) != null ? m : []
|
|
412
|
+
});
|
|
413
|
+
})
|
|
414
|
+
)), a = null, this.disposeWithMe(g);
|
|
415
|
+
})), this.disposeWithMe(r.disposed$.subscribe((l) => {
|
|
416
|
+
var h;
|
|
417
|
+
(h = o.get(l)) == null || h.dispose(), o.delete(l);
|
|
418
|
+
})), this.disposeWithMe(() => {
|
|
419
|
+
o.forEach((l) => {
|
|
420
|
+
l.dispose();
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* @ignore
|
|
426
|
+
*/
|
|
427
|
+
_initialize(e) {
|
|
428
|
+
this._initSheetUIEvent(e), this._initObserverListener(e);
|
|
429
|
+
const r = e.get(I);
|
|
430
|
+
this.registerEventHandler(
|
|
431
|
+
this.Event.BeforeClipboardChange,
|
|
432
|
+
() => r.beforeCommandExecuted((t) => {
|
|
433
|
+
switch (t.id) {
|
|
434
|
+
case V.id:
|
|
435
|
+
case F.id:
|
|
436
|
+
this._beforeClipboardChange();
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
})
|
|
440
|
+
), this.registerEventHandler(
|
|
441
|
+
this.Event.ClipboardChanged,
|
|
442
|
+
() => r.onCommandExecuted((t) => {
|
|
443
|
+
switch (t.id) {
|
|
444
|
+
case V.id:
|
|
445
|
+
case F.id:
|
|
446
|
+
this._clipboardChanged();
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
})
|
|
450
|
+
), this.registerEventHandler(
|
|
451
|
+
this.Event.BeforeClipboardPaste,
|
|
452
|
+
() => r.beforeCommandExecuted((t) => {
|
|
453
|
+
switch (t.id) {
|
|
454
|
+
case L.id:
|
|
455
|
+
this._beforeClipboardPaste(t.params);
|
|
456
|
+
break;
|
|
457
|
+
case Z.id:
|
|
458
|
+
this._beforeClipboardPasteAsync();
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
})
|
|
462
|
+
), this.registerEventHandler(
|
|
463
|
+
this.Event.ClipboardPasted,
|
|
464
|
+
() => r.onCommandExecuted((t) => {
|
|
465
|
+
switch (t.id) {
|
|
466
|
+
case L.id:
|
|
467
|
+
this._clipboardPaste(t.params);
|
|
468
|
+
break;
|
|
469
|
+
case Z.id:
|
|
470
|
+
this._clipboardPasteAsync();
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
})
|
|
474
|
+
), this.registerEventHandler(
|
|
475
|
+
this.Event.SheetSkeletonChanged,
|
|
476
|
+
() => r.onCommandExecuted((t) => {
|
|
477
|
+
if (ve.indexOf(t.id) > -1) {
|
|
478
|
+
const i = this.getActiveSheet();
|
|
479
|
+
if (!i) return;
|
|
480
|
+
const o = Se(t, i.worksheet.getMaxColumns()).map((a) => {
|
|
481
|
+
var d, l;
|
|
482
|
+
return (l = (d = this.getWorkbook(a.unitId)) == null ? void 0 : d.getSheetBySheetId(a.subUnitId)) == null ? void 0 : l.getRange(a.range);
|
|
483
|
+
}).filter(Boolean);
|
|
484
|
+
if (!o.length) return;
|
|
485
|
+
this.fireEvent(this.Event.SheetSkeletonChanged, {
|
|
486
|
+
workbook: i.workbook,
|
|
487
|
+
worksheet: i.worksheet,
|
|
488
|
+
payload: t,
|
|
489
|
+
skeleton: i.worksheet.getSkeleton(),
|
|
490
|
+
effectedRanges: o
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
})
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
_generateClipboardCopyParam() {
|
|
497
|
+
const e = this.getActiveWorkbook(), r = e == null ? void 0 : e.getActiveSheet(), t = e == null ? void 0 : e.getActiveRange();
|
|
498
|
+
if (!e || !r || !t)
|
|
499
|
+
return;
|
|
500
|
+
const o = this._injector.get(Q).generateCopyContent(e.getId(), r.getSheetId(), t.getRange());
|
|
501
|
+
if (!o)
|
|
502
|
+
return;
|
|
503
|
+
const { html: a, plain: d } = o;
|
|
504
|
+
return {
|
|
505
|
+
workbook: e,
|
|
506
|
+
worksheet: r,
|
|
507
|
+
text: d,
|
|
508
|
+
html: a,
|
|
509
|
+
fromSheet: r,
|
|
510
|
+
fromRange: t
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
_beforeClipboardChange() {
|
|
514
|
+
const e = this._generateClipboardCopyParam();
|
|
515
|
+
if (e && (this.fireEvent(this.Event.BeforeClipboardChange, e), e.cancel))
|
|
516
|
+
throw new E();
|
|
517
|
+
}
|
|
518
|
+
_clipboardChanged() {
|
|
519
|
+
const e = this._generateClipboardCopyParam();
|
|
520
|
+
e && this.fireEvent(this.Event.ClipboardChanged, e);
|
|
521
|
+
}
|
|
522
|
+
_generateClipboardPasteParam(e) {
|
|
523
|
+
if (!e)
|
|
524
|
+
return;
|
|
525
|
+
const { htmlContent: r, textContent: t } = e, i = this.getActiveWorkbook(), o = i == null ? void 0 : i.getActiveSheet();
|
|
526
|
+
return !i || !o ? void 0 : {
|
|
527
|
+
workbook: i,
|
|
528
|
+
worksheet: o,
|
|
529
|
+
text: t,
|
|
530
|
+
html: r
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
async _generateClipboardPasteParamAsync() {
|
|
534
|
+
const e = this.getActiveWorkbook(), r = e == null ? void 0 : e.getActiveSheet();
|
|
535
|
+
if (!e || !r)
|
|
536
|
+
return;
|
|
537
|
+
const o = (await this._injector.get(Pe).read())[0];
|
|
538
|
+
let a;
|
|
539
|
+
if (o) {
|
|
540
|
+
const d = o.types, l = d.indexOf(K) !== -1 ? await o.getType(K).then((g) => g && g.text()) : "", h = d.indexOf(Y) !== -1 ? await o.getType(Y).then((g) => g && g.text()) : "";
|
|
541
|
+
a = {
|
|
542
|
+
workbook: e,
|
|
543
|
+
worksheet: r,
|
|
544
|
+
text: l,
|
|
545
|
+
html: h
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
return a;
|
|
549
|
+
}
|
|
550
|
+
_beforeClipboardPaste(e) {
|
|
551
|
+
const r = this._generateClipboardPasteParam(e);
|
|
552
|
+
if (r && (this.fireEvent(this.Event.BeforeClipboardPaste, r), r.cancel))
|
|
553
|
+
throw new E();
|
|
554
|
+
}
|
|
555
|
+
_clipboardPaste(e) {
|
|
556
|
+
const r = this._generateClipboardPasteParam(e);
|
|
557
|
+
if (r && (this.fireEvent(this.Event.ClipboardPasted, r), r.cancel))
|
|
558
|
+
throw new E();
|
|
559
|
+
}
|
|
560
|
+
async _beforeClipboardPasteAsync() {
|
|
561
|
+
if (!X()) {
|
|
562
|
+
this._injector.get(U).warn("[Facade]: The navigator object only supports the browser environment");
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const e = await this._generateClipboardPasteParamAsync();
|
|
566
|
+
if (e && (this.fireEvent(this.Event.BeforeClipboardPaste, e), e.cancel))
|
|
567
|
+
throw new E();
|
|
568
|
+
}
|
|
569
|
+
async _clipboardPasteAsync() {
|
|
570
|
+
if (!X()) {
|
|
571
|
+
this._injector.get(U).warn("[Facade]: The navigator object only supports the browser environment");
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
const e = await this._generateClipboardPasteParamAsync();
|
|
575
|
+
if (e && (this.fireEvent(this.Event.ClipboardPasted, e), e.cancel))
|
|
576
|
+
throw new E();
|
|
577
|
+
}
|
|
578
|
+
customizeColumnHeader(e) {
|
|
579
|
+
var h, g;
|
|
580
|
+
const r = this.getActiveWorkbook();
|
|
581
|
+
if (!r) {
|
|
582
|
+
console.error("WorkBook not exist");
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
const t = r == null ? void 0 : r.getId(), i = this._injector.get(S), o = r.getActiveSheet(), a = o.getSheetId(), d = i.getRenderById(t);
|
|
586
|
+
d && ((h = e.headerStyle) != null && h.size) && (d.with(_).setColumnHeaderSize(d, a, (g = e.headerStyle) == null ? void 0 : g.size), o == null || o.refreshCanvas()), this._getSheetRenderComponent(t, w.COLUMN).setCustomHeader(e), o == null || o.refreshCanvas();
|
|
587
|
+
}
|
|
588
|
+
customizeRowHeader(e) {
|
|
589
|
+
const r = this.getActiveWorkbook();
|
|
590
|
+
if (!r) {
|
|
591
|
+
console.error("WorkBook not exist");
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const t = r == null ? void 0 : r.getId();
|
|
595
|
+
this._getSheetRenderComponent(t, w.ROW).setCustomHeader(e);
|
|
596
|
+
}
|
|
597
|
+
registerSheetRowHeaderExtension(e, ...r) {
|
|
598
|
+
const t = this._getSheetRenderComponent(e, w.ROW), i = t.register(...r);
|
|
599
|
+
return C(() => {
|
|
600
|
+
i.dispose(), t.makeDirty(!0);
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
registerSheetColumnHeaderExtension(e, ...r) {
|
|
604
|
+
const t = this._getSheetRenderComponent(e, w.COLUMN), i = t.register(...r);
|
|
605
|
+
return C(() => {
|
|
606
|
+
i.dispose(), t.makeDirty(!0);
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
registerSheetMainExtension(e, ...r) {
|
|
610
|
+
const t = this._getSheetRenderComponent(e, w.MAIN), i = t.register(...r);
|
|
611
|
+
return C(() => {
|
|
612
|
+
i.dispose(), t.makeDirty(!0);
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Get sheet render component from render by unitId and view key.
|
|
617
|
+
* @private
|
|
618
|
+
* @param {string} unitId The unit id of the spreadsheet.
|
|
619
|
+
* @param {SHEET_VIEW_KEY} viewKey The view key of the spreadsheet.
|
|
620
|
+
* @returns {Nullable<RenderComponentType>} The render component.
|
|
621
|
+
*/
|
|
622
|
+
_getSheetRenderComponent(e, r) {
|
|
623
|
+
const i = this._injector.get(S).getRenderById(e);
|
|
624
|
+
if (!i)
|
|
625
|
+
throw new Error(`Render Unit with unitId ${e} not found`);
|
|
626
|
+
const { components: o } = i, a = o.get(r);
|
|
627
|
+
if (!a)
|
|
628
|
+
throw new Error("Render component not found");
|
|
629
|
+
return a;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Get sheet hooks.
|
|
633
|
+
* @returns {FSheetHooks} FSheetHooks instance
|
|
634
|
+
*/
|
|
635
|
+
getSheetHooks() {
|
|
636
|
+
return this._injector.createInstance(W);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
q.extend(ye);
|
|
640
|
+
class Ue extends ee {
|
|
641
|
+
openSiderbar(e) {
|
|
642
|
+
return this._logDeprecation("openSiderbar"), this._injector.get(Re).open(e);
|
|
643
|
+
}
|
|
644
|
+
openDialog(e) {
|
|
645
|
+
this._logDeprecation("openDialog");
|
|
646
|
+
const t = this._injector.get(He).open({
|
|
647
|
+
...e,
|
|
648
|
+
onClose: () => {
|
|
649
|
+
t.dispose();
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
return t;
|
|
653
|
+
}
|
|
654
|
+
_logDeprecation(e) {
|
|
655
|
+
this._injector.get(U).warn("[FWorkbook]", `${e} is deprecated. Please use the function of the same name on "FUniver".`);
|
|
656
|
+
}
|
|
657
|
+
generateCellParams(e) {
|
|
658
|
+
const r = this.getActiveSheet();
|
|
659
|
+
return {
|
|
660
|
+
row: e.row,
|
|
661
|
+
column: e.col,
|
|
662
|
+
workbook: this,
|
|
663
|
+
worksheet: r
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
onCellClick(e) {
|
|
667
|
+
const r = this._injector.get(p);
|
|
668
|
+
return C(
|
|
669
|
+
r.currentClickedCell$.pipe(u((t) => !!t)).subscribe((t) => {
|
|
670
|
+
e(t);
|
|
671
|
+
})
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
onCellHover(e) {
|
|
675
|
+
const r = this._injector.get(p);
|
|
676
|
+
return C(
|
|
677
|
+
r.currentRichText$.pipe(u((t) => !!t)).subscribe(e)
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
onCellPointerDown(e) {
|
|
681
|
+
const r = this._injector.get(p);
|
|
682
|
+
return C(
|
|
683
|
+
r.currentPointerDownCell$.subscribe(e)
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
onCellPointerUp(e) {
|
|
687
|
+
const r = this._injector.get(p);
|
|
688
|
+
return C(
|
|
689
|
+
r.currentPointerUpCell$.subscribe(e)
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
onCellPointerMove(e) {
|
|
693
|
+
const r = this._injector.get(p);
|
|
694
|
+
return C(
|
|
695
|
+
r.currentCellPosWithEvent$.pipe(u((t) => !!t)).subscribe((t) => {
|
|
696
|
+
e(t, t.event);
|
|
697
|
+
})
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
onDragOver(e) {
|
|
701
|
+
const r = this._injector.get(M);
|
|
702
|
+
return C(
|
|
703
|
+
r.currentCell$.pipe(u((t) => !!t)).subscribe((t) => {
|
|
704
|
+
e(t);
|
|
705
|
+
})
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
onDrop(e) {
|
|
709
|
+
const r = this._injector.get(M);
|
|
710
|
+
return C(
|
|
711
|
+
r.endCell$.pipe(u((t) => !!t)).subscribe((t) => {
|
|
712
|
+
e(t);
|
|
713
|
+
})
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
startEditing() {
|
|
717
|
+
return this._injector.get(I).syncExecuteCommand(f.id, {
|
|
718
|
+
eventType: z.Dblclick,
|
|
719
|
+
unitId: this._workbook.getUnitId(),
|
|
720
|
+
visible: !0
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
async endEditing(e) {
|
|
724
|
+
return this._injector.get(I).syncExecuteCommand(f.id, {
|
|
725
|
+
eventType: z.Keyboard,
|
|
726
|
+
keycode: e ? T.ENTER : T.ESC,
|
|
727
|
+
visible: !1,
|
|
728
|
+
unitId: this._workbook.getUnitId()
|
|
729
|
+
}), await se(0), !0;
|
|
730
|
+
}
|
|
731
|
+
endEditingAsync(e = !0) {
|
|
732
|
+
return this.endEditing(e);
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Get scroll state of specified sheet.
|
|
736
|
+
* @param {string} sheetId - sheet id
|
|
737
|
+
* @returns {IScrollState} scroll state
|
|
738
|
+
* @example
|
|
739
|
+
* ``` ts
|
|
740
|
+
* univerAPI.getActiveWorkbook().getScrollStateBySheetId($sheetId)
|
|
741
|
+
* ```
|
|
742
|
+
*/
|
|
743
|
+
getScrollStateBySheetId(e) {
|
|
744
|
+
const r = this._workbook.getUnitId(), i = this._injector.get(S).getRenderById(r);
|
|
745
|
+
return i ? i.with(x).getScrollStateByParam({ unitId: r, sheetId: e }) : null;
|
|
746
|
+
}
|
|
747
|
+
disableSelection() {
|
|
748
|
+
const e = this._workbook.getUnitId(), t = this._injector.get(S).getRenderById(e);
|
|
749
|
+
return t && t.with(y).disableSelection(), this;
|
|
750
|
+
}
|
|
751
|
+
enableSelection() {
|
|
752
|
+
const e = this._workbook.getUnitId(), t = this._injector.get(S).getRenderById(e);
|
|
753
|
+
return t && t.with(y).enableSelection(), this;
|
|
754
|
+
}
|
|
755
|
+
transparentSelection() {
|
|
756
|
+
const e = this._workbook.getUnitId(), t = this._injector.get(S).getRenderById(e);
|
|
757
|
+
return t && t.with(y).transparentSelection(), this;
|
|
758
|
+
}
|
|
759
|
+
showSelection() {
|
|
760
|
+
const e = this._workbook.getUnitId(), t = this._injector.get(S).getRenderById(e);
|
|
761
|
+
return t && t.with(y).showSelection(), this;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
ee.extend(Ue);
|
|
765
|
+
class xe extends te {
|
|
766
|
+
refreshCanvas() {
|
|
767
|
+
const e = this._injector.get(S), r = this._fWorkbook.id, t = e.getRenderById(r);
|
|
768
|
+
if (!t)
|
|
769
|
+
throw new Error(`Render Unit with unitId ${r} not found`);
|
|
770
|
+
t.with(_).reCalculate();
|
|
771
|
+
const i = t.mainComponent;
|
|
772
|
+
if (!i)
|
|
773
|
+
throw new Error("Main component not found");
|
|
774
|
+
return i.makeDirty(), this;
|
|
775
|
+
}
|
|
776
|
+
zoom(e) {
|
|
777
|
+
const r = this._injector.get(I), t = Math.min(Math.max(e, 0.1), 4);
|
|
778
|
+
return r.executeCommand(A.id, {
|
|
779
|
+
unitId: this._workbook.getUnitId(),
|
|
780
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
781
|
+
zoomRatio: t
|
|
782
|
+
}), this;
|
|
783
|
+
}
|
|
784
|
+
getZoom() {
|
|
785
|
+
return this._worksheet.getZoomRatio();
|
|
786
|
+
}
|
|
787
|
+
getVisibleRange() {
|
|
788
|
+
const e = this._workbook.getUnitId(), t = this._injector.get(S).getRenderById(e);
|
|
789
|
+
let i = {
|
|
790
|
+
startColumn: 0,
|
|
791
|
+
startRow: 0,
|
|
792
|
+
endColumn: 0,
|
|
793
|
+
endRow: 0
|
|
794
|
+
};
|
|
795
|
+
if (!t) return i;
|
|
796
|
+
const a = t.with(_).getCurrentSkeleton();
|
|
797
|
+
if (!a) return i;
|
|
798
|
+
const d = a == null ? void 0 : a.getVisibleRanges();
|
|
799
|
+
if (!d) return i;
|
|
800
|
+
i = a.getVisibleRangeByViewport(le.VIEW_MAIN);
|
|
801
|
+
for (const [l, h] of d)
|
|
802
|
+
ge.indexOf(l) !== -1 && (i.startColumn = Math.min(i.startColumn, h.startColumn), i.startRow = Math.min(i.startRow, h.startRow), i.endColumn = Math.max(i.endColumn, h.endColumn), i.endRow = Math.max(i.endRow, h.endRow));
|
|
803
|
+
return i;
|
|
804
|
+
}
|
|
805
|
+
scrollToCell(e, r) {
|
|
806
|
+
const t = this._workbook.getUnitId(), o = this._injector.get(S).getRenderById(t);
|
|
807
|
+
return o && (o == null ? void 0 : o.with(pe)).scrollToCell(e, r), this;
|
|
808
|
+
}
|
|
809
|
+
getScrollState() {
|
|
810
|
+
const e = {
|
|
811
|
+
offsetX: 0,
|
|
812
|
+
offsetY: 0,
|
|
813
|
+
sheetViewStartColumn: 0,
|
|
814
|
+
sheetViewStartRow: 0
|
|
815
|
+
}, r = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), o = this._injector.get(S).getRenderById(r);
|
|
816
|
+
return o && o.with(x).getScrollStateByParam({ unitId: r, sheetId: t }) || e;
|
|
817
|
+
}
|
|
818
|
+
onScroll(e) {
|
|
819
|
+
var o;
|
|
820
|
+
const r = this._workbook.getUnitId(), i = (o = this._injector.get(S).getRenderById(r)) == null ? void 0 : o.with(x);
|
|
821
|
+
if (i) {
|
|
822
|
+
const a = i.validViewportScrollInfo$.subscribe((d) => {
|
|
823
|
+
e(d);
|
|
824
|
+
});
|
|
825
|
+
return C(a);
|
|
826
|
+
}
|
|
827
|
+
return C(() => {
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
getSkeleton() {
|
|
831
|
+
var r, t;
|
|
832
|
+
const e = (r = this._injector.get(S).getRenderById(this._workbook.getUnitId())) == null ? void 0 : r.with(_);
|
|
833
|
+
return (t = e == null ? void 0 : e.getWorksheetSkeleton(this._worksheet.getSheetId())) == null ? void 0 : t.skeleton;
|
|
834
|
+
}
|
|
835
|
+
autoResizeColumn(e) {
|
|
836
|
+
return this.autoResizeColumns(e, 1);
|
|
837
|
+
}
|
|
838
|
+
autoResizeColumns(e, r) {
|
|
839
|
+
const t = this._workbook.getUnitId(), i = this._worksheet.getSheetId(), o = [
|
|
840
|
+
{
|
|
841
|
+
startColumn: e,
|
|
842
|
+
endColumn: e + r - 1,
|
|
843
|
+
startRow: 0,
|
|
844
|
+
endRow: this._worksheet.getRowCount() - 1
|
|
845
|
+
}
|
|
846
|
+
];
|
|
847
|
+
return this._commandService.syncExecuteCommand(we.id, {
|
|
848
|
+
unitId: t,
|
|
849
|
+
subUnitId: i,
|
|
850
|
+
ranges: o
|
|
851
|
+
}), this;
|
|
852
|
+
}
|
|
853
|
+
setColumnAutoWidth(e, r) {
|
|
854
|
+
return this.autoResizeColumns(e, r);
|
|
855
|
+
}
|
|
856
|
+
autoResizeRows(e, r) {
|
|
857
|
+
const t = this._workbook.getUnitId(), i = this._worksheet.getSheetId(), o = [
|
|
858
|
+
{
|
|
859
|
+
startRow: e,
|
|
860
|
+
endRow: e + r - 1,
|
|
861
|
+
startColumn: 0,
|
|
862
|
+
endColumn: this._worksheet.getColumnCount() - 1
|
|
863
|
+
}
|
|
864
|
+
];
|
|
865
|
+
return this._commandService.syncExecuteCommand(Ce.id, {
|
|
866
|
+
unitId: t,
|
|
867
|
+
subUnitId: i,
|
|
868
|
+
ranges: o
|
|
869
|
+
}), this;
|
|
870
|
+
}
|
|
871
|
+
customizeColumnHeader(e) {
|
|
872
|
+
var l, h;
|
|
873
|
+
const r = this, t = this._fWorkbook.getId(), i = this._injector.get(S), o = r.getSheetId(), a = i.getRenderById(t);
|
|
874
|
+
a && ((l = e.headerStyle) != null && l.size) && (a.with(_).setColumnHeaderSize(a, o, (h = e.headerStyle) == null ? void 0 : h.size), r == null || r.refreshCanvas());
|
|
875
|
+
const d = this._getSheetRenderComponent(t, w.COLUMN);
|
|
876
|
+
d && (d.setCustomHeader(e), r == null || r.refreshCanvas());
|
|
877
|
+
}
|
|
878
|
+
customizeRowHeader(e) {
|
|
879
|
+
const r = this._fWorkbook.getId();
|
|
880
|
+
this._getSheetRenderComponent(r, w.ROW).setCustomHeader(e);
|
|
881
|
+
}
|
|
882
|
+
setColumnHeaderHeight(e) {
|
|
883
|
+
const r = this, t = this._fWorkbook.getId(), i = r.getSheetId();
|
|
884
|
+
return this._commandService.executeCommand(fe.id, {
|
|
885
|
+
unitId: t,
|
|
886
|
+
subUnitId: i,
|
|
887
|
+
size: e
|
|
888
|
+
}), r == null || r.refreshCanvas(), this;
|
|
889
|
+
}
|
|
890
|
+
setRowHeaderWidth(e) {
|
|
891
|
+
const r = this, t = this._fWorkbook.getId(), i = r.getSheetId();
|
|
892
|
+
this._commandService.executeCommand(ke.id, {
|
|
893
|
+
unitId: t,
|
|
894
|
+
subUnitId: i,
|
|
895
|
+
size: e
|
|
896
|
+
});
|
|
897
|
+
const o = this._getSheetRenderComponent(t, w.ROW);
|
|
898
|
+
return o && o.setCustomHeader({ headerStyle: { size: e } }), r == null || r.refreshCanvas(), this;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Get sheet render component from render by unitId and view key.
|
|
902
|
+
* @private
|
|
903
|
+
* @param {string} unitId The unit id of the spreadsheet.
|
|
904
|
+
* @param {SHEET_VIEW_KEY} viewKey The view key of the spreadsheet.
|
|
905
|
+
* @returns {Nullable<RenderComponentType>} The render component.
|
|
906
|
+
*/
|
|
907
|
+
_getSheetRenderComponent(e, r) {
|
|
908
|
+
const i = this._injector.get(S).getRenderById(e);
|
|
909
|
+
if (!i)
|
|
910
|
+
throw new Error(`Render Unit with unitId ${e} not found`);
|
|
911
|
+
const { components: o } = i, a = o.get(r);
|
|
912
|
+
if (!a)
|
|
913
|
+
throw new Error("Render component not found");
|
|
914
|
+
return a;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
te.extend(xe);
|
|
918
|
+
class Te extends re {
|
|
919
|
+
setPermissionDialogVisible(e) {
|
|
920
|
+
this._permissionService.setShowComponents(e);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
re.extend(Te);
|
|
924
|
+
class De extends W {
|
|
925
|
+
onCellPointerMove(e) {
|
|
926
|
+
return C(this._injector.get(p).currentPosition$.subscribe(e));
|
|
927
|
+
}
|
|
928
|
+
onCellPointerOver(e) {
|
|
929
|
+
return C(this._injector.get(p).currentCell$.subscribe(e));
|
|
930
|
+
}
|
|
931
|
+
onCellDragOver(e) {
|
|
932
|
+
return C(this._injector.get(M).currentCell$.subscribe(e));
|
|
933
|
+
}
|
|
934
|
+
onCellDrop(e) {
|
|
935
|
+
return C(this._injector.get(M).endCell$.subscribe(e));
|
|
936
|
+
}
|
|
937
|
+
onCellRender(e, r = ae.Style, t = me.DATA_VALIDATION) {
|
|
938
|
+
return this._injector.get(be).intercept(Ee.CELL_CONTENT, {
|
|
939
|
+
effect: r,
|
|
940
|
+
handler: (i, o, a) => a({
|
|
941
|
+
...i,
|
|
942
|
+
customRender: [
|
|
943
|
+
...(i == null ? void 0 : i.customRender) || [],
|
|
944
|
+
...e || []
|
|
945
|
+
]
|
|
946
|
+
}),
|
|
947
|
+
priority: t
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
onBeforeCellEdit(e) {
|
|
951
|
+
return this._injector.get(I).beforeCommandExecuted((r) => {
|
|
952
|
+
const t = r.params;
|
|
953
|
+
r.id === f.id && t.visible && e(t);
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
onAfterCellEdit(e) {
|
|
957
|
+
return this._injector.get(I).onCommandExecuted((r) => {
|
|
958
|
+
const t = r.params;
|
|
959
|
+
r.id === f.id && !t.visible && e(t);
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
W.extend(De);
|
|
964
|
+
const H = {
|
|
965
|
+
CellClicked: "CellClicked",
|
|
966
|
+
CellPointerDown: "CellPointerDown",
|
|
967
|
+
CellPointerUp: "CellPointerUp",
|
|
968
|
+
CellPointerMove: "CellPointerMove",
|
|
969
|
+
CellHover: "CellHover"
|
|
970
|
+
};
|
|
971
|
+
class Be {
|
|
972
|
+
get BeforeClipboardChange() {
|
|
973
|
+
return "BeforeClipboardChange";
|
|
974
|
+
}
|
|
975
|
+
get ClipboardChanged() {
|
|
976
|
+
return "ClipboardChanged";
|
|
977
|
+
}
|
|
978
|
+
get BeforeClipboardPaste() {
|
|
979
|
+
return "BeforeClipboardPaste";
|
|
980
|
+
}
|
|
981
|
+
get ClipboardPasted() {
|
|
982
|
+
return "ClipboardPasted";
|
|
983
|
+
}
|
|
984
|
+
get BeforeSheetEditStart() {
|
|
985
|
+
return "BeforeSheetEditStart";
|
|
986
|
+
}
|
|
987
|
+
get SheetEditStarted() {
|
|
988
|
+
return "SheetEditStarted";
|
|
989
|
+
}
|
|
990
|
+
get SheetEditChanging() {
|
|
991
|
+
return "SheetEditChanging";
|
|
992
|
+
}
|
|
993
|
+
get BeforeSheetEditEnd() {
|
|
994
|
+
return "BeforeSheetEditEnd";
|
|
995
|
+
}
|
|
996
|
+
get SheetEditEnded() {
|
|
997
|
+
return "SheetEditEnded";
|
|
998
|
+
}
|
|
999
|
+
get CellClicked() {
|
|
1000
|
+
return H.CellClicked;
|
|
1001
|
+
}
|
|
1002
|
+
get CellHover() {
|
|
1003
|
+
return H.CellHover;
|
|
1004
|
+
}
|
|
1005
|
+
get CellPointerDown() {
|
|
1006
|
+
return H.CellPointerDown;
|
|
1007
|
+
}
|
|
1008
|
+
get CellPointerUp() {
|
|
1009
|
+
return H.CellPointerUp;
|
|
1010
|
+
}
|
|
1011
|
+
get CellPointerMove() {
|
|
1012
|
+
return H.CellPointerMove;
|
|
1013
|
+
}
|
|
1014
|
+
get DragOver() {
|
|
1015
|
+
return "DragOver";
|
|
1016
|
+
}
|
|
1017
|
+
get Drop() {
|
|
1018
|
+
return "Drop";
|
|
1019
|
+
}
|
|
1020
|
+
get Scroll() {
|
|
1021
|
+
return "Scroll";
|
|
1022
|
+
}
|
|
1023
|
+
get SelectionMoveStart() {
|
|
1024
|
+
return "SelectionMoveStart";
|
|
1025
|
+
}
|
|
1026
|
+
get SelectionChanged() {
|
|
1027
|
+
return "SelectionChanged";
|
|
1028
|
+
}
|
|
1029
|
+
get SelectionMoving() {
|
|
1030
|
+
return "SelectionMoving";
|
|
1031
|
+
}
|
|
1032
|
+
get SelectionMoveEnd() {
|
|
1033
|
+
return "SelectionMoveEnd";
|
|
1034
|
+
}
|
|
1035
|
+
get RowHeaderClick() {
|
|
1036
|
+
return "RowHeaderClick";
|
|
1037
|
+
}
|
|
1038
|
+
get RowHeaderPointerDown() {
|
|
1039
|
+
return "RowHeaderPointerDown";
|
|
1040
|
+
}
|
|
1041
|
+
get RowHeaderPointerUp() {
|
|
1042
|
+
return "RowHeaderPointerUp";
|
|
1043
|
+
}
|
|
1044
|
+
get RowHeaderHover() {
|
|
1045
|
+
return "RowHeaderHover";
|
|
1046
|
+
}
|
|
1047
|
+
get ColumnHeaderClick() {
|
|
1048
|
+
return "ColumnHeaderClick";
|
|
1049
|
+
}
|
|
1050
|
+
get ColumnHeaderPointerDown() {
|
|
1051
|
+
return "ColumnHeaderPointerDown";
|
|
1052
|
+
}
|
|
1053
|
+
get ColumnHeaderPointerUp() {
|
|
1054
|
+
return "ColumnHeaderPointerUp";
|
|
1055
|
+
}
|
|
1056
|
+
get ColumnHeaderHover() {
|
|
1057
|
+
return "ColumnHeaderHover";
|
|
1058
|
+
}
|
|
1059
|
+
get SheetSkeletonChanged() {
|
|
1060
|
+
return "SheetSkeletonChanged";
|
|
1061
|
+
}
|
|
1062
|
+
get BeforeSheetZoomChange() {
|
|
1063
|
+
return "BeforeSheetZoomChange";
|
|
1064
|
+
}
|
|
1065
|
+
get SheetZoomChanged() {
|
|
1066
|
+
return "SheetZoomChanged";
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
de.extend(Be);
|
|
1070
|
+
class Ae extends ne {
|
|
1071
|
+
getCell() {
|
|
1072
|
+
var d;
|
|
1073
|
+
const e = this._injector.get(S), r = this._injector.get(U), t = this._workbook.getUnitId(), i = this._worksheet.getSheetId(), o = e.getRenderById(t), a = (d = o == null ? void 0 : o.with(_).getSkeletonParam(i)) == null ? void 0 : d.skeleton;
|
|
1074
|
+
if (!a)
|
|
1075
|
+
throw r.error("[Facade]: `FRange.getCell` can only be called in current worksheet"), new Error("`FRange.getCell` can only be called in current worksheet");
|
|
1076
|
+
return a.getCellWithCoordByIndex(this._range.startRow, this._range.startColumn);
|
|
1077
|
+
}
|
|
1078
|
+
getCellRect() {
|
|
1079
|
+
const { startX: e, startY: r, endX: t, endY: i } = this.getCell(), o = { x: e, y: r, width: t - e, height: i - r, top: r, left: e, bottom: i, right: t };
|
|
1080
|
+
return { ...o, toJSON: () => JSON.stringify(o) };
|
|
1081
|
+
}
|
|
1082
|
+
generateHTML() {
|
|
1083
|
+
var t;
|
|
1084
|
+
const r = this._injector.get(Q).generateCopyContent(
|
|
1085
|
+
this._workbook.getUnitId(),
|
|
1086
|
+
this._worksheet.getSheetId(),
|
|
1087
|
+
this._range
|
|
1088
|
+
);
|
|
1089
|
+
return (t = r == null ? void 0 : r.html) != null ? t : "";
|
|
1090
|
+
}
|
|
1091
|
+
attachPopup(e) {
|
|
1092
|
+
var a, d, l;
|
|
1093
|
+
e.direction = (a = e.direction) != null ? a : "horizontal", e.extraProps = (d = e.extraProps) != null ? d : {}, e.offset = (l = e.offset) != null ? l : [0, 0];
|
|
1094
|
+
const { key: r, disposableCollection: t } = G(e, this._injector.get(J)), o = this._injector.get(N).attachPopupToCell(
|
|
1095
|
+
this._range.startRow,
|
|
1096
|
+
this._range.startColumn,
|
|
1097
|
+
{ ...e, componentKey: r },
|
|
1098
|
+
this.getUnitId(),
|
|
1099
|
+
this._worksheet.getSheetId()
|
|
1100
|
+
);
|
|
1101
|
+
return o ? (t.add(o), t) : (t.dispose(), null);
|
|
1102
|
+
}
|
|
1103
|
+
attachAlertPopup(e) {
|
|
1104
|
+
const r = this._injector.get(Ie), t = {
|
|
1105
|
+
workbook: this._workbook,
|
|
1106
|
+
worksheet: this._worksheet,
|
|
1107
|
+
row: this._range.startRow,
|
|
1108
|
+
col: this._range.startColumn,
|
|
1109
|
+
unitId: this.getUnitId(),
|
|
1110
|
+
subUnitId: this._worksheet.getSheetId()
|
|
1111
|
+
};
|
|
1112
|
+
return r.showAlert({
|
|
1113
|
+
...e,
|
|
1114
|
+
location: t
|
|
1115
|
+
}), {
|
|
1116
|
+
dispose: () => {
|
|
1117
|
+
r.removeAlert(e.key);
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* attachDOMPopup
|
|
1123
|
+
* @param popup
|
|
1124
|
+
* @returns {IDisposable} disposable
|
|
1125
|
+
let sheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
1126
|
+
let range = sheet.getRange(2, 2, 3, 3);
|
|
1127
|
+
univerAPI.getActiveWorkbook().setActiveRange(range);
|
|
1128
|
+
let disposable = range.attachDOMPopup({
|
|
1129
|
+
componentKey: 'univer.sheet.single-dom-popup',
|
|
1130
|
+
extraProps: { alert: { type: 0, title: 'This is an Info', message: 'This is an info message' } },
|
|
1131
|
+
});
|
|
1132
|
+
*/
|
|
1133
|
+
attachRangePopup(e) {
|
|
1134
|
+
var a, d, l;
|
|
1135
|
+
e.direction = (a = e.direction) != null ? a : "top-center", e.extraProps = (d = e.extraProps) != null ? d : {}, e.offset = (l = e.offset) != null ? l : [0, 0];
|
|
1136
|
+
const { key: r, disposableCollection: t } = G(e, this._injector.get(J)), o = this._injector.get(N).attachRangePopup(
|
|
1137
|
+
this._range,
|
|
1138
|
+
{ ...e, componentKey: r },
|
|
1139
|
+
this.getUnitId(),
|
|
1140
|
+
this._worksheet.getSheetId()
|
|
1141
|
+
);
|
|
1142
|
+
return o ? (t.add(o), t) : (t.dispose(), null);
|
|
1143
|
+
}
|
|
1144
|
+
highlight(e, r) {
|
|
1145
|
+
const t = this._injector.get(_e), i = t.addShape({ range: this._range, style: e, primary: r });
|
|
1146
|
+
if (!i)
|
|
1147
|
+
throw new Error("Failed to highlight current range");
|
|
1148
|
+
return C(() => {
|
|
1149
|
+
t.removeShape(i);
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
ne.extend(Ae);
|
|
1154
|
+
function G(b, e) {
|
|
1155
|
+
const { componentKey: r, isVue3: t } = b;
|
|
1156
|
+
let i;
|
|
1157
|
+
const o = new B();
|
|
1158
|
+
return typeof r == "string" ? i = r : (i = `External_${ce(6)}`, o.add(e.register(i, r, { framework: t ? "vue3" : "react" }))), {
|
|
1159
|
+
key: i,
|
|
1160
|
+
disposableCollection: o
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
export {
|
|
1164
|
+
G as transformComponentKey
|
|
1165
|
+
};
|