@univerjs/sheets 0.4.2 → 0.5.0-alpha.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 (53) hide show
  1. package/lib/cjs/facade.js +1 -0
  2. package/lib/cjs/index.js +3 -3
  3. package/lib/cjs/locale/en-US.js +1 -0
  4. package/lib/cjs/locale/fa-IR.js +1 -0
  5. package/lib/cjs/locale/ru-RU.js +1 -0
  6. package/lib/cjs/locale/vi-VN.js +1 -0
  7. package/lib/cjs/locale/zh-CN.js +1 -0
  8. package/lib/cjs/locale/zh-TW.js +1 -0
  9. package/lib/es/facade.js +1806 -0
  10. package/lib/es/index.js +7447 -7530
  11. package/lib/es/locale/en-US.js +17 -0
  12. package/lib/es/locale/fa-IR.js +17 -0
  13. package/lib/es/locale/ru-RU.js +17 -0
  14. package/lib/es/locale/vi-VN.js +17 -0
  15. package/lib/es/locale/zh-CN.js +17 -0
  16. package/lib/es/locale/zh-TW.js +17 -0
  17. package/lib/types/commands/commands/add-worksheet-protection.command.d.ts +7 -0
  18. package/lib/types/commands/commands/delete-worksheet-protection.command.d.ts +8 -0
  19. package/lib/types/commands/commands/set-frozen.command.d.ts +13 -0
  20. package/lib/types/commands/commands/set-protection.command.d.ts +13 -0
  21. package/lib/types/commands/commands/set-worksheet-protection.command.d.ts +8 -0
  22. package/lib/types/commands/mutations/reorder-range.mutation.d.ts +1 -1
  23. package/lib/types/facade/__tests__/utils.spec.d.ts +16 -0
  24. package/lib/types/facade/f-permission.d.ts +106 -0
  25. package/lib/types/facade/f-range.d.ts +193 -0
  26. package/lib/types/facade/f-selection.d.ts +11 -0
  27. package/lib/types/facade/f-univer.d.ts +36 -0
  28. package/lib/types/facade/f-workbook.d.ts +105 -0
  29. package/lib/types/facade/f-worksheet.d.ts +408 -0
  30. package/lib/types/facade/index.d.ts +22 -0
  31. package/lib/types/facade/utils.d.ts +24 -0
  32. package/lib/types/index.d.ts +8 -5
  33. package/lib/types/model/range-protection-rule.model.d.ts +10 -1
  34. package/lib/types/services/permission/type.d.ts +3 -1
  35. package/lib/types/services/permission/worksheet-permission/worksheet-permission.service.d.ts +3 -2
  36. package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +38 -7
  37. package/lib/umd/facade.js +1 -0
  38. package/lib/umd/index.js +3 -3
  39. package/lib/umd/locale/en-US.js +1 -0
  40. package/lib/umd/locale/fa-IR.js +1 -0
  41. package/lib/umd/locale/ru-RU.js +1 -0
  42. package/lib/umd/locale/vi-VN.js +1 -0
  43. package/lib/umd/locale/zh-CN.js +1 -0
  44. package/lib/umd/locale/zh-TW.js +1 -0
  45. package/package.json +36 -17
  46. package/lib/locale/en-US.json +0 -14
  47. package/lib/locale/fa-IR.json +0 -14
  48. package/lib/locale/ru-RU.json +0 -14
  49. package/lib/locale/vi-VN.json +0 -14
  50. package/lib/locale/zh-CN.json +0 -14
  51. package/lib/locale/zh-TW.json +0 -14
  52. package/lib/types/commands/commands/set-frozen-cancel.command.d.ts +0 -2
  53. package/lib/types/commands/commands/set-range-protection.command.d.ts +0 -8
