@univerjs/core 0.4.2 → 0.5.0-beta.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.
Files changed (53) hide show
  1. package/lib/cjs/index.js +9 -9
  2. package/lib/es/index.js +11645 -10406
  3. package/lib/types/common/__tests__/interceptor.spec.d.ts +16 -0
  4. package/lib/types/common/interceptor.d.ts +17 -0
  5. package/lib/types/docs/data-model/replacement.d.ts +1 -1
  6. package/lib/types/docs/data-model/text-x/__tests__/apply-consistency.spec.d.ts +16 -0
  7. package/lib/types/docs/data-model/text-x/__tests__/delete-apply.spec.d.ts +16 -0
  8. package/lib/types/docs/data-model/text-x/__tests__/transform-custom-decorations.spec.d.ts +16 -0
  9. package/lib/types/docs/data-model/text-x/__tests__/transform-custom-range.spec.d.ts +16 -0
  10. package/lib/types/docs/data-model/text-x/__tests__/transform-paragraph.spec.d.ts +16 -0
  11. package/lib/types/docs/data-model/text-x/__tests__/transform-textrun.spec.d.ts +16 -0
  12. package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +6 -1
  13. package/lib/types/docs/data-model/text-x/apply-utils/update-apply.d.ts +2 -2
  14. package/lib/types/docs/data-model/text-x/build-utils/__test__/textX.d.ts +16 -0
  15. package/lib/types/docs/data-model/text-x/build-utils/custom-decoration.d.ts +17 -0
  16. package/lib/types/docs/data-model/text-x/build-utils/custom-range.d.ts +15 -5
  17. package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +9 -8
  18. package/lib/types/docs/data-model/text-x/build-utils/selection.d.ts +0 -25
  19. package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +7 -8
  20. package/lib/types/docs/data-model/text-x/text-x.d.ts +4 -0
  21. package/lib/types/docs/data-model/text-x/transform-utils.d.ts +8 -2
  22. package/lib/types/docs/data-model/text-x/utils.d.ts +6 -2
  23. package/lib/types/docs/data-model/types.d.ts +6 -0
  24. package/lib/types/docs/data-model/utils.d.ts +20 -0
  25. package/lib/types/facade/f-base.d.ts +26 -0
  26. package/lib/types/facade/f-hooks.d.ts +57 -0
  27. package/lib/types/facade/f-univer.d.ts +76 -0
  28. package/lib/types/index.d.ts +8 -3
  29. package/lib/types/services/command/command.service.d.ts +5 -5
  30. package/lib/types/services/context/context.d.ts +2 -0
  31. package/lib/types/services/resource-loader/resource-loader.service.d.ts +3 -3
  32. package/lib/types/shared/__tests__/array-search.spec.d.ts +16 -0
  33. package/lib/types/shared/__tests__/doc-tool.spec.d.ts +16 -0
  34. package/lib/types/shared/array-search.d.ts +30 -5
  35. package/lib/types/shared/command-enum.d.ts +1 -2
  36. package/lib/types/shared/common.d.ts +12 -2
  37. package/lib/types/shared/dayjs.d.ts +2 -0
  38. package/lib/types/shared/doc-tool.d.ts +1 -1
  39. package/lib/types/shared/index.d.ts +1 -0
  40. package/lib/types/shared/r-tree.d.ts +4 -3
  41. package/lib/types/shared/rectangle.d.ts +1 -0
  42. package/lib/types/shared/ref-alias.d.ts +1 -1
  43. package/lib/types/shared/rxjs.d.ts +1 -0
  44. package/lib/types/shared/text-diff.d.ts +16 -0
  45. package/lib/types/shared/tools.d.ts +1 -0
  46. package/lib/types/sheets/typedef.d.ts +62 -10
  47. package/lib/types/sheets/util.d.ts +35 -0
  48. package/lib/types/sheets/worksheet.d.ts +41 -2
  49. package/lib/types/types/const/const.d.ts +1 -0
  50. package/lib/types/types/interfaces/i-cell-custom-render.d.ts +3 -3
  51. package/lib/types/types/interfaces/i-document-data.d.ts +7 -4
  52. package/lib/umd/index.js +9 -9
  53. package/package.json +13 -11
@@ -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 {};
@@ -26,3 +26,20 @@ export declare class InterceptorManager<P extends Record<string, IInterceptor<an
26
26
  getInterceptPoints(): P;
27
27
  dispose(): void;
