@univerjs/sheets-ui 0.1.16 → 0.2.0

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 (68) hide show
  1. package/lib/cjs/index.js +12 -11
  2. package/lib/es/index.js +21147 -18801
  3. package/lib/index.css +1 -1
  4. package/lib/locale/en-US.json +1 -1
  5. package/lib/locale/ru-RU.json +1 -1
  6. package/lib/locale/zh-CN.json +1 -1
  7. package/lib/types/commands/commands/__tests__/create-selection-command-test-bed.d.ts +12 -12
  8. package/lib/types/commands/commands/set-scroll.command.d.ts +5 -5
  9. package/lib/types/commands/operations/scroll.operation.d.ts +2 -2
  10. package/lib/types/commands/operations/set-zoom-ratio.operation.d.ts +0 -2
  11. package/lib/types/controllers/auto-fill.controller.d.ts +2 -1
  12. package/lib/types/controllers/editor/editing.render-controller.d.ts +72 -0
  13. package/lib/types/controllers/editor/formula-editor.controller.d.ts +3 -4
  14. package/lib/types/controllers/menu/__tests__/create-menu-test-bed.d.ts +6 -6
  15. package/lib/types/controllers/menu/menu.d.ts +3 -3
  16. package/lib/types/controllers/menu/permission.menu.d.ts +1 -1
  17. package/lib/types/controllers/mobile/mobile-sheet-ui.controller.d.ts +26 -0
  18. package/lib/types/controllers/permission/sheet-permission-interceptor-canvas-render.controller.d.ts +2 -4
  19. package/lib/types/controllers/permission/sheet-permission-render.controller.d.ts +2 -4
  20. package/lib/types/controllers/render-controllers/contextmenu.render-controller.d.ts +1 -1
  21. package/lib/types/controllers/render-controllers/editor-bridge.render-controller.d.ts +4 -13
  22. package/lib/types/controllers/render-controllers/freeze.render-controller.d.ts +5 -5
  23. package/lib/types/controllers/render-controllers/header-menu.render-controller.d.ts +2 -1
  24. package/lib/types/controllers/render-controllers/header-move.render-controller.d.ts +5 -5
  25. package/lib/types/controllers/render-controllers/header-resize.render-controller.d.ts +8 -10
  26. package/lib/types/controllers/render-controllers/mobile/mobile-contextmenu.render-controller.d.ts +20 -0
  27. package/lib/types/controllers/render-controllers/mobile/mobile-scroll.render-controller.d.ts +43 -0
  28. package/lib/types/controllers/render-controllers/mobile/mobile-selection.render-controller.d.ts +40 -0
  29. package/lib/types/controllers/render-controllers/scroll.render-controller.d.ts +3 -2
  30. package/lib/types/controllers/render-controllers/selection.render-controller.d.ts +1 -1
  31. package/lib/types/controllers/render-controllers/sheet.render-controller.d.ts +41 -15
  32. package/lib/types/controllers/render-controllers/skeleton.render-controller.d.ts +10 -0
  33. package/lib/types/controllers/utils/component-tools.d.ts +3 -0
  34. package/lib/types/index.d.ts +35 -15
  35. package/lib/types/mobile-sheets-ui-plugin.d.ts +23 -0
  36. package/lib/types/services/auto-fill/rules.d.ts +1 -0
  37. package/lib/types/services/auto-fill/type.d.ts +7 -6
  38. package/lib/types/services/clipboard/__tests__/clipboard-paste-from-notepad.spec.d.ts +16 -0
  39. package/lib/types/services/clipboard/__tests__/clipboard-test-bed.d.ts +6 -6
  40. package/lib/types/services/clipboard/__tests__/constant.d.ts +2 -1
  41. package/lib/types/services/clipboard/clipboard.service.d.ts +1 -0
  42. package/lib/types/services/clipboard/html-to-usm/converter.d.ts +7 -1
  43. package/lib/types/services/clipboard/html-to-usm/parse-node-style.d.ts +1 -1
  44. package/lib/types/services/clipboard/html-to-usm/utils.d.ts +1 -1
  45. package/lib/types/services/clipboard/utils.d.ts +1 -0
  46. package/lib/types/services/mark-selection/mark-selection.service.d.ts +2 -2
  47. package/lib/types/services/scroll-manager.service.d.ts +63 -14
  48. package/lib/types/services/selection/mobile-selection-render.service.d.ts +179 -0
  49. package/lib/types/services/selection/mobile-selection-shape.d.ts +53 -0
  50. package/lib/types/services/selection/selection-render-model.d.ts +14 -5
  51. package/lib/types/services/selection/selection-render.service.d.ts +22 -21
  52. package/lib/types/services/selection/selection-shape-extension.d.ts +9 -5
  53. package/lib/types/services/selection/selection-shape.d.ts +96 -39
  54. package/lib/types/services/sheet-skeleton-manager.service.d.ts +9 -4
  55. package/lib/types/services/sheets-render.service.d.ts +2 -2
  56. package/lib/types/sheets-ui-plugin.d.ts +3 -4
  57. package/lib/types/views/mobile/sheet-bar/MobileSheetBar.d.ts +3 -0
  58. package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.d.ts +0 -2
  59. package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/animate.d.ts +0 -1
  60. package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.d.ts +3 -0
  61. package/lib/types/views/status-bar/CopyableStatisticItem.d.ts +1 -1
  62. package/lib/umd/index.js +12 -11
  63. package/package.json +25 -25
  64. package/lib/types/controllers/editor/editing.controller.d.ts +0 -10
  65. package/lib/types/controllers/editor/end-edit.controller.d.ts +0 -37
  66. package/lib/types/controllers/editor/start-edit.controller.d.ts +0 -54
  67. package/lib/types/controllers/render-controllers/sheet-render.controller.d.ts +0 -41
  68. /package/lib/types/commands/commands/{delete-range-move-left-confirm.command .d.ts → delete-range-move-left-confirm.command.d.ts} +0 -0
