@univerjs/sheets 0.4.1 → 0.4.2-nightly.202410301606

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 (76) hide show
  1. package/lib/add-worksheet-merge.command-0cuLfO_2.mjs +5939 -0
  2. package/lib/es/facade.js +1818 -0
  3. package/lib/es/index.js +1800 -7245
  4. package/lib/locale/en-US.js +17 -0
  5. package/lib/locale/fa-IR.js +17 -0
  6. package/lib/locale/ru-RU.js +17 -0
  7. package/lib/locale/vi-VN.js +17 -0
  8. package/lib/locale/zh-CN.js +17 -0
  9. package/lib/locale/zh-TW.js +17 -0
  10. package/lib/types/basics/row-column-value.d.ts +14 -0
  11. package/lib/types/commands/commands/__tests__/set-col-data.command.spec.d.ts +16 -0
  12. package/lib/types/commands/commands/__tests__/set-row-data.command.spec.d.ts +16 -0
  13. package/lib/types/commands/commands/__tests__/set-worksheet-default-style.command.spec.d.ts +16 -0
  14. package/lib/types/commands/commands/set-col-data.command.d.ts +7 -0
  15. package/lib/types/commands/commands/set-frozen.command.d.ts +13 -0
  16. package/lib/types/commands/commands/set-row-data.command.d.ts +7 -0
  17. package/lib/types/commands/commands/set-style.command.d.ts +1 -1
  18. package/lib/types/commands/commands/set-worksheet-col-width.command.d.ts +6 -0
  19. package/lib/types/commands/commands/set-worksheet-default-style.command.d.ts +2 -0
  20. package/lib/types/commands/commands/toggle-gridlines.command.d.ts +7 -0
  21. package/lib/types/commands/mutations/add-range-protection.mutation.d.ts +2 -2
  22. package/lib/types/commands/mutations/delete-range-protection.mutation.d.ts +3 -3
  23. package/lib/types/commands/mutations/set-col-data.mutation.d.ts +8 -0
  24. package/lib/types/commands/mutations/set-frozen.mutation.d.ts +8 -0
  25. package/lib/types/commands/mutations/set-row-data.mutation.d.ts +8 -0
  26. package/lib/types/commands/mutations/set-worksheet-col-width.mutation.d.ts +3 -0
  27. package/lib/types/commands/mutations/set-worksheet-default-style.mutation.d.ts +12 -0
  28. package/lib/types/commands/mutations/toggle-gridlines.mutation.d.ts +7 -0
  29. package/lib/types/controllers/config.schema.d.ts +4 -0
  30. package/lib/types/facade/__tests__/utils.spec.d.ts +16 -0
  31. package/lib/types/facade/f-permission.d.ts +106 -0
  32. package/lib/types/facade/f-range.d.ts +193 -0
  33. package/lib/types/facade/f-selection.d.ts +11 -0
  34. package/lib/types/facade/f-univer.d.ts +36 -0
  35. package/lib/types/facade/f-workbook.d.ts +105 -0
  36. package/lib/types/facade/f-worksheet.d.ts +408 -0
  37. package/lib/types/facade/index.d.ts +6 -0
  38. package/lib/types/facade/utils.d.ts +24 -0
  39. package/lib/types/index.d.ts +19 -7
  40. package/lib/types/model/range-protection.cache.d.ts +5 -2
  41. package/lib/types/services/border-style-manager.service.d.ts +2 -2
  42. package/lib/types/services/permission/permission-point/index.d.ts +2 -0
  43. package/lib/types/services/permission/permission-point/range/delete-protection.d.ts +13 -0
  44. package/lib/types/services/permission/permission-point/range/manage-collaborator.d.ts +13 -0
  45. package/lib/types/services/permission/permission-point/workbook/create-permission.d.ts +11 -0
  46. package/lib/types/services/permission/permission-point/worksheet/delete-protection.d.ts +12 -0
  47. package/lib/types/services/permission/range-permission/range-protection.ref-range.d.ts +3 -3
  48. package/lib/types/services/permission/range-permission/range-protection.service.d.ts +3 -2
  49. package/lib/types/services/permission/range-permission/util.d.ts +1 -0
  50. package/lib/types/services/permission/type.d.ts +1 -1
  51. package/lib/types/services/permission/workbook-permission/workbook-permission.service.d.ts +4 -1
  52. package/lib/types/services/permission/worksheet-permission/utils.d.ts +2 -2
  53. package/lib/types/services/selections/selection-manager.service.d.ts +2 -2
  54. package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +38 -7
  55. package/lib/umd/facade.js +3 -0
  56. package/lib/umd/index.js +3 -3
  57. package/lib/umd/locale/en-US.js +1 -0
  58. package/lib/umd/locale/fa-IR.js +1 -0
  59. package/lib/umd/locale/ru-RU.js +1 -0
  60. package/lib/umd/locale/vi-VN.js +1 -0
  61. package/lib/umd/locale/zh-CN.js +1 -0
  62. package/lib/umd/locale/zh-TW.js +1 -0
  63. package/package.json +21 -18
  64. package/LICENSE +0 -176
  65. package/lib/cjs/index.js +0 -3
  66. package/lib/locale/en-US.json +0 -14
  67. package/lib/locale/fa-IR.json +0 -14
  68. package/lib/locale/ru-RU.json +0 -14
  69. package/lib/locale/vi-VN.json +0 -14
  70. package/lib/locale/zh-CN.json +0 -14
  71. package/lib/locale/zh-TW.json +0 -14
  72. package/lib/types/basics/cell-custom.d.ts +0 -12
  73. package/lib/types/commands/commands/set-frozen-cancel.command.d.ts +0 -2
  74. package/lib/types/commands/commands/set-hide-gridlines.command.d.ts +0 -7
  75. package/lib/types/commands/mutations/set-hide-gridlines.mutatiom.d.ts +0 -8
  76. /package/lib/types/basics/__tests__/{cell-custom.spec.d.ts → row-column-value.spec.d.ts} +0 -0
