@univerjs/core 0.1.1 → 0.1.3

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 (44) hide show
  1. package/README.md +22 -2
  2. package/lib/cjs/index.js +8 -6
  3. package/lib/es/index.js +2262 -1685
  4. package/lib/types/common/__tests__/array.spec.d.ts +16 -0
  5. package/lib/types/common/array.d.ts +8 -0
  6. package/lib/types/common/interceptor.d.ts +1 -1
  7. package/lib/types/docs/data-model/__tests__/replacement.spec.d.ts +16 -0
  8. package/lib/types/docs/data-model/replacement.d.ts +17 -0
  9. package/lib/types/docs/data-model/text-x/text-x.d.ts +3 -3
  10. package/lib/types/index.d.ts +14 -1
  11. package/lib/types/services/command/command.service.d.ts +4 -4
  12. package/lib/types/services/context/context.d.ts +1 -0
  13. package/lib/types/services/instance/instance.service.d.ts +1 -1
  14. package/lib/types/services/locale/locale.service.d.ts +4 -2
  15. package/lib/types/services/log/context.d.ts +18 -0
  16. package/lib/types/services/snapshot/__tests__/snapshot-mock.d.ts +37 -0
  17. package/lib/types/services/snapshot/__tests__/snapshot-transform.spec.d.ts +16 -0
  18. package/lib/types/services/snapshot/snapshot-server.service.d.ts +57 -0
  19. package/lib/types/services/snapshot/snapshot-transform.d.ts +43 -0
  20. package/lib/types/services/snapshot/snapshot-utils.d.ts +34 -0
  21. package/lib/types/services/undoredo/undoredo.service.d.ts +20 -7
  22. package/lib/types/shared/coder.d.ts +17 -0
  23. package/lib/types/shared/color/color-kit.d.ts +3 -1
  24. package/lib/types/shared/compare.d.ts +1 -0
  25. package/lib/types/shared/debounce.d.ts +18 -0
  26. package/lib/types/shared/generate.d.ts +1 -1
  27. package/lib/types/shared/index.d.ts +2 -1
  28. package/lib/types/shared/locale.d.ts +2 -1
  29. package/lib/types/shared/object-matrix.d.ts +3 -0
  30. package/lib/types/shared/rxjs.d.ts +20 -0
  31. package/lib/types/shared/tools.d.ts +1 -1
  32. package/lib/types/sheets/__tests__/create-core-test-bed.d.ts +1 -2
  33. package/lib/types/sheets/__tests__/worksheet.spec.d.ts +16 -0
  34. package/lib/types/sheets/row-manager.d.ts +0 -2
  35. package/lib/types/sheets/workbook.d.ts +1 -0
  36. package/lib/types/sheets/worksheet.d.ts +29 -9
  37. package/lib/types/types/interfaces/i-cell-data.d.ts +6 -0
  38. package/lib/types/types/interfaces/i-column-data.d.ts +2 -2
  39. package/lib/types/types/interfaces/i-document-data.d.ts +3 -2
  40. package/lib/types/types/interfaces/i-range.d.ts +5 -0
  41. package/lib/types/types/interfaces/i-row-data.d.ts +2 -2
  42. package/lib/types/types/interfaces/i-selection-data.d.ts +6 -0
  43. package/lib/umd/index.js +8 -6
  44. package/package.json +8 -6
@@ -13,10 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Dependency } from '@wendellhu/redi';
17
16
  import { Univer } from '../../basics/univer';
18
17
  import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