@@ -1,19 +1,46 @@
1
1
  import { IUniverInstanceService, Nullable } from '@univerjs/core';
2
+ import { BehaviorSubject } from 'rxjs';
2
3
  import { IRenderManagerService } from '@univerjs/engine-render';
3
4
 
5
+ export interface IViewportScrollState {
6
+ scrollX: number;
7
+ scrollY: number;
8
+ viewportScrollX: number;
9
+ viewportScrollY: number;
10
+ }
4
11
  export interface IScrollManagerParam {
12
+ /**
13
+ * offsetX from startRow, coordinate same as viewport, not scrollbar
14
+ */
5
15
  offsetX: number;
16
+ /**
17
+ * offsetY from startColumn, coordinate same as viewport, not scrollbar
18
+ */
6
19
  offsetY: number;
20
+ /**
21
+ * currrent start row in viewport visible area
22
+ */
7
23
  sheetViewStartRow: number;
24
+ /**
25
+ * current start column in viewport visible area
26
+ */
8
27
  sheetViewStartColumn: number;
28
+ /**
29
+ * overall offsetX from sheet cotent topleft, should be same as startRow * rowHeight + offsetY
30
+ * coordinate same as viewport, not scrollbar
31
+ */
9
32
  viewportScrollX?: number;
33
+ /**
34
+ * overall offsetY from sheet content topleft, should be same as startColumn * columnWidth + offsetX
35
+ * coordinate same as viewport, not scrollbar
36
+ */
10
37
  viewportScrollY?: number;
11
38
  }
12
39
  export interface IScrollManagerSearchParam {
13
40
  unitId: string;
14
41
  sheetId: string;
15
42
  }