28
28
  }
29
+ export declare function createAsyncInterceptorKey<T, C>(key: string): IAsyncInterceptor<T, C>;
30
+ export type AsyncInterceptorHandler<M = unknown, C = unknown> = (value: Nullable<M>, context: C, next: (value: Nullable<M>) => Promise<Nullable<M>>) => Promise<Nullable<M>>;
31
+ export interface IAsyncInterceptor<M, C> {
32
+ priority?: number;
33
+ handler: AsyncInterceptorHandler<M, C>;
34
+ }
35
+ export type IComposeAsyncInterceptors<T = any, C = any> = (interceptors: Array<IAsyncInterceptor<T, C>>) => (initValue: Nullable<T>, initContext: C) => Promise<Nullable<T>>;
36
+ export declare const composeAsyncInterceptors: <T, C>(interceptors: Array<IAsyncInterceptor<T, C>>) => ((initialValue: Nullable<T>, context: C) => Promise<Nullable<T>>);
37
+ export declare class AsyncInterceptorManager<P extends Record<string, IAsyncInterceptor<any, any>>> {
38
+ private _asyncInterceptorsByName;
39
+ private _asyncInterceptorPoints;
40
+ constructor(asyncInterceptorPoints: P);
41
+ fetchThroughAsyncInterceptors<T, C>(name: IAsyncInterceptor<T, C>): (initialValue: Nullable<T>, context: C) => Promise<Nullable<T>>;
42
+ interceptAsync<T extends IAsyncInterceptor<any, any>>(name: T, interceptor: T): Promise<() => boolean>;
43
+ getInterceptPoints(): P;
44
+ dispose(): void;
45
+ }
@@ -1,2 +1,2 @@
1
1
  import { IDocumentBody } from '../../types/interfaces/i-document-data';
2
- export declare function replaceInDocumentBody(body: IDocumentBody, query: string, target: string): IDocumentBody;
2
+ export declare function replaceInDocumentBody(body: IDocumentBody, query: string, target: string, caseSensitive: boolean): IDocumentBody;
@@ -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 {};
@@ -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 {};
@@ -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 {};
@@ -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 {};
@@ -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 {};
@@ -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 {};
@@ -1,5 +1,5 @@
1
1
  import { ICustomBlock, ICustomDecoration, ICustomRange, ICustomTable, IDocumentBody, IParagraph, ISectionBreak, ITextRun } from '../../../../types/interfaces';
