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