@univerjs/sheets-ui 0.5.4 → 0.5.5-nightly.202501201336

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +35 -35
  3. package/lib/es/facade.js +703 -398
  4. package/lib/es/index.js +10826 -10436
  5. package/lib/index.css +1 -1
  6. package/lib/types/commands/commands/set-selection.command.d.ts +5 -0
  7. package/lib/types/common/keys.d.ts +1 -0
  8. package/lib/types/controllers/clipboard/utils.d.ts +0 -11
  9. package/lib/types/controllers/editor/data-sync.controller.d.ts +3 -1
  10. package/lib/types/controllers/editor/editing.render-controller.d.ts +3 -4
  11. package/lib/types/controllers/editor/formula-editor.controller.d.ts +4 -2
  12. package/lib/types/facade/f-event.d.ts +264 -11
  13. package/lib/types/facade/f-range.d.ts +18 -0
  14. package/lib/types/facade/f-univer.d.ts +2 -1
  15. package/lib/types/facade/f-workbook.d.ts +18 -24
  16. package/lib/types/facade/f-worksheet.d.ts +26 -5
  17. package/lib/types/index.d.ts +2 -1
  18. package/lib/types/services/auto-fill/tools.d.ts +5 -0
  19. package/lib/types/services/canvas-pop-manager.service.d.ts +41 -6
  20. package/lib/types/services/clipboard/type.d.ts +60 -4
  21. package/lib/types/services/editor/cell-editor-resize.service.d.ts +3 -2
  22. package/lib/types/services/editor-bridge.service.d.ts +3 -1
  23. package/lib/types/services/hover-manager.service.d.ts +41 -0
  24. package/lib/types/services/selection/base-selection-render.service.d.ts +4 -0
  25. package/lib/types/services/selection/selection-control.d.ts +2 -2
  26. package/lib/types/services/sheet-skeleton-manager.service.d.ts +2 -1
  27. package/lib/types/views/editor-container/hooks.d.ts +8 -0
  28. package/lib/umd/facade.js +1 -1
  29. package/lib/umd/index.js +26 -26
  30. package/package.json +12 -12
  31. package/LICENSE +0 -176