2
- export declare function normalizeTextRuns(textRuns: ITextRun[]): ITextRun[];
2
+ export declare function normalizeTextRuns(textRuns: ITextRun[], reserveEmptyTextRun?: boolean): ITextRun[];
3
3
  /**
4
4
  * Inserting styled text content into the current document model.
5
5
  * @param body The current content object of the document model.
@@ -20,6 +20,11 @@ export declare function insertParagraphs(body: IDocumentBody, insertBody: IDocum
20
20
  export declare function insertSectionBreaks(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
21
21
  export declare function insertCustomBlocks(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
22
22
  export declare function insertTables(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
23
+ export declare function sliceByParagraph(body: IDocumentBody): IDocumentBody[];
24
+ export declare function mergeContinuousRanges(ranges: ICustomRange[]): ICustomRange[];
25
+ export declare function splitCustomRangesByIndex(customRanges: ICustomRange[], currentIndex: number): void;
26
+ export declare function mergeContinuousDecorations(ranges: ICustomDecoration[]): ICustomDecoration[];
27
+ export declare function splitCustomDecoratesByIndex(customDecorations: ICustomDecoration[], currentIndex: number): void;
23
28
  export declare function insertCustomRanges(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
24
29
  export declare function mergeDecorations(customDecorations: ICustomDecoration[]): ICustomDecoration[];
25
30
  export declare function insertCustomDecorations(body: IDocumentBody, insertBody: IDocumentBody, textLength: number, currentIndex: number): void;
@@ -1,4 +1,4 @@
1
- import { IDocumentBody, ITextRun } from '../../../../types/interfaces';
2
1
  import { UpdateDocsAttributeType } from '../../../../shared';
2
+ import { IDocumentBody, ITextRun } from '../../../../types/interfaces';
3
3
  export declare function updateAttribute(body: IDocumentBody, updateBody: IDocumentBody, textLength: number, currentIndex: number, coverType: UpdateDocsAttributeType): IDocumentBody;
4
- export declare function coverTextRuns(updateDataTextRuns: ITextRun[], removeTextRuns: ITextRun[], coverType: UpdateDocsAttributeType): ITextRun[];
4
+ export declare function coverTextRuns(updateDataTextRuns: ITextRun[], originTextRuns: ITextRun[], coverType: UpdateDocsAttributeType): ITextRun[];
@@ -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 {};
@@ -0,0 +1,17 @@
1
+ import { ITextRange } from '../../../../sheets/typedef';
2
+ import { DocumentDataModel } from '../../document-data-model';
3
+ import { CustomDecorationType } from '../../../../types/interfaces';
4
+ import { TextX } from '../text-x';
5
+ interface IAddCustomDecorationParam {
6
+ ranges: ITextRange[];
7
+ id: string;
8
+ type: CustomDecorationType;
9
+ }
10
+ export declare function addCustomDecorationTextX(param: IAddCustomDecorationParam): TextX;
11
+ export interface IDeleteCustomRangeParam {
12
+ id: string;
13
+ segmentId?: string;
14
+ documentDataModel: DocumentDataModel;
15
+ }
16
+ export declare function deleteCustomDecorationTextX(params: IDeleteCustomRangeParam): false | TextX;
17
+ export {};
@@ -1,7 +1,5 @@
1
1
  import { ITextRange } from '../../../../sheets/typedef';
2
- import { ICustomRange } from '../../../../types/interfaces';
3
- import { DataStreamTreeTokenType } from '../../types';
4
- export declare function isCustomRangeSplitSymbol(text: string): text is DataStreamTreeTokenType.CUSTOM_RANGE_START | DataStreamTreeTokenType.CUSTOM_RANGE_END;
2
+ import { CustomRangeType, ICustomRange, IDocumentBody } from '../../../../types/interfaces';
5
3
  /**
6
4
  * Check if two ranges intersect
7
5
  * @param line1Start - The start of the first range
@@ -11,14 +9,26 @@ export declare function isCustomRangeSplitSymbol(text: string): text is DataStre
11
9
  * @returns True if the ranges intersect, false otherwise
12
10
  */
13
11
  export declare function isIntersecting(line1Start: number, line1End: number, line2Start: number, line2End: number): boolean;
14
- export declare function shouldDeleteCustomRange(deleteStart: number, deleteLen: number, customRange: ICustomRange, dataStream: string): boolean;
15
12
  export declare function getCustomRangesInterestsWithSelection(range: ITextRange, customRanges: ICustomRange[]): ICustomRange<Record<string, any>>[];
16
13
  export declare function copyCustomRange(range: ICustomRange): {
17
14
  rangeId: string;
18
15
  startIndex: number;
19
16
  endIndex: number;
20
- rangeType: import('../../../..').CustomRangeType | number;
17
+ rangeType: CustomRangeType | number;
21
18
  wholeEntity?: boolean;
22
19
  properties?: Record<string, any> | undefined;
23
20
  };
24
21
  export declare function excludePointsFromRange(range: [number, number], points: number[]): [number, number][];
