@univerjs/core 0.2.15 → 0.3.0-alpha.1

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.
@@ -1,9 +1,16 @@
1
1
  import { Nullable } from '../shared/types';
2
2
  export type InterceptorHandler<M = unknown, C = unknown> = (value: Nullable<M>, context: C, next: (value: Nullable<M>) => Nullable<M>) => Nullable<M>;
3
+ export declare enum InterceptorEffectEnum {
4
+ Style = 1,// 1<< 0
5
+ Value = 2
6
+ }
3
7
  export interface IInterceptor<M, C> {
4
8
  priority?: number;
5
9
  handler: InterceptorHandler<M, C>;
6
10
  }
11
+ export interface ICellInterceptor<M, C> extends IInterceptor<M, C> {
12
+ effect?: InterceptorEffectEnum;
13
+ }
7
14
  export declare function createInterceptorKey<T, C>(key: string): IInterceptor<T, C>;
8
15
  export type IComposeInterceptors<T = any, C = any> = (interceptors: Array<IInterceptor<T, C>>) => (initValue: Nullable<T>, initContext: C) => Nullable<T>;
9
16
  /**
@@ -15,5 +15,5 @@
15
15
  */
16
16
  export * from './document-data-model';
17
17
  export * from './preset-list-type';
18
- export * from './types';
19
18
  export * from './text-x/build-utils';
19
+ export * from './types';
@@ -1,8 +1,8 @@
1
- import { DeleteDirection } from '../../../../types/enum';
2
1
  import { Nullable } from '../../../../shared';
3
2
  import { ITextRange } from '../../../../sheets/typedef';
4
3
  import { IDocumentBody } from '../../../../types/interfaces';
5
4
  import { IDeleteAction, IRetainAction } from '../action-types';
5
+ import { DeleteDirection } from '../../../../types/enum';
6
6
  export declare function makeSelection(startOffset: number, endOffset?: number): ITextRange;
7
7
  export declare function normalizeSelection(selection: ITextRange): ITextRange;