19
- export declare function createCoreTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
18
+ export declare function createCoreTestBed(workbookConfig?: IWorkbookData): {
20
19
  univer: Univer;
21
20
  get: {
22
21
  <T>(id: import("@wendellhu/redi").DependencyIdentifier<T>, lookUp?: import("@wendellhu/redi").LookUp | undefined): T;
@@ -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 {};
@@ -18,8 +18,6 @@ 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.
21
- *
22
- * @deprecated This class is not necessary. It increases the complexity of the code and does not bring any benefits.
23
21
  */
24
22
  export declare class RowManager {
25
23
  private readonly _config;
@@ -66,6 +66,7 @@ export declare class Workbook extends Disposable {
66
66
  */
67
67
  addWorksheet(id: string, index: number, worksheetSnapshot: Partial<IWorksheetData>): boolean;
68
68
  getParentRenderUnitId(): string | undefined;
69
+ getSheetOrders(): Readonly<string[]>;
69
70
  getWorksheets(): Map<string, Worksheet>;
70
71
  getActiveSpreadsheet(): Workbook;
71
72
  getStyles(): Styles;
@@ -23,11 +23,10 @@ import { RowManager } from './row-manager';
23
23
  import type { Styles } from './styles';
24
24
  import { SheetViewModel } from './view-model';
25
25
  /**
26
- * Worksheet instance represents a single sheet in a workbook.
26
+ * The model of a Worksheet.
27
27
  */
28
28
  export declare class Worksheet {
29
29
  private readonly _styles;
30
- protected _initialized: boolean;
31
30
  protected _sheetId: string;
32
31
  protected _snapshot: IWorksheetData;
33
32
  protected _cellData: ObjectMatrix<ICellData>;
@@ -83,13 +82,6 @@ export declare class Worksheet {
83
82
  */
84
83
  clone(): Worksheet;
85
84
  getMergeData(): IRange[];
86
- /**
87
- * @deprecated use `getMergedCell` instead
88
- * @param row
89
- * @param col
90
- * @returns
91
- */
92
- getMergedCells(row: number, col: number): Nullable<IRange[]>;
93
85
  getMergedCell(row: number, col: number): Nullable<IRange>;
94
86
  getCell(row: number, col: number): Nullable<ICellDataForSheetInterceptor>;
95
87
  getCellRaw(row: number, col: number): Nullable<ICellData>;
@@ -192,4 +184,32 @@ export declare class Worksheet {
192
184
  */
193
185
  getLastColumnWithContent(): number;
194
186
  cellHasValue(value: ICellData): boolean;
187
+ /**
188
+ * Iterate a range row by row.
189
+ *
190
+ * Performance intensive.
191
+ */
192
+ iterateByRow(range: IRange): Iterator<Readonly<ICell>, Readonly<ICell>>;
193
+ /**
194
+ * Iterate a range column by column. This is pretty similar to `iterateByRow` but with different order.
195
+ *
196
+ * Performance intensive.
197
+ */
198
+ iterateByColumn(range: IRange): Iterator<Readonly<ICell>, Readonly<ICell>>;
195
199
  }
200
+ /**
201
+ * A cell info including its span (if it is the top-left cell of a merged cell).
202
+ */
203
+ export interface ICell {
204
+ row: number;
205
+ col: number;
206
+ rowSpan?: number;
207
+ colSpan?: number;
208
+ value: ICellData;
209
+ }
210
+ /**
211
+ * Get pure text in a cell.
212
+ * @param cell
213
+ * @returns pure text in this cell
214
+ */
215
+ export declare function extractPureTextFromCell(cell: ICellData): Nullable<string>;
@@ -37,7 +37,13 @@ export interface ICellData {
37
37
  */
38
38
  v?: Nullable<CellValue>;
39
39
  t?: Nullable<CellValueType>;
40
+ /**
41
+ * Raw formula string. For example `=SUM(A1:B4)`.
42
+ */
40
43
  f?: Nullable<string>;
44
+ /**
45
+ * Id of the formula.
46
+ */
41
47
  si?: Nullable<string>;
42
48
  }
43
49
  export interface ICellDataForSheetInterceptor extends ICellData {
@@ -21,9 +21,9 @@ export interface IColumnData {
21
21
  /**
22
22
  * width
23
23
  */
24
- w: number;
24
+ w?: number;
25
25
  /**
26
26
  * hidden
27
27
  */
28
- hd: BooleanNumber;
28
+ hd?: BooleanNumber;
29
29
  }
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { ISize } from '../../services/floating-object/floating-object-interfaces';
17
- import type { BooleanNumber, HorizontalAlign, LocaleType, TextDirection, VerticalAlign, WrapStrategy } from '../enum';
17
+ import type { BooleanNumber, CellValueType, HorizontalAlign, LocaleType, TextDirection, VerticalAlign, WrapStrategy } from '../enum';
18
18
  import type { IExtraModelData } from './i-extra-model-data';
19
19
  import type { IColorStyle, IStyleBase } from './i-style-data';
20
20
  /**
@@ -77,7 +77,7 @@ export interface IDocStyles {
77
77
  }
78
78
  /**
79
79
  * Properties of document body
80
- * 三种更新类型,范围叠加、范围互斥、占位符
80
+ * Contain three update types: range overlay, range mutual exclusion, and placeholder
81
81
  * \v COLUMN_BREAK
82
82
  * \f PAGE_BREAK
83
83
  * \0 DOCS_END
@@ -296,6 +296,7 @@ export interface IDocumentRenderConfig {
296
296
  isRotateNonEastAsian?: BooleanNumber;
297
297
  background?: IColorStyle;
298
298
  wrapStrategy?: WrapStrategy;
299
+ cellValueType?: CellValueType;
299
300
  }
300
301
  export interface ISectionBreakBase {
301
302
  columnProperties?: ISectionColumnProperties[];
@@ -86,6 +86,11 @@ export interface IGridRange {
86
86
  sheetId: string;
87
87
  range: IRange;
88
88
  }
89
+ export interface IUnitRangeName {
90
+ unitId: string;
91
+ sheetName: string;
92
+ range: IRange;
93
+ }
89
94
  /**
90
95
  * Range data of Unit
91
96
  */
@@ -21,7 +21,7 @@ export interface IRowData {
21
21
  /**
22
22
  * height in pixel
23
23
  */
24
- h: number;
24
+ h?: number;
25
25
  /**
26
26
  * is current row self-adaptive to its content, use `ah` to set row height when true, else use `h`.
27
27
  */
@@ -33,5 +33,5 @@ export interface IRowData {
33
33
  /**
34
34
  * hidden
35
35
  */
36
- hd: BooleanNumber;
36
+ hd?: BooleanNumber;
37
37
  }
@@ -38,7 +38,13 @@ export interface ISelectionCellWithCoord extends IPosition, ISingleCell {
38
38
  mergeInfo: IRangeWithCoord;
39
39
  }
40
40
  export interface ISelection {
41
+ /**
42
+ * Sheet selection range.
43
+ */
41
44
  range: IRange;
45
+ /**
46
+ * The highlighted cell in the selection range. If there are several selections, only one selection would have a primary cell.
47
+ */
42
48
  primary: Nullable<ISelectionCell>;
43
49
  }
44
50
  export interface ISelectionWithCoord {