@stll/folio-core 0.66.1 → 0.67.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/dist/ai-edits/apply.d.ts +13 -1
- package/dist/ai-edits/apply.js +572 -140
- package/dist/ai-edits/batch-claims.d.ts +26 -0
- package/dist/ai-edits/batch-claims.js +32 -5
- package/dist/ai-edits/clean-text.js +4 -1
- package/dist/ai-edits/headless.d.ts +6 -0
- package/dist/ai-edits/headless.js +25 -3
- package/dist/ai-edits/newListNumbering.d.ts +4 -1
- package/dist/ai-edits/newListNumbering.js +4 -2
- package/dist/ai-edits/read.js +6 -4
- package/dist/ai-edits/snapshot.js +24 -14
- package/dist/ai-edits/table-cell-mutations.js +3 -2
- package/dist/ai-edits/table-row-column-mutations.js +20 -6
- package/dist/ai-edits/types.d.ts +1 -1
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +76 -18
- package/dist/controller/canonicalInput.d.ts +0 -1
- package/dist/controller/canonicalInput.js +19 -1
- package/dist/controller/canonicalSession.js +1 -2
- package/dist/controller/hiddenEditorManager.d.ts +6 -0
- package/dist/controller/hiddenEditorManager.js +3 -1
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +7 -3
- package/dist/controller/layoutSession.d.ts +1 -0
- package/dist/display-list/build/tablePrimitives.d.ts +3 -1
- package/dist/display-list/build/tablePrimitives.js +29 -13
- package/dist/document-operations.d.ts +13 -1
- package/dist/document-operations.js +11 -4
- package/dist/docx/chartPreview.d.ts +4 -1
- package/dist/docx/chartPreview.js +26 -15
- package/dist/docx/listNumberingInstances.d.ts +6 -4
- package/dist/docx/listNumberingInstances.js +12 -11
- package/dist/docx/mainDocumentPart.d.ts +6 -0
- package/dist/docx/mainDocumentPart.js +65 -0
- package/dist/docx/numberingIds.d.ts +10 -0
- package/dist/docx/numberingIds.js +5 -1
- package/dist/docx/packageParts.d.ts +1 -1
- package/dist/docx/packageParts.js +10 -4
- package/dist/docx/paragraphParser.js +16 -3
- package/dist/docx/paragraphProperties.js +2 -1
- package/dist/docx/previewBudget.d.ts +6 -0
- package/dist/docx/previewBudget.js +7 -1
- package/dist/docx/rezip.js +4 -4
- package/dist/docx/serializer/paragraphSerializer.js +86 -66
- package/dist/docx/shapeAlternateContent.js +19 -0
- package/dist/docx/unzip.js +2 -0
- package/dist/i18n/messages/ar.gen.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
- package/dist/i18n/messages/catalogs.gen.js +34 -0
- package/dist/i18n/messages/cs.gen.js +2 -0
- package/dist/i18n/messages/de.gen.js +2 -0
- package/dist/i18n/messages/en.gen.js +2 -0
- package/dist/i18n/messages/es.gen.js +2 -0
- package/dist/i18n/messages/et.gen.js +2 -0
- package/dist/i18n/messages/fr.gen.js +2 -0
- package/dist/i18n/messages/he.gen.js +2 -0
- package/dist/i18n/messages/hi.gen.js +2 -0
- package/dist/i18n/messages/hu.gen.js +2 -0
- package/dist/i18n/messages/lt.gen.js +2 -0
- package/dist/i18n/messages/lv.gen.js +2 -0
- package/dist/i18n/messages/messages.gen.d.ts +2 -0
- package/dist/i18n/messages/pl.gen.js +2 -0
- package/dist/i18n/messages/pt-BR.gen.js +2 -0
- package/dist/i18n/messages/sk.gen.js +2 -0
- package/dist/i18n/messages/tr.gen.js +2 -0
- package/dist/i18n/messages/zh-CN.gen.js +2 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +1 -1
- package/dist/internal/wholeStoryRevisionResolution.js +81 -21
- package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
- package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
- package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/runMarkFormatting.js +1 -0
- package/dist/layout-bridge/convert/tableConversion.js +6 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
- package/dist/layout-bridge/engine/clickToPosition.js +5 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +1 -0
- package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
- package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
- package/dist/layout-engine/tableLayout.js +7 -4
- package/dist/layout-engine/tableRowBreak.d.ts +10 -0
- package/dist/layout-engine/tableRowBreak.js +151 -36
- package/dist/layout-engine/types.d.ts +7 -2
- package/dist/layout-painter/previewSvg.d.ts +8 -0
- package/dist/layout-painter/previewSvg.js +47 -0
- package/dist/layout-painter/renderImage.js +2 -1
- package/dist/layout-painter/renderPage.d.ts +1 -0
- package/dist/layout-painter/renderPage.js +6 -3
- package/dist/layout-painter/renderParagraph.js +3 -2
- package/dist/layout-painter/renderTable.d.ts +5 -2
- package/dist/layout-painter/renderTable.js +33 -19
- package/dist/markdown/renderRuns.js +68 -12
- package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
- package/dist/prosemirror/commands/comments.js +22 -7
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
- package/dist/prosemirror/commands/pastePlainText.js +13 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
- package/dist/prosemirror/commands/resolveParagraphProperties.js +15 -2
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
- package/dist/prosemirror/commentReferenceIntegrity.js +19 -4
- package/dist/prosemirror/conversion/fromProseDoc.js +94 -22
- package/dist/prosemirror/conversion/hyphenTextCarriers.d.ts +23 -1
- package/dist/prosemirror/conversion/hyphenTextCarriers.js +46 -1
- package/dist/prosemirror/conversion/toProseDoc.js +21 -13
- package/dist/prosemirror/extensions/StarterKit.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +6 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +2 -1
- package/dist/prosemirror/extensions/markRegistry.d.ts +3 -1
- package/dist/prosemirror/extensions/markRegistry.js +3 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
- package/dist/prosemirror/extensions/marks/HyphenElementExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/HyphenElementExtension.js +54 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
- package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +87 -7
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
- package/dist/prosemirror/fieldRepresentation.js +2 -1
- package/dist/prosemirror/hyphenElementAttrs.d.ts +10 -0
- package/dist/prosemirror/hyphenElementAttrs.js +32 -0
- package/dist/prosemirror/keptRangeBoundaries.d.ts +2 -0
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listNumbering.js +3 -2
- package/dist/prosemirror/paragraphIndentation.js +2 -1
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -14
- package/dist/prosemirror/paragraphPropertyCarry.js +4 -28
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
- package/dist/prosemirror/plugins/suggestionMode.js +194 -27
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -0
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
- package/dist/prosemirror/rowGridOmissions.js +21 -0
- package/dist/prosemirror/sectionCarrier.d.ts +8 -0
- package/dist/prosemirror/sectionCarrier.js +29 -1
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +10 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +12 -2
- package/dist/prosemirror/tableGridMutation.d.ts +19 -2
- package/dist/prosemirror/tableGridMutation.js +118 -15
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
- package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
- package/dist/prosemirror/tableRunIn.d.ts +24 -9
- package/dist/prosemirror/tableRunIn.js +107 -21
- package/dist/prosemirror/textInput.js +3 -1
- package/dist/prosemirror/validation.js +7 -1
- package/dist/utils/createDocument.js +11 -8
- package/dist/utils/formatToStyle.js +2 -2
- package/dist/utils/units.d.ts +5 -0
- package/dist/utils/units.js +6 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getProseParagraphPropertySourceToken, recreateProseNodeWithParagraphPropertySource } from "../docx/paragraphPropertySource.js";
|
|
2
|
-
import { anchoredTextBoxId, droppedTextBoxAnchorIds } from "../prosemirror/anchoredTextBoxes.js";
|
|
2
|
+
import { anchoredTextBoxId, droppedTextBoxAnchorIds, moveTextBoxesPastNextParagraph } from "../prosemirror/anchoredTextBoxes.js";
|
|
3
3
|
import { expectParagraphAttrs } from "../prosemirror/attrs/index.js";
|
|
4
4
|
import { inlineBookmarksOf } from "../prosemirror/commands/paragraphBookmarkJoin.js";
|
|
5
5
|
import { resolveAllTableChanges } from "../prosemirror/commands/resolveAllTableChanges.js";
|
|
@@ -13,7 +13,8 @@ import { createResolvedCommentPointCollector } from "../prosemirror/replacedAnno
|
|
|
13
13
|
import { expandRunFormattingCarrier } from "../prosemirror/runFormattingInlineCarriers.js";
|
|
14
14
|
import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "../prosemirror/runFormattingReconciliation.js";
|
|
15
15
|
import { paragraphRunStyleContext } from "../prosemirror/runStyleFormatting.js";
|
|
16
|
-
import {
|
|
16
|
+
import { sectionRecordCopyPositions } from "../prosemirror/sectionCarrier.js";
|
|
17
|
+
import { paragraphBeforeRemovedBlock, runParagraphsIntoTables, runsIntoFollowingTable } from "../prosemirror/tableRunIn.js";
|
|
17
18
|
import { paragraphContentOf } from "../prosemirror/zeroWidthAnchors.js";
|
|
18
19
|
import { recordNodeResolution } from "./revisionResolutionEdits.js";
|
|
19
20
|
import { resolveInlineRevisions } from "./revisionResolutionInline.js";
|
|
@@ -36,12 +37,13 @@ const resolveProperties = ({ doc, mode, styleResolver, numbering, steps, changed
|
|
|
36
37
|
const walk = ({ node, position, eligibleComments = true, previous }) => {
|
|
37
38
|
const childComments = eligibleComments && collector.visit(node, position, previous);
|
|
38
39
|
if (node.isText) return node;
|
|
39
|
-
if (!runsIntoTable && !node.isTextblock) {
|
|
40
|
-
|
|
40
|
+
if (!runsIntoTable && !node.isTextblock) for (let index = 0; index + 1 < node.childCount; index++) {
|
|
41
|
+
const options = {
|
|
41
42
|
parent: node,
|
|
42
43
|
index,
|
|
43
44
|
mode
|
|
44
|
-
}
|
|
45
|
+
};
|
|
46
|
+
if (runsIntoFollowingTable(options) || paragraphBeforeRemovedBlock(options)) {
|
|
45
47
|
runsIntoTable = true;
|
|
46
48
|
break;
|
|
47
49
|
}
|
|
@@ -289,10 +291,11 @@ const resolveStructure = ({ node, position, context }) => {
|
|
|
289
291
|
let pendingBookmarks = [];
|
|
290
292
|
let followingContainerChild = false;
|
|
291
293
|
const precedingParagraphs = [];
|
|
292
|
-
|
|
294
|
+
const endsWithAnyBlock = node.type.name === "blockSdt";
|
|
295
|
+
let endsWell = false;
|
|
293
296
|
for (const { node: child } of entries) {
|
|
294
|
-
precedingParagraphs.push(
|
|
295
|
-
if (child !== null && !isBlockBoundaryNode(child))
|
|
297
|
+
precedingParagraphs.push(endsWell);
|
|
298
|
+
if (child !== null && !isBlockBoundaryNode(child)) endsWell = endsWithAnyBlock || child.type.name === "paragraph";
|
|
296
299
|
}
|
|
297
300
|
const flush = () => {
|
|
298
301
|
if (!chain) return;
|
|
@@ -391,6 +394,7 @@ const resolveStructure = ({ node, position, context }) => {
|
|
|
391
394
|
const marker = expectParagraphAttrs(paragraph).pPrMark;
|
|
392
395
|
const markWasAdded = marker?.kind === "ins" || marker?.kind === "moveTo";
|
|
393
396
|
const joins = marker && markWasAdded !== (context.mode === "accept");
|
|
397
|
+
if (joins && entries[index + 1]?.node?.type.name === "textBox") context.textBoxesStandInJoins = true;
|
|
394
398
|
if (joins && chain) {
|
|
395
399
|
const properties = expectParagraphAttrs(paragraph)._sectionProperties;
|
|
396
400
|
const preceding = entries[index - 1]?.node;
|
|
@@ -400,7 +404,7 @@ const resolveStructure = ({ node, position, context }) => {
|
|
|
400
404
|
markWasAdded,
|
|
401
405
|
containerStillEndsWithParagraph: true,
|
|
402
406
|
followingTableCanReceiveRunIn: false,
|
|
403
|
-
removedSectionProperties: markWasAdded &&
|
|
407
|
+
removedSectionProperties: markWasAdded && ownsSection(paragraph),
|
|
404
408
|
precedingSectionOwner: precedingSectionOwner(preceding, properties),
|
|
405
409
|
followingHasSectionProperties: ownsSection(chain.node)
|
|
406
410
|
});
|
|
@@ -522,7 +526,8 @@ const resolveStructure = ({ node, position, context }) => {
|
|
|
522
526
|
flushBookmarks();
|
|
523
527
|
reversed.reverse();
|
|
524
528
|
if (node.type.name === "doc") {
|
|
525
|
-
const
|
|
529
|
+
const carrierIndex = reversed.findLastIndex((child) => child.type.name !== "textBox");
|
|
530
|
+
const carrier = reversed[carrierIndex];
|
|
526
531
|
if (carrier?.type.name === "paragraph" && carrier.attrs["reviewCarrier"] === REVIEW_CARRIERS.TERMINAL_TABLE) {
|
|
527
532
|
const table = reversed.findLast((child) => child.type.name === "table");
|
|
528
533
|
let pending = false;
|
|
@@ -530,9 +535,9 @@ const resolveStructure = ({ node, position, context }) => {
|
|
|
530
535
|
pending ||= child.type.name === "tableRow" && child.attrs["trDel"] !== null && typeof child.attrs["trDel"] === "object" || child.type.name !== "tableRow" && child.marks.some((mark) => mark.type.name === "deletion");
|
|
531
536
|
return !pending;
|
|
532
537
|
});
|
|
533
|
-
const entry = entries.
|
|
538
|
+
const entry = entries.findLast((candidate) => candidate.node?.type.name !== "textBox");
|
|
534
539
|
if (!pending && entry) {
|
|
535
|
-
if (context.mode === "accept") {
|
|
540
|
+
if (context.mode === "accept" || carrier.content.size > 0) {
|
|
536
541
|
const cleared = recreateProseNodeWithParagraphPropertySource(carrier, { attrs: {
|
|
537
542
|
...carrier.attrs,
|
|
538
543
|
reviewCarrier: void 0
|
|
@@ -547,9 +552,9 @@ const resolveStructure = ({ node, position, context }) => {
|
|
|
547
552
|
from: entry.position,
|
|
548
553
|
to: entry.position + carrier.nodeSize
|
|
549
554
|
});
|
|
550
|
-
reversed[
|
|
555
|
+
reversed[carrierIndex] = cleared;
|
|
551
556
|
} else if (reversed.length > 1) {
|
|
552
|
-
reversed.
|
|
557
|
+
reversed.splice(carrierIndex, 1);
|
|
553
558
|
context.deleted.push({
|
|
554
559
|
from: entry.position,
|
|
555
560
|
to: entry.position + carrier.nodeSize
|
|
@@ -612,18 +617,67 @@ const resolveStructure = ({ node, position, context }) => {
|
|
|
612
617
|
});
|
|
613
618
|
return final;
|
|
614
619
|
};
|
|
615
|
-
|
|
616
|
-
|
|
620
|
+
/**
|
|
621
|
+
* The text boxes drawn in a paragraph stand between it and the next one. When
|
|
622
|
+
* the paragraph's mark goes, the two join, and the boxes follow the result.
|
|
623
|
+
*/
|
|
624
|
+
const moveTextBoxesOutOfJoins = (tr, mode) => {
|
|
625
|
+
const joining = [];
|
|
626
|
+
tr.doc.descendants((node, position) => {
|
|
627
|
+
if (node.type.name !== "paragraph") return true;
|
|
628
|
+
const mark = expectParagraphAttrs(node).pPrMark;
|
|
629
|
+
const wasAdded = mark?.kind === "ins" || mark?.kind === "moveTo";
|
|
630
|
+
if (mark && wasAdded !== (mode === "accept")) joining.push(position);
|
|
631
|
+
return false;
|
|
632
|
+
});
|
|
633
|
+
for (const position of joining.toReversed()) moveTextBoxesPastNextParagraph(tr, position);
|
|
634
|
+
};
|
|
635
|
+
const resolveWholeStory = ({ doc: storyDoc, mode, styleResolver, numbering }) => {
|
|
636
|
+
const withoutCopies = new Transform(storyDoc);
|
|
637
|
+
for (const position of sectionRecordCopyPositions(storyDoc)) withoutCopies.setNodeAttribute(position, "_sectionProperties", null);
|
|
638
|
+
const doc = withoutCopies.doc;
|
|
639
|
+
const { runsIntoTable, textBoxesStandInJoins, ...direct } = resolveStoryRevisions({
|
|
617
640
|
doc,
|
|
618
641
|
mode,
|
|
619
642
|
styleResolver,
|
|
620
643
|
numbering
|
|
621
644
|
});
|
|
622
|
-
if (
|
|
645
|
+
if (textBoxesStandInJoins) {
|
|
646
|
+
const prepared = new Transform(doc);
|
|
647
|
+
moveTextBoxesOutOfJoins(prepared, mode);
|
|
648
|
+
if (prepared.docChanged) {
|
|
649
|
+
const result = resolveWholeStory({
|
|
650
|
+
doc: prepared.doc,
|
|
651
|
+
mode,
|
|
652
|
+
styleResolver,
|
|
653
|
+
numbering
|
|
654
|
+
});
|
|
655
|
+
let preparedMap = StepMap.empty;
|
|
656
|
+
for (const map of prepared.mapping.maps) preparedMap = composeRevisionResolutionMaps(preparedMap, map);
|
|
657
|
+
const positionMap = composeRevisionResolutionMaps(preparedMap, result.positionMap);
|
|
658
|
+
return {
|
|
659
|
+
...result,
|
|
660
|
+
steps: [
|
|
661
|
+
...withoutCopies.steps,
|
|
662
|
+
...prepared.steps,
|
|
663
|
+
...result.steps
|
|
664
|
+
],
|
|
665
|
+
positionMap,
|
|
666
|
+
mapping: new Mapping([positionMap])
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if (!runsIntoTable) return {
|
|
671
|
+
...direct,
|
|
672
|
+
steps: [...withoutCopies.steps, ...direct.steps]
|
|
673
|
+
};
|
|
623
674
|
const runIn = new Transform(doc);
|
|
624
675
|
const { targets, maps, transfers } = runParagraphsIntoTables(runIn, mode, styleResolver);
|
|
625
|
-
if (!runIn.docChanged) return
|
|
626
|
-
|
|
676
|
+
if (!runIn.docChanged) return {
|
|
677
|
+
...direct,
|
|
678
|
+
steps: [...withoutCopies.steps, ...direct.steps]
|
|
679
|
+
};
|
|
680
|
+
const { runsIntoTable: _rerun, textBoxesStandInJoins: _standing, ...result } = resolveStoryRevisions({
|
|
627
681
|
doc: runIn.doc,
|
|
628
682
|
mode,
|
|
629
683
|
styleResolver,
|
|
@@ -642,7 +696,11 @@ const resolveWholeStory = ({ doc, mode, styleResolver, numbering }) => {
|
|
|
642
696
|
const positionMap = composeRevisionResolutionMaps(runInMap, result.positionMap);
|
|
643
697
|
return {
|
|
644
698
|
...result,
|
|
645
|
-
steps: [
|
|
699
|
+
steps: [
|
|
700
|
+
...withoutCopies.steps,
|
|
701
|
+
...runIn.steps,
|
|
702
|
+
...result.steps
|
|
703
|
+
],
|
|
646
704
|
positionMap,
|
|
647
705
|
mapping: new Mapping([positionMap]),
|
|
648
706
|
transfers: [...transfers, ...result.transfers]
|
|
@@ -669,7 +727,7 @@ const resolveStoryRevisions = ({ doc, mode, styleResolver, numbering }) => {
|
|
|
669
727
|
removeType: doc.type.schema.marks[mode === "accept" ? "deletion" : "insertion"]
|
|
670
728
|
});
|
|
671
729
|
const inlineResolved = inline?.resolved ?? properties;
|
|
672
|
-
const comments = inline ? resolveCommentReferences(inlineResolved) : null;
|
|
730
|
+
const comments = inline ? resolveCommentReferences(inlineResolved, doc) : null;
|
|
673
731
|
const context = {
|
|
674
732
|
mode,
|
|
675
733
|
styleResolver,
|
|
@@ -682,6 +740,7 @@ const resolveStoryRevisions = ({ doc, mode, styleResolver, numbering }) => {
|
|
|
682
740
|
bookmarkJoins: [],
|
|
683
741
|
structural: propertyResult.structural,
|
|
684
742
|
failed: false,
|
|
743
|
+
textBoxesStandInJoins: false,
|
|
685
744
|
removedEndpointCount: propertyResult.removedEndpointCount,
|
|
686
745
|
removedReferences: [...propertyResult.removedReferences],
|
|
687
746
|
droppedTextBoxAnchors: inline ? droppedTextBoxAnchorIds(properties, inlineResolved) : /* @__PURE__ */ new Set()
|
|
@@ -722,6 +781,7 @@ const resolveStoryRevisions = ({ doc, mode, styleResolver, numbering }) => {
|
|
|
722
781
|
structuralMap,
|
|
723
782
|
structural: context.structural,
|
|
724
783
|
failed: context.failed,
|
|
784
|
+
textBoxesStandInJoins: context.textBoxesStandInJoins,
|
|
725
785
|
removedEndpointCount: context.removedEndpointCount,
|
|
726
786
|
removedReferences: context.removedReferences,
|
|
727
787
|
runsIntoTable: propertyResult.runsIntoTable,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ParagraphBlock } from "../../layout-engine/types.js";
|
|
2
|
+
import { FlowConversionOptions } from "./flowConversionShared.js";
|
|
3
|
+
import { Node } from "prosemirror-model";
|
|
4
|
+
/** The marker where no editor supplies a localised one. */
|
|
5
|
+
export declare const ALT_CHUNK_DEFAULT_MARKER_TEXT = "Content not displayed";
|
|
6
|
+
/**
|
|
7
|
+
* The placeholder for a preserved block at `pos`, or nothing when the block is
|
|
8
|
+
* not an altChunk. Only the first paragraph addresses the node.
|
|
9
|
+
*/
|
|
10
|
+
export declare const convertAltChunkPlaceholder: (node: Node, pos: number, options: FlowConversionOptions) => ParagraphBlock[];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { isAltChunkMarkup } from "../../docx/altChunk.js";
|
|
2
|
+
import { expectPreservedBlockAttrs } from "../../prosemirror/attrs/index.js";
|
|
3
|
+
import { detectBaseDirection } from "../../utils/baseDirection.js";
|
|
4
|
+
import { ALT_CHUNK_CONTENT } from "./flowConversionShared.js";
|
|
5
|
+
import { convertParagraph } from "./paragraphConversion.js";
|
|
6
|
+
// src/layout-bridge/convert/altChunkPlaceholder.ts
|
|
7
|
+
/** The marker where no editor supplies a localised one. */
|
|
8
|
+
const ALT_CHUNK_DEFAULT_MARKER_TEXT = "Content not displayed";
|
|
9
|
+
/** Tints the block, so it does not read as part of the editable text. */
|
|
10
|
+
const PLACEHOLDER_SHADING = "#F2F2F2";
|
|
11
|
+
const MARKER_COLOR = "#595959";
|
|
12
|
+
/** Past this, further lines of a chunk's text run together in the last block. */
|
|
13
|
+
const MAX_PLACEHOLDER_PARAGRAPHS = 2e3;
|
|
14
|
+
const altChunkNodes = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
const isAltChunkNode = (node) => {
|
|
16
|
+
const known = altChunkNodes.get(node);
|
|
17
|
+
if (known !== void 0) return known;
|
|
18
|
+
const isAltChunk = isAltChunkMarkup(expectPreservedBlockAttrs(node).xml);
|
|
19
|
+
altChunkNodes.set(node, isAltChunk);
|
|
20
|
+
return isAltChunk;
|
|
21
|
+
};
|
|
22
|
+
const placeholderLines = (text) => {
|
|
23
|
+
const lines = text.split(/\r\n|\r|\n/u);
|
|
24
|
+
if (lines.length <= MAX_PLACEHOLDER_PARAGRAPHS) return lines;
|
|
25
|
+
const kept = lines.slice(0, 1999);
|
|
26
|
+
kept.push(lines.slice(1999).join(" "));
|
|
27
|
+
return kept;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The placeholder for a preserved block at `pos`, or nothing when the block is
|
|
31
|
+
* not an altChunk. Only the first paragraph addresses the node.
|
|
32
|
+
*/
|
|
33
|
+
const convertAltChunkPlaceholder = (node, pos, options) => {
|
|
34
|
+
if (node.type.name !== "preservedBlock" || !isAltChunkNode(node)) return [];
|
|
35
|
+
const { readerText } = expectPreservedBlockAttrs(node);
|
|
36
|
+
const hasText = options.altChunkContent !== ALT_CHUNK_CONTENT.markerOnly && typeof readerText === "string" && readerText.trim() !== "";
|
|
37
|
+
const isMarker = !hasText;
|
|
38
|
+
const text = hasText ? readerText : options.altChunkMarkerText ?? "Content not displayed";
|
|
39
|
+
const { schema } = node.type;
|
|
40
|
+
const paragraphType = schema.nodes["paragraph"];
|
|
41
|
+
if (!paragraphType) return [];
|
|
42
|
+
const after = pos + node.nodeSize;
|
|
43
|
+
const blocks = [];
|
|
44
|
+
for (const [index, line] of placeholderLines(text).entries()) {
|
|
45
|
+
const block = convertParagraph(paragraphType.create(detectBaseDirection(line) === "rtl" ? { direction: { source: "auto" } } : null, line.length > 0 ? schema.text(line) : null), pos, options);
|
|
46
|
+
delete block.pmStart;
|
|
47
|
+
delete block.pmEnd;
|
|
48
|
+
if (index === 0) {
|
|
49
|
+
block.pmStart = pos;
|
|
50
|
+
block.pmEnd = after;
|
|
51
|
+
}
|
|
52
|
+
block.fixedPosition = after;
|
|
53
|
+
block.attrs = {
|
|
54
|
+
...block.attrs,
|
|
55
|
+
shading: PLACEHOLDER_SHADING
|
|
56
|
+
};
|
|
57
|
+
for (const run of block.runs) {
|
|
58
|
+
if (run.kind !== "text") continue;
|
|
59
|
+
run.pmStart = after;
|
|
60
|
+
run.pmEnd = after;
|
|
61
|
+
if (isMarker) {
|
|
62
|
+
run.italic = true;
|
|
63
|
+
run.color = MARKER_COLOR;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
blocks.push(block);
|
|
67
|
+
}
|
|
68
|
+
return blocks;
|
|
69
|
+
};
|
|
70
|
+
export { ALT_CHUNK_DEFAULT_MARKER_TEXT, convertAltChunkPlaceholder };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expectTableCellAttrs, expectTableRowAttrs } from "../../prosemirror/attrs/index.js";
|
|
2
|
+
import { rowGridOmissions } from "../../prosemirror/rowGridOmissions.js";
|
|
2
3
|
// src/layout-bridge/convert/fixedTableColumnWidths.ts
|
|
3
4
|
/** Resolve absolute cell preferences for an unbounded fixed-layout grid (§17.4.53). */
|
|
4
5
|
const fixedTableColumnWidths = (table, grid) => {
|
|
@@ -7,7 +8,7 @@ const fixedTableColumnWidths = (table, grid) => {
|
|
|
7
8
|
const row = table.child(rowIndex);
|
|
8
9
|
const rowAttrs = expectTableRowAttrs(row);
|
|
9
10
|
if (rowAttrs.trIns || rowAttrs.trDel || rowAttrs.hidden) return grid;
|
|
10
|
-
let column =
|
|
11
|
+
let column = rowGridOmissions(row, 0).gridBefore;
|
|
11
12
|
for (let cellIndex = 0; cellIndex < row.childCount; cellIndex++) {
|
|
12
13
|
const attrs = expectTableCellAttrs(row.child(cellIndex));
|
|
13
14
|
if (attrs._omittedGridSlot) continue;
|
|
@@ -8,7 +8,17 @@ import { Node } from "prosemirror-model";
|
|
|
8
8
|
/**
|
|
9
9
|
* Options for the conversion.
|
|
10
10
|
*/
|
|
11
|
+
/** How much of a `w:altChunk` a story has room to show. */
|
|
12
|
+
export declare const ALT_CHUNK_CONTENT: {
|
|
13
|
+
readonly text: "text";
|
|
14
|
+
readonly markerOnly: "markerOnly";
|
|
15
|
+
};
|
|
16
|
+
export type AltChunkContent = (typeof ALT_CHUNK_CONTENT)[keyof typeof ALT_CHUNK_CONTENT];
|
|
11
17
|
export type ToFlowBlocksOptions = {
|
|
18
|
+
/** Localised text for a `w:altChunk` that has no text of its own to show. */
|
|
19
|
+
altChunkMarkerText?: string;
|
|
20
|
+
/** Defaults to the chunk's own text. */
|
|
21
|
+
altChunkContent?: AltChunkContent;
|
|
12
22
|
/** Paint comment anchors and highlights; false leaves authored marks intact. */
|
|
13
23
|
showCommentHighlights?: boolean;
|
|
14
24
|
/** Embedded families owned by this editor, never ambient process state. */
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
// src/layout-bridge/convert/flowConversionShared.ts
|
|
2
2
|
/**
|
|
3
|
+
* Options for the conversion.
|
|
4
|
+
*/
|
|
5
|
+
/** How much of a `w:altChunk` a story has room to show. */
|
|
6
|
+
const ALT_CHUNK_CONTENT = {
|
|
7
|
+
/** Its own text when it has any, otherwise the marker. */
|
|
8
|
+
text: "text",
|
|
9
|
+
/** Only the marker: the story's height cannot follow the chunk's length. */
|
|
10
|
+
markerOnly: "markerOnly"
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
3
13
|
* Convert twips to pixels (1 twip = 1/1440 inch, 1 inch = 96 CSS px).
|
|
4
14
|
* No rounding — precision prevents cumulative layout drift across paragraphs.
|
|
5
15
|
*/
|
|
@@ -19,4 +29,4 @@ function nextBlockId() {
|
|
|
19
29
|
function resetBlockIdCounter() {
|
|
20
30
|
blockIdCounter = 0;
|
|
21
31
|
}
|
|
22
|
-
export { nextBlockId, resetBlockIdCounter, twipsToPixels };
|
|
32
|
+
export { ALT_CHUNK_CONTENT, nextBlockId, resetBlockIdCounter, twipsToPixels };
|
|
@@ -7,6 +7,7 @@ export type MeasureBlocksFn = (blocks: FlowBlock[], contentWidth: number) => Mea
|
|
|
7
7
|
export type ConvertFootnoteOptions = Pick<ToFlowBlocksOptions, "embeddedFontFamilyMap" | "documentFontFacts"> & {
|
|
8
8
|
/** Whether comment highlights are painted. Defaults to true. */
|
|
9
9
|
showCommentHighlights?: boolean;
|
|
10
|
+
altChunkMarkerText?: string;
|
|
10
11
|
markupView?: DisplayMode;
|
|
11
12
|
styles?: document_d_exports.StyleDefinitions | null;
|
|
12
13
|
numbering?: document_d_exports.NumberingDefinitions;
|
|
@@ -213,7 +213,10 @@ function convertNoteStoryToFlowBlocks(content, options, referenceMarkText) {
|
|
|
213
213
|
if (options.theme !== void 0) proseOptions.theme = options.theme;
|
|
214
214
|
if (options.numbering !== void 0) proseOptions.numbering = options.numbering;
|
|
215
215
|
const pmDoc = footnoteToProseDoc(content, proseOptions);
|
|
216
|
-
const flowOptions = {
|
|
216
|
+
const flowOptions = {
|
|
217
|
+
showCommentHighlights: options.showCommentHighlights !== false && options.markupView !== "no-markup" && options.markupView !== "original",
|
|
218
|
+
...options.altChunkMarkerText === void 0 ? {} : { altChunkMarkerText: options.altChunkMarkerText }
|
|
219
|
+
};
|
|
217
220
|
if (options.defaultSize !== void 0) flowOptions.defaultSize = options.defaultSize;
|
|
218
221
|
if (options.styles) flowOptions.styles = options.styles;
|
|
219
222
|
if (options.theme !== void 0) flowOptions.theme = options.theme;
|
|
@@ -44,6 +44,7 @@ export type ConvertHeaderFooterOptions = {
|
|
|
44
44
|
markupView?: DisplayMode;
|
|
45
45
|
/** Whether comment highlights are painted. Defaults to true. */
|
|
46
46
|
showCommentHighlights?: boolean;
|
|
47
|
+
altChunkMarkerText?: string;
|
|
47
48
|
styles?: document_d_exports.StyleDefinitions | null;
|
|
48
49
|
numbering?: document_d_exports.NumberingDefinitions;
|
|
49
50
|
theme?: document_d_exports.Theme | null;
|
|
@@ -3,6 +3,7 @@ import { isFloatingImageRun, isFloatingTextBoxBlock, isTextWrappingFloatingImage
|
|
|
3
3
|
import { headerFooterToProseDoc } from "../../prosemirror/conversion/toProseDoc.js";
|
|
4
4
|
import { projectStoryMarkupView } from "../../prosemirror/markupViewProjection.js";
|
|
5
5
|
import { emuToPixels } from "../../utils/units.js";
|
|
6
|
+
import { ALT_CHUNK_CONTENT } from "./flowConversionShared.js";
|
|
6
7
|
import { remapMarkupViewBlocks } from "./markupViewFlow.js";
|
|
7
8
|
import { toFlowBlocks } from "./toFlowBlocks.js";
|
|
8
9
|
// src/layout-bridge/convert/headerFooterLayout.ts
|
|
@@ -359,7 +360,11 @@ function convertHeaderFooterToContent(headerFooter, contentWidth, metrics, optio
|
|
|
359
360
|
*/
|
|
360
361
|
function convertHeaderFooterPmDocToContent(pmDoc, contentWidth, metrics, options) {
|
|
361
362
|
if (!pmDoc || pmDoc.content.size === 0) return;
|
|
362
|
-
const flowOptions = {
|
|
363
|
+
const flowOptions = {
|
|
364
|
+
altChunkContent: ALT_CHUNK_CONTENT.markerOnly,
|
|
365
|
+
showCommentHighlights: options.showCommentHighlights !== false && options.markupView !== "no-markup" && options.markupView !== "original",
|
|
366
|
+
...options.altChunkMarkerText === void 0 ? {} : { altChunkMarkerText: options.altChunkMarkerText }
|
|
367
|
+
};
|
|
363
368
|
if (options.defaultSize !== void 0) flowOptions.defaultSize = options.defaultSize;
|
|
364
369
|
if (options.styles) flowOptions.styles = options.styles;
|
|
365
370
|
if (options.theme !== void 0) flowOptions.theme = options.theme;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { setTextBoxGroupId } from "../../layout-engine/textBoxGroup.js";
|
|
2
2
|
import { DEFAULT_TEXTBOX_MARGINS } from "../../layout-engine/types.js";
|
|
3
3
|
import { expectParagraphAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs } from "../../prosemirror/attrs/index.js";
|
|
4
|
+
import { rowGridOmissions } from "../../prosemirror/rowGridOmissions.js";
|
|
4
5
|
import { textBoxHostParagraph } from "../../prosemirror/textBoxHostParagraph.js";
|
|
5
6
|
import { normalizeShapeTextAnchor } from "../../types/documentEnumValues.js";
|
|
7
|
+
import { convertAltChunkPlaceholder } from "./altChunkPlaceholder.js";
|
|
6
8
|
import { fixedTableColumnWidths } from "./fixedTableColumnWidths.js";
|
|
7
9
|
import { convertBorderSpecToLayout } from "./flowBorders.js";
|
|
8
10
|
import { nextBlockId, twipsToPixels } from "./flowConversionShared.js";
|
|
@@ -66,6 +68,7 @@ function convertTableCell(node, startPos, options, tableCellMargins) {
|
|
|
66
68
|
blocks.push(block);
|
|
67
69
|
} else if (child.type.name === "table") blocks.push(convertTable(child, childStart, options));
|
|
68
70
|
else if (child.type.name === "textBox") blocks.push(convertTextBoxNode(child, childStart, options));
|
|
71
|
+
else if (child.type.name === "preservedBlock") blocks.push(...convertAltChunkPlaceholder(child, childStart, options));
|
|
69
72
|
else if (child.type.name === "blockSdt" || child.type.name === "blockCustomXml") {
|
|
70
73
|
let sdtChildStart = childStart + 1;
|
|
71
74
|
child.forEach((sdtChild) => {
|
|
@@ -159,8 +162,9 @@ function convertTableRow(node, startPos, options, { cellMargins }) {
|
|
|
159
162
|
id: nextBlockId(),
|
|
160
163
|
cells
|
|
161
164
|
};
|
|
162
|
-
|
|
163
|
-
if (
|
|
165
|
+
const { gridBefore, gridAfter } = rowGridOmissions(node, attrs._originalFormatting?.gridAfter ?? 0);
|
|
166
|
+
if (gridBefore > 0) row.gridBefore = gridBefore;
|
|
167
|
+
if (gridAfter > 0) row.gridAfter = gridAfter;
|
|
164
168
|
if (attrs.height) row.height = twipsToPixels(attrs.height);
|
|
165
169
|
if (attrs.heightRule) row.heightRule = attrs.heightRule;
|
|
166
170
|
if (attrs.isHeader) row.isHeader = attrs.isHeader;
|
|
@@ -9,6 +9,7 @@ import { expectTextBoxAnchorAttrs } from "../../prosemirror/textBoxAnchorAttrs.j
|
|
|
9
9
|
import { assertValidProseMirrorDocument } from "../../prosemirror/validation.js";
|
|
10
10
|
import { createStyleEngine } from "../../style-engine/styleEngine.js";
|
|
11
11
|
import { getColumns } from "../sectionColumns.js";
|
|
12
|
+
import { convertAltChunkPlaceholder } from "./altChunkPlaceholder.js";
|
|
12
13
|
import { mergeRunInParagraphs, reserveLeadingEmptyOutlineHeight, suppressFinalEmptyParagraphAfterTable, suppressFinalParagraphInRepeatedEmptySuffix } from "./flowBlockPostprocessing.js";
|
|
13
14
|
import { convertBorderSpecToLayout } from "./flowBorders.js";
|
|
14
15
|
import { nextBlockId, resetBlockIdCounter, twipsToPixels } from "./flowConversionShared.js";
|
|
@@ -384,6 +385,9 @@ function toFlowBlocks(doc, options = {}) {
|
|
|
384
385
|
case "textBox":
|
|
385
386
|
pushTextBox(node, pos);
|
|
386
387
|
break;
|
|
388
|
+
case "preservedBlock":
|
|
389
|
+
for (const block of convertAltChunkPlaceholder(node, pos, opts)) trackedPush(block);
|
|
390
|
+
break;
|
|
387
391
|
case "horizontalRule":
|
|
388
392
|
case "pageBreak": {
|
|
389
393
|
if (consumedPageBreakPositions.has(pos)) break;
|
|
@@ -224,6 +224,7 @@ function clickToPositionInParagraph(fragmentHit) {
|
|
|
224
224
|
function clickToPositionInTableCell(tableCellHit) {
|
|
225
225
|
const { cellBlock, cellMeasure, cellLocalX, cellLocalY, cellContentWidth } = tableCellHit;
|
|
226
226
|
if (!cellBlock || !cellMeasure) return null;
|
|
227
|
+
if (cellBlock.fixedPosition !== void 0) return cellBlock.fixedPosition;
|
|
227
228
|
return clickToPositionInParagraph({
|
|
228
229
|
fragment: {
|
|
229
230
|
kind: "paragraph",
|
|
@@ -255,7 +256,10 @@ function clickToPosition(fragmentHit, tableCellHit) {
|
|
|
255
256
|
if (tableCellHit) return clickToPositionInTableCell(tableCellHit);
|
|
256
257
|
if (!fragmentHit) return null;
|
|
257
258
|
const { fragment } = fragmentHit;
|
|
258
|
-
if (fragment.kind === "paragraph")
|
|
259
|
+
if (fragment.kind === "paragraph") {
|
|
260
|
+
if (fragmentHit.block.kind === "paragraph" && fragmentHit.block.fixedPosition !== void 0) return fragmentHit.block.fixedPosition;
|
|
261
|
+
return clickToPositionInParagraph(fragmentHit)?.pmPosition ?? null;
|
|
262
|
+
}
|
|
259
263
|
if (fragment.kind === "image") return fragment.pmStart ?? null;
|
|
260
264
|
return null;
|
|
261
265
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
1
2
|
import { ImageRun, TableCell, TableCellMeasure } from "../types.js";
|
|
2
3
|
import { FloatingImageZone } from "./floatingZones.js";
|
|
3
4
|
export type TableCellFloatingImage = {
|
|
4
5
|
src: string;
|
|
6
|
+
preview?: document_d_exports.PreviewDescriptor;
|
|
5
7
|
width: number;
|
|
6
8
|
height: number;
|
|
7
9
|
alt?: string;
|
|
@@ -64,6 +64,7 @@ function getTableCellFloatingImages(cell, cellMeasure, contentWidth, resolvePosi
|
|
|
64
64
|
else if (run.cssFloat === "right") wrapText = "left";
|
|
65
65
|
result.push({
|
|
66
66
|
src: run.src,
|
|
67
|
+
...run.preview ? { preview: run.preview } : {},
|
|
67
68
|
width: run.width,
|
|
68
69
|
height: run.height,
|
|
69
70
|
...run.alt !== void 0 ? { alt: run.alt } : {},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TableBlock, TableRow } from "../types.js";
|
|
2
|
+
/** A vertical span in the coordinates of whatever is being painted. */
|
|
3
|
+
export type VisibleBand = {
|
|
4
|
+
readonly top: number;
|
|
5
|
+
readonly bottom: number;
|
|
6
|
+
};
|
|
7
|
+
/** The same band in the coordinates of a child that starts at `origin`. */
|
|
8
|
+
export declare const bandFromOrigin: (band: VisibleBand, origin: number) => VisibleBand;
|
|
9
|
+
export declare const isOutsideBand: (band: VisibleBand | undefined, top: number, bottom: number) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Where a row's paint ends: a merged cell belongs to the row that opens it and
|
|
12
|
+
* reaches through every row it spans. `rowTops` has `rows.length + 1` entries.
|
|
13
|
+
*/
|
|
14
|
+
export declare const tableRowPaintBottom: (row: TableRow, rowIndex: number, rowTops: readonly number[]) => number;
|
|
15
|
+
/** Floating cell content can paint outside the row it is anchored in. */
|
|
16
|
+
export declare function tableHasFloatingCellContent(block: TableBlock): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isFloatingImageRun, isFloatingTextBoxBlock } from "../types.js";
|
|
2
|
+
// src/layout-engine/measure/tableVisibleBand.ts
|
|
3
|
+
/** The same band in the coordinates of a child that starts at `origin`. */
|
|
4
|
+
const bandFromOrigin = (band, origin) => ({
|
|
5
|
+
top: band.top - origin,
|
|
6
|
+
bottom: band.bottom - origin
|
|
7
|
+
});
|
|
8
|
+
const isOutsideBand = (band, top, bottom) => band !== void 0 && (bottom <= band.top || top >= band.bottom);
|
|
9
|
+
/**
|
|
10
|
+
* Where a row's paint ends: a merged cell belongs to the row that opens it and
|
|
11
|
+
* reaches through every row it spans. `rowTops` has `rows.length + 1` entries.
|
|
12
|
+
*/
|
|
13
|
+
const tableRowPaintBottom = (row, rowIndex, rowTops) => {
|
|
14
|
+
let widestSpan = 1;
|
|
15
|
+
for (const cell of row.cells) widestSpan = Math.max(widestSpan, cell.rowSpan ?? 1);
|
|
16
|
+
const lastTop = rowTops.length - 1;
|
|
17
|
+
return rowTops[Math.min(lastTop, rowIndex + widestSpan)] ?? 0;
|
|
18
|
+
};
|
|
19
|
+
/** Floating cell content can paint outside the row it is anchored in. */
|
|
20
|
+
function tableHasFloatingCellContent(block) {
|
|
21
|
+
for (const row of block.rows) for (const cell of row.cells) for (const cellBlock of cell.blocks) {
|
|
22
|
+
if (cellBlock.kind === "textBox" && isFloatingTextBoxBlock(cellBlock)) return true;
|
|
23
|
+
if (cellBlock.kind === "paragraph" && cellBlock.runs.some((run) => run.kind === "image" && isFloatingImageRun(run))) return true;
|
|
24
|
+
if (cellBlock.kind === "table" && tableHasFloatingCellContent(cellBlock)) return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
export { bandFromOrigin, isOutsideBand, tableHasFloatingCellContent, tableRowPaintBottom };
|
|
@@ -2,7 +2,7 @@ import { projectedFootnoteReserveGrowth } from "./layoutFlowShared.js";
|
|
|
2
2
|
import { resolveFloatingTablePageX } from "./measure/floatingTablePosition.js";
|
|
3
3
|
import { resolveTableInlineOffset } from "./measure/tableInlinePlacement.js";
|
|
4
4
|
import { isEmptyParagraph } from "./paragraphSpacing.js";
|
|
5
|
-
import { buildTableRowBreakInfo, getRowContinuationSkip, snapRowBreak } from "./tableRowBreak.js";
|
|
5
|
+
import { buildTableRowBreakInfo, getRowContinuationSkip, snapOversizedRowBreak, snapRowBreak } from "./tableRowBreak.js";
|
|
6
6
|
import "./types.js";
|
|
7
7
|
// src/layout-engine/tableLayout.ts
|
|
8
8
|
/**
|
|
@@ -97,7 +97,7 @@ function layoutTable(block, measure, paginator, footnoteHeightById) {
|
|
|
97
97
|
const row = rows[rowIndex];
|
|
98
98
|
const sourceRow = block.rows[rowIndex];
|
|
99
99
|
if (!row || !sourceRow || sourceRow.heightRule === "exact" || sourceRow.isHeader || verticallyMergedRows.has(rowIndex)) return false;
|
|
100
|
-
if ((breakInfo.
|
|
100
|
+
if ((breakInfo.oversizedBreakOffsets[rowIndex]?.length ?? 0) <= 1) return false;
|
|
101
101
|
const freshHeaderOverhead = headerRowCount > 0 && rowIndex >= headerRowCount ? headerRowsHeight : 0;
|
|
102
102
|
const oversized = row.height + freshHeaderOverhead > getCurrentRowCapacity(state);
|
|
103
103
|
if (sourceRow.cantSplit) return oversized && rowOpensFlowRegion(rowIndex, state);
|
|
@@ -145,8 +145,11 @@ function layoutTable(block, measure, paginator, footnoteHeightById) {
|
|
|
145
145
|
advanceAfterNaturalFlowBreak(previousPageNumber);
|
|
146
146
|
continue;
|
|
147
147
|
}
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
slice = snapOversizedRowBreak(breakInfo, currentRowIndex, consumed, sliceAvail);
|
|
149
|
+
if (slice <= 0) {
|
|
150
|
+
const from = consumed;
|
|
151
|
+
slice = (breakInfo.oversizedBreakOffsets[currentRowIndex]?.find((o) => o > from) ?? splittableRow.height) - consumed;
|
|
152
|
+
}
|
|
150
153
|
}
|
|
151
154
|
discardPassedRenderedBreakHints();
|
|
152
155
|
const renderedBreakHint = renderedBreakHints[renderedBreakHintIndex];
|
|
@@ -13,6 +13,11 @@ export type TableRowBreakInfo = {
|
|
|
13
13
|
* final boundary.
|
|
14
14
|
*/
|
|
15
15
|
breakOffsets: number[][];
|
|
16
|
+
/**
|
|
17
|
+
* `breakOffsets` plus the line bottoms inside nested rows that stay whole
|
|
18
|
+
* while a flow region can hold them: where to break once none can.
|
|
19
|
+
*/
|
|
20
|
+
oversizedBreakOffsets: number[][];
|
|
16
21
|
/** Safe cached page boundaries within each row, relative to the row top. */
|
|
17
22
|
renderedBreakHints: RenderedRowBreakHint[][];
|
|
18
23
|
/** Suppressible leading paragraph whitespace after each matching break offset. */
|
|
@@ -35,4 +40,9 @@ export declare function getRowContinuationSkip(info: TableRowBreakInfo, rowIndex
|
|
|
35
40
|
* `maxSlice`. Returns 0 when not even the first line fits.
|
|
36
41
|
*/
|
|
37
42
|
export declare function snapRowBreak(info: TableRowBreakInfo, rowIndex: number, fromOffset: number, maxSlice: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* `snapRowBreak` for a region that starts empty and still cannot hold the next
|
|
45
|
+
* unit: nested rows that stay whole give way so their content stays reachable.
|
|
46
|
+
*/
|
|
47
|
+
export declare function snapOversizedRowBreak(info: TableRowBreakInfo, rowIndex: number, fromOffset: number, maxSlice: number): number;
|
|
38
48
|
export {};
|