@univerjs/sheets-ui 0.5.4-nightly.202501200849 → 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 +612 -544
- package/lib/es/index.js +17075 -16674
- 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/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/render-controllers/freeze.render-controller.d.ts +6 -2
- package/lib/types/facade/f-event.d.ts +20 -5
- package/lib/types/facade/f-range.d.ts +24 -5
- package/lib/types/facade/f-univer.d.ts +4 -1
- package/lib/types/facade/f-workbook.d.ts +27 -1
- package/lib/types/facade/f-worksheet.d.ts +7 -2
- package/lib/types/services/clipboard/clipboard.service.d.ts +5 -2
- package/lib/types/services/clipboard/type.d.ts +9 -1
- package/lib/types/services/selection/base-selection-render.service.d.ts +1 -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/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/lib/es/facade.js
CHANGED
|
@@ -1,537 +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
|
-
if (
|
|
51
|
+
if (commandInfo.id === SetZoomRatioCommand.id) {
|
|
50
52
|
if (!this._eventListend(this.Event.BeforeSheetZoomChange))
|
|
51
53
|
return;
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
54
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
55
|
+
if (!target)
|
|
54
56
|
return;
|
|
55
|
-
const { workbook
|
|
57
|
+
const { workbook, worksheet } = target;
|
|
56
58
|
this.fireEvent(this.Event.BeforeSheetZoomChange, {
|
|
57
|
-
zoom:
|
|
58
|
-
workbook
|
|
59
|
-
worksheet
|
|
59
|
+
zoom: commandInfo.params.zoomRatio,
|
|
60
|
+
workbook,
|
|
61
|
+
worksheet
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
|
-
})), this.disposeWithMe(
|
|
63
|
-
if (
|
|
64
|
+
})), this.disposeWithMe(commandService.onCommandExecuted((commandInfo) => {
|
|
65
|
+
if (commandInfo.id === SetCellEditVisibleOperation.id) {
|
|
64
66
|
if (!this._eventListend(this.Event.SheetEditStarted) && !this._eventListend(this.Event.SheetEditEnded))
|
|
65
67
|
return;
|
|
66
|
-
const
|
|
67
|
-
if (!
|
|
68
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
69
|
+
if (!target)
|
|
68
70
|
return;
|
|
69
|
-
const { workbook
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
row:
|
|
73
|
-
column:
|
|
74
|
-
eventType
|
|
75
|
-
keycode
|
|
76
|
-
workbook
|
|
77
|
-
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,
|
|
78
80
|
isZenEditor: !1
|
|
79
81
|
};
|
|
80
|
-
this.fireEvent(this.Event.SheetEditStarted,
|
|
82
|
+
this.fireEvent(this.Event.SheetEditStarted, eventParams);
|
|
81
83
|
} else {
|
|
82
|
-
const
|
|
83
|
-
row:
|
|
84
|
-
column:
|
|
85
|
-
eventType
|
|
86
|
-
keycode
|
|
87
|
-
workbook
|
|
88
|
-
worksheet
|
|
84
|
+
const eventParams = {
|
|
85
|
+
row: loc.row,
|
|
86
|
+
column: loc.column,
|
|
87
|
+
eventType,
|
|
88
|
+
keycode,
|
|
89
|
+
workbook,
|
|
90
|
+
worksheet,
|
|
89
91
|
isZenEditor: !1,
|
|
90
|
-
isConfirm:
|
|
92
|
+
isConfirm: keycode !== KeyCode.ESC
|
|
91
93
|
};
|
|
92
|
-
this.fireEvent(this.Event.SheetEditEnded,
|
|
94
|
+
this.fireEvent(this.Event.SheetEditEnded, eventParams);
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
|
-
if (
|
|
97
|
+
if (commandInfo.id === RichTextEditingMutation.id) {
|
|
96
98
|
if (!this._eventListend(this.Event.SheetEditChanging))
|
|
97
99
|
return;
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
100
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
101
|
+
if (!target)
|
|
100
102
|
return;
|
|
101
|
-
const { workbook
|
|
102
|
-
if (!
|
|
103
|
-
const { unitId
|
|
104
|
-
if (
|
|
105
|
-
const { row
|
|
106
|
-
workbook
|
|
107
|
-
worksheet
|
|
108
|
-
row
|
|
109
|
-
column
|
|
110
|
-
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()),
|
|
111
113
|
isZenEditor: !1
|
|
112
114
|
};
|
|
113
|
-
this.fireEvent(this.Event.SheetEditChanging,
|
|
115
|
+
this.fireEvent(this.Event.SheetEditChanging, eventParams);
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
|
-
if (
|
|
118
|
+
if (commandInfo.id === SetZoomRatioCommand.id) {
|
|
117
119
|
if (!this._eventListend(this.Event.SheetZoomChanged))
|
|
118
120
|
return;
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
122
|
+
if (!target)
|
|
121
123
|
return;
|
|
122
|
-
const { workbook
|
|
124
|
+
const { workbook, worksheet } = target;
|
|
123
125
|
this.fireEvent(this.Event.SheetZoomChanged, {
|
|
124
|
-
zoom:
|
|
125
|
-
workbook
|
|
126
|
-
worksheet
|
|
126
|
+
zoom: worksheet.getZoom(),
|
|
127
|
+
workbook,
|
|
128
|
+
worksheet
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
|
-
})), this._initObserverListener(
|
|
131
|
+
})), this._initObserverListener(injector);
|
|
130
132
|
}
|
|
131
133
|
// eslint-disable-next-line max-lines-per-function
|
|
132
|
-
_initObserverListener(
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
136
|
-
this.disposeWithMe(
|
|
137
|
-
var
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
(
|
|
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) => {
|
|
143
145
|
if (!this._eventListend(this.Event.CellClicked)) return;
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
...
|
|
147
|
-
...
|
|
148
|
-
row:
|
|
149
|
-
column:
|
|
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
|
|
150
152
|
});
|
|
151
153
|
})
|
|
152
|
-
),
|
|
153
|
-
(
|
|
154
|
+
), disposable.add(
|
|
155
|
+
(_b = hoverManagerService.currentRichText$) == null ? void 0 : _b.pipe(filter((cell) => !!cell)).subscribe((cell) => {
|
|
154
156
|
if (!this._eventListend(this.Event.CellHover)) return;
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
...
|
|
158
|
-
...
|
|
159
|
-
row:
|
|
160
|
-
column:
|
|
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
|
|
161
163
|
});
|
|
162
164
|
})
|
|
163
|
-
),
|
|
164
|
-
(
|
|
165
|
+
), disposable.add(
|
|
166
|
+
(_c = hoverManagerService.currentPointerDownCell$) == null ? void 0 : _c.pipe(filter((cell) => !!cell)).subscribe((cell) => {
|
|
165
167
|
if (!this._eventListend(this.Event.CellPointerDown)) return;
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
...
|
|
169
|
-
...
|
|
170
|
-
row:
|
|
171
|
-
column:
|
|
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
|
|
172
174
|
});
|
|
173
175
|
})
|
|
174
|
-
),
|
|
175
|
-
(
|
|
176
|
+
), disposable.add(
|
|
177
|
+
(_d = hoverManagerService.currentPointerUpCell$) == null ? void 0 : _d.pipe(filter((cell) => !!cell)).subscribe((cell) => {
|
|
176
178
|
if (!this._eventListend(this.Event.CellPointerUp)) return;
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
...
|
|
180
|
-
...
|
|
181
|
-
row:
|
|
182
|
-
column:
|
|
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
|
|
183
185
|
});
|
|
184
186
|
})
|
|
185
|
-
),
|
|
186
|
-
(
|
|
187
|
+
), disposable.add(
|
|
188
|
+
(_e = hoverManagerService.currentCellPosWithEvent$) == null ? void 0 : _e.pipe(filter((cell) => !!cell)).subscribe((cell) => {
|
|
187
189
|
if (!this._eventListend(this.Event.CellPointerMove)) return;
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
...
|
|
191
|
-
...
|
|
192
|
-
row:
|
|
193
|
-
column:
|
|
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
|
|
194
196
|
});
|
|
195
197
|
})
|
|
196
|
-
),
|
|
197
|
-
(
|
|
198
|
+
), disposable.add(
|
|
199
|
+
(_f = dragManagerService.currentCell$) == null ? void 0 : _f.pipe(filter((cell) => !!cell)).subscribe((cell) => {
|
|
198
200
|
if (!this._eventListend(this.Event.DragOver)) return;
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
...
|
|
202
|
-
...
|
|
203
|
-
row:
|
|
204
|
-
column:
|
|
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
|
|
205
207
|
});
|
|
206
208
|
})
|
|
207
|
-
),
|
|
208
|
-
(
|
|
209
|
+
), disposable.add(
|
|
210
|
+
(_g = dragManagerService.endCell$) == null ? void 0 : _g.pipe(filter((cell) => !!cell)).subscribe((cell) => {
|
|
209
211
|
if (!this._eventListend(this.Event.Drop)) return;
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
...
|
|
213
|
-
...
|
|
214
|
-
row:
|
|
215
|
-
column:
|
|
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
|
|
216
218
|
});
|
|
217
219
|
})
|
|
218
|
-
),
|
|
219
|
-
(
|
|
220
|
+
), disposable.add(
|
|
221
|
+
(_h = hoverManagerService.currentRowHeaderClick$) == null ? void 0 : _h.pipe(filter((header) => !!header)).subscribe((header) => {
|
|
220
222
|
if (!this._eventListend(this.Event.RowHeaderClick)) return;
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
...
|
|
224
|
-
row:
|
|
223
|
+
const baseParams = this.getSheetTarget(header.unitId, header.subUnitId);
|
|
224
|
+
baseParams && this.fireEvent(this.Event.RowHeaderClick, {
|
|
225
|
+
...baseParams,
|
|
226
|
+
row: header.index
|
|
225
227
|
});
|
|
226
228
|
})
|
|
227
|
-
),
|
|
228
|
-
(
|
|
229
|
+
), disposable.add(
|
|
230
|
+
(_i = hoverManagerService.currentRowHeaderPointerDown$) == null ? void 0 : _i.pipe(filter((header) => !!header)).subscribe((header) => {
|
|
229
231
|
if (!this._eventListend(this.Event.RowHeaderPointerDown)) return;
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
...
|
|
233
|
-
row:
|
|
232
|
+
const baseParams = this.getSheetTarget(header.unitId, header.subUnitId);
|
|
233
|
+
baseParams && this.fireEvent(this.Event.RowHeaderPointerDown, {
|
|
234
|
+
...baseParams,
|
|
235
|
+
row: header.index
|
|
234
236
|
});
|
|
235
237
|
})
|
|
236
|
-
),
|
|
237
|
-
(
|
|
238
|
+
), disposable.add(
|
|
239
|
+
(_j = hoverManagerService.currentRowHeaderPointerUp$) == null ? void 0 : _j.pipe(filter((header) => !!header)).subscribe((header) => {
|
|
238
240
|
if (!this._eventListend(this.Event.RowHeaderPointerUp)) return;
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
...
|
|
242
|
-
row:
|
|
241
|
+
const baseParams = this.getSheetTarget(header.unitId, header.subUnitId);
|
|
242
|
+
baseParams && this.fireEvent(this.Event.RowHeaderPointerUp, {
|
|
243
|
+
...baseParams,
|
|
244
|
+
row: header.index
|
|
243
245
|
});
|
|
244
246
|
})
|
|
245
|
-
),
|
|
246
|
-
(
|
|
247
|
+
), disposable.add(
|
|
248
|
+
(_k = hoverManagerService.currentHoveredRowHeader$) == null ? void 0 : _k.pipe(filter((header) => !!header)).subscribe((header) => {
|
|
247
249
|
if (!this._eventListend(this.Event.RowHeaderHover)) return;
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
...
|
|
251
|
-
row:
|
|
250
|
+
const baseParams = this.getSheetTarget(header.unitId, header.subUnitId);
|
|
251
|
+
baseParams && this.fireEvent(this.Event.RowHeaderHover, {
|
|
252
|
+
...baseParams,
|
|
253
|
+
row: header.index
|
|
252
254
|
});
|
|
253
255
|
})
|
|
254
|
-
),
|
|
255
|
-
(
|
|
256
|
+
), disposable.add(
|
|
257
|
+
(_l = hoverManagerService.currentColHeaderClick$) == null ? void 0 : _l.pipe(filter((header) => !!header)).subscribe((header) => {
|
|
256
258
|
if (!this._eventListend(this.Event.ColumnHeaderClick)) return;
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
...
|
|
260
|
-
column:
|
|
259
|
+
const baseParams = this.getSheetTarget(header.unitId, header.subUnitId);
|
|
260
|
+
baseParams && this.fireEvent(this.Event.ColumnHeaderClick, {
|
|
261
|
+
...baseParams,
|
|
262
|
+
column: header.index
|
|
261
263
|
});
|
|
262
264
|
})
|
|
263
|
-
),
|
|
264
|
-
(
|
|
265
|
+
), disposable.add(
|
|
266
|
+
(_m = hoverManagerService.currentColHeaderPointerDown$) == null ? void 0 : _m.pipe(filter((header) => !!header)).subscribe((header) => {
|
|
265
267
|
if (!this._eventListend(this.Event.ColumnHeaderPointerDown)) return;
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
...
|
|
269
|
-
column:
|
|
268
|
+
const baseParams = this.getSheetTarget(header.unitId, header.subUnitId);
|
|
269
|
+
baseParams && this.fireEvent(this.Event.ColumnHeaderPointerDown, {
|
|
270
|
+
...baseParams,
|
|
271
|
+
column: header.index
|
|
270
272
|
});
|
|
271
273
|
})
|
|
272
|
-
),
|
|
273
|
-
(
|
|
274
|
+
), disposable.add(
|
|
275
|
+
(_n = hoverManagerService.currentColHeaderPointerUp$) == null ? void 0 : _n.pipe(filter((header) => !!header)).subscribe((header) => {
|
|
274
276
|
if (!this._eventListend(this.Event.ColumnHeaderPointerUp)) return;
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
...
|
|
278
|
-
column:
|
|
277
|
+
const baseParams = this.getSheetTarget(header.unitId, header.subUnitId);
|
|
278
|
+
baseParams && this.fireEvent(this.Event.ColumnHeaderPointerUp, {
|
|
279
|
+
...baseParams,
|
|
280
|
+
column: header.index
|
|
279
281
|
});
|
|
280
282
|
})
|
|
281
|
-
),
|
|
282
|
-
(
|
|
283
|
+
), disposable.add(
|
|
284
|
+
(_o = hoverManagerService.currentHoveredColHeader$) == null ? void 0 : _o.pipe(filter((header) => !!header)).subscribe((header) => {
|
|
283
285
|
if (!this._eventListend(this.Event.ColumnHeaderHover)) return;
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
...
|
|
287
|
-
column:
|
|
286
|
+
const baseParams = this.getSheetTarget(header.unitId, header.subUnitId);
|
|
287
|
+
baseParams && this.fireEvent(this.Event.ColumnHeaderHover, {
|
|
288
|
+
...baseParams,
|
|
289
|
+
column: header.index
|
|
288
290
|
});
|
|
289
291
|
})
|
|
290
292
|
));
|
|
291
|
-
})), this.disposeWithMe(
|
|
293
|
+
})), this.disposeWithMe(disposable);
|
|
292
294
|
}
|
|
293
|
-
const
|
|
294
|
-
let
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
295
|
+
const unitMap = /* @__PURE__ */ new Map();
|
|
296
|
+
let sheetRenderUnit;
|
|
297
|
+
const lifeCycleService = injector.get(LifecycleService), combined$ = combineLatest([
|
|
298
|
+
renderManagerService.created$,
|
|
299
|
+
lifeCycleService.lifecycle$
|
|
298
300
|
]);
|
|
299
|
-
this.disposeWithMe(
|
|
300
|
-
var
|
|
301
|
-
if (
|
|
302
|
-
const
|
|
303
|
-
if (!
|
|
304
|
-
const
|
|
305
|
-
if (!
|
|
306
|
-
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
workbook
|
|
311
|
-
worksheet:
|
|
312
|
-
...
|
|
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
|
|
313
315
|
});
|
|
314
316
|
}));
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
var
|
|
317
|
+
const selectionService = sheetRenderUnit.with(SheetsSelectionsService);
|
|
318
|
+
disposable.add(selectionService.selectionMoveStart$.subscribe((selections) => {
|
|
319
|
+
var _a2;
|
|
318
320
|
this._eventListend(this.Event.SelectionMoveStart) && this.fireEvent(this.Event.SelectionMoveStart, {
|
|
319
|
-
workbook
|
|
320
|
-
worksheet:
|
|
321
|
-
selections: (
|
|
321
|
+
workbook,
|
|
322
|
+
worksheet: workbook.getActiveSheet(),
|
|
323
|
+
selections: (_a2 = selections == null ? void 0 : selections.map((s) => s.range)) != null ? _a2 : []
|
|
322
324
|
});
|
|
323
|
-
})),
|
|
324
|
-
var
|
|
325
|
+
})), disposable.add(selectionService.selectionMoving$.subscribe((selections) => {
|
|
326
|
+
var _a2;
|
|
325
327
|
this._eventListend(this.Event.SelectionMoving) && this.fireEvent(this.Event.SelectionMoving, {
|
|
326
|
-
workbook
|
|
327
|
-
worksheet:
|
|
328
|
-
selections: (
|
|
328
|
+
workbook,
|
|
329
|
+
worksheet: workbook.getActiveSheet(),
|
|
330
|
+
selections: (_a2 = selections == null ? void 0 : selections.map((s) => s.range)) != null ? _a2 : []
|
|
329
331
|
});
|
|
330
|
-
})),
|
|
331
|
-
var
|
|
332
|
+
})), disposable.add(selectionService.selectionMoveEnd$.subscribe((selections) => {
|
|
333
|
+
var _a2;
|
|
332
334
|
this._eventListend(this.Event.SelectionMoveEnd) && this.fireEvent(this.Event.SelectionMoveEnd, {
|
|
333
|
-
workbook
|
|
334
|
-
worksheet:
|
|
335
|
-
selections: (
|
|
335
|
+
workbook,
|
|
336
|
+
worksheet: workbook.getActiveSheet(),
|
|
337
|
+
selections: (_a2 = selections == null ? void 0 : selections.map((s) => s.range)) != null ? _a2 : []
|
|
336
338
|
});
|
|
337
|
-
})),
|
|
338
|
-
var
|
|
339
|
+
})), disposable.add(selectionService.selectionChanged$.subscribe((selections) => {
|
|
340
|
+
var _a2;
|
|
339
341
|
this._eventListend(this.Event.SelectionChanged) && this.fireEvent(this.Event.SelectionChanged, {
|
|
340
|
-
workbook
|
|
341
|
-
worksheet:
|
|
342
|
-
selections: (
|
|
342
|
+
workbook,
|
|
343
|
+
worksheet: workbook.getActiveSheet(),
|
|
344
|
+
selections: (_a2 = selections == null ? void 0 : selections.map((s) => s.range)) != null ? _a2 : []
|
|
343
345
|
});
|
|
344
|
-
})),
|
|
345
|
-
})), this.disposeWithMe(
|
|
346
|
-
var
|
|
347
|
-
(
|
|
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);
|
|
348
350
|
})), this.disposeWithMe(() => {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
+
unitMap.forEach((disposable) => {
|
|
352
|
+
disposable.dispose();
|
|
351
353
|
});
|
|
352
354
|
});
|
|
353
355
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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:
|
|
361
366
|
this._beforeClipboardChange();
|
|
362
367
|
break;
|
|
363
|
-
case
|
|
364
|
-
this._beforeClipboardPaste(
|
|
368
|
+
case SheetPasteShortKeyCommand.id:
|
|
369
|
+
this._beforeClipboardPaste(commandInfo.params);
|
|
365
370
|
break;
|
|
366
371
|
}
|
|
367
|
-
})), this.disposeWithMe(
|
|
368
|
-
if (
|
|
372
|
+
})), this.disposeWithMe(commandService.onCommandExecuted((commandInfo) => {
|
|
373
|
+
if (COMMAND_LISTENER_SKELETON_CHANGE.indexOf(commandInfo.id) > -1) {
|
|
369
374
|
if (!this._eventListend(this.Event.SheetSkeletonChanged)) return;
|
|
370
|
-
const
|
|
371
|
-
if (!
|
|
372
|
-
const
|
|
373
|
-
var
|
|
374
|
-
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);
|
|
375
380
|
}).filter(Boolean);
|
|
376
|
-
if (!
|
|
381
|
+
if (!ranges.length) return;
|
|
377
382
|
this.fireEvent(this.Event.SheetSkeletonChanged, {
|
|
378
|
-
workbook:
|
|
379
|
-
worksheet:
|
|
380
|
-
payload:
|
|
381
|
-
skeleton:
|
|
382
|
-
effectedRanges:
|
|
383
|
+
workbook: sheet.workbook,
|
|
384
|
+
worksheet: sheet.worksheet,
|
|
385
|
+
payload: commandInfo,
|
|
386
|
+
skeleton: sheet.worksheet.getSkeleton(),
|
|
387
|
+
effectedRanges: ranges
|
|
383
388
|
});
|
|
384
389
|
return;
|
|
385
390
|
}
|
|
386
|
-
switch (
|
|
387
|
-
case
|
|
388
|
-
case
|
|
391
|
+
switch (commandInfo.id) {
|
|
392
|
+
case CopyCommand.id:
|
|
393
|
+
case CutCommand.id:
|
|
389
394
|
this._clipboardChanged();
|
|
390
395
|
break;
|
|
391
|
-
case
|
|
396
|
+
case SheetPasteShortKeyCommand.id:
|
|
392
397
|
this._clipboardPaste();
|
|
393
398
|
break;
|
|
394
|
-
case
|
|
399
|
+
case PasteCommand.id:
|
|
395
400
|
this._clipboardPasteAsync();
|
|
396
401
|
break;
|
|
397
402
|
}
|
|
398
|
-
})), this.disposeWithMe(
|
|
399
|
-
switch (
|
|
400
|
-
case
|
|
403
|
+
})), this.disposeWithMe(commandService.beforeCommandExecuted(async (commandInfo) => {
|
|
404
|
+
switch (commandInfo.id) {
|
|
405
|
+
case PasteCommand.id:
|
|
401
406
|
await this._beforeClipboardPasteAsync();
|
|
402
407
|
break;
|
|
403
408
|
}
|
|
404
409
|
}));
|
|
405
410
|
}
|
|
406
411
|
_generateClipboardCopyParam() {
|
|
407
|
-
const
|
|
408
|
-
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)
|
|
409
414
|
return;
|
|
410
|
-
const
|
|
411
|
-
if (!
|
|
415
|
+
const content = this._injector.get(ISheetClipboardService).generateCopyContent(workbook.getId(), worksheet.getSheetId(), range.getRange());
|
|
416
|
+
if (!content)
|
|
412
417
|
return;
|
|
413
|
-
const { html
|
|
418
|
+
const { html, plain } = content;
|
|
414
419
|
return {
|
|
415
|
-
workbook
|
|
416
|
-
worksheet
|
|
417
|
-
text:
|
|
418
|
-
html
|
|
419
|
-
fromSheet:
|
|
420
|
-
fromRange:
|
|
420
|
+
workbook,
|
|
421
|
+
worksheet,
|
|
422
|
+
text: plain,
|
|
423
|
+
html,
|
|
424
|
+
fromSheet: worksheet,
|
|
425
|
+
fromRange: range
|
|
421
426
|
};
|
|
422
427
|
}
|
|
423
428
|
_beforeClipboardChange() {
|
|
424
429
|
if (!this.hasEventCallback(this.Event.BeforeClipboardChange))
|
|
425
430
|
return;
|
|
426
|
-
const
|
|
427
|
-
if (
|
|
431
|
+
const eventParams = this._generateClipboardCopyParam();
|
|
432
|
+
if (eventParams && (this.fireEvent(this.Event.BeforeClipboardChange, eventParams), eventParams.cancel))
|
|
428
433
|
throw new Error("Before clipboard change is canceled");
|
|
429
434
|
}
|
|
430
435
|
_clipboardChanged() {
|
|
431
436
|
if (!this.hasEventCallback(this.Event.ClipboardChanged))
|
|
432
437
|
return;
|
|
433
|
-
const
|
|
434
|
-
if (
|
|
438
|
+
const eventParams = this._generateClipboardCopyParam();
|
|
439
|
+
if (eventParams && (this.fireEvent(this.Event.ClipboardChanged, eventParams), eventParams.cancel))
|
|
435
440
|
throw new Error("Clipboard changed is canceled");
|
|
436
441
|
}
|
|
437
|
-
_generateClipboardPasteParam(
|
|
438
|
-
if (!
|
|
442
|
+
_generateClipboardPasteParam(params) {
|
|
443
|
+
if (!params)
|
|
439
444
|
return;
|
|
440
|
-
const { htmlContent
|
|
441
|
-
return !
|
|
442
|
-
workbook
|
|
443
|
-
worksheet
|
|
444
|
-
text:
|
|
445
|
-
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
|
|
446
451
|
};
|
|
447
452
|
}
|
|
448
453
|
async _generateClipboardPasteParamAsync() {
|
|
449
|
-
const
|
|
450
|
-
if (!
|
|
454
|
+
const workbook = this.getActiveWorkbook(), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
455
|
+
if (!workbook || !worksheet)
|
|
451
456
|
return;
|
|
452
|
-
const
|
|
453
|
-
let
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
workbook
|
|
458
|
-
worksheet
|
|
459
|
-
text
|
|
460
|
-
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
|
|
461
466
|
};
|
|
462
467
|
}
|
|
463
|
-
return
|
|
468
|
+
return eventParams;
|
|
464
469
|
}
|
|
465
|
-
_beforeClipboardPaste(
|
|
470
|
+
_beforeClipboardPaste(params) {
|
|
466
471
|
if (!this.hasEventCallback(this.Event.BeforeClipboardPaste))
|
|
467
472
|
return;
|
|
468
|
-
const
|
|
469
|
-
if (
|
|
473
|
+
const eventParams = this._generateClipboardPasteParam(params);
|
|
474
|
+
if (eventParams && (this.fireEvent(this.Event.BeforeClipboardPaste, eventParams), eventParams.cancel))
|
|
470
475
|
throw new Error("Before clipboard paste is canceled");
|
|
471
476
|
}
|
|
472
|
-
_clipboardPaste(
|
|
477
|
+
_clipboardPaste(params) {
|
|
473
478
|
if (!this.hasEventCallback(this.Event.BeforeClipboardPaste))
|
|
474
479
|
return;
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
480
|
+
const eventParams = this._generateClipboardPasteParam(params);
|
|
481
|
+
if (eventParams && (this.fireEvent(this.Event.BeforeClipboardPaste, eventParams), eventParams.cancel))
|
|
477
482
|
throw new Error("Clipboard pasted is canceled");
|
|
478
483
|
}
|
|
479
484
|
async _beforeClipboardPasteAsync() {
|
|
480
485
|
if (!this.hasEventCallback(this.Event.BeforeClipboardPaste))
|
|
481
486
|
return;
|
|
482
|
-
if (!
|
|
483
|
-
this._injector.get(
|
|
487
|
+
if (!supportClipboardAPI()) {
|
|
488
|
+
this._injector.get(ILogService).warn("[Facade]: The navigator object only supports the browser environment");
|
|
484
489
|
return;
|
|
485
490
|
}
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
491
|
+
const eventParams = await this._generateClipboardPasteParamAsync();
|
|
492
|
+
if (eventParams && (this.fireEvent(this.Event.BeforeClipboardPaste, eventParams), eventParams.cancel))
|
|
488
493
|
throw new Error("Before clipboard paste is canceled");
|
|
489
494
|
}
|
|
490
495
|
async _clipboardPasteAsync() {
|
|
491
496
|
if (!this.hasEventCallback(this.Event.ClipboardPasted))
|
|
492
497
|
return;
|
|
493
|
-
if (!
|
|
494
|
-
this._injector.get(
|
|
498
|
+
if (!supportClipboardAPI()) {
|
|
499
|
+
this._injector.get(ILogService).warn("[Facade]: The navigator object only supports the browser environment");
|
|
495
500
|
return;
|
|
496
501
|
}
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
502
|
+
const eventParams = await this._generateClipboardPasteParamAsync();
|
|
503
|
+
if (eventParams && (this.fireEvent(this.Event.ClipboardPasted, eventParams), eventParams.cancel))
|
|
499
504
|
throw new Error("Clipboard pasted is canceled");
|
|
500
505
|
}
|
|
501
|
-
customizeColumnHeader(
|
|
502
|
-
|
|
503
|
-
|
|
506
|
+
customizeColumnHeader(cfg) {
|
|
507
|
+
var _a, _b;
|
|
508
|
+
const wb = this.getActiveWorkbook();
|
|
509
|
+
if (!wb) {
|
|
504
510
|
console.error("WorkBook not exist");
|
|
505
511
|
return;
|
|
506
512
|
}
|
|
507
|
-
const
|
|
508
|
-
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();
|
|
509
515
|
}
|
|
510
|
-
customizeRowHeader(
|
|
511
|
-
const
|
|
512
|
-
if (!
|
|
516
|
+
customizeRowHeader(cfg) {
|
|
517
|
+
const wb = this.getActiveWorkbook();
|
|
518
|
+
if (!wb) {
|
|
513
519
|
console.error("WorkBook not exist");
|
|
514
520
|
return;
|
|
515
521
|
}
|
|
516
|
-
const
|
|
517
|
-
this._getSheetRenderComponent(
|
|
522
|
+
const unitId = wb == null ? void 0 : wb.getId();
|
|
523
|
+
this._getSheetRenderComponent(unitId, SHEET_VIEW_KEY.ROW).setCustomHeader(cfg);
|
|
518
524
|
}
|
|
519
|
-
registerSheetRowHeaderExtension(
|
|
520
|
-
const
|
|
521
|
-
return
|
|
522
|
-
|
|
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);
|
|
523
529
|
});
|
|
524
530
|
}
|
|
525
|
-
registerSheetColumnHeaderExtension(
|
|
526
|
-
const
|
|
527
|
-
return
|
|
528
|
-
|
|
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);
|
|
529
535
|
});
|
|
530
536
|
}
|
|
531
|
-
registerSheetMainExtension(
|
|
532
|
-
const
|
|
533
|
-
return
|
|
534
|
-
|
|
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);
|
|
535
541
|
});
|
|
536
542
|
}
|
|
537
543
|
/**
|
|
@@ -541,81 +547,119 @@ class Fe extends ue {
|
|
|
541
547
|
* @param {SHEET_VIEW_KEY} viewKey The view key of the spreadsheet.
|
|
542
548
|
* @returns {Nullable<RenderComponentType>} The render component.
|
|
543
549
|
*/
|
|
544
|
-
_getSheetRenderComponent(
|
|
545
|
-
const
|
|
546
|
-
if (!
|
|
547
|
-
throw new Error(`Render Unit with unitId ${
|
|
548
|
-
const { components
|
|
549
|
-
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)
|
|
550
556
|
throw new Error("Render component not found");
|
|
551
|
-
return
|
|
557
|
+
return renderComponent;
|
|
552
558
|
}
|
|
553
559
|
/**
|
|
554
560
|
* Get sheet hooks.
|
|
555
561
|
* @returns {FSheetHooks} FSheetHooks instance
|
|
556
562
|
*/
|
|
557
563
|
getSheetHooks() {
|
|
558
|
-
return this._injector.createInstance(
|
|
564
|
+
return this._injector.createInstance(FSheetHooks);
|
|
559
565
|
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
566
|
+
};
|
|
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) {
|
|
567
575
|
this._logDeprecation("openDialog");
|
|
568
|
-
const
|
|
569
|
-
...
|
|
570
|
-
onClose: () => {
|
|
571
|
-
|
|
572
|
-
}
|
|
576
|
+
const disposable = this._injector.get(IDialogService).open({
|
|
577
|
+
...dialog,
|
|
578
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
579
|
+
disposable.dispose();
|
|
580
|
+
}, "onClose")
|
|
573
581
|
});
|
|
574
|
-
return
|
|
582
|
+
return disposable;
|
|
575
583
|
}
|
|
576
|
-
_logDeprecation(
|
|
577
|
-
this._injector.get(
|
|
584
|
+
_logDeprecation(name) {
|
|
585
|
+
this._injector.get(ILogService).warn("[FWorkbook]", `${name} is deprecated. Please use the function of the same name on "FUniver".`);
|
|
578
586
|
}
|
|
579
|
-
generateCellParams(
|
|
580
|
-
const
|
|
587
|
+
generateCellParams(cell) {
|
|
588
|
+
const worksheet = this.getActiveSheet();
|
|
581
589
|
return {
|
|
582
|
-
row:
|
|
583
|
-
column:
|
|
590
|
+
row: cell.row,
|
|
591
|
+
column: cell.col,
|
|
584
592
|
workbook: this,
|
|
585
|
-
worksheet
|
|
593
|
+
worksheet
|
|
586
594
|
};
|
|
587
595
|
}
|
|
588
|
-
onCellClick(
|
|
589
|
-
const
|
|
590
|
-
return
|
|
591
|
-
|
|
592
|
-
|
|
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);
|
|
601
|
+
})
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
onCellHover(callback) {
|
|
605
|
+
const hoverManagerService = this._injector.get(HoverManagerService);
|
|
606
|
+
return toDisposable(
|
|
607
|
+
hoverManagerService.currentRichText$.pipe(filter((cell) => !!cell)).subscribe(callback)
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
onCellPointerDown(callback) {
|
|
611
|
+
const hoverManagerService = this._injector.get(HoverManagerService);
|
|
612
|
+
return toDisposable(
|
|
613
|
+
hoverManagerService.currentPointerDownCell$.subscribe(callback)
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
onCellPointerUp(callback) {
|
|
617
|
+
const hoverManagerService = this._injector.get(HoverManagerService);
|
|
618
|
+
return toDisposable(
|
|
619
|
+
hoverManagerService.currentPointerUpCell$.subscribe(callback)
|
|
620
|
+
);
|
|
621
|
+
}
|
|
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);
|
|
593
627
|
})
|
|
594
628
|
);
|
|
595
629
|
}
|
|
596
|
-
|
|
597
|
-
const
|
|
598
|
-
return
|
|
599
|
-
|
|
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);
|
|
635
|
+
})
|
|
636
|
+
);
|
|
637
|
+
}
|
|
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);
|
|
643
|
+
})
|
|
600
644
|
);
|
|
601
645
|
}
|
|
602
646
|
startEditing() {
|
|
603
|
-
return this._injector.get(
|
|
604
|
-
eventType:
|
|
647
|
+
return this._injector.get(ICommandService).syncExecuteCommand(SetCellEditVisibleOperation.id, {
|
|
648
|
+
eventType: DeviceInputEventType.Dblclick,
|
|
605
649
|
unitId: this._workbook.getUnitId(),
|
|
606
650
|
visible: !0
|
|
607
651
|
});
|
|
608
652
|
}
|
|
609
|
-
async endEditing(
|
|
610
|
-
return this._injector.get(
|
|
611
|
-
eventType:
|
|
612
|
-
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,
|
|
613
657
|
visible: !1,
|
|
614
658
|
unitId: this._workbook.getUnitId()
|
|
615
|
-
}), await
|
|
659
|
+
}), await awaitTime(0), !0;
|
|
616
660
|
}
|
|
617
|
-
endEditingAsync(
|
|
618
|
-
return this.endEditing(
|
|
661
|
+
endEditingAsync(save = !0) {
|
|
662
|
+
return this.endEditing(save);
|
|
619
663
|
}
|
|
620
664
|
/**
|
|
621
665
|
* Get scroll state of specified sheet.
|
|
@@ -626,149 +670,169 @@ class Ne extends Ce {
|
|
|
626
670
|
* univerAPI.getActiveWorkbook().getScrollStateBySheetId($sheetId)
|
|
627
671
|
* ```
|
|
628
672
|
*/
|
|
629
|
-
getScrollStateBySheetId(
|
|
630
|
-
const
|
|
631
|
-
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;
|
|
632
676
|
}
|
|
633
677
|
disableSelection() {
|
|
634
|
-
const
|
|
635
|
-
return
|
|
678
|
+
const unitId = this._workbook.getUnitId(), render = this._injector.get(IRenderManagerService).getRenderById(unitId);
|
|
679
|
+
return render && render.with(ISheetSelectionRenderService).disableSelection(), this;
|
|
636
680
|
}
|
|
637
681
|
enableSelection() {
|
|
638
|
-
const
|
|
639
|
-
return
|
|
682
|
+
const unitId = this._workbook.getUnitId(), render = this._injector.get(IRenderManagerService).getRenderById(unitId);
|
|
683
|
+
return render && render.with(ISheetSelectionRenderService).enableSelection(), this;
|
|
640
684
|
}
|
|
641
685
|
transparentSelection() {
|
|
642
|
-
const
|
|
643
|
-
return
|
|
686
|
+
const unitId = this._workbook.getUnitId(), render = this._injector.get(IRenderManagerService).getRenderById(unitId);
|
|
687
|
+
return render && render.with(ISheetSelectionRenderService).transparentSelection(), this;
|
|
644
688
|
}
|
|
645
689
|
showSelection() {
|
|
646
|
-
const
|
|
647
|
-
return
|
|
690
|
+
const unitId = this._workbook.getUnitId(), render = this._injector.get(IRenderManagerService).getRenderById(unitId);
|
|
691
|
+
return render && render.with(ISheetSelectionRenderService).showSelection(), this;
|
|
648
692
|
}
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
|
|
693
|
+
};
|
|
694
|
+
__name(_FWorkbookSheetsUIMixin, "FWorkbookSheetsUIMixin");
|
|
695
|
+
let FWorkbookSheetsUIMixin = _FWorkbookSheetsUIMixin;
|
|
696
|
+
FWorkbook.extend(FWorkbookSheetsUIMixin);
|
|
697
|
+
const _FWorksheetSkeletonMixin = class _FWorksheetSkeletonMixin extends FWorksheet {
|
|
652
698
|
refreshCanvas() {
|
|
653
|
-
const
|
|
654
|
-
if (!
|
|
655
|
-
throw new Error(`Render Unit with unitId ${
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
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)
|
|
659
705
|
throw new Error("Main component not found");
|
|
660
|
-
return
|
|
706
|
+
return mainComponent.makeDirty(), this;
|
|
661
707
|
}
|
|
662
|
-
zoom(
|
|
663
|
-
return this._injector.get(
|
|
708
|
+
zoom(zoomRatio) {
|
|
709
|
+
return this._injector.get(ICommandService).syncExecuteCommand(ChangeZoomRatioCommand.id, {
|
|
664
710
|
unitId: this._workbook.getUnitId(),
|
|
665
711
|
subUnitId: this._worksheet.getSheetId(),
|
|
666
|
-
zoomRatio
|
|
712
|
+
zoomRatio
|
|
667
713
|
}), this;
|
|
668
714
|
}
|
|
669
715
|
getZoom() {
|
|
670
716
|
return this._worksheet.getZoomRatio();
|
|
671
717
|
}
|
|
672
718
|
getVisibleRange() {
|
|
673
|
-
const
|
|
674
|
-
let
|
|
719
|
+
const unitId = this._workbook.getUnitId(), render = this._injector.get(IRenderManagerService).getRenderById(unitId);
|
|
720
|
+
let range = {
|
|
675
721
|
startColumn: 0,
|
|
676
722
|
startRow: 0,
|
|
677
723
|
endColumn: 0,
|
|
678
724
|
endRow: 0
|
|
679
725
|
};
|
|
680
|
-
if (!
|
|
681
|
-
const
|
|
682
|
-
if (!
|
|
683
|
-
const
|
|
684
|
-
if (!
|
|
685
|
-
|
|
686
|
-
for (const [
|
|
687
|
-
|
|
688
|
-
return
|
|
689
|
-
}
|
|
690
|
-
scrollToCell(
|
|
691
|
-
const
|
|
692
|
-
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;
|
|
693
739
|
}
|
|
694
740
|
getScrollState() {
|
|
695
|
-
const
|
|
741
|
+
const emptyScrollState = {
|
|
696
742
|
offsetX: 0,
|
|
697
743
|
offsetY: 0,
|
|
698
744
|
sheetViewStartColumn: 0,
|
|
699
745
|
sheetViewStartRow: 0
|
|
700
|
-
},
|
|
701
|
-
return
|
|
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);
|
|
755
|
+
});
|
|
756
|
+
return toDisposable(sub);
|
|
757
|
+
}
|
|
758
|
+
return toDisposable(() => {
|
|
759
|
+
});
|
|
702
760
|
}
|
|
703
761
|
getSkeleton() {
|
|
704
|
-
var
|
|
705
|
-
const
|
|
706
|
-
return (
|
|
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;
|
|
707
765
|
}
|
|
708
|
-
setColumnAutoWidth(
|
|
709
|
-
const
|
|
766
|
+
setColumnAutoWidth(columnPosition, numColumn) {
|
|
767
|
+
const unitId = this._workbook.getUnitId(), subUnitId = this._worksheet.getSheetId(), ranges = [
|
|
710
768
|
{
|
|
711
|
-
startColumn:
|
|
712
|
-
endColumn:
|
|
769
|
+
startColumn: columnPosition,
|
|
770
|
+
endColumn: columnPosition + numColumn - 1,
|
|
713
771
|
startRow: 0,
|
|
714
772
|
endRow: this._worksheet.getRowCount() - 1
|
|
715
773
|
}
|
|
716
774
|
];
|
|
717
|
-
return this._commandService.syncExecuteCommand(
|
|
718
|
-
unitId
|
|
719
|
-
subUnitId
|
|
720
|
-
ranges
|
|
775
|
+
return this._commandService.syncExecuteCommand(SetWorksheetColAutoWidthCommand.id, {
|
|
776
|
+
unitId,
|
|
777
|
+
subUnitId,
|
|
778
|
+
ranges
|
|
721
779
|
}), this;
|
|
722
780
|
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
fe.extend(Ze);
|
|
731
|
-
class Ke extends O {
|
|
732
|
-
onCellPointerMove(e) {
|
|
733
|
-
return E(this._injector.get(y).currentPosition$.subscribe(e));
|
|
734
|
-
}
|
|
735
|
-
onCellPointerOver(e) {
|
|
736
|
-
return E(this._injector.get(y).currentCell$.subscribe(e));
|
|
737
|
-
}
|
|
738
|
-
onCellDragOver(e) {
|
|
739
|
-
return E(this._injector.get(W).currentCell$.subscribe(e));
|
|
740
|
-
}
|
|
741
|
-
onCellDrop(e) {
|
|
742
|
-
return E(this._injector.get(W).endCell$.subscribe(e));
|
|
781
|
+
};
|
|
782
|
+
__name(_FWorksheetSkeletonMixin, "FWorksheetSkeletonMixin");
|
|
783
|
+
let FWorksheetSkeletonMixin = _FWorksheetSkeletonMixin;
|
|
784
|
+
FWorksheet.extend(FWorksheetSkeletonMixin);
|
|
785
|
+
const _FPermissionSheetsUIMixin = class _FPermissionSheetsUIMixin extends FPermission {
|
|
786
|
+
setPermissionDialogVisible(visible) {
|
|
787
|
+
this._permissionService.setShowComponents(visible);
|
|
743
788
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
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,
|
|
749
811
|
customRender: [
|
|
750
|
-
...(
|
|
751
|
-
...
|
|
812
|
+
...(cell == null ? void 0 : cell.customRender) || [],
|
|
813
|
+
...customRender || []
|
|
752
814
|
]
|
|
753
|
-
}),
|
|
754
|
-
priority
|
|
815
|
+
}), "handler"),
|
|
816
|
+
priority
|
|
755
817
|
});
|
|
756
818
|
}
|
|
757
|
-
onBeforeCellEdit(
|
|
758
|
-
return this._injector.get(
|
|
759
|
-
const
|
|
760
|
-
|
|
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);
|
|
761
823
|
});
|
|
762
824
|
}
|
|
763
|
-
onAfterCellEdit(
|
|
764
|
-
return this._injector.get(
|
|
765
|
-
const
|
|
766
|
-
|
|
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);
|
|
767
829
|
});
|
|
768
830
|
}
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
|
|
831
|
+
};
|
|
832
|
+
__name(_FSheetHooksUIMixin, "FSheetHooksUIMixin");
|
|
833
|
+
let FSheetHooksUIMixin = _FSheetHooksUIMixin;
|
|
834
|
+
FSheetHooks.extend(FSheetHooksUIMixin);
|
|
835
|
+
const CellFEventName = {
|
|
772
836
|
CellClicked: "CellClicked",
|
|
773
837
|
CellPointerDown: "CellPointerDown",
|
|
774
838
|
CellPointerUp: "CellPointerUp",
|
|
@@ -781,8 +845,7 @@ const M = {
|
|
|
781
845
|
SelectionMoving: "SelectionMoving",
|
|
782
846
|
SelectionMoveEnd: "SelectionMoveEnd",
|
|
783
847
|
SelectionChanged: "SelectionChanged"
|
|
784
|
-
}
|
|
785
|
-
class ze extends ve {
|
|
848
|
+
}, _FSheetsUIEventName = class _FSheetsUIEventName extends FEventName {
|
|
786
849
|
get BeforeClipboardChange() {
|
|
787
850
|
return "BeforeClipboardChange";
|
|
788
851
|
}
|
|
@@ -811,19 +874,19 @@ class ze extends ve {
|
|
|
811
874
|
return "SheetEditEnded";
|
|
812
875
|
}
|
|
813
876
|
get CellClicked() {
|
|
814
|
-
return
|
|
877
|
+
return CellFEventName.CellClicked;
|
|
815
878
|
}
|
|
816
879
|
get CellHover() {
|
|
817
|
-
return
|
|
880
|
+
return CellFEventName.CellHover;
|
|
818
881
|
}
|
|
819
882
|
get CellPointerDown() {
|
|
820
|
-
return
|
|
883
|
+
return CellFEventName.CellPointerDown;
|
|
821
884
|
}
|
|
822
885
|
get CellPointerUp() {
|
|
823
|
-
return
|
|
886
|
+
return CellFEventName.CellPointerUp;
|
|
824
887
|
}
|
|
825
888
|
get CellPointerMove() {
|
|
826
|
-
return
|
|
889
|
+
return CellFEventName.CellPointerMove;
|
|
827
890
|
}
|
|
828
891
|
get DragOver() {
|
|
829
892
|
return "DragOver";
|
|
@@ -873,43 +936,45 @@ class ze extends ve {
|
|
|
873
936
|
get SheetSkeletonChanged() {
|
|
874
937
|
return "SheetSkeletonChanged";
|
|
875
938
|
}
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
|
|
939
|
+
};
|
|
940
|
+
__name(_FSheetsUIEventName, "FSheetsUIEventName");
|
|
941
|
+
let FSheetsUIEventName = _FSheetsUIEventName;
|
|
942
|
+
FEventName.extend(FSheetsUIEventName);
|
|
943
|
+
const _FRangeSheetsUIMixin = class _FRangeSheetsUIMixin extends FRange {
|
|
879
944
|
getCell() {
|
|
880
|
-
var
|
|
881
|
-
const
|
|
882
|
-
if (!
|
|
883
|
-
throw
|
|
884
|
-
return
|
|
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);
|
|
885
950
|
}
|
|
886
951
|
getCellRect() {
|
|
887
|
-
const { startX:
|
|
888
|
-
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") };
|
|
889
954
|
}
|
|
890
955
|
generateHTML() {
|
|
891
|
-
var
|
|
892
|
-
const
|
|
956
|
+
var _a;
|
|
957
|
+
const copyContent = this._injector.get(ISheetClipboardService).generateCopyContent(
|
|
893
958
|
this._workbook.getUnitId(),
|
|
894
959
|
this._worksheet.getSheetId(),
|
|
895
960
|
this._range
|
|
896
961
|
);
|
|
897
|
-
return (
|
|
962
|
+
return (_a = copyContent == null ? void 0 : copyContent.html) != null ? _a : "";
|
|
898
963
|
}
|
|
899
|
-
attachPopup(
|
|
900
|
-
var
|
|
901
|
-
|
|
902
|
-
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(
|
|
903
968
|
this._range.startRow,
|
|
904
969
|
this._range.startColumn,
|
|
905
|
-
{ ...
|
|
970
|
+
{ ...popup, componentKey: key },
|
|
906
971
|
this.getUnitId(),
|
|
907
972
|
this._worksheet.getSheetId()
|
|
908
973
|
);
|
|
909
|
-
return
|
|
974
|
+
return disposePopup ? (disposableCollection.add(disposePopup), disposableCollection) : (disposableCollection.dispose(), null);
|
|
910
975
|
}
|
|
911
|
-
attachAlertPopup(
|
|
912
|
-
const
|
|
976
|
+
attachAlertPopup(alert) {
|
|
977
|
+
const cellAlertService = this._injector.get(CellAlertManagerService), location = {
|
|
913
978
|
workbook: this._workbook,
|
|
914
979
|
worksheet: this._worksheet,
|
|
915
980
|
row: this._range.startRow,
|
|
@@ -917,13 +982,13 @@ class Ye extends be {
|
|
|
917
982
|
unitId: this.getUnitId(),
|
|
918
983
|
subUnitId: this._worksheet.getSheetId()
|
|
919
984
|
};
|
|
920
|
-
return
|
|
921
|
-
...
|
|
922
|
-
location
|
|
985
|
+
return cellAlertService.showAlert({
|
|
986
|
+
...alert,
|
|
987
|
+
location
|
|
923
988
|
}), {
|
|
924
|
-
dispose: () => {
|
|
925
|
-
|
|
926
|
-
}
|
|
989
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
990
|
+
cellAlertService.removeAlert(alert.key);
|
|
991
|
+
}, "dispose")
|
|
927
992
|
};
|
|
928
993
|
}
|
|
929
994
|
/**
|
|
@@ -938,36 +1003,39 @@ class Ye extends be {
|
|
|
938
1003
|
extraProps: { alert: { type: 0, title: 'This is an Info', message: 'This is an info message' } },
|
|
939
1004
|
});
|
|
940
1005
|
*/
|
|
941
|
-
attachRangePopup(
|
|
942
|
-
var
|
|
943
|
-
|
|
944
|
-
const { key
|
|
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(
|
|
945
1010
|
this._range,
|
|
946
|
-
{ ...
|
|
1011
|
+
{ ...popup, componentKey: key },
|
|
947
1012
|
this.getUnitId(),
|
|
948
1013
|
this._worksheet.getSheetId()
|
|
949
1014
|
);
|
|
950
|
-
return
|
|
1015
|
+
return disposePopup ? (disposableCollection.add(disposePopup), disposableCollection) : (disposableCollection.dispose(), null);
|
|
951
1016
|
}
|
|
952
|
-
highlight(
|
|
953
|
-
const
|
|
954
|
-
if (!
|
|
1017
|
+
highlight(style, primary) {
|
|
1018
|
+
const markSelectionService = this._injector.get(IMarkSelectionService), id = markSelectionService.addShape({ range: this._range, style, primary });
|
|
1019
|
+
if (!id)
|
|
955
1020
|
throw new Error("Failed to highlight current range");
|
|
956
|
-
return
|
|
957
|
-
|
|
1021
|
+
return toDisposable(() => {
|
|
1022
|
+
markSelectionService.removeShape(id);
|
|
958
1023
|
});
|
|
959
1024
|
}
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
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
|
|
969
1036
|
};
|
|
970
1037
|
}
|
|
1038
|
+
__name(transformComponentKey, "transformComponentKey");
|
|
971
1039
|
export {
|
|
972
|
-
|
|
1040
|
+
transformComponentKey
|
|
973
1041
|
};
|