@univerjs/core 0.1.0-alpha.2 → 0.1.0-beta.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 (42) hide show
  1. package/README.md +1 -1
  2. package/lib/cjs/index.js +5 -5
  3. package/lib/es/index.js +2578 -2509
  4. package/lib/types/basics/plugin-holder.d.ts +30 -0
  5. package/lib/types/basics/univer-doc.d.ts +7 -11
  6. package/lib/types/basics/univer-sheet.d.ts +7 -21
  7. package/lib/types/basics/univer-slide.d.ts +6 -19
  8. package/lib/types/basics/univer.d.ts +18 -13
  9. package/lib/types/common/memory-cursor.d.ts +1 -0
  10. package/lib/types/{shared/gen-name.d.ts → common/shims.d.ts} +1 -8
  11. package/lib/types/docs/data-model/index.d.ts +1 -0
  12. package/lib/types/docs/data-model/preset-list-type.d.ts +50 -0
  13. package/lib/types/index.d.ts +2 -1
  14. package/lib/types/plugin/plugin.d.ts +4 -3
  15. package/lib/types/services/command/command.service.d.ts +3 -3
  16. package/lib/types/services/instance/instance.service.d.ts +4 -4
  17. package/lib/types/services/log/log.service.d.ts +8 -6
  18. package/lib/types/shared/color/color-kit.d.ts +64 -0
  19. package/lib/types/shared/color/color.d.ts +17 -3
  20. package/lib/types/shared/common.d.ts +1 -3
  21. package/lib/types/shared/index.d.ts +1 -3
  22. package/lib/types/shared/locale.d.ts +1 -4
  23. package/lib/types/shared/object-matrix.d.ts +30 -28
  24. package/lib/types/shared/rectangle.d.ts +1 -0
  25. package/lib/types/shared/sort-rules.d.ts +2 -2
  26. package/lib/types/shared/tools.d.ts +0 -5
  27. package/lib/types/sheets/column-manager.d.ts +7 -8
  28. package/lib/types/sheets/range.d.ts +4 -4
  29. package/lib/types/sheets/row-manager.d.ts +7 -7
  30. package/lib/types/sheets/styles.d.ts +4 -6
  31. package/lib/types/sheets/workbook.d.ts +10 -14
  32. package/lib/types/sheets/worksheet.d.ts +1 -1
  33. package/lib/types/types/enum/border-style-types.d.ts +6 -1
  34. package/lib/types/types/enum/text-style.d.ts +3 -3
  35. package/lib/types/types/interfaces/i-document-data.d.ts +3 -2
  36. package/lib/types/types/interfaces/i-range.d.ts +13 -11
  37. package/lib/types/types/interfaces/i-style-data.d.ts +17 -0
  38. package/lib/types/types/interfaces/i-worksheet-data.d.ts +4 -5
  39. package/lib/umd/index.js +5 -5
  40. package/package.json +4 -4
  41. package/lib/types/shared/color/color-builder.d.ts +0 -35
  42. package/lib/types/shared/object-array.d.ts +0 -110
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare function sortRules(oa: any, ob: any): 1 | -1 | 0;
17
- export declare function sortRulesByDesc(oa: any, ob: any): 1 | -1 | 0;
16
+ export declare function sortRules(oa: any, ob: any): 1 | 0 | -1;
17
+ export declare function sortRulesByDesc(oa: any, ob: any): 1 | 0 | -1;
18
18
  /**
19
19
  *
20
20
  * @param key compare key
@@ -13,9 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { ObjectArrayPrimitiveType } from './object-array';
17
- import { ObjectArray } from './object-array';
18
- import type { ObjectMatrixPrimitiveType } from './object-matrix';
19
16
  import type { Class, IKeyValue } from './types';
20
17
  /**
21
18
  * Universal tool library
@@ -79,7 +76,6 @@ export declare class Tools {
79
76
  * @param value value to be set
80
77
  * @returns
81
78
  */
82
- static fillObjectMatrix<T>(rows: number, columns: number, value: T): ObjectMatrixPrimitiveType<T>;
83
79
  static numToWord(x: number): string;
