@univerjs/engine-render 1.1.0 → 1.2.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")) {
@@ -16712,7 +16799,23 @@ function hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsB
16712
16799
 
16713
16800
  //#endregion
16714
16801
  //#region src/components/docs/layout/block/paragraph/paragraph-layout.ts
16802
+ /**
16803
+ * Copyright 2023-present DreamNum Co., Ltd.
16804
+ *
16805
+ * Licensed under the Apache License, Version 2.0 (the "License");
16806
+ * you may not use this file except in compliance with the License.
16807
+ * You may obtain a copy of the License at
16808
+ *
16809
+ * http://www.apache.org/licenses/LICENSE-2.0
16810
+ *
16811
+ * Unless required by applicable law or agreed to in writing, software
16812
+ * distributed under the License is distributed on an "AS IS" BASIS,
16813
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16814
+ * See the License for the specific language governing permissions and
16815
+ * limitations under the License.
16816
+ */
16715
16817
  function dealWidthParagraph(ctx, viewModel, paragraphNode, curPage, sectionBreakConfig, nextParagraphNode) {
16818
+ if (viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex)) return [curPage];
16716
16819
  clearFontCreateConfigCache();
16717
16820
  const { content = "", children } = paragraphNode;
16718
16821
  let tableSkeleton = null;
@@ -16965,6 +17068,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
16965
17068
  const paragraphEndIndex = Math.min(sectionNode.children.length, paragraphStartIndex + ((options === null || options === void 0 ? void 0 : options.maxParagraphs) ?? Number.POSITIVE_INFINITY));
16966
17069
  for (let i = paragraphStartIndex; i < paragraphEndIndex; i++) {
16967
17070
  const paragraphNode = sectionNode.children[i];
17071
+ if (viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex)) continue;
16968
17072
  let skeletonPages = [];
16969
17073
  let currentPageCache = curPage;
16970
17074
  if (allCurrentSkeletonPages.length > 0) currentPageCache = allCurrentSkeletonPages[allCurrentSkeletonPages.length - 1];
@@ -18393,7 +18497,9 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
18393
18497
  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);
18394
18498
  }
18395
18499
  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);
18500
+ let tableFlowTop = lineTop;
18501
+ 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);
18502
+ 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
18503
  const previousTopBottomCustomBlockFlowBottom = deferredTopBottomAnchorDrawings.length > 0 ? paragraphConfig.topBottomCustomBlockFlowBottom : void 0;
18398
18504
  const newLineTop = previousTopBottomCustomBlockFlowBottom == null ? calculatedLineTop : Math.max(calculatedLineTop, previousTopBottomCustomBlockFlowBottom);
18399
18505
  const clipsSameParagraphInlineDrawing = hasSameParagraphTopBottomDrawingWithInline && newLineTop < section.height;
@@ -23453,6 +23559,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
23453
23559
  _defineProperty(this, "_paginationMetrics", null);
23454
23560
  _defineProperty(this, "_completedPageCount", void 0);
23455
23561
  _defineProperty(this, "_lastCompleteSkeletonData", null);
23562
+ _defineProperty(this, "_completedHeadingCollapseSignature", "[]");
23563
+ _defineProperty(this, "_publishedHeadingCollapseSignature", "[]");
23456
23564
  _defineProperty(this, "_pendingInvalidationAnchor", null);
23457
23565
  _defineProperty(this, "_layoutGeneration", 0);
23458
23566
  _defineProperty(this, "_activeLayout", null);
@@ -23510,29 +23618,48 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
23510
23618
  ctx = retry;
23511
23619
  }
23512
23620
  this._lastCompleteSkeletonData = this._skeletonData;
23621
+ this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
23622
+ this._publishedHeadingCollapseSignature = this._completedHeadingCollapseSignature;
23513
23623
  this._completedPageCount = (_this$_skeletonData = this._skeletonData) === null || _this$_skeletonData === void 0 ? void 0 : _this$_skeletonData.pages.length;
23514
23624
  this._pendingInvalidationAnchor = null;
23515
23625
  this._paginationMetrics = ctx.paginationMetrics ?? null;
23516
23626
  this._dirty$.next(true);
23517
23627
  }
