@univerjs/core 0.5.1 → 0.5.2

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.
@@ -9,6 +9,11 @@ export interface IInterceptor<M, C> {
9
9
  handler: InterceptorHandler<M, C>;
10
10
  }
11
11
  export interface ICellInterceptor<M, C> extends IInterceptor<M, C> {
12
+ /**
13
+ * The effect of the interceptor handler.
14
+ * If the effect is 'Style', the worksheet@getCellValueOnly will bypass this interceptor.
15
+ * If the effect is 'Value', the worksheet@getStyleOnly will bypass this interceptor.
16
+ */
12
17
  effect?: InterceptorEffectEnum;
13
18
  }
14
19
  export declare function createInterceptorKey<T, C>(key: string): IInterceptor<T, C>;
@@ -0,0 +1,133 @@
1
+ import { Nullable } from '../shared';
2
+ import { Injector } from '@wendellhu/redi';
3
+ import { FBase } from './f-base';
4
+ export interface IFBlobSource {
5
+ /**
6
+ * Return the data inside this object as a blob.
7
+ */
8
+ getBlob(): FBlob;
9
+ /**
10
+ * Return the data inside this object as a blob converted to the specified content type.
11
+ * @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
12
+ */
13
+ getAs(contentType: string): FBlob;
14
+ }
15
+ export declare class FBlob extends FBase {
16
+ private _blob;
17
+ protected readonly _injector: Injector;
18
+ constructor(_blob: Nullable<Blob>, _injector: Injector);
19
+ /**
20
+ * Returns a copy of this blob.
21
+ * @returns a new blob by copying the current blob
22
+ * @example
23
+ * ```ts
24
+ * const blob = UniverApi.newBlob(blob);
25
+ * const newBlob = blob.copyBlob();
26
+ * console.log(newBlob);
27
+ * ```
28
+ */
29
+ copyBlob(): FBlob;
30
+ /**
31
+ * Return the data inside this object as a blob converted to the specified content type.
32
+ * @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
33
+ * @returns a new blob by converting the current blob to the specified content type
34
+ * @example
35
+ * ```ts
36
+ * const blob = UniverApi.newBlob(blob);
37
+ * const newBlob = blob.getBlob();
38
+ * ```
39
+ */
40
+ getAs(contentType: string): FBlob;
41
+ /**
42
+ * get the blob as a string
43
+ * @returns
44
+ * @example
45
+ * ```ts
46
+ * const blob = UniverApi.newBlob(blob);
47
+ * const newBlob = blob.getDataAsString();
48
+ * console.log(newBlob);
49
+ * ```
50
+ */
51
+ getDataAsString(): Promise<string>;
52
+ /**
53
+ * get the blob as a string
54
+ * @param charset the charset
55
+ * @returns the blob content as a string
56
+ * @example
57
+ * ```ts
58
+ * const blob = UniverApi.newBlob(blob);
59
+ * const newBlob = blob.getDataAsString('iso-8859-1');
60
+ * console.log(newBlob);
61
+ * ```
62
+ */
63
+ getDataAsString(charset?: string): Promise<string>;
64
+ /**
65
+ * Gets the data stored in this blob.
66
+ * @returns the blob content as a byte array
67
+ * @example
68
+ * ```ts
69
+ * const blob = UniverApi.newBlob(blob);
70
+ * const newBlob = blob.getBytes();
71
+ * console.log(newBlob);
72
+ * ```
73
+ */
74
+ getBytes(): Promise<Uint8Array>;
75
+ /**
76
+ * Sets the data stored in this blob.
77
+ * @param bytes a byte array
78
+ * @returns the blob object
79
+ * @example
80
+ * ```ts
81
+ * const blob = UniverApi.newBlob();
82
+ * const bytes = new Uint8Array(10);
83
+ * blob.setBytes(bytes);
84
+ * ```
85
+ */
86
+ setBytes(bytes: Uint8Array): FBlob;
87
+ /**
88
+ * Sets the data stored in this blob.
89
+ * @param data blob data string
90
+ * @returns the blob object
91
+ * @example
92
+ * ```ts
93
+ * const blob = UniverApi.newBlob();
94
+ * blob.setDataFromString('Hello, World!');
95
+ * ```
96
+ */
97
+ setDataFromString(data: string): FBlob;
98
+ /**
99
+ * Sets the data stored in this blob.
100
+ * @param data a string
101
+ * @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
102
+ * @returns the blob object
103
+ * @example
104
+ * ```ts
105
+ * const blob = UniverApi.newBlob();
106
+ * blob.setDataFromString('Hello, World!', 'text/plain');
107
+ * ```
108
+ */
109
+ setDataFromString(data: string, contentType?: string): FBlob;
110
+ /**
111
+ * Gets the content type of the data stored in this blob.
112
+ * @returns the content type
113
+ * @example
114
+ * ```ts
115
+ * const blob = UniverApi.newBlob(blob);
116
+ * const newBlob = blob.getContentType();
117
+ * console.log(newBlob);
118
+ * ```
119
+ */
120
+ getContentType(): string | undefined;
121
+ /**
122
+ * Sets the content type of the data stored in this blob.
123
+ * @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
124
+ * @returns the blob object
125
+ * @example
126
+ * ```ts
127
+ * const blob = UniverApi.newBlob(blob);
128
+ * const newBlob = blob.setContentType('text/plain');
129
+ * console.log(newBlob);
130
+ * ```
131
+ */
132
+ setContentType(contentType: string): FBlob;
133
+ }
@@ -4,7 +4,9 @@ import { LifecycleStages } from '../services/lifecycle/lifecycle';
4
4
  import { IUniverInstanceService } from '../services/instance/instance.service';
