@univerjs/sheets 0.6.0 → 0.6.1

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.
@@ -28,9 +28,10 @@ export declare class FSelection {
28
28
  * ```ts
29
29
  * const fWorkbook = univerAPI.getActiveWorkbook();
30
30
  * const fWorksheet = fWorkbook.getActiveSheet();
31
+ * const fRange = fWorksheet.getRange('A10:B11');
32
+ * fRange.activate();
31
33
  * const fSelection = fWorksheet.getSelection();
32
- * const activeRange = fSelection.getActiveRange();
33
- * console.log(activeRange);
34
+ * console.log(fSelection.getActiveRange().getA1Notation()); // A10:B11
34
35
  * ```
35
36
  */
36
37
  getActiveRange(): FRange | null;
@@ -43,7 +44,9 @@ export declare class FSelection {
43
44
  * const fWorksheet = fWorkbook.getActiveSheet();
44
45
  * const fSelection = fWorksheet.getSelection();
45
46
  * const activeRangeList = fSelection.getActiveRangeList();
46
- * console.log(activeRangeList);
47
+ * activeRangeList.forEach((range) => {
48
+ * console.log(range.getA1Notation());
49
+ * });
47
50
  * ```
48
51
  */
49
52
  getActiveRangeList(): FRange[];
@@ -54,9 +57,13 @@ export declare class FSelection {
54
57
  * ```ts
55
58
  * const fWorkbook = univerAPI.getActiveWorkbook();
56
59
  * const fWorksheet = fWorkbook.getActiveSheet();
60
+ * const fRange = fWorksheet.getRange('A10:B11');
61
+ * fRange.activate();
57
62
  * const fSelection = fWorksheet.getSelection();
58
63
  * const currentCell = fSelection.getCurrentCell();
64
+ * const { actualRow, actualColumn } = currentCell;
59
65
  * console.log(currentCell);
66
+ * console.log(`actualRow: ${actualRow}, actualColumn: ${actualColumn}`); // actualRow: 9, actualColumn: 0
60
67
  * ```
61
68
  */
62
69
  getCurrentCell(): Nullable<ISelectionCell>;
@@ -81,26 +88,44 @@ export declare class FSelection {
81
88
  * ```ts
82
89
  * const fWorkbook = univerAPI.getActiveWorkbook();
83
90
  * const fWorksheet = fWorkbook.getActiveSheet();
84
- * const fSelection = fWorksheet.getSelection();
85
- * const cell = fWorksheet.getCell('A1');
86
- * const newSelection = fSelection.updatePrimaryCell(cell);
87
- * console.log(newSelection.getActiveRange().getA1Notation()); // A1
91
+ * const fRange = fWorksheet.getRange('A10:B11');
92
+ * fRange.activate();
93
+ * const cell = fWorksheet.getRange('B11');
94
+ *
95
+ * let fSelection = fWorksheet.getSelection();
96
+ * fSelection.updatePrimaryCell(cell);
97
+ * fSelection = fWorksheet.getSelection();
98
+ *
99
+ * const currentCell = fSelection.getCurrentCell();
100
+ * const { actualRow, actualColumn } = currentCell;
101
+ * console.log(currentCell);
102
+ * console.log(`actualRow: ${actualRow}, actualColumn: ${actualColumn}`); // actualRow: 10, actualColumn: 1
88
103
  * ```
89
104
  */
90
105
  updatePrimaryCell(cell: FRange): FSelection;
91
106
  /**
92
- *Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
107
+ * Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
108
+ * The next primary cell in the specified direction is the next cell only within the current selection range.
109
+ * For example, if the current selection is A1:B2, and the primary cell is B1, the next cell in the right direction is A2 instead of C1.
93
110
  * @param {Direction} direction The direction to move the primary cell.The enum value is maybe one of the following: UP(0),RIGHT(1), DOWN(2), LEFT(3).
94
111
  * @returns {FRange | null} The next primary cell in the specified direction.
95
112
  * @example
96
113
  * ```ts
97
- * // import { Direction } from '@univerjs/core';
98
114
  * const fWorkbook = univerAPI.getActiveWorkbook();
99
115
  * const fWorksheet = fWorkbook.getActiveSheet();
100
- * // make sure the active cell is A1 and selection is A1:C3
101
- * const fSelection = fWorksheet.getSelection();
102
- * const nextCell = fSelection.getNextDataRange(Direction.RIGHT);
116
+ * // make sure the active cell is A1 and selection is A1:B2
117
+ * const fRange = fWorksheet.getRange('A1:B2');
118
+ * fRange.activate();
119
+ *
120
+ * // get the next cell in the right direction, and update the primary cell to the next cell, now the active cell is B1
121
+ * let fSelection = fWorksheet.getSelection();
122
+ * const nextCell = fSelection.getNextDataRange(univerAPI.Enum.Direction.RIGHT);
103
123
  * console.log(nextCell?.getA1Notation()); // B1
124
+ * fSelection = fSelection.updatePrimaryCell(nextCell);
125
+ *
126
+ * // get the next cell in the right direction, the next cell is A2
127
+ * const nextCell2 = fSelection.getNextDataRange(univerAPI.Enum.Direction.RIGHT);
128
+ * console.log(nextCell2?.getA1Notation()); // A2
104
129
  * ```
105
130
  */
106
131
  getNextDataRange(direction: Direction): FRange | null;
@@ -19,12 +19,14 @@ export interface IFUniverSheetsMixin {
19
19
  * @returns {FWorkbook} FWorkbook API instance.
20
20
  * @example
21
21
  * ```ts
22
- * univerAPI.createWorkbook({ id: 'Sheet1', name: 'Sheet1' });
22
+ * const fWorkbook = univerAPI.createWorkbook({ id: 'Sheet1', name: 'Sheet1' });
23
+ * console.log(fWorkbook);
23
24
  * ```
24
25
  *
25
26
  * Add you can make the workbook not as the active workbook by setting options:
26
27
  * ```ts
27
- * univerAPI.createWorkbook({ id: 'Sheet1', name: 'Sheet1' }, { makeCurrent: false });
28
+ * const fWorkbook = univerAPI.createWorkbook({ id: 'Sheet1', name: 'Sheet1' }, { makeCurrent: false });
29
+ * console.log(fWorkbook);
28
30
  * ```
29
31
  */
30
32
  createWorkbook(data: Partial<IWorkbookData>, options?: ICreateUnitOptions): FWorkbook;
@@ -33,7 +35,8 @@ export interface IFUniverSheetsMixin {
33
35
  * @returns {FWorkbook | null} The currently focused Univer spreadsheet.
34
36
  * @example
35
37
  * ```ts
36
- * univerAPI.getActiveWorkbook();
38
+ * const fWorkbook = univerAPI.getActiveWorkbook();
39
+ * console.log(fWorkbook);
37
40
  * ```
38
41
  */
39
42
  getActiveWorkbook(): FWorkbook | null;
@@ -45,6 +48,15 @@ export interface IFUniverSheetsMixin {
45
48
  * Get the spreadsheet API handler by the spreadsheet id.
46
49
  * @param {string} id The spreadsheet id.
47
50
  * @returns {FWorkbook | null} The spreadsheet API instance.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const fWorkbook = univerAPI.getUniverSheet('Sheet1');
55
+ * console.log(fWorkbook);
56
+ *
57
+ * const fWorkbook = univerAPI.getWorkbook('Sheet1');
58
+ * console.log(fWorkbook);
59
+ * ```
48
60
  */
49
61
  getUniverSheet(id: string): FWorkbook | null;
50
62
  getWorkbook(id: string): FWorkbook | null;
@@ -62,7 +74,13 @@ export interface IFUniverSheetsMixin {
62
74
  * @returns {FDefinedNameBuilder} - The defined name builder.
63
75
  * @example
64
76
  * ```ts
65
- * univerAPI.newDefinedName();
77
+ * const fWorkbook = univerAPI.getActiveWorkbook();
78
+ * const definedNameBuilder = univerAPI.newDefinedName()
79
+ * .setRef('Sheet1!$A$1')
80
+ * .setName('MyDefinedName')
81
+ * .setComment('This is a comment');
82
+ * console.log(definedNameBuilder);
83
+ * fWorkbook.insertDefinedNameBuilder(definedNameBuilder.build());
66
84
  * ```
67
85
  */
68
86
  newDefinedName(): FDefinedNameBuilder;
@@ -73,7 +91,12 @@ export interface IFUniverSheetsMixin {
73
91
  * @returns {Nullable<{ workbook: FWorkbook; worksheet: FWorksheet }>} - The target of the sheet.
74
92
  * @example
75
93
  * ```ts
76
- * univerAPI.getSheetTarget('unitId', 'subUnitId');
94
+ * const unitId = 'workbook-01';
95
+ * const subUnitId = 'sheet-0001';
96
+ * const target = univerAPI.getSheetTarget(unitId, subUnitId);
97
+ * if (!target) return;
98
+ * const { workbook, worksheet } = target;
99
+ * console.log(workbook, worksheet);
77
100
  * ```
78
101
  */
79
102
  getSheetTarget(unitId: string, subUnitId: string): Nullable<{
@@ -86,10 +109,11 @@ export interface IFUniverSheetsMixin {
86
109
  * @returns {Nullable<{ workbook: FWorkbook; worksheet: FWorksheet }>} - The target of the sheet.
87
110
  * @example
88
111
  * ```ts
89
- * univerAPI.addEvent(univerAPI.event.CommandExecuted, (commandInfo) => {
112
+ * univerAPI.addEvent(univerAPI.Event.CommandExecuted, (commandInfo) => {
90
113
  * const target = univerAPI.getCommandSheetTarget(commandInfo);
91
114
  * if (!target) return;
92
115
  * const { workbook, worksheet } = target;
116
+ * console.log(workbook, worksheet);
93
117
  * });
94
118
  * ```
95
119
  */
@@ -105,6 +129,7 @@ export interface IFUniverSheetsMixin {
105
129
  * const target = univerAPI.getActiveSheet();
106
130
  * if (!target) return;
107
131
  * const { workbook, worksheet } = target;
132
+ * console.log(workbook, worksheet);
108
133
  * ```
109
134
  */
110
135
  getActiveSheet(): Nullable<{
@@ -139,17 +164,11 @@ export declare class FUniverSheetsMixin extends FUniver implements IFUniverSheet
139
164
  workbook: FWorkbook;
140
165
  worksheet: FWorksheet;
141
166
  }>;
142
- private _fireBeforeActiveSheetChange;
143
167
  private _fireActiveSheetChanged;
144
- private _fireBeforeSheetDelete;
145
168
  private _fireSheetDeleted;
146
- private _fireBeforeSheetMove;
147
169
  private _fireSheetMoved;
148
- private _fireBeforeSheetNameChange;
149
170
  private _fireSheetNameChanged;
150
- private _fireBeforeSheetTabColorChange;
151
171
  private _fireSheetTabColorChanged;
152
- private _fireBeforeSheetHideChange;
153
172
  private _fireSheetHideChanged;
154
173
  }
155
174
  declare module '@univerjs/core/facade' {