@@ -0,0 +1,193 @@
1
+ import { CellValue, ICellData, IObjectMatrixPrimitiveType, IRange, IStyleData, Nullable, Workbook, Worksheet, FBase, ICommandService, Injector, WrapStrategy } from '@univerjs/core';
2
+ import { FHorizontalAlignment, FVerticalAlignment } from './utils';
3
+ import { FormulaDataModel } from '@univerjs/engine-formula';
4
+ export type FontLine = 'none' | 'underline' | 'line-through';
5
+ export type FontStyle = 'normal' | 'italic';
6
+ export type FontWeight = 'normal' | 'bold';
7
+ export declare class FRange extends FBase {
8
+ protected readonly _workbook: Workbook;
9
+ protected readonly _worksheet: Worksheet;
10
+ protected readonly _range: IRange;
11
+ protected readonly _injector: Injector;
12
+ protected readonly _commandService: ICommandService;
13
+ protected readonly _formulaDataModel: FormulaDataModel;
14
+ constructor(_workbook: Workbook, _worksheet: Worksheet, _range: IRange, _injector: Injector, _commandService: ICommandService, _formulaDataModel: FormulaDataModel);
15
+ /**
16
+ * Get the unit ID of the current workbook
17
+ *
18
+ * @return The unit ID of the workbook
19
+ */
20
+ getUnitId(): string;
21
+ /**
22
+ * Gets the name of the worksheet
23
+ *
24
+ * @return The name of the worksheet
25
+ */
26
+ getSheetName(): string;
27
+ /**
28
+ * Gets the area where the statement is applied
29
+ *
30
+ * @return The area where the statement is applied
31
+ */
32
+ getRange(): IRange;
33
+ /**
34
+ * Gets the starting row number of the applied area
35
+ *
36
+ * @return The starting row number of the area
37
+ */
38
+ getRow(): number;
39
+ /**
40
+ * Gets the starting column number of the applied area
41
+ *
42
+ * @return The starting column number of the area
43
+ */
44
+ getColumn(): number;
45
+ /**
46
+ * Gets the width of the applied area
47
+ *
48
+ * @return The width of the area
49
+ */
50
+ getWidth(): number;
51
+ /**
52
+ * Gets the height of the applied area
53
+ *
54
+ * @return The height of the area
55
+ */
56
+ getHeight(): number;
57
+ /**
58
+ * Return first cell model data in this range
59
+ * @returns The cell model data
60
+ */
61
+ getCellData(): ICellData | null;
62
+ /**
63
+ * Return range whether this range is merged
64
+ * @returns if true is merged
65
+ */
66
+ isMerged(): boolean;
67
+ /**
68
+ * Return first cell style data in this range
69
+ * @returns The cell style data
70
+ */
71
+ getCellStyleData(): IStyleData | null;
72
+ /**
73
+ * Returns the value of the cell at the start of this range.
74
+ * @returns The value of the cell.
75
+ */
76
+ getValue(): CellValue | null;
77
+ /**
78
+ * Returns the rectangular grid of values for this range.
79
+ * Returns a two-dimensional array of values, indexed by row, then by column.
80
+ * @returns A two-dimensional array of values.
81
+ */
82
+ getValues(): Nullable<CellValue>[][];
83
+ /**
84
+ * Returns the cell data for the cells in the range.
85
+ * @returns A two-dimensional array of cell data.
86
+ */
87
+ getCellDataGrid(): Nullable<ICellData>[][];
88
+ /**
89
+ * Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
90
+ * @returns A two-dimensional array of formulas in string format.
91
+ */
92
+ getFormulas(): string[][];
93
+ getWrap(): boolean;
94
+ getWrapStrategy(): WrapStrategy;
95
+ getHorizontalAlignment(): string;
96
+ getVerticalAlignment(): string;
97
+ setBackgroundColor(color: string): Promise<boolean>;
98
+ /**
99
+ * The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
100
+ * @param value
101
+ */
102
+ setValue(value: CellValue | ICellData): Promise<boolean>;
103
+ /**
104
+ * Set the cell wrap of the given range.
105
+ * Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.
106
+ */
107
+ setWrap(isWrapEnabled: boolean): Promise<boolean>;
108
+ /**
109
+ * Sets the text wrapping strategy for the cells in the range.
110
+ */
111
+ setWrapStrategy(strategy: WrapStrategy): Promise<boolean>;
112
+ /**
113
+ * Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
114
+ */
115
+ setVerticalAlignment(alignment: FVerticalAlignment): Promise<boolean>;
116
+ /**
117
+ * Set the horizontal (left to right) alignment for the given range (left/center/right).
118
+ */
119
+ setHorizontalAlignment(alignment: FHorizontalAlignment): Promise<boolean>;
120
+ /**
121
+ * Sets a different value for each cell in the range. The value can be a two-dimensional array or a standard range matrix (must match the dimensions of this range), consisting of numbers, strings, Boolean values or Composed of standard cell formats. If a value begins with `=`, it is interpreted as a formula.
122
+ * @param value
123
+ */
124
+ setValues(value: CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>): Promise<boolean>;
125
+ /**
126
+ * Sets the font weight for the given range (normal/bold),
127
+ * @param fontWeight The font weight, either 'normal' or 'bold'; a null value resets the font weight.
128
+ */
129
+ setFontWeight(fontWeight: FontWeight | null): this;
130
+ /**
131
+ * Sets the font style for the given range ('italic' or 'normal').
132
+ * @param fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
133
+ */
134
+ setFontStyle(fontStyle: FontStyle | null): this;
135
+ /**
136
+ * Sets the font line style of the given range ('underline', 'line-through', or 'none').
137
+ * @param fontLine The font line style, either 'underline', 'line-through', or 'none'; a null value resets the font line style.
138
+ */
139
+ setFontLine(fontLine: FontLine | null): this;
140
+ /**
141
+ * Sets the font underline style of the given ITextDecoration
142
+ */
143
+ private _setFontUnderline;
144
+ /**
145
+ * Sets the font strikethrough style of the given ITextDecoration
146
+ */
147
+ private _setFontStrikethrough;
148
+ /**
149
+ * Sets the font family, such as "Arial" or "Helvetica".
150
+ * @param fontFamily The font family to set; a null value resets the font family.
151
+ */
152
+ setFontFamily(fontFamily: string | null): this;
153
+ /**
154
+ * Sets the font size, with the size being the point size to use.
155
+ * @param size A font size in point size. A null value resets the font size.
156
+ */
157
+ setFontSize(size: number | null): this;
158
+ /**
159
+ * Sets the font color in CSS notation (such as '#ffffff' or 'white').
160
+ * @param color The font color in CSS notation (such as '#ffffff' or 'white'); a null value resets the color.
161
+ */
162
+ setFontColor(color: string | null): this;
163
+ /**
164
+ * Merge cells in a range into one merged cell
165
+ * @returns This range, for chaining
166
+ */
167
+ merge(): Promise<FRange>;
168
+ /**
169
+ * Merges cells in a range horizontally.
170
+ * @returns This range, for chaining
171
+ */
172
+ mergeAcross(): Promise<FRange>;
173
+ /**
174
+ * Merges cells in a range vertically.
175
+ * @returns This range, for chaining
176
+ */
177
+ mergeVertically(): Promise<FRange>;
178
+ /**
179
+ * Returns true if cells in the current range overlap a merged cell.
180
+ * @returns {boolean} is overlap with a merged cell
181
+ */
182
+ isPartOfMerge(): boolean;
183
+ /**
184
+ * Unmerge cells in the range
185
+ * @returns This range, for chaining
186
+ */
187
+ breakApart(): FRange;
188
+ /**
189
+ * Iterate cells in this range. Merged cells will be respected.
190
+ * @param callback
191
+ */
192
+ forEach(callback: (row: number, col: number, cell: ICellData) => void): void;
193
+ }
@@ -0,0 +1,11 @@
1
+ import { Workbook, Worksheet, Injector } from '@univerjs/core';
2
+ import { ISelectionWithStyle } from '@univerjs/sheets';
3
+ import { FRange } from './f-range';
4
+ export declare class FSelection {
5
+ private readonly _workbook;
6
+ private readonly _worksheet;
7
+ private readonly _selections;
8
+ private readonly _injector;
9
+ constructor(_workbook: Workbook, _worksheet: Worksheet, _selections: Readonly<ISelectionWithStyle[]>, _injector: Injector);
10
+ getActiveRange(): FRange | null;
11
+ }
@@ -0,0 +1,36 @@
1
+ import { IWorkbookData } from '@univerjs/core';
2
+ import { FPermission } from './f-permission';
3
+ import { FWorkbook } from './f-workbook';
4
+ interface IFUniverSheetsMixin {
5
+ /**
6
+ * Create a new spreadsheet and get the API handler of that spreadsheet.
7
+ *
8
+ * @param {Partial<IWorkbookData>} data The snapshot of the spreadsheet.
9
+ * @returns {FWorkbook} FWorkbook API instance.
10
+ */
11
+ createUniverSheet(data: Partial<IWorkbookData>): FWorkbook;
12
+ /**
13
+ * Get the currently focused Univer spreadsheet.
14
+ *
15
+ * @returns {FWorkbook | null} The currently focused Univer spreadsheet.
16
+ */
17
+ getActiveWorkbook(): FWorkbook | null;
18
+ /**
19
+ * Get the spreadsheet API handler by the spreadsheet id.
20
+ *
21
+ * @param {string} id The spreadsheet id.
22
+ * @returns {FWorkbook | null} The spreadsheet API instance.
23
+ */
24
+ getUniverSheet(id: string): FWorkbook | null;
25
+ /**
26
+ * Get the PermissionInstance.
27
+ *
28
+ * @returns {FPermission} - The PermissionInstance.
29
+ */
30
+ getPermission(): FPermission;
31
+ }
32
+ declare module '@univerjs/core' {
33
+ interface FUniver extends IFUniverSheetsMixin {
34
+ }
35
+ }
36
+ export {};
@@ -0,0 +1,105 @@
1
+ import { CommandListener, IDisposable, IRange, IWorkbookData, Workbook, FBase, ICommandService, ILogService, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService } from '@univerjs/core';
2
+ import { SheetsSelectionsService } from '../services/selections/selection-manager.service';
3
+ import { FRange } from './f-range';
4
+ import { FWorksheet } from './f-worksheet';
5
+ export declare class FWorkbook extends FBase {
6
+ protected readonly _workbook: Workbook;
7
+ protected readonly _injector: Injector;
8
+ protected readonly _resourceLoaderService: IResourceLoaderService;
9
+ protected readonly _selectionManagerService: SheetsSelectionsService;
10
+ protected readonly _univerInstanceService: IUniverInstanceService;
11
+ protected readonly _commandService: ICommandService;
12
+ protected readonly _permissionService: IPermissionService;
13
+ protected readonly _logService: ILogService;
14
+ readonly id: string;
15
+ constructor(_workbook: Workbook, _injector: Injector, _resourceLoaderService: IResourceLoaderService, _selectionManagerService: SheetsSelectionsService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _permissionService: IPermissionService, _logService: ILogService);
16
+ getId(): string;
17
+ getName(): string;
18
+ /**
19
+ * save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
20
+ */
21
+ save(): IWorkbookData;
22
+ /**
23
+ * @deprecated use 'save' instead.
24
+ * @return {*} {IWorkbookData}
25
+ * @memberof FWorkbook
26
+ */
27
+ getSnapshot(): IWorkbookData;
28
+ /**
29
+ * Get the active sheet of the workbook.
30
+ * @returns The active sheet of the workbook
31
+ */
32
+ getActiveSheet(): FWorksheet;
33
+ /**
34
+ * Gets all the worksheets in this workbook
35
+ * @returns An array of all the worksheets in the workbook
36
+ */
37
+ getSheets(): FWorksheet[];
38
+ /**
39
+ * Create a new worksheet and returns a handle to it.
40
+ * @param name Name of the new sheet
41
+ * @param rows How may rows would the new sheet have
42
+ * @param column How many columns would the new sheet have
43
+ * @returns The new created sheet
44
+ */
45
+ create(name: string, rows: number, column: number): FWorksheet;
46
+ /**
47
+ * Get a worksheet by sheet id.
48
+ * @param sheetId The id of the sheet to get.
49
+ * @return The worksheet with given sheet id
50
+ */
51
+ getSheetBySheetId(sheetId: string): FWorksheet | null;
52
+ /**
53
+ * Get a worksheet by sheet name.
54
+ * @param name The name of the sheet to get.
55
+ * @returns The worksheet with given sheet name
56
+ */
57
+ getSheetByName(name: string): FWorksheet | null;
58
+ /**
59
+ * Sets the given worksheet to be the active worksheet in the workbook.
60
+ * @param sheet The worksheet to set as the active worksheet.
61
+ * @returns The active worksheet
62
+ */
63
+ setActiveSheet(sheet: FWorksheet): FWorksheet;
64
+ /**
65
+ * Inserts a new worksheet into the workbook.
66
+ * Using a default sheet name. The new sheet becomes the active sheet
67
+ * @returns The new sheet
68
+ */
69
+ insertSheet(): FWorksheet;
70
+ /**
71
+ * Deletes the specified worksheet.
72
+ * @param sheet The worksheet to delete.
73
+ */
74
+ deleteSheet(sheet: FWorksheet): void;
75
+ undo(): Promise<boolean>;
76
+ redo(): Promise<boolean>;
77
+ /**
78
+ * Register a callback that will be triggered before invoking a command targeting the Univer sheet.
79
+ * @param callback the callback.
80
+ * @returns A function to dispose the listening.
81
+ */
82
+ onBeforeCommandExecute(callback: CommandListener): IDisposable;
83
+ /**
84
+ * Register a callback that will be triggered when a command is invoked targeting the Univer sheet.
85
+ * @param callback the callback.
86
+ * @returns A function to dispose the listening.
87
+ */
88
+ onCommandExecuted(callback: CommandListener): IDisposable;
89
+ onSelectionChange(callback: (selections: IRange[]) => void): IDisposable;
90
+ /**
91
+ * Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.
92
+ * @param {boolean} value editable value want to set
93
+ */
94
+ setEditable(value: boolean): void;
95
+ /**
96
+ * Sets the active selection region for this sheet.
97
+ * @param range The range to set as the active selection.
98
+ */
99
+ setActiveRange(range: FRange): void;
100
+ /**
101
+ * Returns the selected range in the active sheet, or null if there is no active range.
102
+ * @returns the active range
103
+ */
104
+ getActiveRange(): FRange | null;
105
+ }