22
+ export declare function getIntersectingCustomRanges(startIndex: number, endIndex: number, customRanges: ICustomRange[], rangeType?: CustomRangeType): {
23
+ startIndex: number;
24
+ endIndex: number;
25
+ rangeId: string;
26
+ rangeType: CustomRangeType | number;
27
+ wholeEntity?: boolean;
28
+ properties?: Record<string, any> | undefined;
29
+ }[];
30
+ export declare function getSelectionForAddCustomRange(range: ITextRange, body: IDocumentBody): {
31
+ startOffset: number;
32
+ endOffset: number;
33
+ collapsed: boolean;
34
+ };
@@ -1,23 +1,24 @@
1
- import { copyCustomRange, getCustomRangesInterestsWithSelection, isIntersecting, shouldDeleteCustomRange } from './custom-range';
2
- import { getDeleteSelection, getInsertSelection, getRetainAndDeleteFromReplace, isSegmentIntersects, makeSelection, normalizeSelection } from './selection';
3
- import { addCustomRangeTextX, deleteCustomRangeTextX, getRetainAndDeleteAndExcludeLineBreak } from './text-x-utils';
1
+ import { addCustomDecorationTextX, deleteCustomDecorationTextX } from './custom-decoration';
2
+ import { copyCustomRange, getCustomRangesInterestsWithSelection, isIntersecting } from './custom-range';
3
+ import { isSegmentIntersects, makeSelection, normalizeSelection } from './selection';
4
+ import { addCustomRangeTextX, deleteCustomRangeTextX, deleteSelectionTextX } from './text-x-utils';
4
5
  export declare class BuildTextUtils {
5
6
  static customRange: {
6
7
  add: typeof addCustomRangeTextX;
7
8
  delete: typeof deleteCustomRangeTextX;
8
9
  copyCustomRange: typeof copyCustomRange;
9
10
  getCustomRangesInterestsWithSelection: typeof getCustomRangesInterestsWithSelection;
10
- shouldDeleteCustomRange: typeof shouldDeleteCustomRange;
11
11
  isIntersecting: typeof isIntersecting;
12
12
  };
13
+ static customDecoration: {
14
+ add: typeof addCustomDecorationTextX;
15
+ delete: typeof deleteCustomDecorationTextX;
16
+ };
13
17
  static selection: {
14
18
  replace: (params: import('./text-x-utils').IReplaceSelectionTextXParams) => false | import('../text-x').TextX;
15
19
  makeSelection: typeof makeSelection;
16
20
  normalizeSelection: typeof normalizeSelection;
17
- getDeleteSelection: typeof getDeleteSelection;
18
- getInsertSelection: typeof getInsertSelection;
19
- getDeleteActions: typeof getRetainAndDeleteFromReplace;
20
- getDeleteExcludeLastLineBreakActions: typeof getRetainAndDeleteAndExcludeLineBreak;
21
+ delete: typeof deleteSelectionTextX;
21
22
  };
22
23
  static range: {
23
24
  isIntersects: typeof isSegmentIntersects;
@@ -1,29 +1,4 @@
1
- import { Nullable } from '../../../../shared';
2
1
  import { ITextRange } from '../../../../sheets/typedef';
3
- import { IDocumentBody } from '../../../../types/interfaces';
4
- import { IDeleteAction, IRetainAction } from '../action-types';
5
- import { DeleteDirection } from '../../../../types/enum';
6
2
  export declare function makeSelection(startOffset: number, endOffset?: number): ITextRange;
7
3
  export declare function normalizeSelection(selection: ITextRange): ITextRange;
8
- export declare function getSelectionWithSymbolMax(selection: ITextRange, body: IDocumentBody): {
9
- startOffset: number;
10
- endOffset: number;
11
- };
12
- export declare function getSelectionWithNoSymbolSide(selection: ITextRange, body: IDocumentBody): {
13
- startOffset: number;
14
- endOffset: number;
15
- };
16
- export declare function getDeleteSelection<T extends ITextRange>(selection: T, body: IDocumentBody, direction?: DeleteDirection): T;
17
- export declare function getInsertSelection<T extends ITextRange>(selection: T, body: IDocumentBody): T;
18
- /**
19
- * Ensure custom-range has a correct order,
20
- * when range contains range, it won't be present as intersect. <br/>
21
- * For Example `\s1\s2 text \s1\s2` is not allowed, expect `\s1\s2 text \s2\s1`
22
- */
23
- export declare function getSelectionForAddCustomRange(selection: ITextRange, body: IDocumentBody): Nullable<ITextRange>;
24
4
  export declare function isSegmentIntersects(start: number, end: number, start2: number, end2: number): boolean;
25
- export declare function getRetainAndDeleteFromReplace(range: ITextRange, segmentId: string | undefined, memoryCursor: number, body: IDocumentBody): {
26
- dos: (IRetainAction | IDeleteAction)[];
27
- cursor: number;
28
- retain: number;
29
- };
@@ -2,19 +2,16 @@ import { IAccessor } from '@wendellhu/redi';
2
2
  import { ITextRange, ITextRangeParam } from '../../../../sheets/typedef';
3
3
  import { CustomRangeType, IDocumentBody } from '../../../../types/interfaces';
4
4
  import { DocumentDataModel } from '../../document-data-model';
5
- import { IDeleteAction, IRetainAction } from '../action-types';
5
+ import { TextXAction } from '../action-types';
6
+ import { TextXSelection, TextX } from '../text-x';
6
7
  import { Nullable } from '../../../../shared';
7
- import { TextX } from '../text-x';
8
8
  export interface IDeleteCustomRangeParam {
9
9
  rangeId: string;
10
10
  segmentId?: string;
11
11
  documentDataModel: DocumentDataModel;
12
12
  insert?: Nullable<IDocumentBody>;
13
- textRange?: {
14
- index: number;
15
- };
16
13
  }
17
- export declare function deleteCustomRangeTextX(accessor: IAccessor, params: IDeleteCustomRangeParam): false | TextX;
14
+ export declare function deleteCustomRangeTextX(accessor: IAccessor, params: IDeleteCustomRangeParam): false | TextXSelection;
18
15
  export interface IAddCustomRangeTextXParam {
19
16
  range: ITextRange;
20
17
  segmentId?: string;
@@ -24,8 +21,10 @@ export interface IAddCustomRangeTextXParam {
24
21
  wholeEntity?: boolean;
25
22
  body: IDocumentBody;
26
23
  }
27
- export declare function addCustomRangeTextX(param: IAddCustomRangeTextXParam): false | TextX;
28
- export declare function getRetainAndDeleteAndExcludeLineBreak(selection: ITextRange, body: IDocumentBody, segmentId?: string, memoryCursor?: number, preserveLineBreak?: boolean): Array<IRetainAction | IDeleteAction>;
24
+ export declare function addCustomRangeTextX(param: IAddCustomRangeTextXParam): false | (TextX & {
25
+ selections?: ITextRange[];
26
+ });
27
+ export declare function deleteSelectionTextX(selections: ITextRange[], body: IDocumentBody, memoryCursor?: number, insertBody?: Nullable<IDocumentBody>, keepBullet?: boolean): Array<TextXAction>;
29
28
  export interface IReplaceSelectionTextXParams {
30
29
  /**
31
30
  * range to be replaced.
@@ -1,3 +1,4 @@
1
+ import { ITextRange } from '../../../sheets/typedef';
1
2
  import { IDocumentBody } from '../../../types/interfaces/i-document-data';
2
3
  import { UpdateDocsAttributeType } from '../../../shared/command-enum';
3
4
  import { TextXAction } from './action-types';
@@ -50,3 +51,6 @@ export declare class TextX {
50
51
  push(...args: TextXAction[]): this;
51
52
  protected trimEndUselessRetainAction(): this;
52
53
  }
54
+ export type TextXSelection = TextX & {
55
+ selections?: ITextRange[];
56
+ };
@@ -1,3 +1,9 @@
1
- import { IDocumentBody } from '../../../types/interfaces';
2
1
  import { IRetainAction } from './action-types';
3
- export declare function transformBody(thisAction: IRetainAction, otherAction: IRetainAction, priority?: boolean): IDocumentBody;
2
+ import { UpdateDocsAttributeType } from '../../../shared';
3
+ import { IDocumentBody } from '../../../types/interfaces';
4
+ interface ITransformBodyResult {
5
+ body: IDocumentBody;
6
+ coverType: UpdateDocsAttributeType;
7
+ }
8
+ export declare function transformBody(thisAction: IRetainAction, otherAction: IRetainAction, priority?: boolean): ITransformBodyResult;
9
+ export {};
@@ -5,9 +5,13 @@ export declare enum SliceBodyType {
5
5
  copy = 0,
6
6
  cut = 1
7
7
  }
8
- export declare function getBodySlice(body: IDocumentBody, startOffset: number, endOffset: number, returnEmptyTextRun?: boolean, type?: SliceBodyType): IDocumentBody;
8
+ export declare function getBodySlice(body: IDocumentBody, startOffset: number, endOffset: number, returnEmptyArray?: boolean, type?: SliceBodyType): IDocumentBody;
9
9
  export declare function normalizeBody(body: IDocumentBody): IDocumentBody;
10
10
  export declare function getCustomRangeSlice(body: IDocumentBody, startOffset: number, endOffset: number): {
11
+ customRanges?: undefined;
12
+ leftOffset?: undefined;
13
+ rightOffset?: undefined;
14
+ } | {
11
15
  customRanges: {
12
16
  startIndex: number;
13
17
  endIndex: number;
@@ -19,6 +23,6 @@ export declare function getCustomRangeSlice(body: IDocumentBody, startOffset: nu
19
23
  leftOffset: number;
20
24
  rightOffset: number;
21
25
  };
22
- export declare function getCustomDecorationSlice(body: IDocumentBody, startOffset: number, endOffset: number): ICustomDecoration[];
26
+ export declare function getCustomDecorationSlice(body: IDocumentBody, startOffset: number, endOffset: number): ICustomDecoration[] | undefined;
23
27
  export declare function composeBody(thisBody: IDocumentBody, otherBody: IDocumentBody, coverType?: UpdateDocsAttributeType): IDocumentBody;
24
28
  export declare function isUselessRetainAction(action: IRetainAction): boolean;
@@ -30,7 +30,13 @@ export declare enum DataStreamTreeTokenType {
30
30
  TABLE_CELL_END = "\u001D",// 表格单元格结束
31
31
  TABLE_ROW_END = "\u000E",// 表格行结束
32
32
  TABLE_END = "\u000F",// 表格结束
33
+ /**
34
+ * @deprecated
35
+ */
33
36
  CUSTOM_RANGE_START = "\u001F",// 自定义范围开始
37
+ /**
38
+ * @deprecated
39
+ */
34
40
  CUSTOM_RANGE_END = "\u001E",// 自定义范围结束
35
41
  COLUMN_BREAK = "\v",// 换列
36
42
  PAGE_BREAK = "\f",// 换页
@@ -0,0 +1,20 @@
1
+ import { IStyleBase, ITextRotation } from '../../types/interfaces';
2
+ export declare const DEFAULT_FONTFACE_PLANE = "\"Helvetica Neue\", Helvetica, Arial, \"PingFang SC\", \"Hiragino Sans GB\", \"Heiti SC\", \"Microsoft YaHei\", \"WenQuanYi Micro Hei\", sans-serif";
3
+ export interface IDocumentSkeletonFontStyle {
4
+ fontString: string;
5
+ fontSize: number;
6
+ originFontSize: number;
7
+ fontFamily: string;
8
+ fontCache: string;
9
+ }
10
+ export declare function getFontStyleString(textStyle?: IStyleBase): IDocumentSkeletonFontStyle;
11
+ export declare function getBaselineOffsetInfo(_fontFamily: string, fontSize: number): {
12
+ sbr: number;
13
+ sbo: number;
14
+ spr: number;
15
+ spo: number;
16
+ };
17
+ export declare function convertTextRotation(textRotation?: ITextRotation): {
18
+ centerAngle: number;
19
+ vertexAngle: number;
20
+ };
@@ -0,0 +1,26 @@
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
+ /**
17
+ * `FBase` is a base class for all facade classes.
18
+ * It provides a way to extend classes with static and instance methods.
19
+ * The `_initialize` as a special method that will be called after the constructor. You should never call it directly.
20
+ */
21
+ export declare abstract class FBase {
22
+ private static _constructorQueue;
23
+ constructor();
24
+ _initialize(): void;
25
+ static extend(source: any): void;
26
+ }
@@ -0,0 +1,57 @@
1
+ import { IDisposable, Injector } from '../common/di';
2
+ import { IUndoRedoItem } from '../services/undoredo/undoredo.service';
3
+ import { LifecycleService } from '../services/lifecycle/lifecycle.service';
4
+ import { FBase } from './f-base';
5
+ export declare class FHooks extends FBase {
6
+ protected readonly _injector: Injector;
7
+ private readonly _lifecycleService;
8
+ constructor(_injector: Injector, _lifecycleService: LifecycleService);
9
+ /**
10
+ * The onStarting event is fired when lifecycle stage is Starting.
11
+ * @param callback Callback function that will be called when the event is fired
12
+ * @returns A disposable object that can be used to unsubscribe from the event
13
+ */
14
+ onStarting(callback: () => void): IDisposable;
15
+ /**
16
+ * The onReady event is fired when lifecycle stage is Ready.
17
+ * @param callback Callback function that will be called when the event is fired
18
+ * @returns A disposable object that can be used to unsubscribe from the event
19
+ */
20
+ onReady(callback: () => void): IDisposable;
21
+ /**
22
+ * The onRendered event is fired when lifecycle stage is Rendered.
23
+ * @param callback Callback function that will be called when the event is fired
24
+ * @returns A disposable object that can be used to unsubscribe from the event
25
+ */
26
+ onRendered(callback: () => void): IDisposable;
27
+ /**
28
+ * The onSteady event is fired when lifecycle stage is Steady.
29
+ * @param callback Callback function that will be called when the event is fired
30
+ * @returns A disposable object that can be used to unsubscribe from the event
31
+ */
32
+ onSteady(callback: () => void): IDisposable;
33
+ /**
34
+ * Hook that fires before an undo operation is executed.
35
+ * @param callback Function to be called when the event is triggered
36
+ * @returns A disposable object that can be used to unsubscribe from the event
37
+ */
38
+ onBeforeUndo(callback: (action: IUndoRedoItem) => void): IDisposable;
39
+ /**
40
+ * Hook that fires after an undo operation is executed.
41
+ * @param callback Function to be called when the event is triggered
42
+ * @returns A disposable object that can be used to unsubscribe from the event
43
+ */
44
+ onUndo(callback: (action: IUndoRedoItem) => void): IDisposable;
45
+ /**
46
+ * Hook that fires before a redo operation is executed.
47
+ * @param callback Function to be called when the event is triggered
48
+ * @returns A disposable object that can be used to unsubscribe from the event
49
+ */
50
+ onBeforeRedo(callback: (action: IUndoRedoItem) => void): IDisposable;
51
+ /**
52
+ * Hook that fires after a redo operation is executed.
53
+ * @param callback Function to be called when the event is triggered
54
+ * @returns A disposable object that can be used to unsubscribe from the event
55
+ */
56
+ onRedo(callback: (action: IUndoRedoItem) => void): IDisposable;
57
+ }
@@ -0,0 +1,76 @@
1
+ import { IDisposable, Injector } from '../common/di';
2
+ import { CommandListener, IExecutionOptions, ICommandService } from '../services/command/command.service';
3
+ import { LifecycleStages } from '../services/lifecycle/lifecycle';
4
+ import { IUniverInstanceService } from '../services/instance/instance.service';
5
+ import { Univer } from '../univer';
6
+ import { FBase } from './f-base';
7
+ import { FHooks } from './f-hooks';
8
+ export declare class FUniver extends FBase {
9
+ protected readonly _injector: Injector;
10
+ protected readonly _commandService: ICommandService;
11
+ protected readonly _univerInstanceService: IUniverInstanceService;
12
+ /**
13
+ * Create an FUniver instance, if the injector is not provided, it will create a new Univer instance.
14
+ *
15
+ * @static
16
+ *
17
+ * @param {Univer | Injector} wrapped - The Univer instance or injector instance.
18
+ * @returns {FUniver} - The FUniver instance.
19
+ */
20
+ static newAPI(wrapped: Univer | Injector): FUniver;
21
+ constructor(_injector: Injector, _commandService: ICommandService, _univerInstanceService: IUniverInstanceService);
22
+ /**
23
+ * Dispose the UniverSheet by the `unitId`. The UniverSheet would be unload from the application.
24
+ *
25
+ * @param unitId The unit id of the UniverSheet.
26
+ * @returns Whether the Univer instance is disposed successfully.
27
+ */
28
+ disposeUnit(unitId: string): boolean;
29
+ /**
30
+ * Get the current lifecycle stage.
31
+ *
32
+ * @returns {LifecycleStages} - The current lifecycle stage.
33
+ */
34
+ getCurrentLifecycleStage(): LifecycleStages;
35
+ /**
36
+ * Undo an editing on the currently focused document.
37
+ *
38
+ * @returns {Promise<boolean>} undo result
39
+ */
40
+ undo(): Promise<boolean>;
41
+ /**
42
+ * Redo an editing on the currently focused document.
43
+ *
44
+ * @returns {Promise<boolean>} redo result
45
+ */
46
+ redo(): Promise<boolean>;
47
+ /**
48
+ * Register a callback that will be triggered before invoking a command.
49
+ *
50
+ * @param {CommandListener} callback The callback.
51
+ * @returns {IDisposable} The disposable instance.
52
+ */
53
+ onBeforeCommandExecute(callback: CommandListener): IDisposable;
54
+ /**
55
+ * Register a callback that will be triggered when a command is invoked.
56
+ *
57
+ * @param {CommandListener} callback The callback.
58
+ * @returns {IDisposable} The disposable instance.
59
+ */
60
+ onCommandExecuted(callback: CommandListener): IDisposable;
61
+ /**
62
+ * Execute command
63
+ *
64
+ * @param {string} id Command ID
65
+ * @param {object} params Command parameters
66
+ * @param {IExecutionOptions} options Command execution options
67
+ * @returns {Promise<R>} Command execution result
68
+ */
69
+ executeCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): Promise<R>;
70
+ /**
71
+ * Get hooks.
72
+ *
73
+ * @returns {FHooks} FHooks instance
74
+ */
75
+ getHooks(): FHooks;
76
+ }