@univerjs/engine-render 1.0.0-insiders.20260809-70eefdd → 1.0.0-rc.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 (61) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +0 -1
  3. package/lib/cjs/index.js +17525 -11746
  4. package/lib/es/index.js +17519 -11749
  5. package/lib/index.js +17519 -11749
  6. package/lib/types/basics/i-document-skeleton-cached.d.ts +60 -3
  7. package/lib/types/basics/index.d.ts +1 -0
  8. package/lib/types/basics/interfaces.d.ts +4 -0
  9. package/lib/types/basics/performance-monitor.d.ts +5 -0
  10. package/lib/types/basics/range.d.ts +1 -1
  11. package/lib/types/basics/transformer-config.d.ts +32 -1
  12. package/lib/types/components/docs/doc-background.d.ts +8 -0
  13. package/lib/types/components/docs/doc-extension.d.ts +3 -1
  14. package/lib/types/components/docs/document-compatibility.d.ts +1 -1
  15. package/lib/types/components/docs/document.d.ts +4 -3
  16. package/lib/types/components/docs/extensions/font-and-base-line.d.ts +1 -0
  17. package/lib/types/components/docs/layout/block/column.d.ts +15 -1
  18. package/lib/types/components/docs/layout/block/paragraph/layout-ruler.d.ts +6 -4
  19. package/lib/types/components/docs/layout/block/paragraph/line-adjustment.d.ts +1 -1
  20. package/lib/types/components/docs/layout/block/paragraph/linebreaking.d.ts +1 -1
  21. package/lib/types/components/docs/layout/block/paragraph/paragraph-layout.d.ts +1 -1
  22. package/lib/types/components/docs/layout/block/paragraph/shaping.d.ts +3 -0
  23. package/lib/types/components/docs/layout/block/section.d.ts +7 -1
  24. package/lib/types/components/docs/layout/block/table.d.ts +57 -1
  25. package/lib/types/components/docs/layout/doc-skeleton.d.ts +98 -3
  26. package/lib/types/components/docs/layout/document-layout-page-patch.d.ts +104 -0
  27. package/lib/types/components/docs/layout/document-layout-publication.d.ts +50 -0
  28. package/lib/types/components/docs/layout/document-layout-types.d.ts +65 -0
  29. package/lib/types/components/docs/layout/endnote-layout.d.ts +26 -0
  30. package/lib/types/components/docs/layout/footnote-layout.d.ts +70 -0
  31. package/lib/types/components/docs/layout/hyphenation/hyphen.d.ts +2 -0
  32. package/lib/types/components/docs/layout/model/line.d.ts +3 -2
  33. package/lib/types/components/docs/layout/model/page.d.ts +19 -2
  34. package/lib/types/components/docs/layout/note-numbering.d.ts +33 -0
  35. package/lib/types/components/docs/layout/shaping-engine/font-cache.d.ts +12 -1
  36. package/lib/types/components/docs/layout/style/color.d.ts +17 -0
  37. package/lib/types/components/docs/layout/tools.d.ts +33 -1
  38. package/lib/types/components/docs/view-model/document-view-model.d.ts +21 -1
  39. package/lib/types/components/sheets/constants.d.ts +2 -0
  40. package/lib/types/components/sheets/extensions/column-header-layout.d.ts +1 -1
  41. package/lib/types/components/sheets/extensions/row-header-layout.d.ts +1 -1
  42. package/lib/types/components/sheets/sheet.render-skeleton.d.ts +8 -1
  43. package/lib/types/components/sheets/spreadsheet.d.ts +5 -2
  44. package/lib/types/components/sheets/watermark/watermark-layer.d.ts +2 -1
  45. package/lib/types/context.d.ts +4 -0
  46. package/lib/types/engine.d.ts +1 -0
  47. package/lib/types/index.d.ts +6 -0
  48. package/lib/types/layer.d.ts +14 -1
  49. package/lib/types/render-manager/render-manager.service.d.ts +3 -1
  50. package/lib/types/scene.d.ts +19 -0
  51. package/lib/types/scene.input-manager.d.ts +5 -0
  52. package/lib/types/scene.transformer.d.ts +2 -0
  53. package/lib/types/services/canvas-color.service.d.ts +4 -3
  54. package/lib/types/shape/checkbox.d.ts +2 -0
  55. package/lib/types/shape/image.d.ts +4 -0
  56. package/lib/types/shape/scroll-bar.d.ts +2 -2
  57. package/lib/types/shape/shape.d.ts +10 -1
  58. package/lib/types/viewport.d.ts +3 -1
  59. package/lib/types/worker-layout.d.ts +62 -0
  60. package/lib/umd/index.js +4 -2
  61. package/package.json +4 -4