23628
+ _getHeadingCollapseSignature() {
23629
+ return JSON.stringify(this.getViewModel().getHeadingSections().filter((heading) => heading.collapsed).map((heading) => [
23630
+ heading.paragraphId,
23631
+ heading.startOffset,
23632
+ heading.endOffset
23633
+ ]));
23634
+ }
23518
23635
  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;
23636
+ const headingCollapseSignature = this._getHeadingCollapseSignature();
23637
+ const headingVisibilityChanged = headingCollapseSignature !== this._completedHeadingCollapseSignature || headingCollapseSignature !== this._publishedHeadingCollapseSignature;
23638
+ const layoutOptions = headingVisibilityChanged ? {
23639
+ ...options,
23640
+ anchor: 0,
23641
+ priorityAnchor: (options === null || options === void 0 ? void 0 : options.priorityAnchor) ?? (options === null || options === void 0 ? void 0 : options.anchor) ?? 0,
23642
+ invalidation: void 0,
23643
+ reuseUnaffectedTail: false,
23644
+ preserveInteractionWindow: false
23645
+ } : options;
23646
+ this._modernPageWidth = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.modernPageWidth;
23647
+ this._modernHorizontalMargin = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.modernHorizontalMargin;
23521
23648
  this.cancelIncrementalLayout();
23522
23649
  this._externalLayoutProgress = null;
23523
23650
  this._externalProtectedPages = null;
23524
23651
  this._externalProtectedContinuousLayout = null;
23525
23652
  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");
23653
+ const reason = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reason) ?? ((layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor) == null ? "initial" : "edit");
23527
23654
  const dataModel = this.getViewModel().getDataModel();
23528
23655
  const sections = this.getViewModel().getChildren();
23529
23656
  const topLevelBlocks = this._getTopLevelBlocks(sections);
23530
23657
  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);
23658
+ const priorityAnchor = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.priorityAnchor) ?? (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor);
23532
23659
  const hasPublishedCheckpoint = this._skeletonData != null || this._lastCompleteSkeletonData != null;
23533
23660
  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;
23661
+ const invalidation = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.invalidation;
23662
+ const layoutAnchor = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor;
23536
23663
  const invalidationAnchor = layoutAnchor == null ? this._pendingInvalidationAnchor ?? void 0 : Math.min(layoutAnchor, this._pendingInvalidationAnchor ?? layoutAnchor);
23537
23664
  const mutationDelta = invalidation == null ? 0 : invalidation.newEnd - invalidation.oldEnd;
23538
23665
  let priorityPageAnchor = priorityAnchor;
@@ -23545,7 +23672,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
23545
23672
  const previousPriorityPage = priorityPageIndex < 0 ? null : (previousSkeleton === null || previousSkeleton === void 0 ? void 0 : previousSkeleton.pages[priorityPageIndex]) ?? null;
23546
23673
  const previousPriorityPageEnd = previousPriorityPage == null ? null : getLastBodyFlowCharIndex(previousPriorityPage);
23547
23674
  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);
23675
+ 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
23676
  this._pendingInvalidationAnchor = hasPublishedCheckpoint ? invalidationAnchor ?? null : null;
23550
23677
  this._activeLayout = {
23551
23678
  generation,
@@ -23559,6 +23686,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
23559
23686
  sectionBreakConfig: null,
23560
23687
  layoutAnchor: incrementalStart.layoutAnchor,
23561
23688
  priorityAnchor: priorityAnchor ?? null,
23689
+ minimumPublicationHeight: mode === "continuous" && headingVisibilityChanged && this._skeletonData != null ? (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.minimumPublicationHeight) ?? 0 : 0,
23562
23690
  priorityPageIndex,
23563
23691
  priorityPageEnd,
23564
23692
  interactionPageTail: incrementalStart.interactionPageTail,
@@ -23583,16 +23711,16 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
23583
23711
  lastPublishedPageCount: incrementalStart.ctx.skeleton.pages.length > 0 ? Math.max(0, incrementalStart.ctx.skeleton.pages.length - 1) : 0,
23584
23712
  lastPublishedBlockCount: incrementalStart.processedBlockCount,
23585
23713
  publicationRevision: 0,
23586
- reuseUnaffectedTail: (options === null || options === void 0 ? void 0 : options.reuseUnaffectedTail) !== false,
23714
+ reuseUnaffectedTail: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reuseUnaffectedTail) !== false,
23587
23715
  paginationRevision: 0,
