@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.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +44 -48
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +798 -474
- package/lib/es/index.js +17244 -16473
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/index.css +1 -1
- package/lib/types/commands/commands/clipboard.command.d.ts +1 -0
- package/lib/types/commands/commands/set-selection.command.d.ts +5 -0
- package/lib/types/common/keys.d.ts +1 -0
- package/lib/types/components/border-panel/BorderPanel.d.ts +1 -2
- package/lib/types/components/border-panel/border-line/BorderLine.d.ts +1 -2
- package/lib/types/components/border-panel/border-line/icons/BorderDashDot.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderDashDotDot.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderDashed.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderDotted.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderHair.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderMedium.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDot.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDotDot.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashed.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderThick.d.ts +16 -2
- package/lib/types/components/border-panel/border-line/icons/BorderThin.d.ts +16 -2
- package/lib/types/components/menu-item-input/MenuItemInput.d.ts +1 -2
- package/lib/types/controllers/clipboard/clipboard.controller.d.ts +1 -0
- package/lib/types/controllers/clipboard/utils.d.ts +0 -11
- package/lib/types/controllers/editor/data-sync.controller.d.ts +3 -1
- package/lib/types/controllers/editor/editing.render-controller.d.ts +3 -4
- package/lib/types/controllers/editor/formula-editor.controller.d.ts +4 -2
- package/lib/types/controllers/render-controllers/freeze.render-controller.d.ts +6 -2
- package/lib/types/facade/f-event.d.ts +279 -11
- package/lib/types/facade/f-range.d.ts +39 -2
- package/lib/types/facade/f-univer.d.ts +5 -1
- package/lib/types/facade/f-workbook.d.ts +18 -24
- package/lib/types/facade/f-worksheet.d.ts +26 -5
- package/lib/types/index.d.ts +2 -1
- package/lib/types/services/auto-fill/tools.d.ts +5 -0
- package/lib/types/services/canvas-pop-manager.service.d.ts +41 -6
- package/lib/types/services/clipboard/clipboard.service.d.ts +5 -2
- package/lib/types/services/clipboard/type.d.ts +69 -5
- package/lib/types/services/editor/cell-editor-resize.service.d.ts +3 -2
- package/lib/types/services/editor-bridge.service.d.ts +3 -1
- package/lib/types/services/hover-manager.service.d.ts +41 -0
- package/lib/types/services/selection/base-selection-render.service.d.ts +4 -0
- package/lib/types/services/selection/selection-control.d.ts +2 -2
- package/lib/types/services/sheet-skeleton-manager.service.d.ts +2 -1
- package/lib/types/views/cell-alert/CellAlertPopup.d.ts +1 -2
- package/lib/types/views/clipboard/ClipboardPopupMenu.d.ts +16 -2
- package/lib/types/views/count-bar/CountBar.d.ts +16 -2
- package/lib/types/views/count-bar/ZoomSlider.d.ts +16 -2
- package/lib/types/views/defined-name/DefinedName.d.ts +16 -2
- package/lib/types/views/defined-name/DefinedNameContainer.d.ts +16 -2
- package/lib/types/views/defined-name/DefinedNameInput.d.ts +1 -2
- package/lib/types/views/defined-name/DefinedNameOverlay.d.ts +16 -2
- package/lib/types/views/editor-container/hooks.d.ts +8 -0
- package/lib/types/views/formula-bar/FormulaBar.d.ts +16 -2
- package/lib/types/views/mobile/sheet-bar/MobileSheetBar.d.ts +16 -2
- package/lib/types/views/permission/error-msg-dialog/index.d.ts +16 -2
- package/lib/types/views/permission/panel/index.d.ts +1 -2
- package/lib/types/views/permission/panel-detail/PermissionDetailFooterPart.d.ts +1 -2
- package/lib/types/views/permission/panel-detail/PermissionDetailMainPart.d.ts +1 -1
- package/lib/types/views/permission/panel-detail/PermissionDetailPanel.d.ts +1 -2
- package/lib/types/views/permission/panel-detail/PermissionDetailUserPart.d.ts +1 -2
- package/lib/types/views/permission/panel-list/index.d.ts +16 -2
- package/lib/types/views/permission/permission-dialog/index.d.ts +16 -2
- package/lib/types/views/permission/spin/index.d.ts +1 -1
- package/lib/types/views/permission/user-dialog/index.d.ts +16 -2
- package/lib/types/views/sheet-bar/SheetBar.d.ts +16 -2
- package/lib/types/views/sheet-bar/sheet-bar-button/SheetBarButton.d.ts +1 -1
- package/lib/types/views/sheet-bar/sheet-bar-menu/SheetBarMenu.d.ts +1 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarItem.d.ts +1 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.d.ts +16 -2
- package/lib/types/views/sheet-container/SheetContainer.d.ts +18 -4
- package/lib/types/views/status-bar/StatusBar.d.ts +16 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +44 -48
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +13 -13
- package/LICENSE +0 -176
package/lib/es/facade.js
CHANGED
|
@@ -1,270 +1,543 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
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(
|
|
12
|
-
const
|
|
13
|
-
this.disposeWithMe(
|
|
14
|
-
if (
|
|
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
|
|
18
|
-
if (!
|
|
19
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
20
|
+
if (!target)
|
|
19
21
|
return;
|
|
20
|
-
const { workbook
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
row:
|
|
24
|
-
column:
|
|
25
|
-
eventType
|
|
26
|
-
keycode
|
|
27
|
-
workbook
|
|
28
|
-
worksheet
|
|
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,
|
|
32
|
-
throw new
|
|
33
|
+
if (this.fireEvent(this.Event.BeforeSheetEditStart, eventParams), eventParams.cancel)
|
|
34
|
+
throw new CanceledError();
|
|
33
35
|
} else {
|
|
34
|
-
const
|
|
35
|
-
row:
|
|
36
|
-
column:
|
|
37
|
-
eventType
|
|
38
|
-
keycode
|
|
39
|
-
workbook
|
|
40
|
-
worksheet
|
|
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:
|
|
43
|
-
isConfirm:
|
|
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,
|
|
46
|
-
throw new
|
|
47
|
+
if (this.fireEvent(this.Event.BeforeSheetEditEnd, eventParams), eventParams.cancel)
|
|
48
|
+
throw new CanceledError();
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
54
|
-
if (!
|
|
68
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
69
|
+
if (!target)
|
|
55
70
|
return;
|
|
56
|
-
const { workbook
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
row:
|
|
60
|
-
column:
|
|
61
|
-
eventType
|
|
62
|
-
keycode
|
|
63
|
-
workbook
|
|
64
|
-
worksheet
|
|
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,
|
|
82
|
+
this.fireEvent(this.Event.SheetEditStarted, eventParams);
|
|
68
83
|
} else {
|
|
69
|
-
const
|
|
70
|
-
row:
|
|
71
|
-
column:
|
|
72
|
-
eventType
|
|
73
|
-
keycode
|
|
74
|
-
workbook
|
|
75
|
-
worksheet
|
|
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:
|
|
92
|
+
isConfirm: keycode !== KeyCode.ESC
|
|
78
93
|
};
|
|
79
|
-
this.fireEvent(this.Event.SheetEditEnded,
|
|
94
|
+
this.fireEvent(this.Event.SheetEditEnded, eventParams);
|
|
80
95
|
}
|
|
81
96
|
}
|
|
82
|
-
if (
|
|
97
|
+
if (commandInfo.id === RichTextEditingMutation.id) {
|
|
83
98
|
if (!this._eventListend(this.Event.SheetEditChanging))
|
|
84
99
|
return;
|
|
85
|
-
const
|
|
86
|
-
if (!
|
|
100
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
101
|
+
if (!target)
|
|
87
102
|
return;
|
|
88
|
-
const { workbook
|
|
89
|
-
if (!
|
|
90
|
-
const { unitId
|
|
91
|
-
if (
|
|
92
|
-
const { row
|
|
93
|
-
workbook
|
|
94
|
-
worksheet
|
|
95
|
-
row
|
|
96
|
-
column
|
|
97
|
-
value:
|
|
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,
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
|
115
|
-
this._beforeClipboardPaste(
|
|
368
|
+
case SheetPasteShortKeyCommand.id:
|
|
369
|
+
this._beforeClipboardPaste(commandInfo.params);
|
|
116
370
|
break;
|
|
117
371
|
}
|
|
118
|
-
})), this.disposeWithMe(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
|
396
|
+
case SheetPasteShortKeyCommand.id:
|
|
125
397
|
this._clipboardPaste();
|
|
126
398
|
break;
|
|
127
|
-
case
|
|
399
|
+
case PasteCommand.id:
|
|
128
400
|
this._clipboardPasteAsync();
|
|
129
401
|
break;
|
|
130
402
|
}
|
|
131
|
-
})), this.disposeWithMe(
|
|
132
|
-
switch (
|
|
133
|
-
case
|
|
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
|
|
141
|
-
if (!
|
|
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
|
|
144
|
-
if (!
|
|
415
|
+
const content = this._injector.get(ISheetClipboardService).generateCopyContent(workbook.getId(), worksheet.getSheetId(), range.getRange());
|
|
416
|
+
if (!content)
|
|
145
417
|
return;
|
|
146
|
-
const { html
|
|
418
|
+
const { html, plain } = content;
|
|
147
419
|
return {
|
|
148
|
-
workbook
|
|
149
|
-
worksheet
|
|
150
|
-
text:
|
|
151
|
-
html
|
|
152
|
-
fromSheet:
|
|
153
|
-
fromRange:
|
|
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
|
|
160
|
-
if (
|
|
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
|
|
167
|
-
if (
|
|
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(
|
|
171
|
-
if (!
|
|
442
|
+
_generateClipboardPasteParam(params) {
|
|
443
|
+
if (!params)
|
|
172
444
|
return;
|
|
173
|
-
const { htmlContent
|
|
174
|
-
return !
|
|
175
|
-
workbook
|
|
176
|
-
worksheet
|
|
177
|
-
text:
|
|
178
|
-
html:
|
|
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
|
|
183
|
-
if (!
|
|
454
|
+
const workbook = this.getActiveWorkbook(), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
455
|
+
if (!workbook || !worksheet)
|
|
184
456
|
return;
|
|
185
|
-
const
|
|
186
|
-
let
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
workbook
|
|
191
|
-
worksheet
|
|
192
|
-
text
|
|
193
|
-
html
|
|
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
|
|
468
|
+
return eventParams;
|
|
197
469
|
}
|
|
198
|
-
_beforeClipboardPaste(
|
|
470
|
+
_beforeClipboardPaste(params) {
|
|
199
471
|
if (!this.hasEventCallback(this.Event.BeforeClipboardPaste))
|
|
200
472
|
return;
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
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(
|
|
477
|
+
_clipboardPaste(params) {
|
|
206
478
|
if (!this.hasEventCallback(this.Event.BeforeClipboardPaste))
|
|
207
479
|
return;
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
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 (!
|
|
216
|
-
this._injector.get(
|
|
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
|
|
220
|
-
if (
|
|
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 (!
|
|
227
|
-
this._injector.get(
|
|
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
|
|
231
|
-
if (
|
|
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(
|
|
235
|
-
|
|
236
|
-
|
|
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
|
|
241
|
-
this._getSheetRenderComponent(
|
|
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(
|
|
244
|
-
const
|
|
245
|
-
if (!
|
|
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
|
|
250
|
-
this._getSheetRenderComponent(
|
|
522
|
+
const unitId = wb == null ? void 0 : wb.getId();
|
|
523
|
+
this._getSheetRenderComponent(unitId, SHEET_VIEW_KEY.ROW).setCustomHeader(cfg);
|
|
251
524
|
}
|
|
252
|
-
registerSheetRowHeaderExtension(
|
|
253
|
-
const
|
|
254
|
-
return
|
|
255
|
-
|
|
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(
|
|
259
|
-
const
|
|
260
|
-
return
|
|
261
|
-
|
|
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(
|
|
265
|
-
const
|
|
266
|
-
return
|
|
267
|
-
|
|
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(
|
|
278
|
-
const
|
|
279
|
-
if (!
|
|
280
|
-
throw new Error(`Render Unit with unitId ${
|
|
281
|
-
const { components
|
|
282
|
-
if (!
|
|
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
|
|
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(
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
return "
|
|
310
|
-
}
|
|
311
|
-
|
|
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
|
|
362
|
-
...
|
|
363
|
-
onClose: () => {
|
|
364
|
-
|
|
365
|
-
}
|
|
576
|
+
const disposable = this._injector.get(IDialogService).open({
|
|
577
|
+
...dialog,
|
|
578
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
579
|
+
disposable.dispose();
|
|
580
|
+
}, "onClose")
|
|
366
581
|
});
|
|
367
|
-
return
|
|
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
|
-
|
|
373
|
-
|
|
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(
|
|
429
|
-
const
|
|
587
|
+
generateCellParams(cell) {
|
|
588
|
+
const worksheet = this.getActiveSheet();
|
|
430
589
|
return {
|
|
431
|
-
row:
|
|
432
|
-
column:
|
|
590
|
+
row: cell.row,
|
|
591
|
+
column: cell.col,
|
|
433
592
|
workbook: this,
|
|
434
|
-
worksheet
|
|
593
|
+
worksheet
|
|
435
594
|
};
|
|
436
595
|
}
|
|
437
|
-
onCellClick(
|
|
438
|
-
const
|
|
439
|
-
return
|
|
440
|
-
|
|
441
|
-
|
|
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(
|
|
446
|
-
const
|
|
447
|
-
return
|
|
448
|
-
|
|
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(
|
|
452
|
-
const
|
|
453
|
-
return
|
|
454
|
-
|
|
610
|
+
onCellPointerDown(callback) {
|
|
611
|
+
const hoverManagerService = this._injector.get(HoverManagerService);
|
|
612
|
+
return toDisposable(
|
|
613
|
+
hoverManagerService.currentPointerDownCell$.subscribe(callback)
|
|
455
614
|
);
|
|
456
615
|
}
|
|
457
|
-
onCellPointerUp(
|
|
458
|
-
const
|
|
459
|
-
return
|
|
460
|
-
|
|
616
|
+
onCellPointerUp(callback) {
|
|
617
|
+
const hoverManagerService = this._injector.get(HoverManagerService);
|
|
618
|
+
return toDisposable(
|
|
619
|
+
hoverManagerService.currentPointerUpCell$.subscribe(callback)
|
|
461
620
|
);
|
|
462
621
|
}
|
|
463
|
-
onCellPointerMove(
|
|
464
|
-
const
|
|
465
|
-
return
|
|
466
|
-
|
|
467
|
-
|
|
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(
|
|
472
|
-
const
|
|
473
|
-
return
|
|
474
|
-
|
|
475
|
-
|
|
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(
|
|
480
|
-
const
|
|
481
|
-
return
|
|
482
|
-
|
|
483
|
-
|
|
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(
|
|
489
|
-
eventType:
|
|
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(
|
|
495
|
-
return this._injector.get(
|
|
496
|
-
eventType:
|
|
497
|
-
keycode:
|
|
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
|
|
659
|
+
}), await awaitTime(0), !0;
|
|
501
660
|
}
|
|
502
|
-
endEditingAsync(
|
|
503
|
-
return this.endEditing(
|
|
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(
|
|
515
|
-
const
|
|
516
|
-
return
|
|
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
|
|
520
|
-
return
|
|
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
|
|
524
|
-
return
|
|
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
|
|
528
|
-
return
|
|
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
|
|
532
|
-
return
|
|
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
|
-
|
|
536
|
-
|
|
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
|
|
539
|
-
if (!
|
|
540
|
-
throw new Error(`Render Unit with unitId ${
|
|
541
|
-
|
|
542
|
-
const
|
|
543
|
-
if (!
|
|
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
|
|
706
|
+
return mainComponent.makeDirty(), this;
|
|
546
707
|
}
|
|
547
|
-
zoom(
|
|
548
|
-
return this._injector.get(
|
|
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
|
|
712
|
+
zoomRatio
|
|
552
713
|
}), this;
|
|
553
714
|
}
|
|
554
715
|
getZoom() {
|
|
555
716
|
return this._worksheet.getZoomRatio();
|
|
556
717
|
}
|
|
557
718
|
getVisibleRange() {
|
|
558
|
-
const
|
|
559
|
-
let
|
|
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 (!
|
|
566
|
-
const
|
|
567
|
-
if (!
|
|
568
|
-
const
|
|
569
|
-
if (!
|
|
570
|
-
|
|
571
|
-
for (const [
|
|
572
|
-
|
|
573
|
-
return
|
|
574
|
-
}
|
|
575
|
-
scrollToCell(
|
|
576
|
-
const
|
|
577
|
-
return
|
|
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
|
|
741
|
+
const emptyScrollState = {
|
|
581
742
|
offsetX: 0,
|
|
582
743
|
offsetY: 0,
|
|
583
744
|
sheetViewStartColumn: 0,
|
|
584
745
|
sheetViewStartRow: 0
|
|
585
|
-
},
|
|
586
|
-
return
|
|
587
|
-
}
|
|
588
|
-
onScroll(
|
|
589
|
-
var
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
592
|
-
const
|
|
593
|
-
|
|
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
|
|
756
|
+
return toDisposable(sub);
|
|
596
757
|
}
|
|
597
|
-
return
|
|
758
|
+
return toDisposable(() => {
|
|
598
759
|
});
|
|
599
760
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
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
|
-
|
|
619
|
-
|
|
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
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
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
|
-
...(
|
|
628
|
-
...
|
|
812
|
+
...(cell == null ? void 0 : cell.customRender) || [],
|
|
813
|
+
...customRender || []
|
|
629
814
|
]
|
|
630
|
-
}),
|
|
631
|
-
priority
|
|
815
|
+
}), "handler"),
|
|
816
|
+
priority
|
|
632
817
|
});
|
|
633
818
|
}
|
|
634
|
-
onBeforeCellEdit(
|
|
635
|
-
return this._injector.get(
|
|
636
|
-
const
|
|
637
|
-
|
|
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(
|
|
641
|
-
return this._injector.get(
|
|
642
|
-
const
|
|
643
|
-
|
|
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
|
-
|
|
648
|
-
|
|
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
|
-
|
|
651
|
-
|
|
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:
|
|
655
|
-
return { ...
|
|
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
|
|
659
|
-
const
|
|
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 (
|
|
962
|
+
return (_a = copyContent == null ? void 0 : copyContent.html) != null ? _a : "";
|
|
665
963
|
}
|
|
666
|
-
attachPopup(
|
|
667
|
-
var
|
|
668
|
-
|
|
669
|
-
const { key
|
|
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
|
-
{ ...
|
|
970
|
+
{ ...popup, componentKey: key },
|
|
673
971
|
this.getUnitId(),
|
|
674
972
|
this._worksheet.getSheetId()
|
|
675
973
|
);
|
|
676
|
-
return
|
|
974
|
+
return disposePopup ? (disposableCollection.add(disposePopup), disposableCollection) : (disposableCollection.dispose(), null);
|
|
677
975
|
}
|
|
678
|
-
attachAlertPopup(
|
|
679
|
-
const
|
|
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
|
|
688
|
-
...
|
|
689
|
-
location
|
|
985
|
+
return cellAlertService.showAlert({
|
|
986
|
+
...alert,
|
|
987
|
+
location
|
|
690
988
|
}), {
|
|
691
|
-
dispose: () => {
|
|
692
|
-
|
|
693
|
-
}
|
|
989
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
990
|
+
cellAlertService.removeAlert(alert.key);
|
|
991
|
+
}, "dispose")
|
|
694
992
|
};
|
|
695
993
|
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
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
|
|
701
|
-
|
|
1021
|
+
return toDisposable(() => {
|
|
1022
|
+
markSelectionService.removeShape(id);
|
|
702
1023
|
});
|
|
703
1024
|
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
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
|
-
|
|
1040
|
+
transformComponentKey
|
|
717
1041
|
};
|