@@ -18,6 +18,8 @@ import type { IDocumentSkeletonCached, IDocumentSkeletonGlyph, IDocumentSkeleton
18
18
  import type { INodeInfo, INodePosition, INodeSearch } from '../../../basics/interfaces';
19
19
  import type { IViewportInfo, Vector2 } from '../../../basics/vector2';
20
20
  import type { DocumentViewModel } from '../view-model/document-view-model';
21
+ import type { IDocumentLayoutGeometryPublication, IDocumentLayoutPagePublication } from './document-layout-publication';
22
+ import type { DocumentLayoutReason, IDocumentLayoutApplyResult, IDocumentLayoutInvalidation, IDocumentLayoutPageRange, IDocumentLayoutProgress, IDocumentLayoutProtectedRange } from './document-layout-types';
21
23
  import type { IDocumentPaginationMetrics } from './tools';
22
24
  import { Skeleton } from '@univerjs/core';
23
25
  import { PageLayoutType } from '../../../basics/i-document-skeleton-cached';
@@ -28,6 +30,10 @@ export declare enum DocumentSkeletonState {
28
30
  READY = "ready",
29
31
  INVALID = "invalid"
30
32
  }
33
+ export interface IDocumentCustomBlockPresentationRefreshResult {
34
+ didRefresh: boolean;
35
+ requiresLayout: boolean;
36
+ }
31
37
  export interface IFindNodeRestrictions {
32
38
  strict: boolean;
33
39
  segmentId: string;
@@ -37,15 +43,30 @@ export declare class DocumentSkeleton extends Skeleton {
37
43
  private _docViewModel;
38
44
  private _dirty$;
39
45
  readonly dirty$: import("rxjs").Observable<boolean>;
46
+ private _layoutProgress$;
47
+ readonly layoutProgress$: import("rxjs").Observable<IDocumentLayoutProgress>;
40
48
  private _skeletonData;
41
49
  private _findLiquid;
42
50
  private _hyphen;
43
51
  private _languageDetector;
44
- private _iteratorCount;
45
52
  private _initialWidth;
46
53
  private _paginationMetrics;
47
- constructor(_docViewModel: DocumentViewModel, localeService: LocaleService);
48
- static create(docViewModel: DocumentViewModel, localeService: LocaleService): DocumentSkeleton;
54
+ private _lastCompleteSkeletonData;
55
+ private _pendingInvalidationAnchor;
56
+ private _layoutGeneration;
57
+ private _activeLayout;
58
+ private _externalLayoutProgress;
59
+ private _externalProtectedPages;
60
+ private _externalProtectedContinuousLayout;
61
+ private _topLevelBlockSections;
62
+ private _topLevelBlocks;
63
+ private readonly _isolateIncrementalPublications;
64
+ constructor(_docViewModel: DocumentViewModel, localeService: LocaleService, options?: {
65
+ isolateIncrementalPublications?: boolean;
66
+ });
67
+ static create(docViewModel: DocumentViewModel, localeService: LocaleService, options?: {
68
+ isolateIncrementalPublications?: boolean;
69
+ }): DocumentSkeleton;
49
70
  dispose(): void;
50
71
  getViewModel(): DocumentViewModel;
51
72
  /**
@@ -53,7 +74,66 @@ export declare class DocumentSkeleton extends Skeleton {
53
74
  * PS: This method has significant impact on performance.
54
75
  */
55
76
  calculate(bounds?: IViewportInfo): void;
77
+ startIncrementalLayout(options?: {
78
+ reason?: DocumentLayoutReason;
79
+ anchor?: number;
80
+ priorityAnchor?: number;
81
+ invalidation?: IDocumentLayoutInvalidation;
82
+ bounds?: IViewportInfo;
83
+ reuseUnaffectedTail?: boolean;
84
+ /** The caller proved this edit only changes offset-preserving render metadata. */
85
+ allowMetadataOnlyStructuralTailReuse?: boolean;
86
+ preserveInteractionWindow?: boolean;
87
+ /** Cooperative schedulers wait for code-split dictionaries before publishing. */
88
+ waitForHyphenationPatterns?: boolean;
89
+ }): number;
90
+ private _prepareIncrementalLayoutStart;
91
+ private _preparePaginatedParagraphPrefix;
92
+ private _prepareContinuousPrefix;
93
+ private _findBodyPageIndex;
94
+ private _getTopLevelBlocks;
95
+ private _copySkeletonResources;
96
+ cancelIncrementalLayout(generation?: number): void;
97
+ stepIncrementalLayout(generation: number, budgetMs?: number, maxWorkUnits?: number): IDocumentLayoutProgress;
98
+ /**
99
+ * Publishes at most one page that a previous layout slice has already
100
+ * completed. It never advances shaping or pagination work.
101
+ */
102
+ publishIncrementalLayoutBacklog(generation: number): IDocumentLayoutProgress;
103
+ private _stepIncrementalLayout;
104
+ private _createPublishablePartialSkeleton;
105
+ private _createSharedPublishablePartialSkeleton;
106
+ private _findPublishablePriorityPageIndex;
107
+ private _finalizePaginatedPagesForPublication;
108
+ getLayoutProgress(): Nullable<IDocumentLayoutProgress>;
109
+ /**
110
+ * Opens a presentation barrier before an external executor starts layout.
111
+ * The Main interaction snapshot remains authoritative inside its protected
112
+ * page or block range while the external executor publishes a newer tail.
113
+ */
114
+ beginExternalLayout(options: {
115
+ reason: DocumentLayoutReason;
116
+ protectedRange?: IDocumentLayoutProtectedRange;
117
+ }): void;
118
+ cancelExternalLayout(): void;
119
+ /**
120
+ * Whether this skeleton owns a fully finalized layout that can be used as
121
+ * stable geometry while a later incremental generation is still running.
122
+ */
123
+ hasCompleteLayout(): boolean;
56
124
  getSkeletonData(): Nullable<IDocumentSkeletonCached>;
125
+ /**
126
+ * Refreshes Custom Block viewport-only metrics without rebuilding document flow.
127
+ * Pure presentation metrics are published as one batch. Flow metrics are only
128
+ * replaced for compatible drawings; incompatible drawings retain their stable
129
+ * flow geometry while callers schedule a normal layout generation.
130
+ */
131
+ refreshCustomBlockPresentationViewports(): IDocumentCustomBlockPresentationRefreshResult;
132
+ applyLayoutPublication(publication: IDocumentLayoutGeometryPublication, progress: IDocumentLayoutProgress, materializedPageRange?: IDocumentLayoutPageRange): IDocumentLayoutApplyResult;
133
+ applyLayoutPagePublication(publication: IDocumentLayoutPagePublication, materializedPageRange: IDocumentLayoutPageRange): boolean;
134
+ private _compactMaterializedPages;
135
+ private _applyExternalLayoutResources;
136
+ private _resolveProtectedContinuousPublication;
57
137
  /**
58
138
  * Returns a cloned snapshot of the most recent layout's bounded pagination counters.
59
139
  * These diagnostics describe renderer work and are not part of the document model.
@@ -69,6 +149,7 @@ export declare class DocumentSkeleton extends Skeleton {
69
149
  findPositionByGlyph(glyph: IDocumentSkeletonGlyph, segmentPage: number): Nullable<INodeSearch>;
70
150
  findCharIndexByPosition(position: INodePosition): Nullable<number>;
71
151
  findNodePositionByCharIndex(charIndex: number, isBack?: boolean, segmentId?: string, segmentPIndex?: number): Nullable<INodePosition>;
152
+ findBodyPageIndexByCharIndex(charIndex: number): number;
72
153
  findNodeByCharIndex(charIndex: number, segmentId?: string, segmentPageIndex?: number): Nullable<IDocumentSkeletonGlyph>;
73
154
  findGlyphByPosition(position: Nullable<INodePosition>): IDocumentSkeletonGlyph | undefined;
74
155
  findEditAreaByCoord(coord: Vector2, pageLayoutType: PageLayoutType, pageMarginLeft: number, pageMarginTop: number): {
@@ -77,10 +158,23 @@ export declare class DocumentSkeleton extends Skeleton {
77
158
  page: Nullable<IDocumentSkeletonPage>;
78
159
  };
79
160
  findNodeByCoord(coord: Vector2, pageLayoutType: PageLayoutType, pageMarginLeft: number, pageMarginTop: number, restrictions?: IFindNodeRestrictions): Nullable<INodeInfo>;
161
+ private _findNodeByCoord;
80
162
  private _collectNearestNode;
81
163
  private _getNearestNode;
82
164
  private _getPageBoundingBox;
83
165
  private _translatePage;
166
+ private _getLayoutProgress;
167
+ private _tryConvergeUnaffectedTail;
168
+ private _isPriorityAnchorReady;
169
+ private _tryReuseInteractionPageTail;
170
+ private _prepareIncrementalHyphenation;
171
+ private _advanceIncrementalLayout;
172
+ private _resumeAfterSealedInteractionPage;
173
+ private _captureIncrementalParagraphCheckpoint;
174
+ private _restoreIncrementalParagraphCheckpoint;
175
+ private _initializeIncrementalSection;
176
+ private _restartDirtyIncrementalLayout;
177
+ private _finishIncrementalLayout;
84
178
  private _prepareLayoutContext;
85
179
  /**
86
180
  * \v COLUMN_BREAK
@@ -110,6 +204,7 @@ export declare class DocumentSkeleton extends Skeleton {
110
204
  * @returns view model: skeleton
111
205
  */
112
206
  private _createSkeleton;
207
+ private _createSkeletonPass;
113
208
  private _addNewSectionByContinuous;
114
209
  private _addNewSectionByNextColumn;
115
210
  private _restoreContinuousSection;
@@ -0,0 +1,104 @@
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 { IDocDrawingBase, IDocumentData, ITable, ITableRow } from '@univerjs/core';
17
+ import type { IDocumentSkeletonCached, IDocumentSkeletonColumn, IDocumentSkeletonColumnGroup, IDocumentSkeletonColumnGroupColumn, IDocumentSkeletonDivide, IDocumentSkeletonDrawing, IDocumentSkeletonGlyph, IDocumentSkeletonLine, IDocumentSkeletonNote, IDocumentSkeletonNoteDecoration, IDocumentSkeletonPage, IDocumentSkeletonRow, IDocumentSkeletonSection, IDocumentSkeletonTable } from '../../../basics/i-document-skeleton-cached';
18
+ export type IDocumentSkeletonGlyphPatch = Omit<IDocumentSkeletonGlyph, 'parent'>;
19
+ export interface IDocumentSkeletonDividePatch extends Omit<IDocumentSkeletonDivide, 'glyphGroup' | 'parent'> {
20
+ glyphGroup: IDocumentSkeletonGlyphPatch[];
21
+ }
22
+ export interface IDocumentSkeletonLinePatch extends Omit<IDocumentSkeletonLine, 'divides' | 'parent'> {
23
+ divides: IDocumentSkeletonDividePatch[];
24
+ }
25
+ export interface IDocumentSkeletonColumnPatch extends Omit<IDocumentSkeletonColumn, 'lines' | 'parent'> {
26
+ lines: IDocumentSkeletonLinePatch[];
27
+ }
28
+ export interface IDocumentSkeletonSectionPatch extends Omit<IDocumentSkeletonSection, 'columns' | 'parent'> {
29
+ columns: IDocumentSkeletonColumnPatch[];
30
+ }
31
+ export interface IDocumentSkeletonDrawingPatch extends Omit<IDocumentSkeletonDrawing, 'drawingOrigin'> {
32
+ drawingOrigin?: IDocDrawingBase;
33
+ }
34
+ export interface IDocumentSkeletonRowPatch extends Omit<IDocumentSkeletonRow, 'cells' | 'parent' | 'rowSource'> {
35
+ cells: IDocumentSkeletonPagePatch[];
36
+ rowSource?: ITableRow;
37
+ rowSourceIndex?: number;
38
+ }
39
+ export interface IDocumentSkeletonTablePatch extends Omit<IDocumentSkeletonTable, 'rows' | 'parent' | 'tableSource'> {
40
+ rows: IDocumentSkeletonRowPatch[];
41
+ tableSource?: ITable;
42
+ tableSourceId?: string;
43
+ }
44
+ export interface IDocumentSkeletonColumnGroupColumnPatch extends Omit<IDocumentSkeletonColumnGroupColumn, 'page' | 'parent'> {
45
+ page: IDocumentSkeletonPagePatch;
46
+ }
47
+ export interface IDocumentSkeletonColumnGroupPatch extends Omit<IDocumentSkeletonColumnGroup, 'columns' | 'parent'> {
48
+ columns: IDocumentSkeletonColumnGroupColumnPatch[];
49
+ }
50
+ export interface IDocumentSkeletonPagePatch extends Omit<IDocumentSkeletonPage, 'sections' | 'skeDrawings' | 'skeTables' | 'skeColumnGroups' | 'notes' | 'noteDecorations' | 'parent'> {
51
+ sections: IDocumentSkeletonSectionPatch[];
52
+ skeDrawings: Array<[string, IDocumentSkeletonDrawingPatch]>;
53
+ skeTables: Array<[string, IDocumentSkeletonTablePatch]>;
54
+ skeColumnGroups: Array<[string, IDocumentSkeletonColumnGroupPatch]>;
55
+ noteDecorations?: Array<Omit<IDocumentSkeletonNoteDecoration, 'page'> & {
56
+ page: IDocumentSkeletonPagePatch;
57
+ }>;
58
+ notes?: Array<Omit<IDocumentSkeletonNote, 'page' | 'parent'> & {
59
+ page: IDocumentSkeletonPagePatch;
60
+ }>;
61
+ }
62
+ export type IDocumentSkeletonPageGeometryPatch = Omit<IDocumentSkeletonPagePatch, 'sections' | 'skeDrawings' | 'skeTables' | 'skeColumnGroups' | 'notes' | 'noteDecorations'>;
63
+ export type IDocumentSkeletonSectionGeometryPatch = Omit<IDocumentSkeletonSectionPatch, 'columns'>;
64
+ export type IDocumentSkeletonColumnGeometryPatch = Omit<IDocumentSkeletonColumnPatch, 'lines'>;
65
+ export interface IDocumentSkeletonContinuousFlowPatch {
66
+ sectionIndex: number;
67
+ section: IDocumentSkeletonSectionGeometryPatch;
68
+ columnIndex: number;
69
+ column: IDocumentSkeletonColumnGeometryPatch;
70
+ lineIndex: number;
71
+ lines: IDocumentSkeletonLinePatch[];
72
+ trailingColumns: IDocumentSkeletonColumnPatch[];
73
+ trailingSections: IDocumentSkeletonSectionPatch[];
74
+ }
75
+ export interface IDocumentSkeletonContinuousBlockPatch {
76
+ pageIndex: number;
77
+ page: IDocumentSkeletonPageGeometryPatch;
78
+ flow: IDocumentSkeletonContinuousFlowPatch;
79
+ skeDrawings: Array<[string, IDocumentSkeletonDrawingPatch]>;
80
+ skeTables: Array<[string, IDocumentSkeletonTablePatch]>;
81
+ skeColumnGroups: Array<[string, IDocumentSkeletonColumnGroupPatch]>;
82
+ previousHeight: number;
83
+ heightDelta: number;
84
+ }
85
+ export interface IDocumentSkeletonContinuousSnapshot {
86
+ height: number;
87
+ lineEnds: number[];
88
+ }
89
+ export declare function serializeDocumentSkeletonLine(source: IDocumentSkeletonLine): IDocumentSkeletonLinePatch;
90
+ export declare function serializeDocumentSkeletonPage(source: IDocumentSkeletonPage, omitResourceSources?: boolean): IDocumentSkeletonPagePatch;
91
+ export declare function hydrateDocumentSkeletonLine(source: IDocumentSkeletonLinePatch, parent: IDocumentSkeletonColumn): IDocumentSkeletonLine;
92
+ export declare function hydrateDocumentSkeletonPage(source: IDocumentSkeletonPagePatch, parent?: IDocumentSkeletonCached | IDocumentSkeletonRow | IDocumentSkeletonColumnGroupColumn, snapshot?: IDocumentData): IDocumentSkeletonPage;
93
+ export declare function hydrateDocumentSkeletonPagePlaceholder(source: IDocumentSkeletonPagePatch, parent?: IDocumentSkeletonCached): IDocumentSkeletonPage;
94
+ export declare function hydrateDocumentSkeletonPageMaterializationPlaceholder(source: IDocumentSkeletonPagePatch, parent?: IDocumentSkeletonCached): IDocumentSkeletonPage;
95
+ /**
96
+ * Serializes only the changed suffix of a continuous document's logical page.
97
+ * The boundary line is deliberately republished because paragraph spacing can
98
+ * alter it when the next block is appended.
99
+ */
100
+ export declare function serializeDocumentSkeletonContinuousBlock(currentPage: IDocumentSkeletonPage, previousSnapshot: IDocumentSkeletonContinuousSnapshot | null, replacementOffset?: number, omitResourceSources?: boolean): {
101
+ block: IDocumentSkeletonContinuousBlockPatch;
102
+ snapshot: IDocumentSkeletonContinuousSnapshot;
103
+ };
104
+ export declare function applyDocumentSkeletonContinuousBlock(target: IDocumentSkeletonCached, patch: IDocumentSkeletonContinuousBlockPatch, snapshot?: IDocumentData): IDocumentSkeletonPage;
@@ -0,0 +1,50 @@
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 { IDocumentSkeletonDrawingAnchor, IParagraphList } from '../../../basics/i-document-skeleton-cached';
17
+ import type { IDocumentSkeletonContinuousBlockPatch, IDocumentSkeletonPagePatch } from './document-layout-page-patch';
18
+ export type IDocumentLayoutListLevelPublication = Array<[string, IParagraphList[][]]>;
19
+ export type IDocumentLayoutDrawingAnchorPublication = Array<[
20
+ string,
21
+ Array<[number, Omit<IDocumentSkeletonDrawingAnchor, 'elements'>]>
22
+ ]>;
23
+ export interface IDocumentLayoutPagePublication {
24
+ pageIndex: number;
25
+ page: IDocumentSkeletonPagePatch;
26
+ }
27
+ export interface IDocumentLayoutResourcePublication {
28
+ reset: boolean;
29
+ skeHeaders: Array<[string, Array<[number, IDocumentSkeletonPagePatch]>]>;
30
+ skeFooters: Array<[string, Array<[number, IDocumentSkeletonPagePatch]>]>;
31
+ skeListLevel: IDocumentLayoutListLevelPublication | null;
32
+ drawingAnchor: IDocumentLayoutDrawingAnchorPublication | null;
33
+ }
34
+ interface IDocumentLayoutGeometryPublicationBase {
35
+ left: number;
36
+ top: number;
37
+ st: number;
38
+ ed?: number;
39
+ resources: IDocumentLayoutResourcePublication;
40
+ }
41
+ export interface IDocumentLayoutPageGeometryPublication extends IDocumentLayoutGeometryPublicationBase {
42
+ kind: 'page';
43
+ pages: IDocumentLayoutPagePublication[];
44
+ }
45
+ export interface IDocumentLayoutBlockGeometryPublication extends IDocumentLayoutGeometryPublicationBase {
46
+ kind: 'block';
47
+ block: IDocumentSkeletonContinuousBlockPatch;
48
+ }
49
+ export type IDocumentLayoutGeometryPublication = IDocumentLayoutPageGeometryPublication | IDocumentLayoutBlockGeometryPublication;
50
+ export {};
@@ -0,0 +1,65 @@
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
+ export type DocumentLayoutMode = 'paginated' | 'continuous';
17
+ export type DocumentLayoutReason = 'initial' | 'edit';
18
+ export interface IDocumentLayoutInvalidation {
19
+ /** First offset changed in the pre-mutation document. */
20
+ oldStart: number;
21
+ /** Exclusive end of the changed range in the pre-mutation document. */
22
+ oldEnd: number;
23
+ /** Exclusive end of the changed range in the post-mutation document. */
24
+ newEnd: number;
25
+ }
26
+ export interface IDocumentLayoutProtectedPageRange {
27
+ mode: 'paginated';
28
+ startPageIndex: number;
29
+ endPageIndex: number;
30
+ }
31
+ export type IDocumentLayoutPageRange = Pick<IDocumentLayoutProtectedPageRange, 'startPageIndex' | 'endPageIndex'>;
32
+ export interface IDocumentLayoutProtectedContinuousRange {
33
+ mode: 'continuous';
34
+ startOffset: number;
35
+ endOffset: number;
36
+ }
37
+ export type IDocumentLayoutProtectedRange = IDocumentLayoutProtectedPageRange | IDocumentLayoutProtectedContinuousRange;
38
+ export interface IDocumentLayoutApplyResult {
39
+ didReplaceProtectedPages: boolean;
40
+ }
41
+ export interface IDocumentLayoutProgress {
42
+ generation: number;
43
+ publicationRevision: number;
44
+ didPublish: boolean;
45
+ /** The publication atomically replaced the page containing the edit anchor. */
46
+ didPublishAnchor: boolean;
47
+ publishedPageCount: number;
48
+ reason: DocumentLayoutReason;
49
+ mode: DocumentLayoutMode;
50
+ complete: boolean;
51
+ cancelled: boolean;
52
+ anchorReady: boolean;
53
+ laidOutThrough: number;
54
+ /** Last logical offset whose exit geometry cannot be changed by the next block. */
55
+ stableLaidOutThrough: number;
56
+ pageCount: number;
57
+ processedBlockCount: number;
58
+ totalBlockCount: number;
59
+ estimatedPageCount: number;
60
+ estimatedHeight: number;
61
+ elapsedTime: number;
62
+ maxBlockDuration: number;
63
+ /** Main has sealed the protected interaction page and should hand the remaining suffix to Worker. */
64
+ interactionWindowComplete?: boolean;
65
+ }
@@ -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 { IDocumentSkeletonPage } from '../../../basics/i-document-skeleton-cached';
17
+ import type { ISectionBreakConfig } from '../../../basics/interfaces';
18
+ import type { ILayoutContext } from './tools';
19
+ /** Endnotes occupy document flow after a section or the final body section. */
20
+ export declare class DocumentEndnoteLayout {
21
+ private readonly _ctx;
22
+ constructor(_ctx: ILayoutContext);
23
+ finishSection(pages: IDocumentSkeletonPage[], sectionIndex: number, config: ISectionBreakConfig): void;
24
+ private _layoutDecoration;
25
+ }
26
+ export declare function getEndnoteFlowBottom(page: IDocumentSkeletonPage): number;
@@ -0,0 +1,70 @@
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 { IDocumentBody } from '@univerjs/core';
17
+ import type { IDocumentSkeletonGlyph, IDocumentSkeletonPage, IDocumentSkeletonTable } from '../../../basics/i-document-skeleton-cached';
18
+ import type { IParagraphConfig, ISectionBreakConfig } from '../../../basics/interfaces';
19
+ import type { INoteReferenceLayout } from './note-numbering';
20
+ import type { ILayoutContext } from './tools';
21
+ import { DocumentViewModel } from '../view-model/document-view-model';
22
+ export interface INoteLayoutConstraints {
23
+ width: number;
24
+ firstPageHeight: number;
25
+ continuationPageHeight: number;
26
+ columnCount?: number;
27
+ firstColumn?: {
28
+ index: number;
29
+ top: number;
30
+ };
31
+ }
32
+ /** Uses the body layout pipeline, including table row splitting and inline drawing metrics. */
33
+ export declare function layoutNoteBody(parentContext: ILayoutContext, reference: INoteReferenceLayout, sectionConfig: ISectionBreakConfig, constraints: INoteLayoutConstraints): IDocumentSkeletonPage[];
34
+ export declare function layoutNoteSegment(parentContext: ILayoutContext, viewModel: DocumentViewModel, reference: Pick<INoteReferenceLayout, 'noteId' | 'sectionId'> & {
35
+ label?: string;
36
+ }, sectionConfig: ISectionBreakConfig, constraints: INoteLayoutConstraints): IDocumentSkeletonPage[];
37
+ export declare function defaultSeparatorBody(continued: boolean): IDocumentBody;
38
+ /** Per-layout state, shared by synchronous and sliced body pagination. */
39
+ export declare class DocumentFootnoteLayout {
40
+ private readonly _ctx;
41
+ private readonly _pages;
42
+ private readonly _inherited;
43
+ private readonly _references;
44
+ private readonly _referencePageBreaks;
45
+ private readonly _decorations;
46
+ constructor(_ctx: ILayoutContext);
47
+ updateReferenceGlyphs(page: IDocumentSkeletonPage, glyphs: IDocumentSkeletonGlyph[], config: ISectionBreakConfig, paragraph: IParagraphConfig): void;
48
+ private _updateReferenceLabels;
49
+ getTableBodyLimit(page: IDocumentSkeletonPage, currentPages: IDocumentSkeletonPage[], config: ISectionBreakConfig, table: IDocumentSkeletonTable): number;
50
+ /** Measure table slices without publishing speculative notes on body pages. */
51
+ createTablePagination(page: IDocumentSkeletonPage, config: ISectionBreakConfig, availableHeight: number): {
52
+ renumberWholeRow: (table: IDocumentSkeletonTable, rows: IDocumentSkeletonTable["rows"], remainingHeight: number) => boolean;
53
+ measureRow: (table: IDocumentSkeletonTable, rows: IDocumentSkeletonTable["rows"], previousHeights?: readonly number[]) => number[] | undefined;
54
+ append: (table: IDocumentSkeletonTable, row: IDocumentSkeletonTable["rows"][number]) => number | undefined;
55
+ hasContinuation: () => boolean;
56
+ nextPage: () => void;
57
+ } | undefined;
58
+ getBodyLimit(page: IDocumentSkeletonPage, currentPages: IDocumentSkeletonPage[], config: ISectionBreakConfig, bodyBottom: number, incoming?: IDocumentSkeletonGlyph[]): number;
59
+ finish(pages: IDocumentSkeletonPage[], config: ISectionBreakConfig): void;
60
+ getReferencePageBreaks(paragraphIndex: number): readonly number[] | undefined;
61
+ /** Re-shape moved text while retaining the page boundary chosen by keep/widow control. */
62
+ queueReferenceRelayout(pages: IDocumentSkeletonPage[]): void;
63
+ /** Rebuild reservations after keep-lines or widow control relocates shaped lines. */
64
+ reconcilePages(pages: IDocumentSkeletonPage[], config: ISectionBreakConfig): boolean;
65
+ private _layoutPageNotes;
66
+ private _layoutDecoration;
67
+ private _appendFollowing;
68
+ private _getInherited;
69
+ private _position;
70
+ }
@@ -18,12 +18,14 @@ import { Lang } from './lang';
18
18
  export declare class Hyphen implements IDisposable {
19
19
  private _patterns;
20
20
  private _hyphenCache;
21
+ private _patternLoads;
21
22
  private static _instance;
22
23
  static getInstance(): Hyphen;
23
24
  constructor();
24
25
  private _preloadPatterns;
25
26
  private _loadExceptionsToCache;
26
27
  loadPattern(lang: Lang): Promise<void>;
28
+ private _loadPattern;
27
29
  fetchHyphenCache(lang: Lang): Map<string, string[]> | undefined;
28
30
  hasPattern(lang: Lang): boolean;
29
31
  hyphenate(word: string, lang: Lang): string[] | undefined;
@@ -14,9 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Nullable } from '@univerjs/core';
17
- import type { IParagraphConfig } from '../../../../basics';
18
17
  import type { IDocumentSkeletonDivide, IDocumentSkeletonDrawingAnchor, IDocumentSkeletonLine, IDocumentSkeletonPage, LineType } from '../../../../basics/i-document-skeleton-cached';
18
+ import type { IParagraphConfig } from '../../../../basics/interfaces';
19
19
  import type { IFloatObject } from '../tools';
20
+ export declare const TRADITIONAL_TABLE_WRAP_MIN_WIDTH = 24;
20
21
  interface ILineBoundingBox {
21
22
  lineHeight: number;
22
23
  lineTop: number;
@@ -29,7 +30,7 @@ interface ILineBoundingBox {
29
30
  spaceBelowApply?: number;
30
31
  }
31
32
  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>, columnLeft?: number, sectionTop?: number): IDocumentSkeletonLine;
32
- export declare function calculateLineTopByDrawings(lineHeight: number | undefined, lineTop: number | undefined, page: IDocumentSkeletonPage, headerPage: Nullable<IDocumentSkeletonPage>, footerPage: Nullable<IDocumentSkeletonPage>, columnLeft?: number, columnWidth?: number, sectionTop?: number): number;
33
+ export declare function calculateLineTopByDrawings(lineHeight: number | undefined, lineTop: number | undefined, page: IDocumentSkeletonPage, headerPage: Nullable<IDocumentSkeletonPage>, footerPage: Nullable<IDocumentSkeletonPage>, columnLeft?: number, columnWidth?: number, sectionTop?: number, minimumTableWrapWidth?: number): number;
33
34
  export declare function updateDivideInfo(divide: IDocumentSkeletonDivide, states: Partial<IDocumentSkeletonDivide>): void;
34
35
  export declare function setLineMarginBottom(line: IDocumentSkeletonLine, marginBottom: number): void;
35
36
  export declare function collisionDetection(floatObject: IFloatObject, lineHeight: number, lineTop: number, columnLeft: number, columnWidth: number): boolean;
@@ -21,10 +21,27 @@ import type { DocumentViewModel } from '../../view-model/document-view-model';
21
21
  import type { ILayoutContext } from '../tools';
22
22
  import { BreakType } from '../../../../basics/i-document-skeleton-cached';
23
23
  export declare function createSkeletonPage(ctx: ILayoutContext, sectionBreakConfig: ISectionBreakConfig, skeletonResourceReference: ISkeletonResourceReference, pageNumber?: number, breakType?: BreakType): IDocumentSkeletonPage;
24
- export declare function createNullCellPage(ctx: ILayoutContext, sectionBreakConfig: ISectionBreakConfig, tableConfig: ITable, row: number, col: number, availableHeight?: number, maxCellPageHeight?: number): {
24
+ export declare function createNullCellPage(ctx: ILayoutContext, sectionBreakConfig: ISectionBreakConfig, tableConfig: ITable, row: number, col: number, availableHeight?: number, maxCellPageHeight?: number, inheritDocumentLinePitch?: boolean, enableDocumentTableLineGrid?: boolean, cellPageHeights?: readonly number[]): {
25
25
  page: IDocumentSkeletonPage;
26
26
  sectionBreakConfig: ISectionBreakConfig;
27
27
  };
28
- export declare function createSkeletonCellPages(ctx: ILayoutContext, viewModel: DocumentViewModel, cellNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, tableConfig: ITable, row: number, col: number, availableHeight?: number, maxCellPageHeight?: number): IDocumentSkeletonPage[];
28
+ 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[];
29
+ export interface ICellSkeletonBuildState {
30
+ ctx: ILayoutContext;
31
+ viewModel: DocumentViewModel;
32
+ cellNode: DataStreamTreeNode;
33
+ sectionNode: DataStreamTreeNode;
34
+ sectionBreakConfig: ISectionBreakConfig;
35
+ cellSectionBreakConfig: ISectionBreakConfig;
36
+ tableConfig: ITable;
37
+ paragraphIndex: number;
38
+ layoutAnchor: Nullable<number>;
39
+ pages: IDocumentSkeletonPage[];
40
+ complete: boolean;
41
+ requiresSyncFallback: boolean;
42
+ }
43
+ 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;
44
+ export declare function stepSkeletonCellPagesBuild(state: ICellSkeletonBuildState): boolean;
29
45
  export declare function expandCellPageHeightForInlineDrawings(pages: IDocumentSkeletonPage[]): void;
46
+ export declare function expandCellPageHeightForFlowTables(pages: IDocumentSkeletonPage[]): void;
30
47
  export declare function applyTrailingBlockRangeSpaceBelow(pages: IDocumentSkeletonPage[], body: Nullable<IDocumentBody>, containerEndIndex: number): void;
@@ -0,0 +1,33 @@
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 { DocumentNoteType, IDocumentData, IFootnoteProperties, ISectionBreak } from '@univerjs/core';
17
+ export interface INoteLayoutProperties extends Omit<IFootnoteProperties, 'position'> {
18
+ position?: 'pageBottom' | 'beneathText' | 'docEnd' | 'sectEnd';
19
+ }
20
+ export interface INoteReferenceLayout {
21
+ noteId: string;
22
+ type: DocumentNoteType;
23
+ referenceIndex: number;
24
+ sectionId: string;
25
+ label: string;
26
+ number?: number;
27
+ properties: INoteLayoutProperties;
28
+ }
29
+ export declare function formatNoteNumber(number: number, format?: string): string;
30
+ /** Page keys are physical page indices, independent of the printed page-number format. */
31
+ /** Cell section sentinels cannot own document-level note numbering or placement. */
32
+ export declare function getNoteSections(snapshot: Pick<IDocumentData, 'body'>): ISectionBreak[];
33
+ export declare function resolveNoteReferences(snapshot: Pick<IDocumentData, 'body' | 'notes' | 'noteSettings'>, referencePages?: ReadonlyMap<string, number>): Map<number, INoteReferenceLayout>;
@@ -23,12 +23,16 @@ export interface IMeasureTextCache {
23
23
  actualBoundingBoxDescent: number;
24
24
  width: number;
25
25
  }
26
+ /** Invalidates selected CSS font keys in both measurement caches; registered font data is retained. */
27
+ export declare function invalidateDocumentFontMetrics(matches: (fontStyle: string) => boolean): boolean;
26
28
  export declare class FontCache {
29
+ private static _normalLineHeightCache;
27
30
  private static _getTextHeightCache;
28
31
  private static _context;
29
32
  private static _fontDataMap;
30
33
  private static _globalFontMeasureCache;
31
34
  static get globalFontMeasureCache(): Map<string, Map<string, IMeasureTextCache>>;
35
+ static invalidateMetrics(matches: (fontStyle: string) => boolean): boolean;
32
36
  static setFontMeasureCache(fontStyle: string, content: string, tm: IMeasureTextCache): void;
33
37
  static clearFontMeasureCache(path: string): boolean;
34
38
  static getFontMeasureCache(fontStyle: string, content: string): Nullable<IMeasureTextCache>;
@@ -43,7 +47,12 @@ export declare class FontCache {
43
47
  width: number;
44
48
  height: number;
45
49
  };
46
- static getTextSize(content: string, fontStyle: IDocumentSkeletonFontStyle): IDocumentSkeletonBoundingBox;
50
+ /** CSS normal spacing includes font leading that Canvas bounding boxes omit. */
51
+ static getNormalLineHeight(fontStyle: IDocumentSkeletonFontStyle): number | undefined;
52
+ /** Transfers browser-only normal spacing measurements to the document layout Worker. */
53
+ static getNormalLineHeightCache(): Record<string, number>;
54
+ static setNormalLineHeightCache(metrics: Record<string, number>): void;
55
+ static getTextSize(content: string, fontStyle: IDocumentSkeletonFontStyle, includeNormalFontLeading?: boolean): IDocumentSkeletonBoundingBox;
47
56
  /**
48
57
  * Measure text on another canvas.
49
58
  * @param content
@@ -51,6 +60,8 @@ export declare class FontCache {
51
60
  * @returns IMeasureTextCache
52
61
  */
53
62
  static getMeasureText(content: string, fontString: string): IMeasureTextCache;
63
+ private static _createMeasureContext;
64
+ private static _getFontSizeFromStyle;
54
65
  private static _clearMeasureCache;
55
66
  /**
56
67
  * Vertical Metrics https://glyphsapp.com/learn/vertical-metrics
@@ -0,0 +1,17 @@
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 { IColorStyle, Nullable } from '@univerjs/core';
17
+ export declare function getColorStyleForCanvas(color: Nullable<IColorStyle>): Nullable<string>;