@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,43 @@
|
|
|
1
|
+
import { FlowBlock, Measure } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-engine/keep-together.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A chain of consecutive keepNext paragraphs.
|
|
6
|
+
*/
|
|
7
|
+
type KeepNextChain = {
|
|
8
|
+
/** Index of the first paragraph in the chain. */startIndex: number; /** Index of the last paragraph in the chain. */
|
|
9
|
+
endIndex: number; /** All paragraph indices in the chain. */
|
|
10
|
+
memberIndices: number[]; /** Index of the anchor paragraph (first non-keepNext after chain), or -1 if none. */
|
|
11
|
+
anchorIndex: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Pre-scan blocks to find all keepNext chains.
|
|
15
|
+
*
|
|
16
|
+
* A keepNext chain is a sequence of consecutive paragraphs with keepNext=true,
|
|
17
|
+
* followed by an anchor paragraph (the first non-keepNext paragraph).
|
|
18
|
+
* The entire chain must stay on the same page as the anchor's first line.
|
|
19
|
+
*
|
|
20
|
+
* Returns a map from chain start index to chain info.
|
|
21
|
+
*/
|
|
22
|
+
declare function computeKeepNextChains(blocks: FlowBlock[]): Map<number, KeepNextChain>;
|
|
23
|
+
/**
|
|
24
|
+
* Calculate the total height needed to keep a chain together.
|
|
25
|
+
*
|
|
26
|
+
* Includes all chain members plus the first line of the anchor paragraph.
|
|
27
|
+
*/
|
|
28
|
+
declare function calculateChainHeight(chain: KeepNextChain, blocks: FlowBlock[], measures: Measure[]): number;
|
|
29
|
+
/**
|
|
30
|
+
* Get the set of indices that are mid-chain (not chain starters).
|
|
31
|
+
* These should skip the keepNext check since their chain starter already decided.
|
|
32
|
+
*/
|
|
33
|
+
declare function getMidChainIndices(chains: Map<number, KeepNextChain>): Set<number>;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a paragraph has keepLines property (all lines must stay together).
|
|
36
|
+
*/
|
|
37
|
+
declare function hasKeepLines(block: FlowBlock): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a paragraph should start on a new page (pageBreakBefore).
|
|
40
|
+
*/
|
|
41
|
+
declare function hasPageBreakBefore(block: FlowBlock): boolean;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { KeepNextChain, calculateChainHeight, computeKeepNextChains, getMidChainIndices, hasKeepLines, hasPageBreakBefore };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/layout-engine/keep-together.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pre-scan blocks to find all keepNext chains.
|
|
4
|
+
*
|
|
5
|
+
* A keepNext chain is a sequence of consecutive paragraphs with keepNext=true,
|
|
6
|
+
* followed by an anchor paragraph (the first non-keepNext paragraph).
|
|
7
|
+
* The entire chain must stay on the same page as the anchor's first line.
|
|
8
|
+
*
|
|
9
|
+
* Returns a map from chain start index to chain info.
|
|
10
|
+
*/
|
|
11
|
+
function computeKeepNextChains(blocks) {
|
|
12
|
+
const chains = /* @__PURE__ */ new Map();
|
|
13
|
+
const processed = /* @__PURE__ */ new Set();
|
|
14
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
15
|
+
if (processed.has(i)) continue;
|
|
16
|
+
const block = blocks[i];
|
|
17
|
+
if (block.kind !== "paragraph") continue;
|
|
18
|
+
if (!block.attrs?.keepNext) continue;
|
|
19
|
+
const memberIndices = [i];
|
|
20
|
+
let endIndex = i;
|
|
21
|
+
for (let j = i + 1; j < blocks.length; j++) {
|
|
22
|
+
const nextBlock = blocks[j];
|
|
23
|
+
if (nextBlock.kind === "sectionBreak" || nextBlock.kind === "pageBreak" || nextBlock.kind === "columnBreak") break;
|
|
24
|
+
if (nextBlock.kind !== "paragraph") break;
|
|
25
|
+
if (nextBlock.attrs?.keepNext) {
|
|
26
|
+
memberIndices.push(j);
|
|
27
|
+
endIndex = j;
|
|
28
|
+
processed.add(j);
|
|
29
|
+
} else break;
|
|
30
|
+
}
|
|
31
|
+
const potentialAnchor = endIndex + 1;
|
|
32
|
+
let anchorIndex = -1;
|
|
33
|
+
if (potentialAnchor < blocks.length) {
|
|
34
|
+
const anchorBlock = blocks[potentialAnchor];
|
|
35
|
+
if (anchorBlock.kind !== "sectionBreak" && anchorBlock.kind !== "pageBreak" && anchorBlock.kind !== "columnBreak") anchorIndex = potentialAnchor;
|
|
36
|
+
}
|
|
37
|
+
chains.set(i, {
|
|
38
|
+
startIndex: i,
|
|
39
|
+
endIndex,
|
|
40
|
+
memberIndices,
|
|
41
|
+
anchorIndex
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return chains;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Calculate the total height needed to keep a chain together.
|
|
48
|
+
*
|
|
49
|
+
* Includes all chain members plus the first line of the anchor paragraph.
|
|
50
|
+
*/
|
|
51
|
+
function calculateChainHeight(chain, blocks, measures) {
|
|
52
|
+
let totalHeight = 0;
|
|
53
|
+
for (const memberIndex of chain.memberIndices) {
|
|
54
|
+
const block = blocks[memberIndex];
|
|
55
|
+
const measure = measures[memberIndex];
|
|
56
|
+
if (!block || !measure || block.kind !== "paragraph" || measure.kind !== "paragraph") continue;
|
|
57
|
+
const para = block;
|
|
58
|
+
const paraMeasure = measure;
|
|
59
|
+
const spacingBefore = para.attrs?.spacing?.before ?? 0;
|
|
60
|
+
totalHeight += spacingBefore;
|
|
61
|
+
totalHeight += paraMeasure.totalHeight;
|
|
62
|
+
const spacingAfter = para.attrs?.spacing?.after ?? 0;
|
|
63
|
+
totalHeight += spacingAfter;
|
|
64
|
+
}
|
|
65
|
+
if (chain.anchorIndex !== -1) {
|
|
66
|
+
const anchorMeasure = measures[chain.anchorIndex];
|
|
67
|
+
if (anchorMeasure?.kind === "paragraph") {
|
|
68
|
+
const anchorPara = anchorMeasure;
|
|
69
|
+
if (anchorPara.lines.length > 0) totalHeight += anchorPara.lines[0].lineHeight;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return totalHeight;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the set of indices that are mid-chain (not chain starters).
|
|
76
|
+
* These should skip the keepNext check since their chain starter already decided.
|
|
77
|
+
*/
|
|
78
|
+
function getMidChainIndices(chains) {
|
|
79
|
+
const midChain = /* @__PURE__ */ new Set();
|
|
80
|
+
for (const chain of chains.values()) for (let i = 1; i < chain.memberIndices.length; i++) midChain.add(chain.memberIndices[i]);
|
|
81
|
+
return midChain;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if a paragraph has keepLines property (all lines must stay together).
|
|
85
|
+
*/
|
|
86
|
+
function hasKeepLines(block) {
|
|
87
|
+
if (block.kind !== "paragraph") return false;
|
|
88
|
+
return block.attrs?.keepLines === true;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Check if a paragraph should start on a new page (pageBreakBefore).
|
|
92
|
+
*/
|
|
93
|
+
function hasPageBreakBefore(block) {
|
|
94
|
+
if (block.kind !== "paragraph") return false;
|
|
95
|
+
return block.attrs?.pageBreakBefore === true;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { calculateChainHeight, computeKeepNextChains, getMidChainIndices, hasKeepLines, hasPageBreakBefore };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FlowBlock } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-engine/layoutInstrumentation.d.ts
|
|
4
|
+
type LayoutRunReason = "font-ready" | "initial" | "layout-input" | "manual" | "transaction";
|
|
5
|
+
type LayoutPhase = "flow-blocks" | "header-footer" | "initial-fonts" | "layout-document" | "measure-blocks" | "render-pages";
|
|
6
|
+
type HiddenEditorStateReason = "external-document" | "mount";
|
|
7
|
+
type HiddenEditorPhase = "editor-state" | "editor-view" | "to-prose-doc" | "update-state";
|
|
8
|
+
type LayoutInstrumentation = {
|
|
9
|
+
onHiddenEditorPhase?: (event: {
|
|
10
|
+
durationMs: number;
|
|
11
|
+
phase: HiddenEditorPhase;
|
|
12
|
+
reason: HiddenEditorStateReason;
|
|
13
|
+
}) => void;
|
|
14
|
+
onHiddenEditorStateCreate?: (event: {
|
|
15
|
+
reason: HiddenEditorStateReason;
|
|
16
|
+
}) => void;
|
|
17
|
+
onLayoutComplete?: (event: {
|
|
18
|
+
reason: LayoutRunReason;
|
|
19
|
+
}) => void;
|
|
20
|
+
onLayoutError?: (event: {
|
|
21
|
+
message: string;
|
|
22
|
+
reason: LayoutRunReason;
|
|
23
|
+
}) => void;
|
|
24
|
+
onLayoutPhase?: (event: {
|
|
25
|
+
durationMs: number;
|
|
26
|
+
phase: LayoutPhase;
|
|
27
|
+
reason: LayoutRunReason;
|
|
28
|
+
}) => void;
|
|
29
|
+
onMeasureBlock?: (event: {
|
|
30
|
+
blockIndex: number;
|
|
31
|
+
blockKind: FlowBlock["kind"];
|
|
32
|
+
}) => void;
|
|
33
|
+
onMeasureBlockError?: (event: {
|
|
34
|
+
blockIndex: number;
|
|
35
|
+
blockKind: FlowBlock["kind"];
|
|
36
|
+
message: string;
|
|
37
|
+
}) => void;
|
|
38
|
+
};
|
|
39
|
+
declare global {
|
|
40
|
+
var __folioLayoutInstrumentation: LayoutInstrumentation | undefined;
|
|
41
|
+
}
|
|
42
|
+
declare function recordMeasureBlock(blockIndex: number, block: FlowBlock): void;
|
|
43
|
+
declare function recordMeasureBlockError(blockIndex: number, block: FlowBlock, error: unknown): void;
|
|
44
|
+
declare function recordLayoutComplete(reason?: LayoutRunReason): void;
|
|
45
|
+
declare function recordLayoutError(reason: LayoutRunReason, error: unknown): void;
|
|
46
|
+
declare function recordLayoutPhase(reason: LayoutRunReason, phase: LayoutPhase, durationMs: number): void;
|
|
47
|
+
declare function recordHiddenEditorStateCreate(reason: HiddenEditorStateReason): void;
|
|
48
|
+
declare function recordHiddenEditorPhase(reason: HiddenEditorStateReason, phase: HiddenEditorPhase, durationMs: number): void;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { HiddenEditorPhase, HiddenEditorStateReason, LayoutInstrumentation, LayoutPhase, LayoutRunReason, recordHiddenEditorPhase, recordHiddenEditorStateCreate, recordLayoutComplete, recordLayoutError, recordLayoutPhase, recordMeasureBlock, recordMeasureBlockError };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/layout-engine/layoutInstrumentation.ts
|
|
2
|
+
function recordMeasureBlock(blockIndex, block) {
|
|
3
|
+
globalThis.__folioLayoutInstrumentation?.onMeasureBlock?.({
|
|
4
|
+
blockIndex,
|
|
5
|
+
blockKind: block.kind
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
function recordMeasureBlockError(blockIndex, block, error) {
|
|
9
|
+
globalThis.__folioLayoutInstrumentation?.onMeasureBlockError?.({
|
|
10
|
+
blockIndex,
|
|
11
|
+
blockKind: block.kind,
|
|
12
|
+
message: error instanceof Error ? error.message : String(error)
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function recordLayoutComplete(reason = "manual") {
|
|
16
|
+
globalThis.__folioLayoutInstrumentation?.onLayoutComplete?.({ reason });
|
|
17
|
+
}
|
|
18
|
+
function recordLayoutError(reason, error) {
|
|
19
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
20
|
+
globalThis.__folioLayoutInstrumentation?.onLayoutError?.({
|
|
21
|
+
message,
|
|
22
|
+
reason
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function recordLayoutPhase(reason, phase, durationMs) {
|
|
26
|
+
globalThis.__folioLayoutInstrumentation?.onLayoutPhase?.({
|
|
27
|
+
durationMs,
|
|
28
|
+
phase,
|
|
29
|
+
reason
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function recordHiddenEditorStateCreate(reason) {
|
|
33
|
+
globalThis.__folioLayoutInstrumentation?.onHiddenEditorStateCreate?.({ reason });
|
|
34
|
+
}
|
|
35
|
+
function recordHiddenEditorPhase(reason, phase, durationMs) {
|
|
36
|
+
globalThis.__folioLayoutInstrumentation?.onHiddenEditorPhase?.({
|
|
37
|
+
durationMs,
|
|
38
|
+
phase,
|
|
39
|
+
reason
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { recordHiddenEditorPhase, recordHiddenEditorStateCreate, recordLayoutComplete, recordLayoutError, recordLayoutPhase, recordMeasureBlock, recordMeasureBlockError };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MeasuredLine } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-engine/lineFlow.d.ts
|
|
4
|
+
declare function measuredLineAdvance(line: MeasuredLine): number;
|
|
5
|
+
declare function measuredLineRangeHeight(lines: readonly MeasuredLine[], fromLine: number, toLine: number): number;
|
|
6
|
+
declare function measuredLineContentOffset(lines: readonly MeasuredLine[], fromLine: number, lineIndex: number): number;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { measuredLineAdvance, measuredLineContentOffset, measuredLineRangeHeight };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/layout-engine/lineFlow.ts
|
|
2
|
+
function measuredLineAdvance(line) {
|
|
3
|
+
return line.lineHeight + (line.floatSkipBefore ?? 0);
|
|
4
|
+
}
|
|
5
|
+
function measuredLineRangeHeight(lines, fromLine, toLine) {
|
|
6
|
+
let height = 0;
|
|
7
|
+
const start = Math.max(0, fromLine);
|
|
8
|
+
const end = Math.min(toLine, lines.length);
|
|
9
|
+
for (let index = start; index < end; index++) height += measuredLineAdvance(lines[index]);
|
|
10
|
+
return height;
|
|
11
|
+
}
|
|
12
|
+
function measuredLineContentOffset(lines, fromLine, lineIndex) {
|
|
13
|
+
const line = lines.at(lineIndex);
|
|
14
|
+
return measuredLineRangeHeight(lines, fromLine, lineIndex) + (line?.floatSkipBefore ?? 0);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { measuredLineAdvance, measuredLineContentOffset, measuredLineRangeHeight };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ParagraphBlock, ParagraphMeasure } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-engine/measure/cache.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Get cached text width or return undefined
|
|
6
|
+
*/
|
|
7
|
+
declare function getCachedTextWidth(text: string, font: string, letterSpacing?: number): number | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Store text width in cache
|
|
10
|
+
*/
|
|
11
|
+
declare function setCachedTextWidth(text: string, font: string, letterSpacing: number, width: number): void;
|
|
12
|
+
/**
|
|
13
|
+
* Clear the text width cache
|
|
14
|
+
*/
|
|
15
|
+
declare function clearTextWidthCache(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Monotonic generation used by async measurement workers to drop
|
|
18
|
+
* responses that were measured before a cache reset.
|
|
19
|
+
*/
|
|
20
|
+
declare function getTextWidthCacheGeneration(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Set the maximum size of the text width cache
|
|
23
|
+
*/
|
|
24
|
+
declare function setTextCacheSize(size: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get current text width cache size
|
|
27
|
+
*/
|
|
28
|
+
declare function getTextCacheSize(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Cached font metrics entry
|
|
31
|
+
*/
|
|
32
|
+
type FontMetricsEntry = {
|
|
33
|
+
ascent: number;
|
|
34
|
+
descent: number;
|
|
35
|
+
lineHeight: number;
|
|
36
|
+
singleLineRatio: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Get cached font metrics or return undefined
|
|
40
|
+
*/
|
|
41
|
+
declare function getCachedFontMetrics(fontFamily: string, fontSize: number, bold?: boolean, italic?: boolean, fontVariant?: string): FontMetricsEntry | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Store font metrics in cache
|
|
44
|
+
*/
|
|
45
|
+
declare function setCachedFontMetrics(fontFamily: string, fontSize: number, bold: boolean, italic: boolean, metrics: FontMetricsEntry, fontVariant?: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Clear the font metrics cache
|
|
48
|
+
*/
|
|
49
|
+
declare function clearFontMetricsCache(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Set the maximum size of the font metrics cache
|
|
52
|
+
*/
|
|
53
|
+
declare function setFontCacheSize(size: number): void;
|
|
54
|
+
/**
|
|
55
|
+
* Get current font metrics cache size
|
|
56
|
+
*/
|
|
57
|
+
declare function getFontCacheSize(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Generate a simple hash for a paragraph block
|
|
60
|
+
* Used as cache key to identify identical content
|
|
61
|
+
*/
|
|
62
|
+
declare function hashParagraphBlock(block: ParagraphBlock): string;
|
|
63
|
+
/**
|
|
64
|
+
* Get cached paragraph measurement or return undefined
|
|
65
|
+
*/
|
|
66
|
+
declare function getCachedParagraphMeasure(block: ParagraphBlock, maxWidth: number): ParagraphMeasure | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Store paragraph measurement in cache
|
|
69
|
+
*/
|
|
70
|
+
declare function setCachedParagraphMeasure(block: ParagraphBlock, maxWidth: number, measure: ParagraphMeasure): void;
|
|
71
|
+
/**
|
|
72
|
+
* Clear the paragraph measure cache
|
|
73
|
+
*/
|
|
74
|
+
declare function clearParagraphMeasureCache(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Set the maximum size of the paragraph measure cache
|
|
77
|
+
*/
|
|
78
|
+
declare function setParagraphCacheSize(size: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* Get current paragraph measure cache size
|
|
81
|
+
*/
|
|
82
|
+
declare function getParagraphCacheSize(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Clear all measurement caches
|
|
85
|
+
* Call when fonts change, page width changes, or for testing
|
|
86
|
+
*/
|
|
87
|
+
declare function clearAllCaches(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Get total size of all caches
|
|
90
|
+
*/
|
|
91
|
+
declare function getTotalCacheSize(): number;
|
|
92
|
+
//#endregion
|
|
93
|
+
export { clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFontCacheSize, getParagraphCacheSize, getTextCacheSize, getTextWidthCacheGeneration, getTotalCacheSize, hashParagraphBlock, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFontCacheSize, setParagraphCacheSize, setTextCacheSize };
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
//#region src/layout-engine/measure/cache.ts
|
|
2
|
+
/**
|
|
3
|
+
* Current max size for text width cache
|
|
4
|
+
*/
|
|
5
|
+
let textCacheMaxSize = 2e4;
|
|
6
|
+
/**
|
|
7
|
+
* LRU cache for text width measurements
|
|
8
|
+
* Key format: "text|font|letterSpacing"
|
|
9
|
+
*/
|
|
10
|
+
const textWidthCache = /* @__PURE__ */ new Map();
|
|
11
|
+
let textWidthCacheGeneration = 0;
|
|
12
|
+
/**
|
|
13
|
+
* Create a cache key for text width lookup
|
|
14
|
+
*/
|
|
15
|
+
function makeTextKey(text, font, letterSpacing) {
|
|
16
|
+
return `${text}|${font}|${letterSpacing || 0}`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Evict oldest entries if cache exceeds max size
|
|
20
|
+
*/
|
|
21
|
+
function evictTextEntries() {
|
|
22
|
+
while (textWidthCache.size > textCacheMaxSize) {
|
|
23
|
+
const oldestKey = textWidthCache.keys().next().value;
|
|
24
|
+
if (oldestKey === void 0) break;
|
|
25
|
+
textWidthCache.delete(oldestKey);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get cached text width or return undefined
|
|
30
|
+
*/
|
|
31
|
+
function getCachedTextWidth(text, font, letterSpacing = 0) {
|
|
32
|
+
const key = makeTextKey(text, font, letterSpacing);
|
|
33
|
+
const entry = textWidthCache.get(key);
|
|
34
|
+
if (entry !== void 0) {
|
|
35
|
+
textWidthCache.delete(key);
|
|
36
|
+
textWidthCache.set(key, entry);
|
|
37
|
+
return entry.width;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Store text width in cache
|
|
42
|
+
*/
|
|
43
|
+
function setCachedTextWidth(text, font, letterSpacing, width) {
|
|
44
|
+
const key = makeTextKey(text, font, letterSpacing);
|
|
45
|
+
textWidthCache.set(key, { width });
|
|
46
|
+
evictTextEntries();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Clear the text width cache
|
|
50
|
+
*/
|
|
51
|
+
function clearTextWidthCache() {
|
|
52
|
+
textWidthCache.clear();
|
|
53
|
+
textWidthCacheGeneration += 1;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Monotonic generation used by async measurement workers to drop
|
|
57
|
+
* responses that were measured before a cache reset.
|
|
58
|
+
*/
|
|
59
|
+
function getTextWidthCacheGeneration() {
|
|
60
|
+
return textWidthCacheGeneration;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Set the maximum size of the text width cache
|
|
64
|
+
*/
|
|
65
|
+
function setTextCacheSize(size) {
|
|
66
|
+
if (!Number.isFinite(size) || size <= 0) return;
|
|
67
|
+
textCacheMaxSize = size;
|
|
68
|
+
evictTextEntries();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get current text width cache size
|
|
72
|
+
*/
|
|
73
|
+
function getTextCacheSize() {
|
|
74
|
+
return textWidthCache.size;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Current max size for font metrics cache
|
|
78
|
+
*/
|
|
79
|
+
let fontCacheMaxSize = 1e3;
|
|
80
|
+
/**
|
|
81
|
+
* LRU cache for font metrics
|
|
82
|
+
* Key format: "fontFamily|fontSize|bold|italic|fontVariant"
|
|
83
|
+
*/
|
|
84
|
+
const fontMetricsCache = /* @__PURE__ */ new Map();
|
|
85
|
+
/**
|
|
86
|
+
* Create a cache key for font metrics lookup
|
|
87
|
+
*/
|
|
88
|
+
function makeFontKey(fontFamily, fontSize, bold = false, italic = false, fontVariant) {
|
|
89
|
+
return `${fontFamily}|${fontSize}|${bold}|${italic}|${fontVariant ?? ""}`;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Evict oldest entries if font cache exceeds max size
|
|
93
|
+
*/
|
|
94
|
+
function evictFontEntries() {
|
|
95
|
+
while (fontMetricsCache.size > fontCacheMaxSize) {
|
|
96
|
+
const oldestKey = fontMetricsCache.keys().next().value;
|
|
97
|
+
if (oldestKey === void 0) break;
|
|
98
|
+
fontMetricsCache.delete(oldestKey);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get cached font metrics or return undefined
|
|
103
|
+
*/
|
|
104
|
+
function getCachedFontMetrics(fontFamily, fontSize, bold = false, italic = false, fontVariant) {
|
|
105
|
+
const key = makeFontKey(fontFamily, fontSize, bold, italic, fontVariant);
|
|
106
|
+
const entry = fontMetricsCache.get(key);
|
|
107
|
+
if (entry !== void 0) {
|
|
108
|
+
fontMetricsCache.delete(key);
|
|
109
|
+
fontMetricsCache.set(key, entry);
|
|
110
|
+
return entry;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Store font metrics in cache
|
|
115
|
+
*/
|
|
116
|
+
function setCachedFontMetrics(fontFamily, fontSize, bold, italic, metrics, fontVariant) {
|
|
117
|
+
const key = makeFontKey(fontFamily, fontSize, bold, italic, fontVariant);
|
|
118
|
+
fontMetricsCache.set(key, metrics);
|
|
119
|
+
evictFontEntries();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Clear the font metrics cache
|
|
123
|
+
*/
|
|
124
|
+
function clearFontMetricsCache() {
|
|
125
|
+
fontMetricsCache.clear();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Set the maximum size of the font metrics cache
|
|
129
|
+
*/
|
|
130
|
+
function setFontCacheSize(size) {
|
|
131
|
+
if (!Number.isFinite(size) || size <= 0) return;
|
|
132
|
+
fontCacheMaxSize = size;
|
|
133
|
+
evictFontEntries();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get current font metrics cache size
|
|
137
|
+
*/
|
|
138
|
+
function getFontCacheSize() {
|
|
139
|
+
return fontMetricsCache.size;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Current max size for paragraph measure cache
|
|
143
|
+
*/
|
|
144
|
+
let paragraphCacheMaxSize = 5e3;
|
|
145
|
+
/**
|
|
146
|
+
* LRU cache for paragraph measurements
|
|
147
|
+
* Key format: block content hash
|
|
148
|
+
*/
|
|
149
|
+
const paragraphMeasureCache = /* @__PURE__ */ new Map();
|
|
150
|
+
/**
|
|
151
|
+
* Generate a simple hash for a paragraph block
|
|
152
|
+
* Used as cache key to identify identical content
|
|
153
|
+
*/
|
|
154
|
+
function hashParagraphBlock(block) {
|
|
155
|
+
const parts = [];
|
|
156
|
+
for (const run of block.runs) if (run.kind === "text") parts.push(`t:${run.text}|${run.fontFamily}|${run.eastAsiaFontFamily}|${run.fontSize}|${run.bold}|${run.italic}|${run.allCaps}|${run.smallCaps}|${run.horizontalScale}|${run.letterSpacing}`);
|
|
157
|
+
else if (run.kind === "tab") parts.push(`tab:${run.width}`);
|
|
158
|
+
else if (run.kind === "image") parts.push(`img:${run.width}x${run.height}`);
|
|
159
|
+
else if (run.kind === "lineBreak") parts.push("br");
|
|
160
|
+
const attrs = block.attrs;
|
|
161
|
+
if (attrs) {
|
|
162
|
+
if (attrs.alignment) parts.push(`align:${attrs.alignment}`);
|
|
163
|
+
if (attrs.indent) parts.push(`indent:${attrs.indent.left}|${attrs.indent.right}|${attrs.indent.firstLine}|${attrs.indent.hanging}`);
|
|
164
|
+
if (attrs.spacing) parts.push(`spacing:${attrs.spacing.before}|${attrs.spacing.after}|${attrs.spacing.line}|${attrs.spacing.lineRule}`);
|
|
165
|
+
if (attrs.defaultFontSize != null) parts.push(`dfs:${attrs.defaultFontSize}`);
|
|
166
|
+
if (attrs.defaultFontFamily != null) parts.push(`dff:${attrs.defaultFontFamily}`);
|
|
167
|
+
if (attrs.suppressEmptyParagraphHeight) parts.push("sup");
|
|
168
|
+
const borders = attrs.borders;
|
|
169
|
+
if (borders) {
|
|
170
|
+
const signature = (border) => border ? `${border.width ?? ""},${border.style ?? ""},${border.color ?? ""}` : "";
|
|
171
|
+
parts.push(`bdr:${signature(borders.top)}|${signature(borders.bottom)}|${signature(borders.left)}|${signature(borders.right)}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return parts.join("||");
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Evict oldest entries if paragraph cache exceeds max size
|
|
178
|
+
*/
|
|
179
|
+
function evictParagraphEntries() {
|
|
180
|
+
while (paragraphMeasureCache.size > paragraphCacheMaxSize) {
|
|
181
|
+
const oldestKey = paragraphMeasureCache.keys().next().value;
|
|
182
|
+
if (oldestKey === void 0) break;
|
|
183
|
+
paragraphMeasureCache.delete(oldestKey);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get cached paragraph measurement or return undefined
|
|
188
|
+
*/
|
|
189
|
+
function getCachedParagraphMeasure(block, maxWidth) {
|
|
190
|
+
const key = hashParagraphBlock(block);
|
|
191
|
+
const entry = paragraphMeasureCache.get(key);
|
|
192
|
+
if (entry !== void 0 && entry.maxWidth === maxWidth) {
|
|
193
|
+
paragraphMeasureCache.delete(key);
|
|
194
|
+
paragraphMeasureCache.set(key, entry);
|
|
195
|
+
return entry.measure;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Store paragraph measurement in cache
|
|
200
|
+
*/
|
|
201
|
+
function setCachedParagraphMeasure(block, maxWidth, measure) {
|
|
202
|
+
const key = hashParagraphBlock(block);
|
|
203
|
+
paragraphMeasureCache.set(key, {
|
|
204
|
+
measure,
|
|
205
|
+
maxWidth
|
|
206
|
+
});
|
|
207
|
+
evictParagraphEntries();
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Clear the paragraph measure cache
|
|
211
|
+
*/
|
|
212
|
+
function clearParagraphMeasureCache() {
|
|
213
|
+
paragraphMeasureCache.clear();
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Set the maximum size of the paragraph measure cache
|
|
217
|
+
*/
|
|
218
|
+
function setParagraphCacheSize(size) {
|
|
219
|
+
if (!Number.isFinite(size) || size <= 0) return;
|
|
220
|
+
paragraphCacheMaxSize = size;
|
|
221
|
+
evictParagraphEntries();
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get current paragraph measure cache size
|
|
225
|
+
*/
|
|
226
|
+
function getParagraphCacheSize() {
|
|
227
|
+
return paragraphMeasureCache.size;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Clear all measurement caches
|
|
231
|
+
* Call when fonts change, page width changes, or for testing
|
|
232
|
+
*/
|
|
233
|
+
function clearAllCaches() {
|
|
234
|
+
clearTextWidthCache();
|
|
235
|
+
clearFontMetricsCache();
|
|
236
|
+
clearParagraphMeasureCache();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Get total size of all caches
|
|
240
|
+
*/
|
|
241
|
+
function getTotalCacheSize() {
|
|
242
|
+
return getTextCacheSize() + getFontCacheSize() + getParagraphCacheSize();
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
export { clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFontCacheSize, getParagraphCacheSize, getTextCacheSize, getTextWidthCacheGeneration, getTotalCacheSize, hashParagraphBlock, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFontCacheSize, setParagraphCacheSize, setTextCacheSize };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/layout-engine/measure/clampFloatingWrapMargins.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Guard against wrap margins that exceed the available content width.
|
|
4
|
+
*
|
|
5
|
+
* When a float's wrap margins consume the entire content width (or more),
|
|
6
|
+
* there is no horizontal strip beside it for body text. Word renders the
|
|
7
|
+
* following lines at full content width instead of collapsing them to a
|
|
8
|
+
* 1-glyph column. Unchecked margins from near-full-width tables/images can
|
|
9
|
+
* exceed contentWidth and collapse every wrap line to ~1 character.
|
|
10
|
+
*
|
|
11
|
+
* Returned margins are zeroed when either side alone is >= contentWidth or
|
|
12
|
+
* their sum is >= contentWidth. Otherwise the original (non-negative) values
|
|
13
|
+
* pass through unchanged.
|
|
14
|
+
*/
|
|
15
|
+
declare function clampFloatingWrapMargins(leftMargin: number, rightMargin: number, contentWidth: number): {
|
|
16
|
+
leftMargin: number;
|
|
17
|
+
rightMargin: number;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { clampFloatingWrapMargins };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/layout-engine/measure/clampFloatingWrapMargins.ts
|
|
2
|
+
/**
|
|
3
|
+
* Guard against wrap margins that exceed the available content width.
|
|
4
|
+
*
|
|
5
|
+
* When a float's wrap margins consume the entire content width (or more),
|
|
6
|
+
* there is no horizontal strip beside it for body text. Word renders the
|
|
7
|
+
* following lines at full content width instead of collapsing them to a
|
|
8
|
+
* 1-glyph column. Unchecked margins from near-full-width tables/images can
|
|
9
|
+
* exceed contentWidth and collapse every wrap line to ~1 character.
|
|
10
|
+
*
|
|
11
|
+
* Returned margins are zeroed when either side alone is >= contentWidth or
|
|
12
|
+
* their sum is >= contentWidth. Otherwise the original (non-negative) values
|
|
13
|
+
* pass through unchanged.
|
|
14
|
+
*/
|
|
15
|
+
function clampFloatingWrapMargins(leftMargin, rightMargin, contentWidth) {
|
|
16
|
+
const cw = Math.max(1, contentWidth);
|
|
17
|
+
const lm = Math.max(0, leftMargin);
|
|
18
|
+
const rm = Math.max(0, rightMargin);
|
|
19
|
+
if (lm >= cw || rm >= cw || lm + rm >= cw) return {
|
|
20
|
+
leftMargin: 0,
|
|
21
|
+
rightMargin: 0
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
leftMargin: lm,
|
|
25
|
+
rightMargin: rm
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { clampFloatingWrapMargins };
|