@univerjs/engine-render 1.1.0 → 1.3.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.
@@ -13,14 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { ITabStop } from '@univerjs/core';
16
+ import type { ITabStop, ITextStyle } 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
- export declare function layoutParagraph(ctx: ILayoutContext, glyphGroup: IDocumentSkeletonGlyph[], pages: IDocumentSkeletonPage[], sectionBreakConfig: ISectionBreakConfig, paragraphConfig: IParagraphConfig, isParagraphFirstShapedText: boolean, breakPointType?: BreakPointType, renderBullet?: boolean, startNewLine?: boolean): IDocumentSkeletonPage[];
23
+ export declare function layoutParagraph(ctx: ILayoutContext, glyphGroup: IDocumentSkeletonGlyph[], pages: IDocumentSkeletonPage[], sectionBreakConfig: ISectionBreakConfig, paragraphConfig: IParagraphConfig, isParagraphFirstShapedText: boolean, breakPointType?: BreakPointType, renderBullet?: boolean, startNewLine?: boolean, markerTextStyle?: Pick<ITextStyle, 'cl' | 'ul'>): IDocumentSkeletonPage[];
24
24
  declare function _adjustExplicitTabStop(divide: IDocumentSkeletonDivide, followingGlyphs: IDocumentSkeletonGlyph[], paragraphConfig: IParagraphConfig, tabStops?: ITabStop[] | undefined): void;
25
25
  declare function __getWrapTablePosition(table: IDocumentSkeletonTable, column: IDocumentSkeletonColumn, lineTop: number, lineHeight: number, drawingAnchorTop?: number): {
26
26
  left: number;
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { INumberUnit, ITable, Nullable } from '@univerjs/core';
17
+ import { TableAlignmentType } from '@univerjs/core';
17
18
  import type { IDocumentSkeletonPage, IDocumentSkeletonRow, IDocumentSkeletonTable } from '../../../../basics/i-document-skeleton-cached';
18
19
  import type { ISectionBreakConfig } from '../../../../basics/interfaces';
19
20
  import type { DataStreamTreeNode } from '../../view-model/data-stream-tree-node';
@@ -21,7 +22,6 @@ import type { DocumentViewModel } from '../../view-model/document-view-model';
21
22
  import type { DocumentFootnoteLayout } from '../footnote-layout';
22
23
  import type { ICellSkeletonBuildState } from '../model/page';
23
24
  import type { ILayoutContext } from '../tools';
24
- import { TableAlignmentType } from '@univerjs/core';
25
25
  export interface ITableSkeletonBuildState {
26
26
  ctx: ILayoutContext;
27
27
  curPage: IDocumentSkeletonPage;
@@ -82,7 +82,7 @@ export declare function stepTableSkeletonsBuild(state: ISlicedTableSkeletonBuild
82
82
  export declare function cachePrecomputedSlicedTableSkeletons(ctx: ILayoutContext, tableNode: DataStreamTreeNode, availableHeight: number, result: ISlicedTableSkeletonParams): void;
83
83
  export declare function createTableSkeletons(ctx: ILayoutContext, curPage: IDocumentSkeletonPage, viewModel: DocumentViewModel, tableNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, availableHeight: number): ISlicedTableSkeletonParams;
84
84
  export declare function resolveTableLayoutColumns(table: ITable, availableWidth: number, traditional?: boolean): ITable;
85
- export declare function getTableLeft(pageWidth: number, tableWidth: number, align: TableAlignmentType, indent?: INumberUnit): number;
85
+ export declare function getTableLeft(pageWidth: number, tableWidth: number, align: TableAlignmentType, indent?: INumberUnit, allowMarginOverflow?: boolean): number;
86
86
  export declare function getNullTableSkeleton(st: number, ed: number, table: ITable): IDocumentSkeletonTable;
87
87
  export declare function getTableSliceId(tableId: string, sliceIndex: number): string;
88
88
  export declare function getTableIdAndSliceIndex(tableSliceId: string): {
@@ -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;
@@ -82,6 +84,7 @@ export declare class DocumentSkeleton extends Skeleton {
82
84
  * PS: This method has significant impact on performance.
83
85
  */
84
86
  calculate(bounds?: IViewportInfo): void;
87
+ private _getHeadingCollapseSignature;
85
88
  startIncrementalLayout(options?: {
86
89
  reason?: DocumentLayoutReason;
87
90
  anchor?: number;
@@ -90,6 +93,8 @@ export declare class DocumentSkeleton extends Skeleton {
90
93
  modernPageWidth?: number;
91
94
  modernHorizontalMargin?: number;
92
95
  bounds?: IViewportInfo;
96
+ /** Keep the current Modern viewport until a visibility change fills its replacement. */
97
+ minimumPublicationHeight?: number;
93
98
  reuseUnaffectedTail?: boolean;
94
99
  /** The caller proved this edit only changes offset-preserving render metadata. */
95
100
  allowMetadataOnlyStructuralTailReuse?: boolean;
@@ -184,7 +184,7 @@ export declare function getFontConfigFromLastGlyph(glyph: IDocumentSkeletonGlyph
184
184
  snapToGrid: BooleanNumber;
185
185
  pageWidth: number;
186
186
  };
187
- export declare function getFontCreateConfig(index: number, viewModel: DocumentViewModel, paragraphNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, paragraph: IDocumentLayoutParagraph): IFontCreateConfig;
187
+ export declare function getFontCreateConfig(index: number, viewModel: DocumentViewModel, paragraphNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, paragraph: IDocumentLayoutParagraph, includeCustomRangeStyle?: boolean): IFontCreateConfig;
188
188
  export declare function getCustomRangeGlyphWidth(index: number, viewModel: DocumentViewModel, paragraphNode: DataStreamTreeNode, config: IFontCreateConfig): number | undefined;
189
189
  /**
190
190
  * Returns whether a custom range should occupy one measured glyph in the
@@ -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[];