@univerjs/sheets-ui 0.5.4 → 0.5.5-experimental.20250122-3362a4a

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