@univerjs/engine-render 1.0.4 → 1.2.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.
@@ -24,6 +24,7 @@ export declare function getParagraphByGlyph(glyph: Nullable<IDocumentSkeletonGly
24
24
  paragraphEnd: number;
25
25
  startIndex: number;
26
26
  paragraphId: string;
27
+ headingCollapsed?: boolean;
27
28
  styleId?: string;
28
29
  paragraphStyle?: import("@univerjs/core").IParagraphStyle;
29
30
  bullet?: import("@univerjs/core").IBullet;
@@ -42,6 +42,7 @@ export interface ISkeletonResourceReference {
42
42
  drawingAnchor?: Map<string, Map<number, IDocumentSkeletonDrawingAnchor>>;
43
43
  }
44
44
  export interface IDocumentSkeletonDrawingAnchor {
45
+ left?: number;
45
46
  elements: IDocumentSkeletonLine[];
46
47
  paragraphIndex: number;
47
48
  top: number;
@@ -318,6 +319,9 @@ export interface IDocumentSkeletonDrawing {
318
319
  initialState: boolean;
319
320
  drawingOrigin: IDocDrawingBase;
320
321
  columnLeft: number;
322
+ blockAnchorLeft?: number;
323
+ normalizeTraditionalColumnAnchor?: boolean;
324
+ pageAnchorLeft?: number;
321
325
  isPageBreak: boolean;
322
326
  lineTop: number;
323
327
  lineHeight: number;
@@ -61,6 +61,7 @@ export interface IFontLocale {
61
61
  defaultFontSize: number;
62
62
  }
63
63
  export interface IDocsConfig extends IReferenceSource, IDocumentLayout {
64
+ lineGap?: number;
64
65
  localeService: LocaleService;
65
66
  documentTextStyle?: IDocumentLayoutTextStyle;
66
67
  documentCompatibilityPolicy?: IDocumentCompatibilityPolicy;
@@ -138,6 +139,8 @@ export interface IFontCreateConfig {
138
139
  }
139
140
  export interface INodeInfo {
140
141
  node: IDocumentSkeletonGlyph;
142
+ /** The pointer is inside the glyph's content box, excluding line spacing and paragraph margins. */
143
+ isInsideGlyph?: boolean;
141
144
  ratioX: number;
142
145
  ratioY: number;
143
146
  segmentId: string;
@@ -57,6 +57,7 @@ export declare class Documents extends DocComponent {
57
57
  getOffsetConfig(): IDocumentOffsetConfig;
58
58
  getEngine(): Nullable<import("../..").Engine>;
59
59
  isHit(coord: Vector2): boolean;
60
+ private _isHitTable;
60
61
  changeSkeleton(newSkeleton: DocumentSkeleton): this;
61
62
  /** Editor-only emphasis; standalone and export renderers retain full document colors. */
62
63
  setInactiveAreaOpacity(opacity: number): void;
@@ -14,10 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { ITabStop } from '@univerjs/core';
17
+ import { BooleanNumber, GridType, SpacingRule } from '@univerjs/core';
17
18
  import type { IDocumentSkeletonColumn, IDocumentSkeletonDivide, IDocumentSkeletonDrawing, IDocumentSkeletonGlyph, IDocumentSkeletonLine, IDocumentSkeletonPage, IDocumentSkeletonSection, IDocumentSkeletonTable } from '../../../../../basics/i-document-skeleton-cached';
18
19
  import type { IParagraphConfig, IParagraphTableCache, ISectionBreakConfig } from '../../../../../basics/interfaces';
19
20
  import type { IFloatObject, ILayoutContext } from '../../tools';
20
- import { BooleanNumber, GridType, SpacingRule } from '@univerjs/core';
21
21
  import { BreakPointType } from '../../line-breaker/break';
22
22
  declare function isGlyphGroupBeyondDivideWidth(glyphGroup: IDocumentSkeletonGlyph[], offsetLeft: number, divideWidth: number, hangingPunctuation?: boolean, precedingGlyphs?: IDocumentSkeletonGlyph[], preserveWordSpacing?: boolean, lineWrapTolerance?: number, includeParagraphMark?: boolean, justifyWordSpacing?: boolean): boolean;
23
23
  export declare function layoutParagraph(ctx: ILayoutContext, glyphGroup: IDocumentSkeletonGlyph[], pages: IDocumentSkeletonPage[], sectionBreakConfig: ISectionBreakConfig, paragraphConfig: IParagraphConfig, isParagraphFirstShapedText: boolean, breakPointType?: BreakPointType, renderBullet?: boolean, startNewLine?: boolean): IDocumentSkeletonPage[];
@@ -47,6 +47,6 @@ export declare function getLineHeightMetrics(glyphLineHeight: number, paragraphL
47
47
  contentHeight: number;
48
48
  lineSpacingApply: number;
49
49
  };
50
- export declare function updateInlineDrawingPosition(line: IDocumentSkeletonLine, paragraphInlineSkeDrawings?: Map<string, IDocumentSkeletonDrawing>, unitId?: string, blockAnchorTop?: number, paragraphNonInlineSkeDrawings?: Map<string, IDocumentSkeletonDrawing>, documentCompatibilityPolicy?: IParagraphConfig['documentCompatibilityPolicy']): void;
50
+ export declare function updateInlineDrawingPosition(line: IDocumentSkeletonLine, paragraphInlineSkeDrawings?: Map<string, IDocumentSkeletonDrawing>, unitId?: string, blockAnchorTop?: number, paragraphNonInlineSkeDrawings?: Map<string, IDocumentSkeletonDrawing>, documentCompatibilityPolicy?: IParagraphConfig['documentCompatibilityPolicy'], blockAnchorLeft?: number, normalizeTraditionalColumnAnchor?: boolean): void;
51
51
  declare function __checkPageBreak(column: IDocumentSkeletonColumn): boolean;
52
52
  export {};
@@ -29,3 +29,4 @@ export declare function dealWithSection(ctx: ILayoutContext, viewModel: Document
29
29
  nextParagraphIndex: number;
30
30
  complete: boolean;
31
31
  };
32
+ export declare function rollbackSectionPages(paragraphIndex: number, allCurrentSkeletonPages: IDocumentSkeletonPage[]): void;
@@ -25,11 +25,12 @@ export declare class DocSimpleSkeleton {
25
25
  private _warp;
26
26
  private _width;
27
27
  private _height;
28
+ private _lineGap;
28
29
  private _lineBreaker;
29
30
  private _lines;
30
31
  private _dirty;
31
32
  private _lastBreakLength;
32
- constructor(_text: string, _fontStyle: string, _warp: boolean, _width: number, _height: number);
33
+ constructor(_text: string, _fontStyle: string, _warp: boolean, _width: number, _height: number, _lineGap?: number);
33
34
  calculate(): ILineInfo[];
34
35
  getLines(): ILineInfo[];
35
36
  getTotalHeight(): number;
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { LocaleService, Nullable } from '@univerjs/core';
17
+ import { Skeleton } from '@univerjs/core';
17
18
  import type { IDocumentSkeletonCached, IDocumentSkeletonGlyph, IDocumentSkeletonPage } from '../../../basics/i-document-skeleton-cached';
18
19
  import type { INodeInfo, INodePosition, INodeSearch } from '../../../basics/interfaces';
19
20
  import type { IViewportInfo, Vector2 } from '../../../basics/vector2';
@@ -21,7 +22,6 @@ import type { DocumentViewModel } from '../view-model/document-view-model';
21
22
  import type { IDocumentLayoutGeometryPublication, IDocumentLayoutPagePublication } from './document-layout-publication';
22
23
  import type { DocumentLayoutReason, IDocumentLayoutApplyResult, IDocumentLayoutInvalidation, IDocumentLayoutPageRange, IDocumentLayoutProgress, IDocumentLayoutProtectedRange } from './document-layout-types';
23
24
  import type { IDocumentPaginationMetrics } from './tools';
24
- import { Skeleton } from '@univerjs/core';
25
25
  import { PageLayoutType } from '../../../basics/i-document-skeleton-cached';
26
26
  import { DocumentEditArea } from '../view-model/document-view-model';
27
27
  export declare enum DocumentSkeletonState {
@@ -55,6 +55,8 @@ export declare class DocumentSkeleton extends Skeleton {
55
55
  private _paginationMetrics;
56
56
  private _completedPageCount;
57
57
  private _lastCompleteSkeletonData;
58
+ private _completedHeadingCollapseSignature;
59
+ private _publishedHeadingCollapseSignature;
58
60
  private _pendingInvalidationAnchor;
59
61
  private _layoutGeneration;
60
62
  private _activeLayout;
@@ -66,11 +68,14 @@ export declare class DocumentSkeleton extends Skeleton {
66
68
  private readonly _isolateIncrementalPublications;
67
69
  private _modernPageWidth;
68
70
  private _modernHorizontalMargin;
71
+ private readonly _lineGap;
69
72
  constructor(_docViewModel: DocumentViewModel, localeService: LocaleService, options?: {
70
73
  isolateIncrementalPublications?: boolean;
74
+ lineGap?: number;
71
75
  });
72
76
  static create(docViewModel: DocumentViewModel, localeService: LocaleService, options?: {
73
77
  isolateIncrementalPublications?: boolean;
78
+ lineGap?: number;
74
79
  }): DocumentSkeleton;
75
80
  dispose(): void;
76
81
  getViewModel(): DocumentViewModel;
@@ -79,6 +84,7 @@ export declare class DocumentSkeleton extends Skeleton {
79
84
  * PS: This method has significant impact on performance.
80
85
  */
81
86
  calculate(bounds?: IViewportInfo): void;
87
+ private _getHeadingCollapseSignature;
82
88
  startIncrementalLayout(options?: {
83
89
  reason?: DocumentLayoutReason;
84
90
  anchor?: number;
@@ -87,6 +93,8 @@ export declare class DocumentSkeleton extends Skeleton {
87
93
  modernPageWidth?: number;
88
94
  modernHorizontalMargin?: number;
89
95
  bounds?: IViewportInfo;
96
+ /** Keep the current Modern viewport until a visibility change fills its replacement. */
97
+ minimumPublicationHeight?: number;
90
98
  reuseUnaffectedTail?: boolean;
91
99
  /** The caller proved this edit only changes offset-preserving render metadata. */
92
100
  allowMetadataOnlyStructuralTailReuse?: boolean;
@@ -28,7 +28,7 @@ export declare function createNullCellPage(ctx: ILayoutContext, sectionBreakConf
28
28
  };
29
29
  export declare function getCellBorderWidth(border: ITableCellBorder | undefined): number;
30
30
  export declare function getRowBorderInset(row: ITableRow, edge: 'borderTop' | 'borderBottom', tableBoundary?: boolean): number;
31
- export declare function createSkeletonCellPages(ctx: ILayoutContext, viewModel: DocumentViewModel, cellNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, tableConfig: ITable, row: number, col: number, availableHeight?: number, maxCellPageHeight?: number, cellPageHeights?: readonly number[]): IDocumentSkeletonPage[];
31
+ export declare function createSkeletonCellPages(parentContext: ILayoutContext, viewModel: DocumentViewModel, cellNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, tableConfig: ITable, row: number, col: number, availableHeight?: number, maxCellPageHeight?: number, cellPageHeights?: readonly number[]): IDocumentSkeletonPage[];
32
32
  export interface ICellSkeletonBuildState {
33
33
  ctx: ILayoutContext;
34
34
  viewModel: DocumentViewModel;
@@ -44,7 +44,7 @@ export interface ICellSkeletonBuildState {
44
44
  complete: boolean;
45
45
  requiresSyncFallback: boolean;
46
46
  }
47
- export declare function startSkeletonCellPagesBuild(ctx: ILayoutContext, viewModel: DocumentViewModel, cellNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, tableConfig: ITable, row: number, col: number, availableHeight?: number, maxCellPageHeight?: number, cellPageHeights?: readonly number[]): ICellSkeletonBuildState;
47
+ export declare function startSkeletonCellPagesBuild(parentContext: ILayoutContext, viewModel: DocumentViewModel, cellNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, tableConfig: ITable, row: number, col: number, availableHeight?: number, maxCellPageHeight?: number, cellPageHeights?: readonly number[]): ICellSkeletonBuildState;
48
48
  export declare function stepSkeletonCellPagesBuild(state: ICellSkeletonBuildState): boolean;
49
49
  export declare function expandCellPageHeightForInlineDrawings(pages: IDocumentSkeletonPage[]): void;
50
50
  export declare function expandCellPageHeightForFlowTables(pages: IDocumentSkeletonPage[]): void;
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import type { DocumentDataModel, ICustomBlock, ICustomDecorationForInterceptor, ICustomRangeForInterceptor, ICustomTable, IDisposable, ITable, JSONXActions, Nullable } from '@univerjs/core';
17
17
  import type { IDocumentLayoutBody, IDocumentLayoutColumnGroup, IDocumentLayoutCustomColumnGroup, IDocumentLayoutParagraph, IDocumentLayoutSectionBreak, IDocumentLayoutSnapshot, IDocumentLayoutTextRun } from '../document-layout-presentation';
18
+ import type { IHeadingSection } from './heading-sections';
18
19
  import { DataStreamTreeNode } from './data-stream-tree-node';
19
20
  interface ITableNodeCache {
20
21
  table: DataStreamTreeNode;
@@ -56,6 +57,8 @@ export declare class DocumentViewModel implements IDisposable {
56
57
  private _treeNodes;
57
58
  private _treeNodesByStartIndex;
58
59
  private _plainTopLevelParagraphNodes;
60
+ private _headingSections;
61
+ private _collapsedHeadingSections;
59
62
  private _metadataCachesDirty;
60
63
  private _textRunsOrderedAndDisjoint;
61
64
  private _paragraphsOrdered;
@@ -83,6 +86,8 @@ export declare class DocumentViewModel implements IDisposable {
83
86
  getEditArea(): DocumentEditArea;
84
87
  setEditArea(editArea: DocumentEditArea): void;
85
88
  getChildren(): DataStreamTreeNode[];
89
+ getHeadingSections(): readonly IHeadingSection[];
90
+ getCollapsedHeadingAtOffset(offset: number): IHeadingSection | undefined;
86
91
  getBody(): IDocumentLayoutBody | undefined;
87
92
  getSnapshot(): IDocumentLayoutSnapshot;
88
93
  getDataModel(): DocumentDataModel;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { IParagraph } from '@univerjs/core';
17
+ import type { DataStreamTreeNode } from './data-stream-tree-node';
18
+ export interface IHeadingSection {
19
+ paragraphId: string;
20
+ paragraphIndex: number;
21
+ startOffset: number;
22
+ endOffset: number;
23
+ collapsed: boolean;
24
+ }
25
+ /** Each table cell and modern column has its own heading hierarchy. */
26
+ export declare function getHeadingSections(sections: readonly DataStreamTreeNode[], getParagraph: (index: number) => IParagraph | undefined): IHeadingSection[];
@@ -71,7 +71,7 @@ export declare class Font extends SheetExtension {
71
71
  * @param renderFontContext
72
72
  * @param row
73
73
  * @param col
74
- * @param fontCache
74
+ * @param padding
75
75
  */
76
76
  private _clipByRenderBounds;
77
77
  private _renderText;
@@ -86,6 +86,7 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
86
86
  private _gridlinesColor;
87
87
  private _defaultGridlinesColor;
88
88
  private _scene;
89
+ readonly textLineGap: number;
89
90
  constructor(worksheet: Worksheet, _styles: Styles, _localeService: LocaleService, _contextService: IContextService, _configService: IConfigService, _injector: Injector);
90
91
  registerGetCellHeight(): void;
91
92
  setScene(scene: Scene): void;
@@ -25,6 +25,7 @@ export interface ITextProps extends IShapeProps {
25
25
  text: string;
26
26
  fontStyle: string;
27
27
  warp?: boolean;
28
+ lineGap?: number;
28
29
  hAlign?: HorizontalAlign;
29
30
  vAlign?: VerticalAlign;
30
31
  color?: Nullable<string>;
@@ -40,6 +41,7 @@ export declare class Text extends Shape<ITextProps> {
40
41
  text: string;
41
42
  fontStyle: string;
42
43
  warp: boolean;
44
+ lineGap: number;
43
45
  hAlign: HorizontalAlign;
44
46
  vAlign: VerticalAlign;
45
47
  skeleton: DocSimpleSkeleton;