@univerjs/core 0.1.2 → 0.1.4

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 (43) hide show
  1. package/lib/cjs/index.js +8 -5
  2. package/lib/es/index.js +2273 -1732
  3. package/lib/types/basics/univer-slide.d.ts +2 -2
  4. package/lib/types/basics/univer.d.ts +3 -3
  5. package/lib/types/common/__tests__/array.spec.d.ts +16 -0
  6. package/lib/types/common/array.d.ts +8 -0
  7. package/lib/types/common/interceptor.d.ts +1 -1
  8. package/lib/types/docs/data-model/empty-snapshot.d.ts +18 -0
  9. package/lib/types/index.d.ts +11 -2
  10. package/lib/types/services/command/command.service.d.ts +4 -4
  11. package/lib/types/services/context/context.d.ts +2 -1
  12. package/lib/types/services/instance/instance.service.d.ts +21 -21
  13. package/lib/types/services/locale/locale.service.d.ts +4 -2
  14. package/lib/types/services/log/context.d.ts +18 -0
  15. package/lib/types/services/snapshot/__tests__/snapshot-mock.d.ts +37 -0
  16. package/lib/types/services/snapshot/__tests__/snapshot-transform.spec.d.ts +16 -0
  17. package/lib/types/services/snapshot/snapshot-server.service.d.ts +57 -0
  18. package/lib/types/services/snapshot/snapshot-transform.d.ts +43 -0
  19. package/lib/types/services/snapshot/snapshot-utils.d.ts +34 -0
  20. package/lib/types/services/undoredo/undoredo.service.d.ts +20 -7
  21. package/lib/types/shared/__test__/rectangle.spec.d.ts +16 -0
  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/index.d.ts +1 -1
  26. package/lib/types/shared/locale.d.ts +2 -1
  27. package/lib/types/shared/object-matrix.d.ts +3 -0
  28. package/lib/types/shared/rxjs.d.ts +20 -0
  29. package/lib/types/shared/tools.d.ts +1 -1
  30. package/lib/types/sheets/__tests__/create-core-test-bed.d.ts +1 -2
  31. package/lib/types/sheets/row-manager.d.ts +0 -2
  32. package/lib/types/sheets/workbook.d.ts +1 -0
  33. package/lib/types/sheets/worksheet.d.ts +7 -9
  34. package/lib/types/slides/domain/slide-model.d.ts +3 -1
  35. package/lib/types/types/interfaces/i-cell-data.d.ts +6 -0
  36. package/lib/types/types/interfaces/i-column-data.d.ts +2 -2
  37. package/lib/types/types/interfaces/i-document-data.d.ts +3 -1
  38. package/lib/types/types/interfaces/i-range.d.ts +5 -0
  39. package/lib/types/types/interfaces/i-row-data.d.ts +2 -2
  40. package/lib/types/types/interfaces/i-selection-data.d.ts +6 -0
  41. package/lib/types/types/interfaces/i-slide-data.d.ts +2 -1
  42. package/lib/umd/index.js +8 -5
  43. package/package.json +12 -8