8
8
  export declare function getSelectionWithSymbolMax(selection: ITextRange, body: IDocumentBody): {
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ export { debounce, get, merge, mergeWith, set } from 'lodash-es';
16
17
  export { dedupe, groupBy, makeArray, remove, rotate } from './common/array';
17
18
  export { isBooleanString } from './common/boolean';
18
19
  export { createInternalEditorID, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, isInternalEditorID, } from './common/const';
@@ -20,8 +21,8 @@ export * from './common/di';
20
21
  export { shallowEqual } from './common/equal';
21
22
  export { CustomCommandExecutionError } from './common/error';
22
23
  export { throttle } from './common/function';
23
- export type { IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
24
- export { composeInterceptors, createInterceptorKey, InterceptorManager } from './common/interceptor';
24
+ export type { ICellInterceptor, IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
25
+ export { composeInterceptors, createInterceptorKey, InterceptorEffectEnum, InterceptorManager } from './common/interceptor';
25
26
  export type { Serializable } from './common/json';
26
27
  export { MemoryCursor } from './common/memory-cursor';
27
28
  export { mixinClass } from './common/mixin';
@@ -73,7 +74,7 @@ export { DependentOn, PluginService } from './services/plugin/plugin.service';
73
74
  export { type DependencyOverride, mergeOverrideWithDependencies } from './services/plugin/plugin-override';
74
75
  export { IResourceLoaderService } from './services/resource-loader/type';
75
76
  export { ResourceManagerService } from './services/resource-manager/resource-manager.service';
76
- export type { IResourceHook } from './services/resource-manager/type';
77
+ export type { IResourceHook, IResources } from './services/resource-manager/type';
77
78
  export { IResourceManagerService } from './services/resource-manager/type';
78
79
  export { type IStyleSheet, ThemeService } from './services/theme/theme.service';
79
80
  export { type IUndoRedoCommandInfos, type IUndoRedoCommandInfosByInterceptor, type IUndoRedoItem, IUndoRedoService, type IUndoRedoStatus, LocalUndoRedoService, RedoCommand, RedoCommandId, UndoCommand, UndoCommandId, } from './services/undoredo/undoredo.service';
@@ -1,7 +1,7 @@
1
1
  import { Subject } from 'rxjs';
2
2
  import { Disposable } from '../../shared/lifecycle';
3
- import { ILanguagePack, ILocales, LanguageValue } from '../../shared/locale';
4
3
  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
  */
@@ -8,6 +8,6 @@ export declare class ResourceLoaderService extends Disposable implements IResour
8
8
  constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService);
9
9
  private _init;
10
10
  saveUnit<T = object>(unitId: string): ({
11
- resources: import('../resource-manager/type').IResources;
11
+ resources: import('../..').IResources;
12
12
  } & T) | null;
13
13
  }
@@ -13,7 +13,7 @@ export interface IResourceHook<T = any> {
13
13
  businesses: UniverInstanceType[];
14
14
  onLoad: (unitID: string, resource: T) => void;
15
15
  onUnLoad: (unitID: string) => void;
16
- toJson: (unitID: string) => string;
16
+ toJson: (unitID: string, model?: T) => string;
17
17
  parseJson: (bytes: string) => T;
18
18
  }
19
19
  export interface IResourceManagerService {
@@ -15,4 +15,11 @@
15
15
  */
16
16
  export declare function binarySearchArray(arr: number[], pos: number): number;
17
17
  export declare function orderSearchArray(arr: number[], pos: number): number;
18
+ /**
19
+ * return the first index which arr[index] > num
20
+ * ex: searchArray([1, 3, 5, 7, 9], 7) = 4
21
+ * @param arr
22
+ * @param num
23
+ * @returns {number} index
24
+ */
18
25
  export declare function searchArray(arr: number[], num: number): number;
@@ -23,7 +23,6 @@ export { ColorKit, COLORS, type IRgbColor, RGB_PAREN, RGBA_PAREN } from './color
23
23
  export * from './command-enum';
24
24
  export * from './common';
25
25
  export * from './compare';
26
- export * from './debounce';
27
26
  export * from './doc-tool';
28
27
  export * from './generate';
29
28
  export * from './hash-algorithm';
@@ -33,7 +32,7 @@ export { LRUHelper, LRUMap } from './lru/lru-map';
33
32
  export { numfmt } from './numfmt';
34
33
  export * from './object-matrix';
35
34
  export { queryObjectMatrix } from './object-matrix-query';
36
- export { moveRangeByOffset } from './range';
35
+ export { moveRangeByOffset, splitIntoGrid } from './range';
37
36
  export * from './rectangle';
38
37
  export { RefAlias } from './ref-alias';
39
38
  export * from './row-col-iter';
@@ -1,4 +1,7 @@
1
1
  import { ObjectMatrix } from './object-matrix';
2
2
  import { IRange } from '../sheets/typedef';
3
+ /**
4
+ * @deprecated this function could cause memory out of use in large range.
5
+ */
3
6
  export declare function queryObjectMatrix<T>(matrix: ObjectMatrix<T>, match: (value: T) => boolean): IRange[];
4
7
  export declare function multiSubtractMultiRanges(ranges1: IRange[], ranges2: IRange[]): IRange[];
@@ -36,7 +36,7 @@ export declare class ObjectMatrix<T> {
36
36
  getRowOrCreate(rowIndex: number): IObjectArrayPrimitiveType<T>;
37
37
  reset(): void;
38
38
  hasValue(): boolean;
39
- getValue(row: number, column: number): T;
39
+ getValue(row: number, column: number): Nullable<T>;
40
40
  setValue(row: number, column: number, value: T): void;
41
41
  /**
42
42
  * !!
@@ -6,6 +6,14 @@ import { Nullable } from './types';
6
6
  export declare class Rectangle {
7
7
  static clone(src: IRange): IRange;
8
8
  static equals(src: IRange, target: IRange): boolean;
9
+ /**
10
+ * Check intersects of normal range(RANGE_TYPE.NORMAL)
11
+ * For other types of ranges, please consider using the intersects method.
12
+ * @param rangeA
13
+ * @param rangeB
14
+ * @returns boolean
15
+ */
16
+ static simpleRangesIntersect(rangeA: IRange, rangeB: IRange): boolean;
9
17
  static intersects(src: IRange, target: IRange): boolean;
10
18
  static getIntersects(src: IRange, target: IRange): Nullable<IRange>;
11
19
  static contains(src: IRange, target: IRange): boolean;
@@ -17,6 +25,12 @@ export declare class Rectangle {
17
25
  static moveHorizontal: (range: IRange, step?: number, length?: number) => IRange;
18
26
  static moveVertical: (range: IRange, step?: number, length?: number) => IRange;
19
27
  static moveOffset: (range: IRange, offsetX: number, offsetY: number) => IRange;
28
+ /**
29
+ * Subtract range2 from range1, the result is is horizontal first then vertical
30
+ * @param {IRange} range1 The source range
31
+ * @param {IRange} range2 The range to be subtracted
32
+ * @returns {IRange[]} Returns the array of ranges, which are the result not intersected with range1
33
+ */
20
34
  static subtract(range1: IRange, range2: IRange): IRange[];
21
35
  /**
22
36
  * Combine smaller rectangles into larger ones
@@ -102,24 +102,7 @@ export declare class Tools {
102
102
  static hasIntersectionBetweenTwoRanges(range1Start: number, range1End: number, range2Start: number, range2End: number): boolean;
103
103
  static isStartValidPosition(name: string): boolean;
104
104
  static isValidParameter(name: string): boolean;
105
- /**
106
- * As lodash set, via a path string to set value to deep property
107
- * set(obj, 'xx.yy', val)
108
- * @param data
109
- * @param propertyPath
110
- * @param value
111
- */
112
- static set(data: Record<string, any>, propertyPath: string, value: any): void;
113
105
  static clamp(value: number, min: number, max: number): number;
114
106
  static now(): number;
115
- /**
116
- * @static
117
- * @param {unknown} object Modify the property while leaving the reference unchanged.
118
- * @param {unknown} source The source being merged in object.
119
- * @param {(value: unknown, originValue: unknown, key: string, object: unknown, source: unknown, stack: string[]) => {}} [customizer]
120
- * @return {*}
121
- * @memberof Tools
122
- */
123
- static mergeWith(object: unknown, source: unknown, customizer?: (value: unknown, originValue: unknown, key: string, object: unknown, source: unknown, stack: string[]) => {}): any;
124
107
  }
125
108
  export declare function generateRandomId(n?: number, alphabet?: string): string;
@@ -1,5 +1,5 @@
1
- import { IObjectMatrixPrimitiveType, Nullable, ObjectMatrix } from '../shared';
2
- import { HorizontalAlign, VerticalAlign, BooleanNumber, FontItalic, FontWeight, WrapStrategy } from '../types/enum';
1
+ import { ObjectMatrix, IObjectMatrixPrimitiveType, Nullable } from '../shared';
2
+ import { BooleanNumber, FontItalic, FontWeight, WrapStrategy, HorizontalAlign, VerticalAlign } from '../types/enum';
3
3
  import { IBorderData, IDocumentBody, IDocumentData, IStyleBase, IStyleData, ITextDecoration, ITextRotation } from '../types/interfaces';
4
4
  import { Styles } from './styles';
5
5
  import { ICellData, IRange } from './typedef';
@@ -1,5 +1,5 @@
1
- import { Disposable } from '../shared/lifecycle';
2
1
  import { IRange } from './typedef';
2
+ import { Disposable } from '../shared/lifecycle';
3
3
  export declare class SpanModel extends Disposable {
4
4
  /**
5
5
  * @property Cache for RANGE_TYPE.NORMAL
@@ -46,6 +46,13 @@ export declare class SpanModel extends Disposable {
46
46
  isRowContainsMergedCell(row: number): boolean;
47
47
  isColumnContainsMergedCell(column: number): boolean;
48
48
  getMergedCellRange(startRow: number, startColumn: number, endRow: number, endColumn: number): IRange[];
49
+ /**
50
+ * @deprecated sigificant performance impact, use _getCellMergeInfo instead.
51
+ * @param startRow
52
+ * @param startColumn
53
+ * @param endRow
54
+ * @param endColumn
55
+ */
49
56
  getMergedCellRangeForSkeleton(startRow: number, startColumn: number, endRow: number, endColumn: number): IRange[];
50
57
  private _getRangeFromCache;
51
58
  private _getSkeletonRangeFromCache;
@@ -1,3 +1,4 @@
1
+ import { InterceptorEffectEnum } from '../common/interceptor';
1
2
  import { Disposable } from '../shared/lifecycle';
2
3
  import { IDisposable } from '../common/di';
3
4
  import { Nullable } from '../shared/types';
@@ -6,7 +7,7 @@ import { ICellData, ICellDataForSheetInterceptor } from './typedef';
6
7
  * @internal
7
8
  */
8
9
  export interface ICellContentInterceptor {
9
- getCell: (row: number, col: number) => Nullable<ICellDataForSheetInterceptor>;
10
+ getCell: (row: number, col: number, effect: InterceptorEffectEnum) => Nullable<ICellDataForSheetInterceptor>;
10
11
  }
11
12
  export interface IRowFilteredInterceptor {
12
13
  }
@@ -37,6 +38,8 @@ export declare class SheetViewModel extends Disposable {
37
38
  constructor(getRawCell: (row: number, col: number) => Nullable<ICellData>);
38
39
  dispose(): void;
39
40
  getCell(row: number, col: number): Nullable<ICellDataForSheetInterceptor>;
41
+ getCellValueOnly(row: number, col: number): Nullable<ICellDataForSheetInterceptor>;
42
+ getCellStyleOnly(row: number, col: number): Nullable<ICellDataForSheetInterceptor>;
40
43
  getRowFiltered(row: number): boolean;
41
44
  registerCellContentInterceptor(interceptor: ICellContentInterceptor): IDisposable;
42
45
  registerRowFilteredInterceptor(interceptor: IRowFilteredInterceptor): IDisposable;
@@ -138,6 +138,20 @@ export declare class Worksheet {
138
138
  * @returns ICellDataForSheetInterceptor
139
139
  */
140
140
  getCell(row: number, col: number): Nullable<ICellDataForSheetInterceptor>;
141
+ /**
142
+ * Get cellData only use effect on value interceptor
143
+ * @param {number} number row The row index of the cell.
144
+ * @param {number} number col The column index of the cell.
145
+ * @returns {Nullable<ICellDataForSheetInterceptor>} The cell data only use effect on value interceptor
146
+ */
147
+ getCellValueOnly(row: number, col: number): Nullable<ICellDataForSheetInterceptor>;
148
+ /**
149
+ * Get cellData only use effect on style interceptor
150
+ * @param {number} row The row index of the cell.
151
+ * @param {number} col The column index of the cell.
152
+ * @returns {Nullable<ICellDataForSheetInterceptor>} The cell data only use effect on style interceptor
153
+ */
154
+ getCellStyleOnly(row: number, col: number): Nullable<ICellDataForSheetInterceptor>;
141
155
  getCellRaw(row: number, col: number): Nullable<ICellData>;
142
156
  getRowFiltered(row: number): boolean;
143
157
  /**
@@ -18,6 +18,7 @@ export * from './border-style-types';
18
18
  export * from './color-type';
19
19
  export * from './common-hide-types';
20
20
  export * from './copy-paste-type';
21
+ export * from './delete-direction';
21
22
  export * from './developer-metadata-visibility';
22
23
  export * from './dimension';
23
24
  export * from './direction';
@@ -25,9 +26,8 @@ export * from './format-type';
25
26
  export * from './interpolation-point-type';
26
27
  export * from './locale-type';
27
28
  export * from './protection-type';
29
+ export * from './prst-geom-type';
28
30
  export * from './relative-date';
29
31
  export * from './sheet-types';
30
32
  export * from './text-style';
31
33
  export * from './theme-color-type';
32
- export * from './prst-geom-type';
33
- export * from './delete-direction';
@@ -111,7 +111,7 @@ export declare enum BaselineOffset {
111
111
  /**
112
112
  * General Boolean Enum
113
113
  */
114
- export declare const enum BooleanNumber {
114
+ export declare enum BooleanNumber {
115
115
  FALSE = 0,
116
116
  TRUE = 1
117
117
  }
@@ -16,8 +16,8 @@
16
16
  export * from './i-document-data';
17
17
  export * from './i-document-data-interceptor';
18
18
  export * from './i-image-properties';
19
+ export * from './i-need-check-disposable';
19
20
  export * from './i-placeholder';
20
21
  export * from './i-shape-properties';
21
22
  export * from './i-slide-data';
22
23
  export * from './i-style-data';
23
- export * from './i-need-check-disposable';
@@ -1,16 +1,16 @@
1
1
  import { Injector } from './common/di';
2
2
  import { DocumentDataModel } from './docs/data-model/document-data-model';
3
- import { LogLevel } from './services/log/log.service';
4
- import { IStyleSheet } from './services/theme/theme.service';
5
3
  import { Workbook } from './sheets/workbook';
6
4
  import { SlideDataModel } from './slides/slide-model';
7
- import { LocaleType } from './types/enum/locale-type';
8
- import { IDocumentData, ISlideData } from './types/interfaces';
9
5
  import { UnitModel, UnitType } from './common/unit';
6
+ import { LogLevel } from './services/log/log.service';
10
7
  import { Plugin, PluginCtor } from './services/plugin/plugin';
11
8
  import { DependencyOverride } from './services/plugin/plugin-override';
9
+ import { IStyleSheet } from './services/theme/theme.service';
12
10
  import { ILocales } from './shared';
13
11
  import { IWorkbookData } from './sheets/typedef';
12
+ import { LocaleType } from './types/enum/locale-type';
13
+ import { IDocumentData, ISlideData } from './types/interfaces';
14
14
  export interface IUniverConfig {
15
15
  theme: IStyleSheet;
16
16
  locale: LocaleType;