@univerjs/engine-render 0.2.6 → 0.2.7

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 (34) hide show
  1. package/lib/cjs/index.js +2 -2
  2. package/lib/es/index.js +6873 -5639
  3. package/lib/types/base-object.d.ts +4 -0
  4. package/lib/types/basics/document-node-tools.d.ts +7 -1
  5. package/lib/types/basics/i-document-skeleton-cached.d.ts +30 -3
  6. package/lib/types/basics/interfaces.d.ts +8 -1
  7. package/lib/types/basics/range.d.ts +4 -1
  8. package/lib/types/components/docs/document.d.ts +3 -0
  9. package/lib/types/components/docs/layout/block/paragraph/linebreaking.d.ts +3 -2
  10. package/lib/types/components/docs/layout/block/table.d.ts +13 -0
  11. package/lib/types/components/docs/layout/doc-skeleton.d.ts +1 -0
  12. package/lib/types/components/docs/layout/model/line.d.ts +3 -2
  13. package/lib/types/components/docs/layout/model/page.d.ts +4 -0
  14. package/lib/types/components/docs/layout/model/table.d.ts +15 -0
  15. package/lib/types/components/docs/layout/tools.d.ts +2 -1
  16. package/lib/types/components/docs/text-selection/convert-rect-range.d.ts +30 -0
  17. package/lib/types/components/docs/text-selection/{convert-cursor.d.ts → convert-text-range.d.ts} +7 -2
  18. package/lib/types/components/docs/text-selection/range-interface.d.ts +22 -0
  19. package/lib/types/components/docs/text-selection/rect-range.d.ts +49 -0
  20. package/lib/types/components/docs/text-selection/selection-utils.d.ts +28 -0
  21. package/lib/types/components/docs/text-selection/text-range.d.ts +8 -4
  22. package/lib/types/components/docs/text-selection/text-selection-render-manager.d.ts +28 -20
  23. package/lib/types/components/docs/view-model/document-view-model.d.ts +4 -5
  24. package/lib/types/engine.d.ts +5 -0
  25. package/lib/types/index.d.ts +11 -3
  26. package/lib/types/layer.d.ts +4 -0
  27. package/lib/types/render-manager/render-manager.service.d.ts +5 -0
  28. package/lib/types/render-manager/render-unit.d.ts +3 -1
  29. package/lib/types/scene.d.ts +9 -0
  30. package/lib/types/scene.transformer.d.ts +5 -0
  31. package/lib/types/shape/rich-text.d.ts +65 -4
  32. package/lib/umd/index.js +2 -2
  33. package/package.json +5 -5
  34. /package/lib/types/components/docs/layout/block/paragraph/{layout.d.ts → paragraph-layout.d.ts} +0 -0