@@ -0,0 +1,17 @@
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 declare function b64EncodeUnicode(str: string): string;
17
+ export declare function b64DecodeUnicode(str: string): string;
@@ -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
- interface IRgbColor {
16
+ export interface IRgbColor {
17
17
  b: number;
18
18
  g: number;
19
19
  r: number;
@@ -61,4 +61,6 @@ export declare class ColorKit {
61
61
  isLight(): boolean;
62
62
  private _setNullColor;
63
63
  }
64
+ export declare function isBlackColor(color: string): boolean;
65
+ export declare function isWhiteColor(color: string): boolean;
64
66
  export {};
@@ -19,4 +19,5 @@ interface AnyObject {
19
19
  }
20
20
  export declare function deepCompare(arg1: AnyObject, arg2: AnyObject): boolean;
21
21
  export declare function isSameStyleTextRun(tr1: ITextRun, tr2: ITextRun): boolean;
22
+ export declare function checkForSubstrings(searchString: string, substrings: string[]): boolean;
22
23
  export {};
@@ -16,7 +16,7 @@
16
16
  export * from './array-search';
17
17
  export * from './blob';
18
18
  export * from './color/color';
19
- export { ColorKit, COLORS, RGB_PAREN, RGBA_PAREN } from './color/color-kit';
19
+ export { ColorKit, COLORS, RGB_PAREN, RGBA_PAREN, type IRgbColor } from './color/color-kit';
20
20
  export * from './command-enum';
21
21
  export * from './common';
22
22
  export * from './compare';
@@ -13,8 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ export type LanguageValue = string | string[] | ILanguagePack | ILanguagePack[] | boolean;
16
17
  export interface ILanguagePack {
17
- [key: string]: string | ILanguagePack | ILanguagePack[];
18
+ [key: string]: LanguageValue;
18
19
  }
19
20
  export interface ILocales {
20
21
  [key: string]: ILanguagePack;
@@ -42,6 +42,9 @@ export declare class ObjectMatrix<T> {
42
42
  getMatrix(): IObjectMatrixPrimitiveType<T>;
43
43
  forEach(callback: (row: number, objectArray: IObjectArrayPrimitiveType<T>) => Nullable<boolean>): ObjectMatrix<T>;
44
44
  forRow(callback: (row: number, cols: number[]) => Nullable<boolean>): ObjectMatrix<T>;
45
+ /**
46
+ * Iterate the object matrix with row priority, which means it scan the whole range row by row.
47
+ */
45
48
  forValue(callback: (row: number, col: number, value: T) => Nullable<boolean>): ObjectMatrix<T>;
46
49
  swapRow(src: number, target: number): void;
47
50
  getRow(rowIndex: number): Nullable<IObjectArrayPrimitiveType<T>>;
@@ -0,0 +1,20 @@
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
+ import type { IDisposable } from '@wendellhu/redi';
17
+ import { Observable } from 'rxjs';
18
+ type CallbackFn<T extends readonly unknown[]> = (cb: (...args: T) => void) => IDisposable;
19
+ export declare function fromCallback<T extends readonly unknown[]>(callback: CallbackFn<T>): Observable<T>;
20
+ export {};
@@ -23,7 +23,7 @@ export declare class Tools {
23
23
  static deleteBlank(value?: string): string | undefined;
24
24
  static getSystemType(): string;
25
25
  static getBrowserType(): string;
26
- static generateRandomId(n?: number): string;
26
+ static generateRandomId(n?: number, alphabet?: string): string;
27
27
  static getClassName(instance: object): string;
28
28
  static deepMerge(target: any, ...sources: any[]): any;
29
29
  static numberFixed(value: number, digit: number): number;
@@ -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;
@@ -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>;
@@ -215,3 +207,9 @@ export interface ICell {
215
207
  colSpan?: number;
216
208
  value: ICellData;
217
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): string;
@@ -14,10 +14,12 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { ISlideData, ISlidePage } from '../../types/interfaces';
17
- export declare class Slide {
17
+ export declare class SlideDataModel {
18
18
  private _snapshot;
19
19
  private _unitId;
20
20
  constructor(snapshot: Partial<ISlideData>);
21
+ getContainer(): string | undefined;
22
+ getParentRenderUnitId(): string | undefined;
21
23
  getSnapshot(): ISlideData;
22
24
  getUnitId(): string;
23
25
  getPages(): {
@@ -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
  /**
@@ -35,6 +35,7 @@ export interface IDocumentData extends IReferenceSource, IExtraModelData {
35
35
  name: string;
36
36
  data: string;
37
37
  }>;
38
+ disabled?: boolean;
38
39
  }
39
40
  export interface IReferenceSource {
40
41
  footers?: IFooters;
@@ -296,6 +297,7 @@ export interface IDocumentRenderConfig {
296
297
  isRotateNonEastAsian?: BooleanNumber;
297
298
  background?: IColorStyle;
298
299
  wrapStrategy?: WrapStrategy;
300
+ cellValueType?: CellValueType;
299
301
  }
300
302
  export interface ISectionBreakBase {
301
303
  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 {
@@ -18,12 +18,13 @@ import type { IKeyType, Nullable } from '../../shared/types';
18
18
  import type { LocaleType, ThemeColorType } from '../enum';
19
19
  import type { ShapeType } from '../enum/shape-type';
20
20
  import type { ICustomBlock, IDocumentData, ILists } from './i-document-data';
21
+ import type { IExtraModelData } from './i-extra-model-data';
21
22
  import type { IImageProperties } from './i-image-properties';
22
23
  import type { IPlaceholder } from './i-placeholder';
23
24
  import type { IShapeProperties } from './i-shape-properties';
24
25
  import type { IColorStyle, IStyleBase, IStyleData } from './i-style-data';
25
26
  import type { IWorksheetData } from './i-worksheet-data';
26
- export interface ISlideData extends IReferenceSource {
27
+ export interface ISlideData extends IReferenceSource, IExtraModelData {
27
28
  id: string;
28
29
  locale?: LocaleType;
29
30
  title: string;