@univerjs/core 0.4.2 → 0.5.0-alpha.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.
- package/lib/cjs/index.js +9 -9
- package/lib/es/index.js +10808 -10337
- package/lib/types/common/__tests__/interceptor.spec.d.ts +16 -0
- package/lib/types/common/interceptor.d.ts +17 -0
- package/lib/types/docs/data-model/replacement.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/__tests__/transform-custom-decorations.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/__tests__/transform-custom-range.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/__tests__/transform-paragraph.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/__tests__/transform-textrun.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +6 -1
- package/lib/types/docs/data-model/text-x/apply-utils/update-apply.d.ts +2 -2
- package/lib/types/docs/data-model/text-x/build-utils/__test__/textX.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/build-utils/custom-range.d.ts +15 -5
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +4 -8
- package/lib/types/docs/data-model/text-x/build-utils/selection.d.ts +0 -25
- package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +7 -8
- package/lib/types/docs/data-model/text-x/text-x.d.ts +4 -0
- package/lib/types/docs/data-model/text-x/transform-utils.d.ts +8 -2
- package/lib/types/docs/data-model/text-x/utils.d.ts +6 -2
- package/lib/types/docs/data-model/types.d.ts +6 -0
- package/lib/types/docs/data-model/utils.d.ts +20 -0
- package/lib/types/facade/f-base.d.ts +26 -0
- package/lib/types/facade/f-hooks.d.ts +57 -0
- package/lib/types/facade/f-univer.d.ts +76 -0
- package/lib/types/index.d.ts +7 -2
- package/lib/types/services/context/context.d.ts +2 -0
- package/lib/types/services/resource-loader/resource-loader.service.d.ts +3 -3
- package/lib/types/shared/__tests__/array-search.spec.d.ts +16 -0
- package/lib/types/shared/array-search.d.ts +30 -5
- package/lib/types/shared/command-enum.d.ts +1 -2
- package/lib/types/shared/r-tree.d.ts +4 -3
- package/lib/types/shared/ref-alias.d.ts +1 -1
- package/lib/types/shared/rxjs.d.ts +1 -0
- package/lib/types/shared/text-diff.d.ts +16 -0
- package/lib/types/shared/tools.d.ts +1 -0
- package/lib/types/sheets/util.d.ts +35 -0
- package/lib/types/sheets/worksheet.d.ts +38 -2
- package/lib/types/types/const/const.d.ts +1 -0
- package/lib/types/types/interfaces/i-document-data.d.ts +5 -2
- package/lib/umd/index.js +9 -9
- package/package.json +11 -10
|
@@ -13,13 +13,38 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* Return the index of the first value in an ascending array that is greater than the target value. If there is no value greater than the target, return -1.
|
|
18
|
+
*
|
|
19
|
+
* Alternatively, you can consider inserting a number to ensure the array remains sorted, and return the position for insertion. If the target is the same as the maximum value, return arr.length -1
|
|
20
|
+
* @param arr
|
|
21
|
+
* @param target
|
|
22
|
+
*/
|
|
23
|
+
export declare function searchInOrderedArray(arr: number[], target: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Return the index of the first value in an ascending array that is greater than the target value. If there is no value greater than the target, return last index.
|
|
26
|
+
*
|
|
27
|
+
* @param arr
|
|
28
|
+
* @param pos
|
|
29
|
+
*/
|
|
16
30
|
export declare function binarySearchArray(arr: number[], pos: number): number;
|
|
17
|
-
export declare function orderSearchArray(arr: number[], pos: number): number;
|
|
18
31
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
32
|
+
* Return the index of the last index in an ascending array which value is just greater than the target. If there is no value greater than the target, return arr.length - 1.
|
|
33
|
+
*
|
|
34
|
+
* Alternatively, you can consider inserting a number to ensure the array remains sorted, and return the position for insertion.
|
|
35
|
+
*
|
|
21
36
|
* @param arr
|
|
22
|
-
* @param
|
|
37
|
+
* @param target
|
|
38
|
+
*/
|
|
39
|
+
export declare function binSearchFirstGreaterThanTarget(arr: number[], target: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Find value in the data that is just greater than the target; if there are equal values greater than the target, select the last one.
|
|
42
|
+
* If firstMatch is true, then return the index of the first number greater than the target.
|
|
43
|
+
* see #univer/pull/3903
|
|
44
|
+
*
|
|
45
|
+
* @param arr ascending array
|
|
46
|
+
* @param target value wants to find
|
|
47
|
+
* @param firstMatch if true, return the first match when value > target in the array, otherwise return the last value > target. if not match,
|
|
23
48
|
* @returns {number} index
|
|
24
49
|
*/
|
|
25
|
-
export declare function searchArray(arr: number[],
|
|
50
|
+
export declare function searchArray(arr: number[], target: number, firstMatch?: boolean): number;
|
|
@@ -15,6 +15,5 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export declare enum UpdateDocsAttributeType {
|
|
17
17
|
COVER = 0,// Default, if not present, add; if present, overwrite, while retaining the original properties.
|
|
18
|
-
REPLACE = 1
|
|
19
|
-
INTERSECTION = 2
|
|
18
|
+
REPLACE = 1
|
|
20
19
|
}
|
|
@@ -17,12 +17,12 @@ export declare class RTree {
|
|
|
17
17
|
private _tree;
|
|
18
18
|
private _oneCellCache;
|
|
19
19
|
private _kdTree;
|
|
20
|
-
private _kdTreeSearchState;
|
|
21
20
|
constructor(_enableOneCellCache?: boolean);
|
|
22
21
|
dispose(): void;
|
|
23
22
|
getTree(unitId: string, subUnitId: string): RBush<IRBushItem>;
|
|
24
23
|
private _getOneCellCache;
|
|
25
24
|
private _removeOneCellCache;
|
|
25
|
+
private _removeCellCacheByRange;
|
|
26
26
|
private _insertOneCellCache;
|
|
27
27
|
private _getRdTreeItems;
|
|
28
28
|
private _searchByOneCellCache;
|
|
@@ -34,9 +34,10 @@ export declare class RTree {
|
|
|
34
34
|
closeKdTree(): void;
|
|
35
35
|
insert(item: IRTreeItem): void;
|
|
36
36
|
bulkInsert(items: IRTreeItem[]): void;
|
|
37
|
-
|
|
38
|
-
bulkSearch(searchList: IUnitRange[]): Set<StringOrNumber>;
|
|
37
|
+
searchGenerator(search: IUnitRange): IterableIterator<StringOrNumber>;
|
|
38
|
+
bulkSearch(searchList: IUnitRange[], exceptTreeIds?: Set<number>): Set<StringOrNumber>;
|
|
39
39
|
removeById(unitId: string, subUnitId?: string): void;
|
|
40
|
+
private _removeRTreeItem;
|
|
40
41
|
remove(search: IRTreeItem): void;
|
|
41
42
|
bulkRemove(searchList: IRTreeItem[]): void;
|
|
42
43
|
clear(): void;
|
|
@@ -30,7 +30,7 @@ export declare class RefAlias<T extends Record<string, unknown>, K extends keyof
|
|
|
30
30
|
hasValue(key: string): boolean;
|
|
31
31
|
addValue(item: T): void;
|
|
32
32
|
setValue(key: string, attr: keyof T, value: unknown): void;
|
|
33
|
-
deleteValue(key: string): void;
|
|
33
|
+
deleteValue(key: string, keyGroup?: K[]): void;
|
|
34
34
|
getValues(): T[];
|
|
35
35
|
getKeyMap(key: K): unknown[];
|
|
36
36
|
clear(): void;
|
|
@@ -16,4 +16,5 @@ export declare function fromCallback<T extends readonly unknown[]>(callback: Cal
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function takeAfter<T>(callback: (value: T) => boolean): (source: Observable<T>) => Observable<T>;
|
|
18
18
|
export declare function bufferDebounceTime<T>(time?: number): OperatorFunction<T, T[]>;
|
|
19
|
+
export declare function afterTime(ms: number): Observable<void>;
|
|
19
20
|
export {};
|
|
@@ -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 { default as textDiff } from 'fast-diff';
|
|
@@ -113,3 +113,4 @@ export declare function generateRandomId(n?: number, alphabet?: string): string;
|
|
|
113
113
|
* @returns { Nullable<IStyleData>[]} Returns the composed style
|
|
114
114
|
*/
|
|
115
115
|
export declare function composeStyles(...styles: Nullable<IStyleData>[]): IStyleData;
|
|
116
|
+
export declare const isNodeEnv: () => boolean;
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
import { Nullable } from '../shared';
|
|
1
2
|
import { IRange, IUnitRange } from './typedef';
|
|
3
|
+
import { DocumentDataModel } from '../docs';
|
|
4
|
+
import { CellValueType, HorizontalAlign, TextDirection, VerticalAlign, WrapStrategy } from '../types/enum';
|
|
5
|
+
import { IPaddingData, IStyleBase, IStyleData, ITextRotation, ITextStyle } from '../types/interfaces';
|
|
2
6
|
export declare const isRangesEqual: (oldRanges: IRange[], ranges: IRange[]) => boolean;
|
|
3
7
|
export declare const isUnitRangesEqual: (oldRanges: IUnitRange[], ranges: IUnitRange[]) => boolean;
|
|
8
|
+
export declare const DEFAULT_PADDING_DATA: {
|
|
9
|
+
t: number;
|
|
10
|
+
b: number;
|
|
11
|
+
l: number;
|
|
12
|
+
r: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const getDefaultBaselineOffset: (fontSize: number) => {
|
|
15
|
+
sbr: number;
|
|
16
|
+
sbo: number;
|
|
17
|
+
spr: number;
|
|
18
|
+
spo: number;
|
|
19
|
+
};
|
|
20
|
+
export interface ICellStyle {
|
|
21
|
+
textRotation?: ITextRotation;
|
|
22
|
+
textDirection?: Nullable<TextDirection>;
|
|
23
|
+
horizontalAlign?: HorizontalAlign;
|
|
24
|
+
verticalAlign?: VerticalAlign;
|
|
25
|
+
wrapStrategy?: WrapStrategy;
|
|
26
|
+
paddingData?: IPaddingData;
|
|
27
|
+
cellValueType?: CellValueType;
|
|
28
|
+
}
|
|
29
|
+
export declare const VERTICAL_ROTATE_ANGLE = 90;
|
|
30
|
+
export declare function createDocumentModelWithStyle(content: string, textStyle: ITextStyle, config?: ICellStyle): DocumentDataModel;
|
|
31
|
+
export declare function extractOtherStyle(style?: Nullable<IStyleData>): ICellStyle;
|
|
32
|
+
/**
|
|
33
|
+
* Pick font style from cell style.
|
|
34
|
+
* @param format
|
|
35
|
+
* @returns {IStyleBase} style
|
|
36
|
+
*/
|
|
37
|
+
export declare function getFontFormat(format?: Nullable<IStyleData>): IStyleBase;
|
|
38
|
+
export declare function addLinkToDocumentModel(documentModel: DocumentDataModel, linkUrl: string, linkId: string): void;
|
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
import { Nullable, ObjectMatrix } from '../shared';
|
|
2
|
-
import { IStyleData } from '../types/interfaces';
|
|
2
|
+
import { IPaddingData, IStyleData, ITextRotation } from '../types/interfaces';
|
|
3
3
|
import { Styles } from './styles';
|
|
4
4
|
import { ICellData, ICellDataForSheetInterceptor, IFreeze, IRange, ISelectionCell, IWorksheetData } from './typedef';
|
|
5
|
-
import {
|
|
5
|
+
import { DocumentDataModel } from '../docs';
|
|
6
|
+
import { BooleanNumber, CellValueType, HorizontalAlign, TextDirection, VerticalAlign, WrapStrategy } from '../types/enum';
|
|
6
7
|
import { ColumnManager } from './column-manager';
|
|
7
8
|
import { Range } from './range';
|
|
8
9
|
import { RowManager } from './row-manager';
|
|
9
10
|
import { SpanModel } from './span-model';
|
|
10
11
|
import { SheetViewModel } from './view-model';
|
|
12
|
+
export interface IDocumentLayoutObject {
|
|
13
|
+
documentModel: Nullable<DocumentDataModel>;
|
|
14
|
+
fontString: string;
|
|
15
|
+
textRotation: ITextRotation;
|
|
16
|
+
wrapStrategy: WrapStrategy;
|
|
17
|
+
verticalAlign: VerticalAlign;
|
|
18
|
+
horizontalAlign: HorizontalAlign;
|
|
19
|
+
paddingData: IPaddingData;
|
|
20
|
+
fill?: Nullable<string>;
|
|
21
|
+
}
|
|
22
|
+
export interface ICellOtherConfig {
|
|
23
|
+
textRotation?: ITextRotation;
|
|
24
|
+
textDirection?: Nullable<TextDirection>;
|
|
25
|
+
horizontalAlign?: HorizontalAlign;
|
|
26
|
+
verticalAlign?: VerticalAlign;
|
|
27
|
+
wrapStrategy?: WrapStrategy;
|
|
28
|
+
paddingData?: IPaddingData;
|
|
29
|
+
cellValueType?: CellValueType;
|
|
30
|
+
}
|
|
31
|
+
export interface ICellDocumentModelOption {
|
|
32
|
+
isDeepClone?: boolean;
|
|
33
|
+
displayRawFormula?: boolean;
|
|
34
|
+
ignoreTextRotation?: boolean;
|
|
35
|
+
}
|
|
11
36
|
/**
|
|
12
37
|
* The model of a Worksheet.
|
|
13
38
|
*/
|
|
@@ -340,6 +365,17 @@ export declare class Worksheet {
|
|
|
340
365
|
* parameter is set to `false`, the iterator will return cells in the top row.
|
|
341
366
|
*/
|
|
342
367
|
iterateByColumn(range: IRange, skipEmpty?: boolean, skipNonTopLeft?: boolean): Iterable<Readonly<ICell>>;
|
|
368
|
+
/**
|
|
369
|
+
* This method generates a document model based on the cell's properties and handles the associated styles and configurations.
|
|
370
|
+
* If the cell does not exist, it will return null.
|
|
371
|
+
* PS: This method has significant impact on performance.
|
|
372
|
+
* @param cell
|
|
373
|
+
* @param options
|
|
374
|
+
*/
|
|
375
|
+
private _getCellDocumentModel;
|
|
376
|
+
private _updateConfigAndGetDocumentModel;
|
|
377
|
+
getBlankCellDocumentModel(cell: Nullable<ICellData>): IDocumentLayoutObject;
|
|
378
|
+
getCellDocumentModelWithFormula(cell: ICellData): Nullable<IDocumentLayoutObject>;
|
|
343
379
|
}
|
|
344
380
|
/**
|
|
345
381
|
* A cell info including its span (if it is the top-left cell of a merged cell).
|
|
@@ -293,7 +293,8 @@ export declare enum CustomRangeType {
|
|
|
293
293
|
COMMENT = 4,
|
|
294
294
|
CUSTOM = 5,
|
|
295
295
|
MENTION = 6,
|
|
296
|
-
UNI_FORMULA = 7
|
|
296
|
+
UNI_FORMULA = 7,
|
|
297
|
+
DELTED = 9999
|
|
297
298
|
}
|
|
298
299
|
/**
|
|
299
300
|
* Custom Block
|
|
@@ -304,7 +305,8 @@ export interface ICustomBlock {
|
|
|
304
305
|
blockId: string;
|
|
305
306
|
}
|
|
306
307
|
export declare enum CustomDecorationType {
|
|
307
|
-
COMMENT = 0
|
|
308
|
+
COMMENT = 0,
|
|
309
|
+
DELETED = 9999
|
|
308
310
|
}
|
|
309
311
|
export interface ICustomDecoration {
|
|
310
312
|
startIndex: number;
|
|
@@ -388,6 +390,7 @@ export interface IDocumentRenderConfig {
|
|
|
388
390
|
wrapStrategy?: WrapStrategy;
|
|
389
391
|
cellValueType?: CellValueType;
|
|
390
392
|
isRenderStyle?: BooleanNumber;
|
|
393
|
+
zeroWidthParagraphBreak?: BooleanNumber;
|
|
391
394
|
}
|
|
392
395
|
export interface ISectionBreakBase {
|
|
393
396
|
charSpace?: number;
|