@@ -0,0 +1,17 @@
1
+ const e = {
2
+ sheets: {
3
+ tabs: {
4
+ sheetCopy: "(Copy{0})",
5
+ sheet: "Sheet"
6
+ },
7
+ info: {
8
+ overlappingSelections: "Cannot use that command on overlapping selections",
9
+ acrossMergedCell: "Across a merged cell",
10
+ partOfCell: "Only part of a merged cell is selected",
11
+ hideSheet: "No visible sheet after you hide this"
12
+ }
13
+ }
14
+ };
15
+ export {
16
+ e as default
17
+ };
@@ -0,0 +1,17 @@
1
+ const e = {
2
+ sheets: {
3
+ tabs: {
4
+ sheetCopy: "(کپی{0})",
5
+ sheet: "برگ"
6
+ },
7
+ info: {
8
+ overlappingSelections: "نمی‌توان از این دستور روی انتخاب‌های همپوشانی استفاده کرد",
9
+ acrossMergedCell: "در سراسر سلول ادغام شده",
10
+ partOfCell: "فقط بخشی از سلول ادغام شده انتخاب شده است",
11
+ hideSheet: "پس از پنهان کردن این برگ، هیچ برگی قابل مشاهده نخواهد بود"
12
+ }
13
+ }
14
+ };
15
+ export {
16
+ e as default
17
+ };
@@ -0,0 +1,17 @@
1
+ const e = {
2
+ sheets: {
3
+ tabs: {
4
+ sheetCopy: "(Копия{0})",
5
+ sheet: "Лист"
6
+ },
7
+ info: {
8
+ overlappingSelections: "Невозможно использовать эту команду на пересекающихся выделениях",
9
+ acrossMergedCell: "Через объединенную ячейку",
10
+ partOfCell: "Выделена только часть объединенной ячейки",
11
+ hideSheet: "После скрытия этого листа не будет видно ни одного листа"
12
+ }
13
+ }
14
+ };
15
+ export {
16
+ e as default
17
+ };
@@ -0,0 +1,17 @@
1
+ const h = {
2
+ sheets: {
3
+ tabs: {
4
+ sheetCopy: "(Bản sao {0})",
5
+ sheet: "Bảng tính"
6
+ },
7
+ info: {
8
+ overlappingSelections: "Không thể sử dụng lệnh này trên các vùng chọn chồng chéo nhau",
9
+ acrossMergedCell: "Không thể vượt qua các ô đã hợp nhất",
10
+ partOfCell: "Chỉ chọn một phần của ô đã hợp nhất",
11
+ hideSheet: "Không có bảng tính nào hiển thị sau khi ẩn"
12
+ }
13
+ }
14
+ };
15
+ export {
16
+ h as default
17
+ };
@@ -0,0 +1,17 @@
1
+ const e = {
2
+ sheets: {
3
+ tabs: {
4
+ sheetCopy: "(副本{0})",
5
+ sheet: "工作表"
6
+ },
7
+ info: {
8
+ overlappingSelections: "无法对重叠选区使用该命令",
9
+ acrossMergedCell: "无法跨越合并单元格",
10
+ partOfCell: "仅选择了合并单元格的一部分",
11
+ hideSheet: "隐藏后无可见工作表"
12
+ }
13
+ }
14
+ };
15
+ export {
16
+ e as default
17
+ };
@@ -0,0 +1,17 @@
1
+ const e = {
2
+ sheets: {
3
+ tabs: {
4
+ sheetCopy: "(副本{0})",
5
+ sheet: "工作表"
6
+ },
7
+ info: {
8
+ overlappingSelections: "無法對重疊選區使用該命令",
9
+ acrossMergedCell: "無法跨越合併儲存格",
10
+ partOfCell: "僅選擇了合併儲存格的一部份",
11
+ hideSheet: "隱藏後無可見工作表"
12
+ }
13
+ }
14
+ };
15
+ export {
16
+ e as default
17
+ };
@@ -0,0 +1,7 @@
1
+ import { ICommand } from '@univerjs/core';
2
+ import { IWorksheetProtectionRule } from '../../services/permission/type';
3
+ export interface IAddWorksheetProtectionParams {
4
+ unitId: string;
5
+ rule: IWorksheetProtectionRule;
6
+ }
7
+ export declare const AddWorksheetProtectionCommand: ICommand<IAddWorksheetProtectionParams>;
@@ -0,0 +1,8 @@
1
+ import { ICommand } from '@univerjs/core';
2
+ import { IWorksheetProtectionRule } from '../../services/permission/type';
3
+ export interface IDeleteWorksheetProtectionParams {
4
+ unitId: string;
5
+ subUnitId: string;
6
+ rule: IWorksheetProtectionRule;
7
+ }
8
+ export declare const DeleteWorksheetProtectionCommand: ICommand<IDeleteWorksheetProtectionParams>;
@@ -1,2 +1,15 @@
1
1
  import { ICommand } from '@univerjs/core';
