@stll/folio-core 0.0.1-placeholder.0 → 0.1.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/LICENSE +202 -0
- package/NOTICE.md +29 -0
- package/README.md +41 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/ai-edits/apply.d.ts +35 -0
- package/dist/ai-edits/apply.js +683 -0
- package/dist/ai-edits/clean-text.d.ts +28 -0
- package/dist/ai-edits/clean-text.js +23 -0
- package/dist/ai-edits/headless.d.ts +225 -0
- package/dist/ai-edits/headless.js +513 -0
- package/dist/ai-edits/index.d.ts +6 -0
- package/dist/ai-edits/index.js +5 -0
- package/dist/ai-edits/inline-emphasis.d.ts +38 -0
- package/dist/ai-edits/inline-emphasis.js +78 -0
- package/dist/ai-edits/snapshot.d.ts +9 -0
- package/dist/ai-edits/snapshot.js +195 -0
- package/dist/ai-edits/types.d.ts +156 -0
- package/dist/ai-edits/types.js +0 -0
- package/dist/ai-edits/word-diff.d.ts +20 -0
- package/dist/ai-edits/word-diff.js +77 -0
- package/dist/ai-suggestions/apply.d.ts +17 -0
- package/dist/ai-suggestions/apply.js +64 -0
- package/dist/ai-suggestions/conflict.d.ts +22 -0
- package/dist/ai-suggestions/conflict.js +67 -0
- package/dist/ai-suggestions/text-positions.d.ts +21 -0
- package/dist/ai-suggestions/text-positions.js +48 -0
- package/dist/ai-suggestions/types.d.ts +199 -0
- package/dist/ai-suggestions/types.js +59 -0
- package/dist/content-controls/errors.d.ts +52 -0
- package/dist/content-controls/errors.js +36 -0
- package/dist/content-controls/findContentControls.d.ts +55 -0
- package/dist/content-controls/findContentControls.js +75 -0
- package/dist/content-controls/index.d.ts +4 -0
- package/dist/content-controls/index.js +4 -0
- package/dist/content-controls/mutateContentControls.d.ts +51 -0
- package/dist/content-controls/mutateContentControls.js +377 -0
- package/dist/controller/folioEditor.d.ts +21 -0
- package/dist/controller/folioEditor.js +29 -0
- package/dist/controller/folioEditorEvents.d.ts +23 -0
- package/dist/controller/folioEditorEvents.js +24 -0
- package/dist/controller/hiddenEditorApi.d.ts +35 -0
- package/dist/controller/hiddenEditorApi.js +112 -0
- package/dist/controller/hiddenEditorManager.d.ts +93 -0
- package/dist/controller/hiddenEditorManager.js +308 -0
- package/dist/controller/layoutPipeline.d.ts +63 -0
- package/dist/controller/layoutPipeline.js +406 -0
- package/dist/controller/layoutScheduler.d.ts +41 -0
- package/dist/controller/layoutScheduler.js +59 -0
- package/dist/controller/layoutSession.d.ts +24 -0
- package/dist/controller/layoutSession.js +13 -0
- package/dist/docx/blockContentParser.d.ts +13 -0
- package/dist/docx/blockContentParser.js +289 -0
- package/dist/docx/bookmarkParser.d.ts +178 -0
- package/dist/docx/bookmarkParser.js +246 -0
- package/dist/docx/bookmarkPlacement.d.ts +10 -0
- package/dist/docx/bookmarkPlacement.js +50 -0
- package/dist/docx/bulletMarkers.d.ts +4 -0
- package/dist/docx/bulletMarkers.js +42 -0
- package/dist/docx/commentParser.d.ts +34 -0
- package/dist/docx/commentParser.js +127 -0
- package/dist/docx/commentReferenceNormalization.d.ts +25 -0
- package/dist/docx/commentReferenceNormalization.js +97 -0
- package/dist/docx/commentReplyMarkers.d.ts +20 -0
- package/dist/docx/commentReplyMarkers.js +123 -0
- package/dist/docx/compatibility.d.ts +12 -0
- package/dist/docx/compatibility.js +77 -0
- package/dist/docx/documentParser.d.ts +65 -0
- package/dist/docx/documentParser.js +209 -0
- package/dist/docx/drawingUtils.d.ts +56 -0
- package/dist/docx/drawingUtils.js +305 -0
- package/dist/docx/fieldParser.d.ts +228 -0
- package/dist/docx/fieldParser.js +559 -0
- package/dist/docx/footnoteParser.d.ts +109 -0
- package/dist/docx/footnoteParser.js +270 -0
- package/dist/docx/headerFooterParser.d.ts +119 -0
- package/dist/docx/headerFooterParser.js +266 -0
- package/dist/docx/headerFooterRefParser.d.ts +22 -0
- package/dist/docx/headerFooterRefParser.js +52 -0
- package/dist/docx/headerFooterReferenceNormalization.d.ts +19 -0
- package/dist/docx/headerFooterReferenceNormalization.js +64 -0
- package/dist/docx/hyperlinkParser.d.ts +108 -0
- package/dist/docx/hyperlinkParser.js +230 -0
- package/dist/docx/imageParser.d.ts +93 -0
- package/dist/docx/imageParser.js +522 -0
- package/dist/docx/mathToMathml.d.ts +15 -0
- package/dist/docx/mathToMathml.js +357 -0
- package/dist/docx/modelValidation.d.ts +13 -0
- package/dist/docx/modelValidation.js +21 -0
- package/dist/docx/normalizeBaseDirection.d.ts +12 -0
- package/dist/docx/normalizeBaseDirection.js +81 -0
- package/dist/docx/notePropertiesParser.d.ts +16 -0
- package/dist/docx/notePropertiesParser.js +99 -0
- package/dist/docx/numberingParser.d.ts +86 -0
- package/dist/docx/numberingParser.js +735 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +25 -0
- package/dist/docx/numberingReferenceNormalization.js +22 -0
- package/dist/docx/paragraphParser.d.ts +86 -0
- package/dist/docx/paragraphParser.js +1132 -0
- package/dist/docx/paragraphTraversal.d.ts +19 -0
- package/dist/docx/paragraphTraversal.js +76 -0
- package/dist/docx/parser.d.ts +67 -0
- package/dist/docx/parser.js +391 -0
- package/dist/docx/parserEnums.d.ts +45 -0
- package/dist/docx/parserEnums.js +70 -0
- package/dist/docx/relsParser.d.ts +160 -0
- package/dist/docx/relsParser.js +235 -0
- package/dist/docx/replyToComment.d.ts +29 -0
- package/dist/docx/replyToComment.js +73 -0
- package/dist/docx/rezip.d.ts +166 -0
- package/dist/docx/rezip.js +1194 -0
- package/dist/docx/runConsolidator.d.ts +57 -0
- package/dist/docx/runConsolidator.js +224 -0
- package/dist/docx/runParser.d.ts +78 -0
- package/dist/docx/runParser.js +661 -0
- package/dist/docx/sdtProperties.d.ts +15 -0
- package/dist/docx/sdtProperties.js +290 -0
- package/dist/docx/sdtPropertiesPatch.d.ts +16 -0
- package/dist/docx/sdtPropertiesPatch.js +144 -0
- package/dist/docx/sectionParser.d.ts +95 -0
- package/dist/docx/sectionParser.js +534 -0
- package/dist/docx/selectiveSave.d.ts +25 -0
- package/dist/docx/selectiveSave.js +247 -0
- package/dist/docx/selectiveSaveFlags.d.ts +33 -0
- package/dist/docx/selectiveSaveFlags.js +11 -0
- package/dist/docx/selectiveSaveTripwire.d.ts +33 -0
- package/dist/docx/selectiveSaveTripwire.js +79 -0
- package/dist/docx/selectiveXmlPatch.d.ts +103 -0
- package/dist/docx/selectiveXmlPatch.js +493 -0
- package/dist/docx/serializer/blockSdtSerializer.d.ts +6 -0
- package/dist/docx/serializer/blockSdtSerializer.js +88 -0
- package/dist/docx/serializer/borderSerializer.d.ts +25 -0
- package/dist/docx/serializer/borderSerializer.js +44 -0
- package/dist/docx/serializer/commentSerializer.d.ts +31 -0
- package/dist/docx/serializer/commentSerializer.js +184 -0
- package/dist/docx/serializer/documentSerializer.d.ts +65 -0
- package/dist/docx/serializer/documentSerializer.js +199 -0
- package/dist/docx/serializer/headerFooterSerializer.d.ts +12 -0
- package/dist/docx/serializer/headerFooterSerializer.js +84 -0
- package/dist/docx/serializer/noteSerializer.d.ts +19 -0
- package/dist/docx/serializer/noteSerializer.js +70 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +12 -0
- package/dist/docx/serializer/numberingSerializer.js +93 -0
- package/dist/docx/serializer/paragraphSerializer.d.ts +48 -0
- package/dist/docx/serializer/paragraphSerializer.js +559 -0
- package/dist/docx/serializer/runSerializer.d.ts +56 -0
- package/dist/docx/serializer/runSerializer.js +621 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.d.ts +6 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +187 -0
- package/dist/docx/serializer/tableSerializer.d.ts +79 -0
- package/dist/docx/serializer/tableSerializer.js +422 -0
- package/dist/docx/serializer/xmlUtils.d.ts +20 -0
- package/dist/docx/serializer/xmlUtils.js +25 -0
- package/dist/docx/settingsParser.d.ts +8 -0
- package/dist/docx/settingsParser.js +36 -0
- package/dist/docx/shapeParser.d.ts +20 -0
- package/dist/docx/shapeParser.js +272 -0
- package/dist/docx/styleParser.d.ts +50 -0
- package/dist/docx/styleParser.js +905 -0
- package/dist/docx/tableParser.d.ts +202 -0
- package/dist/docx/tableParser.js +811 -0
- package/dist/docx/textBoxParser.d.ts +117 -0
- package/dist/docx/textBoxParser.js +262 -0
- package/dist/docx/themeParser.d.ts +77 -0
- package/dist/docx/themeParser.js +330 -0
- package/dist/docx/trackedMoveRangeNormalization.d.ts +22 -0
- package/dist/docx/trackedMoveRangeNormalization.js +100 -0
- package/dist/docx/unzip.d.ts +118 -0
- package/dist/docx/unzip.js +383 -0
- package/dist/docx/vmlImageParser.d.ts +16 -0
- package/dist/docx/vmlImageParser.js +100 -0
- package/dist/docx/watermarkParser.d.ts +45 -0
- package/dist/docx/watermarkParser.js +348 -0
- package/dist/docx/wrapTypes.d.ts +29 -0
- package/dist/docx/wrapTypes.js +48 -0
- package/dist/docx/xmlParser.d.ts +297 -0
- package/dist/docx/xmlParser.js +527 -0
- package/dist/fields/bookmarkPages.d.ts +13 -0
- package/dist/fields/bookmarkPages.js +66 -0
- package/dist/fields/bookmarkText.d.ts +16 -0
- package/dist/fields/bookmarkText.js +61 -0
- package/dist/fields/evaluateField.d.ts +23 -0
- package/dist/fields/evaluateField.js +77 -0
- package/dist/fields/fieldContext.d.ts +21 -0
- package/dist/fields/fieldContext.js +0 -0
- package/dist/fields/resolveFieldValues.d.ts +44 -0
- package/dist/fields/resolveFieldValues.js +204 -0
- package/dist/fields/sectionPageCounts.d.ts +11 -0
- package/dist/fields/sectionPageCounts.js +16 -0
- package/dist/fields/seqValues.d.ts +14 -0
- package/dist/fields/seqValues.js +36 -0
- package/dist/fonts/embeddedFontTable.d.ts +42 -0
- package/dist/fonts/embeddedFontTable.js +80 -0
- package/dist/fonts/embeddedFonts.d.ts +46 -0
- package/dist/fonts/embeddedFonts.js +112 -0
- package/dist/fonts/fontDeobfuscation.d.ts +30 -0
- package/dist/fonts/fontDeobfuscation.js +57 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +23 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +57 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +316 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +74 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +432 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +36 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.js +176 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +65 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +1309 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +17 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.js +36 -0
- package/dist/layout-bridge/dom/clickToPositionDom.d.ts +66 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +304 -0
- package/dist/layout-bridge/dom/findBodyPmSpans.d.ts +7 -0
- package/dist/layout-bridge/dom/findBodyPmSpans.js +17 -0
- package/dist/layout-bridge/dom/findHfPmSpans.d.ts +62 -0
- package/dist/layout-bridge/dom/findHfPmSpans.js +197 -0
- package/dist/layout-bridge/engine/clickToPosition.d.ts +66 -0
- package/dist/layout-bridge/engine/clickToPosition.js +403 -0
- package/dist/layout-bridge/engine/hitTest.d.ts +135 -0
- package/dist/layout-bridge/engine/hitTest.js +375 -0
- package/dist/layout-bridge/engine/measuring/index.d.ts +10 -0
- package/dist/layout-bridge/engine/measuring/index.js +9 -0
- package/dist/layout-bridge/engine/selectionRects.d.ts +59 -0
- package/dist/layout-bridge/engine/selectionRects.js +485 -0
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +7 -0
- package/dist/layout-bridge/engine/tableWidthUtils.js +25 -0
- package/dist/layout-engine/index.d.ts +44 -0
- package/dist/layout-engine/index.js +691 -0
- package/dist/layout-engine/keep-together.d.ts +43 -0
- package/dist/layout-engine/keep-together.js +98 -0
- package/dist/layout-engine/layoutInstrumentation.d.ts +50 -0
- package/dist/layout-engine/layoutInstrumentation.js +43 -0
- package/dist/layout-engine/lineFlow.d.ts +8 -0
- package/dist/layout-engine/lineFlow.js +17 -0
- package/dist/layout-engine/measure/cache.d.ts +93 -0
- package/dist/layout-engine/measure/cache.js +245 -0
- package/dist/layout-engine/measure/clampFloatingWrapMargins.d.ts +20 -0
- package/dist/layout-engine/measure/clampFloatingWrapMargins.js +29 -0
- package/dist/layout-engine/measure/featureFlags.d.ts +44 -0
- package/dist/layout-engine/measure/featureFlags.js +19 -0
- package/dist/layout-engine/measure/floatingZones.d.ts +89 -0
- package/dist/layout-engine/measure/floatingZones.js +152 -0
- package/dist/layout-engine/measure/font-metrics.worker.d.ts +17 -0
- package/dist/layout-engine/measure/font-metrics.worker.js +104 -0
- package/dist/layout-engine/measure/index.d.ts +9 -0
- package/dist/layout-engine/measure/index.js +8 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +40 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +76 -0
- package/dist/layout-engine/measure/measureBlocks.d.ts +25 -0
- package/dist/layout-engine/measure/measureBlocks.js +450 -0
- package/dist/layout-engine/measure/measureContainer.d.ts +24 -0
- package/dist/layout-engine/measure/measureContainer.js +280 -0
- package/dist/layout-engine/measure/measureHelpers.d.ts +82 -0
- package/dist/layout-engine/measure/measureHelpers.js +156 -0
- package/dist/layout-engine/measure/measureParagraph.d.ts +61 -0
- package/dist/layout-engine/measure/measureParagraph.js +724 -0
- package/dist/layout-engine/measure/measureProvider.d.ts +23 -0
- package/dist/layout-engine/measure/measureProvider.js +35 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +61 -0
- package/dist/layout-engine/measure/measureTypes.js +0 -0
- package/dist/layout-engine/measure/measureWorker.d.ts +54 -0
- package/dist/layout-engine/measure/measureWorker.js +249 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +88 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.js +20 -0
- package/dist/layout-engine/measure/tableCellFloating.d.ts +26 -0
- package/dist/layout-engine/measure/tableCellFloating.js +99 -0
- package/dist/layout-engine/paginator.d.ts +84 -0
- package/dist/layout-engine/paginator.js +348 -0
- package/dist/layout-engine/paragraphFragmentRange.d.ts +9 -0
- package/dist/layout-engine/paragraphFragmentRange.js +40 -0
- package/dist/layout-engine/section-breaks.d.ts +78 -0
- package/dist/layout-engine/section-breaks.js +182 -0
- package/dist/layout-engine/tableRowBreak.d.ts +23 -0
- package/dist/layout-engine/tableRowBreak.js +147 -0
- package/dist/layout-engine/textBoxFlow.d.ts +50 -0
- package/dist/layout-engine/textBoxFlow.js +160 -0
- package/dist/layout-engine/types.d.ts +1031 -0
- package/dist/layout-engine/types.js +100 -0
- package/dist/layout-painter/documentColors.d.ts +4 -0
- package/dist/layout-painter/documentColors.js +40 -0
- package/dist/layout-painter/index.d.ts +110 -0
- package/dist/layout-painter/index.js +182 -0
- package/dist/layout-painter/registry/modules/image.d.ts +6 -0
- package/dist/layout-painter/registry/modules/image.js +17 -0
- package/dist/layout-painter/registry/modules/paragraph.d.ts +6 -0
- package/dist/layout-painter/registry/modules/paragraph.js +18 -0
- package/dist/layout-painter/registry/modules/table.d.ts +6 -0
- package/dist/layout-painter/registry/modules/table.js +16 -0
- package/dist/layout-painter/registry/modules/textBox.d.ts +6 -0
- package/dist/layout-painter/registry/modules/textBox.js +13 -0
- package/dist/layout-painter/registry/modules.d.ts +6 -0
- package/dist/layout-painter/registry/modules.js +26 -0
- package/dist/layout-painter/registry/registry.d.ts +24 -0
- package/dist/layout-painter/registry/registry.js +53 -0
- package/dist/layout-painter/registry/types.d.ts +61 -0
- package/dist/layout-painter/registry/types.js +0 -0
- package/dist/layout-painter/renderFragment.d.ts +32 -0
- package/dist/layout-painter/renderFragment.js +114 -0
- package/dist/layout-painter/renderImage.d.ts +88 -0
- package/dist/layout-painter/renderImage.js +130 -0
- package/dist/layout-painter/renderPage.d.ts +264 -0
- package/dist/layout-painter/renderPage.js +1795 -0
- package/dist/layout-painter/renderParagraph.d.ts +93 -0
- package/dist/layout-painter/renderParagraph.js +1300 -0
- package/dist/layout-painter/renderTable.d.ts +36 -0
- package/dist/layout-painter/renderTable.js +432 -0
- package/dist/layout-painter/renderTextBox.d.ts +22 -0
- package/dist/layout-painter/renderTextBox.js +67 -0
- package/dist/layout-painter/renderUtils.d.ts +42 -0
- package/dist/layout-painter/renderUtils.js +30 -0
- package/dist/layout-painter/renderWatermark.d.ts +16 -0
- package/dist/layout-painter/renderWatermark.js +61 -0
- package/dist/layout-painter/sdtBoundary.d.ts +6 -0
- package/dist/layout-painter/sdtBoundary.js +28 -0
- package/dist/managers/ContextMenuManager.d.ts +28 -0
- package/dist/managers/ContextMenuManager.js +48 -0
- package/dist/managers/DocumentLoaderManager.d.ts +47 -0
- package/dist/managers/DocumentLoaderManager.js +69 -0
- package/dist/managers/EditorModeManager.d.ts +28 -0
- package/dist/managers/EditorModeManager.js +50 -0
- package/dist/managers/ErrorManager.d.ts +26 -0
- package/dist/managers/ErrorManager.js +85 -0
- package/dist/managers/FindReplaceManager.d.ts +54 -0
- package/dist/managers/FindReplaceManager.js +104 -0
- package/dist/managers/HistoryManager.d.ts +92 -0
- package/dist/managers/HistoryManager.js +193 -0
- package/dist/managers/Subscribable.d.ts +34 -0
- package/dist/managers/Subscribable.js +46 -0
- package/dist/managers/TableSelectionManager.d.ts +74 -0
- package/dist/managers/TableSelectionManager.js +225 -0
- package/dist/managers/editorShortcuts.d.ts +42 -0
- package/dist/managers/editorShortcuts.js +60 -0
- package/dist/managers/types.d.ts +41 -0
- package/dist/managers/types.js +0 -0
- package/dist/markdown/annotations.d.ts +14 -0
- package/dist/markdown/annotations.js +42 -0
- package/dist/markdown/escape.d.ts +36 -0
- package/dist/markdown/escape.js +59 -0
- package/dist/markdown/fromMarkdown.d.ts +11 -0
- package/dist/markdown/fromMarkdown.js +223 -0
- package/dist/markdown/headings.d.ts +13 -0
- package/dist/markdown/headings.js +20 -0
- package/dist/markdown/images.d.ts +13 -0
- package/dist/markdown/images.js +63 -0
- package/dist/markdown/index.d.ts +18 -0
- package/dist/markdown/index.js +33 -0
- package/dist/markdown/internals.d.ts +15 -0
- package/dist/markdown/internals.js +35 -0
- package/dist/markdown/renderBlock.d.ts +7 -0
- package/dist/markdown/renderBlock.js +68 -0
- package/dist/markdown/renderParagraph.d.ts +11 -0
- package/dist/markdown/renderParagraph.js +64 -0
- package/dist/markdown/renderRuns.d.ts +11 -0
- package/dist/markdown/renderRuns.js +265 -0
- package/dist/markdown/renderTable.d.ts +8 -0
- package/dist/markdown/renderTable.js +229 -0
- package/dist/markdown/trailers.d.ts +13 -0
- package/dist/markdown/trailers.js +54 -0
- package/dist/markdown/types.d.ts +118 -0
- package/dist/markdown/types.js +0 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +4 -0
- package/dist/paged-layout/LayoutSelectionGate.d.ts +80 -0
- package/dist/paged-layout/LayoutSelectionGate.js +131 -0
- package/dist/paged-layout/headerFooterMargins.d.ts +73 -0
- package/dist/paged-layout/headerFooterMargins.js +120 -0
- package/dist/paged-layout/hiddenEditorScroll.d.ts +4 -0
- package/dist/paged-layout/hiddenEditorScroll.js +4 -0
- package/dist/paged-layout/incrementalMeasure.d.ts +33 -0
- package/dist/paged-layout/incrementalMeasure.js +56 -0
- package/dist/paged-layout/rangeProjection.d.ts +51 -0
- package/dist/paged-layout/rangeProjection.js +153 -0
- package/dist/paged-layout/readOnlyEditAttempt.d.ts +5 -0
- package/dist/paged-layout/readOnlyEditAttempt.js +22 -0
- package/dist/paged-layout/scrollNavigation.d.ts +23 -0
- package/dist/paged-layout/scrollNavigation.js +31 -0
- package/dist/paged-layout/scrollPageInfo.d.ts +41 -0
- package/dist/paged-layout/scrollPageInfo.js +34 -0
- package/dist/paged-layout/scrollToPmPosition.d.ts +17 -0
- package/dist/paged-layout/scrollToPmPosition.js +95 -0
- package/dist/paged-layout/sectionBlockWidths.d.ts +35 -0
- package/dist/paged-layout/sectionBlockWidths.js +52 -0
- package/dist/paged-layout/sectionGeometry.d.ts +21 -0
- package/dist/paged-layout/sectionGeometry.js +36 -0
- package/dist/paged-layout/selectionViewportRect.d.ts +29 -0
- package/dist/paged-layout/selectionViewportRect.js +55 -0
- package/dist/paged-layout/tableColumnResize.d.ts +19 -0
- package/dist/paged-layout/tableColumnResize.js +28 -0
- package/dist/paged-layout/tableInsertButtonGeometry.d.ts +15 -0
- package/dist/paged-layout/tableInsertButtonGeometry.js +15 -0
- package/dist/paged-layout/transactionDirtyRange.d.ts +7 -0
- package/dist/paged-layout/transactionDirtyRange.js +27 -0
- package/dist/paged-layout/zoomScrollAnchor.d.ts +40 -0
- package/dist/paged-layout/zoomScrollAnchor.js +25 -0
- package/dist/prosemirror/attrs/index.d.ts +80 -0
- package/dist/prosemirror/attrs/index.js +1218 -0
- package/dist/prosemirror/autospacingBase.d.ts +11 -0
- package/dist/prosemirror/autospacingBase.js +16 -0
- package/dist/prosemirror/commands/comments.d.ts +93 -0
- package/dist/prosemirror/commands/comments.js +435 -0
- package/dist/prosemirror/commands/contentControls.d.ts +45 -0
- package/dist/prosemirror/commands/contentControls.js +294 -0
- package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +15 -0
- package/dist/prosemirror/commands/contentControlsBlockFill.js +19 -0
- package/dist/prosemirror/commands/formatPainter.d.ts +31 -0
- package/dist/prosemirror/commands/formatPainter.js +130 -0
- package/dist/prosemirror/commands/formatting.d.ts +32 -0
- package/dist/prosemirror/commands/formatting.js +45 -0
- package/dist/prosemirror/commands/hyperlink.d.ts +31 -0
- package/dist/prosemirror/commands/hyperlink.js +79 -0
- package/dist/prosemirror/commands/image.d.ts +59 -0
- package/dist/prosemirror/commands/image.js +219 -0
- package/dist/prosemirror/commands/index.d.ts +13 -0
- package/dist/prosemirror/commands/index.js +13 -0
- package/dist/prosemirror/commands/pageBreak.d.ts +10 -0
- package/dist/prosemirror/commands/pageBreak.js +47 -0
- package/dist/prosemirror/commands/paragraph.d.ts +39 -0
- package/dist/prosemirror/commands/paragraph.js +64 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +39 -0
- package/dist/prosemirror/commands/pastePlainText.js +67 -0
- package/dist/prosemirror/commands/table.d.ts +83 -0
- package/dist/prosemirror/commands/table.js +105 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +27 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +1550 -0
- package/dist/prosemirror/conversion/index.d.ts +4 -0
- package/dist/prosemirror/conversion/index.js +4 -0
- package/dist/prosemirror/conversion/runShadingMark.d.ts +16 -0
- package/dist/prosemirror/conversion/runShadingMark.js +39 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +39 -0
- package/dist/prosemirror/conversion/toProseDoc.js +1404 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +43 -0
- package/dist/prosemirror/extensions/ExtensionManager.js +86 -0
- package/dist/prosemirror/extensions/StarterKit.d.ts +16 -0
- package/dist/prosemirror/extensions/StarterKit.js +132 -0
- package/dist/prosemirror/extensions/core/DocExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +12 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.js +28 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +25 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +619 -0
- package/dist/prosemirror/extensions/core/TextExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/core/TextExtension.js +12 -0
- package/dist/prosemirror/extensions/create.d.ts +17 -0
- package/dist/prosemirror/extensions/create.js +129 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +106 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +172 -0
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +38 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.js +21 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.js +20 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +44 -0
- package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +19 -0
- package/dist/prosemirror/extensions/features/GapCursorExtension.js +24 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +15 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +66 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +91 -0
- package/dist/prosemirror/extensions/features/ListExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +340 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +60 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +35 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +188 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +34 -0
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.js +145 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.js +17 -0
- package/dist/prosemirror/extensions/features/bidiShortcutController.d.ts +31 -0
- package/dist/prosemirror/extensions/features/bidiShortcutController.js +27 -0
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +31 -0
- package/dist/prosemirror/extensions/features/pasteCleanup.js +159 -0
- package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/AllCapsExtension.js +24 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.js +41 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +64 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +47 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.js +38 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +55 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.js +47 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +92 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.js +35 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +115 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +146 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.js +34 -0
- package/dist/prosemirror/extensions/marks/RtlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/RtlExtension.js +21 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +75 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +38 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.js +24 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +33 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +25 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +25 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +50 -0
- package/dist/prosemirror/extensions/marks/TextEffectExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/TextEffectExtension.js +35 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +31 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +22 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +113 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +60 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +34 -0
- package/dist/prosemirror/extensions/marks/markUtils.js +233 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +22 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +122 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +87 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +38 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.js +18 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +132 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.js +56 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +20 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +107 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +30 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +502 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.js +27 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +34 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +1972 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +34 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +150 -0
- package/dist/prosemirror/extensions/types.d.ts +101 -0
- package/dist/prosemirror/extensions/types.js +10 -0
- package/dist/prosemirror/findReplaceSelection.d.ts +23 -0
- package/dist/prosemirror/findReplaceSelection.js +86 -0
- package/dist/prosemirror/index.d.ts +25 -0
- package/dist/prosemirror/index.js +23 -0
- package/dist/prosemirror/insertOperations.d.ts +12 -0
- package/dist/prosemirror/insertOperations.js +19 -0
- package/dist/prosemirror/paragraphDirection.d.ts +42 -0
- package/dist/prosemirror/paragraphDirection.js +33 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +40 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.js +90 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +42 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +135 -0
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +60 -0
- package/dist/prosemirror/plugins/anonymizationDecorations.js +120 -0
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +123 -0
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +283 -0
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +56 -0
- package/dist/prosemirror/plugins/contentControlWidgets.js +192 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +37 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.js +55 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +18 -0
- package/dist/prosemirror/plugins/documentStyles.js +46 -0
- package/dist/prosemirror/plugins/index.d.ts +3 -0
- package/dist/prosemirror/plugins/index.js +3 -0
- package/dist/prosemirror/plugins/pmTextScan.d.ts +19 -0
- package/dist/prosemirror/plugins/pmTextScan.js +39 -0
- package/dist/prosemirror/plugins/selectionTracker.d.ts +43 -0
- package/dist/prosemirror/plugins/selectionTracker.js +179 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +70 -0
- package/dist/prosemirror/plugins/suggestionMode.js +489 -0
- package/dist/prosemirror/plugins/templateDirectives.d.ts +25 -0
- package/dist/prosemirror/plugins/templateDirectives.js +67 -0
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +49 -0
- package/dist/prosemirror/plugins/templatePreviewValues.js +117 -0
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +57 -0
- package/dist/prosemirror/plugins/templateSlashMenu.js +184 -0
- package/dist/prosemirror/schema/index.d.ts +15 -0
- package/dist/prosemirror/schema/index.js +20 -0
- package/dist/prosemirror/schema/marks.d.ts +118 -0
- package/dist/prosemirror/schema/marks.js +0 -0
- package/dist/prosemirror/schema/nodes.d.ts +389 -0
- package/dist/prosemirror/schema/nodes.js +0 -0
- package/dist/prosemirror/selectionState.d.ts +23 -0
- package/dist/prosemirror/selectionState.js +111 -0
- package/dist/prosemirror/styles/index.d.ts +2 -0
- package/dist/prosemirror/styles/index.js +2 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +32 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +108 -0
- package/dist/prosemirror/styles/styleResolver.d.ts +94 -0
- package/dist/prosemirror/styles/styleResolver.js +200 -0
- package/dist/prosemirror/utils/findParagraphByParaId.d.ts +26 -0
- package/dist/prosemirror/utils/findParagraphByParaId.js +37 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +110 -0
- package/dist/prosemirror/utils/tabCalculator.js +137 -0
- package/dist/prosemirror/validation.d.ts +20 -0
- package/dist/prosemirror/validation.js +177 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +6 -0
- package/dist/style-engine/index.d.ts +3 -0
- package/dist/style-engine/index.js +2 -0
- package/dist/style-engine/styleEngine.d.ts +67 -0
- package/dist/style-engine/styleEngine.js +70 -0
- package/dist/types/block-id.d.ts +58 -0
- package/dist/types/block-id.js +61 -0
- package/dist/types/colors.d.ts +2 -0
- package/dist/types/colors.js +0 -0
- package/dist/types/content.d.ts +2 -0
- package/dist/types/content.js +0 -0
- package/dist/types/document.d.ts +7 -0
- package/dist/types/document.js +0 -0
- package/dist/types/documentEnumValues.d.ts +89 -0
- package/dist/types/documentEnumValues.js +693 -0
- package/dist/types/formatting.d.ts +2 -0
- package/dist/types/formatting.js +0 -0
- package/dist/types/index.d.ts +107 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/authorColors.d.ts +16 -0
- package/dist/utils/authorColors.js +30 -0
- package/dist/utils/baseDirection.d.ts +23 -0
- package/dist/utils/baseDirection.js +34 -0
- package/dist/utils/clipboard.d.ts +126 -0
- package/dist/utils/clipboard.js +622 -0
- package/dist/utils/colorResolver.d.ts +158 -0
- package/dist/utils/colorResolver.js +557 -0
- package/dist/utils/createDocument.d.ts +50 -0
- package/dist/utils/createDocument.js +262 -0
- package/dist/utils/documentLoaderBehavior.d.ts +22 -0
- package/dist/utils/documentLoaderBehavior.js +14 -0
- package/dist/utils/docxInput.d.ts +22 -0
- package/dist/utils/docxInput.js +16 -0
- package/dist/utils/domGuards.d.ts +59 -0
- package/dist/utils/domGuards.js +82 -0
- package/dist/utils/fontFamilyMerge.d.ts +7 -0
- package/dist/utils/fontFamilyMerge.js +31 -0
- package/dist/utils/fontLoader.d.ts +50 -0
- package/dist/utils/fontLoader.js +177 -0
- package/dist/utils/fontResolver.d.ts +61 -0
- package/dist/utils/fontResolver.js +651 -0
- package/dist/utils/fontWeights.d.ts +4 -0
- package/dist/utils/fontWeights.js +4 -0
- package/dist/utils/formatToStyle.d.ts +103 -0
- package/dist/utils/formatToStyle.js +289 -0
- package/dist/utils/headerFooter.d.ts +74 -0
- package/dist/utils/headerFooter.js +257 -0
- package/dist/utils/headingCollector.d.ts +22 -0
- package/dist/utils/headingCollector.js +36 -0
- package/dist/utils/hexId.d.ts +33 -0
- package/dist/utils/hexId.js +37 -0
- package/dist/utils/imageValidation.d.ts +5 -0
- package/dist/utils/imageValidation.js +31 -0
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -0
- package/dist/utils/paragraphFormattingMerge.js +68 -0
- package/dist/utils/replaceText.d.ts +17 -0
- package/dist/utils/replaceText.js +161 -0
- package/dist/utils/rotationBoundingBox.d.ts +12 -0
- package/dist/utils/rotationBoundingBox.js +36 -0
- package/dist/utils/scriptSegments.d.ts +36 -0
- package/dist/utils/scriptSegments.js +52 -0
- package/dist/utils/tableOperations.d.ts +87 -0
- package/dist/utils/tableOperations.js +259 -0
- package/dist/utils/textFormattingMerge.d.ts +6 -0
- package/dist/utils/textFormattingMerge.js +31 -0
- package/dist/utils/tiffConverter.d.ts +18 -0
- package/dist/utils/tiffConverter.js +83 -0
- package/dist/utils/units.d.ts +99 -0
- package/dist/utils/units.js +139 -0
- package/dist/utils/urlSecurity.d.ts +7 -0
- package/dist/utils/urlSecurity.js +65 -0
- package/dist/watermark/index.d.ts +39 -0
- package/dist/watermark/index.js +149 -0
- package/package.json +122 -2
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
import { measuredLineAdvance } from "./lineFlow.js";
|
|
2
|
+
import { DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, floatingTextBoxReservesBand, floatingTextBoxWrapsText, isFloatingImageRun, isFloatingTextBoxBlock, isTextWrappingFloatingImageRun } from "./types.js";
|
|
3
|
+
import { calculateChainHeight, computeKeepNextChains, getMidChainIndices, hasKeepLines, hasPageBreakBefore } from "./keep-together.js";
|
|
4
|
+
import { createPaginator } from "./paginator.js";
|
|
5
|
+
import { getParagraphFragmentPmRange } from "./paragraphFragmentRange.js";
|
|
6
|
+
import { buildTableRowBreakInfo, snapRowBreak } from "./tableRowBreak.js";
|
|
7
|
+
import { bandFragmentX, bandTopContentY, isPageFrameRelativeAnchor } from "./textBoxFlow.js";
|
|
8
|
+
import { applyPendingToActive, createInitialSectionState, getEffectiveColumns, getEffectiveMargins, getEffectivePageSize, scheduleSectionBreak } from "./section-breaks.js";
|
|
9
|
+
import { panic } from "better-result";
|
|
10
|
+
//#region src/layout-engine/index.ts
|
|
11
|
+
/**
|
|
12
|
+
* Layout Engine - Main Entry Point
|
|
13
|
+
*
|
|
14
|
+
* Converts blocks + measures into positioned fragments on pages.
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_COLUMNS = {
|
|
17
|
+
count: 1,
|
|
18
|
+
gap: 0
|
|
19
|
+
};
|
|
20
|
+
function collectSectionConfigs(blocks, initialConfig, finalConfig) {
|
|
21
|
+
const configs = [];
|
|
22
|
+
const breakIndices = [];
|
|
23
|
+
let previousConfig = initialConfig;
|
|
24
|
+
for (let index = 0; index < blocks.length; index += 1) {
|
|
25
|
+
const block = blocks[index];
|
|
26
|
+
if (block?.kind !== "sectionBreak") continue;
|
|
27
|
+
const sectionBreak = block;
|
|
28
|
+
const config = {
|
|
29
|
+
pageSize: sectionBreak.pageSize ?? previousConfig.pageSize,
|
|
30
|
+
margins: sectionBreak.margins ?? previousConfig.margins
|
|
31
|
+
};
|
|
32
|
+
if (sectionBreak.columns !== void 0) config.columns = sectionBreak.columns;
|
|
33
|
+
configs.push(config);
|
|
34
|
+
breakIndices.push(index);
|
|
35
|
+
previousConfig = configs.at(-1) ?? previousConfig;
|
|
36
|
+
}
|
|
37
|
+
configs.push(finalConfig);
|
|
38
|
+
return {
|
|
39
|
+
configs,
|
|
40
|
+
breakIndices
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether a paragraph block has no visible content (no runs, or a single
|
|
45
|
+
* empty text run). Word collapses style-inherited spacing on empty
|
|
46
|
+
* paragraphs (only direct `<w:pPr><w:spacing>` formatting survives) — see
|
|
47
|
+
* eigenpal #402.
|
|
48
|
+
*/
|
|
49
|
+
function isEmptyParagraph(block) {
|
|
50
|
+
if (block.runs.length === 0) return true;
|
|
51
|
+
if (block.runs.length !== 1) return false;
|
|
52
|
+
const r = block.runs[0];
|
|
53
|
+
return r?.kind === "text" && (r.text ?? "") === "";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get spacing before a paragraph block. Empty paragraphs whose
|
|
57
|
+
* `before` was inherited from a paragraph style (not set inline) collapse
|
|
58
|
+
* to zero — Word fidelity for incidental empty separators.
|
|
59
|
+
*/
|
|
60
|
+
function getSpacingBefore(block) {
|
|
61
|
+
const value = block.attrs?.spacing?.before ?? 0;
|
|
62
|
+
if (isEmptyParagraph(block) && !block.attrs?.spacingExplicit?.before) return 0;
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get spacing after a paragraph block. Same empty-paragraph collapse rule
|
|
67
|
+
* as `getSpacingBefore`.
|
|
68
|
+
*/
|
|
69
|
+
function getSpacingAfter(block) {
|
|
70
|
+
const value = block.attrs?.spacing?.after ?? 0;
|
|
71
|
+
if (isEmptyParagraph(block) && !block.attrs?.spacingExplicit?.after) return 0;
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Apply contextual spacing suppression (OOXML §17.3.1.9).
|
|
76
|
+
*
|
|
77
|
+
* When two consecutive paragraph blocks both have `contextualSpacing: true`
|
|
78
|
+
* and share the same `styleId`, the spaceAfter of the first paragraph and
|
|
79
|
+
* the spaceBefore of the second paragraph are suppressed (set to 0).
|
|
80
|
+
*
|
|
81
|
+
* This mutates the block attrs in-place before layout runs.
|
|
82
|
+
*/
|
|
83
|
+
function applyContextualSpacing(blocks) {
|
|
84
|
+
for (let i = 0; i < blocks.length - 1; i++) {
|
|
85
|
+
const curr = blocks[i];
|
|
86
|
+
const next = blocks[i + 1];
|
|
87
|
+
if (curr.kind !== "paragraph" || next.kind !== "paragraph") continue;
|
|
88
|
+
const currAttrs = curr.attrs;
|
|
89
|
+
const nextAttrs = next.attrs;
|
|
90
|
+
if (currAttrs?.contextualSpacing && nextAttrs?.contextualSpacing && currAttrs.styleId && currAttrs.styleId === nextAttrs.styleId) {
|
|
91
|
+
if (currAttrs.spacing) currAttrs.spacing = {
|
|
92
|
+
...currAttrs.spacing,
|
|
93
|
+
after: 0
|
|
94
|
+
};
|
|
95
|
+
if (nextAttrs.spacing) nextAttrs.spacing = {
|
|
96
|
+
...nextAttrs.spacing,
|
|
97
|
+
before: 0
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const block of blocks) if (block.kind === "table") for (const row of block.rows) for (const cell of row.cells) applyContextualSpacing(cell.blocks);
|
|
102
|
+
else if (block.kind === "textBox") applyContextualSpacing(block.content);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Layout a document: convert blocks + measures into pages with positioned fragments.
|
|
106
|
+
*
|
|
107
|
+
* Algorithm:
|
|
108
|
+
* 1. Walk blocks in order with their corresponding measures
|
|
109
|
+
* 2. For each block, create appropriate fragment(s)
|
|
110
|
+
* 3. Use paginator to manage page/column state
|
|
111
|
+
* 4. Handle page breaks, section breaks, and keepNext chains
|
|
112
|
+
*/
|
|
113
|
+
function layoutDocument(blocks, measures, options) {
|
|
114
|
+
if (blocks.length !== measures.length) panic(`layoutDocument: expected one measure per block (blocks=${blocks.length}, measures=${measures.length})`);
|
|
115
|
+
const pageSize = options.pageSize;
|
|
116
|
+
const baseMargins = {
|
|
117
|
+
top: options.margins.top,
|
|
118
|
+
right: options.margins.right,
|
|
119
|
+
bottom: options.margins.bottom,
|
|
120
|
+
left: options.margins.left
|
|
121
|
+
};
|
|
122
|
+
if (options.margins.header !== void 0) baseMargins.header = options.margins.header;
|
|
123
|
+
if (options.margins.footer !== void 0) baseMargins.footer = options.margins.footer;
|
|
124
|
+
const margins = { ...baseMargins };
|
|
125
|
+
const finalPageSize = options.finalPageSize ?? pageSize;
|
|
126
|
+
const finalMargins = options.finalMargins ?? margins;
|
|
127
|
+
if (pageSize.w - margins.left - margins.right <= 0) panic("layoutDocument: page size and margins yield no content area");
|
|
128
|
+
const bodyConfig = {
|
|
129
|
+
pageSize,
|
|
130
|
+
margins
|
|
131
|
+
};
|
|
132
|
+
if (options.columns !== void 0) bodyConfig.columns = options.columns;
|
|
133
|
+
const finalConfig = {
|
|
134
|
+
pageSize: finalPageSize,
|
|
135
|
+
margins: finalMargins
|
|
136
|
+
};
|
|
137
|
+
if (options.columns !== void 0) finalConfig.columns = options.columns;
|
|
138
|
+
const { configs: sectionConfigs, breakIndices } = collectSectionConfigs(blocks, bodyConfig, finalConfig);
|
|
139
|
+
const sectionBreakTypes = [...breakIndices.map((index) => blocks[index].type), options.bodyBreakType];
|
|
140
|
+
const initialConfig = sectionConfigs.at(0) ?? bodyConfig;
|
|
141
|
+
const paginator = createPaginator({
|
|
142
|
+
pageSize: initialConfig.pageSize,
|
|
143
|
+
margins: initialConfig.margins,
|
|
144
|
+
...options.firstPageMargins !== void 0 ? { firstPageMargins: options.firstPageMargins } : {},
|
|
145
|
+
columns: initialConfig.columns ?? DEFAULT_COLUMNS,
|
|
146
|
+
...options.footnoteReservedHeights !== void 0 ? { footnoteReservedHeights: options.footnoteReservedHeights } : {},
|
|
147
|
+
...options.sectionHeaderFooterRefs !== void 0 ? { sectionHeaderFooterRefs: options.sectionHeaderFooterRefs } : {}
|
|
148
|
+
});
|
|
149
|
+
applyContextualSpacing(blocks);
|
|
150
|
+
const keepNextChains = computeKeepNextChains(blocks);
|
|
151
|
+
const midChainIndices = getMidChainIndices(keepNextChains);
|
|
152
|
+
let sectionIdx = 0;
|
|
153
|
+
let activeSectionMarginTop = initialConfig.margins.top;
|
|
154
|
+
let activeSectionPageHeight = initialConfig.pageSize.h;
|
|
155
|
+
let activeSectionMarginBottom = initialConfig.margins.bottom;
|
|
156
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
157
|
+
const block = blocks[i];
|
|
158
|
+
const measure = measures[i];
|
|
159
|
+
if (hasPageBreakBefore(block)) paginator.forcePageBreak();
|
|
160
|
+
const chain = keepNextChains.get(i);
|
|
161
|
+
if (chain && !midChainIndices.has(i)) {
|
|
162
|
+
const chainHeight = calculateChainHeight(chain, blocks, measures);
|
|
163
|
+
const state = paginator.getCurrentState();
|
|
164
|
+
const availableHeight = paginator.getAvailableHeight();
|
|
165
|
+
if (chainHeight <= state.contentBottom - state.topMargin && chainHeight > availableHeight && state.page.fragments.length > 0) paginator.forcePageBreak();
|
|
166
|
+
}
|
|
167
|
+
switch (block.kind) {
|
|
168
|
+
case "paragraph":
|
|
169
|
+
layoutParagraph(block, measure, paginator, paginator.getContentWidth(), options.footnoteHeightById);
|
|
170
|
+
break;
|
|
171
|
+
case "table":
|
|
172
|
+
if (block.floating) layoutFloatingTable(block, measure, paginator, paginator.getContentWidth());
|
|
173
|
+
else layoutTable(block, measure, paginator);
|
|
174
|
+
break;
|
|
175
|
+
case "image":
|
|
176
|
+
layoutImage(block, measure, paginator);
|
|
177
|
+
break;
|
|
178
|
+
case "textBox":
|
|
179
|
+
layoutTextBox(block, measure, {
|
|
180
|
+
paginator,
|
|
181
|
+
sectionMarginTop: activeSectionMarginTop,
|
|
182
|
+
sectionPageHeight: activeSectionPageHeight,
|
|
183
|
+
sectionMarginBottom: activeSectionMarginBottom
|
|
184
|
+
});
|
|
185
|
+
break;
|
|
186
|
+
case "pageBreak":
|
|
187
|
+
paginator.forcePageBreak();
|
|
188
|
+
break;
|
|
189
|
+
case "columnBreak":
|
|
190
|
+
paginator.forceColumnBreak();
|
|
191
|
+
break;
|
|
192
|
+
case "sectionBreak": {
|
|
193
|
+
const nextSectionConfig = sectionConfigs[sectionIdx + 1] ?? initialConfig;
|
|
194
|
+
handleSectionBreak(block, paginator, nextSectionConfig, sectionBreakTypes[sectionIdx + 1] ?? sectionBreakTypes[sectionIdx], sectionIdx + 1);
|
|
195
|
+
activeSectionMarginTop = nextSectionConfig.margins.top;
|
|
196
|
+
activeSectionPageHeight = nextSectionConfig.pageSize.h;
|
|
197
|
+
activeSectionMarginBottom = nextSectionConfig.margins.bottom;
|
|
198
|
+
sectionIdx++;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
default: break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (paginator.pages.length === 0) paginator.getCurrentState();
|
|
205
|
+
return {
|
|
206
|
+
pageSize,
|
|
207
|
+
pages: paginator.pages,
|
|
208
|
+
...options.columns !== void 0 ? { columns: options.columns } : {},
|
|
209
|
+
...options.pageGap !== void 0 ? { pageGap: options.pageGap } : {}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Footnote refs whose run sits in line `[fromRun..toRun]`, with their
|
|
214
|
+
* pre-measured content heights. Empty when the engine isn't tracking
|
|
215
|
+
* dynamic fn demand. Used by `layoutParagraph` to (a) reserve fn
|
|
216
|
+
* height per line and (b) record the IDs on the host page so the
|
|
217
|
+
* painter renders the fn on the page where the ref-bearing line
|
|
218
|
+
* actually landed — even when the paragraph splits across pages
|
|
219
|
+
* (fragment pmStart/pmEnd is paragraph-wide and cannot disambiguate
|
|
220
|
+
* between split halves).
|
|
221
|
+
*/
|
|
222
|
+
function getLineFootnoteRefs(block, fromRun, toRun, fnHeights) {
|
|
223
|
+
if (!fnHeights) return {
|
|
224
|
+
ids: [],
|
|
225
|
+
height: 0
|
|
226
|
+
};
|
|
227
|
+
const ids = [];
|
|
228
|
+
let height = 0;
|
|
229
|
+
for (let r = fromRun; r <= toRun; r++) {
|
|
230
|
+
const run = block.runs[r];
|
|
231
|
+
if (!run || run.kind !== "text") continue;
|
|
232
|
+
const id = run.footnoteRefId;
|
|
233
|
+
if (id === void 0) continue;
|
|
234
|
+
const h = fnHeights.get(id);
|
|
235
|
+
if (h !== void 0) {
|
|
236
|
+
ids.push(id);
|
|
237
|
+
height += h;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
ids,
|
|
242
|
+
height
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Layout a paragraph block onto pages.
|
|
247
|
+
*
|
|
248
|
+
* When `footnoteHeightById` is provided, each line carrying a footnote
|
|
249
|
+
* ref additionally reserves space on its host page for the fn's
|
|
250
|
+
* content. Pagination decisions look at the line's effective height
|
|
251
|
+
* (`lineHeight + lineFnHeight`) so a line cannot land on a page that
|
|
252
|
+
* lacks room for both — preventing footnote overflow without the
|
|
253
|
+
* static-reservation iteration loop.
|
|
254
|
+
*/
|
|
255
|
+
function layoutParagraph(block, measure, paginator, contentWidth, footnoteHeightById) {
|
|
256
|
+
const lines = measure.lines;
|
|
257
|
+
if (lines.length === 0) {
|
|
258
|
+
const spaceBefore = getSpacingBefore(block);
|
|
259
|
+
const spaceAfter = getSpacingAfter(block);
|
|
260
|
+
const state = paginator.getCurrentState();
|
|
261
|
+
const fragment = {
|
|
262
|
+
kind: "paragraph",
|
|
263
|
+
blockId: block.id,
|
|
264
|
+
x: paginator.getColumnX(state.columnIndex),
|
|
265
|
+
y: state.cursorY + spaceBefore,
|
|
266
|
+
width: contentWidth,
|
|
267
|
+
height: 0,
|
|
268
|
+
fromLine: 0,
|
|
269
|
+
toLine: 0,
|
|
270
|
+
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
271
|
+
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {},
|
|
272
|
+
...block.sdtGroups ? { sdtGroups: block.sdtGroups } : {}
|
|
273
|
+
};
|
|
274
|
+
paginator.addFragment(fragment, 0, spaceBefore, spaceAfter);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const spaceBefore = getSpacingBefore(block);
|
|
278
|
+
const spaceAfter = getSpacingAfter(block);
|
|
279
|
+
let currentLineIndex = 0;
|
|
280
|
+
while (currentLineIndex < lines.length) {
|
|
281
|
+
const state = paginator.getCurrentState();
|
|
282
|
+
const availableHeight = paginator.getAvailableHeight();
|
|
283
|
+
if (currentLineIndex === 0 && state.trailingSpacing > 0 && state.cursorY !== state.topMargin) {
|
|
284
|
+
const firstLine = lines[0];
|
|
285
|
+
const firstLineRefs = getLineFootnoteRefs(block, firstLine.fromRun, firstLine.toRun, footnoteHeightById);
|
|
286
|
+
const firstLineHeight = measuredLineAdvance(firstLine) + firstLineRefs.height;
|
|
287
|
+
const collapsedLead = Math.max(spaceBefore, state.trailingSpacing);
|
|
288
|
+
const columnCapacity = state.contentBottom - state.topMargin;
|
|
289
|
+
if (collapsedLead + firstLineHeight > availableHeight && spaceBefore + firstLineHeight <= columnCapacity) {
|
|
290
|
+
paginator.ensureFits(collapsedLead + firstLineHeight);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
let linesHeight = 0;
|
|
295
|
+
let linesFnHeight = 0;
|
|
296
|
+
const linesFnIds = [];
|
|
297
|
+
let fittingLines = 0;
|
|
298
|
+
const firstFragmentSpaceBefore = currentLineIndex === 0 ? Math.max(spaceBefore, state.trailingSpacing) : 0;
|
|
299
|
+
for (let j = currentLineIndex; j < lines.length; j++) {
|
|
300
|
+
const line = lines[j];
|
|
301
|
+
const lineAdvance = measuredLineAdvance(line);
|
|
302
|
+
const lineRefs = getLineFootnoteRefs(block, line.fromRun, line.toRun, footnoteHeightById);
|
|
303
|
+
const totalWithLine = linesHeight + lineAdvance;
|
|
304
|
+
if (totalWithLine + firstFragmentSpaceBefore + linesFnHeight + lineRefs.height <= availableHeight || fittingLines === 0) {
|
|
305
|
+
linesHeight = totalWithLine;
|
|
306
|
+
linesFnHeight += lineRefs.height;
|
|
307
|
+
for (const id of lineRefs.ids) linesFnIds.push(id);
|
|
308
|
+
fittingLines++;
|
|
309
|
+
} else break;
|
|
310
|
+
}
|
|
311
|
+
const isFirstFragment = currentLineIndex === 0;
|
|
312
|
+
const isLastFragment = currentLineIndex + fittingLines >= lines.length;
|
|
313
|
+
const effectiveSpaceBefore = isFirstFragment ? spaceBefore : 0;
|
|
314
|
+
const effectiveSpaceAfter = isLastFragment ? spaceAfter : 0;
|
|
315
|
+
const pmRange = getParagraphFragmentPmRange(block, measure, currentLineIndex, currentLineIndex + fittingLines);
|
|
316
|
+
const fragment = {
|
|
317
|
+
kind: "paragraph",
|
|
318
|
+
blockId: block.id,
|
|
319
|
+
x: paginator.getColumnX(state.columnIndex),
|
|
320
|
+
y: 0,
|
|
321
|
+
width: contentWidth,
|
|
322
|
+
height: linesHeight,
|
|
323
|
+
fromLine: currentLineIndex,
|
|
324
|
+
toLine: currentLineIndex + fittingLines,
|
|
325
|
+
...pmRange.pmStart !== void 0 ? { pmStart: pmRange.pmStart } : {},
|
|
326
|
+
...pmRange.pmEnd !== void 0 ? { pmEnd: pmRange.pmEnd } : {},
|
|
327
|
+
...!isFirstFragment ? { continuesFromPrev: true } : {},
|
|
328
|
+
...!isLastFragment ? { continuesOnNext: true } : {},
|
|
329
|
+
...block.sdtGroups ? { sdtGroups: block.sdtGroups } : {}
|
|
330
|
+
};
|
|
331
|
+
if (linesFnHeight > 0) {
|
|
332
|
+
paginator.ensureFits(effectiveSpaceBefore + linesHeight + linesFnHeight);
|
|
333
|
+
if (paginator.getCurrentState().footnoteHeight === 0) paginator.ensureFits(effectiveSpaceBefore + linesHeight + linesFnHeight + 12);
|
|
334
|
+
}
|
|
335
|
+
fragment.y = paginator.addFragment(fragment, linesHeight, effectiveSpaceBefore, effectiveSpaceAfter).y;
|
|
336
|
+
if (linesFnHeight > 0) paginator.addFootnoteHeight(linesFnHeight, linesFnIds);
|
|
337
|
+
currentLineIndex += fittingLines;
|
|
338
|
+
if (currentLineIndex < lines.length) paginator.ensureFits(measuredLineAdvance(lines[currentLineIndex]));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Count consecutive header rows at the start of a table.
|
|
343
|
+
* Header rows are marked with isHeader: true in the block data.
|
|
344
|
+
*/
|
|
345
|
+
function countHeaderRows(block) {
|
|
346
|
+
let count = 0;
|
|
347
|
+
for (const row of block.rows) if (row.isHeader) count++;
|
|
348
|
+
else break;
|
|
349
|
+
return count;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Calculate total height of header rows from their measures.
|
|
353
|
+
*/
|
|
354
|
+
function getHeaderRowsHeight(measure, headerRowCount) {
|
|
355
|
+
let height = 0;
|
|
356
|
+
for (let i = 0; i < headerRowCount && i < measure.rows.length; i++) height += measure.rows[i].height;
|
|
357
|
+
return height;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Layout a table block onto pages.
|
|
361
|
+
*/
|
|
362
|
+
function layoutTable(block, measure, paginator) {
|
|
363
|
+
const rows = measure.rows;
|
|
364
|
+
if (rows.length === 0) return;
|
|
365
|
+
const headerRowCount = countHeaderRows(block);
|
|
366
|
+
const headerRowsHeight = getHeaderRowsHeight(measure, headerRowCount);
|
|
367
|
+
let currentRowIndex = 0;
|
|
368
|
+
const breakInfo = buildTableRowBreakInfo(block, measure);
|
|
369
|
+
const computeTableX = (columnIndex) => {
|
|
370
|
+
let x = paginator.getColumnX(columnIndex);
|
|
371
|
+
if (block.justification === "center") x += (paginator.columnWidth - measure.totalWidth) / 2;
|
|
372
|
+
else if (block.justification === "right") x = x + paginator.columnWidth - measure.totalWidth;
|
|
373
|
+
else if (block.indent) x += block.indent;
|
|
374
|
+
return x;
|
|
375
|
+
};
|
|
376
|
+
const getCurrentRowCapacity = (state = paginator.getCurrentState()) => state.rawContentBottom - state.topMargin;
|
|
377
|
+
const getCurrentAvailableHeight = (state = paginator.getCurrentState()) => state.contentBottom - state.cursorY;
|
|
378
|
+
const hasAdjacentPriorTableRows = (rowIndex, state = paginator.getCurrentState()) => {
|
|
379
|
+
const previous = state.page.fragments.at(-1);
|
|
380
|
+
return previous?.kind === "table" && previous.blockId === block.id && previous.toRow === rowIndex && previous.y + previous.height === state.cursorY && previous.x === computeTableX(state.columnIndex);
|
|
381
|
+
};
|
|
382
|
+
const shouldRepeatHeaderRows = (rowIndex, consumed, state = paginator.getCurrentState()) => headerRowCount > 0 && rowIndex >= headerRowCount && !(consumed === 0 && hasAdjacentPriorTableRows(rowIndex, state));
|
|
383
|
+
const canSplitRow = (rowIndex, state = paginator.getCurrentState()) => {
|
|
384
|
+
const row = rows[rowIndex];
|
|
385
|
+
if (!row) return false;
|
|
386
|
+
const repeatedHeaderOverhead = shouldRepeatHeaderRows(rowIndex, 0, state) ? headerRowsHeight : 0;
|
|
387
|
+
if ((breakInfo.breakOffsets[rowIndex]?.length ?? 0) <= 1) return false;
|
|
388
|
+
const requiredHeight = row.height + repeatedHeaderOverhead;
|
|
389
|
+
if (requiredHeight > getCurrentRowCapacity(state)) return true;
|
|
390
|
+
return hasAdjacentPriorTableRows(rowIndex, state) && requiredHeight > getCurrentAvailableHeight(state) - state.trailingSpacing;
|
|
391
|
+
};
|
|
392
|
+
while (currentRowIndex < rows.length) {
|
|
393
|
+
const oversizedRow = rows[currentRowIndex];
|
|
394
|
+
if (canSplitRow(currentRowIndex)) {
|
|
395
|
+
let consumed = 0;
|
|
396
|
+
while (consumed < oversizedRow.height) {
|
|
397
|
+
const sliceState = paginator.getCurrentState();
|
|
398
|
+
const repeatHeaderRows = shouldRepeatHeaderRows(currentRowIndex, consumed, sliceState);
|
|
399
|
+
const headerOverhead = repeatHeaderRows ? headerRowsHeight : 0;
|
|
400
|
+
const sliceAvail = paginator.getAvailableHeight() - headerOverhead - (consumed === 0 ? sliceState.trailingSpacing : 0);
|
|
401
|
+
let slice = snapRowBreak(breakInfo, currentRowIndex, consumed, sliceAvail);
|
|
402
|
+
if (slice <= 0) {
|
|
403
|
+
if (!(sliceState.cursorY === sliceState.topMargin && sliceState.page.fragments.length === 0)) {
|
|
404
|
+
paginator.forceColumnBreak();
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
const from = consumed;
|
|
408
|
+
slice = (breakInfo.breakOffsets[currentRowIndex]?.find((o) => o > from) ?? oversizedRow.height) - consumed;
|
|
409
|
+
}
|
|
410
|
+
const sliceBottom = consumed + slice;
|
|
411
|
+
const reachesRowEnd = sliceBottom >= oversizedRow.height;
|
|
412
|
+
const moreAfter = !reachesRowEnd || currentRowIndex + 1 < rows.length;
|
|
413
|
+
const fragmentHeight = headerOverhead + slice;
|
|
414
|
+
const sliceFragment = {
|
|
415
|
+
kind: "table",
|
|
416
|
+
blockId: block.id,
|
|
417
|
+
x: computeTableX(sliceState.columnIndex),
|
|
418
|
+
y: 0,
|
|
419
|
+
width: measure.totalWidth,
|
|
420
|
+
height: fragmentHeight,
|
|
421
|
+
fromRow: currentRowIndex,
|
|
422
|
+
toRow: currentRowIndex + 1,
|
|
423
|
+
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
424
|
+
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {},
|
|
425
|
+
...consumed > 0 || currentRowIndex > 0 ? { continuesFromPrev: true } : {},
|
|
426
|
+
...moreAfter ? { continuesOnNext: true } : {},
|
|
427
|
+
...repeatHeaderRows ? { headerRowCount } : {},
|
|
428
|
+
...consumed > 0 ? { topClip: consumed } : {},
|
|
429
|
+
...reachesRowEnd ? {} : { bottomClip: sliceBottom },
|
|
430
|
+
...block.sdtGroups ? { sdtGroups: block.sdtGroups } : {}
|
|
431
|
+
};
|
|
432
|
+
const sliceResult = paginator.addFragment(sliceFragment, fragmentHeight, 0, 0);
|
|
433
|
+
sliceFragment.y = sliceResult.y;
|
|
434
|
+
sliceFragment.x = computeTableX(sliceResult.state.columnIndex);
|
|
435
|
+
consumed = sliceBottom;
|
|
436
|
+
if (consumed < oversizedRow.height) paginator.forceColumnBreak();
|
|
437
|
+
}
|
|
438
|
+
currentRowIndex += 1;
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const state = paginator.getCurrentState();
|
|
442
|
+
const rawAvailableHeight = paginator.getAvailableHeight();
|
|
443
|
+
const isFirstFragment = currentRowIndex === 0;
|
|
444
|
+
const bandSkip = isFirstFragment ? measure.bandSkipBefore ?? 0 : 0;
|
|
445
|
+
const availableHeight = rawAvailableHeight - (isFirstFragment ? Math.max(bandSkip, state.trailingSpacing) : 0);
|
|
446
|
+
const repeatHeaderRowsForNormalFragment = shouldRepeatHeaderRows(currentRowIndex, 0, state);
|
|
447
|
+
const normalHeaderOverhead = repeatHeaderRowsForNormalFragment ? headerRowsHeight : 0;
|
|
448
|
+
let rowsHeight = 0;
|
|
449
|
+
let fittingRows = 0;
|
|
450
|
+
for (let j = currentRowIndex; j < rows.length; j++) {
|
|
451
|
+
const rowHeight = rows[j].height;
|
|
452
|
+
if (rowsHeight + rowHeight + normalHeaderOverhead <= availableHeight || fittingRows === 0) {
|
|
453
|
+
rowsHeight += rowHeight;
|
|
454
|
+
fittingRows++;
|
|
455
|
+
} else break;
|
|
456
|
+
}
|
|
457
|
+
const fragmentHeight = rowsHeight + normalHeaderOverhead;
|
|
458
|
+
const isLastFragment = currentRowIndex + fittingRows >= rows.length;
|
|
459
|
+
const desiredX = computeTableX(state.columnIndex);
|
|
460
|
+
const fragment = {
|
|
461
|
+
kind: "table",
|
|
462
|
+
blockId: block.id,
|
|
463
|
+
x: desiredX,
|
|
464
|
+
y: 0,
|
|
465
|
+
width: measure.totalWidth,
|
|
466
|
+
height: fragmentHeight,
|
|
467
|
+
fromRow: currentRowIndex,
|
|
468
|
+
toRow: currentRowIndex + fittingRows,
|
|
469
|
+
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
470
|
+
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {},
|
|
471
|
+
...!isFirstFragment ? { continuesFromPrev: true } : {},
|
|
472
|
+
...!isLastFragment ? { continuesOnNext: true } : {},
|
|
473
|
+
...repeatHeaderRowsForNormalFragment ? { headerRowCount } : {},
|
|
474
|
+
...block.sdtGroups ? { sdtGroups: block.sdtGroups } : {}
|
|
475
|
+
};
|
|
476
|
+
fragment.y = paginator.addFragment(fragment, fragmentHeight, bandSkip, 0).y;
|
|
477
|
+
fragment.x = desiredX;
|
|
478
|
+
currentRowIndex += fittingRows;
|
|
479
|
+
if (currentRowIndex < rows.length) {
|
|
480
|
+
if (canSplitRow(currentRowIndex)) {
|
|
481
|
+
const nextState = paginator.getCurrentState();
|
|
482
|
+
const nextHeaderOverhead = shouldRepeatHeaderRows(currentRowIndex, 0, nextState) ? headerRowsHeight : 0;
|
|
483
|
+
const nextSliceAvail = paginator.getAvailableHeight() - nextHeaderOverhead - nextState.trailingSpacing;
|
|
484
|
+
if (snapRowBreak(breakInfo, currentRowIndex, 0, nextSliceAvail) > 0) continue;
|
|
485
|
+
}
|
|
486
|
+
const nextState = paginator.getCurrentState();
|
|
487
|
+
const nextRowHeight = rows[currentRowIndex].height + (shouldRepeatHeaderRows(currentRowIndex, 0, nextState) ? headerRowsHeight : 0);
|
|
488
|
+
paginator.ensureFits(nextRowHeight);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Layout a floating table (anchored) without advancing the cursor.
|
|
494
|
+
*/
|
|
495
|
+
function layoutFloatingTable(block, measure, paginator, contentWidth) {
|
|
496
|
+
const state = paginator.getCurrentState();
|
|
497
|
+
const floating = block.floating;
|
|
498
|
+
const page = state.page;
|
|
499
|
+
const margins = page.margins;
|
|
500
|
+
const tableWidth = measure.totalWidth;
|
|
501
|
+
const tableHeight = measure.totalHeight;
|
|
502
|
+
const contentHeight = page.size.h - margins.top - margins.bottom;
|
|
503
|
+
let baseX = margins.left;
|
|
504
|
+
let baseY = margins.top;
|
|
505
|
+
if (floating?.horzAnchor === "page") baseX = 0;
|
|
506
|
+
if (floating?.vertAnchor === "page") baseY = 0;
|
|
507
|
+
let x = paginator.getColumnX(state.columnIndex);
|
|
508
|
+
if (floating?.tblpX !== void 0) x = baseX + floating.tblpX;
|
|
509
|
+
else if (floating?.tblpXSpec) {
|
|
510
|
+
const spec = floating.tblpXSpec;
|
|
511
|
+
if (spec === "left" || spec === "inside") x = baseX;
|
|
512
|
+
else if (spec === "right" || spec === "outside") x = baseX + contentWidth - tableWidth;
|
|
513
|
+
else x = baseX + (contentWidth - tableWidth) / 2;
|
|
514
|
+
} else if (block.justification === "center") x = baseX + (contentWidth - tableWidth) / 2;
|
|
515
|
+
else if (block.justification === "right") x = baseX + contentWidth - tableWidth;
|
|
516
|
+
let y = state.cursorY;
|
|
517
|
+
let usedExplicitY = false;
|
|
518
|
+
if (floating?.tblpY !== void 0) {
|
|
519
|
+
y = baseY + floating.tblpY;
|
|
520
|
+
usedExplicitY = true;
|
|
521
|
+
} else if (floating?.tblpYSpec) {
|
|
522
|
+
usedExplicitY = true;
|
|
523
|
+
const spec = floating.tblpYSpec;
|
|
524
|
+
if (spec === "top") y = baseY;
|
|
525
|
+
else if (spec === "bottom") y = baseY + contentHeight - tableHeight;
|
|
526
|
+
else if (spec === "center") y = baseY + (contentHeight - tableHeight) / 2;
|
|
527
|
+
}
|
|
528
|
+
if (!usedExplicitY) y = paginator.ensureFits(tableHeight).cursorY;
|
|
529
|
+
const minX = margins.left;
|
|
530
|
+
const maxX = margins.left + contentWidth - tableWidth;
|
|
531
|
+
if (Number.isFinite(maxX)) x = Math.max(minX, Math.min(x, maxX));
|
|
532
|
+
const fragment = {
|
|
533
|
+
kind: "table",
|
|
534
|
+
blockId: block.id,
|
|
535
|
+
x,
|
|
536
|
+
y,
|
|
537
|
+
width: tableWidth,
|
|
538
|
+
height: tableHeight,
|
|
539
|
+
fromRow: 0,
|
|
540
|
+
toRow: block.rows.length,
|
|
541
|
+
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
542
|
+
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {},
|
|
543
|
+
isFloating: true,
|
|
544
|
+
...block.sdtGroups ? { sdtGroups: block.sdtGroups } : {}
|
|
545
|
+
};
|
|
546
|
+
state.page.fragments.push(fragment);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Layout an image block onto pages.
|
|
550
|
+
*/
|
|
551
|
+
function layoutImage(block, measure, paginator) {
|
|
552
|
+
if (block.anchor?.isAnchored) {
|
|
553
|
+
layoutAnchoredImage(block, measure, paginator);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const bandSkip = measure.bandSkipBefore ?? 0;
|
|
557
|
+
const state = paginator.ensureFits(bandSkip + measure.height);
|
|
558
|
+
const fragment = {
|
|
559
|
+
kind: "image",
|
|
560
|
+
blockId: block.id,
|
|
561
|
+
x: paginator.getColumnX(state.columnIndex),
|
|
562
|
+
y: 0,
|
|
563
|
+
width: measure.width,
|
|
564
|
+
height: measure.height,
|
|
565
|
+
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
566
|
+
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {}
|
|
567
|
+
};
|
|
568
|
+
fragment.y = paginator.addFragment(fragment, measure.height, bandSkip, 0).y;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Layout an anchored (floating) image.
|
|
572
|
+
*/
|
|
573
|
+
function layoutAnchoredImage(block, measure, paginator) {
|
|
574
|
+
const state = paginator.getCurrentState();
|
|
575
|
+
const anchor = block.anchor;
|
|
576
|
+
if (!anchor) return;
|
|
577
|
+
const x = anchor.offsetH ?? paginator.getColumnX(state.columnIndex);
|
|
578
|
+
const y = anchor.offsetV ?? state.cursorY;
|
|
579
|
+
const fragment = {
|
|
580
|
+
kind: "image",
|
|
581
|
+
blockId: block.id,
|
|
582
|
+
x,
|
|
583
|
+
y,
|
|
584
|
+
width: measure.width,
|
|
585
|
+
height: measure.height,
|
|
586
|
+
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
587
|
+
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {},
|
|
588
|
+
isAnchored: true,
|
|
589
|
+
zIndex: anchor.behindDoc ? -1 : 1
|
|
590
|
+
};
|
|
591
|
+
state.page.fragments.push(fragment);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Layout a text box block onto pages.
|
|
595
|
+
*/
|
|
596
|
+
function layoutTextBox(block, measure, { paginator, sectionMarginTop, sectionPageHeight, sectionMarginBottom }) {
|
|
597
|
+
if (isPagePinnedBandTextBox(block)) {
|
|
598
|
+
const state = paginator.getCurrentState();
|
|
599
|
+
const bandTop = bandTopContentY(block.position?.vertical, {
|
|
600
|
+
pageHeight: sectionPageHeight,
|
|
601
|
+
marginTop: sectionMarginTop,
|
|
602
|
+
marginBottom: sectionMarginBottom,
|
|
603
|
+
boxHeight: measure.height
|
|
604
|
+
});
|
|
605
|
+
const horizontal = block.position?.horizontal;
|
|
606
|
+
const x = horizontal ? bandFragmentX(horizontal, {
|
|
607
|
+
pageWidth: state.page.size.w,
|
|
608
|
+
marginLeft: state.page.margins.left,
|
|
609
|
+
marginRight: state.page.margins.right,
|
|
610
|
+
boxWidth: measure.width
|
|
611
|
+
}) : paginator.getColumnX(state.columnIndex);
|
|
612
|
+
const fragment = {
|
|
613
|
+
kind: "textBox",
|
|
614
|
+
blockId: block.id,
|
|
615
|
+
x,
|
|
616
|
+
y: state.topMargin + bandTop,
|
|
617
|
+
width: measure.width,
|
|
618
|
+
height: measure.height,
|
|
619
|
+
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
620
|
+
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {}
|
|
621
|
+
};
|
|
622
|
+
state.page.fragments.push(fragment);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
const state = paginator.ensureFits(measure.height);
|
|
626
|
+
const fragment = {
|
|
627
|
+
kind: "textBox",
|
|
628
|
+
blockId: block.id,
|
|
629
|
+
x: paginator.getColumnX(state.columnIndex),
|
|
630
|
+
y: 0,
|
|
631
|
+
width: measure.width,
|
|
632
|
+
height: measure.height,
|
|
633
|
+
...block.pmStart !== void 0 ? { pmStart: block.pmStart } : {},
|
|
634
|
+
...block.pmEnd !== void 0 ? { pmEnd: block.pmEnd } : {}
|
|
635
|
+
};
|
|
636
|
+
fragment.y = paginator.addFragment(fragment, measure.height, 0, 0).y;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* A topAndBottom text box whose vertical anchor pins it to the page frame
|
|
640
|
+
* (page/margin/margin-strip) — it floats to a fixed page position rather than
|
|
641
|
+
* flowing in document order. Must agree with the measure pass's band extraction
|
|
642
|
+
* (extractFloatingZones), which uses the same predicate. eigenpal #694.
|
|
643
|
+
*/
|
|
644
|
+
function isPagePinnedBandTextBox(block) {
|
|
645
|
+
if (!floatingTextBoxReservesBand(block)) return false;
|
|
646
|
+
return isPageFrameRelativeAnchor(block.position?.vertical?.relativeTo);
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Handle a section break block.
|
|
650
|
+
* @param block - The section break block (current section's properties)
|
|
651
|
+
* @param paginator - The paginator instance
|
|
652
|
+
* @param nextSectionConfig - Page layout for the NEXT section
|
|
653
|
+
* @param nextSectionType - Break type of the NEXT section (how it starts relative to current)
|
|
654
|
+
*/
|
|
655
|
+
function handleSectionBreak(_block, paginator, nextSectionConfig, nextSectionType = "nextPage", nextSectionIndex) {
|
|
656
|
+
switch (nextSectionType) {
|
|
657
|
+
case "nextPage":
|
|
658
|
+
paginator.updatePageLayout(nextSectionConfig.pageSize, nextSectionConfig.margins);
|
|
659
|
+
if (nextSectionIndex !== void 0) paginator.startSection(nextSectionIndex);
|
|
660
|
+
paginator.forcePageBreak({ coalesceBlankPage: true });
|
|
661
|
+
break;
|
|
662
|
+
case "evenPage":
|
|
663
|
+
paginator.updatePageLayout(nextSectionConfig.pageSize, nextSectionConfig.margins);
|
|
664
|
+
if (nextSectionIndex !== void 0) paginator.startSection(nextSectionIndex);
|
|
665
|
+
if (paginator.forcePageBreak({ coalesceBlankPage: true }).page.number % 2 !== 0) paginator.forcePageBreak();
|
|
666
|
+
break;
|
|
667
|
+
case "oddPage":
|
|
668
|
+
paginator.updatePageLayout(nextSectionConfig.pageSize, nextSectionConfig.margins);
|
|
669
|
+
if (nextSectionIndex !== void 0) paginator.startSection(nextSectionIndex);
|
|
670
|
+
if (paginator.forcePageBreak({ coalesceBlankPage: true }).page.number % 2 === 0) paginator.forcePageBreak();
|
|
671
|
+
break;
|
|
672
|
+
case "continuous": {
|
|
673
|
+
const currentPage = paginator.pages.at(-1);
|
|
674
|
+
const nextSize = nextSectionConfig.pageSize;
|
|
675
|
+
const pageSizeChanges = currentPage != null && (Math.round(nextSize.w) !== Math.round(currentPage.size.w) || Math.round(nextSize.h) !== Math.round(currentPage.size.h));
|
|
676
|
+
if (nextSectionIndex !== void 0) paginator.startSection(nextSectionIndex);
|
|
677
|
+
if (pageSizeChanges) {
|
|
678
|
+
paginator.updatePageLayout(nextSize, nextSectionConfig.margins);
|
|
679
|
+
if (!paginator.retargetCurrentBlankPage()) paginator.forcePageBreak({ coalesceBlankPage: true });
|
|
680
|
+
} else {
|
|
681
|
+
paginator.updatePageLayout(nextSize, nextSectionConfig.margins, false);
|
|
682
|
+
paginator.retargetCurrentBlankPage();
|
|
683
|
+
}
|
|
684
|
+
break;
|
|
685
|
+
}
|
|
686
|
+
default: break;
|
|
687
|
+
}
|
|
688
|
+
paginator.updateColumns(nextSectionConfig.columns ?? DEFAULT_COLUMNS);
|
|
689
|
+
}
|
|
690
|
+
//#endregion
|
|
691
|
+
export { DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, applyContextualSpacing, applyPendingToActive, calculateChainHeight, collectSectionConfigs, computeKeepNextChains, createInitialSectionState, createPaginator, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getEffectiveColumns, getEffectiveMargins, getEffectivePageSize, getHeaderRowsHeight, getMidChainIndices, hasKeepLines, hasPageBreakBefore, isFloatingImageRun, isFloatingTextBoxBlock, isTextWrappingFloatingImageRun, layoutDocument, scheduleSectionBreak };
|