5
5
  import { Univer } from '../univer';
6
6
  import { FBase } from './f-base';
7
+ import { FBlob } from './f-blob';
7
8
  import { FHooks } from './f-hooks';
9
+ import { FUserManager } from './f-usermanager';
8
10
  export declare class FUniver extends FBase {
9
11
  protected readonly _injector: Injector;
10
12
  protected readonly _commandService: ICommandService;
@@ -80,4 +82,15 @@ export declare class FUniver extends FBase {
80
82
  * @returns {FHooks} FHooks instance
81
83
  */
82
84
  getHooks(): FHooks;
85
+ /**
86
+ * Create a new blob.
87
+ *
88
+ * @returns {FBlob} The new blob instance
89
+ * @example
90
+ * ```ts
91
+ * const blob = UniverApi.newBlob();
92
+ * ```
93
+ */
94
+ newBlob(): FBlob;
95
+ getUserManager(): FUserManager;
83
96
  }
@@ -0,0 +1,14 @@
1
+ import { IUser, UserManagerService } from '../services/user-manager/user-manager.service';
2
+ import { Injector } from '../common/di';
3
+ import { FBase } from './f-base';
4
+ export declare class FUserManager extends FBase {
5
+ protected readonly _injector: Injector;
6
+ private readonly _userManagerService;
7
+ constructor(_injector: Injector, _userManagerService: UserManagerService);
8
+ /**
9
+ * Get current user info
10
+ * @example
11
+ * `univerAPI.getUserManager().getCurrentUser()`
12
+ */
13
+ getCurrentUser(): IUser;
14
+ }
@@ -22,7 +22,7 @@ export * from './common/di';
22
22
  export { shallowEqual } from './common/equal';
23
23
  export { CustomCommandExecutionError } from './common/error';
24
24
  export { throttle } from './common/function';
25
- export type { ICellInterceptor, IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
25
+ export type { IAsyncInterceptor, ICellInterceptor, IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
26
26
  export { AsyncInterceptorManager, composeInterceptors, createAsyncInterceptorKey, createInterceptorKey, InterceptorEffectEnum, InterceptorManager } from './common/interceptor';
27
27
  export type { Serializable } from './common/json';
28
28
  export { MemoryCursor } from './common/memory-cursor';
@@ -30,6 +30,7 @@ export { mixinClass } from './common/mixin';
30
30
  export { FBase } from './facade/f-base';
31
31
  export { FUniver } from './facade/f-univer';
32
32
  export { FHooks } from './facade/f-hooks';
33
+ export { FBlob, type IFBlobSource } from './facade/f-blob';
33
34
  export { isNumeric, isSafeNumeric } from './common/number';
34
35
  export { Registry, RegistryAsMap } from './common/registry';
35
36
  export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
@@ -96,7 +97,7 @@ export { Range } from './sheets/range';
96
97
  export { DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_COUNT_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_HEIGHT_KEY, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY, mergeWorksheetSnapshotWithDefault, } from './sheets/sheet-snapshot-utils';
97
98
  export { Styles } from './sheets/styles';
98
99
  export * from './sheets/typedef';
99
- export { addLinkToDocumentModel, isRangesEqual, isUnitRangesEqual } from './sheets/util';
100
+ export { addLinkToDocumentModel, isNotNullOrUndefined, isRangesEqual, isUnitRangesEqual } from './sheets/util';
100
101
  export { SheetViewModel } from './sheets/view-model';
101
102
  export { createDocumentModelWithStyle } from './sheets/util';
102
103
  export { ImageCacheMap } from './shared/cache/image-cache';
@@ -1,7 +1,7 @@
1
+ import { ILanguagePack, ILocales, LanguageValue } from '../../shared/locale';
1
2
  import { Subject } from 'rxjs';
2
3
  import { Disposable } from '../../shared/lifecycle';
3
4
  import { LocaleType } from '../../types/enum/locale-type';
4
- import { ILanguagePack, ILocales, LanguageValue } from '../../shared/locale';
5
5
  /**
6
6
  * This service provides i18n and timezone / location features to other modules.
7
7
  */
@@ -11,7 +11,9 @@ export declare function toDisposable(v: DisposableLike): IDisposable;
11
11
  export declare function fromObservable(subscription: Subscription): IDisposable;
12
12
  export declare class DisposableCollection implements IDisposable {
13
13
  private readonly _disposables;
14
- add(disposable: DisposableLike): IDisposable;
14
+ add(disposable: DisposableLike): {
15
+ dispose: (notDisposeSelf?: boolean) => void;
16
+ };
15
17
  dispose(): void;
16
18
  }
17
19
  export declare class Disposable implements IDisposable {
@@ -16,6 +16,7 @@ export declare class Tools {
16
16
  */
17
17
  static generateRandomId(n?: number, alphabet?: string): string;
18
18
  static getClassName(instance: object): string;
19
+ /** @deprecated This method is deprecated, please use `import { merge } from '@univerjs/core` instead */
19
20
  static deepMerge(target: any, ...sources: any[]): any;
20
21
  static numberFixed(value: number, digit: number): number;
21
22
  static diffValue(one: any, two: any): boolean;
@@ -101,6 +101,10 @@ export interface IWorksheetData {
101
101
  hidden?: BooleanNumber;
102
102
  };
103
103
  showGridlines: BooleanNumber;
104
+ /**
105
+ * Color of the gridlines.
106
+ */
107
+ gridlinesColor?: string;
104
108
  rightToLeft: BooleanNumber;
105
109
  }
106
110
  export type CustomData = Nullable<Record<string, any>>;
@@ -549,4 +553,14 @@ export interface ITextRangeParam extends ITextRange {
549
553
  * @deprecated please use worksheet.getCellInfoInMergeData instead
550
554
  */
551
555
  export declare function getCellInfoInMergeData(row: number, column: number, mergeData?: IRange[]): ISelectionCell;
556
+ export type ICellDataWithSpanAndDisplay = ICellData & {
557
+ rowSpan?: number;
558
+ colSpan?: number;
559
+ displayV?: string;
560
+ };
561
+ export declare enum CellModeEnum {
562
+ Raw = "raw",
563
+ Intercepted = "intercepted",
564
+ Both = "both"
565
+ }
552
566
  export {};
@@ -36,3 +36,4 @@ export declare function extractOtherStyle(style?: Nullable<IStyleData>): ICellSt
36
36
  */
37
37
  export declare function getFontFormat(format?: Nullable<IStyleData>): IStyleBase;
38
38
  export declare function addLinkToDocumentModel(documentModel: DocumentDataModel, linkUrl: string, linkId: string): void;
39
+ export declare function isNotNullOrUndefined<T>(value: T | null | undefined): value is T;
@@ -1,7 +1,7 @@
1
1
  import { Nullable, ObjectMatrix } from '../shared';
2
2
  import { IPaddingData, IStyleData, ITextRotation } from '../types/interfaces';
3
3
  import { Styles } from './styles';
4
- import { ICellData, ICellDataForSheetInterceptor, IFreeze, IRange, ISelectionCell, IWorksheetData } from './typedef';
4
+ import { ICellData, ICellDataForSheetInterceptor, ICellDataWithSpanAndDisplay, IFreeze, IRange, ISelectionCell, IWorksheetData, CellModeEnum } from './typedef';
5
5
  import { DocumentDataModel } from '../docs';
6
6
  import { BooleanNumber, CellValueType, HorizontalAlign, TextDirection, VerticalAlign, WrapStrategy } from '../types/enum';
7
7
  import { ColumnManager } from './column-manager';
@@ -158,6 +158,8 @@ export declare class Worksheet {
158
158
  getMergeData(): IRange[];
159
159
  /**
160
160
  * Get the merged cell Range of the sheet cell.
161
+ * If (row, col) is not in a merged cell, return null
162
+ *
161
163
  * @param {number} row The row index of test cell
162
164
  * @param {number} col The column index of test cell
163
165
  * @returns {Nullable<IRange>} The merged cell range of the cell, if the cell is not in a merged cell, return null
@@ -232,11 +234,11 @@ export declare class Worksheet {
232
234
  *
233
235
  * Notice that `ICellData` here is not after copying. In another word, the object matrix here should be
234
236
  * considered as a slice of the original worksheet data matrix.
237
+ *
238
+ * Control the v attribute in the return cellData.v through dataMode
235
239
  */
236
- getMatrixWithMergedCells(row: number, col: number, endRow: number, endCol: number, isRaw?: boolean): ObjectMatrix<ICellData & {
237
- rowSpan?: number;
238
- colSpan?: number;
239
- }>;
240
+ getMatrixWithMergedCells(row: number, col: number, endRow: number, endCol: number): ObjectMatrix<ICellDataWithSpanAndDisplay>;
241
+ getMatrixWithMergedCells(row: number, col: number, endRow: number, endCol: number, dataMode: CellModeEnum): ObjectMatrix<ICellDataWithSpanAndDisplay>;
240
242
  getRange(range: IRange): Range;
241
243
  getRange(startRow: number, startColumn: number): Range;
242
244
  getRange(startRow: number, startColumn: number, endRow: number, endColumn: number): Range;
@@ -280,9 +282,14 @@ export declare class Worksheet {
280
282
  isSheetHidden(): BooleanNumber;
281
283
  /**
282
284
  * Returns true if the sheet's gridlines are hidden; otherwise returns false. Gridlines are visible by default.
283
- * @returns Gridlines Hidden Status
285
+ * @returns {boolean} Gridlines Hidden Status.
284
286
  */
285
287
  hasHiddenGridlines(): boolean;
288
+ /**
289
+ * Returns the color of the gridlines, or undefined if the gridlines are not colored.
290
+ * @returns {string | undefined} returns the color of the gridlines, or undefined if the gridlines are default.
291
+ */
292
+ getGridlinesColor(): string | undefined;
286
293
  /**
287
294
  * Gets the sheet tab color, or null if the sheet tab has no color.
288
295
  * @returns the sheet tab color or null
@@ -346,6 +353,7 @@ export declare class Worksheet {
346
353
  * @returns the position of the last column that has content.
347
354
  */
348
355
  getLastColumnWithContent(): number;
356
+ getDataRangeScope(): IRange;
349
357
  cellHasValue(value: ICellData): boolean;
350
358
  /**
351
359
  * Iterate a range row by row.
@@ -1,14 +1,14 @@
1
+ import { IDisposable, Injector } from './common/di';
1
2
  import { UnitModel, UnitType } from './common/unit';
2
3
  import { LogLevel } from './services/log/log.service';
3
4
  import { Plugin, PluginCtor } from './services/plugin/plugin';
4
5
  import { DependencyOverride } from './services/plugin/plugin-override';
5
6
  import { IStyleSheet } from './services/theme/theme.service';
6
- import { ILocales } from './shared';
7
7
  import { IWorkbookData } from './sheets/typedef';
8
8
  import { LocaleType } from './types/enum/locale-type';
9
9
  import { IDocumentData, ISlideData } from './types/interfaces';
10
- import { Injector } from './common/di';
11
10
  import { DocumentDataModel } from './docs/data-model/document-data-model';
11
+ import { ILocales } from './shared';
12
12
  import { Workbook } from './sheets/workbook';
13
13
  import { SlideDataModel } from './slides/slide-model';
14
14
  export interface IUniverConfig {
@@ -18,11 +18,12 @@ export interface IUniverConfig {
18
18
  logLevel: LogLevel;
19
19
  override?: DependencyOverride;
20
20
  }
21
- export declare class Univer {
21
+ export declare class Univer implements IDisposable {
22
22
  private _startedTypes;
23
23
  private _injector;
24
24
  private get _univerInstanceService();
25
25
  private get _pluginService();
26
+ private _disposingCallbacks;
26
27
  /**
27
28
  * Create a Univer instance.
28
29
  * @param config Configuration data for Univer
@@ -30,6 +31,15 @@ export declare class Univer {
30
31
  */
31
32
  constructor(config?: Partial<IUniverConfig>, parentInjector?: Injector);
32
33
  __getInjector(): Injector;
34
+ /**
35
+ * Register a callback function which will be called when this Univer instance is disposing.
36
+ *
37
+ * @ignore
38
+ *
39
+ * @param callback The callback function.
40
+ * @returns To remove this callback function from this Univer instance's on disposing list.
41
+ */
42
+ onDispose(callback: () => void): IDisposable;
33
43
  dispose(): void;
34
44
  setLocale(locale: LocaleType): void;
35
45
  createUnit<T, U extends UnitModel>(type: UnitType, data: Partial<T>): U;