@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.
- package/lib/cjs/index.js +230 -35
- package/lib/es/index.js +231 -36
- package/lib/index.js +231 -36
- package/lib/types/basics/document-node-tools.d.ts +1 -0
- package/lib/types/components/docs/layout/block/paragraph/layout-ruler.d.ts +3 -3
- package/lib/types/components/docs/layout/block/table.d.ts +2 -2
- package/lib/types/components/docs/layout/doc-skeleton.d.ts +6 -1
- package/lib/types/components/docs/layout/tools.d.ts +1 -1
- package/lib/types/components/docs/view-model/document-view-model.d.ts +5 -0
- package/lib/types/components/docs/view-model/heading-sections.d.ts +26 -0
- package/lib/umd/index.js +4 -4
- package/package.json +4 -4
package/lib/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, DocxBreakType, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, JSON1, ListGlyphType, LocaleService, LookUp, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SHEET_TEXT_LINE_GAP, SectionType, SheetSkeleton, Skeleton, SpacingRule, TabStopAlignment, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextDecoration, TextX, TextXActionType, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, characterSpacingControlType, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, getColorStyle, getDisplayValueFromCell, getRichTextEditPath, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isCellCoverable, isClassDependencyItem, isDefaultFormat, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, numfmt, regexp, registerDependencies, remove, requestImmediateMacroTask, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReferences, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
1
|
+
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, DocxBreakType, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, JSON1, ListGlyphType, LocaleService, LookUp, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NamedStyleType, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SHEET_TEXT_LINE_GAP, SectionType, SheetSkeleton, Skeleton, SpacingRule, TabStopAlignment, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextDecoration, TextX, TextXActionType, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, characterSpacingControlType, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, getColorStyle, getDisplayValueFromCell, getRichTextEditPath, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isCellCoverable, isClassDependencyItem, isDefaultFormat, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, numfmt, regexp, registerDependencies, remove, requestImmediateMacroTask, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReferences, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
2
2
|
import { BehaviorSubject, Observable, Subject, Subscription, distinctUntilChanged, merge as merge$1, shareReplay, startWith } from "rxjs";
|
|
3
3
|
import { franc } from "franc-min";
|
|
4
4
|
import { getOverflowAncestors } from "@floating-ui/dom";
|
|
@@ -13125,6 +13125,48 @@ var DataStreamTreeNode = class DataStreamTreeNode {
|
|
|
13125
13125
|
}
|
|
13126
13126
|
};
|
|
13127
13127
|
|
|
13128
|
+
//#endregion
|
|
13129
|
+
//#region src/components/docs/view-model/heading-sections.ts
|
|
13130
|
+
/** Each table cell and modern column has its own heading hierarchy. */
|
|
13131
|
+
function getHeadingSections(sections, getParagraph) {
|
|
13132
|
+
const result = [];
|
|
13133
|
+
function visitFlow(nodes, endOffset) {
|
|
13134
|
+
const open = [];
|
|
13135
|
+
for (const node of nodes) {
|
|
13136
|
+
var _paragraph$paragraphS;
|
|
13137
|
+
const paragraph = node.nodeType === DataStreamTreeNodeType.PARAGRAPH && node.children.length === 0 ? getParagraph(node.endIndex) : void 0;
|
|
13138
|
+
const level = paragraph === null || paragraph === void 0 || (_paragraph$paragraphS = paragraph.paragraphStyle) === null || _paragraph$paragraphS === void 0 ? void 0 : _paragraph$paragraphS.namedStyleType;
|
|
13139
|
+
if (paragraph && level != null && level >= NamedStyleType.HEADING_1 && level <= NamedStyleType.HEADING_5) {
|
|
13140
|
+
while (open.length && open[open.length - 1].level >= level) open.pop().section.endOffset = node.startIndex;
|
|
13141
|
+
const section = {
|
|
13142
|
+
paragraphId: paragraph.paragraphId,
|
|
13143
|
+
paragraphIndex: paragraph.startIndex,
|
|
13144
|
+
startOffset: paragraph.startIndex + 1,
|
|
13145
|
+
endOffset,
|
|
13146
|
+
collapsed: paragraph.headingCollapsed === true
|
|
13147
|
+
};
|
|
13148
|
+
result.push(section);
|
|
13149
|
+
open.push({
|
|
13150
|
+
level,
|
|
13151
|
+
section
|
|
13152
|
+
});
|
|
13153
|
+
}
|
|
13154
|
+
visitContainers(node);
|
|
13155
|
+
}
|
|
13156
|
+
}
|
|
13157
|
+
function visitContainers(node) {
|
|
13158
|
+
if (node.nodeType === DataStreamTreeNodeType.TABLE_CELL || node.nodeType === DataStreamTreeNodeType.COLUMN) {
|
|
13159
|
+
const nodes = node.children.flatMap((child) => child.nodeType === DataStreamTreeNodeType.SECTION_BREAK ? child.children : [child]);
|
|
13160
|
+
visitFlow(nodes, nodes.length ? nodes[nodes.length - 1].endIndex + 1 : node.endIndex);
|
|
13161
|
+
return;
|
|
13162
|
+
}
|
|
13163
|
+
for (const child of node.children) visitContainers(child);
|
|
13164
|
+
}
|
|
13165
|
+
const nodes = sections.flatMap((section) => section.children);
|
|
13166
|
+
visitFlow(nodes, nodes.length ? nodes[nodes.length - 1].endIndex + 1 : 0);
|
|
13167
|
+
return result.sort((a, b) => a.paragraphIndex - b.paragraphIndex);
|
|
13168
|
+
}
|
|
13169
|
+
|
|
13128
13170
|
//#endregion
|
|
13129
13171
|
//#region src/components/docs/view-model/document-view-model.ts
|
|
13130
13172
|
const NON_STRUCTURAL_ROOT_FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -13449,6 +13491,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13449
13491
|
_defineProperty(this, "_treeNodes", []);
|
|
13450
13492
|
_defineProperty(this, "_treeNodesByStartIndex", []);
|
|
13451
13493
|
_defineProperty(this, "_plainTopLevelParagraphNodes", []);
|
|
13494
|
+
_defineProperty(this, "_headingSections", null);
|
|
13495
|
+
_defineProperty(this, "_collapsedHeadingSections", null);
|
|
13452
13496
|
_defineProperty(this, "_metadataCachesDirty", false);
|
|
13453
13497
|
_defineProperty(this, "_textRunsOrderedAndDisjoint", true);
|
|
13454
13498
|
_defineProperty(this, "_paragraphsOrdered", true);
|
|
@@ -13492,6 +13536,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13492
13536
|
this._treeNodes = [];
|
|
13493
13537
|
this._treeNodesByStartIndex = [];
|
|
13494
13538
|
this._plainTopLevelParagraphNodes = [];
|
|
13539
|
+
this._headingSections = null;
|
|
13540
|
+
this._collapsedHeadingSections = null;
|
|
13495
13541
|
this._lastTextRun = null;
|
|
13496
13542
|
this._noteTreeMap.forEach((viewModel) => viewModel.dispose());
|
|
13497
13543
|
this._noteTreeMap.clear();
|
|
@@ -13519,6 +13565,41 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13519
13565
|
getChildren() {
|
|
13520
13566
|
return this._children;
|
|
13521
13567
|
}
|
|
13568
|
+
getHeadingSections() {
|
|
13569
|
+
const snapshot = this.getSnapshot();
|
|
13570
|
+
if (snapshot.documentStyle.documentFlavor !== DocumentFlavor.MODERN) return [];
|
|
13571
|
+
this._headingSections ??= getHeadingSections(this._children, (index) => {
|
|
13572
|
+
var _paragraph$paragraphS;
|
|
13573
|
+
const paragraph = this.getParagraph(index);
|
|
13574
|
+
if (!(paragraph === null || paragraph === void 0 ? void 0 : paragraph.styleId) || ((_paragraph$paragraphS = paragraph.paragraphStyle) === null || _paragraph$paragraphS === void 0 ? void 0 : _paragraph$paragraphS.namedStyleType) != null) return paragraph;
|
|
13575
|
+
return {
|
|
13576
|
+
...paragraph,
|
|
13577
|
+
paragraphStyle: resolveDocumentParagraphStyle(snapshot.documentStyle, paragraph.paragraphStyle, {
|
|
13578
|
+
styles: snapshot.styles,
|
|
13579
|
+
paragraphStyleId: paragraph.styleId
|
|
13580
|
+
})
|
|
13581
|
+
};
|
|
13582
|
+
});
|
|
13583
|
+
return this._headingSections;
|
|
13584
|
+
}
|
|
13585
|
+
getCollapsedHeadingAtOffset(offset) {
|
|
13586
|
+
if (!this._collapsedHeadingSections) {
|
|
13587
|
+
this._collapsedHeadingSections = [];
|
|
13588
|
+
for (const section of this.getHeadingSections()) {
|
|
13589
|
+
const previous = this._collapsedHeadingSections[this._collapsedHeadingSections.length - 1];
|
|
13590
|
+
if (section.collapsed && section.endOffset > section.startOffset && (!previous || section.startOffset >= previous.endOffset)) this._collapsedHeadingSections.push(section);
|
|
13591
|
+
}
|
|
13592
|
+
}
|
|
13593
|
+
let low = 0;
|
|
13594
|
+
let high = this._collapsedHeadingSections.length - 1;
|
|
13595
|
+
while (low <= high) {
|
|
13596
|
+
const middle = Math.floor((low + high) / 2);
|
|
13597
|
+
const section = this._collapsedHeadingSections[middle];
|
|
13598
|
+
if (offset < section.startOffset) high = middle - 1;
|
|
13599
|
+
else if (offset >= section.endOffset) low = middle + 1;
|
|
13600
|
+
else return section;
|
|
13601
|
+
}
|
|
13602
|
+
}
|
|
13522
13603
|
getBody() {
|
|
13523
13604
|
const presentation = getDocumentLayoutPresentation(this._documentDataModel);
|
|
13524
13605
|
return presentation ? presentation.getSnapshot(this._documentDataModel.getSnapshot()).body : this._documentDataModel.getBody();
|
|
@@ -13539,6 +13620,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13539
13620
|
return this;
|
|
13540
13621
|
}
|
|
13541
13622
|
reset(documentDataModel) {
|
|
13623
|
+
this._headingSections = null;
|
|
13624
|
+
this._collapsedHeadingSections = null;
|
|
13542
13625
|
this._children.forEach((child) => child.dispose());
|
|
13543
13626
|
this._textRunsCache.clear();
|
|
13544
13627
|
this._paragraphCache.clear();
|
|
@@ -13564,6 +13647,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13564
13647
|
if (edit.insertText.length > 0 && !this._insertPlainText(edit.offset, edit.insertText)) return false;
|
|
13565
13648
|
}
|
|
13566
13649
|
this._documentDataModel = documentDataModel;
|
|
13650
|
+
this._headingSections = null;
|
|
13651
|
+
this._collapsedHeadingSections = null;
|
|
13567
13652
|
this._metadataCachesDirty = true;
|
|
13568
13653
|
this._lastTextRun = null;
|
|
13569
13654
|
if (!this._textRunsOrderedAndDisjoint) this._buildTextRunsCache();
|
|
@@ -13573,6 +13658,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13573
13658
|
const rootFields = getNonStructuralMutationRootFields(actions);
|
|
13574
13659
|
if (rootFields == null) return false;
|
|
13575
13660
|
this._documentDataModel = documentDataModel;
|
|
13661
|
+
this._headingSections = null;
|
|
13662
|
+
this._collapsedHeadingSections = null;
|
|
13576
13663
|
this._metadataCachesDirty = true;
|
|
13577
13664
|
this._lastTextRun = null;
|
|
13578
13665
|
if (rootFields.has("tableSource")) {
|
|
@@ -14763,7 +14850,7 @@ function _finishTableSkeletonBuild(state) {
|
|
|
14763
14850
|
applyTableOuterBorderSpacing(tableSkeleton, state.sectionBreakConfig);
|
|
14764
14851
|
for (const rowSkeleton of tableSkeleton.rows) _verticalAlignInCell(rowSkeleton, table.tableRows[rowSkeleton.index]);
|
|
14765
14852
|
const { pageWidth, marginLeft = 0, marginRight = 0 } = curPage;
|
|
14766
|
-
tableSkeleton.left = getTableLeft(pageWidth - marginLeft - marginRight, state.tableWidth, table.align, table.indent);
|
|
14853
|
+
tableSkeleton.left = getTableLeft(pageWidth - marginLeft - marginRight, state.tableWidth, table.align, table.indent, shouldAllowImportedTableMarginOverflow(state.sectionBreakConfig.documentCompatibilityPolicy ?? getDocumentCompatibilityPolicy(), table));
|
|
14767
14854
|
state.complete = true;
|
|
14768
14855
|
}
|
|
14769
14856
|
function applyMergedCellContentHeights(tableSkeleton, mergedCellContentHeights) {
|
|
@@ -14918,7 +15005,7 @@ function cachePrecomputedSlicedTableSkeletons(ctx, tableNode, availableHeight, r
|
|
|
14918
15005
|
});
|
|
14919
15006
|
}
|
|
14920
15007
|
function _finishTableSkeletonsBuild(state) {
|
|
14921
|
-
updateTableSkeletonsPosition(state.createCache, state.curPage, state.skeTables, state.table);
|
|
15008
|
+
updateTableSkeletonsPosition(state.createCache, state.curPage, state.skeTables, state.table, state.sectionBreakConfig);
|
|
14922
15009
|
state.skeTables.forEach((table) => applyTableOuterBorderSpacing(table, state.sectionBreakConfig));
|
|
14923
15010
|
const policy = state.sectionBreakConfig.documentCompatibilityPolicy ?? getDocumentCompatibilityPolicy();
|
|
14924
15011
|
state.result = {
|
|
@@ -14977,7 +15064,7 @@ function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakCo
|
|
|
14977
15064
|
cellPageHeights = dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, row, table, createCache, false, precomputedTable === null || precomputedTable === void 0 ? void 0 : precomputedTable.rows[row], void 0, cellPageHeights);
|
|
14978
15065
|
while (cellPageHeights);
|
|
14979
15066
|
}
|
|
14980
|
-
updateTableSkeletonsPosition(createCache, curPage, skeTables, table);
|
|
15067
|
+
updateTableSkeletonsPosition(createCache, curPage, skeTables, table, sectionBreakConfig);
|
|
14981
15068
|
skeTables.forEach((table) => applyTableOuterBorderSpacing(table, sectionBreakConfig));
|
|
14982
15069
|
const documentCompatibilityPolicy = sectionBreakConfig.documentCompatibilityPolicy ?? getDocumentCompatibilityPolicy();
|
|
14983
15070
|
return {
|
|
@@ -14985,10 +15072,10 @@ function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakCo
|
|
|
14985
15072
|
fromCurrentPage: createCache.fromCurrentPage !== false && skeTables[0].height <= availableHeight + documentCompatibilityPolicy.table.currentPageOverflowTolerance
|
|
14986
15073
|
};
|
|
14987
15074
|
}
|
|
14988
|
-
function updateTableSkeletonsPosition(cache, curPage, skeTables, table) {
|
|
15075
|
+
function updateTableSkeletonsPosition(cache, curPage, skeTables, table, sectionBreakConfig) {
|
|
14989
15076
|
const { pageWidth, marginLeft = 0, marginRight = 0 } = curPage;
|
|
14990
15077
|
const { tableWidth } = cache;
|
|
14991
|
-
const tableLeft = getTableLeft(pageWidth - marginLeft - marginRight, tableWidth, table.align, table.indent);
|
|
15078
|
+
const tableLeft = getTableLeft(pageWidth - marginLeft - marginRight, tableWidth, table.align, table.indent, shouldAllowImportedTableMarginOverflow(sectionBreakConfig.documentCompatibilityPolicy ?? getDocumentCompatibilityPolicy(), table));
|
|
14992
15079
|
const rowFragments = /* @__PURE__ */ new Map();
|
|
14993
15080
|
for (const part of skeTables) for (const row of part.rows) if (!row.isRepeatRow) rowFragments.set(row.index, (rowFragments.get(row.index) ?? 0) + 1);
|
|
14994
15081
|
let tableIndex = 0;
|
|
@@ -15322,11 +15409,11 @@ function resolveTableLayoutColumns(table, availableWidth, traditional = false) {
|
|
|
15322
15409
|
}))
|
|
15323
15410
|
};
|
|
15324
15411
|
}
|
|
15325
|
-
function getTableLeft(pageWidth, tableWidth, align, indent = { v: 0 }) {
|
|
15412
|
+
function getTableLeft(pageWidth, tableWidth, align, indent = { v: 0 }, allowMarginOverflow = false) {
|
|
15326
15413
|
switch (align) {
|
|
15327
15414
|
case TableAlignmentType.START: return indent.v;
|
|
15328
|
-
case TableAlignmentType.END: return Math.max(0, pageWidth - tableWidth);
|
|
15329
|
-
case TableAlignmentType.CENTER: return Math.max(0, (pageWidth - tableWidth) / 2);
|
|
15415
|
+
case TableAlignmentType.END: return allowMarginOverflow ? pageWidth - tableWidth : Math.max(0, pageWidth - tableWidth);
|
|
15416
|
+
case TableAlignmentType.CENTER: return allowMarginOverflow ? (pageWidth - tableWidth) / 2 : Math.max(0, (pageWidth - tableWidth) / 2);
|
|
15330
15417
|
default: throw new Error("Unknown table alignment type");
|
|
15331
15418
|
}
|
|
15332
15419
|
}
|
|
@@ -15963,6 +16050,19 @@ function _isDocxColumnBreakVisuallyBlankColumn(column) {
|
|
|
15963
16050
|
function _hasOnlyCustomBlockGlyphs(glyphs) {
|
|
15964
16051
|
return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK);
|
|
15965
16052
|
}
|
|
16053
|
+
function _mergeTrailingBlockEndShapedTexts(shapedTextList) {
|
|
16054
|
+
const result = [];
|
|
16055
|
+
for (const shapedText of shapedTextList) {
|
|
16056
|
+
const previous = result[result.length - 1];
|
|
16057
|
+
if ((previous === null || previous === void 0 ? void 0 : previous.breakPointType) === "Mandatory" && _endsWithToken(previous.text, previous.glyphs, DataStreamTreeTokenType.PARAGRAPH) && shapedText.glyphs.length > 0 && shapedText.glyphs.some((glyph) => glyph.streamType === DataStreamTreeTokenType.BLOCK_END) && shapedText.glyphs.every((glyph, index) => glyph.width === 0 && (glyph.streamType === DataStreamTreeTokenType.BLOCK_END || index === shapedText.glyphs.length - 1 && glyph.streamType === DataStreamTreeTokenType.SECTION_BREAK))) result[result.length - 1] = {
|
|
16058
|
+
...previous,
|
|
16059
|
+
text: previous.text + shapedText.text,
|
|
16060
|
+
glyphs: [...previous.glyphs, ...shapedText.glyphs]
|
|
16061
|
+
};
|
|
16062
|
+
else result.push(shapedText);
|
|
16063
|
+
}
|
|
16064
|
+
return result;
|
|
16065
|
+
}
|
|
15966
16066
|
function _mergeAdjacentCustomBlockShapedTexts(shapedTextList, customBlockDrawings) {
|
|
15967
16067
|
const mergedShapedTextList = [];
|
|
15968
16068
|
for (const originShapedText of shapedTextList) {
|
|
@@ -16445,7 +16545,7 @@ function _prepareLineBreaking(ctx, viewModel, curPage, paragraphNode, sectionBre
|
|
|
16445
16545
|
...getFontCreateConfig(endIndex - paragraphNode.contentStartIndex, viewModel, paragraphNode, sectionBreakConfig, {
|
|
16446
16546
|
...paragraph,
|
|
16447
16547
|
paragraphStyle: resolvedParagraphStyle
|
|
16448
|
-
}).textStyle,
|
|
16548
|
+
}, false).textStyle,
|
|
16449
16549
|
ul: { s: BooleanNumber.FALSE }
|
|
16450
16550
|
} : void 0;
|
|
16451
16551
|
const bulletSkeleton = dealWithBullet(bullet, lists, listLevelAncestors, localeService, false, markerTextStyle);
|
|
@@ -16514,7 +16614,7 @@ function _layoutShapedTexts({ ctx, viewModel, shapedTextList, allPages: initialP
|
|
|
16514
16614
|
let deferredRenderedMarkers = [];
|
|
16515
16615
|
const retainedBreaks = (_ctx$footnoteLayout = ctx.footnoteLayout) === null || _ctx$footnoteLayout === void 0 ? void 0 : _ctx$footnoteLayout.getReferencePageBreaks(paragraphNode.endIndex);
|
|
16516
16616
|
const referencePageBreaks = retainedBreaks ? new Set(retainedBreaks.map((offset) => offset - paragraphNode.contentStartIndex)) : void 0;
|
|
16517
|
-
const mergedShapedTextList = _mergeAdjacentCustomBlockShapedTexts(_splitAtReferencePageBreaks(shapedTextList, referencePageBreaks), paragraphNonInlineSkeDrawingsByBlockId);
|
|
16617
|
+
const mergedShapedTextList = _mergeTrailingBlockEndShapedTexts(_mergeAdjacentCustomBlockShapedTexts(_splitAtReferencePageBreaks(shapedTextList, referencePageBreaks), paragraphNonInlineSkeDrawingsByBlockId));
|
|
16518
16618
|
for (let shapedIndex = 0; shapedIndex < mergedShapedTextList.length; shapedIndex++) {
|
|
16519
16619
|
const { text, glyphs, breakPointType } = mergedShapedTextList[shapedIndex];
|
|
16520
16620
|
const textStartIndex = paragraphNode.contentStartIndex + shapedTextOffset;
|
|
@@ -16524,6 +16624,7 @@ function _layoutShapedTexts({ ctx, viewModel, shapedTextList, allPages: initialP
|
|
|
16524
16624
|
const textEndIndex = textStartIndex + textGlyphCount;
|
|
16525
16625
|
const pushPending = (pendingGlyphs = glyphs, layoutBreakPointType = breakPointType) => {
|
|
16526
16626
|
if (pendingGlyphs.length === 0) return;
|
|
16627
|
+
const markerSourceIndex = textStartIndex - paragraphNode.contentStartIndex - _glyphCount(deferredRenderedMarkers);
|
|
16527
16628
|
if (deferredRenderedMarkers.length > 0) {
|
|
16528
16629
|
pendingGlyphs = [...deferredRenderedMarkers, ...pendingGlyphs];
|
|
16529
16630
|
deferredRenderedMarkers = [];
|
|
@@ -16531,7 +16632,16 @@ function _layoutShapedTexts({ ctx, viewModel, shapedTextList, allPages: initialP
|
|
|
16531
16632
|
syncActiveParagraphDrawings(pendingGlyphs, paragraphNonInlineSkeDrawings, paragraphInlineSkeDrawings, paragraphNonInlineSkeDrawingsByBlockId, paragraphInlineSkeDrawingsByBlockId);
|
|
16532
16633
|
const nonFlowAnchor = isNonFlowFloatingAnchor(pendingGlyphs, paragraphNonInlineSkeDrawings);
|
|
16533
16634
|
const preserveParagraphStart = nonFlowAnchor && mergedShapedTextList.slice(shapedIndex + 1).some(({ glyphs }) => glyphs.some((glyph) => glyph.width > 0 && glyph.streamType !== DataStreamTreeTokenType.PARAGRAPH && glyph.streamType !== DataStreamTreeTokenType.SECTION_BREAK && glyph.streamType !== DataStreamTreeTokenType.DOCS_END));
|
|
16534
|
-
|
|
16635
|
+
const renderBullet = renderParagraphBullet && !preserveParagraphStart;
|
|
16636
|
+
const paragraph = renderBullet && paragraphConfig.bulletSkeleton ? viewModel.getParagraph(paragraphNode.endIndex) : void 0;
|
|
16637
|
+
const markerTextStyle = paragraph ? getFontCreateConfig(markerSourceIndex, viewModel, paragraphNode, sectionBreakConfig, {
|
|
16638
|
+
...paragraph,
|
|
16639
|
+
paragraphStyle: paragraphConfig.paragraphStyle
|
|
16640
|
+
}, false).textStyle : void 0;
|
|
16641
|
+
allPages = layoutParagraph(ctx, pendingGlyphs, allPages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText || !nonFlowAnchor && hasOnlyFloatingCustomBlockGlyphs(pendingGlyphs, paragraphNonInlineSkeDrawingsByBlockId), layoutBreakPointType, renderBullet, startNewLine, markerTextStyle ? {
|
|
16642
|
+
cl: markerTextStyle.cl,
|
|
16643
|
+
ul: markerTextStyle.ul
|
|
16644
|
+
} : void 0);
|
|
16535
16645
|
if (!preserveParagraphStart) {
|
|
16536
16646
|
isParagraphFirstShapedText = false;
|
|
16537
16647
|
renderParagraphBullet = false;
|
|
@@ -16711,7 +16821,23 @@ function hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsB
|
|
|
16711
16821
|
|
|
16712
16822
|
//#endregion
|
|
16713
16823
|
//#region src/components/docs/layout/block/paragraph/paragraph-layout.ts
|
|
16824
|
+
/**
|
|
16825
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
16826
|
+
*
|
|
16827
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16828
|
+
* you may not use this file except in compliance with the License.
|
|
16829
|
+
* You may obtain a copy of the License at
|
|
16830
|
+
*
|
|
16831
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16832
|
+
*
|
|
16833
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16834
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16835
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16836
|
+
* See the License for the specific language governing permissions and
|
|
16837
|
+
* limitations under the License.
|
|
16838
|
+
*/
|
|
16714
16839
|
function dealWidthParagraph(ctx, viewModel, paragraphNode, curPage, sectionBreakConfig, nextParagraphNode) {
|
|
16840
|
+
if (viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex)) return [curPage];
|
|
16715
16841
|
clearFontCreateConfigCache();
|
|
16716
16842
|
const { content = "", children } = paragraphNode;
|
|
16717
16843
|
let tableSkeleton = null;
|
|
@@ -16964,6 +17090,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16964
17090
|
const paragraphEndIndex = Math.min(sectionNode.children.length, paragraphStartIndex + ((options === null || options === void 0 ? void 0 : options.maxParagraphs) ?? Number.POSITIVE_INFINITY));
|
|
16965
17091
|
for (let i = paragraphStartIndex; i < paragraphEndIndex; i++) {
|
|
16966
17092
|
const paragraphNode = sectionNode.children[i];
|
|
17093
|
+
if (viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex)) continue;
|
|
16967
17094
|
let skeletonPages = [];
|
|
16968
17095
|
let currentPageCache = curPage;
|
|
16969
17096
|
if (allCurrentSkeletonPages.length > 0) currentPageCache = allCurrentSkeletonPages[allCurrentSkeletonPages.length - 1];
|
|
@@ -17714,7 +17841,7 @@ function isGlyphGroupBeyondDivideWidth(glyphGroup, offsetLeft, divideWidth, hang
|
|
|
17714
17841
|
const shrinkability = precedingGlyphs !== void 0 && (wordFitsWithPunctuationCompression || spacedWesternWordFits || !precedingLineCanStretch && offsetLeft + width - trailingShrinkability - hangingExtra - divideWidth <= divideWidth - offsetLeft) && !precedingGlyphs.some((glyph) => glyph.glyphType === 4) && !glyphGroup.some((glyph) => glyph.glyphType === 4) ? getGlyphGroupShrinkability(precedingGlyphs) + getGlyphGroupShrinkability(glyphGroup) - (trailingAutoSpacing + leadingAutoSpacing) / 2 : trailingShrinkability;
|
|
17715
17842
|
return isBeyondDivideWidth(offsetLeft + width - shrinkability - hangingExtra, divideWidth, lineWrapTolerance);
|
|
17716
17843
|
}
|
|
17717
|
-
function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", renderBullet = isParagraphFirstShapedText, startNewLine = false) {
|
|
17844
|
+
function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", renderBullet = isParagraphFirstShapedText, startNewLine = false, markerTextStyle) {
|
|
17718
17845
|
paragraphConfig.documentCompatibilityPolicy ??= sectionBreakConfig.documentCompatibilityPolicy;
|
|
17719
17846
|
if (isParagraphFirstShapedText || startNewLine) {
|
|
17720
17847
|
if (renderBullet && paragraphConfig.bulletSkeleton) {
|
|
@@ -17723,7 +17850,14 @@ function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
|
|
|
17723
17850
|
const { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 10.5 } = sectionBreakConfig;
|
|
17724
17851
|
const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
|
|
17725
17852
|
const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
|
|
17726
|
-
const
|
|
17853
|
+
const resolvedBulletSkeleton = markerTextStyle ? {
|
|
17854
|
+
...bulletSkeleton,
|
|
17855
|
+
ts: {
|
|
17856
|
+
...markerTextStyle,
|
|
17857
|
+
...bulletSkeleton.ts
|
|
17858
|
+
}
|
|
17859
|
+
} : bulletSkeleton;
|
|
17860
|
+
const bulletGlyph = createSkeletonBulletGlyph(glyphGroup[0], resolvedBulletSkeleton, charSpaceApply, paragraphConfig.documentCompatibilityPolicy ?? sectionBreakConfig.documentCompatibilityPolicy);
|
|
17727
17861
|
const paragraphProperties = bulletSkeleton.paragraphProperties || {};
|
|
17728
17862
|
paragraphConfig.paragraphStyle = {
|
|
17729
17863
|
...paragraphProperties,
|
|
@@ -18227,7 +18361,7 @@ function _getParagraphContentMetrics(ctx, glyphGroup, lastPage, column, sectionB
|
|
|
18227
18361
|
};
|
|
18228
18362
|
}
|
|
18229
18363
|
function _getParagraphLineMetrics(ctx, glyphGroup, lastPage, column, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, defaultSpanMetrics) {
|
|
18230
|
-
var _sectionBreakConfig$d2;
|
|
18364
|
+
var _paragraphConfig$skeT, _sectionBreakConfig$d2;
|
|
18231
18365
|
const metrics = _getParagraphContentMetrics(ctx, glyphGroup, lastPage, column, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, defaultSpanMetrics);
|
|
18232
18366
|
const { preLine, paragraphIndex, paragraphStyle, spaceAbove, spaceBelow, spacingRule, gridType, snapToGrid, hasInlineCustomBlock, positionedCustomBlockOnly, drawingMLLineHeight, drawingMLBaselineHeight, isZeroWidthNonFlowFloatingAnchorLine, isStructuralTableAnchorLine, isEmptyFramedParagraph, isStandalonePageBoundary, wordAutoLeading } = metrics;
|
|
18233
18367
|
let { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = metrics;
|
|
@@ -18241,10 +18375,12 @@ function _getParagraphLineMetrics(ctx, glyphGroup, lastPage, column, sectionBrea
|
|
|
18241
18375
|
var _section$children$;
|
|
18242
18376
|
return index > 0 && ((_section$children$ = section.children[0]) === null || _section$children$ === void 0 ? void 0 : _section$children$.endIndex) === paragraphIndex;
|
|
18243
18377
|
}) : void 0;
|
|
18378
|
+
const hasInlineTableBoundary = isParagraphFirstShapedText && ((_paragraphConfig$skeT = paragraphConfig.skeTablesInParagraph) === null || _paragraphConfig$skeT === void 0 || (_paragraphConfig$skeT = _paragraphConfig$skeT.find((item) => !item.hasPositioned)) === null || _paragraphConfig$skeT === void 0 ? void 0 : _paragraphConfig$skeT.table.tableSource.textWrap) === TableTextWrapType.NONE;
|
|
18379
|
+
const spaceBeforeTable = hasInlineTableBoundary ? Math.max(0, (preLine === null || preLine === void 0 ? void 0 : preLine.spaceBelowApply) ?? 0) : 0;
|
|
18244
18380
|
let { marginTop, spaceBelowApply } = isHiddenParagraph ? {
|
|
18245
18381
|
marginTop: 0,
|
|
18246
18382
|
spaceBelowApply: (preLine === null || preLine === void 0 ? void 0 : preLine.spaceBelowApply) ?? 0
|
|
18247
|
-
} : __getParagraphSpace(((_sectionBreakConfig$d2 = sectionBreakConfig.documentCompatibilityPolicy) === null || _sectionBreakConfig$d2 === void 0 ? void 0 : _sectionBreakConfig$d2.mode) === "drawingml", lineSpacingApply, suppressCellAutoSpaceAbove ? void 0 : spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine, _shouldSuppressPageTopSpacing(lastPage, column, paragraphConfig, preLine, firstPageNumber, startingSection != null), drawingMLLineHeight);
|
|
18383
|
+
} : __getParagraphSpace(((_sectionBreakConfig$d2 = sectionBreakConfig.documentCompatibilityPolicy) === null || _sectionBreakConfig$d2 === void 0 ? void 0 : _sectionBreakConfig$d2.mode) === "drawingml", lineSpacingApply, suppressCellAutoSpaceAbove ? void 0 : spaceAbove, spaceBelow, isParagraphFirstShapedText, hasInlineTableBoundary ? void 0 : preLine, !hasInlineTableBoundary && _shouldSuppressPageTopSpacing(lastPage, column, paragraphConfig, preLine, firstPageNumber, startingSection != null), drawingMLLineHeight);
|
|
18248
18384
|
if (preLine) marginTop += sectionBreakConfig.lineGap ?? 0;
|
|
18249
18385
|
if (startingSection && marginTop > 0 && isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy)) marginTop = _collapseSectionBeforeSpacing(ctx, startingSection.children[0].startIndex - 2, marginTop);
|
|
18250
18386
|
if (positionedCustomBlockOnly) spaceBelowApply = 0;
|
|
@@ -18283,6 +18419,7 @@ function _getParagraphLineMetrics(ctx, glyphGroup, lastPage, column, sectionBrea
|
|
|
18283
18419
|
paddingBottom,
|
|
18284
18420
|
contentHeight,
|
|
18285
18421
|
marginTop,
|
|
18422
|
+
spaceBeforeTable,
|
|
18286
18423
|
spaceBelowApply,
|
|
18287
18424
|
borderTopSpace,
|
|
18288
18425
|
borderBottomSpace,
|
|
@@ -18371,7 +18508,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18371
18508
|
const previousLineHeight = preLine === null || preLine === void 0 ? void 0 : preLine.lineHeight;
|
|
18372
18509
|
const previousLineMarginBottom = preLine === null || preLine === void 0 ? void 0 : preLine.marginBottom;
|
|
18373
18510
|
const { paragraphNonInlineSkeDrawings, skeTablesInParagraph, skeHeaders, skeFooters, pDrawingAnchor, paragraphIndex } = paragraphConfig;
|
|
18374
|
-
const { paragraphStyle, spacingRule, drawingMLLineHeight, drawingMLBaselineHeight, gridType, snapToGrid, hasInlineCustomBlock, positionedCustomBlockOnly, isStandalonePageBoundary, paddingTop, paddingBottom, contentHeight, marginTop, spaceBelowApply, borderTopSpace, borderBottomSpace, wordAutoLeading } = _getParagraphLineMetrics(ctx, glyphGroup, lastPage, column, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, defaultSpanMetrics);
|
|
18511
|
+
const { paragraphStyle, spacingRule, drawingMLLineHeight, drawingMLBaselineHeight, gridType, snapToGrid, hasInlineCustomBlock, positionedCustomBlockOnly, isStandalonePageBoundary, paddingTop, paddingBottom, contentHeight, marginTop, spaceBeforeTable, spaceBelowApply, borderTopSpace, borderBottomSpace, wordAutoLeading } = _getParagraphLineMetrics(ctx, glyphGroup, lastPage, column, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, defaultSpanMetrics);
|
|
18375
18512
|
const { indentFirstLine, hanging, indentStart, indentEnd } = paragraphStyle;
|
|
18376
18513
|
const lineHeight = marginTop + paddingTop + contentHeight + paddingBottom;
|
|
18377
18514
|
const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
|
|
@@ -18389,10 +18526,12 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18389
18526
|
const { deferredInlineGroupAnchorDrawings, deferredTopBottomAnchorDrawings } = _positionLineDrawings(ctx, glyphGroup, column, lastPage, paragraphConfig, lineTop, lineHeight, paragraphAnchorLeft, hasInlineCustomBlock, isParagraphFirstShapedText);
|
|
18390
18527
|
if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
|
|
18391
18528
|
var _pDrawingAnchor$get2;
|
|
18392
|
-
needOpenNewPageByTableLayout = _updateAndPositionTable(ctx, lineTop, lineHeight, lastPage, pages, column, section, skeTablesInParagraph, paragraphConfig.paragraphIndex, sectionBreakConfig, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get2 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get2 === void 0 ? void 0 : _pDrawingAnchor$get2.top);
|
|
18529
|
+
needOpenNewPageByTableLayout = _updateAndPositionTable(ctx, lineTop + spaceBeforeTable, lineHeight, lastPage, pages, column, section, skeTablesInParagraph, paragraphConfig.paragraphIndex, sectionBreakConfig, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get2 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get2 === void 0 ? void 0 : _pDrawingAnchor$get2.top);
|
|
18393
18530
|
}
|
|
18394
18531
|
const hasSameParagraphTopBottomDrawingWithInline = hasInlineCustomBlock && paragraphNonInlineSkeDrawings != null && [...paragraphNonInlineSkeDrawings.values()].some((drawing) => drawing.drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM);
|
|
18395
|
-
|
|
18532
|
+
let tableFlowTop = lineTop;
|
|
18533
|
+
for (const item of skeTablesInParagraph ?? []) if (item.hasPositioned && item.table.parent === lastPage && item.table.tableSource.textWrap === TableTextWrapType.NONE) tableFlowTop = Math.max(lineTop, item.table.top + item.table.height - section.top);
|
|
18534
|
+
const calculatedLineTop = positionedCustomBlockOnly ? tableFlowTop : calculateLineTopByDrawings(lineHeight, tableFlowTop, lastPage, headerPage, footerPage, column.left, column.width, section.top, isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy) ? Math.max(24, Math.min(__getGlyphGroupWidth(glyphGroup) - .001, column.width - 1)) : 0);
|
|
18396
18535
|
const previousTopBottomCustomBlockFlowBottom = deferredTopBottomAnchorDrawings.length > 0 ? paragraphConfig.topBottomCustomBlockFlowBottom : void 0;
|
|
18397
18536
|
const newLineTop = previousTopBottomCustomBlockFlowBottom == null ? calculatedLineTop : Math.max(calculatedLineTop, previousTopBottomCustomBlockFlowBottom);
|
|
18398
18537
|
const clipsSameParagraphInlineDrawing = hasSameParagraphTopBottomDrawingWithInline && newLineTop < section.height;
|
|
@@ -18566,7 +18705,7 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column,
|
|
|
18566
18705
|
if (firstUnPositionedTable.isSlideTable === false || tableSource.textWrap === TableTextWrapType.NONE) switch (tableSource.textWrap) {
|
|
18567
18706
|
case TableTextWrapType.NONE:
|
|
18568
18707
|
table.top = section.top + lineTop;
|
|
18569
|
-
table.left = column.left + getTableLeft(column.width, table.width, tableSource.align, tableSource.indent);
|
|
18708
|
+
table.left = column.left + getTableLeft(column.width, table.width, tableSource.align, tableSource.indent, shouldAllowImportedTableMarginOverflow(sectionBreakConfig.documentCompatibilityPolicy ?? getDocumentCompatibilityPolicy(), tableSource));
|
|
18570
18709
|
__avoidFlowAffectingDrawingsForTable(table, page, column);
|
|
18571
18710
|
__avoidNonOverlappingFloatingTables(table, page);
|
|
18572
18711
|
break;
|
|
@@ -20006,7 +20145,7 @@ const DEFAULT_TEXT_RUN = {
|
|
|
20006
20145
|
st: 0,
|
|
20007
20146
|
ed: 0
|
|
20008
20147
|
};
|
|
20009
|
-
function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
|
|
20148
|
+
function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig, paragraph, includeCustomRangeStyle = true) {
|
|
20010
20149
|
var _textStyle$eastAsiaFo;
|
|
20011
20150
|
const { gridType = GridType.LINES, charSpace = 0, documentTextStyle = {}, pageSize = {
|
|
20012
20151
|
width: Number.POSITIVE_INFINITY,
|
|
@@ -20020,7 +20159,7 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
|
|
|
20020
20159
|
const customDecoration = viewModel.getCustomDecoration(index + startIndex);
|
|
20021
20160
|
const showCustomDecoration = customDecoration && customDecoration.show !== false;
|
|
20022
20161
|
const customDecorationStyle = showCustomDecoration ? getCustomDecorationStyle(customDecoration) : null;
|
|
20023
|
-
const customRange = viewModel.getCustomRange(index + startIndex);
|
|
20162
|
+
const customRange = includeCustomRangeStyle ? viewModel.getCustomRange(index + startIndex) : null;
|
|
20024
20163
|
const showCustomRange = customRange && customRange.show !== false;
|
|
20025
20164
|
const customRangeStyle = showCustomRange ? getCustomRangeStyle(customRange) : null;
|
|
20026
20165
|
const hasAddonStyle = showCustomRange || showCustomDecoration || !!bullet || (paragraphStyle === null || paragraphStyle === void 0 ? void 0 : paragraphStyle.namedStyleType) || (paragraphStyle === null || paragraphStyle === void 0 ? void 0 : paragraphStyle.textStyle) != null || (paragraphStyle === null || paragraphStyle === void 0 ? void 0 : paragraphStyle.paragraphMarkTextStyle) != null;
|
|
@@ -23452,6 +23591,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23452
23591
|
_defineProperty(this, "_paginationMetrics", null);
|
|
23453
23592
|
_defineProperty(this, "_completedPageCount", void 0);
|
|
23454
23593
|
_defineProperty(this, "_lastCompleteSkeletonData", null);
|
|
23594
|
+
_defineProperty(this, "_completedHeadingCollapseSignature", "[]");
|
|
23595
|
+
_defineProperty(this, "_publishedHeadingCollapseSignature", "[]");
|
|
23455
23596
|
_defineProperty(this, "_pendingInvalidationAnchor", null);
|
|
23456
23597
|
_defineProperty(this, "_layoutGeneration", 0);
|
|
23457
23598
|
_defineProperty(this, "_activeLayout", null);
|
|
@@ -23509,29 +23650,48 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23509
23650
|
ctx = retry;
|
|
23510
23651
|
}
|
|
23511
23652
|
this._lastCompleteSkeletonData = this._skeletonData;
|
|
23653
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23654
|
+
this._publishedHeadingCollapseSignature = this._completedHeadingCollapseSignature;
|
|
23512
23655
|
this._completedPageCount = (_this$_skeletonData = this._skeletonData) === null || _this$_skeletonData === void 0 ? void 0 : _this$_skeletonData.pages.length;
|
|
23513
23656
|
this._pendingInvalidationAnchor = null;
|
|
23514
23657
|
this._paginationMetrics = ctx.paginationMetrics ?? null;
|
|
23515
23658
|
this._dirty$.next(true);
|
|
23516
23659
|
}
|
|
23660
|
+
_getHeadingCollapseSignature() {
|
|
23661
|
+
return JSON.stringify(this.getViewModel().getHeadingSections().filter((heading) => heading.collapsed).map((heading) => [
|
|
23662
|
+
heading.paragraphId,
|
|
23663
|
+
heading.startOffset,
|
|
23664
|
+
heading.endOffset
|
|
23665
|
+
]));
|
|
23666
|
+
}
|
|
23517
23667
|
startIncrementalLayout(options) {
|
|
23518
|
-
|
|
23519
|
-
|
|
23668
|
+
const headingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23669
|
+
const headingVisibilityChanged = headingCollapseSignature !== this._completedHeadingCollapseSignature || headingCollapseSignature !== this._publishedHeadingCollapseSignature;
|
|
23670
|
+
const layoutOptions = headingVisibilityChanged ? {
|
|
23671
|
+
...options,
|
|
23672
|
+
anchor: 0,
|
|
23673
|
+
priorityAnchor: (options === null || options === void 0 ? void 0 : options.priorityAnchor) ?? (options === null || options === void 0 ? void 0 : options.anchor) ?? 0,
|
|
23674
|
+
invalidation: void 0,
|
|
23675
|
+
reuseUnaffectedTail: false,
|
|
23676
|
+
preserveInteractionWindow: false
|
|
23677
|
+
} : options;
|
|
23678
|
+
this._modernPageWidth = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.modernPageWidth;
|
|
23679
|
+
this._modernHorizontalMargin = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.modernHorizontalMargin;
|
|
23520
23680
|
this.cancelIncrementalLayout();
|
|
23521
23681
|
this._externalLayoutProgress = null;
|
|
23522
23682
|
this._externalProtectedPages = null;
|
|
23523
23683
|
this._externalProtectedContinuousLayout = null;
|
|
23524
23684
|
const generation = ++this._layoutGeneration;
|
|
23525
|
-
const reason = (
|
|
23685
|
+
const reason = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reason) ?? ((layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor) == null ? "initial" : "edit");
|
|
23526
23686
|
const dataModel = this.getViewModel().getDataModel();
|
|
23527
23687
|
const sections = this.getViewModel().getChildren();
|
|
23528
23688
|
const topLevelBlocks = this._getTopLevelBlocks(sections);
|
|
23529
23689
|
const mode = dataModel.documentStyle.documentFlavor === DocumentFlavor.MODERN ? "continuous" : "paginated";
|
|
23530
|
-
const priorityAnchor = (
|
|
23690
|
+
const priorityAnchor = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.priorityAnchor) ?? (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor);
|
|
23531
23691
|
const hasPublishedCheckpoint = this._skeletonData != null || this._lastCompleteSkeletonData != null;
|
|
23532
23692
|
const previousSkeleton = this._lastCompleteSkeletonData ?? this._skeletonData;
|
|
23533
|
-
const invalidation =
|
|
23534
|
-
const layoutAnchor =
|
|
23693
|
+
const invalidation = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.invalidation;
|
|
23694
|
+
const layoutAnchor = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor;
|
|
23535
23695
|
const invalidationAnchor = layoutAnchor == null ? this._pendingInvalidationAnchor ?? void 0 : Math.min(layoutAnchor, this._pendingInvalidationAnchor ?? layoutAnchor);
|
|
23536
23696
|
const mutationDelta = invalidation == null ? 0 : invalidation.newEnd - invalidation.oldEnd;
|
|
23537
23697
|
let priorityPageAnchor = priorityAnchor;
|
|
@@ -23544,7 +23704,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23544
23704
|
const previousPriorityPage = priorityPageIndex < 0 ? null : (previousSkeleton === null || previousSkeleton === void 0 ? void 0 : previousSkeleton.pages[priorityPageIndex]) ?? null;
|
|
23545
23705
|
const previousPriorityPageEnd = previousPriorityPage == null ? null : getLastBodyFlowCharIndex(previousPriorityPage);
|
|
23546
23706
|
const priorityPageEnd = previousPriorityPageEnd == null ? null : previousPriorityPageEnd + (invalidation != null && invalidation.oldStart <= previousPriorityPageEnd ? mutationDelta : 0);
|
|
23547
|
-
const incrementalStart = this._prepareIncrementalLayoutStart(invalidationAnchor, mode, invalidation, (
|
|
23707
|
+
const incrementalStart = this._prepareIncrementalLayoutStart(invalidationAnchor, mode, invalidation, (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.preserveInteractionWindow) === true, (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reuseUnaffectedTail) === false);
|
|
23548
23708
|
this._pendingInvalidationAnchor = hasPublishedCheckpoint ? invalidationAnchor ?? null : null;
|
|
23549
23709
|
this._activeLayout = {
|
|
23550
23710
|
generation,
|
|
@@ -23558,6 +23718,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23558
23718
|
sectionBreakConfig: null,
|
|
23559
23719
|
layoutAnchor: incrementalStart.layoutAnchor,
|
|
23560
23720
|
priorityAnchor: priorityAnchor ?? null,
|
|
23721
|
+
minimumPublicationHeight: mode === "continuous" && headingVisibilityChanged && this._skeletonData != null ? (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.minimumPublicationHeight) ?? 0 : 0,
|
|
23561
23722
|
priorityPageIndex,
|
|
23562
23723
|
priorityPageEnd,
|
|
23563
23724
|
interactionPageTail: incrementalStart.interactionPageTail,
|
|
@@ -23582,16 +23743,16 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23582
23743
|
lastPublishedPageCount: incrementalStart.ctx.skeleton.pages.length > 0 ? Math.max(0, incrementalStart.ctx.skeleton.pages.length - 1) : 0,
|
|
23583
23744
|
lastPublishedBlockCount: incrementalStart.processedBlockCount,
|
|
23584
23745
|
publicationRevision: 0,
|
|
23585
|
-
reuseUnaffectedTail: (
|
|
23746
|
+
reuseUnaffectedTail: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reuseUnaffectedTail) !== false,
|
|
23586
23747
|
paginationRevision: 0,
|
|
23587
|
-
allowMetadataOnlyStructuralTailReuse: (
|
|
23748
|
+
allowMetadataOnlyStructuralTailReuse: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.allowMetadataOnlyStructuralTailReuse) === true,
|
|
23588
23749
|
reusedTail: false,
|
|
23589
23750
|
tailConvergencePageCount: incrementalStart.ctx.skeleton.pages.length,
|
|
23590
23751
|
dirtyRetries: /* @__PURE__ */ new Map(),
|
|
23591
23752
|
preparedHyphenationNodes: /* @__PURE__ */ new WeakSet(),
|
|
23592
23753
|
pendingHyphenation: null,
|
|
23593
23754
|
hyphenationError: null,
|
|
23594
|
-
waitForHyphenationPatterns: (
|
|
23755
|
+
waitForHyphenationPatterns: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.waitForHyphenationPatterns) === true
|
|
23595
23756
|
};
|
|
23596
23757
|
return generation;
|
|
23597
23758
|
}
|
|
@@ -23966,10 +24127,12 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23966
24127
|
if (isFinalPublication) {
|
|
23967
24128
|
var _state$ctx$skeleton;
|
|
23968
24129
|
this._lastCompleteSkeletonData = state.ctx.skeleton;
|
|
24130
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23969
24131
|
this._completedPageCount = (_state$ctx$skeleton = state.ctx.skeleton) === null || _state$ctx$skeleton === void 0 ? void 0 : _state$ctx$skeleton.pages.length;
|
|
23970
24132
|
this._pendingInvalidationAnchor = null;
|
|
23971
24133
|
}
|
|
23972
24134
|
this._skeletonData = isFinalPublication ? state.ctx.skeleton : !this._isolateIncrementalPublications && state.mode === "paginated" ? this._createSharedPublishablePartialSkeleton(state, publishedPageCount) : this._createPublishablePartialSkeleton(state, publishedPageCount);
|
|
24135
|
+
this._publishedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23973
24136
|
this._paginationMetrics = state.ctx.paginationMetrics ?? null;
|
|
23974
24137
|
this._dirty$.next(true);
|
|
23975
24138
|
didPublish = true;
|
|
@@ -23994,6 +24157,19 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23994
24157
|
const startIndex = ((_stablePages$at = stablePages.at(-1)) === null || _stablePages$at === void 0 ? void 0 : _stablePages$at.ed) ?? -1;
|
|
23995
24158
|
updateBlockIndex(activePages, startIndex, state.ctx.docsConfig.documentCompatibilityPolicy);
|
|
23996
24159
|
mergeContinuousDuplicatePages(activePages, state.mode === "continuous");
|
|
24160
|
+
if (state.mode === "continuous") {
|
|
24161
|
+
const paragraphConfigCache = new Map([...state.ctx.paragraphConfigCache].map(([segmentId, configs]) => [segmentId, new Map([...configs].map(([index, config]) => {
|
|
24162
|
+
var _config$paragraphInli;
|
|
24163
|
+
return [index, ((_config$paragraphInli = config.paragraphInlineSkeDrawings) === null || _config$paragraphInli === void 0 ? void 0 : _config$paragraphInli.size) ? {
|
|
24164
|
+
...config,
|
|
24165
|
+
paragraphInlineSkeDrawings: new Map([...config.paragraphInlineSkeDrawings].map(([id, drawing]) => [id, { ...drawing }]))
|
|
24166
|
+
} : config];
|
|
24167
|
+
}))]));
|
|
24168
|
+
updateInlineDrawingCoordsAndBorder({
|
|
24169
|
+
...state.ctx,
|
|
24170
|
+
paragraphConfigCache
|
|
24171
|
+
}, activePages);
|
|
24172
|
+
}
|
|
23997
24173
|
const flowPages = [...stablePages, ...activePages];
|
|
23998
24174
|
const currentPriorityPageIndex = state.priorityAnchor == null ? -1 : this._findBodyPageIndex(flowPages, state.priorityAnchor);
|
|
23999
24175
|
const previousPriorityPage = previous === null || previous === void 0 ? void 0 : previous.pages[state.priorityPageIndex];
|
|
@@ -24267,6 +24443,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24267
24443
|
if (progress.complete) {
|
|
24268
24444
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24269
24445
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24446
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24270
24447
|
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24271
24448
|
this._pendingInvalidationAnchor = null;
|
|
24272
24449
|
this._externalProtectedContinuousLayout = null;
|
|
@@ -24337,6 +24514,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24337
24514
|
if (publicationToApply.resources.drawingAnchor != null) skeletonData.drawingAnchor = hydrateDrawingAnchors(publicationToApply.resources.drawingAnchor);
|
|
24338
24515
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24339
24516
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24517
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24340
24518
|
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24341
24519
|
this._pendingInvalidationAnchor = null;
|
|
24342
24520
|
this._externalProtectedPages = null;
|
|
@@ -24344,6 +24522,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24344
24522
|
}
|
|
24345
24523
|
this._skeletonData = skeletonData;
|
|
24346
24524
|
this._externalLayoutProgress = progress.complete ? null : progress;
|
|
24525
|
+
this._publishedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24347
24526
|
this._dirty$.next(true);
|
|
24348
24527
|
this._layoutProgress$.next(progress);
|
|
24349
24528
|
return { didReplaceProtectedPages };
|
|
@@ -24397,7 +24576,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24397
24576
|
const firstUnprotectedLineOffset = flow.lines.findIndex((line) => line.st > protectedEndOffset);
|
|
24398
24577
|
if (firstUnprotectedLineOffset < 0) return null;
|
|
24399
24578
|
const existingColumn = (_skeletonData$pages$p = skeletonData.pages[publication.block.pageIndex]) === null || _skeletonData$pages$p === void 0 || (_skeletonData$pages$p = _skeletonData$pages$p.sections[flow.sectionIndex]) === null || _skeletonData$pages$p === void 0 ? void 0 : _skeletonData$pages$p.columns[flow.columnIndex];
|
|
24400
|
-
if (existingColumn == null)
|
|
24579
|
+
if (existingColumn == null) return null;
|
|
24401
24580
|
const firstUnprotectedLine = flow.lines[firstUnprotectedLineOffset];
|
|
24402
24581
|
const matchingTailLineIndex = existingColumn.lines.findIndex((line) => line.st >= firstUnprotectedLine.st);
|
|
24403
24582
|
const targetLineIndex = matchingTailLineIndex < 0 ? existingColumn.lines.length : matchingTailLineIndex;
|
|
@@ -25132,7 +25311,23 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
25132
25311
|
const anchor = state.priorityAnchor;
|
|
25133
25312
|
if (anchor == null || state.complete) return true;
|
|
25134
25313
|
if (state.interactionPageComplete) return true;
|
|
25135
|
-
if (state.mode === "continuous")
|
|
25314
|
+
if (state.mode === "continuous") {
|
|
25315
|
+
if (state.laidOutThrough < anchor) return false;
|
|
25316
|
+
if (state.minimumPublicationHeight <= 0) return true;
|
|
25317
|
+
let height = 0;
|
|
25318
|
+
for (const page of state.ctx.skeleton.pages) for (const section of page.sections) {
|
|
25319
|
+
let sectionHeight = 0;
|
|
25320
|
+
for (const column of section.columns) for (let index = column.lines.length - 1; index >= 0; index--) {
|
|
25321
|
+
const line = column.lines[index];
|
|
25322
|
+
if (line.paragraphIndex <= state.stableLaidOutThrough) {
|
|
25323
|
+
sectionHeight = Math.max(sectionHeight, line.top + line.lineHeight);
|
|
25324
|
+
break;
|
|
25325
|
+
}
|
|
25326
|
+
}
|
|
25327
|
+
height += sectionHeight;
|
|
25328
|
+
}
|
|
25329
|
+
return height >= state.minimumPublicationHeight;
|
|
25330
|
+
}
|
|
25136
25331
|
if (state.priorityPageEnd != null) {
|
|
25137
25332
|
var _state$invalidation;
|
|
25138
25333
|
const requiredOffset = Math.max(anchor, state.priorityPageEnd, ((_state$invalidation = state.invalidation) === null || _state$invalidation === void 0 ? void 0 : _state$invalidation.newEnd) ?? anchor);
|
|
@@ -25319,7 +25514,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
25319
25514
|
const curSkeletonPage = getLastPage(ctx.skeleton.pages);
|
|
25320
25515
|
if (sectionBreakConfig == null || curSkeletonPage == null) throw new Error("Incremental document layout failed to initialize a section page.");
|
|
25321
25516
|
const paragraphNode = sectionNode.children[state.paragraphIndex];
|
|
25322
|
-
const tableNode =
|
|
25517
|
+
const tableNode = paragraphNode && !ctx.viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex) && paragraphNode.children.length === 1 && paragraphNode.children[0].nodeType === DataStreamTreeNodeType.TABLE ? paragraphNode.children[0] : null;
|
|
25323
25518
|
if (tableNode != null) {
|
|
25324
25519
|
state.pendingTableBuild ??= startTableSkeletonBuild(ctx, curSkeletonPage, ctx.viewModel, tableNode, sectionBreakConfig);
|
|
25325
25520
|
if (state.pendingTableBuild != null && !stepTableSkeletonBuild(state.pendingTableBuild)) return;
|
|
@@ -35581,7 +35776,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
35581
35776
|
//#endregion
|
|
35582
35777
|
//#region package.json
|
|
35583
35778
|
var name = "@univerjs/engine-render";
|
|
35584
|
-
var version = "1.
|
|
35779
|
+
var version = "1.3.0";
|
|
35585
35780
|
|
|
35586
35781
|
//#endregion
|
|
35587
35782
|
//#region src/config/config.ts
|