@@ -57,6 +57,7 @@ interface IFRangeSheetsUIMixin {
57
57
  ```
58
58
  let sheet = univerAPI.getActiveWorkbook().getActiveSheet();
59
59
  let range = sheet.getRange(2, 2, 3, 3);
60
+ univerAPI.getActiveWorkbook().setActiveRange(range);
60
61
  let disposable = range.attachPopup({
61
62
  componentKey: 'univer.sheet.cell-alert',
62
63
  extraProps: { alert: { type: 0, title: 'This is an Info', message: 'This is an info message' } },
@@ -76,6 +77,22 @@ interface IFRangeSheetsUIMixin {
76
77
  * ```
77
78
  */
78
79
  attachAlertPopup(alert: Omit<ICellAlert, 'location'>): IDisposable;
80
+ /**
81
+ * Attach a DOM popup to the start cell of current range.
82
+ * @param alert The alert to attach
83
+ * @returns The disposable object to detach the alert.
84
+ * @example
85
+ * ```ts
86
+ let sheet = univerAPI.getActiveWorkbook().getActiveSheet();
87
+ let range = sheet.getRange(2, 2, 3, 3);
88
+ univerAPI.getActiveWorkbook().setActiveRange(range);
89
+ let disposable = range.attachRangePopup({
90
+ componentKey: 'univer.sheet.single-dom-popup',
91
+ extraProps: { alert: { type: 0, title: 'This is an Info', message: 'This is an info message' } },
92
+ });
93
+ * ```
94
+ */
95
+ attachRangePopup(popup: IFCanvasPopup): Nullable<IDisposable>;
79
96
  /**
80
97
  * Highlight the range with the specified style and primary cell.
81
98
  * @param style - style for highlight range.
@@ -97,6 +114,7 @@ declare module '@univerjs/sheets/facade' {
97
114
  * Transform component key
98
115
  * @param {IFComponentKey} component - The component key to transform.
99
116
  * @param {ComponentManager} componentManager - The component manager to use for registration.
117
+ * @returns {string} The transformed component key.
100
118
  */
101
119
  export declare function transformComponentKey(component: IFComponentKey, componentManager: ComponentManager): {
102
120
  key: string;
@@ -7,7 +7,7 @@ export interface IFUniverSheetsUIMixin {
7
7
  * @param {IColumnsHeaderCfgParam} cfg The configuration of the column header.
8
8
  * @example
9
9
  * ```typescript
10
- * univerAPI.customizeColumnHeader({ headerStyle: { backgroundColor: 'pink', fontSize: 9 }, columnsCfg: ['MokaII', undefined, null, { text: 'Size', textAlign: 'left' }] });
10
+ * univerAPI.customizeColumnHeader({ headerStyle: { fontColor: '#fff', size: 40, backgroundColor: '#4e69ee', fontSize: 9 }, columnsCfg: ['MokaII', undefined, null, { text: 'Size', textAlign: 'left' }] });
11
11
  * ```
12
12
  */
13
13
  customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void;
@@ -48,6 +48,7 @@ export interface IFUniverSheetsUIMixin {
48
48
  }
49
49
  export declare class FUniverSheetsUIMixin extends FUniver implements IFUniverSheetsUIMixin {
50
50
  private _initSheetUIEvent;
51
+ _initObserverListener(injector: Injector): void;
51
52
  _initialize(injector: Injector): void;
52
53
  private _generateClipboardCopyParam;
53
54
  private _beforeClipboardChange;
@@ -1,9 +1,9 @@
1
1
  import { IDisposable, Nullable } from '@univerjs/core';
2
2
  import { IMouseEvent, IPointerEvent } from '@univerjs/engine-render';
3
3
  import { ICellPosWithEvent, IDragCellPosition, IHoverRichTextInfo, IHoverRichTextPosition, IScrollState } from '@univerjs/sheets-ui';
4
+ import { ICellEventParam } from './f-event';
4
5
  import { FWorkbook } from '@univerjs/sheets/facade';
5
6
  import { IDialogPartMethodOptions, ISidebarMethodOptions } from '@univerjs/ui';
6
- import { ICellEventParam, IFSheetsUIEventParamConfig } from './f-event';
7
7
  export interface IFWorkbookSheetsUIMixin {
8
8
  /**
9
9
  * Open a sidebar.
@@ -20,33 +20,32 @@ export interface IFWorkbookSheetsUIMixin {
20
20
  */
21
21
  openDialog(dialog: IDialogPartMethodOptions): IDisposable;
22
22
  /**
23
- * Subscribe to cell click events
24
- * @param callback - The callback function to be called when a cell is clicked
25
- * @returns A disposable object that can be used to unsubscribe from the event
23
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CellClick, () => {})` instead
26
24
  */
27
25
  onCellClick(callback: (cell: IHoverRichTextInfo) => void): IDisposable;
28
26
  /**
29
- * Subscribe cell hover events
30
- * @param callback - The callback function to be called when a cell is hovered
31
- * @returns A disposable object that can be used to unsubscribe from the event
27
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CellHover, () => {})` instead
32
28
  */
33
29
  onCellHover(callback: (cell: IHoverRichTextPosition) => void): IDisposable;
34
30
  /**
35
- * Subscribe to pointer move events on workbook. Just like onCellHover, but with event information.
36
- * @param {function(ICellPosWithEvent): any} callback The callback function accept cell location and event.
31
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CellPointerMove, () => {})` instead
37
32
  */
38
33
  onCellPointerMove(callback: (cell: ICellPosWithEvent, event: IPointerEvent | IMouseEvent) => void): IDisposable;
39
34
  /**
40
- * Subscribe to cell pointer down events.
41
- * @param {function(ICellPosWithEvent): any} callback The callback function accept cell location and event.
35
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CellPointerDown, () => {})` instead
42
36
  */
43
37
  onCellPointerDown(callback: (cell: ICellPosWithEvent) => void): IDisposable;
44
38
  /**
45
- * Subscribe to cell pointer up events.
46
- * @param {function(ICellPosWithEvent): any} callback The callback function accept cell location and event.
39
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CellPointerUp, () => {})` instead
47
40
  */
48
41
  onCellPointerUp(callback: (cell: ICellPosWithEvent) => void): IDisposable;
42
+ /**
43
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.DragOver, () => {})` instead
44
+ */
49
45
  onDragOver(callback: (cell: IDragCellPosition) => void): IDisposable;
46
+ /**
47
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.Drop, () => {})` instead
48
+ */
50
49
  onDrop(callback: (cell: IDragCellPosition) => void): IDisposable;
51
50
  /**
52
51
  * Start the editing process
@@ -58,22 +57,18 @@ export interface IFWorkbookSheetsUIMixin {
58
57
  */
59
58
  startEditing(): boolean;
60
59
  /**
61
- * Use endEditingAsync as instead
62
- * @deprecated
63
- * End the editing process
64
- * @async
65
- * @param save - Whether to save the changes
66
- * @returns A promise that resolves to a boolean value
67
- * @example
68
- * ``` ts
69
- * univerAPI.getActiveWorkbook().endEditing(true);
70
- * ```
60
+ * @deprecated Use `endEditingAsync` as instead
71
61
  */
72
62
  endEditing(save?: boolean): Promise<boolean>;
73
63
  /**
74
64
  * @async
65
+ * End the editing process
75
66
  * @param {boolean} save - Whether to save the changes, default is true
76
67
  * @returns {Promise<boolean>} A promise that resolves to a boolean value
68
+ * @example
69
+ * ```ts
70
+ * await univerAPI.getActiveWorkbook().endEditingAsync(false);
71
+ * ```
77
72
  */
78
73
  endEditingAsync(save?: boolean): Promise<boolean>;
79
74
  getScrollStateBySheetId(sheetId: string): Nullable<IScrollState>;
@@ -115,7 +110,6 @@ export declare class FWorkbookSheetsUIMixin extends FWorkbook implements IFWorkb
115
110
  openSiderbar(params: ISidebarMethodOptions): IDisposable;
116
111
  openDialog(dialog: IDialogPartMethodOptions): IDisposable;
117
112
  private _logDeprecation;
118
- addUIEvent(event: keyof IFSheetsUIEventParamConfig, _callback: (params: IFSheetsUIEventParamConfig[typeof event]) => void): IDisposable;
119
113
  generateCellParams(cell: IHoverRichTextPosition | ICellPosWithEvent): ICellEventParam;
120
114
  onCellClick(callback: (cell: IHoverRichTextInfo) => void): IDisposable;
121
115
  onCellHover(callback: (cell: IHoverRichTextPosition) => void): IDisposable;
@@ -1,4 +1,5 @@
1
1
  import { IDisposable, IRange, Nullable } from '@univerjs/core';
2
+ import { SpreadsheetSkeleton } from '@univerjs/engine-render';
2
3
  import { IScrollState, IViewportScrollState } from '@univerjs/sheets-ui';
3
4
  import { FWorksheet } from '@univerjs/sheets/facade';
4
5
  export interface IFWorksheetSkeletonMixin {
@@ -65,14 +66,32 @@ export interface IFWorksheetSkeletonMixin {
65
66
  */
66
67
  getScrollState(): IScrollState;
67
68
  /**
68
- * Invoked when scrolling the sheet.
69
- * @param {function(Nullable<IViewportScrollState>): void} callback The scrolling callback function.
70
- * @returns {IDisposable} The disposable object to remove the event listener.
69
+ * Get the skeleton service of the worksheet.
70
+ * @returns {Nullable<SpreadsheetSkeleton>} The skeleton of the worksheet.
71
71
  * @example
72
- * ``` ts
73
- * univerAPI.getActiveWorkbook().getActiveSheet().onScroll((params) => {...})
72
+ * ```ts
73
+ * const fWorkbook = univerAPI.getActiveWorkbook();
74
+ * const fWorksheet = fWorkbook.getActiveSheet();
75
+ * const skeleton = fWorksheet.getSkeleton();
76
+ * console.log(skeleton);
74
77
  * ```
75
78
  */
79
+ getSkeleton(): Nullable<SpreadsheetSkeleton>;
80
+ /**
81
+ * Set the given column width to fix-content.
82
+ * @param {number} columnPosition - Column position
83
+ * @param {number} numColumn - Number of columns
84
+ * @example
85
+ * ```ts
86
+ * const fWorkbook = univerAPI.getActiveWorkbook();
87
+ * const fWorksheet = fWorkbook.getActiveSheet();
88
+ * fWorksheet.setColumnAutoWidth(0, 3);
89
+ * ```
90
+ */
91
+ setColumnAutoWidth(columnPosition: number, numColumn: number): FWorksheet;
92
+ /**
93
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.Scroll, () => {})` instead
94
+ */
76
95
  onScroll(callback: (params: Nullable<IViewportScrollState>) => void): IDisposable;
77
96
  }
78
97
  export declare class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSkeletonMixin {
@@ -83,6 +102,8 @@ export declare class FWorksheetSkeletonMixin extends FWorksheet implements IFWor
83
102
  scrollToCell(row: number, column: number): FWorksheet;
84
103
  getScrollState(): IScrollState;
85
104
  onScroll(callback: (params: Nullable<IViewportScrollState>) => void): IDisposable;
105
+ getSkeleton(): Nullable<SpreadsheetSkeleton>;
106
+ setColumnAutoWidth(columnPosition: number, numColumn: number): FWorksheet;
86
107
  }
87
108
  declare module '@univerjs/sheets/facade' {
88
109
  interface FWorksheet extends IFWorksheetSkeletonMixin {
@@ -92,6 +92,7 @@ export { FormatPainterStatus, IFormatPainterService } from './services/format-pa
92
92
  export type { IFormatPainterBeforeApplyHookParams, IFormatPainterHook } from './services/format-painter/format-painter.service';
93
93
  export { SELECTION_SHAPE_DEPTH } from './services/selection/const';
94
94
  export { type IBaseSheetBarProps } from './views/sheet-bar/sheet-bar-tabs/SheetBarItem';
95
+ export { SetWorksheetColAutoWidthCommand } from './commands/commands/set-worksheet-auto-col-width.command';
95
96
  export { AutoClearContentCommand, AutoFillCommand } from './commands/commands/auto-fill.command';
96
97
  export { type ISheetPasteByShortKeyParams, type ISheetPasteParams, SheetCopyCommand, SheetCutCommand, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, } from './commands/commands/clipboard.command';
97
98
  export { DeleteRangeMoveLeftConfirmCommand } from './commands/commands/delete-range-move-left-confirm.command';
@@ -108,7 +109,7 @@ export { ApplyFormatPainterCommand, SetInfiniteFormatPainterCommand, SetOnceForm
108
109
  export { SetColumnFrozenCommand, SetRowFrozenCommand, SetSelectionFrozenCommand } from './commands/commands/set-frozen.command';
109
110
  export { type IScrollCommandParams, type IScrollToCellCommandParams, type ISetScrollRelativeCommandParams, ResetScrollCommand, ScrollCommand, ScrollToCellCommand, SetScrollRelativeCommand, } from './commands/commands/set-scroll.command';
110
111
  export { ExpandSelectionCommand, JumpOver, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, SelectAllCommand } from './commands/commands/set-selection.command';
111
- export { ChangeZoomRatioCommand, SetZoomRatioCommand } from './commands/commands/set-zoom-ratio.command';
112
+ export { ChangeZoomRatioCommand, type ISetZoomRatioCommandParams, SetZoomRatioCommand } from './commands/commands/set-zoom-ratio.command';
112
113
  export { ShowMenuListCommand } from './commands/commands/unhide.command';
113
114
  export { ChangeSheetProtectionFromSheetBarCommand, DeleteWorksheetProtectionFormSheetBarCommand, } from './commands/commands/worksheet-protection.command';
114
115
  export { SetActivateCellEditOperation } from './commands/operations/activate-cell-edit.operation';
@@ -106,3 +106,8 @@ export declare function getAutoFillRepeatRange(sourceRange: IRange, targetRange:
106
106
  * @returns
107
107
  */
108
108
  export declare function needsUpdateCellValue(cell: ICellData): boolean;
109
+ /**
110
+ * Remove cell.custom
111
+ * @param cell
112
+ */
113
+ export declare function removeCellCustom(cell: Nullable<ICellData>): void;
@@ -1,10 +1,12 @@
1
- import { DrawingTypeEnum, ICommandInfo, INeedCheckDisposable, Nullable, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
1
+ import { DrawingTypeEnum, ICommandInfo, INeedCheckDisposable, IRange, Nullable, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
2
2
  import { BaseObject, IBoundRectNoAngle, Viewport, IRenderManagerService } from '@univerjs/engine-render';
3
- import { ISheetLocationBase, RefRangeService } from '@univerjs/sheets';
3
+ import { ISheetLocationBase, RefRangeService, SheetsSelectionsService } from '@univerjs/sheets';
4
4
  import { IPopup, ICanvasPopupService } from '@univerjs/ui';
5
+ import { ISheetSelectionRenderService } from './selection/base-selection-render.service';
5
6
  export interface ICanvasPopup extends Omit<IPopup, 'anchorRect' | 'anchorRect$' | 'unitId' | 'subUnitId' | 'canvasElement'> {
6
7
  mask?: boolean;
7
8
  extraProps?: Record<string, unknown>;
9
+ showOnSelectionMoving?: boolean;
8
10
  }
9
11
  interface IPopupMenuItem {
10
12
  label: string;
@@ -20,8 +22,12 @@ export declare class SheetCanvasPopManagerService extends Disposable {
20
22
  private readonly _univerInstanceService;
21
23
  private readonly _refRangeService;
22
24
  private readonly _commandService;
25
+ private readonly _refSelectionsService;
26
+ private readonly _selectionManagerService;
23
27
  private _popupMenuFeatureMap;
24
- constructor(_globalPopupManagerService: ICanvasPopupService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _refRangeService: RefRangeService, _commandService: ICommandService);
28
+ constructor(_globalPopupManagerService: ICanvasPopupService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _refRangeService: RefRangeService, _commandService: ICommandService, _refSelectionsService: ISheetSelectionRenderService, _selectionManagerService: SheetsSelectionsService);
29
+ private _isSelectionMoving;
30
+ private _initMoving;
25
31
  /**
26
32
  * Register a feature menu callback for a specific drawing type.such as image, chart, etc.
27
33
  */
@@ -49,20 +55,49 @@ export declare class SheetCanvasPopManagerService extends Disposable {
49
55
  attachPopupToAbsolutePosition(bound: IBoundRectNoAngle, popup: ICanvasPopup, _unitId?: string, _subUnitId?: string): {
50
56
  dispose: () => void;
51
57
  canDispose: () => boolean;
52
- } | null;
58
+ } | null | undefined;
53
59
  /**
54
- *
60
+ * Bind popup to the right part of cell at(row, col).
61
+ * This popup would move with the cell.
55
62
  * @param row
56
63
  * @param col
57
64
  * @param popup
58
65
  * @param _unitId
59
66
  * @param _subUnitId
60
67
  * @param viewport
68
+ * @returns
69
+ */
70
+ attachPopupToCell(row: number, col: number, popup: ICanvasPopup, _unitId?: string, _subUnitId?: string, viewport?: Viewport): Nullable<INeedCheckDisposable>;
71
+ /**
72
+ * attach Comp to floatDOM
73
+ * @param range
74
+ * @param popup
75
+ * @param _unitId
76
+ * @param _subUnitId
77
+ * @param viewport
61
78
  * @param showOnSelectionMoving
62
79
  * @returns
63
80
  */
64
- attachPopupToCell(row: number, col: number, popup: ICanvasPopup, _unitId?: string, _subUnitId?: string, viewport?: Viewport, showOnSelectionMoving?: boolean): Nullable<INeedCheckDisposable>;
81
+ attachRangePopup(range: IRange, popup: ICanvasPopup, _unitId?: string, _subUnitId?: string, viewport?: Viewport, showOnSelectionMoving?: boolean): Nullable<INeedCheckDisposable>;
82
+ /**
83
+ *
84
+ * @param initialRow
85
+ * @param initialCol
86
+ * @param currentRender
87
+ * @param skeleton
88
+ * @param activeViewport
89
+ * @returns
90
+ */
65
91
  private _createCellPositionObserver;
66
92
  private _calcCellPositionByCell;
93
+ /**
94
+ * Unlike _createCellPositionObserver, this accept a range not a single cell.
95
+ * @param initialRow
96
+ * @param initialCol
97
+ * @param currentRender
98
+ * @param skeleton
99
+ * @param activeViewport
100
+ */
101
+ private _createRangePositionObserver;
67
102
  }
68
103
  export {};
@@ -56,20 +56,36 @@ export interface ISpecialPasteInfo {
56
56
  /**
57
57
  * `ClipboardHook` could:
58
58
  * 1. Before copy/cut/paste, decide whether to execute the command and prepare caches if necessary.
59
- * 1. When copying, decide what content could be written into clipboard.
60
- * 1. When pasting, get access to the clipboard content and append mutations to the paste command.
59
+ * 2. When copying, decide what content could be written into clipboard.
60
+ * 3. When pasting, get access to the clipboard content and append mutations to the paste command.
61
61
  */
62
62
  export interface ISheetClipboardHook {
63
+ /**
64
+ * The unique id of the hook.
65
+ */
63
66
  id: string;
67
+ /**
68
+ * Whether this hook is the default hook.
69
+ */
64
70
  isDefaultHook?: boolean;
71
+ /**
72
+ * Only special paste info should be provided, which will replace the default hook.
73
+ */
65
74
  specialPasteInfo?: ISpecialPasteInfo;
75
+ /**
76
+ * The priority of the hook. The higher the priority, the earlier the hook would be called.
77
+ */
66
78
  priority?: number;
67
79
  /**
68
80
  * The callback would be called after the clipboard service has decided what region need to be copied.
69
81
  * Features could use this hook to build copying cache or any other pre-copy jobs.
82
+ * @param unitId
83
+ * @param subUnitId
84
+ * @param range
70
85
  */
71
86
  onBeforeCopy?(unitId: string, subUnitId: string, range: IRange): void;
72
87
  /**
88
+ * Properties that would be appended to the td element.
73
89
  *
74
90
  * @param row
75
91
  * @param col
@@ -82,16 +98,21 @@ export interface ISheetClipboardHook {
82
98
  * @deprecated should be merged with `onCopyCellContent` to `onCopyCell`
83
99
  * @param row row of the the copied cell
84
100
  * @param col col of the the copied cell
101
+ * @param rowSpan row span of the the copied cell
102
+ * @param colSpan col span of the the copied cell
103
+ * @return content
85
104
  */
86
105
  onCopyCellStyle?(row: number, col: number, rowSpan?: number, colSpan?: number): IClipboardPropertyItem | null;
87
106
  /**
88
107
  * Properties that would be appended to the tr element.
89
108
  * @param row each row of the the copied range
109
+ * @return content
90
110
  */
91
111
  onCopyRow?(row: number): IClipboardPropertyItem | null;
92
112
  /**
93
113
  * Properties that would be appended to the col element.
94
114
  * @param col each col of the copied range
115
+ * @return content
95
116
  */
96
117
  onCopyColumn?(col: number): IClipboardPropertyItem | null;
97
118
  /**
@@ -103,30 +124,65 @@ export interface ISheetClipboardHook {
103
124
  * The callback would be called after the clipboard service has decided what region need to be pasted.
104
125
  * Features could use this hook to build copying cache or any other pre-copy jobs.
105
126
  *
127
+ * @param pasteTo
106
128
  * @returns if it block copying it should return false
107
129
  */
108
130
  onBeforePaste?(pasteTo: ISheetDiscreteRangeLocation): boolean;
109
131
  /**
132
+ * Handles pasting cells, it needs to return Undo Mutations & Redo Mutations that handle the cell contents
110
133
  *
111
- * @param row
112
- * @param col
134
+ * @param pasteFrom
135
+ * @param pasteTo
136
+ * @param data
137
+ * @param payload
138
+ * @returns undo and redo mutations
113
139
  */
114
140
  onPasteCells?(pasteFrom: ISheetDiscreteRangeLocation | null, pasteTo: ISheetDiscreteRangeLocation, data: ObjectMatrix<ICellDataWithSpanInfo>, payload: ICopyPastePayload): {
115
141
  undos: IMutationInfo[];
116
142
  redos: IMutationInfo[];
117
143
  };
144
+ /**
145
+ * Handle the pasted row properties, it needs to return the Undo Mutations & Redo Mutations that handle the row properties
146
+ *
147
+ * @param pasteTo
148
+ * @param rowProperties
149
+ * @param payload
150
+ * @returns undo and redo mutations
151
+ */
118
152
  onPasteRows?(pasteTo: ISheetDiscreteRangeLocation, rowProperties: IClipboardPropertyItem[], payload: ICopyPastePayload): {
119
153
  undos: IMutationInfo[];
120
154
  redos: IMutationInfo[];
121
155
  };
156
+ /**
157
+ * Handle the pasted column properties, it needs to return the Undo Mutations & Redo Mutations that handle the column properties
158
+ *
159
+ * @param pasteTo
160
+ * @param colProperties
161
+ * @param payload
162
+ * @returns undo and redo mutations
163
+ */
122
164
  onPasteColumns?(pasteTo: ISheetDiscreteRangeLocation, colProperties: IClipboardPropertyItem[], payload: ICopyPastePayload): {
123
165
  undos: IMutationInfo[];
124
166
  redos: IMutationInfo[];
125
167
  };
168
+ /**
169
+ * Hanle the pasted plain text, it needs to return the Undo Mutations & Redo Mutations that handle the plain text
170
+ *
171
+ * @param pasteTo
172
+ * @param text
173
+ * @param payload
174
+ * @returns undo and redo mutations
175
+ */
126
176
  onPastePlainText?(pasteTo: ISheetDiscreteRangeLocation, text: string, payload: ICopyPastePayload): {
127
177
  undos: IMutationInfo[];
128
178
  redos: IMutationInfo[];
129
179
  };
180
+ /**
181
+ * Would be called after paste content has been written into Univer.
182
+ * Features could do some cleaning up jobs here.
183
+ *
184
+ * @param success whether the paste operation is successful
185
+ */
130
186
  onAfterPaste?(success: boolean): void;
131
187
  /**
132
188
  * The callback would be called before the clipboard service decides what region need to be copied from or pasted to.
@@ -1,4 +1,4 @@
1
- import { Workbook, Disposable } from '@univerjs/core';
1
+ import { Workbook, Disposable, IUniverInstanceService } from '@univerjs/core';
2
2
  import { IRenderContext, IRenderModule, IRenderManagerService } from '@univerjs/engine-render';
3
3
  import { ILayoutService } from '@univerjs/ui';
4
4
  import { IEditorBridgeService } from '../editor-bridge.service';
@@ -11,7 +11,8 @@ export declare class SheetCellEditorResizeService extends Disposable implements
11
11
  private readonly _editorBridgeService;
12
12
  private readonly _renderManagerService;
13
13
  private readonly _sheetSkeletonManagerService;
14
- constructor(_context: IRenderContext<Workbook>, _layoutService: ILayoutService, _cellEditorManagerService: ICellEditorManagerService, _editorBridgeService: IEditorBridgeService, _renderManagerService: IRenderManagerService, _sheetSkeletonManagerService: SheetSkeletonManagerService);
14
+ private readonly _univerInstanceService;
15
+ constructor(_context: IRenderContext<Workbook>, _layoutService: ILayoutService, _cellEditorManagerService: ICellEditorManagerService, _editorBridgeService: IEditorBridgeService, _renderManagerService: IRenderManagerService, _sheetSkeletonManagerService: SheetSkeletonManagerService, _univerInstanceService: IUniverInstanceService);
15
16
  fitTextSize(callback?: () => void): void;
16
17
  /**
17
18
  * Mainly used to pre-calculate the width of the editor,
@@ -42,6 +42,7 @@ export interface IEditorBridgeService {
42
42
  currentEditCellLayout$: Observable<Nullable<ICellEditorLayout>>;
43
43
  currentEditCell$: Observable<Nullable<IEditorBridgeServiceParam>>;
44
44
  visible$: Observable<IEditorBridgeServiceVisibleParam>;
45
+ forceKeepVisible$: Observable<boolean>;
45
46
  dispose(): void;
46
47
  refreshEditCellState(): void;
47
48
  refreshEditCellPosition(resetSizeOnly?: boolean): void;
@@ -68,7 +69,6 @@ export declare class EditorBridgeService extends Disposable implements IEditorBr
68
69
  private readonly _refSelectionsService;
69
70
  private readonly _contextService;
70
71
  private _editorUnitId;
71
- private _isForceKeepVisible;
72
72
  private _editorIsDirty;
73
73
  private _isDisabled;
74
74
  private _visible;
@@ -99,6 +99,8 @@ export declare class EditorBridgeService extends Disposable implements IEditorBr
99
99
  readonly visible$: Observable<IEditorBridgeServiceVisibleParam>;
100
100
  private readonly _afterVisible$;
101
101
  readonly afterVisible$: Observable<IEditorBridgeServiceVisibleParam>;
102
+ private readonly _forceKeepVisible$;
103
+ readonly forceKeepVisible$: Observable<boolean>;
102
104
  constructor(_sheetInterceptorService: SheetInterceptorService, _renderManagerService: IRenderManagerService, _themeService: ThemeService, _univerInstanceService: IUniverInstanceService, _editorService: IEditorService, _refSelectionsService: SheetsSelectionsService, _contextService: IContextService);
103
105
  refreshEditCellState(): void;
104
106
  refreshEditCellPosition(resetSizeOnly?: boolean): void;
@@ -45,6 +45,11 @@ export interface IHoverRichTextPosition extends ISheetLocationBase {
45
45
  drawing?: Nullable<string>;
46
46
  event?: IMouseEvent | IPointerEvent;
47
47
  }
48
+ export interface IHoverHeaderPosition {
49
+ unitId: string;
50
+ subUnitId: string;
51
+ index: number;
52
+ }
48
53
  export declare function getLocationBase(location: ISheetLocation): {
49
54
  unitId: string;
50
55
  subUnitId: string;
@@ -57,9 +62,20 @@ export declare class HoverManagerService extends Disposable {
57
62
  private _currentCell$;
58
63
  private _currentRichText$;
59
64
  private _currentClickedCell$;
65
+ private _currentDbClickedCell$;
60
66
  private _currentCellWithEvent$;
61
67
  private _currentPointerDownCell$;
62
68
  private _currentPointerUpCell$;
69
+ private _currentHoveredRowHeader$;
70
+ private _currentHoveredColHeader$;
71
+ private _currentRowHeaderClick$;
72
+ private _currentColHeaderClick$;
73
+ private _currentRowHeaderDbClick$;
74
+ private _currentColHeaderDbClick$;
75
+ private _currentRowHeaderPointerDown$;
76
+ private _currentColHeaderPointerDown$;
77
+ private _currentRowHeaderPointerUp$;
78
+ private _currentColHeaderPointerUp$;
63
79
  currentCell$: import('rxjs').Observable<Nullable<IHoverCellPosition>>;
64
80
  currentRichText$: import('rxjs').Observable<void | IHoverRichTextPosition | null | undefined>;
65
81
  /**
@@ -68,12 +84,26 @@ export declare class HoverManagerService extends Disposable {
68
84
  currentCellPosWithEvent$: import('rxjs').Observable<void | ICellPosWithEvent | null | undefined>;
69
85
  currentPosition$: import('rxjs').Observable<Nullable<IHoverCellPosition>>;
70
86
  currentClickedCell$: import('rxjs').Observable<IHoverRichTextInfo>;
87
+ currentDbClickedCell$: import('rxjs').Observable<IHoverRichTextInfo>;
71
88
  currentPointerDownCell$: import('rxjs').Observable<ICellPosWithEvent>;
72
89
  currentPointerUpCell$: import('rxjs').Observable<ICellPosWithEvent>;
90
+ currentHoveredRowHeader$: import('rxjs').Observable<Nullable<IHoverHeaderPosition>>;
91
+ currentHoveredColHeader$: import('rxjs').Observable<Nullable<IHoverHeaderPosition>>;
92
+ currentRowHeaderClick$: import('rxjs').Observable<IHoverHeaderPosition>;
93
+ currentColHeaderClick$: import('rxjs').Observable<IHoverHeaderPosition>;
94
+ currentRowHeaderDbClick$: import('rxjs').Observable<IHoverHeaderPosition>;
95
+ currentColHeaderDbClick$: import('rxjs').Observable<IHoverHeaderPosition>;
96
+ currentRowHeaderPointerDown$: import('rxjs').Observable<IHoverHeaderPosition>;
97
+ currentColHeaderPointerDown$: import('rxjs').Observable<IHoverHeaderPosition>;
98
+ currentRowHeaderPointerUp$: import('rxjs').Observable<IHoverHeaderPosition>;
99
+ currentColHeaderPointerUp$: import('rxjs').Observable<IHoverHeaderPosition>;
73
100
  constructor(_univerInstanceService: IUniverInstanceService, _renderManagerService: IRenderManagerService);
74
101
  dispose(): void;
75
102
  private _initCellDisposableListener;
103
+ private _getCalcDeps;
76
104
  private _calcActiveCell;
105
+ private _calcActiveRowHeader;
106
+ private _calcActiveColHeader;
77
107
  triggerPointerDown(unitId: string, event: IPointerEvent | IMouseEvent): void;
78
108
  triggerPointerUp(unitId: string, event: IPointerEvent | IMouseEvent): void;
79
109
  triggerMouseMove(unitId: string, event: IPointerEvent | IMouseEvent): void;
@@ -84,5 +114,16 @@ export declare class HoverManagerService extends Disposable {
84
114
  * @param offsetY
85
115
  */
86
116
  triggerClick(unitId: string, offsetX: number, offsetY: number): void;
117
+ triggerDbClick(unitId: string, offsetX: number, offsetY: number): void;
87
118
  triggerScroll(): void;
119
+ triggerRowHeaderClick(unitId: string, offsetX: number, offsetY: number): void;
120
+ triggerColHeaderClick(unitId: string, offsetX: number, offsetY: number): void;
121
+ triggerRowHeaderDbClick(unitId: string, offsetX: number, offsetY: number): void;
122
+ triggerColHeaderDbClick(unitId: string, offsetX: number, offsetY: number): void;
123
+ triggerRowHeaderMouseMove(unitId: string, offsetX: number, offsetY: number): void;
124
+ triggerColHeaderMouseMove(unitId: string, offsetX: number, offsetY: number): void;
125
+ triggerRowHeaderPoniterDown(unitId: string, offsetX: number, offsetY: number): void;
126
+ triggerColHeaderPoniterDown(unitId: string, offsetX: number, offsetY: number): void;
127
+ triggerRowHeaderPoniterUp(unitId: string, offsetX: number, offsetY: number): void;
128
+ triggerColHeaderPoniterUp(unitId: string, offsetX: number, offsetY: number): void;
88
129
  }
@@ -39,6 +39,7 @@ export interface ISheetSelectionRenderService {
39
39
  getCellWithCoordByOffset(x: number, y: number, skeleton?: SpreadsheetSkeleton): Nullable<ICellWithCoord>;
40
40
  setSingleSelectionEnabled(enabled: boolean): void;
41
41
  refreshSelectionMoveEnd(): void;
42
+ resetSelectionsByModelData(selectionsWithStyleList: readonly ISelectionWithStyle[]): void;
42
43
  }
43
44
  export declare const ISheetSelectionRenderService: import('@wendellhu/redi').IdentifierDecorator<ISheetSelectionRenderService>;
44
45
  /**
@@ -57,6 +58,7 @@ export declare class BaseSelectionRenderService extends Disposable implements IS
57
58
  readonly controlFillConfig$: Observable<IControlFillConfig | null>;
58
59
  protected _selectionControls: SelectionControl[];
59
60
  protected _startRangeWhenPointerDown: IRangeWithCoord;
61
+ protected _activeControlIndex: number;
60
62
  /**
61
63
  * the posX of viewport when the pointer down
62
64
  */
@@ -158,6 +160,8 @@ export declare class BaseSelectionRenderService extends Disposable implements IS
158
160
  * Returns the selected range in the active sheet, or null if there is no active range. If multiple ranges are selected this method returns only the last selected range.
159
161
  */
160
162
  getActiveRange(): Nullable<IRange>;
163
+ setActiveSelectionIndex(index: number): void;
164
+ resetActiveSelectionIndex(): void;
161
165
  /**
162
166
  * get active(actually last) selection control
163
167
  * @returns T extends SelectionControl
@@ -1,5 +1,5 @@
1
1
  import { ICellWithCoord, IRangeWithCoord, Nullable, ThemeService, Disposable, RANGE_TYPE } from '@univerjs/core';
2
- import { Scene, Group, Rect } from '@univerjs/engine-render';
2
+ import { Scene, SpreadsheetSkeleton, Group, Rect } from '@univerjs/engine-render';
3
3
  import { ISelectionStyle, ISelectionWidgetConfig, ISelectionWithCoord } from '@univerjs/sheets';
4
4
  import { ISelectionShapeExtensionOption, SelectionShapeExtension } from './selection-shape-extension';
5
5
  import { Subject } from 'rxjs';
@@ -175,7 +175,7 @@ export declare class SelectionControl extends Disposable {
175
175
  * Update range and primary range and style.
176
176
  * @param selectionWthCoord
177
177
  */
178
- updateRangeBySelectionWithCoord(selectionWthCoord: ISelectionWithCoord): void;
178
+ updateRangeBySelectionWithCoord(selectionWthCoord: ISelectionWithCoord, sk?: SpreadsheetSkeleton): void;
179
179
  /**
180
180
  * Update selection model with new range & primary cell(aka: highlight/current), also update row/col selection size & style.
181
181
  *
@@ -1,5 +1,5 @@
1
1
  import { IRange, IRangeWithCoord, Nullable, Workbook, Disposable, Injector } from '@univerjs/core';
2
- import { IRenderContext, IRenderModule, SpreadsheetSkeleton } from '@univerjs/engine-render';
2
+ import { IRender, IRenderContext, IRenderModule, SpreadsheetSkeleton } from '@univerjs/engine-render';
3
3
  export interface ISheetSkeletonManagerParam {
4
4
  unitId: string;
5
5
  sheetId: string;
@@ -58,4 +58,5 @@ export declare class SheetSkeletonManagerService extends Disposable implements I
58
58
  attachRangeWithCoord(range: IRange): Nullable<IRangeWithCoord>;
59
59
  private _getSkeleton;
60
60
  private _buildSkeleton;
61
+ setColumnHeaderSize(sheetId: string, render: IRender, size: number): void;
61
62
  }
@@ -0,0 +1,8 @@
1
+ import { KeyCode } from '@univerjs/ui';
2
+ export declare function useKeyEventConfig(isRefSelecting: React.MutableRefObject<0 | 1 | 2>, unitId: string): {
3
+ keyCodes: {
4
+ keyCode: KeyCode;
5
+ }[];
6
+ handler: (keycode: KeyCode) => void;
7
+ };
8
+ export declare function useIsFocusing(editorId: string): boolean | undefined;