@univerjs/sheets-ui 0.5.4 → 0.5.5-nightly.202501201336

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