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