@@ -134,6 +134,10 @@ export declare abstract class BaseObject extends Disposable {
134
134
  scale(scaleX?: number, scaleY?: number): this;
135
135
  skew(skewX?: number, skewY?: number): this;
136
136
  flip(flipX?: boolean, flipY?: boolean): this;
137
+ /**
138
+ * this[pKey] = option[pKey]
139
+ * @param option
140
+ */
137
141
  transformByState(option: IObjectFullState): this | undefined;
138
142
  isRender(bounds?: IViewportInfo): boolean | undefined;
139
143
  getParent(): any;
@@ -5,6 +5,12 @@ export declare function hasListGlyph(glyph: Nullable<IDocumentSkeletonGlyph>): b
5
5
  export declare function isIndentByGlyph(glyph: Nullable<IDocumentSkeletonGlyph>, body?: IDocumentBody): boolean;
6
6
  export declare function isLastGlyph(glyph: Nullable<IDocumentSkeletonGlyph>): boolean;
7
7
  export declare function isFirstGlyph(glyph: Nullable<IDocumentSkeletonGlyph>): boolean;
8
- export declare function getParagraphByGlyph(glyph: Nullable<IDocumentSkeletonGlyph>, body?: IDocumentBody): import('@univerjs/core').IParagraph | undefined;
8
+ export declare function getParagraphByGlyph(glyph: Nullable<IDocumentSkeletonGlyph>, body?: IDocumentBody): {
9
+ paragraphStart: number;
10
+ paragraphEnd: number;
11
+ startIndex: number;
12
+ paragraphStyle?: import('@univerjs/core').IParagraphStyle;
13
+ bullet?: import('@univerjs/core').IBullet;
14
+ } | undefined;
9
15
  export declare function isPlaceholderOrSpace(glyph: Nullable<IDocumentSkeletonGlyph>): boolean;
10
16
  export declare function isSameLine(glyph1: Nullable<IDocumentSkeletonGlyph>, glyph2: Nullable<IDocumentSkeletonGlyph>): boolean;
@@ -1,4 +1,4 @@
1
- import { BulletAlignment, ColumnSeparatorType, DataStreamTreeTokenType, IDocDrawingBase, IDocumentRenderConfig, INestingLevel, IParagraphProperties, ITextStyle, PageOrientType } from '@univerjs/core';
1
+ import { BulletAlignment, ColumnSeparatorType, DataStreamTreeTokenType, IDocDrawingBase, IDocumentRenderConfig, INestingLevel, IParagraphProperties, ITable, ITextStyle, PageOrientType } from '@univerjs/core';
2
2
  import { BreakPointType } from '../components/docs/layout/line-breaker/break';
3
3
 
4
4
  export interface IDocumentSkeletonCached extends ISkeletonResourceReference {
@@ -7,6 +7,7 @@ export interface IDocumentSkeletonCached extends ISkeletonResourceReference {
7
7
  top: number;
8
8
  st: number;
9
9
  ed?: number;
10
+ parent?: unknown;
10
11
  }
11
12
  export interface ISkeletonResourceReference {
12
13
  skeHeaders: Map<string, Map<number, IDocumentSkeletonHeaderFooter>>;
@@ -22,7 +23,8 @@ export interface IDocumentSkeletonDrawingAnchor {
22
23
  export declare enum DocumentSkeletonPageType {
23
24
  BODY = 0,
24
25
  HEADER = 1,
25
- FOOTER = 2
26
+ FOOTER = 2,
27
+ CELL = 3
26
28
  }
27
29
  export interface IDocumentSkeletonPage {
28
30
  sections: IDocumentSkeletonSection[];
@@ -37,6 +39,7 @@ export interface IDocumentSkeletonPage {
37
39
  marginTop: number;
38
40
  originMarginBottom: number;
39
41
  marginBottom: number;
42
+ left: number;
40
43
  pageNumber: number;
41
44
  pageNumberStart: number;
42
45
  verticalAlign: boolean;
@@ -47,10 +50,11 @@ export interface IDocumentSkeletonPage {
47
50
  st: number;
48
51
  ed: number;
49
52
  skeDrawings: Map<string, IDocumentSkeletonDrawing>;
53
+ skeTables: Map<string, IDocumentSkeletonTable>;
50
54
  segmentId: string;
51
55
  type: DocumentSkeletonPageType;
52
56
  renderConfig?: IDocumentRenderConfig;
53
- parent?: IDocumentSkeletonCached;
57
+ parent?: IDocumentSkeletonCached | IDocumentSkeletonRow;
54
58
  }
55
59
  export interface IDocumentSkeletonHeaderFooter extends IDocumentSkeletonPage {
56
60
  }
@@ -63,6 +67,27 @@ export interface IDocumentSkeletonSection {
63
67
  ed: number;
64
68
  parent?: IDocumentSkeletonPage;
65
69
  }
70
+ export interface IDocumentSkeletonTable {
71
+ rows: IDocumentSkeletonRow[];
72
+ width: number;
73
+ height: number;
74
+ top: number;
75
+ left: number;
76
+ st: number;
77
+ ed: number;
78
+ tableId: string;
79
+ tableSource: ITable;
80
+ parent?: IDocumentSkeletonPage;
81
+ }
82
+ export interface IDocumentSkeletonRow {
83
+ cells: IDocumentSkeletonPage[];
84
+ index: number;
85
+ height: number;
86
+ top: number;
87
+ st: number;
88
+ ed: number;
89
+ parent?: IDocumentSkeletonTable;
90
+ }
66
91
  export interface IDocumentSkeletonColumn {
67
92
  lines: IDocumentSkeletonLine[];
68
93
  left: number;
@@ -97,6 +122,8 @@ export interface IDocumentSkeletonLine {
97
122
  lineIndex: number;
98
123
  bullet?: IDocumentSkeletonBullet;
99
124
  paragraphStart: boolean;
125
+ isBehindTable: boolean;
126
+ tableId: string;
100
127
  parent?: IDocumentSkeletonColumn;
101
128
  }
102
129
  export interface IDocumentSkeletonDivide {
@@ -1,6 +1,6 @@
1
1
  import { BooleanNumber, GridType, IDocStyleBase, IDocumentLayout, IOffset, IParagraphStyle, IReferenceSource, IScale, ISectionBreakBase, ISize, ITextStyle, ITransformState, LocaleService } from '@univerjs/core';
2
2
  import { DocumentViewModel } from '../components/docs/view-model/document-view-model';
3
- import { DocumentSkeletonPageType, IDocumentSkeletonBullet, IDocumentSkeletonDrawing, IDocumentSkeletonDrawingAnchor, IDocumentSkeletonFontStyle, IDocumentSkeletonGlyph, IDocumentSkeletonHeaderFooter } from './i-document-skeleton-cached';
3
+ import { DocumentSkeletonPageType, IDocumentSkeletonBullet, IDocumentSkeletonDrawing, IDocumentSkeletonDrawingAnchor, IDocumentSkeletonFontStyle, IDocumentSkeletonGlyph, IDocumentSkeletonHeaderFooter, IDocumentSkeletonTable } from './i-document-skeleton-cached';
4
4
  import { Vector2 } from './vector2';
5
5
  import { ITransformerConfig } from './transformer-config';
6
6
 
@@ -56,10 +56,16 @@ export interface ISectionBreakConfig extends IDocStyleBase, ISectionBreakBase, I
56
56
  useFirstPageHeaderFooter?: BooleanNumber;
57
57
  evenAndOddHeaders?: BooleanNumber;
58
58
  }
59
+ export interface IParagraphTableCache {
60
+ tableId: string;
61
+ table: IDocumentSkeletonTable;
62
+ hasPositioned: boolean;
63
+ }
59
64
  export interface IParagraphConfig {
60
65
  paragraphIndex: number;
61
66
  paragraphAffectSkeDrawings?: Map<string, IDocumentSkeletonDrawing>;
62
67
  paragraphInlineSkeDrawings?: Map<string, IDocumentSkeletonDrawing>;
68
+ skeTablesInParagraph?: IParagraphTableCache[];
63
69
  bulletSkeleton?: IDocumentSkeletonBullet;
64
70
  paragraphStyle?: IParagraphStyle;
65
71
  skeHeaders: Map<string, Map<number, IDocumentSkeletonHeaderFooter>>;
@@ -90,6 +96,7 @@ export interface INodeSearch {
90
96
  page: number;
91
97
  segmentPage: number;
92
98
  pageType: DocumentSkeletonPageType;
99
+ path: (string | number)[];
93
100
  }
94
101
  export interface INodePosition extends INodeSearch {
95
102
  isBack: boolean;
@@ -1,4 +1,5 @@
1
1
  import { ITextRangeParam } from '@univerjs/core';
2
+ import { DOC_RANGE_TYPE } from '../components/docs/text-selection/range-interface';
2
3
 
3
4
  export interface ITextSelectionStyle {
4
5
  strokeWidth: number;
@@ -9,13 +10,15 @@ export interface ITextSelectionStyle {
9
10
  export declare const NORMAL_TEXT_SELECTION_PLUGIN_STYLE: ITextSelectionStyle;
10
11
  export interface ITextRangeWithStyle extends ITextRangeParam {
11
12
  style?: ITextSelectionStyle;
13
+ rangeType?: DOC_RANGE_TYPE;
12
14
  }
13
- export interface ISuccinctTextRangeParam {
15
+ export interface ISuccinctDocRangeParam {
14
16
  startOffset: number;
15
17
  endOffset: number;
16
18
  segmentId?: string;
17
19
  segmentPage?: number;
18
20
  style?: ITextSelectionStyle;
21
+ rangeType?: DOC_RANGE_TYPE;
19
22
  }
20
23
  export declare enum RANGE_DIRECTION {
21
24
  NONE = "none",
@@ -32,6 +32,9 @@ export declare class Documents extends DocComponent {
32
32
  changeSkeleton(newSkeleton: DocumentSkeleton): this;
33
33
  protected _draw(ctx: UniverRenderingContext, bounds?: IViewportInfo): void;
34
34
  draw(ctx: UniverRenderingContext, bounds?: IViewportInfo): void;
35
+ private _drawTable;
36
+ private _drawTableCell;
37
+ private _drawTableCellBorders;
35
38
  private _drawHeaderFooter;
36
39
  private _horizontalHandler;
37
40
  private _verticalHandler;
@@ -1,8 +1,9 @@
1
- import { IDocumentSkeletonPage } from '../../../../../basics/i-document-skeleton-cached';
1
+ import { Nullable } from '@univerjs/core';
2
+ import { IDocumentSkeletonPage, IDocumentSkeletonTable } from '../../../../../basics/i-document-skeleton-cached';
2
3
  import { ILayoutContext } from '../../tools';
3
4
  import { DataStreamTreeNode } from '../../../view-model/data-stream-tree-node';
4
5
  import { ISectionBreakConfig } from '../../../../../basics/interfaces';
5
6
  import { DocumentViewModel } from '../../../view-model/document-view-model';
6
7
  import { IShapedText } from './shaping';
7
8
 
8
- export declare function lineBreaking(ctx: ILayoutContext, viewModel: DocumentViewModel, shapedTextList: IShapedText[], curPage: IDocumentSkeletonPage, paragraphNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig): IDocumentSkeletonPage[];
9
+ export declare function lineBreaking(ctx: ILayoutContext, viewModel: DocumentViewModel, shapedTextList: IShapedText[], curPage: IDocumentSkeletonPage, paragraphNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, tableSkeleton: Nullable<IDocumentSkeletonTable>): IDocumentSkeletonPage[];
@@ -0,0 +1,13 @@
1
+ import { ITable } from '@univerjs/core';
2
+ import { IDocumentSkeletonPage, IDocumentSkeletonTable, ISectionBreakConfig } from '../../../../basics';
3
+ import { DataStreamTreeNode } from '../../view-model/data-stream-tree-node';
4
+ import { DocumentViewModel } from '../../view-model/document-view-model';
5
+ import { ILayoutContext } from '../tools';
6
+
7
+ export declare function createTableSkeleton(ctx: ILayoutContext, curPage: IDocumentSkeletonPage, viewModel: DocumentViewModel, tableNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig): IDocumentSkeletonTable;
8
+ export declare function getNullTableSkeleton(st: number, ed: number, table: ITable): IDocumentSkeletonTable;
9
+ export declare function getTableSliceId(tableId: string, sliceIndex: number): string;
10
+ export declare function getTableIdAndSliceIndex(tableSliceId: string): {
11
+ tableId: string;
12
+ sliceIndex: number;
13
+ };
@@ -36,6 +36,7 @@ export declare class DocumentSkeleton extends Skeleton {
36
36
  private _getPageActualWidth;
37
37
  getPageSize(): import('@univerjs/core').ISize | undefined;
38
38
  findPositionByGlyph(glyph: IDocumentSkeletonGlyph, segmentPage: number): Nullable<INodeSearch>;
39
+ findCharIndexByPosition(position: INodePosition): Nullable<number>;
39
40
  findNodePositionByCharIndex(charIndex: number, isBack?: boolean, segmentId?: string, segmentPIndex?: number): Nullable<INodePosition>;
40
41
  findNodeByCharIndex(charIndex: number, segmentId?: string, segmentPageIndex?: number): Nullable<IDocumentSkeletonGlyph>;
41
42
  findGlyphByPosition(position: Nullable<INodePosition>): IDocumentSkeletonGlyph | undefined;
@@ -1,5 +1,6 @@
1
1
  import { Nullable } from '@univerjs/core';
2
2
  import { IDocumentSkeletonDivide, IDocumentSkeletonDrawing, IDocumentSkeletonDrawingAnchor, IDocumentSkeletonLine, IDocumentSkeletonPage, LineType } from '../../../../basics/i-document-skeleton-cached';
3
+ import { IParagraphConfig } from '../../../../basics';
3
4
 
4
5
  interface ILineBoundingBox {
5
6
  lineHeight: number;
@@ -12,11 +13,11 @@ interface ILineBoundingBox {
12
13
  marginTop?: number;
13
14
  spaceBelowApply?: number;
14
15
  }
15
- export declare function createSkeletonLine(paragraphIndex: number, lineType: LineType, lineBoundingBox: ILineBoundingBox, columnWidth: number, lineIndex: number | undefined, isParagraphStart: boolean | undefined, page: IDocumentSkeletonPage, headerPage: Nullable<IDocumentSkeletonPage>, footerPage: Nullable<IDocumentSkeletonPage>): IDocumentSkeletonLine;
16
+ export declare function createSkeletonLine(paragraphIndex: number, lineType: LineType, lineBoundingBox: ILineBoundingBox, columnWidth: number, lineIndex: number | undefined, isParagraphStart: boolean | undefined, paragraphConfig: IParagraphConfig, page: IDocumentSkeletonPage, headerPage: Nullable<IDocumentSkeletonPage>, footerPage: Nullable<IDocumentSkeletonPage>): IDocumentSkeletonLine;
16
17
  export declare function calculateLineTopByDrawings(lineHeight: number | undefined, lineTop: number | undefined, page: IDocumentSkeletonPage, headerPage: Nullable<IDocumentSkeletonPage>, footerPage: Nullable<IDocumentSkeletonPage>): number;
17
18
  export declare function updateDivideInfo(divide: IDocumentSkeletonDivide, states: Partial<IDocumentSkeletonDivide>): void;
18
19
  export declare function setLineMarginBottom(line: IDocumentSkeletonLine, marginBottom: number): void;
19
20
  export declare function collisionDetection(drawing: IDocumentSkeletonDrawing, lineHeight: number, lineTop: number, columnLeft: number, columnWidth: number): boolean;
20
- export declare function getBoundingBox(angle: number, left: number, width: number, top: number, height: number): import('../../../..').IRect;
21
+ export declare function getBoundingBox(angle: number, left: number, width: number, top: number, height: number): import('../../../../basics').IRect;
21
22
  export declare function createAndUpdateBlockAnchor(paragraphIndex: number, line: IDocumentSkeletonLine, top: number, drawingAnchor?: Map<number, IDocumentSkeletonDrawingAnchor>): void;
22
23
  export {};
@@ -1,5 +1,9 @@
1
+ import { ITable } from '@univerjs/core';
1
2
  import { IDocumentSkeletonPage, ISkeletonResourceReference, BreakType } from '../../../../basics/i-document-skeleton-cached';
2
3
  import { ISectionBreakConfig } from '../../../../basics/interfaces';
4
+ import { DocumentViewModel } from '../../view-model/document-view-model';
3
5
  import { ILayoutContext } from '../tools';
6
+ import { DataStreamTreeNode } from '../../view-model/data-stream-tree-node';
4
7
 
5
8
  export declare function createSkeletonPage(ctx: ILayoutContext, sectionBreakConfig: ISectionBreakConfig, skeletonResourceReference: ISkeletonResourceReference, pageNumber?: number, breakType?: BreakType): IDocumentSkeletonPage;
9
+ export declare function createSkeletonCellPage(ctx: ILayoutContext, viewModel: DocumentViewModel, cellNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, tableConfig: ITable, row: number, col: number): IDocumentSkeletonPage;
@@ -0,0 +1,15 @@
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
+ */
@@ -51,7 +51,7 @@ export declare function getCharSpaceConfig(sectionBreakConfig: ISectionBreakConf
51
51
  export declare function updateBlockIndex(pages: IDocumentSkeletonPage[], start?: number): void;
52
52
  export declare function updateInlineDrawingCoords(ctx: ILayoutContext, pages: IDocumentSkeletonPage[]): void;
53
53
  export declare function glyphIterator(pages: IDocumentSkeletonPage[], cb: (glyph: IDocumentSkeletonGlyph, divide: IDocumentSkeletonDivide, line: IDocumentSkeletonLine, column: IDocumentSkeletonColumn, section: IDocumentSkeletonSection, page: IDocumentSkeletonPage) => void): void;
54
- export declare function lineIterator(pages: IDocumentSkeletonPage[], cb: (line: IDocumentSkeletonLine, column: IDocumentSkeletonColumn, section: IDocumentSkeletonSection, page: IDocumentSkeletonPage) => void): void;
54
+ export declare function lineIterator(pagesOrCells: (IDocumentSkeletonPage)[], cb: (line: IDocumentSkeletonLine, column: IDocumentSkeletonColumn, section: IDocumentSkeletonSection, page: IDocumentSkeletonPage) => void): void;
55
55
  export declare function columnIterator(pages: IDocumentSkeletonPage[], iteratorFunction: (column: IDocumentSkeletonColumn) => void): void;
56
56
  export declare function getPositionHorizon(positionH: IObjectPositionH, column: IDocumentSkeletonColumn, page: IDocumentSkeletonPage, objectWidth: number, isPageBreak?: boolean): number | undefined;
57
57
  export declare function getPositionVertical(positionV: IObjectPositionV, page: IDocumentSkeletonPage, lineTop: number, lineHeight: number, objectHeight: number, blockAnchorTop?: number, isPageBreak?: boolean): number | undefined;
@@ -101,4 +101,5 @@ export declare const DEFAULT_PAGE_SIZE: {
101
101
  };
102
102
  export declare function prepareSectionBreakConfig(ctx: ILayoutContext, nodeIndex: number): ISectionBreakConfig;
103
103
  export declare function resetContext(ctx: ILayoutContext): void;
104
+ export declare function mergeByV<T = unknown>(object: unknown, originObject: unknown, type: 'max' | 'min'): T;
104
105
  export {};
@@ -0,0 +1,30 @@
1
+ import { Nullable } from '@univerjs/core';
2
+ import { INodePosition, IPoint } from '../../../basics';
3
+ import { IDocumentOffsetConfig } from '../document';
4
+ import { DocumentSkeleton } from '../layout/doc-skeleton';
5
+
6
+ export declare function isValidRectRange(anchorNodePosition: INodePosition, focusNodePosition: INodePosition): boolean;
7
+ export declare function isInSameTableCell(anchorNodePosition: INodePosition, focusNodePosition: INodePosition): boolean;
8
+ export declare function compareNodePositionInTable(a: INodePosition, b: INodePosition): boolean;
9
+ interface IRectRangeNodePositions {
10
+ anchor: INodePosition;
11
+ focus: INodePosition;
12
+ }
13
+ export declare class NodePositionConvertToRectRange {
14
+ private _documentOffsetConfig;
15
+ private _docSkeleton;
16
+ private _liquid;
17
+ constructor(_documentOffsetConfig: IDocumentOffsetConfig, _docSkeleton: DocumentSkeleton);
18
+ getRangePointData(startNodePosition: INodePosition, endNodePosition: INodePosition): {
19
+ pointGroup: IPoint[][];
20
+ startRow: number;
21
+ startColumn: number;
22
+ endRow: number;
23
+ endColumn: number;
24
+ tableId: string;
25
+ } | undefined;
26
+ getNodePositionGroup(anchorNodePosition: INodePosition, focusNodePosition: INodePosition): Nullable<IRectRangeNodePositions[]>;
27
+ private _collectPositionGroup;
28
+ private _getTableRectRangeInfo;
29
+ }
30
+ export {};
@@ -1,4 +1,5 @@
1
- import { ITextRange, Nullable } from '@univerjs/core';
1
+ import { IPosition, ITextRange, Nullable } from '@univerjs/core';
2
+ import { IDocumentSkeletonCached, IDocumentSkeletonPage } from '../../../basics/i-document-skeleton-cached';
2
3
  import { INodePosition } from '../../../basics/interfaces';
3
4
  import { IPoint } from '../../../basics/vector2';
4
5
  import { DocumentSkeleton } from '../layout/doc-skeleton';
@@ -39,6 +40,11 @@ export declare function compareNodePosition(pos1: INodePosition, pos2: INodePosi
39
40
  end: INodePosition;
40
41
  };
41
42
  export declare function getOneTextSelectionRange(rangeList: ITextRange[]): Nullable<ITextRange>;
43
+ export declare function pushToPoints(position: IPosition): {
44
+ x: number;
45
+ y: number;
46
+ }[];
47
+ export declare function getPageFromPath(skeletonData: IDocumentSkeletonCached, path: (string | number)[]): Nullable<IDocumentSkeletonPage>;
42
48
  export declare class NodePositionConvertToCursor {
43
49
  private _documentOffsetConfig;
44
50
  private _docSkeleton;
@@ -56,6 +62,5 @@ export declare class NodePositionConvertToCursor {
56
62
  private _setNodePositionState;
57
63
  private _checkPreviousNodePositionState;
58
64
  private _getSelectionRuler;
59
- private _pushToPoints;
60
65
  private _selectionIterator;
61
66
  }
@@ -0,0 +1,22 @@
1
+ import { Nullable } from '@univerjs/core';
2
+ import { INodePosition, ITextSelectionStyle, RANGE_DIRECTION } from '../../../basics';
3
+
4
+ export declare enum DOC_RANGE_TYPE {
5
+ RECT = "RECT",
6
+ TEXT = "TEXT"
7
+ }
8
+ export interface IDocRange {
9
+ rangeType: DOC_RANGE_TYPE;
10
+ anchorNodePosition?: Nullable<INodePosition>;
11
+ focusNodePosition?: Nullable<INodePosition>;
12
+ style: ITextSelectionStyle;
13
+ get startOffset(): Nullable<number>;
14
+ get endOffset(): Nullable<number>;
15
+ get collapsed(): boolean;
16
+ get startNodePosition(): Nullable<INodePosition>;
17
+ get endNodePosition(): Nullable<INodePosition>;
18
+ get direction(): RANGE_DIRECTION;
19
+ isActive(): boolean;
20
+ dispose(): void;
21
+ refresh(): void;
22
+ }
@@ -0,0 +1,49 @@
1
+ import { Nullable } from '@univerjs/core';
2
+ import { INodePosition, ITextSelectionStyle, RANGE_DIRECTION } from '../../../basics';
3
+ import { ThinScene } from '../../../thin-scene';
4
+ import { Documents } from '../document';
5
+ import { DocumentSkeleton } from '../layout/doc-skeleton';
6
+ import { IDocRange, DOC_RANGE_TYPE } from './range-interface';
7
+
8
+ export declare function convertPositionsToRectRanges(scene: ThinScene, document: Documents, docSkeleton: DocumentSkeleton, anchorNodePosition: INodePosition, focusNodePosition: INodePosition, style?: ITextSelectionStyle, segmentId?: string): RectRange[];
9
+ export declare class RectRange implements IDocRange {
10
+ private _scene;
11
+ private _document;
12
+ private _docSkeleton;
13
+ anchorNodePosition: INodePosition;
14
+ focusNodePosition: INodePosition;
15
+ style: ITextSelectionStyle;
16
+ private _segmentId;
17
+ rangeType: DOC_RANGE_TYPE;
18
+ private _rangeShape;
19
+ private _current;
20
+ private _startRow;
21
+ private _startCol;
22
+ private _endRow;
23
+ private _endCol;
24
+ private _tableId;
25
+ constructor(_scene: ThinScene, _document: Documents, _docSkeleton: DocumentSkeleton, anchorNodePosition: INodePosition, focusNodePosition: INodePosition, style?: ITextSelectionStyle, _segmentId?: string);
26
+ get startOffset(): Nullable<number>;
27
+ get endOffset(): Nullable<number>;
28
+ get collapsed(): boolean;
29
+ get startRow(): number;
30
+ get startColumn(): number;
31
+ get endRow(): number;
32
+ get endColumn(): number;
33
+ get tableId(): string;
34
+ get segmentId(): string;
35
+ get spanEntireRow(): boolean;
36
+ get spanEntireColumn(): boolean;
37
+ get spanEntireTable(): boolean;
38
+ get startNodePosition(): INodePosition;
39
+ get endNodePosition(): INodePosition;
40
+ get direction(): RANGE_DIRECTION;
41
+ isActive(): boolean;
42
+ activate(): void;
43
+ deactivate(): void;
44
+ dispose(): void;
45
+ isIntersection(compareRange: RectRange): boolean;
46
+ refresh(): void;
47
+ private _updateTableInfo;
48
+ private _createOrUpdateRange;
49
+ }
@@ -0,0 +1,28 @@
1
+ import { Nullable } from '@univerjs/core';
2
+ import { IDocumentSkeletonGlyph, INodePosition, ITextSelectionStyle } from '../../../basics';
3
+ import { DocumentSkeleton } from '../layout/doc-skeleton';
4
+ import { Engine } from '../../../engine';
5
+ import { Documents } from '../document';
6
+ import { Scene } from '../../../scene';
7
+ import { RectRange } from './rect-range';
8
+ import { TextRange } from './text-range';
9
+
10
+ interface IDocRangeList {
11
+ textRanges: TextRange[];
12
+ rectRanges: RectRange[];
13
+ }
14
+ export declare function getTextRangeFromCharIndex(startOffset: number, endOffset: number, scene: Scene, document: Documents, skeleton: DocumentSkeleton, style: ITextSelectionStyle, segmentId: string, segmentPage: number): Nullable<TextRange>;
15
+ export declare function getRectRangeFromCharIndex(startOffset: number, endOffset: number, scene: Scene, document: Documents, skeleton: DocumentSkeleton, style: ITextSelectionStyle, segmentId: string, segmentPage: number): Nullable<RectRange>;
16
+ export declare function getRangeListFromCharIndex(startOffset: number, endOffset: number, scene: Scene, document: Documents, skeleton: DocumentSkeleton, style: ITextSelectionStyle, segmentId: string, segmentPage: number): Nullable<IDocRangeList>;
17
+ export declare function getRangeListFromSelection(anchorPosition: INodePosition, focusPosition: INodePosition, scene: Scene, document: Documents, skeleton: DocumentSkeleton, style: ITextSelectionStyle, segmentId: string, segmentPage: number): Nullable<IDocRangeList>;
18
+ export declare function getCanvasOffsetByEngine(engine: Nullable<Engine>): {
19
+ left: number;
20
+ top: number;
21
+ };
22
+ export declare function getParagraphInfoByGlyph(node: IDocumentSkeletonGlyph): {
23
+ st: number;
24
+ ed: number;
25
+ content: string;
26
+ nodeIndex: number;
27
+ } | undefined;
28
+ export {};
@@ -1,15 +1,16 @@
1
1
  import { Nullable } from '@univerjs/core';
2
2
  import { INodePosition } from '../../../basics/interfaces';
3
- import { ISuccinctTextRangeParam, ITextSelectionStyle, RANGE_DIRECTION } from '../../../basics/range';
3
+ import { ISuccinctDocRangeParam, ITextSelectionStyle, RANGE_DIRECTION } from '../../../basics/range';
4
4
  import { IPoint } from '../../../basics/vector2';
5
5
  import { Scene } from '../../../scene';
6
6
  import { Rect } from '../../../shape/rect';
7
7
  import { ThinScene } from '../../../thin-scene';
8
8
  import { DocumentSkeleton } from '../layout/doc-skeleton';
9
9
  import { Documents } from '../document';
10
+ import { IDocRange, DOC_RANGE_TYPE } from './range-interface';
10
11
 
11
12
  export declare const TEXT_RANGE_LAYER_INDEX = 3;
12
- export declare function cursorConvertToTextRange(scene: Scene, range: ISuccinctTextRangeParam, docSkeleton: DocumentSkeleton, document: Documents): Nullable<TextRange>;
13
+ export declare function cursorConvertToTextRange(scene: Scene, range: ISuccinctDocRangeParam, docSkeleton: DocumentSkeleton, document: Documents): Nullable<TextRange>;
13
14
  export declare function getAnchorBounding(pointsGroup: IPoint[][]): {
14
15
  left: number;
15
16
  top: number;
@@ -22,19 +23,21 @@ export declare function getLineBounding(pointsGroup: IPoint[][]): {
22
23
  top: number;
23
24
  bottom: number;
24
25
  }[];
25
- export declare class TextRange {
26
+ export declare class TextRange implements IDocRange {
26
27
  private _scene;
27
28
  private _document;
28
29
  private _docSkeleton;
29
30
  anchorNodePosition?: Nullable<INodePosition>;
30
31
  focusNodePosition?: Nullable<INodePosition>;
31
32
  style: ITextSelectionStyle;
33
+ private _segmentId;
34
+ rangeType: DOC_RANGE_TYPE;
32
35
  private _current;
33
36
  private _rangeShape;
34
37
  private _anchorShape;
35
38
  private _cursorList;
36
39
  private _anchorBlinkTimer;
37
- constructor(_scene: ThinScene, _document: Documents, _docSkeleton: DocumentSkeleton, anchorNodePosition?: Nullable<INodePosition>, focusNodePosition?: Nullable<INodePosition>, style?: ITextSelectionStyle);
40
+ constructor(_scene: ThinScene, _document: Documents, _docSkeleton: DocumentSkeleton, anchorNodePosition?: Nullable<INodePosition>, focusNodePosition?: Nullable<INodePosition>, style?: ITextSelectionStyle, _segmentId?: string);
38
41
  private _anchorBlink;
39
42
  get startOffset(): number | undefined;
40
43
  get endOffset(): number | undefined;
@@ -42,6 +45,7 @@ export declare class TextRange {
42
45
  get startNodePosition(): INodePosition | null;
43
46
  get endNodePosition(): Nullable<INodePosition>;
44
47
  get direction(): RANGE_DIRECTION;
48
+ get segmentId(): string;
45
49
  getAbsolutePosition(): {
46
50
  left: number;
47
51
  top: number;
@@ -1,21 +1,18 @@
1
1
  import { Nullable, ILogService, RxDisposable } from '@univerjs/core';
2
2
  import { Observable } from 'rxjs';
3
3
  import { IMouseEvent, IPointerEvent } from '../../../basics/i-events';
4
- import { INodePosition } from '../../../basics/interfaces';
5
- import { ISuccinctTextRangeParam, ITextRangeWithStyle, ITextSelectionStyle, RANGE_DIRECTION } from '../../../basics/range';
6
- import { Engine } from '../../../engine';
4
+ import { INodeInfo, INodePosition } from '../../../basics/interfaces';
5
+ import { ISuccinctDocRangeParam, ITextRangeWithStyle, ITextSelectionStyle, RANGE_DIRECTION } from '../../../basics/range';
7
6
  import { Scene } from '../../../scene';
8
7
  import { Viewport } from '../../../viewport';
9
- import { DocumentSkeleton } from '../layout/doc-skeleton';
8
+ import { DocumentSkeleton, IFindNodeRestrictions } from '../layout/doc-skeleton';
10
9
  import { Documents } from '../document';
11
10
  import { TextRange } from './text-range';
11
+ import { RectRange } from './rect-range';
12
12
 
13
- export declare function getCanvasOffsetByEngine(engine: Nullable<Engine>): {
14
- left: number;
15
- top: number;
16
- };
17
13
  export interface ITextSelectionInnerParam {
18
14
  textRanges: TextRange[];
15
+ rectRanges: RectRange[];
19
16
  segmentId: string;
20
17
  isEditing: boolean;
21
18
  style: ITextSelectionStyle;
@@ -58,8 +55,8 @@ export interface ITextSelectionRenderManager {
58
55
  getSegmentPage(): number;
59
56
  setStyle(style: ITextSelectionStyle): void;
60
57
  resetStyle(): void;
61
- removeAllTextRanges(): void;
62
- addTextRanges(ranges: ISuccinctTextRangeParam[], isEditing?: boolean, options?: {
58
+ removeAllRanges(): void;
59
+ addDocRanges(ranges: ISuccinctDocRangeParam[], isEditing?: boolean, options?: {
63
60
  [key: string]: boolean;
64
61
  }): void;
65
62
  sync(): void;
@@ -74,7 +71,7 @@ export interface ITextSelectionRenderManager {
74
71
  dispose(): void;
75
72
  handleDblClick(evt: IPointerEvent | IMouseEvent): void;
76
73
  handleTripleClick(evt: IPointerEvent | IMouseEvent): void;
77
- eventTrigger(evt: IPointerEvent | IMouseEvent): void;
74
+ onPointDown(evt: IPointerEvent | IMouseEvent): void;
78
75
  setCursorManually(evtOffsetX: number, evtOffsetY: number): void;
79
76
  }
80
77
  export interface IEditorInputConfig {
@@ -113,9 +110,12 @@ export declare class TextSelectionRenderManager extends RxDisposable implements
113
110
  private _inputParent;
114
111
  private _input;
115
112
  private _scrollTimers;
116
- private _viewportScrollX;
117
- private _viewportScrollY;
118
113
  private _rangeList;
114
+ private _rangeListCache;
115
+ private _rectRangeList;
116
+ private _rectRangeListCache;
117
+ private _anchorNodePosition;
118
+ private _focusNodePosition;
119
119
  private _currentSegmentId;
120
120
  private _currentSegmentPage;
121
121
  private _selectionStyle;
@@ -140,7 +140,7 @@ export declare class TextSelectionRenderManager extends RxDisposable implements
140
140
  resetStyle(): void;
141
141
  enableSelection(): void;
142
142
  disableSelection(): void;
143
- addTextRanges(ranges: ISuccinctTextRangeParam[], isEditing?: boolean, options?: {
143
+ addDocRanges(ranges: ISuccinctDocRangeParam[], isEditing?: boolean, options?: {
144
144
  [key: string]: boolean;
145
145
  }): void;
146
146
  setCursorManually(evtOffsetX: number, evtOffsetY: number): void;
@@ -155,23 +155,31 @@ export declare class TextSelectionRenderManager extends RxDisposable implements
155
155
  changeRuntime(docSkeleton: DocumentSkeleton, scene: Scene, document: Documents): void;
156
156
  handleDblClick(evt: IPointerEvent | IMouseEvent): void;
157
157
  handleTripleClick(evt: IPointerEvent | IMouseEvent): void;
158
- eventTrigger(evt: IPointerEvent | IMouseEvent): void;
159
- removeAllTextRanges(): void;
158
+ onPointDown(evt: IPointerEvent | IMouseEvent): void;
159
+ removeAllRanges(): void;
160
160
  private _setSystemHighlightColorToStyle;
161
161
  private _getAllTextRanges;
162
+ private _getAllRectRanges;
162
163
  private _getActiveRange;
163
- private _add;
164
164
  private _getActiveRangeInstance;
165
165
  dispose(): void;
166
166
  private _initDOM;
167
167
  private _initInput;
168
168
  private _getNodePosition;
169
- private _interactTextRange;
169
+ private _interactTextRanges;
170
+ private _interactRectRanges;
171
+ private _removeAllRanges;
172
+ private _removeAllCacheRanges;
170
173
  private _removeAllTextRanges;
174
+ private _removeAllRectRanges;
171
175
  private _deactivateAllTextRanges;
176
+ private _deactivateAllRectRanges;
177
+ private _addTextRangesToCache;
172
178
  private _addTextRange;
179
+ private _addRectRangesToCache;
180
+ private _addRectRanges;
173
181
  private _updateTextRangeAnchorPosition;
174
- private _updateActiveRangeFocusPosition;
182
+ private _updateActiveRangePosition;
175
183
  private _isEmpty;
176
184
  private _getCanvasOffset;
177
185
  private _updateInputPosition;
@@ -180,7 +188,7 @@ export declare class TextSelectionRenderManager extends RxDisposable implements
180
188
  private _initInputEvents;
181
189
  private _eventHandle;
182
190
  private _getTransformCoordForDocumentOffset;
183
- private _findNodeByCoord;
191
+ findNodeByCoord(evtOffsetX: number, evtOffsetY: number, restrictions: IFindNodeRestrictions): Nullable<INodeInfo>;
184
192
  private _getNodeIndex;
185
193
  private _detachEvent;
186
194
  private _activeSelectionRefresh;
@@ -10,6 +10,7 @@ export declare enum DocumentEditArea {
10
10
  HEADER = "HEADER",
11
11
  FOOTER = "FOOTER"
12
12
  }
13
+ export declare function parseDataStreamToTree(dataStream: string): DataStreamTreeNode[];
13
14
  export declare class DocumentViewModel implements IDisposable {
14
15
  private _documentDataModel;
15
16
  private _interceptor;
@@ -28,12 +29,13 @@ export declare class DocumentViewModel implements IDisposable {
28
29
  constructor(_documentDataModel: DocumentDataModel);
29
30
  registerCustomRangeInterceptor(interceptor: ICustomRangeInterceptor): IDisposable;
30
31
  dispose(): void;
31
- selfPlus(len: number, index: number): void;
32
+ selfPlus(_len: number, _index: number): void;
32
33
  getEditArea(): DocumentEditArea;
33
34
  setEditArea(editArea: DocumentEditArea): void;
34
35
  getPositionInParent(): number;
35
36
  getLastIndex(): number;
36
37
  getBody(): IDocumentBody | undefined;
38
+ getSnapshot(): import('@univerjs/core').IDocumentData;
37
39
  getDataModel(): DocumentDataModel;
38
40
  getSelfOrHeaderFooterViewModel(segmentId?: string): DocumentViewModel;
39
41
  reset(documentDataModel: DocumentDataModel): void;
@@ -43,7 +45,7 @@ export declare class DocumentViewModel implements IDisposable {
43
45
  getText(): string;
44
46
  resetCache(): void;
45
47
  getSectionBreak(index: number): import('@univerjs/core').ISectionBreak | undefined;
46
- getParagraph(index: number): import('@univerjs/core').IParagraph | undefined;
48
+ getParagraph(index: number, fromStart?: boolean): import('@univerjs/core').IParagraph | undefined;
47
49
  getTextRunRange(startIndex: number | undefined, endIndex: number): ITextRun[];
48
50
  /**
49
51
  * textRun matches according to the selection. If the text length is 10, then the range of textRun is from 0 to 11.
@@ -56,9 +58,6 @@ export declare class DocumentViewModel implements IDisposable {
56
58
  getCustomRange(index: number): Nullable<ICustomRangeForInterceptor>;
57
59
  getCustomDecorationRaw(index: number): import('@univerjs/core').ICustomDecoration | undefined;
58
60
  getCustomDecoration(index: number): Nullable<ICustomDecorationForInterceptor>;
59
- protected _transformToTree(dataStream: string): DataStreamTreeNode[];
60
- private _processPreviousNodesUntil;
61
- private _batchParent;
62
61
  private _buildHeaderFooterViewModel;
63
62
  private _getParagraphByIndex;
64
63
  private _forEachTop;