@univerjs/sheets-ui 0.5.4 → 0.5.5-experimental.20250123-34738ff

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