2
+ export interface ISetFrozenCommandParams {
3
+ startRow: number;
4
+ startColumn: number;
5
+ ySplit: number;
6
+ xSplit: number;
7
+ unitId?: string;
8
+ subUnitId?: string;
9
+ }
2
10
  export declare const SetFrozenCommand: ICommand;
11
+ export interface ICancelFrozenCommandParams {
12
+ unitId?: string;
13
+ subUnitId?: string;
14
+ }
15
+ export declare const CancelFrozenCommand: ICommand<ICancelFrozenCommandParams>;
@@ -0,0 +1,13 @@
1
+ import { ICommand, IRange } from '@univerjs/core';
2
+ import { IRangeProtectionRule } from '../../model/range-protection-rule.model';
3
+ import { IWorksheetProtectionRule } from '../../services/permission/type';
4
+ type IPermissionRule = (IRangeProtectionRule | IWorksheetProtectionRule) & {
5
+ ranges: IRange[];
6
+ id: string;
7
+ };
8
+ interface ISetProtectionParams {
9
+ rule: IPermissionRule;
10
+ oldRule: IPermissionRule;
11
+ }
12
+ export declare const SetProtectionCommand: ICommand<ISetProtectionParams>;
13
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ICommand } from '@univerjs/core';
2
+ import { IWorksheetProtectionRule } from '../../services/permission/type';
3
+ export interface ISetWorksheetProtectionParams {
4
+ permissionId: string;
5
+ rule: IWorksheetProtectionRule;
6
+ oldRule: IWorksheetProtectionRule;
7
+ }
8
+ export declare const SetWorksheetProtectionCommand: ICommand<ISetWorksheetProtectionParams>;
@@ -1,5 +1,5 @@
1
1
  import { IMutation, IRange } from '@univerjs/core';
