@stll/folio-core 0.0.1-placeholder.0 → 0.1.1
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 +66 -0
- package/dist/types/block-id.js +73 -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,44 @@
|
|
|
1
|
+
//#region src/layout-engine/measure/featureFlags.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Feature flags for the measurement subsystem.
|
|
4
|
+
*
|
|
5
|
+
* Flags are read from `globalThis.__folioFeatureFlags`. This mirrors the
|
|
6
|
+
* existing `__folioLayoutInstrumentation` pattern: callers from `apps/web`
|
|
7
|
+
* (or any host app) install the bag before mounting `DocxEditor`, and the
|
|
8
|
+
* measurement code reads it on demand without taking a hard dependency on
|
|
9
|
+
* any host framework.
|
|
10
|
+
*
|
|
11
|
+
* All flags default OFF so that callers who never set the bag see exactly
|
|
12
|
+
* the same behaviour as before any of this code existed.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Flag bag shape. Adding a new flag means adding a key here and a `get*Flag`
|
|
16
|
+
* accessor below.
|
|
17
|
+
*/
|
|
18
|
+
type FolioMeasurementFeatureFlags = {
|
|
19
|
+
/**
|
|
20
|
+
* Pre-warm the text-width cache from a Web Worker so cache misses during
|
|
21
|
+
* the line-break binary search become cache hits on subsequent probes.
|
|
22
|
+
*
|
|
23
|
+
* When OFF (default), no worker is ever created and every measurement
|
|
24
|
+
* runs on the main thread exactly as before.
|
|
25
|
+
*/
|
|
26
|
+
workerFontMetrics?: boolean;
|
|
27
|
+
};
|
|
28
|
+
declare global {
|
|
29
|
+
var __folioFeatureFlags: FolioMeasurementFeatureFlags | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Read the worker-font-metrics flag. Returns `false` if the bag is missing,
|
|
33
|
+
* the key is unset, or the value is anything other than `true`. The strict
|
|
34
|
+
* comparison ensures truthy-but-not-true values (strings, numbers) cannot
|
|
35
|
+
* accidentally enable the worker path.
|
|
36
|
+
*/
|
|
37
|
+
declare function isWorkerFontMetricsEnabled(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Test-only helper to set the flag bag without polluting host state.
|
|
40
|
+
* Production callers should set `globalThis.__folioFeatureFlags` directly.
|
|
41
|
+
*/
|
|
42
|
+
declare function setFolioMeasurementFlags(flags: FolioMeasurementFeatureFlags | undefined): void;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { FolioMeasurementFeatureFlags, isWorkerFontMetricsEnabled, setFolioMeasurementFlags };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/layout-engine/measure/featureFlags.ts
|
|
2
|
+
/**
|
|
3
|
+
* Read the worker-font-metrics flag. Returns `false` if the bag is missing,
|
|
4
|
+
* the key is unset, or the value is anything other than `true`. The strict
|
|
5
|
+
* comparison ensures truthy-but-not-true values (strings, numbers) cannot
|
|
6
|
+
* accidentally enable the worker path.
|
|
7
|
+
*/
|
|
8
|
+
function isWorkerFontMetricsEnabled() {
|
|
9
|
+
return globalThis.__folioFeatureFlags?.workerFontMetrics === true;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Test-only helper to set the flag bag without polluting host state.
|
|
13
|
+
* Production callers should set `globalThis.__folioFeatureFlags` directly.
|
|
14
|
+
*/
|
|
15
|
+
function setFolioMeasurementFlags(flags) {
|
|
16
|
+
globalThis.__folioFeatureFlags = flags;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { isWorkerFontMetricsEnabled, setFolioMeasurementFlags };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//#region src/layout-engine/measure/floatingZones.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Floating exclusion zones — shared between floating images and anchored
|
|
4
|
+
* text boxes. Ported from eigenpal docx-editor #474 to extract per-object
|
|
5
|
+
* zone construction out of the page renderer so text-box anchors can
|
|
6
|
+
* contribute exclusion rects through the same pipeline.
|
|
7
|
+
*
|
|
8
|
+
* Folio adds `clampFloatingWrapMargins` (near-full-width float guard) on top
|
|
9
|
+
* of the upstream conversion; without it, body text after a wide float
|
|
10
|
+
* collapses to ~1 glyph per line.
|
|
11
|
+
*/
|
|
12
|
+
type WrapTextDirection = "bothSides" | "left" | "right" | "largest";
|
|
13
|
+
/**
|
|
14
|
+
* A single floating object's exclusion rectangle in content-area coordinates.
|
|
15
|
+
* Produced from images and anchored text boxes; consumed by
|
|
16
|
+
* `rectsToFloatingZones` to derive per-line wrap margins.
|
|
17
|
+
*/
|
|
18
|
+
type FloatingExclusionRect = {
|
|
19
|
+
/** Which side the object is on for simple one-sided wrapping. */side: "left" | "right"; /** X position relative to the content area. */
|
|
20
|
+
x: number; /** Y position relative to the content area. */
|
|
21
|
+
y: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
distTop: number;
|
|
25
|
+
distBottom: number;
|
|
26
|
+
distLeft: number;
|
|
27
|
+
distRight: number;
|
|
28
|
+
wrapText?: WrapTextDirection;
|
|
29
|
+
wrapType?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Per-object exclusion zone in the measurement coordinate space. Each rect
|
|
33
|
+
* becomes its own zone so lines at different Y positions get independently
|
|
34
|
+
* correct widths.
|
|
35
|
+
*/
|
|
36
|
+
type FloatingImageZone = {
|
|
37
|
+
/** Left margin reduction (pixels from left edge). */leftMargin: number; /** Right margin reduction (pixels from right edge). */
|
|
38
|
+
rightMargin: number; /** Top Y coordinate of the exclusion zone. */
|
|
39
|
+
topY: number; /** Bottom Y coordinate of the exclusion zone. */
|
|
40
|
+
bottomY: number; /** Optional split segments for centered both-sides wrapping. */
|
|
41
|
+
segments?: FloatingLineSegmentZone[];
|
|
42
|
+
/**
|
|
43
|
+
* Full-width vertical band (OOXML `topAndBottom` wrap): no text fits beside
|
|
44
|
+
* it, so any line overlapping `[topY, bottomY]` is pushed below the band
|
|
45
|
+
* (via `findClearLineY`). Ported from eigenpal docx-editor #694.
|
|
46
|
+
*/
|
|
47
|
+
fullWidthBlock?: boolean;
|
|
48
|
+
};
|
|
49
|
+
type FloatingLineSegmentZone = {
|
|
50
|
+
leftOffset: number;
|
|
51
|
+
availableWidth: number;
|
|
52
|
+
};
|
|
53
|
+
type FloatingLineMargins = {
|
|
54
|
+
leftMargin: number;
|
|
55
|
+
rightMargin: number;
|
|
56
|
+
segments?: FloatingLineSegmentZone[];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Convert floating exclusion rectangles to per-object zones for the
|
|
60
|
+
* measurement system. Mirrors eigenpal #474.
|
|
61
|
+
*
|
|
62
|
+
* `wrapText` controls which side(s) text flows on:
|
|
63
|
+
* - `right` → text only on right → object blocks left side (leftMargin)
|
|
64
|
+
* - `left` → text only on left → object blocks right side (rightMargin)
|
|
65
|
+
* - `bothSides` → ideally splits the line into two segments when the
|
|
66
|
+
* object is centered in the column; folio currently falls
|
|
67
|
+
* back to the wider side because split-segment rendering
|
|
68
|
+
* is not yet plumbed through the painter (see comment in
|
|
69
|
+
* the function body).
|
|
70
|
+
* - `largest` → pick whichever side has more remaining room and reduce
|
|
71
|
+
* the line to that single side (no split).
|
|
72
|
+
*/
|
|
73
|
+
declare function rectsToFloatingZones(rects: FloatingExclusionRect[], contentWidth: number): FloatingImageZone[];
|
|
74
|
+
/**
|
|
75
|
+
* Effective horizontal text width for a line under the given margins.
|
|
76
|
+
* When the zone provides split segments (centered both-sides wrap), each
|
|
77
|
+
* segment is clipped against `leftMargin`/`rightMargin` so a side float
|
|
78
|
+
* overlapping vertically with the centered float still reduces the budget.
|
|
79
|
+
* Otherwise falls back to `baseWidth - leftMargin - rightMargin`.
|
|
80
|
+
*/
|
|
81
|
+
declare function getFloatingAvailableWidth(margins: FloatingLineMargins, baseWidth: number): number;
|
|
82
|
+
/**
|
|
83
|
+
* Calculate width reduction for a line based on floating object zones.
|
|
84
|
+
* Returns the left and right margins (plus optional segments) that apply
|
|
85
|
+
* at this vertical position.
|
|
86
|
+
*/
|
|
87
|
+
declare function getFloatingMargins(lineY: number, lineHeight: number, zones: FloatingImageZone[] | undefined, paragraphYOffset: number): FloatingLineMargins;
|
|
88
|
+
//#endregion
|
|
89
|
+
export { FloatingExclusionRect, FloatingImageZone, FloatingLineMargins, FloatingLineSegmentZone, WrapTextDirection, getFloatingAvailableWidth, getFloatingMargins, rectsToFloatingZones };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { clampFloatingWrapMargins } from "./clampFloatingWrapMargins.js";
|
|
2
|
+
//#region src/layout-engine/measure/floatingZones.ts
|
|
3
|
+
/**
|
|
4
|
+
* Floating exclusion zones — shared between floating images and anchored
|
|
5
|
+
* text boxes. Ported from eigenpal docx-editor #474 to extract per-object
|
|
6
|
+
* zone construction out of the page renderer so text-box anchors can
|
|
7
|
+
* contribute exclusion rects through the same pipeline.
|
|
8
|
+
*
|
|
9
|
+
* Folio adds `clampFloatingWrapMargins` (near-full-width float guard) on top
|
|
10
|
+
* of the upstream conversion; without it, body text after a wide float
|
|
11
|
+
* collapses to ~1 glyph per line.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Convert floating exclusion rectangles to per-object zones for the
|
|
15
|
+
* measurement system. Mirrors eigenpal #474.
|
|
16
|
+
*
|
|
17
|
+
* `wrapText` controls which side(s) text flows on:
|
|
18
|
+
* - `right` → text only on right → object blocks left side (leftMargin)
|
|
19
|
+
* - `left` → text only on left → object blocks right side (rightMargin)
|
|
20
|
+
* - `bothSides` → ideally splits the line into two segments when the
|
|
21
|
+
* object is centered in the column; folio currently falls
|
|
22
|
+
* back to the wider side because split-segment rendering
|
|
23
|
+
* is not yet plumbed through the painter (see comment in
|
|
24
|
+
* the function body).
|
|
25
|
+
* - `largest` → pick whichever side has more remaining room and reduce
|
|
26
|
+
* the line to that single side (no split).
|
|
27
|
+
*/
|
|
28
|
+
function rectsToFloatingZones(rects, contentWidth) {
|
|
29
|
+
return rects.map((rect) => {
|
|
30
|
+
const rectLeft = rect.x - rect.distLeft;
|
|
31
|
+
const rectRight = rect.x + rect.width + rect.distRight;
|
|
32
|
+
const rectTop = rect.y - rect.distTop;
|
|
33
|
+
const rectBottom = rect.y + rect.height + rect.distBottom;
|
|
34
|
+
if (rect.wrapType === "topAndBottom") return {
|
|
35
|
+
leftMargin: 0,
|
|
36
|
+
rightMargin: 0,
|
|
37
|
+
topY: rectTop,
|
|
38
|
+
bottomY: rectBottom,
|
|
39
|
+
fullWidthBlock: true
|
|
40
|
+
};
|
|
41
|
+
let leftMargin = 0;
|
|
42
|
+
let rightMargin = 0;
|
|
43
|
+
if (rect.wrapText === "right") leftMargin = leftObjectMargin(rectRight);
|
|
44
|
+
else if (rect.wrapText === "left") rightMargin = rightObjectMargin(rectLeft, contentWidth);
|
|
45
|
+
else if (rect.wrapText === "largest" || rect.wrapText === "bothSides" && canSplitCenteredBothSidesWrap(rectLeft, rectRight, contentWidth)) ({leftMargin, rightMargin} = largestSideMargins(rectLeft, rectRight, contentWidth));
|
|
46
|
+
else if (rect.side === "left") leftMargin = leftObjectMargin(rectRight);
|
|
47
|
+
else rightMargin = rightObjectMargin(rectLeft, contentWidth);
|
|
48
|
+
const clamped = clampFloatingWrapMargins(leftMargin, rightMargin, contentWidth);
|
|
49
|
+
return {
|
|
50
|
+
leftMargin: clamped.leftMargin,
|
|
51
|
+
rightMargin: clamped.rightMargin,
|
|
52
|
+
topY: rectTop,
|
|
53
|
+
bottomY: rectBottom
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Effective horizontal text width for a line under the given margins.
|
|
59
|
+
* When the zone provides split segments (centered both-sides wrap), each
|
|
60
|
+
* segment is clipped against `leftMargin`/`rightMargin` so a side float
|
|
61
|
+
* overlapping vertically with the centered float still reduces the budget.
|
|
62
|
+
* Otherwise falls back to `baseWidth - leftMargin - rightMargin`.
|
|
63
|
+
*/
|
|
64
|
+
function getFloatingAvailableWidth(margins, baseWidth) {
|
|
65
|
+
if (margins.segments?.length) {
|
|
66
|
+
const leftLimit = margins.leftMargin;
|
|
67
|
+
const rightLimit = baseWidth - margins.rightMargin;
|
|
68
|
+
let total = 0;
|
|
69
|
+
for (const segment of margins.segments) {
|
|
70
|
+
const start = Math.max(segment.leftOffset, leftLimit);
|
|
71
|
+
const end = Math.min(segment.leftOffset + segment.availableWidth, rightLimit);
|
|
72
|
+
total += Math.max(0, end - start);
|
|
73
|
+
}
|
|
74
|
+
return total;
|
|
75
|
+
}
|
|
76
|
+
return baseWidth - margins.leftMargin - margins.rightMargin;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Calculate width reduction for a line based on floating object zones.
|
|
80
|
+
* Returns the left and right margins (plus optional segments) that apply
|
|
81
|
+
* at this vertical position.
|
|
82
|
+
*/
|
|
83
|
+
function getFloatingMargins(lineY, lineHeight, zones, paragraphYOffset) {
|
|
84
|
+
if (!zones || zones.length === 0) return {
|
|
85
|
+
leftMargin: 0,
|
|
86
|
+
rightMargin: 0
|
|
87
|
+
};
|
|
88
|
+
let leftMargin = 0;
|
|
89
|
+
let rightMargin = 0;
|
|
90
|
+
let segments;
|
|
91
|
+
const absoluteLineTop = paragraphYOffset + lineY;
|
|
92
|
+
const absoluteLineBottom = absoluteLineTop + lineHeight;
|
|
93
|
+
for (const zone of zones) {
|
|
94
|
+
if (absoluteLineBottom <= zone.topY || absoluteLineTop >= zone.bottomY) continue;
|
|
95
|
+
if (zone.fullWidthBlock) return {
|
|
96
|
+
leftMargin: 0,
|
|
97
|
+
rightMargin: 0,
|
|
98
|
+
segments: [{
|
|
99
|
+
leftOffset: 0,
|
|
100
|
+
availableWidth: 0
|
|
101
|
+
}]
|
|
102
|
+
};
|
|
103
|
+
if (zone.segments?.length) {
|
|
104
|
+
segments = segments ? intersectSegments(segments, zone.segments) : zone.segments;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
leftMargin = Math.max(leftMargin, zone.leftMargin);
|
|
108
|
+
rightMargin = Math.max(rightMargin, zone.rightMargin);
|
|
109
|
+
}
|
|
110
|
+
if (segments) return {
|
|
111
|
+
leftMargin,
|
|
112
|
+
rightMargin,
|
|
113
|
+
segments
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
leftMargin,
|
|
117
|
+
rightMargin
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function intersectSegments(a, b) {
|
|
121
|
+
const result = [];
|
|
122
|
+
for (const left of a) for (const right of b) {
|
|
123
|
+
const start = Math.max(left.leftOffset, right.leftOffset);
|
|
124
|
+
const end = Math.min(left.leftOffset + left.availableWidth, right.leftOffset + right.availableWidth);
|
|
125
|
+
if (end > start) result.push({
|
|
126
|
+
leftOffset: start,
|
|
127
|
+
availableWidth: end - start
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
function canSplitCenteredBothSidesWrap(rectLeft, rectRight, contentWidth) {
|
|
133
|
+
return rectLeft > 0 && rectRight < contentWidth;
|
|
134
|
+
}
|
|
135
|
+
function largestSideMargins(rectLeft, rectRight, contentWidth) {
|
|
136
|
+
const leftWidth = Math.max(0, rectLeft);
|
|
137
|
+
return Math.max(0, contentWidth - rectRight) >= leftWidth ? {
|
|
138
|
+
leftMargin: leftObjectMargin(rectRight),
|
|
139
|
+
rightMargin: 0
|
|
140
|
+
} : {
|
|
141
|
+
leftMargin: 0,
|
|
142
|
+
rightMargin: rightObjectMargin(rectLeft, contentWidth)
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function leftObjectMargin(rectRight) {
|
|
146
|
+
return Math.max(0, rectRight);
|
|
147
|
+
}
|
|
148
|
+
function rightObjectMargin(rectLeft, contentWidth) {
|
|
149
|
+
return Math.max(0, contentWidth - rectLeft);
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
export { getFloatingAvailableWidth, getFloatingMargins, rectsToFloatingZones };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MeasureWorkerRequest, MeasureWorkerResponse } from "./measureWorkerProtocol.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-engine/measure/font-metrics.worker.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Test-only: reset the cached OffscreenCanvas context. Used by unit
|
|
6
|
+
* tests that toggle the global `OffscreenCanvas` between cases. The
|
|
7
|
+
* worker itself never needs this — its lifetime is one tab.
|
|
8
|
+
*/
|
|
9
|
+
declare function __resetWorkerCtxForTests(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Pure-function entry point. Exported so tests can exercise the worker
|
|
12
|
+
* contract without spawning a real `Worker`. Production code only
|
|
13
|
+
* reaches this via `postMessage`.
|
|
14
|
+
*/
|
|
15
|
+
declare function handleMeasureRequest(req: MeasureWorkerRequest): MeasureWorkerResponse;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { __resetWorkerCtxForTests, handleMeasureRequest };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { WORKER_FONT_FINGERPRINT_TEXT, countCodePoints } from "./measureWorkerProtocol.js";
|
|
2
|
+
import { TaggedError } from "better-result";
|
|
3
|
+
//#region src/layout-engine/measure/font-metrics.worker.ts
|
|
4
|
+
/**
|
|
5
|
+
* Web Worker entry for off-main-thread text-width measurement.
|
|
6
|
+
*
|
|
7
|
+
* The worker holds a single `OffscreenCanvas` 2D context and answers
|
|
8
|
+
* batched `measure` requests. It is a pure function over its inputs —
|
|
9
|
+
* no cache and no font-loading orchestration. The main thread owns all
|
|
10
|
+
* of that.
|
|
11
|
+
*
|
|
12
|
+
* On any failure (no `OffscreenCanvas`, no 2D context), it replies with
|
|
13
|
+
* `ok: false` so the proxy disables itself for the session and every
|
|
14
|
+
* future read falls back to the main-thread canvas.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: this file runs in worker scope. It must not import anything
|
|
17
|
+
* that touches `document`, `window`, or React. The protocol module is
|
|
18
|
+
* deliberately dependency-free.
|
|
19
|
+
*/
|
|
20
|
+
var WorkerInitError = class extends TaggedError("WorkerInitError")() {};
|
|
21
|
+
let ctx = null;
|
|
22
|
+
let initError = null;
|
|
23
|
+
const FONT_FINGERPRINT_EPSILON = .01;
|
|
24
|
+
function getCtx() {
|
|
25
|
+
if (ctx !== null) return ctx;
|
|
26
|
+
if (initError !== null) throw new WorkerInitError({ message: initError });
|
|
27
|
+
if (typeof OffscreenCanvas === "undefined") {
|
|
28
|
+
initError = "OffscreenCanvas not available in worker scope";
|
|
29
|
+
throw new WorkerInitError({ message: initError });
|
|
30
|
+
}
|
|
31
|
+
const next = new OffscreenCanvas(1, 1).getContext("2d");
|
|
32
|
+
if (next === null) {
|
|
33
|
+
initError = "Failed to acquire OffscreenCanvas 2D context";
|
|
34
|
+
throw new WorkerInitError({ message: initError });
|
|
35
|
+
}
|
|
36
|
+
ctx = next;
|
|
37
|
+
return ctx;
|
|
38
|
+
}
|
|
39
|
+
function isFontFingerprintMatch(context, expectedWidth) {
|
|
40
|
+
const actualWidth = context.measureText(WORKER_FONT_FINGERPRINT_TEXT).width;
|
|
41
|
+
const tolerance = Math.max(FONT_FINGERPRINT_EPSILON, expectedWidth * 1e-4);
|
|
42
|
+
return Math.abs(actualWidth - expectedWidth) <= tolerance;
|
|
43
|
+
}
|
|
44
|
+
function measureEntry(entry) {
|
|
45
|
+
const context = getCtx();
|
|
46
|
+
context.font = entry.font;
|
|
47
|
+
if (!isFontFingerprintMatch(context, entry.fontFingerprintWidth)) return null;
|
|
48
|
+
let width = context.measureText(entry.text).width;
|
|
49
|
+
const codePoints = countCodePoints(entry.text);
|
|
50
|
+
if (entry.letterSpacing !== 0 && codePoints > 1) width += entry.letterSpacing * (codePoints - 1);
|
|
51
|
+
width *= entry.horizontalScale;
|
|
52
|
+
return {
|
|
53
|
+
text: entry.text,
|
|
54
|
+
fontCacheKey: entry.fontCacheKey,
|
|
55
|
+
letterSpacing: entry.letterSpacing,
|
|
56
|
+
width
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Test-only: reset the cached OffscreenCanvas context. Used by unit
|
|
61
|
+
* tests that toggle the global `OffscreenCanvas` between cases. The
|
|
62
|
+
* worker itself never needs this — its lifetime is one tab.
|
|
63
|
+
*/
|
|
64
|
+
function __resetWorkerCtxForTests() {
|
|
65
|
+
ctx = null;
|
|
66
|
+
initError = null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Pure-function entry point. Exported so tests can exercise the worker
|
|
70
|
+
* contract without spawning a real `Worker`. Production code only
|
|
71
|
+
* reaches this via `postMessage`.
|
|
72
|
+
*/
|
|
73
|
+
function handleMeasureRequest(req) {
|
|
74
|
+
try {
|
|
75
|
+
const entries = [];
|
|
76
|
+
for (const entry of req.entries) {
|
|
77
|
+
const measured = measureEntry(entry);
|
|
78
|
+
if (measured !== null) entries.push(measured);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
type: "measure-result",
|
|
82
|
+
id: req.id,
|
|
83
|
+
ok: true,
|
|
84
|
+
entries
|
|
85
|
+
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
return {
|
|
89
|
+
type: "measure-result",
|
|
90
|
+
id: req.id,
|
|
91
|
+
ok: false,
|
|
92
|
+
error: message
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (typeof self !== "undefined" && typeof addEventListener === "function") {
|
|
97
|
+
const workerScope = self;
|
|
98
|
+
addEventListener("message", (event) => {
|
|
99
|
+
const reply = handleMeasureRequest(event.data);
|
|
100
|
+
workerScope.postMessage(reply);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { __resetWorkerCtxForTests, handleMeasureRequest };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FontMetrics, FontStyle, RunMeasurement, TextMeasurement } from "./measureTypes.js";
|
|
2
|
+
import { MeasureProvider, getFontMetrics, getMeasureProvider, measureRun, measureText, measureTextWidth, resetMeasureProvider, setMeasureProvider } from "./measureProvider.js";
|
|
3
|
+
import { buildFontString, findCharacterAtX, getXForCharacter, halfPtToPx, ptToPx, pxToHalfPt, pxToPt, pxToTwips, twipsToPx } from "./measureHelpers.js";
|
|
4
|
+
import { FloatingExclusionRect, FloatingImageZone, FloatingLineMargins, FloatingLineSegmentZone, WrapTextDirection, getFloatingAvailableWidth, getFloatingMargins, rectsToFloatingZones } from "./floatingZones.js";
|
|
5
|
+
import { clampFloatingWrapMargins } from "./clampFloatingWrapMargins.js";
|
|
6
|
+
import { MeasureParagraphOptions, getRunCharWidths, measureParagraph, measureParagraphs } from "./measureParagraph.js";
|
|
7
|
+
import { clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFontCacheSize, getParagraphCacheSize, getTextCacheSize, getTotalCacheSize, hashParagraphBlock, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFontCacheSize, setParagraphCacheSize, setTextCacheSize } from "./cache.js";
|
|
8
|
+
import { FolioMeasurementFeatureFlags, isWorkerFontMetricsEnabled, setFolioMeasurementFlags } from "./featureFlags.js";
|
|
9
|
+
export { type FloatingExclusionRect, type FloatingImageZone, type FloatingLineMargins, type FloatingLineSegmentZone, type FolioMeasurementFeatureFlags, type FontMetrics, type FontStyle, type MeasureParagraphOptions, type MeasureProvider, type RunMeasurement, type TextMeasurement, type WrapTextDirection, buildFontString, clampFloatingWrapMargins, clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, findCharacterAtX, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFloatingAvailableWidth, getFloatingMargins, getFontCacheSize, getFontMetrics, getMeasureProvider, getParagraphCacheSize, getRunCharWidths, getTextCacheSize, getTotalCacheSize, getXForCharacter, halfPtToPx, hashParagraphBlock, isWorkerFontMetricsEnabled, measureParagraph, measureParagraphs, measureRun, measureText, measureTextWidth, ptToPx, pxToHalfPt, pxToPt, pxToTwips, rectsToFloatingZones, resetMeasureProvider, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFolioMeasurementFlags, setFontCacheSize, setMeasureProvider, setParagraphCacheSize, setTextCacheSize, twipsToPx };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getFontMetrics, getMeasureProvider, measureRun, measureText, measureTextWidth, resetMeasureProvider, setMeasureProvider } from "./measureProvider.js";
|
|
2
|
+
import { buildFontString, findCharacterAtX, getXForCharacter, halfPtToPx, ptToPx, pxToHalfPt, pxToPt, pxToTwips, twipsToPx } from "./measureHelpers.js";
|
|
3
|
+
import { clampFloatingWrapMargins } from "./clampFloatingWrapMargins.js";
|
|
4
|
+
import { getFloatingAvailableWidth, getFloatingMargins, rectsToFloatingZones } from "./floatingZones.js";
|
|
5
|
+
import { getRunCharWidths, measureParagraph, measureParagraphs } from "./measureParagraph.js";
|
|
6
|
+
import { clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFontCacheSize, getParagraphCacheSize, getTextCacheSize, getTotalCacheSize, hashParagraphBlock, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFontCacheSize, setParagraphCacheSize, setTextCacheSize } from "./cache.js";
|
|
7
|
+
import { isWorkerFontMetricsEnabled, setFolioMeasurementFlags } from "./featureFlags.js";
|
|
8
|
+
export { buildFontString, clampFloatingWrapMargins, clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, findCharacterAtX, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFloatingAvailableWidth, getFloatingMargins, getFontCacheSize, getFontMetrics, getMeasureProvider, getParagraphCacheSize, getRunCharWidths, getTextCacheSize, getTotalCacheSize, getXForCharacter, halfPtToPx, hashParagraphBlock, isWorkerFontMetricsEnabled, measureParagraph, measureParagraphs, measureRun, measureText, measureTextWidth, ptToPx, pxToHalfPt, pxToPt, pxToTwips, rectsToFloatingZones, resetMeasureProvider, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFolioMeasurementFlags, setFontCacheSize, setMeasureProvider, setParagraphCacheSize, setTextCacheSize, twipsToPx };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ParagraphBlock } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-engine/measure/listMarkerWidth.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* OOXML default `w:defaultTabStop` (§17.6.13) when settings.xml omits it.
|
|
6
|
+
* 720 twips = 0.5 inch = 48 CSS px at 96 DPI. Folio doesn't currently parse
|
|
7
|
+
* settings.xml; documents that override this fall back to the OOXML default.
|
|
8
|
+
*/
|
|
9
|
+
declare const DEFAULT_TAB_STOP_TWIPS = 720;
|
|
10
|
+
/**
|
|
11
|
+
* Marker font resolution per ECMA-376 §17.9.6:
|
|
12
|
+
* 1. explicit numbering-level rPr (`attrs.listMarkerFont*`),
|
|
13
|
+
* 2. first body text run's font,
|
|
14
|
+
* 3. paragraph defaults, then document defaults.
|
|
15
|
+
*/
|
|
16
|
+
declare function resolveListMarkerFont(block: ParagraphBlock): {
|
|
17
|
+
fontFamily: string;
|
|
18
|
+
fontSize: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Compute the marker's inline-block width in pixels, or 0 if the paragraph
|
|
22
|
+
* has no rendered marker.
|
|
23
|
+
*
|
|
24
|
+
* Honors:
|
|
25
|
+
* - hanging indent — body wraps at `indentLeft`, marker sits at
|
|
26
|
+
* `indentLeft - hanging`. Width is `hanging` so the marker fills the slot.
|
|
27
|
+
* - `w:suff` (§17.9.25): `nothing` → natural width, `space` → natural +
|
|
28
|
+
* one space glyph, `tab` (default) → grow to the next tab stop.
|
|
29
|
+
* - `w:tabs` on the paragraph: non-`clear`/non-`bar` stops past the marker.
|
|
30
|
+
* `bar` (§17.3.1.37) is a vertical line and doesn't advance the cursor.
|
|
31
|
+
* - default tab grid: stops at multiples of `DEFAULT_TAB_STOP_TWIPS`,
|
|
32
|
+
* anchored at 0 (start of body content area, NOT `w:ind`).
|
|
33
|
+
*
|
|
34
|
+
* Word interleaves the two — both custom tabs and default-grid stops are
|
|
35
|
+
* candidates; the closest stop past the marker wins (§17.6.13: the default
|
|
36
|
+
* grid is not erased by custom tabs, just augmented).
|
|
37
|
+
*/
|
|
38
|
+
declare function getListMarkerInlineWidth(block: ParagraphBlock): number;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { DEFAULT_TAB_STOP_TWIPS, getListMarkerInlineWidth, resolveListMarkerFont };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { measureTextWidth } from "./measureProvider.js";
|
|
2
|
+
import { ptToPx } from "./measureHelpers.js";
|
|
3
|
+
//#region src/layout-engine/measure/listMarkerWidth.ts
|
|
4
|
+
const DEFAULT_FONT_FAMILY = "Calibri";
|
|
5
|
+
const DEFAULT_FONT_SIZE = 11;
|
|
6
|
+
/**
|
|
7
|
+
* OOXML default `w:defaultTabStop` (§17.6.13) when settings.xml omits it.
|
|
8
|
+
* 720 twips = 0.5 inch = 48 CSS px at 96 DPI. Folio doesn't currently parse
|
|
9
|
+
* settings.xml; documents that override this fall back to the OOXML default.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_TAB_STOP_TWIPS = 720;
|
|
12
|
+
const TWIPS_TO_PX = 96 / 1440;
|
|
13
|
+
/**
|
|
14
|
+
* Marker font resolution per ECMA-376 §17.9.6:
|
|
15
|
+
* 1. explicit numbering-level rPr (`attrs.listMarkerFont*`),
|
|
16
|
+
* 2. first body text run's font,
|
|
17
|
+
* 3. paragraph defaults, then document defaults.
|
|
18
|
+
*/
|
|
19
|
+
function resolveListMarkerFont(block) {
|
|
20
|
+
const attrs = block.attrs;
|
|
21
|
+
const firstTextRun = block.runs.find((r) => r.kind === "text");
|
|
22
|
+
return {
|
|
23
|
+
fontFamily: attrs?.listMarkerFontFamily ?? firstTextRun?.fontFamily ?? attrs?.defaultFontFamily ?? DEFAULT_FONT_FAMILY,
|
|
24
|
+
fontSize: attrs?.listMarkerFontSize ?? firstTextRun?.fontSize ?? attrs?.defaultFontSize ?? DEFAULT_FONT_SIZE
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compute the marker's inline-block width in pixels, or 0 if the paragraph
|
|
29
|
+
* has no rendered marker.
|
|
30
|
+
*
|
|
31
|
+
* Honors:
|
|
32
|
+
* - hanging indent — body wraps at `indentLeft`, marker sits at
|
|
33
|
+
* `indentLeft - hanging`. Width is `hanging` so the marker fills the slot.
|
|
34
|
+
* - `w:suff` (§17.9.25): `nothing` → natural width, `space` → natural +
|
|
35
|
+
* one space glyph, `tab` (default) → grow to the next tab stop.
|
|
36
|
+
* - `w:tabs` on the paragraph: non-`clear`/non-`bar` stops past the marker.
|
|
37
|
+
* `bar` (§17.3.1.37) is a vertical line and doesn't advance the cursor.
|
|
38
|
+
* - default tab grid: stops at multiples of `DEFAULT_TAB_STOP_TWIPS`,
|
|
39
|
+
* anchored at 0 (start of body content area, NOT `w:ind`).
|
|
40
|
+
*
|
|
41
|
+
* Word interleaves the two — both custom tabs and default-grid stops are
|
|
42
|
+
* candidates; the closest stop past the marker wins (§17.6.13: the default
|
|
43
|
+
* grid is not erased by custom tabs, just augmented).
|
|
44
|
+
*/
|
|
45
|
+
function getListMarkerInlineWidth(block) {
|
|
46
|
+
const attrs = block.attrs;
|
|
47
|
+
if (!attrs?.listMarker || attrs.listMarkerHidden) return 0;
|
|
48
|
+
const { fontFamily, fontSize } = resolveListMarkerFont(block);
|
|
49
|
+
const style = {
|
|
50
|
+
fontFamily,
|
|
51
|
+
fontSize
|
|
52
|
+
};
|
|
53
|
+
const naturalWidth = measureTextWidth(attrs.listMarker, style);
|
|
54
|
+
const suffix = attrs.listMarkerSuffix ?? "tab";
|
|
55
|
+
if (suffix === "nothing") return naturalWidth;
|
|
56
|
+
if (suffix === "space") return naturalWidth + measureTextWidth(" ", style);
|
|
57
|
+
const indent = attrs.indent;
|
|
58
|
+
const indentLeft = indent?.left ?? 0;
|
|
59
|
+
const firstLine = indent?.firstLine ?? 0;
|
|
60
|
+
const hanging = indent?.hanging ?? 0;
|
|
61
|
+
const markerStartPx = hanging > 0 ? indentLeft - hanging : indentLeft + firstLine;
|
|
62
|
+
const minBodyStart = markerStartPx + naturalWidth;
|
|
63
|
+
const customTabs = (attrs.tabs ?? []).filter((t) => t.val !== "clear" && t.val !== "bar").map((t) => t.pos * TWIPS_TO_PX);
|
|
64
|
+
if (hanging > 0) customTabs.push(indentLeft);
|
|
65
|
+
const searchStart = hanging > 0 ? Math.max(minBodyStart, indentLeft) : minBodyStart;
|
|
66
|
+
const firstCustomPast = customTabs.filter((px) => px >= searchStart).sort((a, b) => a - b)[0];
|
|
67
|
+
const defaultTabStopPx = (attrs.defaultTabStopTwips ?? 720) * TWIPS_TO_PX;
|
|
68
|
+
const firstGridPast = defaultTabStopPx > 0 ? Math.ceil(searchStart / defaultTabStopPx) * defaultTabStopPx : void 0;
|
|
69
|
+
let bodyStart;
|
|
70
|
+
if (firstCustomPast !== void 0 && firstGridPast !== void 0) bodyStart = Math.min(firstCustomPast, firstGridPast);
|
|
71
|
+
else bodyStart = firstCustomPast ?? firstGridPast;
|
|
72
|
+
if (bodyStart === void 0) return naturalWidth + ptToPx(fontSize) * .5;
|
|
73
|
+
return bodyStart - markerStartPx;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { DEFAULT_TAB_STOP_TWIPS, getListMarkerInlineWidth, resolveListMarkerFont };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FlowBlock, Measure, TableBlock, TableMeasure, TextBoxBlock, TextBoxMeasure } from "../types.js";
|
|
2
|
+
import { FloatingImageZone } from "./floatingZones.js";
|
|
3
|
+
//#region src/layout-engine/measure/measureBlocks.d.ts
|
|
4
|
+
declare function measureTableCellBlockVisualHeight(block: FlowBlock, blockMeasure: Measure): number;
|
|
5
|
+
declare function measureTableBlock(tableBlock: TableBlock, contentWidth: number, fieldValues?: ReadonlyMap<number, string>): TableMeasure;
|
|
6
|
+
type BandPageGeometry = {
|
|
7
|
+
pageHeight: number | number[];
|
|
8
|
+
marginBottom: number | number[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Measure a block based on its type.
|
|
12
|
+
*/
|
|
13
|
+
declare function measureBlock(block: FlowBlock, contentWidth: number, floatingZones?: FloatingImageZone[], cumulativeY?: number, fieldValues?: ReadonlyMap<number, string>): Measure;
|
|
14
|
+
declare function measureTextBoxBlock(tb: TextBoxBlock, fieldValues?: ReadonlyMap<number, string>): TextBoxMeasure;
|
|
15
|
+
/**
|
|
16
|
+
* Measure all blocks with floating image support.
|
|
17
|
+
*
|
|
18
|
+
* Pre-scans all blocks to find floating images and creates exclusion zones.
|
|
19
|
+
* Then measures each block, passing the zones so paragraphs can calculate
|
|
20
|
+
* per-line widths based on vertical overlap with floating images.
|
|
21
|
+
*/
|
|
22
|
+
declare function measureBlocks(blocks: FlowBlock[], contentWidth: number | number[], marginTop?: number | number[], pageGeometry?: BandPageGeometry, fieldValues?: ReadonlyMap<number, string>): Measure[];
|
|
23
|
+
declare function measureSingleBlockWithoutFloatingZones(block: FlowBlock, blockWidth: number, blockIndex: number): Measure;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { measureBlock, measureBlocks, measureSingleBlockWithoutFloatingZones, measureTableBlock, measureTableCellBlockVisualHeight, measureTextBoxBlock };
|