@univerjs/sheets-ui 0.15.4 → 0.15.5
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 +16 -16
- package/lib/es/facade.js +84 -103
- package/lib/es/index.js +13265 -14584
- package/lib/facade.js +84 -103
- package/lib/index.js +13265 -14584
- package/lib/types/controllers/{auto-fill.controller.d.ts → auto-fill-ui.controller.d.ts} +5 -17
- package/lib/types/controllers/auto-height.controller.d.ts +0 -1
- package/lib/types/controllers/auto-width.controller.d.ts +0 -1
- package/lib/types/controllers/clipboard/utils.d.ts +1 -1
- package/lib/types/controllers/permission/sheet-permission-check-ui.controller.d.ts +1 -4
- package/lib/types/controllers/utils/range-tools.d.ts +2 -7
- package/lib/types/facade/f-range.d.ts +1 -40
- package/lib/types/index.d.ts +3 -10
- package/lib/types/services/clipboard/clipboard.service.d.ts +1 -2
- package/lib/types/services/clipboard/copy-content-cache.d.ts +1 -1
- package/lib/types/services/clipboard/type.d.ts +1 -1
- package/lib/types/services/clipboard/usm-to-html/convertor.d.ts +1 -1
- package/lib/types/services/clipboard/utils.d.ts +1 -2
- package/lib/types/views/auto-fill-popup-menu/AutoFillPopupMenu.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +15 -15
- package/package.json +12 -12
- package/lib/types/commands/commands/auto-fill.command.d.ts +0 -15
- package/lib/types/commands/commands/refill.command.d.ts +0 -2
- package/lib/types/services/auto-fill/auto-fill.service.d.ts +0 -76
- package/lib/types/services/auto-fill/rules.d.ts +0 -10
- package/lib/types/services/auto-fill/tools.d.ts +0 -115
- package/lib/types/services/auto-fill/type.d.ts +0 -70
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { Disposable, ICommandService,
|
|
1
|
+
import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
3
|
-
import { IAutoFillService } from '
|
|
3
|
+
import { AutoFillController, IAutoFillService } from '@univerjs/sheets';
|
|
4
4
|
import { IEditorBridgeService } from '../services/editor-bridge.service';
|
|
5
5
|
import { SheetsRenderService } from '../services/sheets-render.service';
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class AutoFillUIController extends Disposable {
|
|
7
7
|
private readonly _univerInstanceService;
|
|
8
8
|
private readonly _commandService;
|
|
9
9
|
private readonly _autoFillService;
|
|
10
|
+
private _autoFillController;
|
|
10
11
|
private readonly _editorBridgeService;
|
|
11
12
|
private readonly _renderManagerService;
|
|
12
|
-
private readonly _injector;
|
|
13
13
|
private _sheetsRenderService;
|
|
14
|
-
private _beforeApplyData;
|
|
15
14
|
private _currentLocation;
|
|
16
|
-
|
|
17
|
-
private _defaultHook;
|
|
18
|
-
constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _autoFillService: IAutoFillService, _editorBridgeService: IEditorBridgeService, _renderManagerService: IRenderManagerService, _injector: Injector, _sheetsRenderService: SheetsRenderService);
|
|
15
|
+
constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _autoFillService: IAutoFillService, _autoFillController: AutoFillController, _editorBridgeService: IEditorBridgeService, _renderManagerService: IRenderManagerService, _sheetsRenderService: SheetsRenderService);
|
|
19
16
|
private _init;
|
|
20
17
|
private _initSkeletonChange;
|
|
21
18
|
private _initDefaultHook;
|
|
@@ -24,13 +21,4 @@ export declare class AutoFillController extends Disposable {
|
|
|
24
21
|
private _initSelectionControlFillChanged;
|
|
25
22
|
private _handleDbClickFill;
|
|
26
23
|
private _detectFillRange;
|
|
27
|
-
private _getApplyData;
|
|
28
|
-
private _applyFunctions;
|
|
29
|
-
private _getCopyData;
|
|
30
|
-
private _getEmptyCopyDataPiece;
|
|
31
|
-
private _getMergeApplyData;
|
|
32
|
-
private _presetAndCacheData;
|
|
33
|
-
private _fillData;
|
|
34
|
-
private _shouldDisableSeries;
|
|
35
|
-
private _getPreferredApplyType;
|
|
36
24
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IRange, ObjectMatrix, Disposable, IConfigService, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { RenderManagerService } from '@univerjs/engine-render';
|
|
3
3
|
import { SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
|
|
4
|
-
export declare const AFFECT_LAYOUT_STYLES: string[];
|
|
5
4
|
export declare class AutoHeightController extends Disposable {
|
|
6
5
|
private readonly _renderManagerService;
|
|
7
6
|
private readonly _sheetInterceptorService;
|
|
@@ -2,7 +2,6 @@ import { Worksheet, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
|
2
2
|
import { RenderManagerService } from '@univerjs/engine-render';
|
|
3
3
|
import { ISetWorksheetColWidthMutationParams } from '@univerjs/sheets';
|
|
4
4
|
import { ISetWorksheetColIsAutoWidthCommandParams } from '../commands/commands/set-worksheet-auto-col-width.command';
|
|
5
|
-
export declare const AFFECT_LAYOUT_STYLES: string[];
|
|
6
5
|
export declare const createAutoColWidthUndoMutationsByRedos: (params: ISetWorksheetColWidthMutationParams, worksheet: Worksheet) => ISetWorksheetColWidthMutationParams;
|
|
7
6
|
export declare class AutoWidthController extends Disposable {
|
|
8
7
|
private readonly _renderManagerService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IAccessor, IDocumentBody, IMutationInfo, Nullable, ObjectMatrix } from '@univerjs/core';
|
|
2
|
+
import { IDiscreteRange } from '@univerjs/sheets';
|
|
2
3
|
import { ICellDataWithSpanInfo, ICopyPastePayload, ISheetDiscreteRangeLocation } from '../../services/clipboard/type';
|
|
3
|
-
import { IDiscreteRange } from '../utils/range-tools';
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param pasteFrom
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { Disposable, DisposableCollection, ICommandService, IContextService, IPermissionService, IUniverInstanceService, LocaleService } from '@univerjs/core';
|
|
2
2
|
import { RangeProtectionRuleModel, SheetPermissionCheckController } from '@univerjs/sheets';
|
|
3
3
|
import { IDialogService } from '@univerjs/ui';
|
|
4
|
-
import { IAutoFillService } from '../../services/auto-fill/auto-fill.service';
|
|
5
4
|
export declare class SheetPermissionCheckUIController extends Disposable {
|
|
6
5
|
private readonly _commandService;
|
|
7
6
|
private readonly _univerInstanceService;
|
|
8
7
|
private readonly _permissionService;
|
|
9
8
|
private readonly _dialogService;
|
|
10
9
|
private _rangeProtectionRuleModel;
|
|
11
|
-
private _autoFillService;
|
|
12
10
|
private readonly _localeService;
|
|
13
11
|
private readonly _contextService;
|
|
14
12
|
private readonly _sheetPermissionCheckController;
|
|
15
13
|
disposableCollection: DisposableCollection;
|
|
16
|
-
constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _permissionService: IPermissionService, _dialogService: IDialogService, _rangeProtectionRuleModel: RangeProtectionRuleModel,
|
|
14
|
+
constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _permissionService: IPermissionService, _dialogService: IDialogService, _rangeProtectionRuleModel: RangeProtectionRuleModel, _localeService: LocaleService, _contextService: IContextService, _sheetPermissionCheckController: SheetPermissionCheckController);
|
|
17
15
|
private _initUIEvent;
|
|
18
16
|
private _haveNotPermissionHandle;
|
|
19
17
|
private _getPermissionCheck;
|
|
20
18
|
private _initialize;
|
|
21
19
|
private _commandExecutedListener;
|
|
22
20
|
private _permissionCheckByPaste;
|
|
23
|
-
private _permissionCheckByAutoFillCommand;
|
|
24
21
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
rows: number[];
|
|
4
|
-
cols: number[];
|
|
5
|
-
}
|
|
6
|
-
export declare function discreteRangeToRange(discreteRange: IDiscreteRange): IRange;
|
|
1
|
+
import { IRange } from '@univerjs/core';
|
|
2
|
+
import { IDiscreteRange } from '@univerjs/sheets';
|
|
7
3
|
export declare function virtualizeDiscreteRanges(ranges: IDiscreteRange[]): {
|
|
8
4
|
ranges: IRange[];
|
|
9
5
|
mapFunc: (row: number, col: number) => {
|
|
@@ -11,4 +7,3 @@ export declare function virtualizeDiscreteRanges(ranges: IDiscreteRange[]): {
|
|
|
11
7
|
col: number;
|
|
12
8
|
};
|
|
13
9
|
};
|
|
14
|
-
export declare function generateNullCellValueRowCol(range: IDiscreteRange[]): IObjectMatrixPrimitiveType<ICellData>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ICellWithCoord, IDisposable, ISelectionCell, Nullable, DisposableCollection } from '@univerjs/core';
|
|
2
2
|
import { ISelectionStyle } from '@univerjs/sheets';
|
|
3
|
-
import {
|
|
3
|
+
import { ICanvasPopup, ICellAlert, IDropdownParam } from '@univerjs/sheets-ui';
|
|
4
4
|
import { ComponentType, ComponentManager } from '@univerjs/ui';
|
|
5
5
|
import { FRange } from '@univerjs/sheets/facade';
|
|
6
6
|
export interface IFComponentKey {
|
|
@@ -196,45 +196,6 @@ interface IFRangeSheetsUIMixin {
|
|
|
196
196
|
* ```
|
|
197
197
|
*/
|
|
198
198
|
showDropdown(param: IDropdownParam): IDisposable;
|
|
199
|
-
/**
|
|
200
|
-
* Fills the target range with data based on the data in the current range.
|
|
201
|
-
* @param {FRange} targetRange - The range to be filled with data.
|
|
202
|
-
* @param {APPLY_TYPE} [applyType] - The type of data fill to be applied.
|
|
203
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the fill operation was successful, false otherwise.
|
|
204
|
-
* @example
|
|
205
|
-
* ```ts
|
|
206
|
-
* // Auto-fill the range D1:D10 based on the data in the range C1:C2
|
|
207
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
208
|
-
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
209
|
-
* const fRange = fWorksheet.getRange('A1:A4');
|
|
210
|
-
*
|
|
211
|
-
* // Auto-fill without specifying applyType (default behavior)
|
|
212
|
-
* await fRange.autoFill(fWorksheet.getRange('A1:A20'))
|
|
213
|
-
*
|
|
214
|
-
* // Auto-fill with 'COPY' type
|
|
215
|
-
* await fRange.autoFill(fWorksheet.getRange('A1:A20'), 'COPY')
|
|
216
|
-
*
|
|
217
|
-
* // Auto-fill with 'SERIES' type
|
|
218
|
-
* await fRange.autoFill(fWorksheet.getRange('A1:A20'), 'SERIES')
|
|
219
|
-
* ```
|
|
220
|
-
*
|
|
221
|
-
* ```ts
|
|
222
|
-
* // Operate on a specific worksheet
|
|
223
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
224
|
-
* const fWorksheet = fWorkbook.getSheetBySheetId('sheetId');
|
|
225
|
-
* const fRange = fWorksheet.getRange('A1:A4');
|
|
226
|
-
*
|
|
227
|
-
* // Auto-fill without specifying applyType (default behavior)
|
|
228
|
-
* await fRange.autoFill(fWorksheet.getRange('A1:A20'))
|
|
229
|
-
*
|
|
230
|
-
* // Auto-fill with 'COPY' type
|
|
231
|
-
* await fRange.autoFill(fWorksheet.getRange('A1:A20'), 'COPY')
|
|
232
|
-
*
|
|
233
|
-
* // Auto-fill with 'SERIES' type
|
|
234
|
-
* await fRange.autoFill(fWorksheet.getRange('A1:A20'), 'SERIES')
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
237
|
-
autoFill(targetRange: FRange, applyType?: APPLY_TYPE): Promise<boolean>;
|
|
238
199
|
}
|
|
239
200
|
declare module '@univerjs/sheets/facade' {
|
|
240
201
|
interface FRange extends IFRangeSheetsUIMixin {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import './global.css';
|
|
17
17
|
export { getEditorObject } from './basics/editor/get-editor-object';
|
|
18
|
-
export { AutoClearContentCommand, AutoFillCommand } from './commands/commands/auto-fill.command';
|
|
19
18
|
export { type ISheetPasteByShortKeyParams, type ISheetPasteParams, SheetCopyCommand, SheetCutCommand, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, } from './commands/commands/clipboard.command';
|
|
20
19
|
export { DeleteRangeMoveLeftConfirmCommand } from './commands/commands/delete-range-move-left-confirm.command';
|
|
21
20
|
export { DeleteRangeMoveUpConfirmCommand } from './commands/commands/delete-range-move-up-confirm.command';
|
|
@@ -25,7 +24,6 @@ export { ResetRangeTextColorCommand, SetRangeBoldCommand, SetRangeFontDecreaseCo
|
|
|
25
24
|
export { InsertRangeMoveDownConfirmCommand } from './commands/commands/insert-range-move-down-confirm.command';
|
|
26
25
|
export { InsertRangeMoveRightConfirmCommand } from './commands/commands/insert-range-move-right-confirm.command';
|
|
27
26
|
export { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, DeleteRangeProtectionFromContextMenuCommand, SetRangeProtectionFromContextMenuCommand, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand, } from './commands/commands/range-protection.command';
|
|
28
|
-
export { RefillCommand } from './commands/commands/refill.command';
|
|
29
27
|
export { RemoveColConfirmCommand, RemoveRowConfirmCommand } from './commands/commands/remove-row-col-confirm.command';
|
|
30
28
|
export { RemoveSheetConfirmCommand } from './commands/commands/remove-sheet-confirm.command';
|
|
31
29
|
export { ApplyFormatPainterCommand, SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand } from './commands/commands/set-format-painter.command';
|
|
@@ -52,8 +50,8 @@ export { useActiveWorkbook, useActiveWorksheet, useWorkbooks } from './component
|
|
|
52
50
|
export { UNIVER_SHEET_PERMISSION_USER_PART } from './consts/permission';
|
|
53
51
|
export { SHEET_UI_PLUGIN_NAME } from './consts/plugin-name';
|
|
54
52
|
export { SheetsUIPart } from './consts/ui-name';
|
|
55
|
-
export {
|
|
56
|
-
export {
|
|
53
|
+
export { AutoFillUIController } from './controllers/auto-fill-ui.controller';
|
|
54
|
+
export { AutoHeightController } from './controllers/auto-height.controller';
|
|
57
55
|
export { AutoWidthController } from './controllers/auto-width.controller';
|
|
58
56
|
export { CellCustomRenderController } from './controllers/cell-custom-render.controller';
|
|
59
57
|
export { type IUniverSheetsUIConfig } from './controllers/config.schema';
|
|
@@ -76,16 +74,11 @@ export { SheetUIController } from './controllers/sheet-ui.controller';
|
|
|
76
74
|
export { whenFormulaEditorActivated, whenSheetEditorFocused } from './controllers/shortcuts/utils';
|
|
77
75
|
export { StatusBarController } from './controllers/status-bar.controller';
|
|
78
76
|
export { getCoordByCell, getCoordByOffset, getSheetObject, getTransformCoord } from './controllers/utils/component-tools';
|
|
79
|
-
export
|
|
80
|
-
export { discreteRangeToRange, virtualizeDiscreteRanges } from './controllers/utils/range-tools';
|
|
77
|
+
export { virtualizeDiscreteRanges } from './controllers/utils/range-tools';
|
|
81
78
|
export { matchedSelectionByRowColIndex as checkInHeaderRanges } from './controllers/utils/selections-tools';
|
|
82
79
|
export { useHighlightRange } from './hooks/use-highlight-range';
|
|
83
80
|
export { UniverSheetsMobileUIPlugin } from './mobile-plugin';
|
|
84
81
|
export { UniverSheetsUIPlugin } from './plugin';
|
|
85
|
-
export { AutoFillService, IAutoFillService } from './services/auto-fill/auto-fill.service';
|
|
86
|
-
export { getAutoFillRepeatRange } from './services/auto-fill/tools';
|
|
87
|
-
export { APPLY_TYPE, DATA_TYPE, type IAutoFillRule, type ICopyDataInTypeIndexInfo } from './services/auto-fill/type';
|
|
88
|
-
export type { IAutoFillLocation, ICopyDataPiece, ISheetAutoFillHook } from './services/auto-fill/type';
|
|
89
82
|
export { type ICanvasPopup, SheetCanvasPopManagerService } from './services/canvas-pop-manager.service';
|
|
90
83
|
export { CellAlertManagerService, CellAlertType, type ICellAlert } from './services/cell-alert-manager.service';
|
|
91
84
|
export { type IDropdownParam, ISheetCellDropdownManagerService, SheetCellDropdownManagerService } from './services/cell-dropdown-manager.service';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ICellDataWithSpanAndDisplay, IDisposable, IRange, Nullable, Disposable, ErrorService, ICommandService, ILogService, Injector, IUndoRedoService, IUniverInstanceService, LocaleService, ObjectMatrix, ThemeService } from '@univerjs/core';
|
|
2
|
+
import { IDiscreteRange, SheetsSelectionsService } from '@univerjs/sheets';
|
|
2
3
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { IDiscreteRange } from '../../controllers/utils/range-tools';
|
|
4
4
|
import { ICopyOptions, IPasteHookKeyType, IPasteOptionCache, ISheetClipboardHook } from './type';
|
|
5
5
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
6
|
-
import { SheetsSelectionsService } from '@univerjs/sheets';
|
|
7
6
|
import { IClipboardInterfaceService, INotificationService, IPlatformService } from '@univerjs/ui';
|
|
8
7
|
import { IMarkSelectionService } from '../mark-selection/mark-selection.service';
|
|
9
8
|
import { CopyContentCache } from './copy-content-cache';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullable, ObjectMatrix } from '@univerjs/core';
|
|
2
|
-
import { IDiscreteRange } from '
|
|
2
|
+
import { IDiscreteRange } from '@univerjs/sheets';
|
|
3
3
|
import { COPY_TYPE, ICellDataWithSpanInfo } from './type';
|
|
4
4
|
export interface ICopyContentCacheData {
|
|
5
5
|
subUnitId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICellData, ICellDataWithSpanAndDisplay, IDocumentData, IMutationInfo, IRange, ObjectMatrix } from '@univerjs/core';
|
|
2
|
-
import { IDiscreteRange } from '
|
|
2
|
+
import { IDiscreteRange } from '@univerjs/sheets';
|
|
3
3
|
import { PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE } from './clipboard.service';
|
|
4
4
|
export declare enum COPY_TYPE {
|
|
5
5
|
COPY = "COPY",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICellData, ObjectMatrix } from '@univerjs/core';
|
|
2
|
-
import { IDiscreteRange } from '
|
|
2
|
+
import { IDiscreteRange } from '@univerjs/sheets';
|
|
3
3
|
import { ISheetClipboardHook } from '../type';
|
|
4
4
|
export declare class USMToHtmlService {
|
|
5
5
|
convert(matrix: ObjectMatrix<ICellData & {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ICellData, IMutationInfo, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';
|
|
2
|
-
import { ISetRangeValuesMutationParams } from '@univerjs/sheets';
|
|
3
|
-
import { IDiscreteRange } from '../../controllers/utils/range-tools';
|
|
2
|
+
import { IDiscreteRange, ISetRangeValuesMutationParams } from '@univerjs/sheets';
|
|
4
3
|
/**
|
|
5
4
|
*
|
|
6
5
|
*
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AUTO_FILL_APPLY_TYPE } from '@univerjs/sheets';
|
|
2
2
|
export interface IAnchorPoint {
|
|
3
3
|
row: number;
|
|
4
4
|
col: number;
|
|
5
5
|
}
|
|
6
6
|
export interface IAutoFillPopupMenuItem {
|
|
7
7
|
label: string;
|
|
8
|
-
value:
|
|
8
|
+
value: AUTO_FILL_APPLY_TYPE;
|
|
9
9
|
index: number;
|
|
10
10
|
disable: boolean;
|
|
11
11
|
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(E,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("@univerjs/sheets/facade"),require("@univerjs/ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/core/facade","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-ui","@univerjs/sheets/facade","@univerjs/ui","rxjs"],h):(E=typeof globalThis<"u"?globalThis:E||self,h(E.UniverSheetsUiFacade={},E.UniverCore,E.UniverCoreFacade,E.UniverDocs,E.UniverEngineRender,E.UniverSheets,E.UniverSheetsUi,E.UniverSheetsFacade,E.UniverUi,E.rxjs))})(this,(function(E,h,k,R,u,I,s,b,C,m){"use strict";class H extends k.FUniver{_initSheetUIEvent(e){const r=e.get(h.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditStart,()=>r.beforeCommandExecuted(t=>{if(t.id!==s.SetCellEditVisibleOperation.id)return;const i=this.getActiveSheet();if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=t.params,{visible:v,keycode:S,eventType:c}=g,n=l.getEditLocation();if(v){const a={row:n.row,column:n.column,eventType:c,keycode:S,workbook:o,worksheet:d,isZenEditor:!1};if(this.fireEvent(this.Event.BeforeSheetEditStart,a),a.cancel)throw new h.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditEnd,()=>r.beforeCommandExecuted(t=>{if(t.id!==s.SetCellEditVisibleOperation.id)return;const i=this.getActiveSheet();if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=e.get(h.IUniverInstanceService),v=t.params,{visible:S,keycode:c,eventType:n}=v,a=l.getEditLocation();if(!S){const p={row:a.row,column:a.column,eventType:n,keycode:c,workbook:o,worksheet:d,isZenEditor:!1,value:h.RichTextValue.create(g.getUnit(h.DOCS_NORMAL_EDITOR_UNIT_ID_KEY).getSnapshot()),isConfirm:c!==C.KeyCode.ESC};if(this.fireEvent(this.Event.BeforeSheetEditEnd,p),p.cancel)throw new h.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditStarted,()=>r.onCommandExecuted(t=>{if(t.id!==s.SetCellEditVisibleOperation.id)return;const i=this.getCommandSheetTarget(t);if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=t.params,{visible:v,keycode:S,eventType:c}=g,n=l.getEditLocation();if(v){const a={row:n.row,column:n.column,eventType:c,keycode:S,workbook:o,worksheet:d,isZenEditor:!1};this.fireEvent(this.Event.SheetEditStarted,a)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditEnded,()=>r.onCommandExecuted(t=>{if(t.id!==s.SetCellEditVisibleOperation.id)return;const i=this.getCommandSheetTarget(t);if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=t.params,{visible:v,keycode:S,eventType:c}=g,n=l.getEditLocation();if(!v){const a={row:n.row,column:n.column,eventType:c,keycode:S,workbook:o,worksheet:d,isZenEditor:!1,isConfirm:S!==C.KeyCode.ESC};this.fireEvent(this.Event.SheetEditEnded,a)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditChanging,()=>r.onCommandExecuted(t=>{if(t.id!==R.RichTextEditingMutation.id)return;const i=this.getActiveSheet();if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=e.get(h.IUniverInstanceService),v=t.params;if(!l.isVisible().visible)return;const{unitId:S}=v;if(S===h.DOCS_NORMAL_EDITOR_UNIT_ID_KEY){const{row:c,column:n}=l.getEditLocation(),a={workbook:o,worksheet:d,row:c,column:n,value:h.RichTextValue.create(g.getUnit(h.DOCS_NORMAL_EDITOR_UNIT_ID_KEY).getSnapshot()),isZenEditor:!1};this.fireEvent(this.Event.SheetEditChanging,a)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetZoomChange,()=>r.beforeCommandExecuted(t=>{if(t.id!==s.SetZoomRatioCommand.id)return;const i=this.getCommandSheetTarget(t);if(!i)return;const{workbook:o,worksheet:d}=i,l={zoom:t.params.zoomRatio,workbook:o,worksheet:d};if(this.fireEvent(this.Event.BeforeSheetZoomChange,l),l.cancel)throw new h.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetZoomChanged,()=>r.onCommandExecuted(t=>{if(t.id!==s.SetZoomRatioCommand.id)return;const i=this.getCommandSheetTarget(t);if(!i)return;const{workbook:o,worksheet:d}=i;this.fireEvent(this.Event.SheetZoomChanged,{zoom:d.getZoom(),workbook:o,worksheet:d})})))}_initObserverListener(e){const r=e.get(u.IRenderManagerService),t=e.get(h.LifecycleService),i=new h.DisposableCollection;this.disposeWithMe(t.lifecycle$.subscribe(g=>{if(g!==h.LifecycleStages.Rendered)return;const v=e.get(s.HoverManagerService),S=e.get(s.DragManagerService);v&&(i.dispose(),i.add(this.registerEventHandler(this.Event.CellClicked,()=>{var c;return(c=v.currentClickedCell$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.location.unitId,n.location.subUnitId);a&&this.fireEvent(this.Event.CellClicked,{...a,...n,row:n.location.row,column:n.location.col})})})),i.add(this.registerEventHandler(this.Event.CellHover,()=>{var c;return(c=v.currentRichText$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.CellHover,{...a,...n,row:n.row,column:n.col})})})),i.add(this.registerEventHandler(this.Event.CellPointerDown,()=>{var c;return(c=v.currentPointerDownCell$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.CellPointerDown,{...a,...n,row:n.row,column:n.col})})})),i.add(this.registerEventHandler(this.Event.CellPointerUp,()=>{var c;return(c=v.currentPointerUpCell$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.CellPointerUp,{...a,...n,row:n.row,column:n.col})})})),i.add(this.registerEventHandler(this.Event.CellPointerMove,()=>{var c;return(c=v.currentCellPosWithEvent$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.CellPointerMove,{...a,...n,row:n.row,column:n.col})})})),i.add(this.registerEventHandler(this.Event.DragOver,()=>{var c;return(c=S.currentCell$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.location.unitId,n.location.subUnitId);a&&this.fireEvent(this.Event.DragOver,{...a,...n,row:n.location.row,column:n.location.col})})})),i.add(this.registerEventHandler(this.Event.Drop,()=>{var c;return(c=S.endCell$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.location.unitId,n.location.subUnitId);a&&this.fireEvent(this.Event.Drop,{...a,...n,row:n.location.row,column:n.location.col})})})),i.add(this.registerEventHandler(this.Event.RowHeaderClick,()=>{var c;return(c=v.currentRowHeaderClick$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.RowHeaderClick,{...a,row:n.index})})})),i.add(this.registerEventHandler(this.Event.RowHeaderPointerDown,()=>{var c;return(c=v.currentRowHeaderPointerDown$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.RowHeaderPointerDown,{...a,row:n.index})})})),i.add(this.registerEventHandler(this.Event.RowHeaderPointerUp,()=>{var c;return(c=v.currentRowHeaderPointerUp$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.RowHeaderPointerUp,{...a,row:n.index})})})),i.add(this.registerEventHandler(this.Event.RowHeaderHover,()=>{var c;return(c=v.currentHoveredRowHeader$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.RowHeaderHover,{...a,row:n.index})})})),i.add(this.registerEventHandler(this.Event.ColumnHeaderClick,()=>{var c;return(c=v.currentColHeaderClick$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.ColumnHeaderClick,{...a,column:n.index})})})),i.add(this.registerEventHandler(this.Event.ColumnHeaderPointerDown,()=>{var c;return(c=v.currentColHeaderPointerDown$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.ColumnHeaderPointerDown,{...a,column:n.index})})})),i.add(this.registerEventHandler(this.Event.ColumnHeaderPointerUp,()=>{var c;return(c=v.currentColHeaderPointerUp$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.ColumnHeaderPointerUp,{...a,column:n.index})})})),i.add(this.registerEventHandler(this.Event.ColumnHeaderHover,()=>{var c;return(c=v.currentHoveredColHeader$)==null?void 0:c.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.ColumnHeaderHover,{...a,column:n.index})})})),this.disposeWithMe(i))}));let o;const d=m.combineLatest([r.created$,t.lifecycle$]),l=new h.DisposableCollection;this.disposeWithMe(d.subscribe(([g,v])=>{if(g.type===h.UniverInstanceType.UNIVER_SHEET&&(o=g),v<=h.LifecycleStages.Rendered||!o)return;const S=this.getWorkbook(o.unitId);if(!S)return;l.dispose();const c=o.with(s.SheetScrollManagerService),n=o.with(I.SheetsSelectionsService);l.add(this.registerEventHandler(this.Event.Scroll,()=>c.validViewportScrollInfo$.subscribe(a=>{a&&this.fireEvent(this.Event.Scroll,{workbook:S,worksheet:S.getActiveSheet(),...a})}))),l.add(this.registerEventHandler(this.Event.SelectionMoveStart,()=>n.selectionMoveStart$.subscribe(a=>{var p;this.fireEvent(this.Event.SelectionMoveStart,{workbook:S,worksheet:S.getActiveSheet(),selections:(p=a==null?void 0:a.map(f=>f.range))!=null?p:[]})}))),l.add(this.registerEventHandler(this.Event.SelectionMoving,()=>n.selectionMoving$.subscribe(a=>{var p;this.fireEvent(this.Event.SelectionMoving,{workbook:S,worksheet:S.getActiveSheet(),selections:(p=a==null?void 0:a.map(f=>f.range))!=null?p:[]})}))),l.add(this.registerEventHandler(this.Event.SelectionMoveEnd,()=>n.selectionMoveEnd$.subscribe(a=>{var p;this.fireEvent(this.Event.SelectionMoveEnd,{workbook:S,worksheet:S.getActiveSheet(),selections:(p=a==null?void 0:a.map(f=>f.range))!=null?p:[]})}))),l.add(this.registerEventHandler(this.Event.SelectionChanged,()=>n.selectionChanged$.subscribe(a=>{var p;this.fireEvent(this.Event.SelectionChanged,{workbook:S,worksheet:S.getActiveSheet(),selections:(p=a==null?void 0:a.map(f=>f.range))!=null?p:[]})}))),o=null,this.disposeWithMe(l)}))}_initialize(e){this._initSheetUIEvent(e),this._initObserverListener(e);const r=e.get(h.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeClipboardChange,()=>r.beforeCommandExecuted(t=>{switch(t.id){case C.CopyCommand.id:case C.CutCommand.id:this._beforeClipboardChange();break}}))),this.disposeWithMe(this.registerEventHandler(this.Event.ClipboardChanged,()=>r.onCommandExecuted(t=>{switch(t.id){case C.CopyCommand.id:case C.CutCommand.id:this._clipboardChanged();break}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeClipboardPaste,()=>r.beforeCommandExecuted(t=>{switch(t.id){case s.SheetPasteShortKeyCommand.id:this._beforeClipboardPaste(t.params);break;case C.PasteCommand.id:this._beforeClipboardPasteAsync();break}}))),this.disposeWithMe(this.registerEventHandler(this.Event.ClipboardPasted,()=>r.onCommandExecuted(t=>{switch(t.id){case s.SheetPasteShortKeyCommand.id:this._clipboardPaste(t.params);break;case C.PasteCommand.id:this._clipboardPasteAsync();break}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetSkeletonChanged,()=>r.onCommandExecuted(t=>{if(I.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(t.id)>-1){const i=this.getActiveSheet();if(!i)return;const o=I.getSkeletonChangedEffectedRange(t,i.worksheet.getMaxColumns()).map(d=>{var l,g;return(g=(l=this.getWorkbook(d.unitId))==null?void 0:l.getSheetBySheetId(d.subUnitId))==null?void 0:g.getRange(d.range)}).filter(Boolean);if(!o.length)return;this.fireEvent(this.Event.SheetSkeletonChanged,{workbook:i.workbook,worksheet:i.worksheet,payload:t,skeleton:i.worksheet.getSkeleton(),effectedRanges:o})}})))}_generateClipboardCopyParam(){const e=this.getActiveWorkbook(),r=e==null?void 0:e.getActiveSheet(),t=e==null?void 0:e.getActiveRange();if(!e||!r||!t)return;const o=this._injector.get(s.ISheetClipboardService).generateCopyContent(e.getId(),r.getSheetId(),t.getRange());if(!o)return;const{html:d,plain:l}=o;return{workbook:e,worksheet:r,text:l,html:d,fromSheet:r,fromRange:t}}_beforeClipboardChange(){const e=this._generateClipboardCopyParam();if(e&&(this.fireEvent(this.Event.BeforeClipboardChange,e),e.cancel))throw new h.CanceledError}_clipboardChanged(){const e=this._generateClipboardCopyParam();e&&this.fireEvent(this.Event.ClipboardChanged,e)}_generateClipboardPasteParam(e){if(!e)return;const{htmlContent:r,textContent:t}=e,i=this.getActiveWorkbook(),o=i==null?void 0:i.getActiveSheet();return!i||!o?void 0:{workbook:i,worksheet:o,text:t,html:r}}async _generateClipboardPasteParamAsync(){const e=this.getActiveWorkbook(),r=e==null?void 0:e.getActiveSheet();if(!e||!r)return;const o=(await this._injector.get(C.IClipboardInterfaceService).read())[0];let d;if(o){const l=o.types,g=l.indexOf(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await o.getType(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(S=>S&&S.text()):"",v=l.indexOf(C.HTML_CLIPBOARD_MIME_TYPE)!==-1?await o.getType(C.HTML_CLIPBOARD_MIME_TYPE).then(S=>S&&S.text()):"";d={workbook:e,worksheet:r,text:g,html:v}}return d}_beforeClipboardPaste(e){const r=this._generateClipboardPasteParam(e);if(r&&(this.fireEvent(this.Event.BeforeClipboardPaste,r),r.cancel))throw new h.CanceledError}_clipboardPaste(e){const r=this._generateClipboardPasteParam(e);if(r&&(this.fireEvent(this.Event.ClipboardPasted,r),r.cancel))throw new h.CanceledError}async _beforeClipboardPasteAsync(){if(!C.supportClipboardAPI()){this._injector.get(h.ILogService).warn("[Facade]: The navigator object only supports the browser environment");return}const e=await this._generateClipboardPasteParamAsync();if(e&&(this.fireEvent(this.Event.BeforeClipboardPaste,e),e.cancel))throw new h.CanceledError}async _clipboardPasteAsync(){if(!C.supportClipboardAPI()){this._injector.get(h.ILogService).warn("[Facade]: The navigator object only supports the browser environment");return}const e=await this._generateClipboardPasteParamAsync();if(e&&(this.fireEvent(this.Event.ClipboardPasted,e),e.cancel))throw new h.CanceledError}customizeColumnHeader(e){var v,S;const r=this.getActiveWorkbook();if(!r){console.error("WorkBook not exist");return}const t=r==null?void 0:r.getId(),i=this._injector.get(u.IRenderManagerService),o=r.getActiveSheet(),d=o.getSheetId(),l=i.getRenderById(t);l&&((v=e.headerStyle)!=null&&v.size)&&(l.with(s.SheetSkeletonManagerService).setColumnHeaderSize(l,d,(S=e.headerStyle)==null?void 0:S.size),o==null||o.refreshCanvas()),this._getSheetRenderComponent(t,s.SHEET_VIEW_KEY.COLUMN).setCustomHeader(e),o==null||o.refreshCanvas()}customizeRowHeader(e){const r=this.getActiveWorkbook();if(!r){console.error("WorkBook not exist");return}const t=r==null?void 0:r.getId();this._getSheetRenderComponent(t,s.SHEET_VIEW_KEY.ROW).setCustomHeader(e)}registerSheetRowHeaderExtension(e,...r){const t=this._getSheetRenderComponent(e,s.SHEET_VIEW_KEY.ROW),i=t.register(...r);return h.toDisposable(()=>{i.dispose(),t.makeDirty(!0)})}registerSheetColumnHeaderExtension(e,...r){const t=this._getSheetRenderComponent(e,s.SHEET_VIEW_KEY.COLUMN),i=t.register(...r);return h.toDisposable(()=>{i.dispose(),t.makeDirty(!0)})}registerSheetMainExtension(e,...r){const t=this._getSheetRenderComponent(e,s.SHEET_VIEW_KEY.MAIN),i=t.register(...r);return h.toDisposable(()=>{i.dispose(),t.makeDirty(!0)})}_getSheetRenderComponent(e,r){const i=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!i)throw new Error(`Render Unit with unitId ${e} not found`);const{components:o}=i,d=o.get(r);if(!d)throw new Error("Render component not found");return d}getSheetHooks(){return this._injector.createInstance(b.FSheetHooks)}pasteIntoSheet(e,r,t){return this._commandService.executeCommand(s.SheetPasteShortKeyCommand.id,{htmlContent:e,textContent:r,files:t})}setProtectedRangeShadowStrategy(e){this._injector.get(s.SheetPermissionRenderManagerService).setProtectedRangeShadowStrategy(e)}getProtectedRangeShadowStrategy(){return this._injector.get(s.SheetPermissionRenderManagerService).getProtectedRangeShadowStrategy()}getProtectedRangeShadowStrategy$(){return this._injector.get(s.SheetPermissionRenderManagerService).getProtectedRangeShadowStrategy$()}setPermissionDialogVisible(e){this._injector.get(h.IPermissionService).setShowComponents(e)}}k.FUniver.extend(H);class y extends b.FWorkbook{openSiderbar(e){return this._logDeprecation("openSiderbar"),this._injector.get(C.ISidebarService).open(e)}openDialog(e){this._logDeprecation("openDialog");const t=this._injector.get(C.IDialogService).open({...e,onClose:()=>{t.dispose()}});return t}customizeColumnHeader(e){const r=this._workbook.getUnitId();this._getSheetRenderComponent(r,s.SHEET_VIEW_KEY.COLUMN).setCustomHeader(e)}customizeRowHeader(e){const r=this._workbook.getUnitId();this._getSheetRenderComponent(r,s.SHEET_VIEW_KEY.ROW).setCustomHeader(e)}_getSheetRenderComponent(e,r){const i=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!i)throw new Error(`Render Unit with unitId ${e} not found`);const{components:o}=i,d=o.get(r);if(!d)throw new Error("Render component not found");return d}_logDeprecation(e){this._injector.get(h.ILogService).warn("[FWorkbook]",`${e} is deprecated. Please use the function of the same name on "FUniver".`)}generateCellParams(e){const r=this.getActiveSheet();return{row:e.row,column:e.col,workbook:this,worksheet:r}}onCellClick(e){const r=this._injector.get(s.HoverManagerService);return h.toDisposable(r.currentClickedCell$.pipe(m.filter(t=>!!t)).subscribe(t=>{e(t)}))}onCellHover(e){const r=this._injector.get(s.HoverManagerService);return h.toDisposable(r.currentRichText$.pipe(m.filter(t=>!!t)).subscribe(e))}onCellPointerDown(e){const r=this._injector.get(s.HoverManagerService);return h.toDisposable(r.currentPointerDownCell$.subscribe(e))}onCellPointerUp(e){const r=this._injector.get(s.HoverManagerService);return h.toDisposable(r.currentPointerUpCell$.subscribe(e))}onCellPointerMove(e){const r=this._injector.get(s.HoverManagerService);return h.toDisposable(r.currentCellPosWithEvent$.pipe(m.filter(t=>!!t)).subscribe(t=>{e(t,t.event)}))}onDragOver(e){const r=this._injector.get(s.DragManagerService);return h.toDisposable(r.currentCell$.pipe(m.filter(t=>!!t)).subscribe(t=>{e(t)}))}onDrop(e){const r=this._injector.get(s.DragManagerService);return h.toDisposable(r.endCell$.pipe(m.filter(t=>!!t)).subscribe(t=>{e(t)}))}startEditing(){const e=this._injector.get(h.ICommandService);return this._injector.get(s.IEditorBridgeService).isVisible().visible?!0:e.syncExecuteCommand(s.SetCellEditVisibleOperation.id,{eventType:u.DeviceInputEventType.Dblclick,unitId:this._workbook.getUnitId(),visible:!0})}async endEditing(e){const r=this._injector.get(h.ICommandService);return this._injector.get(s.IEditorBridgeService).isVisible().visible&&r.syncExecuteCommand(s.SetCellEditVisibleOperation.id,{eventType:u.DeviceInputEventType.Keyboard,keycode:e?C.KeyCode.ENTER:C.KeyCode.ESC,visible:!1,unitId:this._workbook.getUnitId()}),await h.awaitTime(0),!0}endEditingAsync(e=!0){return this.endEditing(e)}abortEditingAsync(){return this.endEditingAsync(!1)}isCellEditing(){return this._injector.get(s.IEditorBridgeService).isVisible().visible}getScrollStateBySheetId(e){const r=this._workbook.getUnitId(),i=this._injector.get(u.IRenderManagerService).getRenderById(r);return i?i.with(s.SheetScrollManagerService).getScrollStateByParam({unitId:r,sheetId:e}):null}disableSelection(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);return t&&t.with(s.ISheetSelectionRenderService).disableSelection(),this}enableSelection(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);return t&&t.with(s.ISheetSelectionRenderService).enableSelection(),this}transparentSelection(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);return t&&t.with(s.ISheetSelectionRenderService).transparentSelection(),this}showSelection(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);return t&&t.with(s.ISheetSelectionRenderService).showSelection(),this}}b.FWorkbook.extend(y);class D extends b.FWorksheet{refreshCanvas(){const e=this._injector.get(u.IRenderManagerService),r=this._fWorkbook.id,t=e.getRenderById(r);if(!t)throw new Error(`Render Unit with unitId ${r} not found`);t.with(s.SheetSkeletonManagerService).reCalculate();const i=t.mainComponent;if(!i)throw new Error("Main component not found");return i.makeDirty(),this}highlightRanges(e,r,t){const i=this._injector.get(s.IMarkSelectionService),o=[];for(const d of e){const l=d.getRange(),g=i.addShapeWithNoFresh({range:l,style:r,primary:t});g&&o.push(g)}if(i.refreshShapes(),o.length===0)throw new Error("Failed to highlight current range");return h.toDisposable(()=>{o.forEach(d=>{i.removeShape(d)})})}zoom(e){const r=this._injector.get(h.ICommandService),t=Math.min(Math.max(e,.1),4);return r.executeCommand(s.SetZoomRatioCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),zoomRatio:t}),this}getZoom(){return this._worksheet.getZoomRatio()}getVisibleRange(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!t)return null;const o=t.with(s.SheetSkeletonManagerService).getCurrentSkeleton();return o?o.getVisibleRangeByViewport(u.SHEET_VIEWPORT_KEY.VIEW_MAIN):null}getVisibleRangesOfAllViewports(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!t)return null;const o=t.with(s.SheetSkeletonManagerService).getCurrentSkeleton();return o?o.getVisibleRanges():null}scrollToCell(e,r,t){const i=this._workbook.getUnitId(),d=this._injector.get(u.IRenderManagerService).getRenderById(i);return d&&(d==null?void 0:d.with(s.SheetsScrollRenderController)).scrollToCell(e,r,t),this}getScrollState(){const e={offsetX:0,offsetY:0,sheetViewStartColumn:0,sheetViewStartRow:0},r=this._workbook.getUnitId(),t=this._worksheet.getSheetId(),o=this._injector.get(u.IRenderManagerService).getRenderById(r);return o&&o.with(s.SheetScrollManagerService).getScrollStateByParam({unitId:r,sheetId:t})||e}onScroll(e){var o;const r=this._workbook.getUnitId(),i=(o=this._injector.get(u.IRenderManagerService).getRenderById(r))==null?void 0:o.with(s.SheetScrollManagerService);if(i){const d=i.validViewportScrollInfo$.subscribe(l=>{e(l)});return h.toDisposable(d)}return h.toDisposable(()=>{})}getSkeleton(){var r,t;const e=(r=this._injector.get(u.IRenderManagerService).getRenderById(this._workbook.getUnitId()))==null?void 0:r.with(s.SheetSkeletonManagerService);return(t=e==null?void 0:e.getWorksheetSkeleton(this._worksheet.getSheetId()))==null?void 0:t.skeleton}autoResizeColumn(e){return this.autoResizeColumns(e,1)}autoResizeColumns(e,r){const t=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),o=[{startColumn:e,endColumn:e+r-1,startRow:0,endRow:this._worksheet.getRowCount()-1}];return this._commandService.syncExecuteCommand(s.SetWorksheetColAutoWidthCommand.id,{unitId:t,subUnitId:i,ranges:o}),this}setColumnAutoWidth(e,r){return this.autoResizeColumns(e,r)}autoResizeRows(e,r){const t=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),o=[{startRow:e,endRow:e+r-1,startColumn:0,endColumn:this._worksheet.getColumnCount()-1}];return this._commandService.syncExecuteCommand(I.SetWorksheetRowIsAutoHeightCommand.id,{unitId:t,subUnitId:i,ranges:o}),this}customizeColumnHeader(e){var l,g;const r=this._workbook.getUnitId(),t=this._worksheet.getSheetId(),o=this._injector.get(u.IRenderManagerService).getRenderById(r);o&&((l=e.headerStyle)!=null&&l.size)&&o.with(s.SheetSkeletonManagerService).setColumnHeaderSize(o,t,(g=e.headerStyle)==null?void 0:g.size),this._getSheetRenderComponent(r,s.SHEET_VIEW_KEY.COLUMN).setCustomHeader(e,t)}customizeRowHeader(e){var l,g;const r=this._workbook.getUnitId(),t=this._worksheet.getSheetId(),o=this._injector.get(u.IRenderManagerService).getRenderById(r);o&&((l=e.headerStyle)!=null&&l.size)&&o.with(s.SheetSkeletonManagerService).setRowHeaderSize(o,t,(g=e.headerStyle)==null?void 0:g.size),this._getSheetRenderComponent(r,s.SHEET_VIEW_KEY.ROW).setCustomHeader(e,t)}setColumnHeaderHeight(e){const r=this._workbook.getUnitId(),t=this._worksheet.getSheetId();return this._commandService.executeCommand(s.SetColumnHeaderHeightCommand.id,{unitId:r,subUnitId:t,size:e}),this}setRowHeaderWidth(e){const r=this._workbook.getUnitId(),t=this._worksheet.getSheetId();return this._commandService.executeCommand(s.SetRowHeaderWidthCommand.id,{unitId:r,subUnitId:t,size:e}),this}_getSheetRenderComponent(e,r){const i=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!i)throw new Error(`Render Unit with unitId ${e} not found`);const{components:o}=i,d=o.get(r);if(!d)throw new Error("Render component not found");return d}}b.FWorksheet.extend(D);class T extends b.FPermission{setPermissionDialogVisible(e){this._permissionService.setShowComponents(e)}}b.FPermission.extend(T);class B extends b.FSheetHooks{onCellPointerMove(e){return h.toDisposable(this._injector.get(s.HoverManagerService).currentPosition$.subscribe(e))}onCellPointerOver(e){return h.toDisposable(this._injector.get(s.HoverManagerService).currentCell$.subscribe(e))}onCellDragOver(e){return h.toDisposable(this._injector.get(s.DragManagerService).currentCell$.subscribe(e))}onCellDrop(e){return h.toDisposable(this._injector.get(s.DragManagerService).endCell$.subscribe(e))}onCellRender(e,r=h.InterceptorEffectEnum.Style,t=I.InterceptCellContentPriority.DATA_VALIDATION){return this._injector.get(I.SheetInterceptorService).intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r,handler:(i,o,d)=>(i&&!i.customRender&&e&&(i.customRender=[...e]),d(i)),priority:t})}onBeforeCellEdit(e){return this._injector.get(h.ICommandService).beforeCommandExecuted(r=>{const t=r.params;r.id===s.SetCellEditVisibleOperation.id&&t.visible&&e(t)})}onAfterCellEdit(e){return this._injector.get(h.ICommandService).onCommandExecuted(r=>{const t=r.params;r.id===s.SetCellEditVisibleOperation.id&&!t.visible&&e(t)})}}b.FSheetHooks.extend(B);const _={CellClicked:"CellClicked",CellPointerDown:"CellPointerDown",CellPointerUp:"CellPointerUp",CellPointerMove:"CellPointerMove",CellHover:"CellHover"};class A{get BeforeClipboardChange(){return"BeforeClipboardChange"}get ClipboardChanged(){return"ClipboardChanged"}get BeforeClipboardPaste(){return"BeforeClipboardPaste"}get ClipboardPasted(){return"ClipboardPasted"}get BeforeSheetEditStart(){return"BeforeSheetEditStart"}get SheetEditStarted(){return"SheetEditStarted"}get SheetEditChanging(){return"SheetEditChanging"}get BeforeSheetEditEnd(){return"BeforeSheetEditEnd"}get SheetEditEnded(){return"SheetEditEnded"}get CellClicked(){return _.CellClicked}get CellHover(){return _.CellHover}get CellPointerDown(){return _.CellPointerDown}get CellPointerUp(){return _.CellPointerUp}get CellPointerMove(){return _.CellPointerMove}get DragOver(){return"DragOver"}get Drop(){return"Drop"}get Scroll(){return"Scroll"}get SelectionMoveStart(){return"SelectionMoveStart"}get SelectionChanged(){return"SelectionChanged"}get SelectionMoving(){return"SelectionMoving"}get SelectionMoveEnd(){return"SelectionMoveEnd"}get RowHeaderClick(){return"RowHeaderClick"}get RowHeaderPointerDown(){return"RowHeaderPointerDown"}get RowHeaderPointerUp(){return"RowHeaderPointerUp"}get RowHeaderHover(){return"RowHeaderHover"}get ColumnHeaderClick(){return"ColumnHeaderClick"}get ColumnHeaderPointerDown(){return"ColumnHeaderPointerDown"}get ColumnHeaderPointerUp(){return"ColumnHeaderPointerUp"}get ColumnHeaderHover(){return"ColumnHeaderHover"}get SheetSkeletonChanged(){return"SheetSkeletonChanged"}get BeforeSheetZoomChange(){return"BeforeSheetZoomChange"}get SheetZoomChanged(){return"SheetZoomChanged"}}k.FEventName.extend(A);class P{get SHEET_VIEWPORT_KEY(){return u.SHEET_VIEWPORT_KEY}}k.FEnum.extend(P);class x extends b.FRange{getCell(){var l;const e=this._injector.get(u.IRenderManagerService),r=this._injector.get(h.ILogService),t=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),o=e.getRenderById(t),d=(l=o==null?void 0:o.with(s.SheetSkeletonManagerService).getSkeletonParam(i))==null?void 0:l.skeleton;if(!d)throw r.error("[Facade]: `FRange.getCell` can only be called in current worksheet"),new Error("`FRange.getCell` can only be called in current worksheet");return d.getCellWithCoordByIndex(this._range.startRow,this._range.startColumn)}getCellRect(){const{startX:e,startY:r,endX:t,endY:i}=this.getCell(),o={x:e,y:r,width:t-e,height:i-r,top:r,left:e,bottom:i,right:t};return{...o,toJSON:()=>JSON.stringify(o)}}generateHTML(){var t;const r=this._injector.get(s.ISheetClipboardService).generateCopyContent(this._workbook.getUnitId(),this._worksheet.getSheetId(),this._range);return(t=r==null?void 0:r.html)!=null?t:""}attachPopup(e){var d,l,g;e.direction=(d=e.direction)!=null?d:"horizontal",e.extraProps=(l=e.extraProps)!=null?l:{},e.offset=(g=e.offset)!=null?g:[0,0];const{key:r,disposableCollection:t}=M(e,this._injector.get(C.ComponentManager)),o=this._injector.get(s.SheetCanvasPopManagerService).attachPopupToCell(this._range.startRow,this._range.startColumn,{...e,componentKey:r},this.getUnitId(),this._worksheet.getSheetId());return o?(t.add(o),t):(t.dispose(),null)}attachAlertPopup(e){const r=this._injector.get(s.CellAlertManagerService),t={workbook:this._workbook,worksheet:this._worksheet,row:this._range.startRow,col:this._range.startColumn,unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId()};return r.showAlert({...e,location:t}),{dispose:()=>{r.removeAlert(e.key)}}}attachRangePopup(e){var d,l,g;e.direction=(d=e.direction)!=null?d:"top-center",e.extraProps=(l=e.extraProps)!=null?l:{},e.offset=(g=e.offset)!=null?g:[0,0];const{key:r,disposableCollection:t}=M(e,this._injector.get(C.ComponentManager)),o=this._injector.get(s.SheetCanvasPopManagerService).attachRangePopup(this._range,{...e,componentKey:r},this.getUnitId(),this._worksheet.getSheetId());return o?(t.add(o),t):(t.dispose(),null)}highlight(e,r){const t=this._injector.get(s.IMarkSelectionService),i=t.addShape({range:this._range,style:e,primary:r});if(!i)throw new Error("Failed to highlight current range");return h.toDisposable(()=>{t.removeShape(i)})}showDropdown(e){return this._injector.get(s.ISheetCellDropdownManagerService).showDropdown(e)}async autoFill(e,r){const t=this.getRange(),i=e.getRange();if(!h.Rectangle.contains(i,t))throw new Error("AutoFill target range must contain source range");const{startRow:o,startColumn:d,endRow:l,endColumn:g}=t,{startRow:v,startColumn:S,endRow:c,endColumn:n}=i;if(l-o!==c-v&&g-d!==n-S)throw new Error("AutoFill can only fill in one direction");if(l-o===c-v&&d!==S&&g!==n)throw new Error("AutoFill can only fill in one direction");if(g-d===n-S&&o!==v&&l!==c)throw new Error("AutoFill can only fill in one direction");return this._commandService.executeCommand(s.AutoFillCommand.id,{sourceRange:t,targetRange:i,unitId:this.getUnitId(),subUnitId:this.getSheetId(),applyType:r})}}b.FRange.extend(x);function M(w,e){const{componentKey:r,isVue3:t}=w;let i;const o=new h.DisposableCollection;return typeof r=="string"?i=r:(i=`External_${h.generateRandomId(6)}`,o.add(e.register(i,r,{framework:t?"vue3":"react"}))),{key:i,disposableCollection:o}}E.FSheetsUIEnum=P,E.transformComponentKey=M,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(E,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("@univerjs/sheets/facade"),require("@univerjs/ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/core/facade","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-ui","@univerjs/sheets/facade","@univerjs/ui","rxjs"],c):(E=typeof globalThis<"u"?globalThis:E||self,c(E.UniverSheetsUiFacade={},E.UniverCore,E.UniverCoreFacade,E.UniverDocs,E.UniverEngineRender,E.UniverSheets,E.UniverSheetsUi,E.UniverSheetsFacade,E.UniverUi,E.rxjs))})(this,(function(E,c,_,R,u,I,s,b,C,m){"use strict";class H extends _.FUniver{_initSheetUIEvent(e){const r=e.get(c.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditStart,()=>r.beforeCommandExecuted(t=>{if(t.id!==s.SetCellEditVisibleOperation.id)return;const i=this.getActiveSheet();if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=t.params,{visible:v,keycode:S,eventType:h}=g,n=l.getEditLocation();if(v){const a={row:n.row,column:n.column,eventType:h,keycode:S,workbook:o,worksheet:d,isZenEditor:!1};if(this.fireEvent(this.Event.BeforeSheetEditStart,a),a.cancel)throw new c.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetEditEnd,()=>r.beforeCommandExecuted(t=>{if(t.id!==s.SetCellEditVisibleOperation.id)return;const i=this.getActiveSheet();if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=e.get(c.IUniverInstanceService),v=t.params,{visible:S,keycode:h,eventType:n}=v,a=l.getEditLocation();if(!S){const p={row:a.row,column:a.column,eventType:n,keycode:h,workbook:o,worksheet:d,isZenEditor:!1,value:c.RichTextValue.create(g.getUnit(c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY).getSnapshot()),isConfirm:h!==C.KeyCode.ESC};if(this.fireEvent(this.Event.BeforeSheetEditEnd,p),p.cancel)throw new c.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditStarted,()=>r.onCommandExecuted(t=>{if(t.id!==s.SetCellEditVisibleOperation.id)return;const i=this.getCommandSheetTarget(t);if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=t.params,{visible:v,keycode:S,eventType:h}=g,n=l.getEditLocation();if(v){const a={row:n.row,column:n.column,eventType:h,keycode:S,workbook:o,worksheet:d,isZenEditor:!1};this.fireEvent(this.Event.SheetEditStarted,a)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditEnded,()=>r.onCommandExecuted(t=>{if(t.id!==s.SetCellEditVisibleOperation.id)return;const i=this.getCommandSheetTarget(t);if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=t.params,{visible:v,keycode:S,eventType:h}=g,n=l.getEditLocation();if(!v){const a={row:n.row,column:n.column,eventType:h,keycode:S,workbook:o,worksheet:d,isZenEditor:!1,isConfirm:S!==C.KeyCode.ESC};this.fireEvent(this.Event.SheetEditEnded,a)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetEditChanging,()=>r.onCommandExecuted(t=>{if(t.id!==R.RichTextEditingMutation.id)return;const i=this.getActiveSheet();if(!i)return;const{workbook:o,worksheet:d}=i,l=e.get(s.IEditorBridgeService),g=e.get(c.IUniverInstanceService),v=t.params;if(!l.isVisible().visible)return;const{unitId:S}=v;if(S===c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY){const{row:h,column:n}=l.getEditLocation(),a={workbook:o,worksheet:d,row:h,column:n,value:c.RichTextValue.create(g.getUnit(c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY).getSnapshot()),isZenEditor:!1};this.fireEvent(this.Event.SheetEditChanging,a)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetZoomChange,()=>r.beforeCommandExecuted(t=>{if(t.id!==s.SetZoomRatioCommand.id)return;const i=this.getCommandSheetTarget(t);if(!i)return;const{workbook:o,worksheet:d}=i,l={zoom:t.params.zoomRatio,workbook:o,worksheet:d};if(this.fireEvent(this.Event.BeforeSheetZoomChange,l),l.cancel)throw new c.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetZoomChanged,()=>r.onCommandExecuted(t=>{if(t.id!==s.SetZoomRatioCommand.id)return;const i=this.getCommandSheetTarget(t);if(!i)return;const{workbook:o,worksheet:d}=i;this.fireEvent(this.Event.SheetZoomChanged,{zoom:d.getZoom(),workbook:o,worksheet:d})})))}_initObserverListener(e){const r=e.get(u.IRenderManagerService),t=e.get(c.LifecycleService),i=new c.DisposableCollection;this.disposeWithMe(t.lifecycle$.subscribe(g=>{if(g!==c.LifecycleStages.Rendered)return;const v=e.get(s.HoverManagerService),S=e.get(s.DragManagerService);v&&(i.dispose(),i.add(this.registerEventHandler(this.Event.CellClicked,()=>{var h;return(h=v.currentClickedCell$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.location.unitId,n.location.subUnitId);a&&this.fireEvent(this.Event.CellClicked,{...a,...n,row:n.location.row,column:n.location.col})})})),i.add(this.registerEventHandler(this.Event.CellHover,()=>{var h;return(h=v.currentRichText$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.CellHover,{...a,...n,row:n.row,column:n.col})})})),i.add(this.registerEventHandler(this.Event.CellPointerDown,()=>{var h;return(h=v.currentPointerDownCell$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.CellPointerDown,{...a,...n,row:n.row,column:n.col})})})),i.add(this.registerEventHandler(this.Event.CellPointerUp,()=>{var h;return(h=v.currentPointerUpCell$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.CellPointerUp,{...a,...n,row:n.row,column:n.col})})})),i.add(this.registerEventHandler(this.Event.CellPointerMove,()=>{var h;return(h=v.currentCellPosWithEvent$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.CellPointerMove,{...a,...n,row:n.row,column:n.col})})})),i.add(this.registerEventHandler(this.Event.DragOver,()=>{var h;return(h=S.currentCell$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.location.unitId,n.location.subUnitId);a&&this.fireEvent(this.Event.DragOver,{...a,...n,row:n.location.row,column:n.location.col})})})),i.add(this.registerEventHandler(this.Event.Drop,()=>{var h;return(h=S.endCell$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.location.unitId,n.location.subUnitId);a&&this.fireEvent(this.Event.Drop,{...a,...n,row:n.location.row,column:n.location.col})})})),i.add(this.registerEventHandler(this.Event.RowHeaderClick,()=>{var h;return(h=v.currentRowHeaderClick$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.RowHeaderClick,{...a,row:n.index})})})),i.add(this.registerEventHandler(this.Event.RowHeaderPointerDown,()=>{var h;return(h=v.currentRowHeaderPointerDown$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.RowHeaderPointerDown,{...a,row:n.index})})})),i.add(this.registerEventHandler(this.Event.RowHeaderPointerUp,()=>{var h;return(h=v.currentRowHeaderPointerUp$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.RowHeaderPointerUp,{...a,row:n.index})})})),i.add(this.registerEventHandler(this.Event.RowHeaderHover,()=>{var h;return(h=v.currentHoveredRowHeader$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.RowHeaderHover,{...a,row:n.index})})})),i.add(this.registerEventHandler(this.Event.ColumnHeaderClick,()=>{var h;return(h=v.currentColHeaderClick$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.ColumnHeaderClick,{...a,column:n.index})})})),i.add(this.registerEventHandler(this.Event.ColumnHeaderPointerDown,()=>{var h;return(h=v.currentColHeaderPointerDown$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.ColumnHeaderPointerDown,{...a,column:n.index})})})),i.add(this.registerEventHandler(this.Event.ColumnHeaderPointerUp,()=>{var h;return(h=v.currentColHeaderPointerUp$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.ColumnHeaderPointerUp,{...a,column:n.index})})})),i.add(this.registerEventHandler(this.Event.ColumnHeaderHover,()=>{var h;return(h=v.currentHoveredColHeader$)==null?void 0:h.pipe(m.filter(n=>!!n)).subscribe(n=>{const a=this.getSheetTarget(n.unitId,n.subUnitId);a&&this.fireEvent(this.Event.ColumnHeaderHover,{...a,column:n.index})})})),this.disposeWithMe(i))}));let o;const d=m.combineLatest([r.created$,t.lifecycle$]),l=new c.DisposableCollection;this.disposeWithMe(d.subscribe(([g,v])=>{if(g.type===c.UniverInstanceType.UNIVER_SHEET&&(o=g),v<=c.LifecycleStages.Rendered||!o)return;const S=this.getWorkbook(o.unitId);if(!S)return;l.dispose();const h=o.with(s.SheetScrollManagerService),n=o.with(I.SheetsSelectionsService);l.add(this.registerEventHandler(this.Event.Scroll,()=>h.validViewportScrollInfo$.subscribe(a=>{a&&this.fireEvent(this.Event.Scroll,{workbook:S,worksheet:S.getActiveSheet(),...a})}))),l.add(this.registerEventHandler(this.Event.SelectionMoveStart,()=>n.selectionMoveStart$.subscribe(a=>{var p;this.fireEvent(this.Event.SelectionMoveStart,{workbook:S,worksheet:S.getActiveSheet(),selections:(p=a==null?void 0:a.map(f=>f.range))!=null?p:[]})}))),l.add(this.registerEventHandler(this.Event.SelectionMoving,()=>n.selectionMoving$.subscribe(a=>{var p;this.fireEvent(this.Event.SelectionMoving,{workbook:S,worksheet:S.getActiveSheet(),selections:(p=a==null?void 0:a.map(f=>f.range))!=null?p:[]})}))),l.add(this.registerEventHandler(this.Event.SelectionMoveEnd,()=>n.selectionMoveEnd$.subscribe(a=>{var p;this.fireEvent(this.Event.SelectionMoveEnd,{workbook:S,worksheet:S.getActiveSheet(),selections:(p=a==null?void 0:a.map(f=>f.range))!=null?p:[]})}))),l.add(this.registerEventHandler(this.Event.SelectionChanged,()=>n.selectionChanged$.subscribe(a=>{var p;this.fireEvent(this.Event.SelectionChanged,{workbook:S,worksheet:S.getActiveSheet(),selections:(p=a==null?void 0:a.map(f=>f.range))!=null?p:[]})}))),o=null,this.disposeWithMe(l)}))}_initialize(e){this._initSheetUIEvent(e),this._initObserverListener(e);const r=e.get(c.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeClipboardChange,()=>r.beforeCommandExecuted(t=>{switch(t.id){case C.CopyCommand.id:case C.CutCommand.id:this._beforeClipboardChange();break}}))),this.disposeWithMe(this.registerEventHandler(this.Event.ClipboardChanged,()=>r.onCommandExecuted(t=>{switch(t.id){case C.CopyCommand.id:case C.CutCommand.id:this._clipboardChanged();break}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeClipboardPaste,()=>r.beforeCommandExecuted(t=>{switch(t.id){case s.SheetPasteShortKeyCommand.id:this._beforeClipboardPaste(t.params);break;case C.PasteCommand.id:this._beforeClipboardPasteAsync();break}}))),this.disposeWithMe(this.registerEventHandler(this.Event.ClipboardPasted,()=>r.onCommandExecuted(t=>{switch(t.id){case s.SheetPasteShortKeyCommand.id:this._clipboardPaste(t.params);break;case C.PasteCommand.id:this._clipboardPasteAsync();break}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetSkeletonChanged,()=>r.onCommandExecuted(t=>{if(I.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(t.id)>-1){const i=this.getActiveSheet();if(!i)return;const o=I.getSkeletonChangedEffectedRange(t,i.worksheet.getMaxColumns()).map(d=>{var l,g;return(g=(l=this.getWorkbook(d.unitId))==null?void 0:l.getSheetBySheetId(d.subUnitId))==null?void 0:g.getRange(d.range)}).filter(Boolean);if(!o.length)return;this.fireEvent(this.Event.SheetSkeletonChanged,{workbook:i.workbook,worksheet:i.worksheet,payload:t,skeleton:i.worksheet.getSkeleton(),effectedRanges:o})}})))}_generateClipboardCopyParam(){const e=this.getActiveWorkbook(),r=e==null?void 0:e.getActiveSheet(),t=e==null?void 0:e.getActiveRange();if(!e||!r||!t)return;const o=this._injector.get(s.ISheetClipboardService).generateCopyContent(e.getId(),r.getSheetId(),t.getRange());if(!o)return;const{html:d,plain:l}=o;return{workbook:e,worksheet:r,text:l,html:d,fromSheet:r,fromRange:t}}_beforeClipboardChange(){const e=this._generateClipboardCopyParam();if(e&&(this.fireEvent(this.Event.BeforeClipboardChange,e),e.cancel))throw new c.CanceledError}_clipboardChanged(){const e=this._generateClipboardCopyParam();e&&this.fireEvent(this.Event.ClipboardChanged,e)}_generateClipboardPasteParam(e){if(!e)return;const{htmlContent:r,textContent:t}=e,i=this.getActiveWorkbook(),o=i==null?void 0:i.getActiveSheet();return!i||!o?void 0:{workbook:i,worksheet:o,text:t,html:r}}async _generateClipboardPasteParamAsync(){const e=this.getActiveWorkbook(),r=e==null?void 0:e.getActiveSheet();if(!e||!r)return;const o=(await this._injector.get(C.IClipboardInterfaceService).read())[0];let d;if(o){const l=o.types,g=l.indexOf(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await o.getType(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(S=>S&&S.text()):"",v=l.indexOf(C.HTML_CLIPBOARD_MIME_TYPE)!==-1?await o.getType(C.HTML_CLIPBOARD_MIME_TYPE).then(S=>S&&S.text()):"";d={workbook:e,worksheet:r,text:g,html:v}}return d}_beforeClipboardPaste(e){const r=this._generateClipboardPasteParam(e);if(r&&(this.fireEvent(this.Event.BeforeClipboardPaste,r),r.cancel))throw new c.CanceledError}_clipboardPaste(e){const r=this._generateClipboardPasteParam(e);if(r&&(this.fireEvent(this.Event.ClipboardPasted,r),r.cancel))throw new c.CanceledError}async _beforeClipboardPasteAsync(){if(!C.supportClipboardAPI()){this._injector.get(c.ILogService).warn("[Facade]: The navigator object only supports the browser environment");return}const e=await this._generateClipboardPasteParamAsync();if(e&&(this.fireEvent(this.Event.BeforeClipboardPaste,e),e.cancel))throw new c.CanceledError}async _clipboardPasteAsync(){if(!C.supportClipboardAPI()){this._injector.get(c.ILogService).warn("[Facade]: The navigator object only supports the browser environment");return}const e=await this._generateClipboardPasteParamAsync();if(e&&(this.fireEvent(this.Event.ClipboardPasted,e),e.cancel))throw new c.CanceledError}customizeColumnHeader(e){var v,S;const r=this.getActiveWorkbook();if(!r){console.error("WorkBook not exist");return}const t=r==null?void 0:r.getId(),i=this._injector.get(u.IRenderManagerService),o=r.getActiveSheet(),d=o.getSheetId(),l=i.getRenderById(t);l&&((v=e.headerStyle)!=null&&v.size)&&(l.with(s.SheetSkeletonManagerService).setColumnHeaderSize(l,d,(S=e.headerStyle)==null?void 0:S.size),o==null||o.refreshCanvas()),this._getSheetRenderComponent(t,s.SHEET_VIEW_KEY.COLUMN).setCustomHeader(e),o==null||o.refreshCanvas()}customizeRowHeader(e){const r=this.getActiveWorkbook();if(!r){console.error("WorkBook not exist");return}const t=r==null?void 0:r.getId();this._getSheetRenderComponent(t,s.SHEET_VIEW_KEY.ROW).setCustomHeader(e)}registerSheetRowHeaderExtension(e,...r){const t=this._getSheetRenderComponent(e,s.SHEET_VIEW_KEY.ROW),i=t.register(...r);return c.toDisposable(()=>{i.dispose(),t.makeDirty(!0)})}registerSheetColumnHeaderExtension(e,...r){const t=this._getSheetRenderComponent(e,s.SHEET_VIEW_KEY.COLUMN),i=t.register(...r);return c.toDisposable(()=>{i.dispose(),t.makeDirty(!0)})}registerSheetMainExtension(e,...r){const t=this._getSheetRenderComponent(e,s.SHEET_VIEW_KEY.MAIN),i=t.register(...r);return c.toDisposable(()=>{i.dispose(),t.makeDirty(!0)})}_getSheetRenderComponent(e,r){const i=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!i)throw new Error(`Render Unit with unitId ${e} not found`);const{components:o}=i,d=o.get(r);if(!d)throw new Error("Render component not found");return d}getSheetHooks(){return this._injector.createInstance(b.FSheetHooks)}pasteIntoSheet(e,r,t){return this._commandService.executeCommand(s.SheetPasteShortKeyCommand.id,{htmlContent:e,textContent:r,files:t})}setProtectedRangeShadowStrategy(e){this._injector.get(s.SheetPermissionRenderManagerService).setProtectedRangeShadowStrategy(e)}getProtectedRangeShadowStrategy(){return this._injector.get(s.SheetPermissionRenderManagerService).getProtectedRangeShadowStrategy()}getProtectedRangeShadowStrategy$(){return this._injector.get(s.SheetPermissionRenderManagerService).getProtectedRangeShadowStrategy$()}setPermissionDialogVisible(e){this._injector.get(c.IPermissionService).setShowComponents(e)}}_.FUniver.extend(H);class y extends b.FWorkbook{openSiderbar(e){return this._logDeprecation("openSiderbar"),this._injector.get(C.ISidebarService).open(e)}openDialog(e){this._logDeprecation("openDialog");const t=this._injector.get(C.IDialogService).open({...e,onClose:()=>{t.dispose()}});return t}customizeColumnHeader(e){const r=this._workbook.getUnitId();this._getSheetRenderComponent(r,s.SHEET_VIEW_KEY.COLUMN).setCustomHeader(e)}customizeRowHeader(e){const r=this._workbook.getUnitId();this._getSheetRenderComponent(r,s.SHEET_VIEW_KEY.ROW).setCustomHeader(e)}_getSheetRenderComponent(e,r){const i=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!i)throw new Error(`Render Unit with unitId ${e} not found`);const{components:o}=i,d=o.get(r);if(!d)throw new Error("Render component not found");return d}_logDeprecation(e){this._injector.get(c.ILogService).warn("[FWorkbook]",`${e} is deprecated. Please use the function of the same name on "FUniver".`)}generateCellParams(e){const r=this.getActiveSheet();return{row:e.row,column:e.col,workbook:this,worksheet:r}}onCellClick(e){const r=this._injector.get(s.HoverManagerService);return c.toDisposable(r.currentClickedCell$.pipe(m.filter(t=>!!t)).subscribe(t=>{e(t)}))}onCellHover(e){const r=this._injector.get(s.HoverManagerService);return c.toDisposable(r.currentRichText$.pipe(m.filter(t=>!!t)).subscribe(e))}onCellPointerDown(e){const r=this._injector.get(s.HoverManagerService);return c.toDisposable(r.currentPointerDownCell$.subscribe(e))}onCellPointerUp(e){const r=this._injector.get(s.HoverManagerService);return c.toDisposable(r.currentPointerUpCell$.subscribe(e))}onCellPointerMove(e){const r=this._injector.get(s.HoverManagerService);return c.toDisposable(r.currentCellPosWithEvent$.pipe(m.filter(t=>!!t)).subscribe(t=>{e(t,t.event)}))}onDragOver(e){const r=this._injector.get(s.DragManagerService);return c.toDisposable(r.currentCell$.pipe(m.filter(t=>!!t)).subscribe(t=>{e(t)}))}onDrop(e){const r=this._injector.get(s.DragManagerService);return c.toDisposable(r.endCell$.pipe(m.filter(t=>!!t)).subscribe(t=>{e(t)}))}startEditing(){const e=this._injector.get(c.ICommandService);return this._injector.get(s.IEditorBridgeService).isVisible().visible?!0:e.syncExecuteCommand(s.SetCellEditVisibleOperation.id,{eventType:u.DeviceInputEventType.Dblclick,unitId:this._workbook.getUnitId(),visible:!0})}async endEditing(e){const r=this._injector.get(c.ICommandService);return this._injector.get(s.IEditorBridgeService).isVisible().visible&&r.syncExecuteCommand(s.SetCellEditVisibleOperation.id,{eventType:u.DeviceInputEventType.Keyboard,keycode:e?C.KeyCode.ENTER:C.KeyCode.ESC,visible:!1,unitId:this._workbook.getUnitId()}),await c.awaitTime(0),!0}endEditingAsync(e=!0){return this.endEditing(e)}abortEditingAsync(){return this.endEditingAsync(!1)}isCellEditing(){return this._injector.get(s.IEditorBridgeService).isVisible().visible}getScrollStateBySheetId(e){const r=this._workbook.getUnitId(),i=this._injector.get(u.IRenderManagerService).getRenderById(r);return i?i.with(s.SheetScrollManagerService).getScrollStateByParam({unitId:r,sheetId:e}):null}disableSelection(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);return t&&t.with(s.ISheetSelectionRenderService).disableSelection(),this}enableSelection(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);return t&&t.with(s.ISheetSelectionRenderService).enableSelection(),this}transparentSelection(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);return t&&t.with(s.ISheetSelectionRenderService).transparentSelection(),this}showSelection(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);return t&&t.with(s.ISheetSelectionRenderService).showSelection(),this}}b.FWorkbook.extend(y);class D extends b.FWorksheet{refreshCanvas(){const e=this._injector.get(u.IRenderManagerService),r=this._fWorkbook.id,t=e.getRenderById(r);if(!t)throw new Error(`Render Unit with unitId ${r} not found`);t.with(s.SheetSkeletonManagerService).reCalculate();const i=t.mainComponent;if(!i)throw new Error("Main component not found");return i.makeDirty(),this}highlightRanges(e,r,t){const i=this._injector.get(s.IMarkSelectionService),o=[];for(const d of e){const l=d.getRange(),g=i.addShapeWithNoFresh({range:l,style:r,primary:t});g&&o.push(g)}if(i.refreshShapes(),o.length===0)throw new Error("Failed to highlight current range");return c.toDisposable(()=>{o.forEach(d=>{i.removeShape(d)})})}zoom(e){const r=this._injector.get(c.ICommandService),t=Math.min(Math.max(e,.1),4);return r.executeCommand(s.SetZoomRatioCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),zoomRatio:t}),this}getZoom(){return this._worksheet.getZoomRatio()}getVisibleRange(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!t)return null;const o=t.with(s.SheetSkeletonManagerService).getCurrentSkeleton();return o?o.getVisibleRangeByViewport(u.SHEET_VIEWPORT_KEY.VIEW_MAIN):null}getVisibleRangesOfAllViewports(){const e=this._workbook.getUnitId(),t=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!t)return null;const o=t.with(s.SheetSkeletonManagerService).getCurrentSkeleton();return o?o.getVisibleRanges():null}scrollToCell(e,r,t){const i=this._workbook.getUnitId(),d=this._injector.get(u.IRenderManagerService).getRenderById(i);return d&&(d==null?void 0:d.with(s.SheetsScrollRenderController)).scrollToCell(e,r,t),this}getScrollState(){const e={offsetX:0,offsetY:0,sheetViewStartColumn:0,sheetViewStartRow:0},r=this._workbook.getUnitId(),t=this._worksheet.getSheetId(),o=this._injector.get(u.IRenderManagerService).getRenderById(r);return o&&o.with(s.SheetScrollManagerService).getScrollStateByParam({unitId:r,sheetId:t})||e}onScroll(e){var o;const r=this._workbook.getUnitId(),i=(o=this._injector.get(u.IRenderManagerService).getRenderById(r))==null?void 0:o.with(s.SheetScrollManagerService);if(i){const d=i.validViewportScrollInfo$.subscribe(l=>{e(l)});return c.toDisposable(d)}return c.toDisposable(()=>{})}getSkeleton(){var r,t;const e=(r=this._injector.get(u.IRenderManagerService).getRenderById(this._workbook.getUnitId()))==null?void 0:r.with(s.SheetSkeletonManagerService);return(t=e==null?void 0:e.getWorksheetSkeleton(this._worksheet.getSheetId()))==null?void 0:t.skeleton}autoResizeColumn(e){return this.autoResizeColumns(e,1)}autoResizeColumns(e,r){const t=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),o=[{startColumn:e,endColumn:e+r-1,startRow:0,endRow:this._worksheet.getRowCount()-1}];return this._commandService.syncExecuteCommand(s.SetWorksheetColAutoWidthCommand.id,{unitId:t,subUnitId:i,ranges:o}),this}setColumnAutoWidth(e,r){return this.autoResizeColumns(e,r)}autoResizeRows(e,r){const t=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),o=[{startRow:e,endRow:e+r-1,startColumn:0,endColumn:this._worksheet.getColumnCount()-1}];return this._commandService.syncExecuteCommand(I.SetWorksheetRowIsAutoHeightCommand.id,{unitId:t,subUnitId:i,ranges:o}),this}customizeColumnHeader(e){var l,g;const r=this._workbook.getUnitId(),t=this._worksheet.getSheetId(),o=this._injector.get(u.IRenderManagerService).getRenderById(r);o&&((l=e.headerStyle)!=null&&l.size)&&o.with(s.SheetSkeletonManagerService).setColumnHeaderSize(o,t,(g=e.headerStyle)==null?void 0:g.size),this._getSheetRenderComponent(r,s.SHEET_VIEW_KEY.COLUMN).setCustomHeader(e,t)}customizeRowHeader(e){var l,g;const r=this._workbook.getUnitId(),t=this._worksheet.getSheetId(),o=this._injector.get(u.IRenderManagerService).getRenderById(r);o&&((l=e.headerStyle)!=null&&l.size)&&o.with(s.SheetSkeletonManagerService).setRowHeaderSize(o,t,(g=e.headerStyle)==null?void 0:g.size),this._getSheetRenderComponent(r,s.SHEET_VIEW_KEY.ROW).setCustomHeader(e,t)}setColumnHeaderHeight(e){const r=this._workbook.getUnitId(),t=this._worksheet.getSheetId();return this._commandService.executeCommand(s.SetColumnHeaderHeightCommand.id,{unitId:r,subUnitId:t,size:e}),this}setRowHeaderWidth(e){const r=this._workbook.getUnitId(),t=this._worksheet.getSheetId();return this._commandService.executeCommand(s.SetRowHeaderWidthCommand.id,{unitId:r,subUnitId:t,size:e}),this}_getSheetRenderComponent(e,r){const i=this._injector.get(u.IRenderManagerService).getRenderById(e);if(!i)throw new Error(`Render Unit with unitId ${e} not found`);const{components:o}=i,d=o.get(r);if(!d)throw new Error("Render component not found");return d}}b.FWorksheet.extend(D);class T extends b.FPermission{setPermissionDialogVisible(e){this._permissionService.setShowComponents(e)}}b.FPermission.extend(T);class B extends b.FSheetHooks{onCellPointerMove(e){return c.toDisposable(this._injector.get(s.HoverManagerService).currentPosition$.subscribe(e))}onCellPointerOver(e){return c.toDisposable(this._injector.get(s.HoverManagerService).currentCell$.subscribe(e))}onCellDragOver(e){return c.toDisposable(this._injector.get(s.DragManagerService).currentCell$.subscribe(e))}onCellDrop(e){return c.toDisposable(this._injector.get(s.DragManagerService).endCell$.subscribe(e))}onCellRender(e,r=c.InterceptorEffectEnum.Style,t=I.InterceptCellContentPriority.DATA_VALIDATION){return this._injector.get(I.SheetInterceptorService).intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r,handler:(i,o,d)=>(i&&!i.customRender&&e&&(i.customRender=[...e]),d(i)),priority:t})}onBeforeCellEdit(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(r=>{const t=r.params;r.id===s.SetCellEditVisibleOperation.id&&t.visible&&e(t)})}onAfterCellEdit(e){return this._injector.get(c.ICommandService).onCommandExecuted(r=>{const t=r.params;r.id===s.SetCellEditVisibleOperation.id&&!t.visible&&e(t)})}}b.FSheetHooks.extend(B);const k={CellClicked:"CellClicked",CellPointerDown:"CellPointerDown",CellPointerUp:"CellPointerUp",CellPointerMove:"CellPointerMove",CellHover:"CellHover"};class x{get BeforeClipboardChange(){return"BeforeClipboardChange"}get ClipboardChanged(){return"ClipboardChanged"}get BeforeClipboardPaste(){return"BeforeClipboardPaste"}get ClipboardPasted(){return"ClipboardPasted"}get BeforeSheetEditStart(){return"BeforeSheetEditStart"}get SheetEditStarted(){return"SheetEditStarted"}get SheetEditChanging(){return"SheetEditChanging"}get BeforeSheetEditEnd(){return"BeforeSheetEditEnd"}get SheetEditEnded(){return"SheetEditEnded"}get CellClicked(){return k.CellClicked}get CellHover(){return k.CellHover}get CellPointerDown(){return k.CellPointerDown}get CellPointerUp(){return k.CellPointerUp}get CellPointerMove(){return k.CellPointerMove}get DragOver(){return"DragOver"}get Drop(){return"Drop"}get Scroll(){return"Scroll"}get SelectionMoveStart(){return"SelectionMoveStart"}get SelectionChanged(){return"SelectionChanged"}get SelectionMoving(){return"SelectionMoving"}get SelectionMoveEnd(){return"SelectionMoveEnd"}get RowHeaderClick(){return"RowHeaderClick"}get RowHeaderPointerDown(){return"RowHeaderPointerDown"}get RowHeaderPointerUp(){return"RowHeaderPointerUp"}get RowHeaderHover(){return"RowHeaderHover"}get ColumnHeaderClick(){return"ColumnHeaderClick"}get ColumnHeaderPointerDown(){return"ColumnHeaderPointerDown"}get ColumnHeaderPointerUp(){return"ColumnHeaderPointerUp"}get ColumnHeaderHover(){return"ColumnHeaderHover"}get SheetSkeletonChanged(){return"SheetSkeletonChanged"}get BeforeSheetZoomChange(){return"BeforeSheetZoomChange"}get SheetZoomChanged(){return"SheetZoomChanged"}}_.FEventName.extend(x);class P{get SHEET_VIEWPORT_KEY(){return u.SHEET_VIEWPORT_KEY}}_.FEnum.extend(P);class W extends b.FRange{getCell(){var l;const e=this._injector.get(u.IRenderManagerService),r=this._injector.get(c.ILogService),t=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),o=e.getRenderById(t),d=(l=o==null?void 0:o.with(s.SheetSkeletonManagerService).getSkeletonParam(i))==null?void 0:l.skeleton;if(!d)throw r.error("[Facade]: `FRange.getCell` can only be called in current worksheet"),new Error("`FRange.getCell` can only be called in current worksheet");return d.getCellWithCoordByIndex(this._range.startRow,this._range.startColumn)}getCellRect(){const{startX:e,startY:r,endX:t,endY:i}=this.getCell(),o={x:e,y:r,width:t-e,height:i-r,top:r,left:e,bottom:i,right:t};return{...o,toJSON:()=>JSON.stringify(o)}}generateHTML(){var t;const r=this._injector.get(s.ISheetClipboardService).generateCopyContent(this._workbook.getUnitId(),this._worksheet.getSheetId(),this._range);return(t=r==null?void 0:r.html)!=null?t:""}attachPopup(e){var d,l,g;e.direction=(d=e.direction)!=null?d:"horizontal",e.extraProps=(l=e.extraProps)!=null?l:{},e.offset=(g=e.offset)!=null?g:[0,0];const{key:r,disposableCollection:t}=M(e,this._injector.get(C.ComponentManager)),o=this._injector.get(s.SheetCanvasPopManagerService).attachPopupToCell(this._range.startRow,this._range.startColumn,{...e,componentKey:r},this.getUnitId(),this._worksheet.getSheetId());return o?(t.add(o),t):(t.dispose(),null)}attachAlertPopup(e){const r=this._injector.get(s.CellAlertManagerService),t={workbook:this._workbook,worksheet:this._worksheet,row:this._range.startRow,col:this._range.startColumn,unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId()};return r.showAlert({...e,location:t}),{dispose:()=>{r.removeAlert(e.key)}}}attachRangePopup(e){var d,l,g;e.direction=(d=e.direction)!=null?d:"top-center",e.extraProps=(l=e.extraProps)!=null?l:{},e.offset=(g=e.offset)!=null?g:[0,0];const{key:r,disposableCollection:t}=M(e,this._injector.get(C.ComponentManager)),o=this._injector.get(s.SheetCanvasPopManagerService).attachRangePopup(this._range,{...e,componentKey:r},this.getUnitId(),this._worksheet.getSheetId());return o?(t.add(o),t):(t.dispose(),null)}highlight(e,r){const t=this._injector.get(s.IMarkSelectionService),i=t.addShape({range:this._range,style:e,primary:r});if(!i)throw new Error("Failed to highlight current range");return c.toDisposable(()=>{t.removeShape(i)})}showDropdown(e){return this._injector.get(s.ISheetCellDropdownManagerService).showDropdown(e)}}b.FRange.extend(W);function M(w,e){const{componentKey:r,isVue3:t}=w;let i;const o=new c.DisposableCollection;return typeof r=="string"?i=r:(i=`External_${c.generateRandomId(6)}`,o.add(e.register(i,r,{framework:t?"vue3":"react"}))),{key:i,disposableCollection:o}}E.FSheetsUIEnum=P,E.transformComponentKey=M,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
|