2
- import { ISheetCommandSharedParams } from '@univerjs/sheets';
2
+ import { ISheetCommandSharedParams } from '../../commands/utils/interface';
3
3
  export interface IReorderRangeMutationParams extends ISheetCommandSharedParams {
4
4
  range: IRange;
5
5
  order: {
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -0,0 +1,106 @@
1
+ import { IRange, RangePermissionPointConstructor, WorkbookPermissionPointConstructor, WorkSheetPermissionPointConstructor, FBase, IAuthzIoService, ICommandService, Injector, IPermissionService } from '@univerjs/core';
2
+ import { RangeProtectionRuleModel, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';
3
+ export declare class FPermission extends FBase {
4
+ protected readonly _injector: Injector;
5
+ protected readonly _commandService: ICommandService;
6
+ protected readonly _permissionService: IPermissionService;
7
+ protected readonly _worksheetProtectionRuleModel: WorksheetProtectionRuleModel;
8
+ protected readonly _rangeProtectionRuleModel: RangeProtectionRuleModel;
9
+ protected readonly _worksheetProtectionPointRuleModel: WorksheetProtectionPointModel;
10
+ protected readonly _authzIoService: IAuthzIoService;
11
+ constructor(_injector: Injector, _commandService: ICommandService, _permissionService: IPermissionService, _worksheetProtectionRuleModel: WorksheetProtectionRuleModel, _rangeProtectionRuleModel: RangeProtectionRuleModel, _worksheetProtectionPointRuleModel: WorksheetProtectionPointModel, _authzIoService: IAuthzIoService);
12
+ /**
13
+ * Configures a specific permission point for a workbook.
14
+ *
15
+ * This function sets or updates a permission point for a workbook identified by `unitId`.
16
+ * It creates a new permission point if it does not already exist, and updates the point with the provided value.
17
+ *
18
+ * @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
19
+ * @param {WorkbookPermissionPointConstructor} FPointClass - The constructor function for creating a permission point instance. Other point constructors can See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
20
+ * @param {boolean} value - The boolean value to determine whether the permission point is enabled or disabled.
21
+ *
22
+ */
23
+ setWorkbookPermissionPoint(unitId: string, FPointClass: WorkbookPermissionPointConstructor, value: boolean): void;
24
+ /**
25
+ * This function is used to set whether the workbook can be edited
26
+ *
27
+ * @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
28
+ * @param {boolean} value - A value that controls whether the workbook can be edited
29
+ *
30
+ */
31
+ setWorkbookEditPermission(unitId: string, value: boolean): void;
32
+ /**
33
+ * This function is used to add a base permission for a worksheet.
34
+ *
35
+ * @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
36
+ * @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
37
+ *
38
+ * @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission is successfully added. If the operation fails or no result is returned, it resolves to `undefined`.
39
+ */
40
+ addWorksheetBasePermission(unitId: string, subUnitId: string): Promise<string | undefined>;
41
+ /**
42
+ * Delete the entire table protection set for the worksheet and reset the point permissions of the worksheet to true
43
+ *
44
+ * @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
45
+ * @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
46
+ */
47
+ removeWorksheetPermission(unitId: string, subUnitId: string): void;
48
+ /**
49
+ * Sets the worksheet permission point by updating or adding the permission point for the worksheet.
50
+ * If the worksheet doesn't have a base permission, it creates one to used render
51
+ *
52
+ * @param {string} unitId - The unique identifier of the workbook.
53
+ * @param {string} subUnitId - The unique identifier of the worksheet.
54
+ * @param {WorkSheetPermissionPointConstructor} FPointClass - The constructor for the permission point class.
55
+ * See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
56
+ * @param {boolean} value - The new permission value to be set for the worksheet.
57
+ *
58
+ * @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission point is successfully set or created. If no permission is set, it resolves to `undefined`.
59
+ */
60
+ setWorksheetPermissionPoint(unitId: string, subUnitId: string, FPointClass: WorkSheetPermissionPointConstructor, value: boolean): Promise<string | undefined>;
61
+ /**
62
+ * Adds a range protection to the worksheet.
63
+ *
64
+ * @param {string} unitId - The unique identifier of the workbook.
65
+ * @param {string} subUnitId - The unique identifier of the worksheet.
66
+ * @param {IRange[]} ranges - The ranges to be protected.
67
+ *
68
+ * @returns {Promise<{ permissionId: string, ruleId: string } | undefined>} - Returns an object containing the `permissionId` and `ruleId` if the range protection is successfully added. If the operation fails or no result is returned, it resolves to `undefined`. permissionId is used to stitch permission point ID,ruleId is used to store permission rules
69
+ */
70
+ addRangeBaseProtection(unitId: string, subUnitId: string, ranges: IRange[]): Promise<{
71
+ permissionId: string;
72
+ ruleId: string;
73
+ } | undefined>;
74
+ /**
75
+ * Removes the range protection from the worksheet.
76
+ *
77
+ * @param {string} unitId - The unique identifier of the workbook.
78
+ * @param {string} subUnitId - The unique identifier of the worksheet.
79
+ * @param {string[]} ruleIds - The rule IDs of the range protection to be removed.
80
+ */
81
+ removeRangeProtection(unitId: string, subUnitId: string, ruleIds: string[]): void;
82
+ /**
83
+ * Modify the permission points of a custom area
84
+ *
85
+ * @param {string} unitId - The unique identifier of the workbook.
86
+ * @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
87
+ * @param {string} permissionId - The unique identifier of the permission that controls access to the range.
88
+ * @param {RangePermissionPointConstructor} FPointClass - The constructor for the range permission point class.
89
+ * See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
90
+ * @param {boolean} value - The new permission value to be set for the range (e.g., true for allowing access, false for restricting access).
91
+ */
92
+ setRangeProtectionPermissionPoint(unitId: string, subUnitId: string, permissionId: string, FPointClass: RangePermissionPointConstructor, value: boolean): void;
93
+ /**
94
+ * Sets the ranges for range protection in a worksheet.
95
+ *
96
+ * This method finds the rule by unitId, subUnitId, and ruleId, and updates the rule with the provided ranges.
97
+ * It checks for overlaps with existing ranges in the same subunit and shows an error message if any overlap is detected.
98
+ * If no overlap is found, it executes the command to update the range protection with the new ranges.
99
+ *
100
+ * @param {string} unitId - The unique identifier of the workbook.
101
+ * @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
102
+ * @param {string} ruleId - The ruleId of the range protection rule that is being updated.
103
+ * @param {IRange[]} ranges - The array of new ranges to be set for the range protection rule.
104
+ */
105
+ setRangeProtectionRanges(unitId: string, subUnitId: string, ruleId: string, ranges: IRange[]): void;
106
+ }
@@ -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 '@univerjs/sheets';
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
+ }