@univerjs/engine-render 1.0.3 → 1.1.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.
@@ -36,12 +36,13 @@ export interface IDocumentSkeletonParagraphBorders {
36
36
  borderBetween?: IParagraphBorder;
37
37
  }
38
38
  export interface ISkeletonResourceReference {
39
- skeHeaders: Map<string, Map<number, IDocumentSkeletonHeaderFooter>>;
40
- skeFooters: Map<string, Map<number, IDocumentSkeletonHeaderFooter>>;
39
+ skeHeaders: Map<string, Map<number | string, IDocumentSkeletonHeaderFooter>>;
40
+ skeFooters: Map<string, Map<number | string, IDocumentSkeletonHeaderFooter>>;
41
41
  skeListLevel?: Map<string, IParagraphList[][]>;
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;
@@ -67,6 +68,10 @@ export interface IDocumentSkeletonPage {
67
68
  sections: IDocumentSkeletonSection[];
68
69
  headerId: string;
69
70
  footerId: string;
71
+ /** Per-page field geometry; plain stories keep the legacy width cache key. */
72
+ fieldsResolved?: boolean;
73
+ headerLayoutKey?: string;
74
+ footerLayoutKey?: string;
70
75
  pageWidth: number;
71
76
  pageHeight: number;
72
77
  pageOrient: PageOrientType;
@@ -314,6 +319,9 @@ export interface IDocumentSkeletonDrawing {
314
319
  initialState: boolean;
315
320
  drawingOrigin: IDocDrawingBase;
316
321
  columnLeft: number;
322
+ blockAnchorLeft?: number;
323
+ normalizeTraditionalColumnAnchor?: boolean;
324
+ pageAnchorLeft?: number;
317
325
  isPageBreak: boolean;
318
326
  lineTop: number;
319
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;
@@ -121,8 +122,8 @@ export interface IParagraphConfig {
121
122
  paragraphStyle?: IDocumentLayoutParagraphStyle;
122
123
  borderTopSpace?: number;
123
124
  borderBottomSpace?: number;
124
- skeHeaders: Map<string, Map<number, IDocumentSkeletonHeaderFooter>>;
125
- skeFooters: Map<string, Map<number, IDocumentSkeletonHeaderFooter>>;
125
+ skeHeaders: Map<string, Map<number | string, IDocumentSkeletonHeaderFooter>>;
126
+ skeFooters: Map<string, Map<number | string, IDocumentSkeletonHeaderFooter>>;
126
127
  pDrawingAnchor?: Map<number, IDocumentSkeletonDrawingAnchor>;
127
128
  }
128
129
  export interface IFontCreateConfig {
@@ -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;
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { ICustomRange, IDisposable, Nullable } from '@univerjs/core';
17
- import type { IDocumentSkeletonGlyph, IDocumentSkeletonPage, IDocumentSkeletonSection } from '../../basics/i-document-skeleton-cached';
16
+ import type { IDisposable, Nullable } from '@univerjs/core';
17
+ import type { IDocumentSkeletonPage, IDocumentSkeletonSection } from '../../basics/i-document-skeleton-cached';
18
18
  import type { Transform } from '../../basics/transform';
19
19
  import type { IViewportInfo } from '../../basics/vector2';
20
20
  import type { UniverRenderingContext } from '../../context';
@@ -23,7 +23,6 @@ import type { DocumentSkeleton } from './layout/doc-skeleton';
23
23
  import { Vector2 } from '../../basics/vector2';
24
24
  import { DocComponent } from './doc-component';
25
25
  import './extensions';
26
- export declare function resolveHeaderFooterFieldGlyph(glyph: IDocumentSkeletonGlyph, startIndex: number, endIndex: number, customRanges: ICustomRange[], pageNumber: number, pageCount: number): IDocumentSkeletonGlyph;
27
26
  export interface IPageRenderConfig {
28
27
  page: IDocumentSkeletonPage;
29
28
  pageLeft: number;
@@ -58,6 +57,7 @@ export declare class Documents extends DocComponent {
58
57
  getOffsetConfig(): IDocumentOffsetConfig;
59
58
  getEngine(): Nullable<import("../..").Engine>;
60
59
  isHit(coord: Vector2): boolean;
60
+ private _isHitTable;
61
61
  changeSkeleton(newSkeleton: DocumentSkeleton): this;
62
62
  /** Editor-only emphasis; standalone and export renderers retain full document colors. */
63
63
  setInactiveAreaOpacity(opacity: number): void;
@@ -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;
@@ -53,6 +53,7 @@ export declare class DocumentSkeleton extends Skeleton {
53
53
  private _languageDetector;
54
54
  private _initialWidth;
55
55
  private _paginationMetrics;
56
+ private _completedPageCount;
56
57
  private _lastCompleteSkeletonData;
57
58
  private _pendingInvalidationAnchor;
58
59
  private _layoutGeneration;
@@ -65,11 +66,14 @@ export declare class DocumentSkeleton extends Skeleton {
65
66
  private readonly _isolateIncrementalPublications;
66
67
  private _modernPageWidth;
67
68
  private _modernHorizontalMargin;
69
+ private readonly _lineGap;
68
70
  constructor(_docViewModel: DocumentViewModel, localeService: LocaleService, options?: {
69
71
  isolateIncrementalPublications?: boolean;
72
+ lineGap?: number;
70
73
  });
71
74
  static create(docViewModel: DocumentViewModel, localeService: LocaleService, options?: {
72
75
  isolateIncrementalPublications?: boolean;
76
+ lineGap?: number;
73
77
  }): DocumentSkeleton;
74
78
  dispose(): void;
75
79
  getViewModel(): DocumentViewModel;
@@ -188,6 +192,8 @@ export declare class DocumentSkeleton extends Skeleton {
188
192
  private _initializeIncrementalSection;
189
193
  private _restartDirtyIncrementalLayout;
190
194
  private _finishIncrementalLayout;
195
+ getCompletedPageCount(): number | undefined;
196
+ private _prepareFieldCountRetry;
191
197
  private _prepareLayoutContext;
192
198
  /**
193
199
  * \v COLUMN_BREAK
@@ -26,8 +26,8 @@ export interface IDocumentLayoutPagePublication {
26
26
  }
27
27
  export interface IDocumentLayoutResourcePublication {
28
28
  reset: boolean;
29
- skeHeaders: Array<[string, Array<[number, IDocumentSkeletonPagePatch]>]>;
30
- skeFooters: Array<[string, Array<[number, IDocumentSkeletonPagePatch]>]>;
29
+ skeHeaders: Array<[string, Array<[number | string, IDocumentSkeletonPagePatch]>]>;
30
+ skeFooters: Array<[string, Array<[number | string, IDocumentSkeletonPagePatch]>]>;
31
31
  skeListLevel: IDocumentLayoutListLevelPublication | null;
32
32
  drawingAnchor: IDocumentLayoutDrawingAnchorPublication | null;
33
33
  }
@@ -41,6 +41,8 @@ export interface IDocumentLayoutApplyResult {
41
41
  export interface IDocumentLayoutProgress {
42
42
  generation: number;
43
43
  publicationRevision: number;
44
+ /** Pagination may restart when a total-page field changes the available body space. */
45
+ paginationRevision?: number;
44
46
  didPublish: boolean;
45
47
  /** The publication atomically replaced the page containing the edit anchor. */
46
48
  didPublishAnchor: boolean;
@@ -0,0 +1,18 @@
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 { ICustomRange } from '@univerjs/core';
17
+ import type { IDocumentSkeletonGlyph } from '../../../basics/i-document-skeleton-cached';
18
+ export declare function resolveHeaderFooterFieldGlyph(glyph: IDocumentSkeletonGlyph, startIndex: number, endIndex: number, customRanges: ICustomRange[], pageNumber: number, pageCount: number | undefined): IDocumentSkeletonGlyph;
@@ -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;
@@ -103,7 +103,7 @@ export interface IDocumentSkeletonLineContext {
103
103
  visualWidth?: number;
104
104
  }
105
105
  export type DocumentSkeletonTableSource = 'page' | 'table-cell' | 'column' | 'header' | 'footer';
106
- type HeaderFooterSkeletonMap = Map<string, Map<number, IDocumentSkeletonPage>>;
106
+ type HeaderFooterSkeletonMap = Map<string, Map<number | string, IDocumentSkeletonPage>>;
107
107
  export interface IDocumentSkeletonTableCellGeometry {
108
108
  cell: IDocumentSkeletonPage;
109
109
  cellRect: IBoundRectNoAngle;
@@ -241,6 +241,15 @@ export interface IDocumentPaginationMetrics {
241
241
  peakCheckpointLineCount: number;
242
242
  }
243
243
  export interface ILayoutContext {
244
+ headerFooterFieldContext?: {
245
+ pageNumber: number;
246
+ pageCount?: number;
247
+ };
248
+ fieldPageCount?: number;
249
+ hasNumPagesFields?: boolean;
250
+ fieldCountCandidates?: Set<number>;
251
+ fieldCountCycle?: boolean;
252
+ headerFooterMinimumMargins?: Map<string, number>;
244
253
  noteReferences?: ReadonlyMap<number, INoteReferenceLayout>;
245
254
  footnoteLayout?: DocumentFootnoteLayout;
246
255
  endnoteLayout?: DocumentEndnoteLayout;
@@ -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;
@@ -45,6 +45,7 @@ export declare class DocumentLayoutSession extends Disposable {
45
45
  private readonly _viewModel;
46
46
  private readonly _skeleton;
47
47
  private _lastPublishedPageCount;
48
+ private _paginationRevision;
48
49
  private _layoutReason;
49
50
  private _didPublishEditAnchor;
50
51
  private _continuousPageSnapshot;