16
- export interface IScrollManagerInsertParam extends IScrollManagerSearchParam, IScrollManagerParam {
43
+ export interface IScrollManagerWithSearchParam extends IScrollManagerSearchParam, IScrollManagerParam {
17
44
  }
18
45
  export type IScrollInfo = Map<string, Map<string, IScrollManagerParam>>;
19
46
  /**
@@ -25,9 +52,27 @@ export type IScrollInfo = Map<string, Map<string, IScrollManagerParam>>;
25
52
  export declare class ScrollManagerService {
26
53
  private readonly _univerInstanceService;
27
54
  private readonly _renderManagerService;
28
- private readonly _scrollInfo;
55
+ /**
56
+ * a map holds all scroll info for each sheet
57
+ */
58
+ private readonly _scrollInfoMap;
59
+ /**
60
+ * a subject for current sheet scrollInfo
61
+ */
29
62
  private readonly _scrollInfo$;
30
- readonly scrollInfo$: import('rxjs').Observable<Nullable<IScrollManagerParam>>;
63
+ /**
64
+ * a subject for current sheet scrollInfo ( events, ex wheel event and point events add deltaXY to rawScrollInfo$)
65
+ */
66
+ readonly rawScrollInfo$: import('rxjs').Observable<Nullable<IScrollManagerParam>>;
67
+ /**
68
+ * a subject for current valid scrollInfo, viewport@_scrollCore would limit rawScrollInfo$ exclude negative value or over max value.
69
+ * use this subject not rawScrollInfo$ when get scrolling state of viewport.
70
+ */
71
+ readonly validViewportScrollInfo$: BehaviorSubject<Nullable<IViewportScrollState>>;
72
+ /**
73
+ * a subject for current valid scrollInfo, viewport@_scrollCore would limit rawScrollInfo$ exclude negative value or over max value.
74
+ * use this subject not rawScrollInfo$ when get scrolling state of viewport.
75
+ */
31
76
  private _searchParamForScroll;
32
77
  constructor(_univerInstanceService: IUniverInstanceService, _renderManagerService: IRenderManagerService);
33
78
  dispose(): void;
@@ -39,26 +84,30 @@ export declare class ScrollManagerService {
39
84
  /**
40
85
  * set scrollInfo by cmd,
41
86
  * call _setScrollInfo twice after one scrolling.
42
- * first time set scrollInfo bt scrollOperation, but offsetXY is derived from scroll event.
87
+ * first time set scrollInfo by scrollOperation, but offsetXY is derived from scroll event.
43
88
  * second time set scrollInfo by viewport.scrollTo(scrol.render-controller --> onScrollAfterObserver), this time offsetXY has been limited.
44
89
  *
45
- * wheelevent --> sheetCanvasView --> set-scroll.command('sheet.command.set-scroll-relative') --> scrollOperation --> this.setScrollInfo --> scrollInfo$.next --> scroll.render-controller@viewportMain.scrollTo & notify -->
46
- * scroll.render-controller@onScrollAfterObserver --> this.setScrollInfoToCurrSheetWithoutNotify --> this._setScrollInfo({}, false)
90
+ * wheelevent --> sheetCanvasView --> set-scroll.command('sheet.command.set-scroll-relative') --> scrollOperation --> scrollManagerService.setScrollInfo --> scrollInfo$.next --> scroll.render-controller@viewportMain.scrollTo & notify -->
91
+ * scroll.render-controller@onScrollAfter$ --> this.setScrollInfoToCurrSheetWithoutNotify --> this._setScrollInfo({}, false)
47
92
  * call _setScrollInfo again, a loop!, so we should call setScrollInfoToCurrSheetWithoutNotify
48
93
  * @param param
49
94
  */
50
- setScrollInfo(param: IScrollManagerInsertParam): void;
51
- setScrollInfoToCurrSheet(scrollInfo: IScrollManagerParam): void;
52
- setScrollInfoToCurrSheetWithoutNotify(scroll: IScrollManagerParam): void;
95
+ setScrollInfoAndEmitEvent(param: IScrollManagerWithSearchParam): void;
96
+ setScrollInfoToCurrSheetAndEmitEvent(scrollInfo: IScrollManagerParam): void;
97
+ /**
98
+ * call _setScrollInfo but no _scrollInfo$.next
99
+ * @param scroll
100
+ */
101
+ justSetScrollInfoToCurrSheet(scroll: IScrollManagerParam): void;
53
102
  clear(): void;
54
- calcViewportScrollFromOffset(scrollInfo: IScrollManagerInsertParam): {
103
+ calcViewportScrollFromRowColOffset(scrollInfo: IScrollManagerWithSearchParam): {
55
104
  scrollTop: number;
56
105
  scrollLeft: number;
57
- viewportScrollX?: undefined;
58
- viewportScrollY?: undefined;
106
+ overallScrollX?: undefined;
107
+ overallScrollY?: undefined;
59
108
  } | {
60
- viewportScrollX: number;
61
- viewportScrollY: number;
109
+ overallScrollX: number;
110
+ overallScrollY: number;
62
111
  scrollTop?: undefined;
63
112
  scrollLeft?: undefined;
64
113
  };
@@ -0,0 +1,179 @@
1
+ import { IRange, IRangeWithCoord, ISelection, ISelectionCell, ISelectionCellWithMergeInfo, Nullable, InterceptorManager, RANGE_TYPE, ThemeService } from '@univerjs/core';
2
+ import { IMouseEvent, IPointerEvent, Scene, SpreadsheetSkeleton, Viewport, IRenderManagerService } from '@univerjs/engine-render';
3
+ import { ISelectionStyle, ISelectionWithCoordAndStyle, ISelectionWithStyle } from '@univerjs/sheets';
4
+ import { IShortcutService } from '@univerjs/ui';
5
+ import { Injector } from '@wendellhu/redi';
6
+ import { SelectionControl } from './selection-shape';
7
+ import { IControlFillConfig, ISelectionRenderService } from './selection-render.service';
8
+ import { MobileSelectionControl } from './mobile-selection-shape';
9
+
10
+ declare enum ExpandingControl {
11
+ BOTTOM_RIGHT = "bottom-right",
12
+ TOP_LEFT = "top-left",
13
+ LEFT = "left",
14
+ RIGHT = "right",
15
+ TOP = "top",
16
+ BOTTOM = "bottom"
17
+ }
18
+ export declare class MobileSelectionRenderService implements ISelectionRenderService {
19
+ private readonly _themeService;
20
+ private readonly _shortcutService;
21
+ private readonly _renderManagerService;
22
+ private readonly _injector;
23
+ hasSelection: boolean;
24
+ private _pointerdownSub;
25
+ private _mainScenePointerUpSub;
26
+ private _scenePointerMoveSub;
27
+ private _scenePointerUpSub;
28
+ private _controlFillConfig$;
29
+ readonly controlFillConfig$: import('rxjs').Observable<IControlFillConfig | null>;
30
+ private _selectionControls;
31
+ private _activeCellRangeOfCurrSelection;
32
+ private _startOffsetX;
33
+ private _startOffsetY;
34
+ private _scrollTimer;
35
+ private _skeleton;
36
+ private _scene;
37
+ private _isHeaderHighlight;
38
+ private _isDetectMergedCell;
39
+ private _selectionStyle;
40
+ private _isSelectionEnabled;
41
+ private _isShowPreviousEnable;
42
+ private _isRemainLastEnable;
43
+ private _isSkipRemainLastEnable;
44
+ private _isSingleSelection;
45
+ private readonly _selectionMoveEnd$;
46
+ readonly selectionMoveEnd$: import('rxjs').Observable<ISelectionWithCoordAndStyle[]>;
47
+ private readonly _selectionMoving$;
48
+ /**
49
+ * Triggered during the drawing of the selection area.
50
+ */
51
+ readonly selectionMoving$: import('rxjs').Observable<ISelectionWithCoordAndStyle[]>;
52
+ private readonly _selectionMoveStart$;
53
+ /**
54
+ * Triggered during the start draw the selection area.
55
+ */
56
+ readonly selectionMoveStart$: import('rxjs').Observable<ISelectionWithCoordAndStyle[]>;
57
+ private _activeViewport;
58
+ /**
59
+ * This service relies on the scene and skeleton to work
60
+ * Use usable$ to check if this service works
61
+ */
62
+ private readonly _usable$;
63
+ readonly usable$: import('rxjs').Observable<boolean>;
64
+ interceptor: InterceptorManager<{
65
+ RANGE_MOVE_PERMISSION_CHECK: import('@univerjs/core').IInterceptor<boolean, null>;
66
+ RANGE_FILL_PERMISSION_CHECK: import('@univerjs/core').IInterceptor<boolean, {
67
+ x: number;
68
+ y: number;
69
+ skeleton: SpreadsheetSkeleton;
70
+ scene: Scene;
71
+ }>;
72
+ }>;
73
+ expandingControlMode: ExpandingControl;
74
+ constructor(_themeService: ThemeService, _shortcutService: IShortcutService, _renderManagerService: IRenderManagerService, _injector: Injector);
75
+ enableHeaderHighlight(): void;
76
+ disableHeaderHighlight(): void;
77
+ enableDetectMergedCell(): void;
78
+ disableDetectMergedCell(): void;
79
+ setStyle(style: ISelectionStyle): void;
80
+ resetStyle(): void;
81
+ enableSelection(): void;
82
+ disableSelection(): void;
83
+ enableShowPrevious(): void;
84
+ disableShowPrevious(): void;
85
+ enableRemainLast(): void;
86
+ disableRemainLast(): void;
87
+ enableSkipRemainLast(): void;
88
+ disableSkipRemainLast(): void;
89
+ enableSingleSelection(): void;
90
+ disableSingleSelection(): void;
91
+ getViewPort(): Viewport;
92
+ /**
93
+ * add a selection
94
+ *
95
+ * in PC:init & pointerup would call this function.
96
+ *
97
+ * init
98
+ * selectionController@_initSkeletonChangeListener --> selectionManagerService.add --> selectionManagerService._selectionMoveEnd$ --> this.addControlToCurrentByRangeData
99
+ *
100
+ * selectionMoveEnd$ --> this.addSelectionControlBySelectionData
101
+ *
102
+ *
103
+ *
104
+ * pointer
105
+ * engine@_pointerDownEvent --> spreadsheet?.onPointerDownObserve --> eventTrigger --> scene@disableEvent() --> then scene.input-manager currentObject is always scene until scene@enableEvent.
106
+ * engine@_pointerUpEvent --> scene.input-manager@_onPointerUp --> this._selectionMoveEnd$ --> _selectionManagerService.selectionMoveEnd$ --> this.addControlToCurrentByRangeData
107
+ *
108
+ * but in mobile, we do not call disableEvent() in eventTrigger,
109
+ * so pointerup --> scene.input-manager currentObject is spreadsheet --> this.eventTrigger
110
+ *
111
+ *
112
+ *
113
+ * @param selectionData
114
+ */
115
+ addSelectionControlBySelectionData(selectionData: ISelectionWithCoordAndStyle): void;
116
+ newSelectionControl(scene: Scene, rangeType: RANGE_TYPE): MobileSelectionControl;
117
+ updateControlForCurrentByRangeData(selections: ISelectionWithCoordAndStyle[]): void;
118
+ refreshSelectionMoveStart(): void;
119
+ changeRuntime(skeleton: Nullable<SpreadsheetSkeleton>, scene: Nullable<Scene>, viewport?: Viewport): void;
120
+ getSelectionDataWithStyle(): ISelectionWithCoordAndStyle[];
121
+ getSelectionControls(): SelectionControl[];
122
+ private _clearSelectionControls;
123
+ private _getFreeze;
124
+ private _getViewportByCell;
125
+ /**
126
+ * Returns the list of active ranges in the active sheet or null if there are no active ranges.
127
+ * If there is a single range selected, this method behaves like a getActiveRange() call.
128
+ */
129
+ getActiveSelections(): Nullable<ISelection[]>;
130
+ /**
131
+ * 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.
132
+ */
133
+ getActiveRange(): Nullable<IRange>;
134
+ /**
135
+ * get last selection control
136
+ */
137
+ getActiveSelectionControl(): Nullable<SelectionControl>;
138
+ endSelection(): void;
139
+ reset(): void;
140
+ resetAndEndSelection(): void;
141
+ expandingSelection: boolean;
142
+ /**
143
+ * invoked when pointerup or longpress on spreadsheet, or pointerdown on row&col
144
+ * then move curr selection to cell at cursor
145
+ * Main perpose to create a new selection, or update curr selection to a new range.
146
+ * @param evt
147
+ * @param _zIndex
148
+ * @param rangeType
149
+ * @param viewport
150
+ */
151
+ eventTrigger(evt: IPointerEvent | IMouseEvent, _zIndex?: number, rangeType?: RANGE_TYPE, viewport?: Viewport): false | undefined;
152
+ /**
153
+ *
154
+ * @param evt component point event
155
+ * @param style selection style, Styles for user-customized selectors
156
+ * @param zIndex Stacking order of the selection object
157
+ * @param rangeType Determines whether the selection is made normally according to the range or by rows and columns
158
+ *
159
+ * invoked by selection.render-controller@pointerDownObserver
160
+ *
161
+ * derived from eventTrigger
162
+ */
163
+ private _fillControlPointerDownHandler;
164
+ attachSelectionWithCoord(selectionWithStyle: ISelectionWithStyle): ISelectionWithCoordAndStyle;
165
+ attachRangeWithCoord(range: IRange): Nullable<IRangeWithCoord>;
166
+ attachPrimaryWithCoord(primary: Nullable<ISelectionCell>): Nullable<ISelectionCellWithMergeInfo>;
167
+ getSelectionCellByPosition(x: number, y: number): Nullable<ISelectionCellWithMergeInfo>;
168
+ /**
169
+ * When mousedown and mouseup need to go to the coordination and undo stack, when mousemove does not need to go to the coordination and undo stack
170
+ */
171
+ private _movingHandler;
172
+ /**
173
+ * rm pointerUp & pointerMove Observer on scene
174
+ */
175
+ private _endSelection;
176
+ private _addCancelObserver;
177
+ private _getCellRangeByCursorPosition;
178
+ }
179
+ export {};
@@ -0,0 +1,53 @@
1
+ import { IRangeWithCoord, Nullable, ThemeService, RANGE_TYPE } from '@univerjs/core';
2
+ import { IRectProps, Scene, Rect } from '@univerjs/engine-render';
3
+ import { ISelectionStyle } from '@univerjs/sheets';
4
+ import { SelectionControl } from './selection-shape';
5
+
6
+ export declare class MobileSelectionControl extends SelectionControl {
7
+ protected _scene: Scene;
8
+ protected _zIndex: number;
9
+ protected _isHeaderHighlight: boolean;
10
+ protected readonly _themeService: ThemeService;
11
+ protected _rangeType: RANGE_TYPE;
12
+ /**
13
+ * topLeft controlPointer, it is not visible, just transparent, for handling event.
14
+ */
15
+ private _fillControlTopLeft;
16
+ /**
17
+ * bottomRight controlPointer, it is not visible, just transparent, for handling event.
18
+ */
19
+ private _fillControlBottomRight;
20
+ /**
21
+ * a very small visible point, placed in control pointer
22
+ */
23
+ private _fillControlTopLeftInner;
24
+ /**
25
+ * a very small visible point, placed in control pointer
26
+ */
27
+ private _fillControlBottomRightInner;
28
+ constructor(_scene: Scene, _zIndex: number, _isHeaderHighlight: boolean, _themeService: ThemeService, _rangeType?: RANGE_TYPE);
29
+ initControlPoints(): void;
30
+ get fillControlTopLeft(): Rect<IRectProps> | null;
31
+ set fillControlTopLeft(value: Rect);
32
+ get fillControlBottomRight(): Rect<IRectProps> | null;
33
+ set fillControlBottomRight(value: Rect);
34
+ get rangeType(): RANGE_TYPE;
35
+ set rangeType(value: RANGE_TYPE);
36
+ dispose(): void;
37
+ updateRange(range: IRangeWithCoord): void;
38
+ protected _updateControl(style: Nullable<ISelectionStyle>, rowHeaderWidth: number, columnHeaderHeight: number): void;
39
+ getViewportMainScrollInfo(): {
40
+ viewportScrollX: number;
41
+ viewportScrollY: number;
42
+ width: number;
43
+ height: number;
44
+ };
45
+ /**
46
+ * Mainly for row & col selection control point position. update control point position by when scrolling.
47
+ * @param viewportScrollX viewportScrollX
48
+ * @param viewportScrollY
49
+ * @param sheetContentWidth
50
+ * @param sheetContentHeight max sheet content height, for very short sheet, control pointer shoud not out of sheet
51
+ */
52
+ transformControlPoint(viewportScrollX?: number, viewportScrollY?: number, sheetContentWidth?: number, sheetContentHeight?: number): void;
53
+ }
@@ -1,4 +1,4 @@
1
- import { IRangeWithCoord, ISelectionCellWithCoord, ISelectionWithCoord, Nullable, RANGE_TYPE } from '@univerjs/core';
1
+ import { IRangeWithCoord, ISelectionCellWithMergeInfo, ISelectionWithCoord, Nullable, RANGE_TYPE } from '@univerjs/core';
2
2
 
3
3
  export declare class SelectionRenderModel implements IRangeWithCoord {
4
4
  private _startColumn;
@@ -12,6 +12,11 @@ export declare class SelectionRenderModel implements IRangeWithCoord {
12
12
  private _startY;
13
13
  private _endX;
14
14
  private _endY;
15
+ /**
16
+ * highlight cell of selection
17
+ * when there is no merge info
18
+ * top left cell of current selection (or bottomLeft of current selection)
19
+ */
15
20
  private _currentCell;
16
21
  private _rangeType;
17
22
  get startColumn(): number;
@@ -34,7 +39,10 @@ export declare class SelectionRenderModel implements IRangeWithCoord {
34
39
  * value from { startY, endY, startX, endX } = getCellPositionByIndex in basics/tools
35
40
  */
36
41
  get endY(): number;
37
- get currentCell(): Nullable<ISelectionCellWithCoord>;
42
+ /**
43
+ * highlight cell of selection
44
+ */
45
+ get currentCell(): Nullable<ISelectionCellWithMergeInfo>;
38
46
  get rangeType(): RANGE_TYPE;
39
47
  isEqual(rangeWithCoord: IRangeWithCoord): boolean;
40
48
  isInclude(rangeWithCoord: IRangeWithCoord): boolean;
@@ -50,10 +58,11 @@ export declare class SelectionRenderModel implements IRangeWithCoord {
50
58
  endY: number;
51
59
  rangeType: RANGE_TYPE;
52
60
  };
53
- getCell(): Nullable<ISelectionCellWithCoord>;
61
+ getCell(): Nullable<ISelectionCellWithMergeInfo>;
54
62
  getRangeType(): RANGE_TYPE;
63
+ setRangeType(rangeType: RANGE_TYPE): void;
55
64
  getValue(): ISelectionWithCoord;
56
- setValue(newSelectionRange: IRangeWithCoord, currentCell: Nullable<ISelectionCellWithCoord>): void;
57
- setCurrentCell(currentCell: Nullable<ISelectionCellWithCoord>): void;
65
+ setValue(newSelectionRange: IRangeWithCoord, currentCell: Nullable<ISelectionCellWithMergeInfo>): void;
66
+ setCurrentCell(currentCell: Nullable<ISelectionCellWithMergeInfo>): void;
58
67
  clearCurrentCell(): void;
59
68
  }
@@ -1,10 +1,10 @@
1
- import { IInterceptor, IRange, IRangeWithCoord, ISelection, ISelectionCell, ISelectionCellWithCoord, Nullable, InterceptorManager, IUniverInstanceService, RANGE_TYPE, ThemeService } from '@univerjs/core';
1
+ import { IInterceptor, IRange, IRangeWithCoord, ISelection, ISelectionCell, ISelectionCellWithMergeInfo, Nullable, InterceptorManager, RANGE_TYPE, ThemeService } from '@univerjs/core';
2
2
  import { IMouseEvent, IPointerEvent, Scene, SpreadsheetSkeleton, Viewport, IRenderManagerService, ScrollTimerType } from '@univerjs/engine-render';
3
3
  import { ISelectionStyle, ISelectionWithCoordAndStyle, ISelectionWithStyle } from '@univerjs/sheets';
4
4
  import { IShortcutService } from '@univerjs/ui';
5
5
  import { Injector } from '@wendellhu/redi';
6
6
  import { Observable } from 'rxjs';
7
- import { SelectionShape } from './selection-shape';
7
+ import { SelectionControl as SelectionShape } from './selection-shape';
8
8
 
9
9
  export interface IControlFillConfig {
10
10
  oldRange: IRange;
@@ -39,20 +39,20 @@ export interface ISelectionRenderService {
39
39
  disableRemainLast(): void;
40
40
  enableSkipRemainLast(): void;
41
41
  disableSkipRemainLast(): void;
42
- addControlToCurrentByRangeData(data: ISelectionWithCoordAndStyle): void;
42
+ addSelectionControlBySelectionData(data: ISelectionWithCoordAndStyle): void;
43
43
  updateControlForCurrentByRangeData(selections: ISelectionWithCoordAndStyle[]): void;
44
44
  changeRuntime(skeleton: Nullable<SpreadsheetSkeleton>, scene: Nullable<Scene>, viewport?: Viewport): void;
45
45
  /** @deprecated This should not be provided by the selection render service. */
46
46
  getViewPort(): Viewport;
47
- getCurrentControls(): SelectionShape[];
47
+ getSelectionControls(): SelectionShape[];
48
48
  getActiveSelections(): Nullable<ISelection[]>;
49
49
  getActiveRange(): Nullable<IRange>;
50
- getActiveSelection(): Nullable<SelectionShape>;
50
+ getActiveSelectionControl(): Nullable<SelectionShape>;
51
51
  getSelectionDataWithStyle(): ISelectionWithCoordAndStyle[];
52
52
  attachSelectionWithCoord(selectionWithStyle: ISelectionWithStyle): ISelectionWithCoordAndStyle;
53
53
  attachRangeWithCoord(range: IRange): Nullable<IRangeWithCoord>;
54
- attachPrimaryWithCoord(primary: Nullable<ISelectionCell>): Nullable<ISelectionCellWithCoord>;
55
- getSelectionCellByPosition(x: number, y: number): Nullable<ISelectionCellWithCoord>;
54
+ attachPrimaryWithCoord(primary: Nullable<ISelectionCell>): Nullable<ISelectionCellWithMergeInfo>;
55
+ getSelectionCellByPosition(x: number, y: number): Nullable<ISelectionCellWithMergeInfo>;
56
56
  eventTrigger(evt: IPointerEvent | IMouseEvent, zIndex: number, rangeType: RANGE_TYPE, viewport?: Viewport, scrollTimerType?: ScrollTimerType): void;
57
57
  reset(): void;
58
58
  refreshSelectionMoveStart(): void;
@@ -83,12 +83,12 @@ export declare class SelectionRenderService implements ISelectionRenderService {
83
83
  private readonly _themeService;
84
84
  private readonly _shortcutService;
85
85
  private readonly _renderManagerService;
86
- private readonly _instanceService;
87
86
  private readonly _injector;
88
87
  hasSelection: boolean;
89
- private _downObserver;
90
- private _moveObserver;
91
- private _upObserver;
88
+ private _pointerdownSub;
89
+ private _mainScenePointerUpSub;
90
+ private _scenePointerMoveSub;
91
+ private _scenePointerUpSub;
92
92
  private _controlFillConfig$;
93
93
  readonly controlFillConfig$: Observable<IControlFillConfig | null>;
94
94
  private _selectionControls;
@@ -96,8 +96,6 @@ export declare class SelectionRenderService implements ISelectionRenderService {
96
96
  private _startOffsetX;
97
97
  private _startOffsetY;
98
98
  private _scrollTimer;
99
- private _cancelDownObserver;
100
- private _cancelUpObserver;
101
99
  private _skeleton;
102
100
  private _scene;
103
101
  private _isHeaderHighlight;
@@ -136,7 +134,7 @@ export declare class SelectionRenderService implements ISelectionRenderService {
136
134
  scene: Scene;
137
135
  }>;
138
136
  }>;
139
- constructor(_themeService: ThemeService, _shortcutService: IShortcutService, _renderManagerService: IRenderManagerService, _instanceService: IUniverInstanceService, _injector: Injector);
137
+ constructor(_themeService: ThemeService, _shortcutService: IShortcutService, _renderManagerService: IRenderManagerService, _injector: Injector);
140
138
  enableHeaderHighlight(): void;
141
139
  disableHeaderHighlight(): void;
142
140
  enableDetectMergedCell(): void;
@@ -156,15 +154,14 @@ export declare class SelectionRenderService implements ISelectionRenderService {
156
154
  getViewPort(): Viewport;
157
155
  /**
158
156
  * add a selection
159
- * @param selectionRange
160
- * @param curCellRange
157
+ * @param data
161
158
  */
162
- addControlToCurrentByRangeData(data: ISelectionWithCoordAndStyle): void;
159
+ addSelectionControlBySelectionData(data: ISelectionWithCoordAndStyle): void;
163
160
  updateControlForCurrentByRangeData(selections: ISelectionWithCoordAndStyle[]): void;
164
161
  refreshSelectionMoveStart(): void;
165
162
  changeRuntime(skeleton: Nullable<SpreadsheetSkeleton>, scene: Nullable<Scene>, viewport?: Viewport): void;
166
163
  getSelectionDataWithStyle(): ISelectionWithCoordAndStyle[];
167
- getCurrentControls(): SelectionShape[];
164
+ getSelectionControls(): SelectionShape[];
168
165
  private _clearSelectionControls;
169
166
  private _getFreeze;
170
167
  private _getViewportByCell;
@@ -185,8 +182,12 @@ export declare class SelectionRenderService implements ISelectionRenderService {
185
182
  * get active selection control
186
183
  * @returns
187
184
  */
188
- getActiveSelection(): Nullable<SelectionShape>;
185
+ getActiveSelectionControl(): Nullable<SelectionShape>;
189
186
  endSelection(): void;
187
+ /**
188
+ * first, clear All selection controls
189
+ * then unsubscribe all events
190
+ */
190
191
  reset(): void;
191
192
  resetAndEndSelection(): void;
192
193
  /**
@@ -199,8 +200,8 @@ export declare class SelectionRenderService implements ISelectionRenderService {
199
200
  eventTrigger(evt: IPointerEvent | IMouseEvent, zIndex?: number, rangeType?: RANGE_TYPE, viewport?: Viewport, scrollTimerType?: ScrollTimerType): false | undefined;
200
201
  attachSelectionWithCoord(selectionWithStyle: ISelectionWithStyle): ISelectionWithCoordAndStyle;
201
202
  attachRangeWithCoord(range: IRange): Nullable<IRangeWithCoord>;
202
- attachPrimaryWithCoord(primary: Nullable<ISelectionCell>): Nullable<ISelectionCellWithCoord>;
203
- getSelectionCellByPosition(x: number, y: number): Nullable<ISelectionCellWithCoord>;
203
+ attachPrimaryWithCoord(primary: Nullable<ISelectionCell>): Nullable<ISelectionCellWithMergeInfo>;
204
+ getSelectionCellByPosition(x: number, y: number): Nullable<ISelectionCellWithMergeInfo>;
204
205
  /**
205
206
  * When mousedown and mouseup need to go to the coordination and undo stack, when mousemove does not need to go to the coordination and undo stack
206
207
  */
@@ -1,12 +1,16 @@
1
1
  import { IRangeWithCoord, ThemeService } from '@univerjs/core';
2
2
  import { Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';
3
3
  import { Injector } from '@wendellhu/redi';
4
- import { SelectionShape } from './selection-shape';
4
+ import { SelectionControl } from './selection-shape';
5
5
 
6
6
  export interface ISelectionShapeTargetSelection {
7
- originControl: SelectionShape;
7
+ originControl: SelectionControl;
8
8
  targetSelection: IRangeWithCoord;
9
9
  }
10
+ /**
11
+ * for auto-fill (crosshair expand selection range)
12
+ * drag selection range
13
+ */
10
14
  export declare class SelectionShapeExtension {
11
15
  private _control;
12
16
  private _skeleton;
@@ -19,15 +23,15 @@ export declare class SelectionShapeExtension {
19
23
  private _relativeSelectionPositionColumn;
20
24
  private _relativeSelectionRowLength;
21
25
  private _relativeSelectionColumnLength;
22
- private _moveObserver;
23
- private _upObserver;
26
+ private _scenePointerMoveSub;
27
+ private _scenePointerUpSub;
24
28
  private _helperSelection;
25
29
  private _scrollTimer;
26
30
  private _activeViewport;
27
31
  private _targetSelection;
28
32
  private _isInMergeState;
29
33
  private _fillControlColors;
30
- constructor(_control: SelectionShape, _skeleton: SpreadsheetSkeleton, _scene: Scene, _themeService: ThemeService, _injector: Injector);
34
+ constructor(_control: SelectionControl, _skeleton: SpreadsheetSkeleton, _scene: Scene, _themeService: ThemeService, _injector: Injector);
31
35
  get isHelperSelection(): boolean;
32
36
  dispose(): void;
33
37
  private _getFreeze;