@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,135 @@
|
|
|
1
|
+
import { FlowBlock, Fragment, Layout, Measure, Page, ParagraphBlock, ParagraphMeasure, TableBlock, TableFragment, TableMeasure } from "../../layout-engine/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-bridge/engine/hitTest.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A 2D point in page coordinate space.
|
|
6
|
+
*/
|
|
7
|
+
type Point = {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Result of hit-testing to find which page contains a point.
|
|
13
|
+
*/
|
|
14
|
+
type PageHit = {
|
|
15
|
+
/** Index of the page (0-based). */pageIndex: number; /** The page that was hit. */
|
|
16
|
+
page: Page; /** Y position relative to the page top. */
|
|
17
|
+
pageY: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Result of hit-testing to find which fragment contains a point.
|
|
21
|
+
*/
|
|
22
|
+
type FragmentHit = {
|
|
23
|
+
/** The fragment that was hit. */fragment: Fragment; /** The corresponding flow block. */
|
|
24
|
+
block: FlowBlock; /** The corresponding measurement. */
|
|
25
|
+
measure: Measure; /** Page index (0-based). */
|
|
26
|
+
pageIndex: number; /** Y position relative to the fragment top. */
|
|
27
|
+
localY: number; /** X position relative to the fragment left. */
|
|
28
|
+
localX: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Result of hit-testing a table to find the cell.
|
|
32
|
+
*/
|
|
33
|
+
type TableCellHit = {
|
|
34
|
+
/** The table fragment. */fragment: TableFragment; /** The table block. */
|
|
35
|
+
block: TableBlock; /** The table measure. */
|
|
36
|
+
measure: TableMeasure; /** Page index (0-based). */
|
|
37
|
+
pageIndex: number; /** Row index (0-based). */
|
|
38
|
+
rowIndex: number; /** Column index (0-based). */
|
|
39
|
+
colIndex: number; /** Paragraph block within the cell (first one). */
|
|
40
|
+
cellBlock?: ParagraphBlock; /** Paragraph measure within the cell. */
|
|
41
|
+
cellMeasure?: ParagraphMeasure; /** X position relative to cell content area. */
|
|
42
|
+
cellLocalX: number; /** Y position relative to cell content area. */
|
|
43
|
+
cellLocalY: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Hit-test pages to find which page contains a given Y coordinate.
|
|
47
|
+
*
|
|
48
|
+
* Pages are stacked vertically with optional gaps between them.
|
|
49
|
+
* If the point is in a gap, returns the nearest page.
|
|
50
|
+
*
|
|
51
|
+
* @param layout - The layout containing pages.
|
|
52
|
+
* @param point - The point to test (only Y is used for page lookup).
|
|
53
|
+
* @returns PageHit if a page was found, null otherwise.
|
|
54
|
+
*/
|
|
55
|
+
declare function hitTestPage(layout: Layout, point: Point): PageHit | null;
|
|
56
|
+
/**
|
|
57
|
+
* Calculate the Y offset of a page from the top of the document.
|
|
58
|
+
*/
|
|
59
|
+
declare function getPageTop(layout: Layout, pageIndex: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* Get the page index at a specific Y coordinate.
|
|
62
|
+
* Returns null if the coordinate is outside all pages.
|
|
63
|
+
*/
|
|
64
|
+
declare function getPageIndexAtY(layout: Layout, y: number): number | null;
|
|
65
|
+
/**
|
|
66
|
+
* Hit-test fragments on a page to find which fragment contains a point.
|
|
67
|
+
*
|
|
68
|
+
* Fragments are checked in visual order (sorted by Y then X).
|
|
69
|
+
* Only considers paragraph and table fragments (not images for now).
|
|
70
|
+
*
|
|
71
|
+
* @param pageHit - The page hit result from hitTestPage.
|
|
72
|
+
* @param blocks - All flow blocks in the document.
|
|
73
|
+
* @param measures - All measurements corresponding to blocks.
|
|
74
|
+
* @param pagePoint - Point in page-relative coordinates.
|
|
75
|
+
* @returns FragmentHit if a fragment was found, null otherwise.
|
|
76
|
+
*/
|
|
77
|
+
declare function hitTestFragment(pageHit: PageHit, blocks: FlowBlock[], measures: Measure[], pagePoint: Point): FragmentHit | null;
|
|
78
|
+
/**
|
|
79
|
+
* Hit-test to find image fragments (they may overlap other content).
|
|
80
|
+
*/
|
|
81
|
+
declare function hitTestImageFragment(pageHit: PageHit, blocks: FlowBlock[], measures: Measure[], pagePoint: Point): FragmentHit | null;
|
|
82
|
+
/**
|
|
83
|
+
* Hit-test within a table fragment to find the specific cell.
|
|
84
|
+
*
|
|
85
|
+
* @param pageHit - The page hit result.
|
|
86
|
+
* @param blocks - All flow blocks.
|
|
87
|
+
* @param measures - All measurements.
|
|
88
|
+
* @param pagePoint - Point in page-relative coordinates.
|
|
89
|
+
* @returns TableCellHit if a table cell was found, null otherwise.
|
|
90
|
+
*/
|
|
91
|
+
declare function hitTestTableCell(pageHit: PageHit, blocks: FlowBlock[], measures: Measure[], pagePoint: Point): TableCellHit | null;
|
|
92
|
+
/**
|
|
93
|
+
* Combined result of all hit testing.
|
|
94
|
+
*/
|
|
95
|
+
type HitTestResult = {
|
|
96
|
+
/** Page that was hit. */pageHit: PageHit | null; /** Fragment that was hit (if any). */
|
|
97
|
+
fragmentHit: FragmentHit | null; /** Table cell that was hit (if fragment is a table). */
|
|
98
|
+
tableCellHit: TableCellHit | null;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Perform complete hit testing from document coordinates to the most specific element.
|
|
102
|
+
*
|
|
103
|
+
* @param layout - The layout containing pages.
|
|
104
|
+
* @param blocks - All flow blocks.
|
|
105
|
+
* @param measures - All measurements.
|
|
106
|
+
* @param point - Point in document coordinates (Y is cumulative from document top).
|
|
107
|
+
* @returns Complete hit test result.
|
|
108
|
+
*/
|
|
109
|
+
declare function hitTest(layout: Layout, blocks: FlowBlock[], measures: Measure[], point: Point): HitTestResult;
|
|
110
|
+
/**
|
|
111
|
+
* Get the total document height (all pages + gaps).
|
|
112
|
+
*/
|
|
113
|
+
declare function getTotalDocumentHeight(layout: Layout): number;
|
|
114
|
+
/**
|
|
115
|
+
* Get Y coordinate to scroll to for a specific page.
|
|
116
|
+
*/
|
|
117
|
+
declare function getScrollYForPage(layout: Layout, pageIndex: number): number;
|
|
118
|
+
/**
|
|
119
|
+
* Get page bounds (top and bottom Y coordinates).
|
|
120
|
+
*/
|
|
121
|
+
declare function getPageBounds(layout: Layout, pageIndex: number): {
|
|
122
|
+
top: number;
|
|
123
|
+
bottom: number;
|
|
124
|
+
} | null;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a point is within the content area of a page (inside margins).
|
|
127
|
+
*/
|
|
128
|
+
declare function isPointInContentArea(_layout: Layout, pageHit: PageHit, pagePoint: Point): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Find the nearest fragment to a point on a page.
|
|
131
|
+
* Useful when the click is in whitespace.
|
|
132
|
+
*/
|
|
133
|
+
declare function findNearestFragment(pageHit: PageHit, blocks: FlowBlock[], measures: Measure[], pagePoint: Point): FragmentHit | null;
|
|
134
|
+
//#endregion
|
|
135
|
+
export { FragmentHit, HitTestResult, PageHit, Point, TableCellHit, findNearestFragment, getPageBounds, getPageIndexAtY, getPageTop, getScrollYForPage, getTotalDocumentHeight, hitTest, hitTestFragment, hitTestImageFragment, hitTestPage, hitTestTableCell, isPointInContentArea };
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { measuredLineRangeHeight } from "../../layout-engine/lineFlow.js";
|
|
2
|
+
import { getHeaderRowsHeight } from "../../layout-engine/index.js";
|
|
3
|
+
//#region src/layout-bridge/engine/hitTest.ts
|
|
4
|
+
/**
|
|
5
|
+
* Hit Testing Utilities
|
|
6
|
+
*
|
|
7
|
+
* Maps click coordinates to pages, fragments, and document positions.
|
|
8
|
+
* Used by the paged editor to translate user clicks into PM positions.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Hit-test pages to find which page contains a given Y coordinate.
|
|
12
|
+
*
|
|
13
|
+
* Pages are stacked vertically with optional gaps between them.
|
|
14
|
+
* If the point is in a gap, returns the nearest page.
|
|
15
|
+
*
|
|
16
|
+
* @param layout - The layout containing pages.
|
|
17
|
+
* @param point - The point to test (only Y is used for page lookup).
|
|
18
|
+
* @returns PageHit if a page was found, null otherwise.
|
|
19
|
+
*/
|
|
20
|
+
function hitTestPage(layout, point) {
|
|
21
|
+
if (layout.pages.length === 0) return null;
|
|
22
|
+
const pageGap = layout.pageGap ?? 0;
|
|
23
|
+
let cursorY = 0;
|
|
24
|
+
let nearestPageIndex = null;
|
|
25
|
+
let nearestDistance = Infinity;
|
|
26
|
+
for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex++) {
|
|
27
|
+
const page = layout.pages[pageIndex];
|
|
28
|
+
const pageHeight = page.size.h;
|
|
29
|
+
const pageTop = cursorY;
|
|
30
|
+
const pageBottom = pageTop + pageHeight;
|
|
31
|
+
if (point.y >= pageTop && point.y < pageBottom) return {
|
|
32
|
+
pageIndex,
|
|
33
|
+
page,
|
|
34
|
+
pageY: point.y - pageTop
|
|
35
|
+
};
|
|
36
|
+
const pageCenter = pageTop + pageHeight / 2;
|
|
37
|
+
const distance = Math.abs(point.y - pageCenter);
|
|
38
|
+
if (distance < nearestDistance) {
|
|
39
|
+
nearestDistance = distance;
|
|
40
|
+
nearestPageIndex = pageIndex;
|
|
41
|
+
}
|
|
42
|
+
cursorY = pageBottom + pageGap;
|
|
43
|
+
}
|
|
44
|
+
if (nearestPageIndex !== null) {
|
|
45
|
+
const page = layout.pages[nearestPageIndex];
|
|
46
|
+
const pageTop = getPageTop(layout, nearestPageIndex);
|
|
47
|
+
return {
|
|
48
|
+
pageIndex: nearestPageIndex,
|
|
49
|
+
page,
|
|
50
|
+
pageY: Math.max(0, Math.min(point.y - pageTop, page.size.h))
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Calculate the Y offset of a page from the top of the document.
|
|
57
|
+
*/
|
|
58
|
+
function getPageTop(layout, pageIndex) {
|
|
59
|
+
const pageGap = layout.pageGap ?? 0;
|
|
60
|
+
let y = 0;
|
|
61
|
+
for (let i = 0; i < pageIndex && i < layout.pages.length; i++) {
|
|
62
|
+
const pageHeight = layout.pages[i].size.h;
|
|
63
|
+
y += pageHeight + pageGap;
|
|
64
|
+
}
|
|
65
|
+
return y;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the page index at a specific Y coordinate.
|
|
69
|
+
* Returns null if the coordinate is outside all pages.
|
|
70
|
+
*/
|
|
71
|
+
function getPageIndexAtY(layout, y) {
|
|
72
|
+
return hitTestPage(layout, {
|
|
73
|
+
x: 0,
|
|
74
|
+
y
|
|
75
|
+
})?.pageIndex ?? null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Find a block by its ID in the blocks array.
|
|
79
|
+
*/
|
|
80
|
+
function findBlockIndexById(blocks, blockId) {
|
|
81
|
+
return blocks.findIndex((block) => block.id === blockId);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Calculate the actual height of a paragraph fragment from its lines.
|
|
85
|
+
*/
|
|
86
|
+
function calculateParagraphFragmentHeight(fragment, measure) {
|
|
87
|
+
return measuredLineRangeHeight(measure.lines, fragment.fromLine, fragment.toLine);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Hit-test fragments on a page to find which fragment contains a point.
|
|
91
|
+
*
|
|
92
|
+
* Fragments are checked in visual order (sorted by Y then X).
|
|
93
|
+
* Only considers paragraph and table fragments (not images for now).
|
|
94
|
+
*
|
|
95
|
+
* @param pageHit - The page hit result from hitTestPage.
|
|
96
|
+
* @param blocks - All flow blocks in the document.
|
|
97
|
+
* @param measures - All measurements corresponding to blocks.
|
|
98
|
+
* @param pagePoint - Point in page-relative coordinates.
|
|
99
|
+
* @returns FragmentHit if a fragment was found, null otherwise.
|
|
100
|
+
*/
|
|
101
|
+
function hitTestFragment(pageHit, blocks, measures, pagePoint) {
|
|
102
|
+
const sortedFragments = [...pageHit.page.fragments].toSorted((a, b) => {
|
|
103
|
+
const dy = a.y - b.y;
|
|
104
|
+
if (Math.abs(dy) > .5) return dy;
|
|
105
|
+
return a.x - b.x;
|
|
106
|
+
});
|
|
107
|
+
for (const fragment of sortedFragments) {
|
|
108
|
+
const blockIndex = findBlockIndexById(blocks, fragment.blockId);
|
|
109
|
+
if (blockIndex === -1) continue;
|
|
110
|
+
const block = blocks[blockIndex];
|
|
111
|
+
const measure = measures[blockIndex];
|
|
112
|
+
if (!block || !measure) continue;
|
|
113
|
+
let fragmentHeight;
|
|
114
|
+
if (fragment.kind === "paragraph") {
|
|
115
|
+
if (block.kind !== "paragraph" || measure.kind !== "paragraph") continue;
|
|
116
|
+
fragmentHeight = calculateParagraphFragmentHeight(fragment, measure);
|
|
117
|
+
} else if (fragment.kind === "table") fragmentHeight = fragment.height;
|
|
118
|
+
else if (fragment.kind === "image") fragmentHeight = fragment.height;
|
|
119
|
+
else continue;
|
|
120
|
+
const withinX = pagePoint.x >= fragment.x && pagePoint.x <= fragment.x + fragment.width;
|
|
121
|
+
const withinY = pagePoint.y >= fragment.y && pagePoint.y <= fragment.y + fragmentHeight;
|
|
122
|
+
if (withinX && withinY) return {
|
|
123
|
+
fragment,
|
|
124
|
+
block,
|
|
125
|
+
measure,
|
|
126
|
+
pageIndex: pageHit.pageIndex,
|
|
127
|
+
localX: pagePoint.x - fragment.x,
|
|
128
|
+
localY: pagePoint.y - fragment.y
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Hit-test to find image fragments (they may overlap other content).
|
|
135
|
+
*/
|
|
136
|
+
function hitTestImageFragment(pageHit, blocks, measures, pagePoint) {
|
|
137
|
+
for (const fragment of pageHit.page.fragments) {
|
|
138
|
+
if (fragment.kind !== "image") continue;
|
|
139
|
+
const blockIndex = findBlockIndexById(blocks, fragment.blockId);
|
|
140
|
+
if (blockIndex === -1) continue;
|
|
141
|
+
const block = blocks[blockIndex];
|
|
142
|
+
const measure = measures[blockIndex];
|
|
143
|
+
if (!block || !measure) continue;
|
|
144
|
+
const withinX = pagePoint.x >= fragment.x && pagePoint.x <= fragment.x + fragment.width;
|
|
145
|
+
const withinY = pagePoint.y >= fragment.y && pagePoint.y <= fragment.y + fragment.height;
|
|
146
|
+
if (withinX && withinY) return {
|
|
147
|
+
fragment,
|
|
148
|
+
block,
|
|
149
|
+
measure,
|
|
150
|
+
pageIndex: pageHit.pageIndex,
|
|
151
|
+
localX: pagePoint.x - fragment.x,
|
|
152
|
+
localY: pagePoint.y - fragment.y
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Hit-test within a table fragment to find the specific cell.
|
|
159
|
+
*
|
|
160
|
+
* @param pageHit - The page hit result.
|
|
161
|
+
* @param blocks - All flow blocks.
|
|
162
|
+
* @param measures - All measurements.
|
|
163
|
+
* @param pagePoint - Point in page-relative coordinates.
|
|
164
|
+
* @returns TableCellHit if a table cell was found, null otherwise.
|
|
165
|
+
*/
|
|
166
|
+
function hitTestTableCell(pageHit, blocks, measures, pagePoint) {
|
|
167
|
+
for (const fragment of pageHit.page.fragments) {
|
|
168
|
+
if (fragment.kind !== "table") continue;
|
|
169
|
+
const tableFragment = fragment;
|
|
170
|
+
const withinX = pagePoint.x >= tableFragment.x && pagePoint.x <= tableFragment.x + tableFragment.width;
|
|
171
|
+
const withinY = pagePoint.y >= tableFragment.y && pagePoint.y <= tableFragment.y + tableFragment.height;
|
|
172
|
+
if (!withinX || !withinY) continue;
|
|
173
|
+
const blockIndex = findBlockIndexById(blocks, tableFragment.blockId);
|
|
174
|
+
if (blockIndex === -1) continue;
|
|
175
|
+
const block = blocks[blockIndex];
|
|
176
|
+
const measure = measures[blockIndex];
|
|
177
|
+
if (!block || block.kind !== "table" || !measure || measure.kind !== "table") continue;
|
|
178
|
+
const tableBlock = block;
|
|
179
|
+
const tableMeasure = measure;
|
|
180
|
+
const localX = pagePoint.x - tableFragment.x;
|
|
181
|
+
const localY = pagePoint.y - tableFragment.y;
|
|
182
|
+
const headerRowCount = tableFragment.headerRowCount ?? 0;
|
|
183
|
+
const headerHeight = headerRowCount > 0 && tableFragment.continuesFromPrev ? getHeaderRowsHeight(tableMeasure, headerRowCount) : 0;
|
|
184
|
+
let rowY = 0;
|
|
185
|
+
let rowIndex = -1;
|
|
186
|
+
if (tableMeasure.rows.length === 0 || tableBlock.rows.length === 0) continue;
|
|
187
|
+
if (headerHeight > 0 && localY < headerHeight) {
|
|
188
|
+
let hdrY = 0;
|
|
189
|
+
for (let h = 0; h < headerRowCount && h < tableMeasure.rows.length; h++) {
|
|
190
|
+
const hdrRowMeasure = tableMeasure.rows[h];
|
|
191
|
+
if (localY >= hdrY && localY < hdrY + hdrRowMeasure.height) {
|
|
192
|
+
rowIndex = h;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
hdrY += hdrRowMeasure.height;
|
|
196
|
+
}
|
|
197
|
+
if (rowIndex === -1) rowIndex = 0;
|
|
198
|
+
} else {
|
|
199
|
+
const adjustedLocalY = localY - headerHeight + (tableFragment.topClip ?? 0);
|
|
200
|
+
for (let r = tableFragment.fromRow; r < tableFragment.toRow && r < tableMeasure.rows.length; r++) {
|
|
201
|
+
const rowMeasure = tableMeasure.rows[r];
|
|
202
|
+
if (adjustedLocalY >= rowY && adjustedLocalY < rowY + rowMeasure.height) {
|
|
203
|
+
rowIndex = r;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
rowY += rowMeasure.height;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (rowIndex === -1) {
|
|
210
|
+
rowIndex = Math.min(tableFragment.toRow - 1, tableMeasure.rows.length - 1);
|
|
211
|
+
if (rowIndex < tableFragment.fromRow) continue;
|
|
212
|
+
}
|
|
213
|
+
const rowMeasure = tableMeasure.rows[rowIndex];
|
|
214
|
+
const row = tableBlock.rows[rowIndex];
|
|
215
|
+
if (!rowMeasure || !row) continue;
|
|
216
|
+
let colX = 0;
|
|
217
|
+
let colIndex = -1;
|
|
218
|
+
if (rowMeasure.cells.length === 0 || row.cells.length === 0) continue;
|
|
219
|
+
for (let c = 0; c < rowMeasure.cells.length; c++) {
|
|
220
|
+
const cellMeasure = rowMeasure.cells[c];
|
|
221
|
+
if (localX >= colX && localX < colX + cellMeasure.width) {
|
|
222
|
+
colIndex = c;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
colX += cellMeasure.width;
|
|
226
|
+
}
|
|
227
|
+
if (colIndex === -1) {
|
|
228
|
+
colIndex = rowMeasure.cells.length - 1;
|
|
229
|
+
if (colIndex < 0) continue;
|
|
230
|
+
}
|
|
231
|
+
const cellMeasure = rowMeasure.cells[colIndex];
|
|
232
|
+
const cell = row.cells[colIndex];
|
|
233
|
+
if (!cellMeasure || !cell) continue;
|
|
234
|
+
let rowTop = 0;
|
|
235
|
+
const isClickOnHeader = headerHeight > 0 && rowIndex < headerRowCount;
|
|
236
|
+
if (isClickOnHeader) for (let r = 0; r < rowIndex; r++) rowTop += tableMeasure.rows[r]?.height ?? 0;
|
|
237
|
+
else {
|
|
238
|
+
rowTop = headerHeight;
|
|
239
|
+
for (let r = tableFragment.fromRow; r < rowIndex; r++) rowTop += tableMeasure.rows[r]?.height ?? 0;
|
|
240
|
+
}
|
|
241
|
+
let colLeft = 0;
|
|
242
|
+
for (let c = 0; c < colIndex; c++) colLeft += rowMeasure.cells[c]?.width ?? 0;
|
|
243
|
+
let cellBlock;
|
|
244
|
+
let cellBlockMeasure;
|
|
245
|
+
if (cell.blocks.length > 0) {
|
|
246
|
+
const firstBlock = cell.blocks[0];
|
|
247
|
+
const firstMeasure = cellMeasure.blocks[0];
|
|
248
|
+
if (firstBlock.kind === "paragraph" && firstMeasure?.kind === "paragraph") {
|
|
249
|
+
cellBlock = firstBlock;
|
|
250
|
+
cellBlockMeasure = firstMeasure;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const cellLocalX = localX - colLeft;
|
|
254
|
+
const clipOffset = isClickOnHeader ? 0 : tableFragment.topClip ?? 0;
|
|
255
|
+
const cellLocalY = localY - rowTop + clipOffset;
|
|
256
|
+
return {
|
|
257
|
+
fragment: tableFragment,
|
|
258
|
+
block: tableBlock,
|
|
259
|
+
measure: tableMeasure,
|
|
260
|
+
pageIndex: pageHit.pageIndex,
|
|
261
|
+
rowIndex,
|
|
262
|
+
colIndex,
|
|
263
|
+
...cellBlock !== void 0 ? { cellBlock } : {},
|
|
264
|
+
...cellBlockMeasure !== void 0 ? { cellMeasure: cellBlockMeasure } : {},
|
|
265
|
+
cellLocalX: Math.max(0, cellLocalX),
|
|
266
|
+
cellLocalY: Math.max(0, cellLocalY)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Perform complete hit testing from document coordinates to the most specific element.
|
|
273
|
+
*
|
|
274
|
+
* @param layout - The layout containing pages.
|
|
275
|
+
* @param blocks - All flow blocks.
|
|
276
|
+
* @param measures - All measurements.
|
|
277
|
+
* @param point - Point in document coordinates (Y is cumulative from document top).
|
|
278
|
+
* @returns Complete hit test result.
|
|
279
|
+
*/
|
|
280
|
+
function hitTest(layout, blocks, measures, point) {
|
|
281
|
+
const result = {
|
|
282
|
+
pageHit: null,
|
|
283
|
+
fragmentHit: null,
|
|
284
|
+
tableCellHit: null
|
|
285
|
+
};
|
|
286
|
+
result.pageHit = hitTestPage(layout, point);
|
|
287
|
+
if (!result.pageHit) return result;
|
|
288
|
+
const pageTop = getPageTop(layout, result.pageHit.pageIndex);
|
|
289
|
+
const pagePoint = {
|
|
290
|
+
x: point.x,
|
|
291
|
+
y: point.y - pageTop
|
|
292
|
+
};
|
|
293
|
+
result.fragmentHit = hitTestFragment(result.pageHit, blocks, measures, pagePoint);
|
|
294
|
+
if (result.fragmentHit?.fragment.kind === "table") result.tableCellHit = hitTestTableCell(result.pageHit, blocks, measures, pagePoint);
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Get the total document height (all pages + gaps).
|
|
299
|
+
*/
|
|
300
|
+
function getTotalDocumentHeight(layout) {
|
|
301
|
+
if (layout.pages.length === 0) return 0;
|
|
302
|
+
const pageGap = layout.pageGap ?? 0;
|
|
303
|
+
let height = 0;
|
|
304
|
+
for (let i = 0; i < layout.pages.length; i++) {
|
|
305
|
+
const page = layout.pages[i];
|
|
306
|
+
height += page.size.h;
|
|
307
|
+
if (i < layout.pages.length - 1) height += pageGap;
|
|
308
|
+
}
|
|
309
|
+
return height;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Get Y coordinate to scroll to for a specific page.
|
|
313
|
+
*/
|
|
314
|
+
function getScrollYForPage(layout, pageIndex) {
|
|
315
|
+
return getPageTop(layout, pageIndex);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Get page bounds (top and bottom Y coordinates).
|
|
319
|
+
*/
|
|
320
|
+
function getPageBounds(layout, pageIndex) {
|
|
321
|
+
if (pageIndex < 0 || pageIndex >= layout.pages.length) return null;
|
|
322
|
+
const top = getPageTop(layout, pageIndex);
|
|
323
|
+
return {
|
|
324
|
+
top,
|
|
325
|
+
bottom: top + layout.pages[pageIndex].size.h
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Check if a point is within the content area of a page (inside margins).
|
|
330
|
+
*/
|
|
331
|
+
function isPointInContentArea(_layout, pageHit, pagePoint) {
|
|
332
|
+
const page = pageHit.page;
|
|
333
|
+
const margins = page.margins;
|
|
334
|
+
const contentLeft = margins.left;
|
|
335
|
+
const contentRight = page.size.w - margins.right;
|
|
336
|
+
const contentTop = margins.top;
|
|
337
|
+
const contentBottom = page.size.h - margins.bottom;
|
|
338
|
+
return pagePoint.x >= contentLeft && pagePoint.x <= contentRight && pagePoint.y >= contentTop && pagePoint.y <= contentBottom;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Find the nearest fragment to a point on a page.
|
|
342
|
+
* Useful when the click is in whitespace.
|
|
343
|
+
*/
|
|
344
|
+
function findNearestFragment(pageHit, blocks, measures, pagePoint) {
|
|
345
|
+
let nearestHit = null;
|
|
346
|
+
let nearestDistance = Infinity;
|
|
347
|
+
for (const fragment of pageHit.page.fragments) {
|
|
348
|
+
const blockIndex = findBlockIndexById(blocks, fragment.blockId);
|
|
349
|
+
if (blockIndex === -1) continue;
|
|
350
|
+
const block = blocks[blockIndex];
|
|
351
|
+
const measure = measures[blockIndex];
|
|
352
|
+
if (!block || !measure) continue;
|
|
353
|
+
let height;
|
|
354
|
+
if (fragment.kind === "paragraph" && measure.kind === "paragraph") height = calculateParagraphFragmentHeight(fragment, measure);
|
|
355
|
+
else if (fragment.kind === "table" || fragment.kind === "image") height = fragment.height;
|
|
356
|
+
else continue;
|
|
357
|
+
const centerX = fragment.x + fragment.width / 2;
|
|
358
|
+
const centerY = fragment.y + height / 2;
|
|
359
|
+
const distance = Math.hypot(pagePoint.x - centerX, pagePoint.y - centerY);
|
|
360
|
+
if (distance < nearestDistance) {
|
|
361
|
+
nearestDistance = distance;
|
|
362
|
+
nearestHit = {
|
|
363
|
+
fragment,
|
|
364
|
+
block,
|
|
365
|
+
measure,
|
|
366
|
+
pageIndex: pageHit.pageIndex,
|
|
367
|
+
localX: Math.max(0, Math.min(pagePoint.x - fragment.x, fragment.width)),
|
|
368
|
+
localY: Math.max(0, Math.min(pagePoint.y - fragment.y, height))
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return nearestHit;
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
export { findNearestFragment, getPageBounds, getPageIndexAtY, getPageTop, getScrollYForPage, getTotalDocumentHeight, hitTest, hitTestFragment, hitTestImageFragment, hitTestPage, hitTestTableCell, isPointInContentArea };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FontMetrics, FontStyle, RunMeasurement, TextMeasurement } from "../../../layout-engine/measure/measureTypes.js";
|
|
2
|
+
import { getFontMetrics, measureRun, measureText, measureTextWidth } from "../../../layout-engine/measure/measureProvider.js";
|
|
3
|
+
import { getCanvasContext, resetCanvasContext } from "../../../layout-engine/measure/measureContainer.js";
|
|
4
|
+
import { buildFontString, findCharacterAtX, getXForCharacter, halfPtToPx, ptToPx, pxToHalfPt, pxToPt, pxToTwips, twipsToPx } from "../../../layout-engine/measure/measureHelpers.js";
|
|
5
|
+
import { FloatingExclusionRect, FloatingImageZone, FloatingLineMargins, FloatingLineSegmentZone, WrapTextDirection, getFloatingAvailableWidth, getFloatingMargins, rectsToFloatingZones } from "../../../layout-engine/measure/floatingZones.js";
|
|
6
|
+
import { clampFloatingWrapMargins } from "../../../layout-engine/measure/clampFloatingWrapMargins.js";
|
|
7
|
+
import { MIN_WRAP_SEGMENT_WIDTH, MeasureParagraphOptions, findClearLineY, getRunCharWidths, measureParagraph, measureParagraphs } from "../../../layout-engine/measure/measureParagraph.js";
|
|
8
|
+
import { clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFontCacheSize, getParagraphCacheSize, getTextCacheSize, getTotalCacheSize, hashParagraphBlock, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFontCacheSize, setParagraphCacheSize, setTextCacheSize } from "../../../layout-engine/measure/cache.js";
|
|
9
|
+
import { FolioMeasurementFeatureFlags, isWorkerFontMetricsEnabled, setFolioMeasurementFlags } from "../../../layout-engine/measure/featureFlags.js";
|
|
10
|
+
export { type FloatingExclusionRect, type FloatingImageZone, type FloatingLineMargins, type FloatingLineSegmentZone, type FolioMeasurementFeatureFlags, type FontMetrics, type FontStyle, MIN_WRAP_SEGMENT_WIDTH, type MeasureParagraphOptions, type RunMeasurement, type TextMeasurement, type WrapTextDirection, buildFontString, clampFloatingWrapMargins, clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, findCharacterAtX, findClearLineY, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getCanvasContext, getFloatingAvailableWidth, getFloatingMargins, getFontCacheSize, getFontMetrics, getParagraphCacheSize, getRunCharWidths, getTextCacheSize, getTotalCacheSize, getXForCharacter, halfPtToPx, hashParagraphBlock, isWorkerFontMetricsEnabled, measureParagraph, measureParagraphs, measureRun, measureText, measureTextWidth, ptToPx, pxToHalfPt, pxToPt, pxToTwips, rectsToFloatingZones, resetCanvasContext, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFolioMeasurementFlags, setFontCacheSize, setParagraphCacheSize, setTextCacheSize, twipsToPx };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getFontMetrics, measureRun, measureText, measureTextWidth } from "../../../layout-engine/measure/measureProvider.js";
|
|
2
|
+
import { buildFontString, findCharacterAtX, getXForCharacter, halfPtToPx, ptToPx, pxToHalfPt, pxToPt, pxToTwips, twipsToPx } from "../../../layout-engine/measure/measureHelpers.js";
|
|
3
|
+
import { clampFloatingWrapMargins } from "../../../layout-engine/measure/clampFloatingWrapMargins.js";
|
|
4
|
+
import { getFloatingAvailableWidth, getFloatingMargins, rectsToFloatingZones } from "../../../layout-engine/measure/floatingZones.js";
|
|
5
|
+
import { MIN_WRAP_SEGMENT_WIDTH, findClearLineY, getRunCharWidths, measureParagraph, measureParagraphs } from "../../../layout-engine/measure/measureParagraph.js";
|
|
6
|
+
import { clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getFontCacheSize, getParagraphCacheSize, getTextCacheSize, getTotalCacheSize, hashParagraphBlock, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFontCacheSize, setParagraphCacheSize, setTextCacheSize } from "../../../layout-engine/measure/cache.js";
|
|
7
|
+
import { isWorkerFontMetricsEnabled, setFolioMeasurementFlags } from "../../../layout-engine/measure/featureFlags.js";
|
|
8
|
+
import { getCanvasContext, resetCanvasContext } from "../../../layout-engine/measure/measureContainer.js";
|
|
9
|
+
export { MIN_WRAP_SEGMENT_WIDTH, buildFontString, clampFloatingWrapMargins, clearAllCaches, clearFontMetricsCache, clearParagraphMeasureCache, clearTextWidthCache, findCharacterAtX, findClearLineY, getCachedFontMetrics, getCachedParagraphMeasure, getCachedTextWidth, getCanvasContext, getFloatingAvailableWidth, getFloatingMargins, getFontCacheSize, getFontMetrics, getParagraphCacheSize, getRunCharWidths, getTextCacheSize, getTotalCacheSize, getXForCharacter, halfPtToPx, hashParagraphBlock, isWorkerFontMetricsEnabled, measureParagraph, measureParagraphs, measureRun, measureText, measureTextWidth, ptToPx, pxToHalfPt, pxToPt, pxToTwips, rectsToFloatingZones, resetCanvasContext, setCachedFontMetrics, setCachedParagraphMeasure, setCachedTextWidth, setFolioMeasurementFlags, setFontCacheSize, setParagraphCacheSize, setTextCacheSize, twipsToPx };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FlowBlock, Layout, Measure } from "../../layout-engine/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-bridge/engine/selectionRects.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A rectangle representing part of a selection.
|
|
6
|
+
*/
|
|
7
|
+
type SelectionRect = {
|
|
8
|
+
/** X coordinate in container space. */x: number; /** Y coordinate in container space. */
|
|
9
|
+
y: number; /** Width of the rectangle. */
|
|
10
|
+
width: number; /** Height of the rectangle (typically line height). */
|
|
11
|
+
height: number; /** Page index (0-based). */
|
|
12
|
+
pageIndex: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Caret position for collapsed selection.
|
|
16
|
+
*/
|
|
17
|
+
type CaretPosition = {
|
|
18
|
+
/** X coordinate in container space. */x: number; /** Y coordinate in container space. */
|
|
19
|
+
y: number; /** Height of the caret (line height). */
|
|
20
|
+
height: number; /** Page index (0-based). */
|
|
21
|
+
pageIndex: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Convert a ProseMirror selection range to screen rectangles.
|
|
25
|
+
*
|
|
26
|
+
* @param layout - The document layout.
|
|
27
|
+
* @param blocks - All flow blocks.
|
|
28
|
+
* @param measures - All measurements.
|
|
29
|
+
* @param from - Start PM position.
|
|
30
|
+
* @param to - End PM position.
|
|
31
|
+
* @returns Array of rectangles covering the selection.
|
|
32
|
+
*/
|
|
33
|
+
declare function selectionToRects(layout: Layout, blocks: FlowBlock[], measures: Measure[], from: number, to: number): SelectionRect[];
|
|
34
|
+
/**
|
|
35
|
+
* Get caret position for a collapsed selection.
|
|
36
|
+
*
|
|
37
|
+
* @param layout - The document layout.
|
|
38
|
+
* @param blocks - All flow blocks.
|
|
39
|
+
* @param measures - All measurements.
|
|
40
|
+
* @param pmPosition - The PM position.
|
|
41
|
+
* @returns Caret position, or null if not found.
|
|
42
|
+
*/
|
|
43
|
+
declare function getCaretPosition(layout: Layout, blocks: FlowBlock[], measures: Measure[], pmPosition: number): CaretPosition | null;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a selection spans multiple pages.
|
|
46
|
+
*
|
|
47
|
+
* @param rects - Selection rectangles.
|
|
48
|
+
* @returns True if selection spans multiple pages.
|
|
49
|
+
*/
|
|
50
|
+
declare function isMultiPageSelection(rects: SelectionRect[]): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Get selection rectangles grouped by page.
|
|
53
|
+
*
|
|
54
|
+
* @param rects - Selection rectangles.
|
|
55
|
+
* @returns Map of page index to rectangles on that page.
|
|
56
|
+
*/
|
|
57
|
+
declare function groupRectsByPage(rects: SelectionRect[]): Map<number, SelectionRect[]>;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { CaretPosition, SelectionRect, getCaretPosition, groupRectsByPage, isMultiPageSelection, selectionToRects };
|