84
80
  /**
85
81
  *
@@ -112,6 +108,5 @@ export declare class Tools {
112
108
  static commonExtend<T>(originJson: IKeyValue, extendJson: IKeyValue): T;
113
109
  static commonExtend1<T>(originJson: IKeyValue, extendJson: IKeyValue): T;
114
110
  static arrayToObject(array: IKeyValue[][]): IKeyValue;
115
- static createObjectArray<T>(array: ObjectArrayPrimitiveType<T> | ObjectArray<T>): ObjectArray<T>;
116
111
  static hasIntersectionBetweenTwoRanges(range1Start: number, range1End: number, range2Start: number, range2End: number): boolean;
117
112
  }
@@ -13,9 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Nullable } from '../shared';
17
- import type { ObjectArrayType } from '../shared/object-array';
18
- import { ObjectArray } from '../shared/object-array';
16
+ import type { Nullable } from '../common/type-utils';
17
+ import type { IObjectArrayPrimitiveType } from '../shared/object-matrix';
19
18
  import type { IColumnData, IRange, IWorksheetData } from '../types/interfaces';
20
19
  /**
21
20
  * Manage configuration information of all columns, get column width, column length, set column width, etc.
@@ -23,15 +22,15 @@ import type { IColumnData, IRange, IWorksheetData } from '../types/interfaces';
23
22
  export declare class ColumnManager {
24
23
  private readonly _config;
25
24
  private _columnData;
26
- constructor(_config: IWorksheetData, data: ObjectArrayType<Partial<IColumnData>>);
25
+ constructor(_config: IWorksheetData, data: IObjectArrayPrimitiveType<Partial<IColumnData>>);
27
26
  /**
28
27
  * Get width and hidden status of columns in the sheet
29
28
  * @returns
30
29
  */
31
- getColumnData(): ObjectArray<IColumnData>;
30
+ getColumnData(): IObjectArrayPrimitiveType<Partial<IColumnData>>;
32
31
  getColVisible(colPos: number): boolean;
33
32
  getHiddenCols(start?: number, end?: number): IRange[];
34
- getColumnDatas(columnPos: number, numColumns: number): ObjectArray<IColumnData>;
33
+ getColumnDatas(columnPos: number, numColumns: number): IObjectArrayPrimitiveType<Partial<IColumnData>>;
35
34
  /**
36
35
  * Get count of column in the sheet
37
36
  * @returns
@@ -48,11 +47,11 @@ export declare class ColumnManager {
48
47
  * @param columnPos column index
49
48
  * @returns
50
49
  */
51
- getColumn(columnPos: number): Nullable<IColumnData>;
50
+ getColumn(columnPos: number): Nullable<Partial<IColumnData>>;
52
51
  /**
53
52
  * get given column data or create a column data when it's null
54
53
  * @param columnPos column index
55
54
  * @returns
56
55
  */
57
- getColumnOrCreate(columnPos: number): IColumnData;
56
+ getColumnOrCreate(columnPos: number): Partial<IColumnData>;
58
57
  }
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Nullable, ObjectMatrixPrimitiveType } from '../shared';
16
+ import type { IObjectMatrixPrimitiveType, Nullable } from '../shared';
17
17
  import { ObjectMatrix } from '../shared';
18
18
  import type { HorizontalAlign, VerticalAlign, WrapStrategy } from '../types/enum';
19
19
  import { BooleanNumber, FontItalic, FontWeight } from '../types/enum';
@@ -79,7 +79,7 @@ export declare class Range {
79
79
  *
80
80
  * @returns range matrix
81
81
  */
82
- getMatrix(): ObjectMatrix<ICellData>;
82
+ getMatrix(): ObjectMatrix<Nullable<ICellData>>;
83
83
  /**
84
84
  * get range matrix object
85
85
  *
@@ -121,14 +121,14 @@ export declare class Range {
121
121
  /**
122
122
  * Returns the data of the object structure, and can set whether to bring styles
123
123
  */
124
- getObjectValue(options?: IValueOptionsType): ICellData;
124
+ getObjectValue(options?: IValueOptionsType): Nullable<ICellData>;
125
125
  /**
126
126
  * Returns the data of the object structure, and can set whether to bring styles
127
127
  *
128
128
  * @param options set whether to include style
129
129
  * @returns Returns a value in object format
130
130
  */
131
- getObjectValues(options?: IValueOptionsType): ObjectMatrixPrimitiveType<ICellData>;
131
+ getObjectValues(options?: IValueOptionsType): IObjectMatrixPrimitiveType<Nullable<ICellData>>;
132
132
  /**
133
133
  * Returns the font color of the cell in the top-left corner of the range, in CSS notation
134
134
  */
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Nullable, ObjectArrayType } from '../shared';
17
- import { ObjectArray } from '../shared';
16
+ import { type IObjectArrayPrimitiveType } from '../shared/object-matrix';
17
+ import type { Nullable } from '../shared/types';
18
18
  import type { IRange, IRowData, IWorksheetData } from '../types/interfaces';