23588
- allowMetadataOnlyStructuralTailReuse: (options === null || options === void 0 ? void 0 : options.allowMetadataOnlyStructuralTailReuse) === true,
23716
+ allowMetadataOnlyStructuralTailReuse: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.allowMetadataOnlyStructuralTailReuse) === true,
23589
23717
  reusedTail: false,
23590
23718
  tailConvergencePageCount: incrementalStart.ctx.skeleton.pages.length,
23591
23719
  dirtyRetries: /* @__PURE__ */ new Map(),
23592
23720
  preparedHyphenationNodes: /* @__PURE__ */ new WeakSet(),
23593
23721
  pendingHyphenation: null,
23594
23722
  hyphenationError: null,
23595
- waitForHyphenationPatterns: (options === null || options === void 0 ? void 0 : options.waitForHyphenationPatterns) === true
23723
+ waitForHyphenationPatterns: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.waitForHyphenationPatterns) === true
23596
23724
  };
23597
23725
  return generation;
23598
23726
  }
@@ -23967,10 +24095,12 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
23967
24095
  if (isFinalPublication) {
23968
24096
  var _state$ctx$skeleton;
23969
24097
  this._lastCompleteSkeletonData = state.ctx.skeleton;
24098
+ this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
23970
24099
  this._completedPageCount = (_state$ctx$skeleton = state.ctx.skeleton) === null || _state$ctx$skeleton === void 0 ? void 0 : _state$ctx$skeleton.pages.length;
23971
24100
  this._pendingInvalidationAnchor = null;
23972
24101
  }
23973
24102
  this._skeletonData = isFinalPublication ? state.ctx.skeleton : !this._isolateIncrementalPublications && state.mode === "paginated" ? this._createSharedPublishablePartialSkeleton(state, publishedPageCount) : this._createPublishablePartialSkeleton(state, publishedPageCount);
24103
+ this._publishedHeadingCollapseSignature = this._getHeadingCollapseSignature();
23974
24104
  this._paginationMetrics = state.ctx.paginationMetrics ?? null;
23975
24105
  this._dirty$.next(true);
23976
24106
  didPublish = true;
@@ -23995,6 +24125,19 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
23995
24125
  const startIndex = ((_stablePages$at = stablePages.at(-1)) === null || _stablePages$at === void 0 ? void 0 : _stablePages$at.ed) ?? -1;
23996
24126
  updateBlockIndex(activePages, startIndex, state.ctx.docsConfig.documentCompatibilityPolicy);
23997
24127
  mergeContinuousDuplicatePages(activePages, state.mode === "continuous");
24128
+ if (state.mode === "continuous") {
24129
+ const paragraphConfigCache = new Map([...state.ctx.paragraphConfigCache].map(([segmentId, configs]) => [segmentId, new Map([...configs].map(([index, config]) => {
24130
+ var _config$paragraphInli;
24131
+ return [index, ((_config$paragraphInli = config.paragraphInlineSkeDrawings) === null || _config$paragraphInli === void 0 ? void 0 : _config$paragraphInli.size) ? {
24132
+ ...config,
24133
+ paragraphInlineSkeDrawings: new Map([...config.paragraphInlineSkeDrawings].map(([id, drawing]) => [id, { ...drawing }]))
24134
+ } : config];
24135
+ }))]));
24136
+ updateInlineDrawingCoordsAndBorder({
24137
+ ...state.ctx,
24138
+ paragraphConfigCache
24139
+ }, activePages);
24140
+ }
23998
24141
  const flowPages = [...stablePages, ...activePages];
23999
24142
  const currentPriorityPageIndex = state.priorityAnchor == null ? -1 : this._findBodyPageIndex(flowPages, state.priorityAnchor);
24000
24143
  const previousPriorityPage = previous === null || previous === void 0 ? void 0 : previous.pages[state.priorityPageIndex];
