@stll/folio-core 0.67.0 → 0.69.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 +9 -1
- package/dist/ai-edits/apply.js +94 -8
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +106 -36
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/newListNumbering.d.ts +14 -1
- package/dist/ai-edits/newListNumbering.js +24 -1
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/pending-suggestions.js +2 -2
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +31 -14
- package/dist/controller/canonicalComposition.js +35 -6
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +32 -7
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +23 -0
- package/dist/controller/canonicalLockGuard.js +133 -0
- package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
- package/dist/controller/canonicalProjectionBlocks.js +75 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +676 -46
- package/dist/controller/canonicalSeedContent.d.ts +12 -0
- package/dist/controller/canonicalSeedContent.js +131 -0
- package/dist/controller/canonicalSession.d.ts +133 -21
- package/dist/controller/canonicalSession.js +738 -205
- package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
- package/dist/controller/canonicalSourceNormalization.js +148 -0
- package/dist/controller/canonicalStoryEditor.d.ts +4 -3
- package/dist/controller/canonicalStoryEditor.js +20 -15
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +4 -0
- package/dist/controller/headerFooterEditorManager.d.ts +7 -2
- package/dist/controller/headerFooterEditorManager.js +11 -6
- package/dist/controller/hiddenEditorApi.d.ts +17 -2
- package/dist/controller/hiddenEditorApi.js +4 -0
- package/dist/controller/hiddenEditorManager.d.ts +11 -3
- package/dist/controller/hiddenEditorManager.js +157 -48
- package/dist/controller/layoutPipeline.js +50 -16
- package/dist/controller/layoutSession.d.ts +3 -0
- package/dist/controller/layoutSession.js +3 -1
- package/dist/controller/noteEditorManager.d.ts +7 -2
- package/dist/controller/noteEditorManager.js +11 -6
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.js +23 -4
- package/dist/display-list/dom/renderDisplayListToDom.js +13 -11
- package/dist/document-operations.d.ts +9 -1
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +11 -2
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +40 -5
- package/dist/docx/commentAnchorIndex.js +94 -12
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/contentTypeRegistry.js +1 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +27 -0
- package/dist/docx/hostCommentThreads.js +72 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +226 -96
- package/dist/docx/listNumberingInstances.d.ts +1 -1
- package/dist/docx/listNumberingInstances.js +2 -2
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/numberingIds.d.ts +6 -0
- package/dist/docx/numberingIds.js +6 -1
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
- package/dist/docx/numberingReferenceNormalization.js +12 -2
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +29 -0
- package/dist/docx/paragraphPropertySource.js +106 -16
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +8 -0
- package/dist/docx/removeHeaderFooterParts.js +1 -1
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +171 -33
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +38 -21
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +5 -2
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/partNamespaces.d.ts +1 -1
- package/dist/docx/serializer/partNamespaces.js +1 -1
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +19 -2
- package/dist/docx/structuralXmlPatch.js +44 -11
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/docx/xmlParser.d.ts +1 -1
- package/dist/docx/xmlParser.js +2 -3
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +3 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
- package/dist/i18n/messages/catalogs.gen.js +51 -0
- package/dist/i18n/messages/cs.gen.js +3 -0
- package/dist/i18n/messages/de.gen.js +3 -0
- package/dist/i18n/messages/en.gen.js +3 -0
- package/dist/i18n/messages/es.gen.js +3 -0
- package/dist/i18n/messages/et.gen.js +3 -0
- package/dist/i18n/messages/fr.gen.js +3 -0
- package/dist/i18n/messages/he.gen.js +3 -0
- package/dist/i18n/messages/hi.gen.js +3 -0
- package/dist/i18n/messages/hu.gen.js +3 -0
- package/dist/i18n/messages/lt.gen.js +3 -0
- package/dist/i18n/messages/lv.gen.js +3 -0
- package/dist/i18n/messages/messages.gen.d.ts +3 -0
- package/dist/i18n/messages/pl.gen.js +3 -0
- package/dist/i18n/messages/pt-BR.gen.js +3 -0
- package/dist/i18n/messages/sk.gen.js +3 -0
- package/dist/i18n/messages/tr.gen.js +3 -0
- package/dist/i18n/messages/zh-CN.gen.js +3 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
- package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/internal/subtreeHolds.d.ts +12 -0
- package/dist/internal/subtreeHolds.js +25 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
- package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
- package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
- package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
- package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
- package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
- package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
- package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
- package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
- package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
- package/dist/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
- package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
- package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
- package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
- package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
- package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
- package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
- package/dist/layout-bridge/dom/textStreamDom.js +3 -2
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-bridge/headerFooterLayout.js +12 -11
- package/dist/layout-bridge/tableInsertHover.js +2 -1
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.d.ts +2 -0
- package/dist/layout-engine/measure/cache.js +16 -6
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
- package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
- package/dist/layout-engine/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +42 -1
- package/dist/layout-painter/imageLayout.js +2 -1
- package/dist/layout-painter/pageShellStyles.d.ts +10 -0
- package/dist/layout-painter/pageShellStyles.js +32 -0
- package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
- package/dist/layout-painter/reconcileRenderedContent.js +117 -0
- package/dist/layout-painter/renderFragment.js +4 -6
- package/dist/layout-painter/renderImage.js +2 -2
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +54 -46
- package/dist/layout-painter/renderParagraph.js +3 -3
- package/dist/layout-painter/renderTable.js +16 -16
- package/dist/layout-painter/renderTextBox.js +2 -2
- package/dist/layout-painter/sdtBoundary.js +3 -2
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/paged-layout/blockGeometry.js +3 -2
- package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
- package/dist/paged-layout/editorScrollRoot.js +10 -1
- package/dist/paged-layout/rangeProjection.js +5 -4
- package/dist/paged-layout/scrollToPmPosition.js +3 -3
- package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
- package/dist/paged-layout/selectionViewportRect.js +8 -2
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/attrs/index.js +2 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +30 -2
- package/dist/prosemirror/commands/comments.js +189 -18
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentRecords.d.ts +137 -0
- package/dist/prosemirror/commentRecords.js +400 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +85 -34
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +140 -4
- package/dist/prosemirror/conversion/toProseDoc.js +432 -76
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +23 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/nativeSelection.d.ts +33 -0
- package/dist/prosemirror/nativeSelection.js +74 -0
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/numberedRefFields.d.ts +2 -0
- package/dist/prosemirror/numberedRefFields.js +16 -5
- package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
- package/dist/prosemirror/paragraphMarkJoin.js +155 -16
- package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +37 -15
- package/dist/prosemirror/plugins/suggestionMode.js +33 -10
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +13 -1
- package/dist/prosemirror/storyListNumbering.js +7 -2
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/tableResize.d.ts +10 -9
- package/dist/prosemirror/tableResize.js +60 -49
- package/dist/prosemirror/textInput.d.ts +30 -1
- package/dist/prosemirror/textInput.js +144 -17
- package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
- package/dist/prosemirror/validation.d.ts +19 -0
- package/dist/prosemirror/validation.js +79 -5
- package/dist/redline.js +23 -9
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
- package/dist/render-dom/RenderedDomContext.js +7 -6
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +38 -16
- package/dist/types/canonicalCapabilities.js +21 -18
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/findMatchView.js +4 -3
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/dist/utils/mergeDocumentContent.js +2 -2
- package/dist/utils/paintedPositions.d.ts +60 -0
- package/dist/utils/paintedPositions.js +101 -0
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -3
|
@@ -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, snapOversizedRowBreak, snapRowBreak } from "./tableRowBreak.js";
|
|
5
|
+
import { buildTableRowBreakInfo, cellBandFromLines, getRowContinuationSkip, perCellRowCut, rowCellLineBands, 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.oversizedBreakOffsets[rowIndex]?.length ?? 0) <= 1) return false;
|
|
100
|
+
if ((breakInfo.oversizedBreakOffsets[rowIndex]?.length ?? 0) <= 1 && !rowCellLineBands(block, measure, rowIndex).some((lines) => lines.length > 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);
|
|
@@ -106,6 +106,7 @@ function layoutTable(block, measure, paginator, footnoteHeightById) {
|
|
|
106
106
|
const currentAvailableHeight = paginator.getAvailableHeight() - currentHeaderOverhead - state.trailingSpacing;
|
|
107
107
|
return oversized || row.height > currentAvailableHeight;
|
|
108
108
|
};
|
|
109
|
+
const rowCellBands = (rowIndex, band) => rowCellLineBands(block, measure, rowIndex).map((lines) => cellBandFromLines(lines, band));
|
|
109
110
|
while (currentRowIndex < rows.length) {
|
|
110
111
|
const rowState = paginator.getCurrentState();
|
|
111
112
|
const rowHeaderOverhead = shouldRepeatHeaderRows(currentRowIndex, 0, rowState) ? headerRowsHeight : 0;
|
|
@@ -122,6 +123,7 @@ function layoutTable(block, measure, paginator, footnoteHeightById) {
|
|
|
122
123
|
const splittableRow = rows[currentRowIndex];
|
|
123
124
|
if (canSplitRow(currentRowIndex)) {
|
|
124
125
|
let consumed = 0;
|
|
126
|
+
let shownThrough = 0;
|
|
125
127
|
const renderedBreakHints = tableRowHasTrackedChanges(block, currentRowIndex) ? [] : breakInfo.renderedBreakHints[currentRowIndex] ?? [];
|
|
126
128
|
let renderedBreakHintIndex = 0;
|
|
127
129
|
const discardPassedRenderedBreakHints = () => {
|
|
@@ -138,6 +140,7 @@ function layoutTable(block, measure, paginator, footnoteHeightById) {
|
|
|
138
140
|
const sliceAvail = paginator.getAvailableHeight() - headerOverhead - (consumed === 0 ? sliceState.trailingSpacing : 0);
|
|
139
141
|
let slice = snapRowBreak(breakInfo, currentRowIndex, consumed, sliceAvail);
|
|
140
142
|
let forceRenderedPageBreak = false;
|
|
143
|
+
let perCellCut = null;
|
|
141
144
|
if (slice <= 0) {
|
|
142
145
|
if (!(sliceState.cursorY === sliceState.topMargin && sliceState.page.fragments.length === 0)) {
|
|
143
146
|
const previousPageNumber = sliceState.page.number;
|
|
@@ -149,18 +152,30 @@ function layoutTable(block, measure, paginator, footnoteHeightById) {
|
|
|
149
152
|
if (slice <= 0) {
|
|
150
153
|
const from = consumed;
|
|
151
154
|
slice = (breakInfo.oversizedBreakOffsets[currentRowIndex]?.find((o) => o > from) ?? splittableRow.height) - consumed;
|
|
155
|
+
if (slice > sliceAvail) {
|
|
156
|
+
const cutPlan = perCellRowCut({
|
|
157
|
+
cellLines: rowCellLineBands(block, measure, currentRowIndex),
|
|
158
|
+
bandTop: consumed,
|
|
159
|
+
shownThrough: Math.max(shownThrough, consumed),
|
|
160
|
+
maxSlice: sliceAvail
|
|
161
|
+
});
|
|
162
|
+
if (cutPlan) {
|
|
163
|
+
slice = sliceAvail;
|
|
164
|
+
perCellCut = cutPlan;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
152
167
|
}
|
|
153
168
|
}
|
|
154
169
|
discardPassedRenderedBreakHints();
|
|
155
170
|
const renderedBreakHint = renderedBreakHints[renderedBreakHintIndex];
|
|
156
|
-
if (renderedBreakHint && renderedBreakHint.offset <= consumed + slice && sliceAvail - (renderedBreakHint.offset - consumed) <= renderedBreakHint.lineAdvance * 3) {
|
|
171
|
+
if (!perCellCut && renderedBreakHint && renderedBreakHint.offset <= consumed + slice && sliceAvail - (renderedBreakHint.offset - consumed) <= renderedBreakHint.lineAdvance * 3) {
|
|
157
172
|
slice = renderedBreakHint.offset - consumed;
|
|
158
173
|
renderedBreakHintIndex += 1;
|
|
159
174
|
forceRenderedPageBreak = true;
|
|
160
175
|
}
|
|
161
176
|
const sliceBottom = consumed + slice;
|
|
162
177
|
const continuationSkip = sliceBottom < splittableRow.height ? getRowContinuationSkip(breakInfo, currentRowIndex, sliceBottom) : 0;
|
|
163
|
-
const nextConsumed = Math.min(splittableRow.height, sliceBottom + continuationSkip);
|
|
178
|
+
const nextConsumed = perCellCut ? perCellCut.nextTop : Math.min(splittableRow.height, sliceBottom + continuationSkip);
|
|
164
179
|
const moreAfter = !(nextConsumed >= splittableRow.height) || currentRowIndex + 1 < rows.length;
|
|
165
180
|
const fragmentHeight = headerOverhead + slice;
|
|
166
181
|
const sliceFragment = {
|
|
@@ -177,11 +192,19 @@ function layoutTable(block, measure, paginator, footnoteHeightById) {
|
|
|
177
192
|
toRow: currentRowIndex + 1,
|
|
178
193
|
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
179
194
|
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {},
|
|
180
|
-
...consumed > 0 || currentRowIndex > 0 ? { continuesFromPrev: true } : {},
|
|
195
|
+
...consumed > 0 || shownThrough > 0 || currentRowIndex > 0 ? { continuesFromPrev: true } : {},
|
|
181
196
|
...moreAfter ? { continuesOnNext: true } : {},
|
|
182
197
|
...repeatHeaderRows ? { headerRowCount } : {},
|
|
183
198
|
...consumed > 0 ? { topClip: consumed } : {},
|
|
184
199
|
...sliceBottom >= splittableRow.height ? {} : { bottomClip: sliceBottom },
|
|
200
|
+
...perCellCut || shownThrough > consumed ? { cellLineBand: {
|
|
201
|
+
shownThrough,
|
|
202
|
+
cut: sliceBottom,
|
|
203
|
+
cells: rowCellBands(currentRowIndex, {
|
|
204
|
+
shownThrough,
|
|
205
|
+
cut: sliceBottom
|
|
206
|
+
})
|
|
207
|
+
} } : {},
|
|
185
208
|
...block.sdtGroups ? { sdtGroups: block.sdtGroups } : {}
|
|
186
209
|
};
|
|
187
210
|
const sliceResult = paginator.addFragment(sliceFragment, fragmentHeight, 0, 0);
|
|
@@ -191,6 +214,7 @@ function layoutTable(block, measure, paginator, footnoteHeightById) {
|
|
|
191
214
|
rowIndex: currentRowIndex
|
|
192
215
|
});
|
|
193
216
|
consumed = nextConsumed;
|
|
217
|
+
shownThrough = perCellCut ? perCellCut.cut : consumed;
|
|
194
218
|
if (consumed < splittableRow.height) {
|
|
195
219
|
if (forceRenderedPageBreak) paginator.forcePageBreak();
|
|
196
220
|
else {
|
|
@@ -32,6 +32,42 @@ export type TableRowBreakInfo = {
|
|
|
32
32
|
export declare function tableKeepNextOpeningHeight(block: TableBlock, measure: TableMeasure): number;
|
|
33
33
|
/** Build break geometry for a table from its block + measure. */
|
|
34
34
|
export declare function buildTableRowBreakInfo(block: TableBlock, measure: TableMeasure): TableRowBreakInfo;
|
|
35
|
+
/** Each cell's whole lines and atomic blocks, relative to the row top. */
|
|
36
|
+
export declare function rowCellLineBands(block: TableBlock, measure: TableMeasure, rowIndex: number): {
|
|
37
|
+
top: number;
|
|
38
|
+
bottom: number;
|
|
39
|
+
}[][];
|
|
40
|
+
type PerCellRowCutOptions = {
|
|
41
|
+
cellLines: readonly (readonly {
|
|
42
|
+
top: number;
|
|
43
|
+
bottom: number;
|
|
44
|
+
}[])[];
|
|
45
|
+
bandTop: number;
|
|
46
|
+
shownThrough: number;
|
|
47
|
+
maxSlice: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Cut a row that no shared line boundary lets a page hold. The cut itself runs
|
|
51
|
+
* through some cell's line, which then waits for the next band, so that band
|
|
52
|
+
* starts at the highest such line. Null when no line would finish on this page,
|
|
53
|
+
* or the next band would not start lower than this one, which is a line taller
|
|
54
|
+
* than the page: only clipping can place that.
|
|
55
|
+
*/
|
|
56
|
+
export declare function perCellRowCut({ cellLines, bandTop, shownThrough, maxSlice }: PerCellRowCutOptions): {
|
|
57
|
+
cut: number;
|
|
58
|
+
nextTop: number;
|
|
59
|
+
} | null;
|
|
60
|
+
/** The part of one cell a `cellLineBand` shows, in the row's own coordinates. */
|
|
61
|
+
export declare function cellBandFromLines(lines: readonly {
|
|
62
|
+
top: number;
|
|
63
|
+
bottom: number;
|
|
64
|
+
}[], { shownThrough, cut }: {
|
|
65
|
+
shownThrough: number;
|
|
66
|
+
cut: number;
|
|
67
|
+
}): {
|
|
68
|
+
top: number;
|
|
69
|
+
bottom: number;
|
|
70
|
+
};
|
|
35
71
|
/** Leading empty-paragraph whitespace to consume when a row resumes after `offset`. */
|
|
36
72
|
export declare function getRowContinuationSkip(info: TableRowBreakInfo, rowIndex: number, offset: number): number;
|
|
37
73
|
/**
|
|
@@ -314,6 +314,48 @@ function buildTableRowBreakInfo(block, measure) {
|
|
|
314
314
|
continuationSkips
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
+
/** Each cell's whole lines and atomic blocks, relative to the row top. */
|
|
318
|
+
function rowCellLineBands(block, measure, rowIndex) {
|
|
319
|
+
return rowCellGeometries(block, measure, rowIndex).map((geometry) => mergeBreakRanges(geometry.unsafeRanges));
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Cut a row that no shared line boundary lets a page hold. The cut itself runs
|
|
323
|
+
* through some cell's line, which then waits for the next band, so that band
|
|
324
|
+
* starts at the highest such line. Null when no line would finish on this page,
|
|
325
|
+
* or the next band would not start lower than this one, which is a line taller
|
|
326
|
+
* than the page: only clipping can place that.
|
|
327
|
+
*/
|
|
328
|
+
function perCellRowCut({ cellLines, bandTop, shownThrough, maxSlice }) {
|
|
329
|
+
const cut = bandTop + maxSlice;
|
|
330
|
+
let finishesLine = false;
|
|
331
|
+
let nextTop = cut;
|
|
332
|
+
for (const lines of cellLines) for (const line of lines) {
|
|
333
|
+
if (line.bottom <= shownThrough + BREAK_OFFSET_EPSILON) continue;
|
|
334
|
+
if (line.bottom <= cut + BREAK_OFFSET_EPSILON) {
|
|
335
|
+
finishesLine = true;
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
nextTop = Math.min(nextTop, line.top);
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
return finishesLine && nextTop > bandTop + BREAK_OFFSET_EPSILON ? {
|
|
342
|
+
cut,
|
|
343
|
+
nextTop
|
|
344
|
+
} : null;
|
|
345
|
+
}
|
|
346
|
+
/** The part of one cell a `cellLineBand` shows, in the row's own coordinates. */
|
|
347
|
+
function cellBandFromLines(lines, { shownThrough, cut }) {
|
|
348
|
+
const shown = lines.filter(({ bottom }) => bottom > shownThrough + BREAK_OFFSET_EPSILON && bottom <= cut + BREAK_OFFSET_EPSILON);
|
|
349
|
+
const first = shown.at(0);
|
|
350
|
+
const last = shown.at(-1);
|
|
351
|
+
return first && last ? {
|
|
352
|
+
top: first.top,
|
|
353
|
+
bottom: last.bottom
|
|
354
|
+
} : {
|
|
355
|
+
top: cut,
|
|
356
|
+
bottom: cut
|
|
357
|
+
};
|
|
358
|
+
}
|
|
317
359
|
/** Leading empty-paragraph whitespace to consume when a row resumes after `offset`. */
|
|
318
360
|
function getRowContinuationSkip(info, rowIndex, offset) {
|
|
319
361
|
const offsets = info.breakOffsets[rowIndex];
|
|
@@ -348,4 +390,4 @@ function snapToOffsets(offsets, fromOffset, maxSlice) {
|
|
|
348
390
|
}
|
|
349
391
|
return best;
|
|
350
392
|
}
|
|
351
|
-
export { buildTableRowBreakInfo, getRowContinuationSkip, snapOversizedRowBreak, snapRowBreak, tableKeepNextOpeningHeight };
|
|
393
|
+
export { buildTableRowBreakInfo, cellBandFromLines, getRowContinuationSkip, perCellRowCut, rowCellLineBands, snapOversizedRowBreak, snapRowBreak, tableKeepNextOpeningHeight };
|
|
@@ -5,7 +5,7 @@ import { CssBorderStyle } from "../utils/borderCss.js";
|
|
|
5
5
|
import { AutomaticTextSpacingPolicy } from "./measure/measureTypes.js";
|
|
6
6
|
import { ImagePosition, ImageWrap, InlineWrapper, NumberFormat, OutlineLevel, ParagraphNumberingOverride, PreviewDescriptor, SdtProperties, SdtType, SectionStart, ShapeTextBody, TableCellFormatting, TableWidthType, UnderlineStyle, VerticalAlign } from "@stll/docx-core/model";
|
|
7
7
|
declare namespace types_d_exports {
|
|
8
|
-
export { BlockId, BorderStyle, CellBorderSpec, CellBorders, ColumnBreakBlock, ColumnBreakMeasure, ColumnLayout, DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, DocumentPosition, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, FieldRun, FloatingTablePosition, FlowBlock, FootnoteContent, Fragment, FragmentBase, HeaderFooterContent, HeaderFooterContentHeights, HeaderFooterLayout, HitTestResult, HyperlinkInfo, ImageBlock, ImageFragment, ImageMeasure, ImageRun, ImageRunPosition, Layout, LayoutOptions, LineBreakRun, ListMarkerFormatting, MathRun, Measure, MeasuredLine, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, NoteAreaLayout, NoteSeparatorKind, NoteSeparatorRule, Page, PageBreakBlock, PageBreakMeasure, PageHeaderFooterRefs, PageMargins, ParagraphAttrs, ParagraphBlock, ParagraphBorders, ParagraphFragment, ParagraphIndent, ParagraphMeasure, ParagraphSpacing, RenderedPageBreakRun, Run, RunFormatting, SdtGroup, SectionBreakBlock, SectionBreakMeasure, SectionPageNumbering, TabAlignment, TabRun, TabStop, TableBlock, TableCell, TableCellMeasure, TableFragment, TableMeasure, TableRow, TableRowMeasure, TextBoxBlock, TextBoxFlowAttrs, TextBoxFragment, TextBoxGradientFill, TextBoxMeasure, TextRun, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, stripFlowBlockPmAnchors, tableColumnsArePinned };
|
|
8
|
+
export { BlockId, BorderStyle, CellBorderSpec, CellBorders, ColumnBreakBlock, ColumnBreakMeasure, ColumnLayout, DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, DocumentPosition, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, FieldRun, FloatingTablePosition, FlowBlock, FootnoteContent, FootnoteWindow, Fragment, FragmentBase, HeaderFooterContent, HeaderFooterContentHeights, HeaderFooterLayout, HitTestResult, HyperlinkInfo, ImageBlock, ImageFragment, ImageMeasure, ImageRun, ImageRunPosition, Layout, LayoutOptions, LineBreakRun, ListMarkerFormatting, MathRun, Measure, MeasuredLine, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, NoteAreaLayout, NoteSeparatorKind, NoteSeparatorRule, Page, PageBreakBlock, PageBreakMeasure, PageHeaderFooterRefs, PageMargins, ParagraphAttrs, ParagraphBlock, ParagraphBorders, ParagraphFragment, ParagraphIndent, ParagraphMeasure, ParagraphSpacing, RenderedPageBreakRun, Run, RunFormatting, SdtGroup, SectionBreakBlock, SectionBreakMeasure, SectionPageNumbering, TabAlignment, TabRun, TabStop, TableBlock, TableCell, TableCellMeasure, TableFragment, TableMeasure, TableRow, TableRowMeasure, TextBoxBlock, TextBoxFlowAttrs, TextBoxFragment, TextBoxGradientFill, TextBoxMeasure, TextRun, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, stripFlowBlockPmAnchors, tableColumnsArePinned };
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Unique identifier for a block in the document.
|
|
@@ -559,6 +559,12 @@ export type ParagraphAttrs = {
|
|
|
559
559
|
date?: string;
|
|
560
560
|
revisionId?: number;
|
|
561
561
|
};
|
|
562
|
+
/**
|
|
563
|
+
* Set when the paragraph holds a pending formatting change: of its own
|
|
564
|
+
* properties (`w:pPrChange`) or of a run in it (`w:rPrChange`). The text
|
|
565
|
+
* paints with its current formatting, so the change bar is what shows it.
|
|
566
|
+
*/
|
|
567
|
+
formattingRevision?: true;
|
|
562
568
|
/**
|
|
563
569
|
* When the marker text contains a TAB character (\t), the marker is
|
|
564
570
|
* rendered as a flex layout with two slots; this is the column offset
|
|
@@ -1217,6 +1223,22 @@ export type TableFragment = FragmentBase & {
|
|
|
1217
1223
|
*/
|
|
1218
1224
|
topClip?: number;
|
|
1219
1225
|
bottomClip?: number;
|
|
1226
|
+
/**
|
|
1227
|
+
* Set when no line boundary is shared by every cell within a page: the band
|
|
1228
|
+
* above cuts through some cell's line, so each cell shows only the lines that
|
|
1229
|
+
* end in `(shownThrough, cut]`, in the row's own coordinates. The next band
|
|
1230
|
+
* starts at the highest line left over, so a cell can show nothing twice and
|
|
1231
|
+
* lose nothing, at the cost of a gap of up to one line beside a shorter cell.
|
|
1232
|
+
*/
|
|
1233
|
+
cellLineBand?: {
|
|
1234
|
+
shownThrough: number;
|
|
1235
|
+
cut: number;
|
|
1236
|
+
/** Each cell's visible band, by cell index, in the row's own coordinates. */
|
|
1237
|
+
cells: readonly {
|
|
1238
|
+
top: number;
|
|
1239
|
+
bottom: number;
|
|
1240
|
+
}[];
|
|
1241
|
+
};
|
|
1220
1242
|
};
|
|
1221
1243
|
/**
|
|
1222
1244
|
* An image fragment positioned on a page.
|
|
@@ -1296,6 +1318,11 @@ export type Page = {
|
|
|
1296
1318
|
endnoteIds?: number[];
|
|
1297
1319
|
/** Height reserved for the footnote area at page bottom (pixels). */
|
|
1298
1320
|
footnoteReservedHeight?: number;
|
|
1321
|
+
/**
|
|
1322
|
+
* The part of a note this page shows, for a note too tall for its page. A
|
|
1323
|
+
* note listed in `footnoteIds` with no window shows whole.
|
|
1324
|
+
*/
|
|
1325
|
+
footnoteWindows?: readonly FootnoteWindow[];
|
|
1299
1326
|
/**
|
|
1300
1327
|
* Rules drawn for the `w:separator` / `w:continuationSeparator` marks of a
|
|
1301
1328
|
* note area that flows with the body (endnotes), in page coordinates.
|
|
@@ -1361,6 +1388,12 @@ export type HeaderFooterContentHeights = Partial<Record<"default" | "first" | "e
|
|
|
1361
1388
|
/**
|
|
1362
1389
|
* Pre-calculated footnote content for layout and rendering.
|
|
1363
1390
|
*/
|
|
1391
|
+
/** The part of a footnote's content one page shows, in the note's own heights. */
|
|
1392
|
+
export type FootnoteWindow = {
|
|
1393
|
+
noteId: number;
|
|
1394
|
+
from: number;
|
|
1395
|
+
to: number;
|
|
1396
|
+
};
|
|
1364
1397
|
export type FootnoteContent = {
|
|
1365
1398
|
/** Footnote ID. */
|
|
1366
1399
|
id: number;
|
|
@@ -1445,6 +1478,14 @@ export type LayoutOptions = {
|
|
|
1445
1478
|
* earlier-column placement.
|
|
1446
1479
|
*/
|
|
1447
1480
|
footnoteHeightById?: Map<number, number>;
|
|
1481
|
+
/**
|
|
1482
|
+
* Set when a note taller than its page's room continues on the next pages.
|
|
1483
|
+
* A reference then reserves at most a share of its section's page, and the
|
|
1484
|
+
* layout ends with `trailingPages` pages for what passes the last body page.
|
|
1485
|
+
*/
|
|
1486
|
+
footnoteContinuation?: {
|
|
1487
|
+
trailingPages: number;
|
|
1488
|
+
};
|
|
1448
1489
|
/** Header/footer references for each document section, by section index. */
|
|
1449
1490
|
sectionHeaderFooterRefs?: PageHeaderFooterRefs[];
|
|
1450
1491
|
/** Note areas (endnotes) whose blocks flow with the body blocks. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasPaintedStart } from "../utils/paintedPositions.js";
|
|
1
2
|
import { pixelsToEmu } from "../utils/units.js";
|
|
2
3
|
// src/layout-painter/imageLayout.ts
|
|
3
4
|
const LAYOUT_IMAGE_CLASSES = {
|
|
@@ -30,7 +31,7 @@ function findImageElement(target) {
|
|
|
30
31
|
if (!(target instanceof HTMLElement)) return null;
|
|
31
32
|
if (target.tagName === "IMG" && target.classList.contains(LAYOUT_IMAGE_CLASSES.runImage)) return target;
|
|
32
33
|
const container = target.closest(IMAGE_HIT_SELECTOR);
|
|
33
|
-
if (container && container
|
|
34
|
+
if (container && hasPaintedStart(container)) return container;
|
|
34
35
|
return null;
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolveFontFamily } from "../utils/fontResolver.js";
|
|
2
|
+
type PageShellStyleProperty = "position" | "width" | "height" | "backgroundColor" | "color" | "overflow" | "border" | "boxShadow" | "outline" | "fontFamily" | "fontSize";
|
|
3
|
+
export type PageShellStyleOptions = NonNullable<Parameters<typeof resolveFontFamily>[1]> & {
|
|
4
|
+
backgroundColor?: string | undefined;
|
|
5
|
+
};
|
|
6
|
+
/** The shell's styles for a `width` x `height` page, one value per property. */
|
|
7
|
+
export declare const pageShellStyles: (width: number, height: number, options: PageShellStyleOptions) => Readonly<Record<PageShellStyleProperty, string>>;
|
|
8
|
+
/** Give `element` the shell styles, each property written once. */
|
|
9
|
+
export declare const applyPageShellStyles: (element: HTMLElement, width: number, height: number, options: PageShellStyleOptions) => void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DEFAULT_FONT_FAMILY } from "../layout-engine/measure/measureHelpers.js";
|
|
2
|
+
import { resolveFontFamily } from "../utils/fontResolver.js";
|
|
3
|
+
// src/layout-painter/pageShellStyles.ts
|
|
4
|
+
/**
|
|
5
|
+
* The inline styles of a painted page's shell.
|
|
6
|
+
*
|
|
7
|
+
* Every layout pass applies them to every page shell. The page's text
|
|
8
|
+
* inherits colour and font from the shell, so a property written to another
|
|
9
|
+
* value and back within a pass restyles every line painted on the page, on
|
|
10
|
+
* every keystroke. Each property therefore appears once, with its final
|
|
11
|
+
* value: writing a value the shell already holds changes nothing.
|
|
12
|
+
*/
|
|
13
|
+
/** The shell's styles for a `width` x `height` page, one value per property. */
|
|
14
|
+
const pageShellStyles = (width, height, options) => ({
|
|
15
|
+
position: "relative",
|
|
16
|
+
width: `${width}px`,
|
|
17
|
+
height: `${height}px`,
|
|
18
|
+
backgroundColor: options.backgroundColor ?? "var(--doc-canvas, #ffffff)",
|
|
19
|
+
color: "var(--doc-canvas-text, #000)",
|
|
20
|
+
overflow: "hidden",
|
|
21
|
+
border: "none",
|
|
22
|
+
boxShadow: "none",
|
|
23
|
+
outline: "none",
|
|
24
|
+
fontFamily: resolveFontFamily(DEFAULT_FONT_FAMILY, options).cssFallback,
|
|
25
|
+
fontSize: `${1056 / 72}px`
|
|
26
|
+
});
|
|
27
|
+
/** Give `element` the shell styles, each property written once. */
|
|
28
|
+
const applyPageShellStyles = (element, width, height, options) => {
|
|
29
|
+
const styles = pageShellStyles(width, height, options);
|
|
30
|
+
for (const property of Object.keys(styles)) element.style[property] = styles[property];
|
|
31
|
+
};
|
|
32
|
+
export { applyPageShellStyles, pageShellStyles };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bring a painted page's content up to a fresh rendering of it while keeping
|
|
3
|
+
* the painted nodes that did not change. Replacing the whole content area for
|
|
4
|
+
* one edited paragraph makes the browser restyle, lay out, paint and raster
|
|
5
|
+
* every line on the page; keeping the unchanged nodes limits that to the
|
|
6
|
+
* paragraphs the edit touched.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Make `painted` equal to `fresh` (as `isEqualNode` compares them), keeping
|
|
10
|
+
* every node of `painted` that shows what its counterpart in `fresh` shows and
|
|
11
|
+
* moving in from `fresh` only the smallest subtrees that differ: an edit in
|
|
12
|
+
* one table cell replaces that cell's changed line, not the table. Returns
|
|
13
|
+
* false, changing nothing, when the two differ in their own attributes or in
|
|
14
|
+
* their number of children: the caller then replaces `painted` whole.
|
|
15
|
+
*
|
|
16
|
+
* The fresh nodes it moves leave `fresh`; what remains there is the caller's
|
|
17
|
+
* to release.
|
|
18
|
+
*/
|
|
19
|
+
export declare const reconcileRenderedContent: (painted: Element, fresh: Element) => boolean;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { releaseDisplayPageResources } from "../display-list/pageResourceOwnership.js";
|
|
2
|
+
import { PAINTED_POSITION_ATTRIBUTES } from "../utils/paintedPositions.js";
|
|
3
|
+
// src/layout-painter/reconcileRenderedContent.ts
|
|
4
|
+
/**
|
|
5
|
+
* Bring a painted page's content up to a fresh rendering of it while keeping
|
|
6
|
+
* the painted nodes that did not change. Replacing the whole content area for
|
|
7
|
+
* one edited paragraph makes the browser restyle, lay out, paint and raster
|
|
8
|
+
* every line on the page; keeping the unchanged nodes limits that to the
|
|
9
|
+
* paragraphs the edit touched.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The attributes that say where a painted node stands in the editor document.
|
|
13
|
+
* An edit before a paragraph shifts them without changing what it shows, so a
|
|
14
|
+
* node that differs from its fresh rendering only in these is kept and takes
|
|
15
|
+
* the fresh values.
|
|
16
|
+
*/
|
|
17
|
+
const POSITION_ATTRIBUTES = PAINTED_POSITION_ATTRIBUTES;
|
|
18
|
+
const sameAttributes = (painted, fresh, ignoring) => {
|
|
19
|
+
if (painted.attributes.length !== fresh.attributes.length) return false;
|
|
20
|
+
for (const attribute of Array.from(fresh.attributes)) {
|
|
21
|
+
if (ignoring.has(attribute.name)) {
|
|
22
|
+
if (!painted.hasAttribute(attribute.name)) return false;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (painted.getAttribute(attribute.name) !== attribute.value) return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
const NO_ATTRIBUTES = /* @__PURE__ */ new Set();
|
|
30
|
+
/** Whether `painted` shows what `fresh` shows, positions aside. */
|
|
31
|
+
const showsTheSame = (painted, fresh) => {
|
|
32
|
+
if (painted.nodeType !== fresh.nodeType) return false;
|
|
33
|
+
if (painted.nodeType !== painted.ELEMENT_NODE) return painted.isEqualNode(fresh);
|
|
34
|
+
const paintedElement = painted;
|
|
35
|
+
const freshElement = fresh;
|
|
36
|
+
if (paintedElement.namespaceURI !== freshElement.namespaceURI || paintedElement.localName !== freshElement.localName || !sameAttributes(paintedElement, freshElement, POSITION_ATTRIBUTES)) return false;
|
|
37
|
+
const paintedChildren = painted.childNodes;
|
|
38
|
+
const freshChildren = fresh.childNodes;
|
|
39
|
+
if (paintedChildren.length !== freshChildren.length) return false;
|
|
40
|
+
for (let index = 0; index < freshChildren.length; index += 1) {
|
|
41
|
+
const paintedChild = paintedChildren[index];
|
|
42
|
+
const freshChild = freshChildren[index];
|
|
43
|
+
if (!paintedChild || !freshChild || !showsTheSame(paintedChild, freshChild)) return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
/** Give `painted` its own position attributes from `fresh`. */
|
|
48
|
+
const takeOwnPositions = (painted, fresh) => {
|
|
49
|
+
for (const name of POSITION_ATTRIBUTES) {
|
|
50
|
+
const value = fresh.getAttribute(name);
|
|
51
|
+
if (value !== null && painted.getAttribute(name) !== value) painted.setAttribute(name, value);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/** Give `painted` the position attributes of `fresh`, which shows the same. */
|
|
55
|
+
const takePositions = (painted, fresh) => {
|
|
56
|
+
if (painted.nodeType !== painted.ELEMENT_NODE) return;
|
|
57
|
+
takeOwnPositions(painted, fresh);
|
|
58
|
+
const paintedChildren = painted.childNodes;
|
|
59
|
+
const freshChildren = fresh.childNodes;
|
|
60
|
+
for (let index = 0; index < freshChildren.length; index += 1) {
|
|
61
|
+
const paintedChild = paintedChildren[index];
|
|
62
|
+
const freshChild = freshChildren[index];
|
|
63
|
+
if (paintedChild && freshChild) takePositions(paintedChild, freshChild);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Whether `painted` can stay with `fresh`'s position attributes while its
|
|
68
|
+
* children are brought up to `fresh`'s one by one.
|
|
69
|
+
*/
|
|
70
|
+
const sameShell = (painted, fresh) => {
|
|
71
|
+
if (painted.nodeType !== painted.ELEMENT_NODE || fresh.nodeType !== fresh.ELEMENT_NODE) return false;
|
|
72
|
+
const paintedElement = painted;
|
|
73
|
+
const freshElement = fresh;
|
|
74
|
+
return paintedElement.namespaceURI === freshElement.namespaceURI && paintedElement.localName === freshElement.localName && painted.childNodes.length === fresh.childNodes.length && sameAttributes(paintedElement, freshElement, POSITION_ATTRIBUTES);
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Bring each child of `painted` up to its counterpart in `fresh`: keep it when
|
|
78
|
+
* it shows the same, descend into it when only some of its children differ,
|
|
79
|
+
* and move the fresh one in otherwise. The two have as many children.
|
|
80
|
+
*/
|
|
81
|
+
const reconcileChildren = (painted, fresh) => {
|
|
82
|
+
const paintedChildren = Array.from(painted.childNodes);
|
|
83
|
+
const freshChildren = Array.from(fresh.childNodes);
|
|
84
|
+
for (const [index, freshChild] of freshChildren.entries()) {
|
|
85
|
+
const paintedChild = paintedChildren[index];
|
|
86
|
+
if (!paintedChild) continue;
|
|
87
|
+
if (paintedChild.isEqualNode(freshChild)) continue;
|
|
88
|
+
if (showsTheSame(paintedChild, freshChild)) {
|
|
89
|
+
takePositions(paintedChild, freshChild);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (sameShell(paintedChild, freshChild)) {
|
|
93
|
+
takeOwnPositions(paintedChild, freshChild);
|
|
94
|
+
reconcileChildren(paintedChild, freshChild);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (paintedChild.nodeType === paintedChild.ELEMENT_NODE) releaseDisplayPageResources(paintedChild);
|
|
98
|
+
paintedChild.replaceWith(freshChild);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Make `painted` equal to `fresh` (as `isEqualNode` compares them), keeping
|
|
103
|
+
* every node of `painted` that shows what its counterpart in `fresh` shows and
|
|
104
|
+
* moving in from `fresh` only the smallest subtrees that differ: an edit in
|
|
105
|
+
* one table cell replaces that cell's changed line, not the table. Returns
|
|
106
|
+
* false, changing nothing, when the two differ in their own attributes or in
|
|
107
|
+
* their number of children: the caller then replaces `painted` whole.
|
|
108
|
+
*
|
|
109
|
+
* The fresh nodes it moves leave `fresh`; what remains there is the caller's
|
|
110
|
+
* to release.
|
|
111
|
+
*/
|
|
112
|
+
const reconcileRenderedContent = (painted, fresh) => {
|
|
113
|
+
if (painted.localName !== fresh.localName || !sameAttributes(painted, fresh, NO_ATTRIBUTES) || painted.childNodes.length !== fresh.childNodes.length) return false;
|
|
114
|
+
reconcileChildren(painted, fresh);
|
|
115
|
+
return true;
|
|
116
|
+
};
|
|
117
|
+
export { reconcileRenderedContent };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { writePaintedRange } from "../utils/paintedPositions.js";
|
|
1
2
|
import { applySdtDataAttrs } from "./sdtBoundary.js";
|
|
2
3
|
// src/layout-painter/renderFragment.ts
|
|
3
4
|
/**
|
|
@@ -50,8 +51,7 @@ function renderParagraphFragmentPlaceholder(fragment, _context, doc) {
|
|
|
50
51
|
el.dataset["blockId"] = String(fragment.blockId);
|
|
51
52
|
el.dataset["fromLine"] = String(fragment.fromLine);
|
|
52
53
|
el.dataset["toLine"] = String(fragment.toLine);
|
|
53
|
-
|
|
54
|
-
if (fragment.pmEnd !== void 0) el.dataset["pmEnd"] = String(fragment.pmEnd);
|
|
54
|
+
writePaintedRange(el, fragment.pmStart, fragment.pmEnd);
|
|
55
55
|
if (fragment.continuesFromPrev) el.dataset["continuesFromPrev"] = "true";
|
|
56
56
|
if (fragment.continuesOnNext) el.dataset["continuesOnNext"] = "true";
|
|
57
57
|
applySdtDataAttrs(el, fragment.sdtGroups);
|
|
@@ -70,8 +70,7 @@ function renderTableFragmentPlaceholder(fragment, _context, doc) {
|
|
|
70
70
|
el.dataset["blockId"] = String(fragment.blockId);
|
|
71
71
|
el.dataset["fromRow"] = String(fragment.fromRow);
|
|
72
72
|
el.dataset["toRow"] = String(fragment.toRow);
|
|
73
|
-
|
|
74
|
-
if (fragment.pmEnd !== void 0) el.dataset["pmEnd"] = String(fragment.pmEnd);
|
|
73
|
+
writePaintedRange(el, fragment.pmStart, fragment.pmEnd);
|
|
75
74
|
applySdtDataAttrs(el, fragment.sdtGroups);
|
|
76
75
|
return el;
|
|
77
76
|
}
|
|
@@ -83,8 +82,7 @@ function renderImageFragmentPlaceholder(fragment, _context, doc) {
|
|
|
83
82
|
el.className = `${FRAGMENT_CLASS_NAMES.fragment} ${FRAGMENT_CLASS_NAMES.image}`;
|
|
84
83
|
applyBaseFragmentStyles(el);
|
|
85
84
|
el.dataset["blockId"] = String(fragment.blockId);
|
|
86
|
-
|
|
87
|
-
if (fragment.pmEnd !== void 0) el.dataset["pmEnd"] = String(fragment.pmEnd);
|
|
85
|
+
writePaintedRange(el, fragment.pmStart, fragment.pmEnd);
|
|
88
86
|
if (fragment.isAnchored) el.dataset["anchored"] = "true";
|
|
89
87
|
if (fragment.zIndex !== void 0) el.style.zIndex = String(fragment.zIndex);
|
|
90
88
|
return el;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { imageLuminanceFilter } from "../utils/imageLuminance.js";
|
|
2
|
+
import { writePaintedRange } from "../utils/paintedPositions.js";
|
|
2
3
|
import { applySanitizedImageSrc } from "../utils/sanitizeImageSrc.js";
|
|
3
4
|
import { anchorTargetAttrs, sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
4
5
|
import { paintedImageSource } from "./previewSvg.js";
|
|
@@ -137,8 +138,7 @@ function renderImageFragment(fragment, block, _measure, _context, options = {})
|
|
|
137
138
|
if (fragment.zIndex !== void 0) containerEl.style.zIndex = String(fragment.zIndex);
|
|
138
139
|
if (block.anchor?.behindDoc) containerEl.style.zIndex = "-1";
|
|
139
140
|
containerEl.dataset["blockId"] = String(fragment.blockId);
|
|
140
|
-
|
|
141
|
-
if (fragment.pmEnd !== void 0) containerEl.dataset["pmEnd"] = String(fragment.pmEnd);
|
|
141
|
+
writePaintedRange(containerEl, fragment.pmStart, fragment.pmEnd);
|
|
142
142
|
const imgEl = doc.createElement("img");
|
|
143
143
|
applySanitizedImageSrc(imgEl, paintedImageSource(block));
|
|
144
144
|
imgEl.alt = block.alt ?? "";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { DocumentFontFacts } from "../fonts/documentFontFacts.js";
|
|
3
|
-
import { FootnoteContent, HeaderFooterContent, ImageRun, Page, isFloatingImageRun } from "../layout-engine/types.js";
|
|
3
|
+
import { FootnoteContent, FootnoteWindow, HeaderFooterContent, ImageRun, Page, isFloatingImageRun } from "../layout-engine/types.js";
|
|
4
4
|
import { AnchoredImagePosition, PageGeometry } from "./anchoredImagePosition.js";
|
|
5
5
|
import { RenderContext, emuToPixels } from "./renderUtils.js";
|
|
6
6
|
import { BlockLookup } from "./index.js";
|
|
@@ -249,12 +249,12 @@ export declare function renderFloatingImagesLayer(floatingImages: PageFloatingIm
|
|
|
249
249
|
* from eigenpal/docx-editor#485, extended for folio's fallback rendering
|
|
250
250
|
* and any wrapper margin so the helper matches the painted stack.
|
|
251
251
|
*/
|
|
252
|
-
export declare function calculateFootnoteAreaRenderHeight(footnotes: FootnoteRenderItem[]): number;
|
|
252
|
+
export declare function calculateFootnoteAreaRenderHeight(footnotes: FootnoteRenderItem[], windows?: readonly FootnoteWindow[]): number;
|
|
253
253
|
/**
|
|
254
254
|
* Render the footnote area at the bottom of a page.
|
|
255
255
|
* Includes a separator line (33% width) and footnote entries.
|
|
256
256
|
*/
|
|
257
|
-
export declare function renderFootnoteArea(footnotes: FootnoteRenderItem[], contentWidth: number, doc: Document, context?: RenderContext): HTMLElement;
|
|
257
|
+
export declare function renderFootnoteArea(footnotes: FootnoteRenderItem[], contentWidth: number, doc: Document, context?: RenderContext, windows?: readonly FootnoteWindow[]): HTMLElement;
|
|
258
258
|
/**
|
|
259
259
|
* Render a single page to DOM
|
|
260
260
|
*
|
|
@@ -280,7 +280,7 @@ export declare function applySectionHeaderFooterOptions(page: Page, pageOptions:
|
|
|
280
280
|
* Compute a fingerprint string for a page that changes when its content changes.
|
|
281
281
|
* Used to detect which pages need re-rendering on incremental updates.
|
|
282
282
|
*/
|
|
283
|
-
export declare function computePageFingerprint(page: Page, blockLookup?: BlockLookup): string;
|
|
283
|
+
export declare function computePageFingerprint(page: Page, blockLookup?: BlockLookup, footnotes?: readonly FootnoteRenderItem[]): string;
|
|
284
284
|
/**
|
|
285
285
|
* Render multiple pages to a container with virtualization for large documents.
|
|
286
286
|
*
|