19
19
  /**
20
20
  * Manage configuration information of all rows, get row height, row length, set row height, etc.
@@ -24,13 +24,13 @@ import type { IRange, IRowData, IWorksheetData } from '../types/interfaces';
24
24
  export declare class RowManager {
25
25
  private readonly _config;
26
26
  private _rowData;
27
- constructor(_config: IWorksheetData, data: ObjectArrayType<Partial<IRowData>>);
27
+ constructor(_config: IWorksheetData, data: IObjectArrayPrimitiveType<Partial<IRowData>>);
28
28
  /**
29
29
  * Get height and hidden status of columns in the sheet
30
30
  * @returns
31
31
  */
32
- getRowData(): ObjectArray<IRowData>;
33
- getRowDatas(rowPos: number, numRows: number): ObjectArray<IRowData>;
32
+ getRowData(): IObjectArrayPrimitiveType<Partial<IRowData>>;
33
+ getRowDatas(rowPos: number, numRows: number): IObjectArrayPrimitiveType<Partial<IRowData>>;
34
34
  getRowHeight(rowPos: number): number;
35
35
  getRowHeight(rowPos: number, count: number): number;
36
36
  /**
@@ -38,13 +38,13 @@ export declare class RowManager {
38
38
  * @param rowPos row index
39
39
  * @returns
40
40
  */
41
- getRow(rowPos: number): Nullable<IRowData>;
41
+ getRow(rowPos: number): Nullable<Partial<IRowData>>;
42
42
  /**
43
43
  * Get given row data or create a row data when it's null
44
44
  * @param rowPos row index
45
45
  * @returns
46
46
  */
47
- getRowOrCreate(rowPos: number): IRowData;
47
+ getRowOrCreate(rowPos: number): Partial<IRowData>;
48
48
  getHiddenRows(start?: number, end?: number): IRange[];
49
49
  getRowVisible(rowPos: number): boolean;
50
50
  /**
@@ -18,20 +18,18 @@ import type { ICellDataForSheetInterceptor, IStyleData } from '../types/interfac
18
18
  /**
19
19
  * Styles in a workbook, cells locate styles based on style IDs
20
20
  *
21
- * TODO@Dushusir: Cachemap needs to follow style to clear cleared following styles
22
21
  */
23
22
  export declare class Styles {
24
23
  private _styles;
25
24
  private _cacheMap;
26
- private _maxCacheSize;
27
- constructor(styles?: IKeyType<Nullable<IStyleData>>, maxCacheSize?: number);
25
+ constructor(styles?: IKeyType<Nullable<IStyleData>>);
28
26
  each(callback: (value: [string, Nullable<IStyleData>], index: number, array: Array<[string, Nullable<IStyleData>]>) => void): this;
29
- search(data: IStyleData): string;
27
+ search(data: IStyleData, styleObject: string): string;
30
28
  get(id: string | Nullable<IStyleData>): Nullable<IStyleData>;
31
- add(data: IStyleData): string;
29
+ add(data: IStyleData, styleObject: string): string;
32
30
  setValue(data: Nullable<IStyleData>): Nullable<string>;
33
31
  toJSON(): IKeyType<Nullable<IStyleData>>;
34
32
  getStyleByCell(cell: Nullable<ICellDataForSheetInterceptor>): Nullable<IStyleData>;
35
33
  private _generateCacheMap;
36
- private getExistingStyleId;
34
+ private _getExistingStyleId;
37
35
  }
@@ -13,9 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Injector } from '@wendellhu/redi';
16
+ import { ILogService } from '../services/log/log.service';
17
17
  import type { Nullable } from '../shared';
18
- import { GenName } from '../shared';
19
18
  import { Disposable } from '../shared/lifecycle';
20
19
  import type { IGridRange, IRangeType, IWorkbookData, IWorksheetData } from '../types/interfaces';
21
20
  import { Styles } from './styles';