@@ -24268,6 +24411,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
24268
24411
  if (progress.complete) {
24269
24412
  setPageParent(skeletonData.pages, skeletonData);
24270
24413
  this._lastCompleteSkeletonData = skeletonData;
24414
+ this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
24271
24415
  this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
24272
24416
  this._pendingInvalidationAnchor = null;
24273
24417
  this._externalProtectedContinuousLayout = null;
@@ -24338,6 +24482,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
24338
24482
  if (publicationToApply.resources.drawingAnchor != null) skeletonData.drawingAnchor = hydrateDrawingAnchors(publicationToApply.resources.drawingAnchor);
24339
24483
  setPageParent(skeletonData.pages, skeletonData);
24340
24484
  this._lastCompleteSkeletonData = skeletonData;
24485
+ this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
24341
24486
  this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
24342
24487
  this._pendingInvalidationAnchor = null;
24343
24488
  this._externalProtectedPages = null;
@@ -24345,6 +24490,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
24345
24490
  }
24346
24491
  this._skeletonData = skeletonData;
24347
24492
  this._externalLayoutProgress = progress.complete ? null : progress;
24493
+ this._publishedHeadingCollapseSignature = this._getHeadingCollapseSignature();
24348
24494
  this._dirty$.next(true);
24349
24495
  this._layoutProgress$.next(progress);
24350
24496
  return { didReplaceProtectedPages };
@@ -24398,7 +24544,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
24398
24544
  const firstUnprotectedLineOffset = flow.lines.findIndex((line) => line.st > protectedEndOffset);
24399
24545
  if (firstUnprotectedLineOffset < 0) return null;
24400
24546
  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.");
24547
+ if (existingColumn == null) return null;
24402
24548
  const firstUnprotectedLine = flow.lines[firstUnprotectedLineOffset];
24403
24549
  const matchingTailLineIndex = existingColumn.lines.findIndex((line) => line.st >= firstUnprotectedLine.st);
24404
24550
  const targetLineIndex = matchingTailLineIndex < 0 ? existingColumn.lines.length : matchingTailLineIndex;
@@ -25133,7 +25279,23 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
25133
25279
  const anchor = state.priorityAnchor;
25134
25280
  if (anchor == null || state.complete) return true;
25135
25281
  if (state.interactionPageComplete) return true;
25136
- if (state.mode === "continuous") return state.laidOutThrough >= anchor;
25282
+ if (state.mode === "continuous") {
25283
+ if (state.laidOutThrough < anchor) return false;
25284
+ if (state.minimumPublicationHeight <= 0) return true;
25285
+ let height = 0;
25286
+ for (const page of state.ctx.skeleton.pages) for (const section of page.sections) {
25287
+ let sectionHeight = 0;
25288
+ for (const column of section.columns) for (let index = column.lines.length - 1; index >= 0; index--) {
25289
+ const line = column.lines[index];
25290
+ if (line.paragraphIndex <= state.stableLaidOutThrough) {
25291
+ sectionHeight = Math.max(sectionHeight, line.top + line.lineHeight);
25292
+ break;
25293
+ }
25294
+ }
25295
+ height += sectionHeight;
25296
+ }
25297
+ return height >= state.minimumPublicationHeight;
25298
+ }
25137
25299
  if (state.priorityPageEnd != null) {
25138
25300
  var _state$invalidation;
25139
25301
  const requiredOffset = Math.max(anchor, state.priorityPageEnd, ((_state$invalidation = state.invalidation) === null || _state$invalidation === void 0 ? void 0 : _state$invalidation.newEnd) ?? anchor);
@@ -25320,7 +25482,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
25320
25482
  const curSkeletonPage = getLastPage(ctx.skeleton.pages);
25321
25483
  if (sectionBreakConfig == null || curSkeletonPage == null) throw new Error("Incremental document layout failed to initialize a section page.");
25322
25484
  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;
25485
+ 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
25486
  if (tableNode != null) {
25325
25487
  state.pendingTableBuild ??= startTableSkeletonBuild(ctx, curSkeletonPage, ctx.viewModel, tableNode, sectionBreakConfig);
25326
25488
  if (state.pendingTableBuild != null && !stepTableSkeletonBuild(state.pendingTableBuild)) return;
@@ -35582,7 +35744,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
35582
35744
  //#endregion
35583
35745
  //#region package.json
35584
35746
  var name = "@univerjs/engine-render";
35585
- var version = "1.1.0";
35747
+ var version = "1.2.0";
35586
35748
 
35587
35749
  //#endregion
35588
35750
  //#region src/config/config.ts