@@ -25,12 +24,13 @@ export declare function getWorksheetUID(workbook: Workbook, worksheet: Worksheet
25
24
  * Access and create Univer Sheets files
26
25
  */
27
26
  export declare class Workbook extends Disposable {
28
- private readonly _genName;
29
- readonly _injector: Injector;
27
+ private readonly _log;
30
28
  private readonly _sheetCreated$;
31
29
  readonly sheetCreated$: import("rxjs").Observable<Worksheet>;
32
30
  private readonly _sheetDisposed$;
33
31
  readonly sheetDisposed$: import("rxjs").Observable<Worksheet>;
32
+ private readonly _activeSheet$;
33
+ readonly activeSheet$: import("rxjs").Observable<Nullable<Worksheet>>;
34
34
  /**
35
35
  * sheets list
36
36
  * @private
@@ -47,7 +47,8 @@ export declare class Workbook extends Disposable {
47
47
  */
48
48
  private _snapshot;
49
49
  private _unitId;
50
- constructor(workbookData: Partial<IWorkbookData> | undefined, _genName: GenName, _injector: Injector);
50
+ private _count;
51
+ constructor(workbookData: Partial<IWorkbookData> | undefined, _log: ILogService);
51
52
  dispose(): void;
52
53
  save(): IWorkbookData;
53
54
  static isIRangeType(range: IRangeType | IRangeType[]): Boolean;
@@ -69,6 +70,7 @@ export declare class Workbook extends Disposable {
69
70
  getIndexBySheetId(sheetId: string): number;
70
71
  getRawActiveSheet(): Nullable<string>;
71
72
  getActiveSheet(): Worksheet;
73
+ __setActiveSheet(worksheet: Worksheet): void;
72
74
  getActiveSheetIndex(): number;
73
75
  getSheetSize(): number;
74
76
  /**
@@ -78,14 +80,12 @@ export declare class Workbook extends Disposable {
78
80
  */
79
81
  flush(): void;
80
82
  getSheets(): Worksheet[];
83
+ getSheetsName(): string[];
81
84
  getSheetIndex(sheet: Worksheet): number;
82
85
  getSheetBySheetName(name: string): Nullable<Worksheet>;
83
86
  getSheetBySheetId(sheetId: string): Nullable<Worksheet>;
84
87
  getSheetByIndex(index: number): Nullable<Worksheet>;
85
88
  getHiddenWorksheets(): string[];
86
- /**
87
- * Creates a builder for a conditional formatting rule.
88
- */
89
89
  /**
90
90
  * transform any range type to range data
91
91
  *
@@ -126,21 +126,17 @@ export declare class Workbook extends Disposable {
126
126
  */
127
127
  transformRangeType(range: IRangeType | IRangeType[]): IGridRange;
128
128
  load(config: IWorkbookData): void;
129
+ checkSheetName(name: string): boolean;
130
+ uniqueSheetName(name?: string): string;
129
131
  /**
130
132
  * Get the range array based on the range string and sheet id
131
133
  *
132
- * @privateRemarks
133
- * zh: 根据范围字符串和sheet id取得范围数组
134
- *
135
134
  * @param txt - range string
136
135
  * @returns
137
- *
138
- * @internal
139
136
  */
140
137
  private _getCellRange;
141
138
  /**
142
139
  * Get Default Sheet
143
- * @private
144
140
  */
145
141
  private _getDefaultWorkSheet;
146
142
  }
@@ -46,7 +46,7 @@ export declare class Worksheet {
46
46
  * Returns WorkSheet Cell Data Matrix
47
47
  * @returns
48
48
  */
49
- getCellMatrix(): ObjectMatrix<ICellData>;
49
+ getCellMatrix(): ObjectMatrix<Nullable<ICellData>>;
50
50
  /**
51
51
  * Returns Row Manager
52
52
  * @returns Row Manager
@@ -39,5 +39,10 @@ export declare enum BorderType {
39
39
  OUTSIDE = "outside",
40
40
  INSIDE = "inside",
41
41
  HORIZONTAL = "horizontal",
42
- VERTICAL = "vertical"
42
+ VERTICAL = "vertical",
43
+ TLBR = "tlbr",
44
+ TLBC_TLMR = "tlbc_tlmr",
45
+ TLBR_TLBC_TLMR = "tlbr_tlbc_tlmr",
46
+ BLTR = "bl_tr",
47
+ MLTR_BCTR = "mltr_bctr"
43
48
  }
@@ -108,9 +108,9 @@ export declare enum FontWeight {
108
108
  BOLD = 1
109
109
  }
110
110
  export declare enum BaselineOffset {
111
- NORMAL = 0,
112
- SUBSCRIPT = 1,
113
- SUPERSCRIPT = 2
111
+ NORMAL = 1,
112
+ SUBSCRIPT = 2,
113
+ SUPERSCRIPT = 3
114
114
  }
115
115
  /**
116
116
  * General Boolean Enum
@@ -56,7 +56,7 @@ export interface IFooters {
56
56
  * Set of lists
57
57
  */
58
58
  export interface ILists {
59
- [listId: string]: IListData;
59
+ [listType: string]: IListData;
60
60
  }
61
61
  /**
62
62
  * Set of Drawings
@@ -136,7 +136,7 @@ export interface IHeaderData {
136
136
  * The properties of a list which describe the look and feel of bullets belonging to paragraphs associated with a list.
137
137
  */
138
138
  export interface IListData {
139
- listId: string;
139
+ listType: string;
140
140
  nestingLevel: INestingLevel[];
141
141
  }
142
142
  /**
@@ -360,6 +360,7 @@ export declare enum ParagraphElementType {
360
360
  * Properties of list
361
361
  */
362
362
  export interface IBullet {
363
+ listType: string;
363
364
  listId: string;
364
365
  nestingLevel: number;
365
366
  textStyle: ITextStyle;
@@ -31,6 +31,18 @@ export declare enum AbsoluteRefType {
31
31
  COLUMN = 2,
32
32
  ALL = 3
33
33
  }
34
+ export interface IRowRange {
35
+ /**
36
+ * The start row (inclusive) of the range
37
+ * startRow
38
+ */
39
+ startRow: number;
40
+ /**
41
+ * The end row (exclusive) of the range
42
+ * endRow
43
+ */
44
+ endRow: number;
45
+ }
34
46
  /**
35
47
  * Range data structure
36
48
  *
@@ -46,22 +58,12 @@ export declare enum AbsoluteRefType {
46
58
  *
47
59
  * means "A1:B2"
48
60
  */
49
- export interface IRange {
50
- /**
51
- * The start row (inclusive) of the range
52
- * startRow
53
- */
54
- startRow: number;
61
+ export interface IRange extends IRowRange {
55
62
  /**
56
63
  * The start column (inclusive) of the range
57
64
  * startColumn
58
65
  */
59
66
  startColumn: number;
60
- /**
61
- * The end row (exclusive) of the range
62
- * endRow
63
- */
64
- endRow: number;
65
67
  /**
66
68
  * The end column (exclusive) of the range
67
69
  * endColumn
@@ -50,12 +50,29 @@ export interface IBorderStyleData {
50
50
  }
51
51
  /**
52
52
  * Style properties of top, bottom, left and right border
53
+ *
54
+ * TLBR = 'tlbr', //START_TOP_LEFT_END_BOTTOM_RIGHT
55
+ * TLBC = 'tlbc', // START_TOP_LEFT_END_BOTTOM_CENTER
56
+
57
+ * TLMR = 'tlmr', // START_TOP_LEFT_END_MIDDLE_RIGHT
58
+
59
+ * BLTR = 'bltr', // START_BOTTOM_LEFT_END_TOP_RIGHT
60
+
61
+ * MLTR = 'mltr', // START_MIDDLE_LEFT_END_TOP_RIGHT
62
+
63
+ * BCTR = 'bctr', // START_BOTTOM_CENTER_END_TOP_RIGHT
53
64
  */
54
65
  export interface IBorderData {
55
66
  t?: Nullable<IBorderStyleData>;
56
67
  r?: Nullable<IBorderStyleData>;
57
68
  b?: Nullable<IBorderStyleData>;
58
69
  l?: Nullable<IBorderStyleData>;
70
+ tl_br?: Nullable<IBorderStyleData>;
71
+ tl_bc?: Nullable<IBorderStyleData>;
72
+ tl_mr?: Nullable<IBorderStyleData>;
73
+ bl_tr?: Nullable<IBorderStyleData>;
74
+ ml_tr?: Nullable<IBorderStyleData>;
75
+ bc_tr?: Nullable<IBorderStyleData>;
59
76
  }
60
77
  export interface ITextRotation {
61
78
  /**
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { ObjectArrayType } from '../../shared/object-array';
17
- import type { ObjectMatrixPrimitiveType } from '../../shared/object-matrix';
16
+ import type { IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType } from '../../shared/object-matrix';
18
17
  import type { IKeyValue } from '../../shared/types';
19
18
  import type { BooleanNumber, SheetTypes } from '../enum';
20
19
  import type { ICellData } from './i-cell-data';
@@ -62,9 +61,9 @@ export interface IWorksheetData {
62
61
  * @deprecated this should be removed
63
62
  */
64
63
  status: BooleanNumber;
65
- cellData: ObjectMatrixPrimitiveType<ICellData>;
66
- rowData: ObjectArrayType<Partial<IRowData>>;
67
- columnData: ObjectArrayType<Partial<IColumnData>>;
64
+ cellData: IObjectMatrixPrimitiveType<ICellData>;
65
+ rowData: IObjectArrayPrimitiveType<Partial<IRowData>>;
66
+ columnData: IObjectArrayPrimitiveType<Partial<IColumnData>>;
68
67
  showGridlines: BooleanNumber;
69
68
  rowHeader: {
70
69
  width: number;