@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,70 @@
|
|
|
1
|
+
import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../types/documentEnumValues.js";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
//#region src/docx/parserEnums.ts
|
|
4
|
+
/**
|
|
5
|
+
* OOXML enum schemas for parser narrowing.
|
|
6
|
+
*
|
|
7
|
+
* Parsers throughout this directory read string-valued XML attributes
|
|
8
|
+
* (`<w:u w:val="single"/>`, `<w:pgBorders w:val="dashed"/>`, …) that
|
|
9
|
+
* the document model types as a small literal union. The historical
|
|
10
|
+
* pattern was `getAttribute(...) as UnderlineStyle`, which lies to
|
|
11
|
+
* the type system: a malformed file produces a typed value that
|
|
12
|
+
* silently contains garbage and breaks downstream consumers.
|
|
13
|
+
*
|
|
14
|
+
* These valibot picklists are the single source of truth for each
|
|
15
|
+
* OOXML enum. `narrowEnum(value, schema)` widens a parsed string to
|
|
16
|
+
* the typed enum *iff* the value is recognised; unknown values
|
|
17
|
+
* become `undefined` so callers can fall back to a default, matching
|
|
18
|
+
* how Word degrades when it doesn't recognise a value.
|
|
19
|
+
*
|
|
20
|
+
* Picklist entries are checked at compile time against the TS union
|
|
21
|
+
* via `satisfies` — a new variant added to the model type fails to
|
|
22
|
+
* compile until the picklist is updated, giving the same compile-time
|
|
23
|
+
* coverage gate as `switch-exhaustiveness-check`.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Narrow a raw attribute string to a picklist member, or `undefined`
|
|
27
|
+
* if the value isn't recognised. The cast lives once inside the
|
|
28
|
+
* valibot output type; callers receive a properly-typed value with
|
|
29
|
+
* no `as` at the call site.
|
|
30
|
+
*/
|
|
31
|
+
const narrowEnum = (value, schema) => {
|
|
32
|
+
if (value === null || value === void 0) return;
|
|
33
|
+
const result = v.safeParse(schema, value);
|
|
34
|
+
return result.success ? result.output : void 0;
|
|
35
|
+
};
|
|
36
|
+
const ThemeColorSlotSchema = v.picklist(THEME_COLOR_SLOT_VALUES);
|
|
37
|
+
const BorderStyleSchema = v.picklist(BORDER_STYLE_VALUES);
|
|
38
|
+
const UnderlineStyleSchema = v.picklist(UNDERLINE_STYLE_VALUES);
|
|
39
|
+
const HighlightColorSchema = v.picklist(HIGHLIGHT_COLOR_VALUES);
|
|
40
|
+
const TextEffectSchema = v.picklist(TEXT_EFFECT_VALUES);
|
|
41
|
+
const EmphasisMarkSchema = v.picklist(EMPHASIS_MARK_VALUES);
|
|
42
|
+
const FontThemeSchema = v.picklist(FONT_THEME_VALUES);
|
|
43
|
+
const ParagraphAlignmentSchema = v.picklist(PARAGRAPH_ALIGNMENT_VALUES);
|
|
44
|
+
const LineSpacingRuleSchema = v.picklist(LINE_SPACING_RULE_VALUES);
|
|
45
|
+
const TabStopAlignmentSchema = v.picklist(TAB_STOP_ALIGNMENT_VALUES);
|
|
46
|
+
const TabLeaderSchema = v.picklist(TAB_LEADER_VALUES);
|
|
47
|
+
const FrameXAlignSchema = v.picklist(FRAME_X_ALIGN_VALUES);
|
|
48
|
+
const FrameYAlignSchema = v.picklist(FRAME_Y_ALIGN_VALUES);
|
|
49
|
+
const FrameWrapSchema = v.picklist(FRAME_WRAP_VALUES);
|
|
50
|
+
const SdtLockSchema = v.picklist(SDT_LOCK_VALUES);
|
|
51
|
+
const FieldTypeSchema = v.picklist(FIELD_TYPE_VALUES);
|
|
52
|
+
const StyleTypeSchema = v.picklist(STYLE_TYPE_VALUES);
|
|
53
|
+
const ConditionalStyleTypeSchema = v.picklist(CONDITIONAL_STYLE_TYPE_VALUES);
|
|
54
|
+
const TableWidthTypeSchema = v.picklist(TABLE_WIDTH_TYPE_VALUES);
|
|
55
|
+
const TableRowHeightRuleSchema = v.picklist(TABLE_ROW_HEIGHT_RULE_VALUES);
|
|
56
|
+
const TableCellTextDirectionSchema = v.picklist(TABLE_CELL_TEXT_DIRECTION_VALUES);
|
|
57
|
+
const ShadingPatternSchema = v.picklist(SHADING_PATTERN_VALUES);
|
|
58
|
+
const FloatingTableXSpecSchema = v.picklist(FLOATING_TABLE_X_SPEC_VALUES);
|
|
59
|
+
const FloatingTableYSpecSchema = v.picklist(FLOATING_TABLE_Y_SPEC_VALUES);
|
|
60
|
+
const ImageHorizontalRelativeToSchema = v.picklist(IMAGE_HORIZONTAL_RELATIVE_TO_VALUES);
|
|
61
|
+
const ImageHorizontalAlignmentSchema = v.picklist(IMAGE_HORIZONTAL_ALIGNMENT_VALUES);
|
|
62
|
+
const ImageVerticalRelativeToSchema = v.picklist(IMAGE_VERTICAL_RELATIVE_TO_VALUES);
|
|
63
|
+
const ImageVerticalAlignmentSchema = v.picklist(IMAGE_VERTICAL_ALIGNMENT_VALUES);
|
|
64
|
+
const ImageWrapTextSchema = v.picklist(IMAGE_WRAP_TEXT_VALUES);
|
|
65
|
+
const ShapeOutlineStyleSchema = v.picklist(SHAPE_OUTLINE_STYLE_VALUES);
|
|
66
|
+
const ShapeTypeSchema = v.picklist(SHAPE_TYPE_VALUES);
|
|
67
|
+
const NumberFormatSchema = v.picklist(NUMBER_FORMAT_VALUES);
|
|
68
|
+
const LevelSuffixSchema = v.picklist(LEVEL_SUFFIX_VALUES);
|
|
69
|
+
//#endregion
|
|
70
|
+
export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
//#region src/docx/relsParser.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Relationship type constants for common types
|
|
5
|
+
*/
|
|
6
|
+
declare const RELATIONSHIP_TYPES: {
|
|
7
|
+
readonly image: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
|
8
|
+
readonly hyperlink: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
|
9
|
+
readonly header: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
|
10
|
+
readonly footer: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";
|
|
11
|
+
readonly footnotes: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes";
|
|
12
|
+
readonly endnotes: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes";
|
|
13
|
+
readonly styles: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
|
|
14
|
+
readonly numbering: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
|
|
15
|
+
readonly fontTable: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable";
|
|
16
|
+
readonly theme: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
|
17
|
+
readonly settings: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings";
|
|
18
|
+
readonly webSettings: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings";
|
|
19
|
+
readonly oleObject: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
20
|
+
readonly chart: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
|
|
21
|
+
readonly diagramData: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData";
|
|
22
|
+
readonly officeDocument: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
|
|
23
|
+
readonly coreProperties: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
|
24
|
+
readonly extendedProperties: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
|
|
25
|
+
readonly customProperties: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties";
|
|
26
|
+
readonly customXml: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml";
|
|
27
|
+
readonly comments: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
|
|
28
|
+
readonly commentsExtended: "http://schemas.microsoft.com/office/2011/relationships/commentsExtended";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Parse a .rels XML file into a RelationshipMap
|
|
32
|
+
*
|
|
33
|
+
* @param relsXml - XML content of a .rels file
|
|
34
|
+
* @returns Map of relationship ID to Relationship object
|
|
35
|
+
*/
|
|
36
|
+
declare function parseRelationships(relsXml: string): document_d_exports.RelationshipMap;
|
|
37
|
+
/**
|
|
38
|
+
* Get the short type name from a full relationship type URI
|
|
39
|
+
*
|
|
40
|
+
* @param typeUri - Full relationship type URI
|
|
41
|
+
* @returns Short type name (e.g., "image", "hyperlink") or "unknown"
|
|
42
|
+
*/
|
|
43
|
+
declare function getRelationshipTypeName(typeUri: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a relationship type is an external link (hyperlink)
|
|
46
|
+
*
|
|
47
|
+
* @param rel - Relationship to check
|
|
48
|
+
* @returns true if this is an external hyperlink
|
|
49
|
+
*/
|
|
50
|
+
declare function isExternalHyperlink(rel: document_d_exports.Relationship): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a relationship type is an image
|
|
53
|
+
*
|
|
54
|
+
* @param rel - Relationship to check
|
|
55
|
+
* @returns true if this is an image relationship
|
|
56
|
+
*/
|
|
57
|
+
declare function isImageRelationship(rel: document_d_exports.Relationship): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Check if a relationship type is a header
|
|
60
|
+
*
|
|
61
|
+
* @param rel - Relationship to check
|
|
62
|
+
* @returns true if this is a header relationship
|
|
63
|
+
*/
|
|
64
|
+
declare function isHeaderRelationship(rel: document_d_exports.Relationship): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Check if a relationship type is a footer
|
|
67
|
+
*
|
|
68
|
+
* @param rel - Relationship to check
|
|
69
|
+
* @returns true if this is a footer relationship
|
|
70
|
+
*/
|
|
71
|
+
declare function isFooterRelationship(rel: document_d_exports.Relationship): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Filter relationships by type
|
|
74
|
+
*
|
|
75
|
+
* @param map - RelationshipMap to filter
|
|
76
|
+
* @param type - Relationship type URI to filter by
|
|
77
|
+
* @returns Array of matching relationships
|
|
78
|
+
*/
|
|
79
|
+
declare function filterByType(map: document_d_exports.RelationshipMap, type: document_d_exports.RelationshipType): document_d_exports.Relationship[];
|
|
80
|
+
/**
|
|
81
|
+
* Get all images from a relationship map
|
|
82
|
+
*
|
|
83
|
+
* @param map - RelationshipMap to search
|
|
84
|
+
* @returns Array of image relationships
|
|
85
|
+
*/
|
|
86
|
+
declare function getImages(map: document_d_exports.RelationshipMap): document_d_exports.Relationship[];
|
|
87
|
+
/**
|
|
88
|
+
* Get all hyperlinks from a relationship map
|
|
89
|
+
*
|
|
90
|
+
* @param map - RelationshipMap to search
|
|
91
|
+
* @returns Array of hyperlink relationships
|
|
92
|
+
*/
|
|
93
|
+
declare function getHyperlinks(map: document_d_exports.RelationshipMap): document_d_exports.Relationship[];
|
|
94
|
+
/**
|
|
95
|
+
* Get all headers from a relationship map
|
|
96
|
+
*
|
|
97
|
+
* @param map - RelationshipMap to search
|
|
98
|
+
* @returns Array of header relationships
|
|
99
|
+
*/
|
|
100
|
+
declare function getHeaders(map: document_d_exports.RelationshipMap): document_d_exports.Relationship[];
|
|
101
|
+
/**
|
|
102
|
+
* Get all footers from a relationship map
|
|
103
|
+
*
|
|
104
|
+
* @param map - RelationshipMap to search
|
|
105
|
+
* @returns Array of footer relationships
|
|
106
|
+
*/
|
|
107
|
+
declare function getFooters(map: document_d_exports.RelationshipMap): document_d_exports.Relationship[];
|
|
108
|
+
/**
|
|
109
|
+
* Resolve a relationship ID to a target path
|
|
110
|
+
*
|
|
111
|
+
* @param map - RelationshipMap to search
|
|
112
|
+
* @param rId - Relationship ID (e.g., "rId1")
|
|
113
|
+
* @returns Target path or undefined if not found
|
|
114
|
+
*/
|
|
115
|
+
declare function resolveTarget(map: document_d_exports.RelationshipMap, rId: string): string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Resolve a relationship ID to a full relationship
|
|
118
|
+
*
|
|
119
|
+
* @param map - RelationshipMap to search
|
|
120
|
+
* @param rId - Relationship ID (e.g., "rId1")
|
|
121
|
+
* @returns Relationship or undefined if not found
|
|
122
|
+
*/
|
|
123
|
+
declare function resolveRelationship(map: document_d_exports.RelationshipMap, rId: string): document_d_exports.Relationship | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Resolve a relative target path to an absolute path within the DOCX
|
|
126
|
+
*
|
|
127
|
+
* For example, if basePath is "word/_rels/document.xml.rels" and
|
|
128
|
+
* target is "media/image1.png", the result is "word/media/image1.png"
|
|
129
|
+
*
|
|
130
|
+
* @param basePath - Path of the .rels file
|
|
131
|
+
* @param target - Relative target from the relationship
|
|
132
|
+
* @returns Absolute path within the DOCX
|
|
133
|
+
*/
|
|
134
|
+
declare function resolveRelativePath(basePath: string, target: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Parse document.xml.rels specifically
|
|
137
|
+
*
|
|
138
|
+
* This is a convenience wrapper for the main document relationships.
|
|
139
|
+
*
|
|
140
|
+
* @param relsXml - XML content of word/_rels/document.xml.rels
|
|
141
|
+
* @returns RelationshipMap
|
|
142
|
+
*/
|
|
143
|
+
declare function parseDocumentRelationships(relsXml: string): document_d_exports.RelationshipMap;
|
|
144
|
+
/**
|
|
145
|
+
* Parse package-level .rels
|
|
146
|
+
*
|
|
147
|
+
* This is a convenience wrapper for the package relationships (_rels/.rels)
|
|
148
|
+
*
|
|
149
|
+
* @param relsXml - XML content of _rels/.rels
|
|
150
|
+
* @returns RelationshipMap
|
|
151
|
+
*/
|
|
152
|
+
declare function parsePackageRelationships(relsXml: string): document_d_exports.RelationshipMap;
|
|
153
|
+
/**
|
|
154
|
+
* Debug: Print all relationships in a map
|
|
155
|
+
*
|
|
156
|
+
* @param map - RelationshipMap to print
|
|
157
|
+
*/
|
|
158
|
+
declare function formatRelationships(map: document_d_exports.RelationshipMap): string;
|
|
159
|
+
//#endregion
|
|
160
|
+
export { RELATIONSHIP_TYPES, filterByType, formatRelationships, getFooters, getHeaders, getHyperlinks, getImages, getRelationshipTypeName, isExternalHyperlink, isFooterRelationship, isHeaderRelationship, isImageRelationship, parseDocumentRelationships, parsePackageRelationships, parseRelationships, resolveRelationship, resolveRelativePath, resolveTarget };
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { getAttribute, getChildElements, parseXmlDocument } from "./xmlParser.js";
|
|
2
|
+
//#region src/docx/relsParser.ts
|
|
3
|
+
/**
|
|
4
|
+
* Relationship type constants for common types
|
|
5
|
+
*/
|
|
6
|
+
const RELATIONSHIP_TYPES = {
|
|
7
|
+
image: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
8
|
+
hyperlink: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
|
|
9
|
+
header: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
|
|
10
|
+
footer: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
|
|
11
|
+
footnotes: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
|
|
12
|
+
endnotes: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",
|
|
13
|
+
styles: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
|
|
14
|
+
numbering: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
|
|
15
|
+
fontTable: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
|
|
16
|
+
theme: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
|
|
17
|
+
settings: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
|
|
18
|
+
webSettings: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",
|
|
19
|
+
oleObject: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject",
|
|
20
|
+
chart: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
|
|
21
|
+
diagramData: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData",
|
|
22
|
+
officeDocument: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
|
23
|
+
coreProperties: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",
|
|
24
|
+
extendedProperties: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
|
|
25
|
+
customProperties: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",
|
|
26
|
+
customXml: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",
|
|
27
|
+
comments: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
|
|
28
|
+
commentsExtended: "http://schemas.microsoft.com/office/2011/relationships/commentsExtended"
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Parse a .rels XML file into a RelationshipMap
|
|
32
|
+
*
|
|
33
|
+
* @param relsXml - XML content of a .rels file
|
|
34
|
+
* @returns Map of relationship ID to Relationship object
|
|
35
|
+
*/
|
|
36
|
+
function parseRelationships(relsXml) {
|
|
37
|
+
const map = /* @__PURE__ */ new Map();
|
|
38
|
+
if (!relsXml || relsXml.trim().length === 0) return map;
|
|
39
|
+
const root = parseXmlDocument(relsXml);
|
|
40
|
+
if (!root) return map;
|
|
41
|
+
const children = getChildElements(root);
|
|
42
|
+
for (const child of children) {
|
|
43
|
+
const name = child.name || "";
|
|
44
|
+
if (!name.endsWith("Relationship") && !name.includes(":Relationship")) continue;
|
|
45
|
+
const id = getAttribute(child, null, "Id");
|
|
46
|
+
const type = getAttribute(child, null, "Type");
|
|
47
|
+
const target = getAttribute(child, null, "Target");
|
|
48
|
+
const targetMode = getAttribute(child, null, "TargetMode");
|
|
49
|
+
if (!id || !type || !target) continue;
|
|
50
|
+
const relationship = {
|
|
51
|
+
id,
|
|
52
|
+
type,
|
|
53
|
+
target
|
|
54
|
+
};
|
|
55
|
+
if (targetMode === "External") relationship.targetMode = "External";
|
|
56
|
+
else if (targetMode === "Internal") relationship.targetMode = "Internal";
|
|
57
|
+
map.set(id, relationship);
|
|
58
|
+
}
|
|
59
|
+
return map;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the short type name from a full relationship type URI
|
|
63
|
+
*
|
|
64
|
+
* @param typeUri - Full relationship type URI
|
|
65
|
+
* @returns Short type name (e.g., "image", "hyperlink") or "unknown"
|
|
66
|
+
*/
|
|
67
|
+
function getRelationshipTypeName(typeUri) {
|
|
68
|
+
for (const [name, uri] of Object.entries(RELATIONSHIP_TYPES)) if (uri === typeUri) return name;
|
|
69
|
+
const lastSlash = typeUri.lastIndexOf("/");
|
|
70
|
+
if (lastSlash !== -1) return typeUri.slice(lastSlash + 1);
|
|
71
|
+
return "unknown";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if a relationship type is an external link (hyperlink)
|
|
75
|
+
*
|
|
76
|
+
* @param rel - Relationship to check
|
|
77
|
+
* @returns true if this is an external hyperlink
|
|
78
|
+
*/
|
|
79
|
+
function isExternalHyperlink(rel) {
|
|
80
|
+
return rel.type === RELATIONSHIP_TYPES.hyperlink && rel.targetMode === "External";
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if a relationship type is an image
|
|
84
|
+
*
|
|
85
|
+
* @param rel - Relationship to check
|
|
86
|
+
* @returns true if this is an image relationship
|
|
87
|
+
*/
|
|
88
|
+
function isImageRelationship(rel) {
|
|
89
|
+
return rel.type === RELATIONSHIP_TYPES.image;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Check if a relationship type is a header
|
|
93
|
+
*
|
|
94
|
+
* @param rel - Relationship to check
|
|
95
|
+
* @returns true if this is a header relationship
|
|
96
|
+
*/
|
|
97
|
+
function isHeaderRelationship(rel) {
|
|
98
|
+
return rel.type === RELATIONSHIP_TYPES.header;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Check if a relationship type is a footer
|
|
102
|
+
*
|
|
103
|
+
* @param rel - Relationship to check
|
|
104
|
+
* @returns true if this is a footer relationship
|
|
105
|
+
*/
|
|
106
|
+
function isFooterRelationship(rel) {
|
|
107
|
+
return rel.type === RELATIONSHIP_TYPES.footer;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Filter relationships by type
|
|
111
|
+
*
|
|
112
|
+
* @param map - RelationshipMap to filter
|
|
113
|
+
* @param type - Relationship type URI to filter by
|
|
114
|
+
* @returns Array of matching relationships
|
|
115
|
+
*/
|
|
116
|
+
function filterByType(map, type) {
|
|
117
|
+
const results = [];
|
|
118
|
+
for (const rel of map.values()) if (rel.type === type) results.push(rel);
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get all images from a relationship map
|
|
123
|
+
*
|
|
124
|
+
* @param map - RelationshipMap to search
|
|
125
|
+
* @returns Array of image relationships
|
|
126
|
+
*/
|
|
127
|
+
function getImages(map) {
|
|
128
|
+
return filterByType(map, RELATIONSHIP_TYPES.image);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get all hyperlinks from a relationship map
|
|
132
|
+
*
|
|
133
|
+
* @param map - RelationshipMap to search
|
|
134
|
+
* @returns Array of hyperlink relationships
|
|
135
|
+
*/
|
|
136
|
+
function getHyperlinks(map) {
|
|
137
|
+
return filterByType(map, RELATIONSHIP_TYPES.hyperlink);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get all headers from a relationship map
|
|
141
|
+
*
|
|
142
|
+
* @param map - RelationshipMap to search
|
|
143
|
+
* @returns Array of header relationships
|
|
144
|
+
*/
|
|
145
|
+
function getHeaders(map) {
|
|
146
|
+
return filterByType(map, RELATIONSHIP_TYPES.header);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get all footers from a relationship map
|
|
150
|
+
*
|
|
151
|
+
* @param map - RelationshipMap to search
|
|
152
|
+
* @returns Array of footer relationships
|
|
153
|
+
*/
|
|
154
|
+
function getFooters(map) {
|
|
155
|
+
return filterByType(map, RELATIONSHIP_TYPES.footer);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Resolve a relationship ID to a target path
|
|
159
|
+
*
|
|
160
|
+
* @param map - RelationshipMap to search
|
|
161
|
+
* @param rId - Relationship ID (e.g., "rId1")
|
|
162
|
+
* @returns Target path or undefined if not found
|
|
163
|
+
*/
|
|
164
|
+
function resolveTarget(map, rId) {
|
|
165
|
+
return map.get(rId)?.target;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Resolve a relationship ID to a full relationship
|
|
169
|
+
*
|
|
170
|
+
* @param map - RelationshipMap to search
|
|
171
|
+
* @param rId - Relationship ID (e.g., "rId1")
|
|
172
|
+
* @returns Relationship or undefined if not found
|
|
173
|
+
*/
|
|
174
|
+
function resolveRelationship(map, rId) {
|
|
175
|
+
return map.get(rId);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Resolve a relative target path to an absolute path within the DOCX
|
|
179
|
+
*
|
|
180
|
+
* For example, if basePath is "word/_rels/document.xml.rels" and
|
|
181
|
+
* target is "media/image1.png", the result is "word/media/image1.png"
|
|
182
|
+
*
|
|
183
|
+
* @param basePath - Path of the .rels file
|
|
184
|
+
* @param target - Relative target from the relationship
|
|
185
|
+
* @returns Absolute path within the DOCX
|
|
186
|
+
*/
|
|
187
|
+
function resolveRelativePath(basePath, target) {
|
|
188
|
+
if (target.startsWith("/")) return target.slice(1);
|
|
189
|
+
const lastSlash = basePath.lastIndexOf("/");
|
|
190
|
+
let directory = lastSlash !== -1 ? basePath.slice(0, lastSlash) : "";
|
|
191
|
+
if (directory.endsWith("/_rels")) directory = directory.slice(0, -6);
|
|
192
|
+
else if (directory === "_rels") directory = "";
|
|
193
|
+
const parts = target.split("/");
|
|
194
|
+
const dirParts = directory ? directory.split("/") : [];
|
|
195
|
+
for (const part of parts) if (part === "..") dirParts.pop();
|
|
196
|
+
else if (part !== ".") dirParts.push(part);
|
|
197
|
+
return dirParts.join("/");
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Parse document.xml.rels specifically
|
|
201
|
+
*
|
|
202
|
+
* This is a convenience wrapper for the main document relationships.
|
|
203
|
+
*
|
|
204
|
+
* @param relsXml - XML content of word/_rels/document.xml.rels
|
|
205
|
+
* @returns RelationshipMap
|
|
206
|
+
*/
|
|
207
|
+
function parseDocumentRelationships(relsXml) {
|
|
208
|
+
return parseRelationships(relsXml);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Parse package-level .rels
|
|
212
|
+
*
|
|
213
|
+
* This is a convenience wrapper for the package relationships (_rels/.rels)
|
|
214
|
+
*
|
|
215
|
+
* @param relsXml - XML content of _rels/.rels
|
|
216
|
+
* @returns RelationshipMap
|
|
217
|
+
*/
|
|
218
|
+
function parsePackageRelationships(relsXml) {
|
|
219
|
+
return parseRelationships(relsXml);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Debug: Print all relationships in a map
|
|
223
|
+
*
|
|
224
|
+
* @param map - RelationshipMap to print
|
|
225
|
+
*/
|
|
226
|
+
function formatRelationships(map) {
|
|
227
|
+
const lines = ["Relationships:"];
|
|
228
|
+
for (const [id, rel] of map.entries()) {
|
|
229
|
+
const typeName = getRelationshipTypeName(rel.type);
|
|
230
|
+
lines.push(` ${id}: ${typeName} -> ${rel.target}${rel.targetMode === "External" ? " (External)" : ""}`);
|
|
231
|
+
}
|
|
232
|
+
return lines.join("\n");
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
export { RELATIONSHIP_TYPES, filterByType, formatRelationships, getFooters, getHeaders, getHyperlinks, getImages, getRelationshipTypeName, isExternalHyperlink, isFooterRelationship, isHeaderRelationship, isImageRelationship, parseDocumentRelationships, parsePackageRelationships, parseRelationships, resolveRelationship, resolveRelativePath, resolveTarget };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
|
|
3
|
+
//#region src/docx/replyToComment.d.ts
|
|
4
|
+
type CreateCommentReplyInput = {
|
|
5
|
+
author: string;
|
|
6
|
+
text: string;
|
|
7
|
+
initials?: string; /** ISO date; defaults to now. */
|
|
8
|
+
date?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Build a reply to `parentCommentId` against an existing comment list and
|
|
12
|
+
* return it, mutating the thread root's last paragraph to guarantee it has a
|
|
13
|
+
* paraId. Does NOT append the reply to `comments` — the caller owns storage
|
|
14
|
+
* (the standalone {@link replyToComment} writes it back to the document model;
|
|
15
|
+
* the headless reviewer keeps its own created-comment list). Returns `null` when
|
|
16
|
+
* the parent comment does not exist, or is malformed (no paragraphs) so it
|
|
17
|
+
* cannot anchor a thread. A reply to a reply re-parents onto the same thread as
|
|
18
|
+
* the target (Word threads are flat: every reply links to the root).
|
|
19
|
+
*/
|
|
20
|
+
declare const createReply: (comments: readonly document_d_exports.Comment[], parentCommentId: number, input: CreateCommentReplyInput) => document_d_exports.Comment | null;
|
|
21
|
+
/**
|
|
22
|
+
* Append a reply to `parentCommentId` in `doc`'s comment list, mutating the
|
|
23
|
+
* document model in place, and return the created reply. Returns `null` when the
|
|
24
|
+
* parent comment does not exist or cannot anchor a thread (see
|
|
25
|
+
* {@link createReply}).
|
|
26
|
+
*/
|
|
27
|
+
declare const replyToComment: (doc: document_d_exports.Document, parentCommentId: number, input: CreateCommentReplyInput) => document_d_exports.Comment | null;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { CreateCommentReplyInput, createReply, replyToComment };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { generateHexId } from "../utils/hexId.js";
|
|
2
|
+
//#region src/docx/replyToComment.ts
|
|
3
|
+
const nextCommentId = (comments) => {
|
|
4
|
+
let max = 0;
|
|
5
|
+
for (const comment of comments) if (comment.id > max) max = comment.id;
|
|
6
|
+
return max + 1;
|
|
7
|
+
};
|
|
8
|
+
const usedParaIds = (comments) => {
|
|
9
|
+
const ids = /* @__PURE__ */ new Set();
|
|
10
|
+
for (const comment of comments) for (const paragraph of comment.content) if (paragraph.paraId) ids.add(paragraph.paraId.toUpperCase());
|
|
11
|
+
return ids;
|
|
12
|
+
};
|
|
13
|
+
const freshParaId = (used) => {
|
|
14
|
+
let id = generateHexId();
|
|
15
|
+
while (used.has(id.toUpperCase())) id = generateHexId();
|
|
16
|
+
used.add(id.toUpperCase());
|
|
17
|
+
return id;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Build a reply to `parentCommentId` against an existing comment list and
|
|
21
|
+
* return it, mutating the thread root's last paragraph to guarantee it has a
|
|
22
|
+
* paraId. Does NOT append the reply to `comments` — the caller owns storage
|
|
23
|
+
* (the standalone {@link replyToComment} writes it back to the document model;
|
|
24
|
+
* the headless reviewer keeps its own created-comment list). Returns `null` when
|
|
25
|
+
* the parent comment does not exist, or is malformed (no paragraphs) so it
|
|
26
|
+
* cannot anchor a thread. A reply to a reply re-parents onto the same thread as
|
|
27
|
+
* the target (Word threads are flat: every reply links to the root).
|
|
28
|
+
*/
|
|
29
|
+
const createReply = (comments, parentCommentId, input) => {
|
|
30
|
+
const parent = comments.find((comment) => comment.id === parentCommentId);
|
|
31
|
+
if (!parent) return null;
|
|
32
|
+
const threadRootId = parent.parentId ?? parent.id;
|
|
33
|
+
const rootLastParagraph = ((comments.find((comment) => comment.id === threadRootId) ?? parent).content ?? []).at(-1);
|
|
34
|
+
if (!rootLastParagraph) return null;
|
|
35
|
+
const used = usedParaIds(comments);
|
|
36
|
+
if (!rootLastParagraph.paraId) rootLastParagraph.paraId = freshParaId(used);
|
|
37
|
+
const replyParagraph = {
|
|
38
|
+
type: "paragraph",
|
|
39
|
+
formatting: {},
|
|
40
|
+
paraId: freshParaId(used),
|
|
41
|
+
content: [{
|
|
42
|
+
type: "run",
|
|
43
|
+
formatting: {},
|
|
44
|
+
content: [{
|
|
45
|
+
type: "text",
|
|
46
|
+
text: input.text
|
|
47
|
+
}]
|
|
48
|
+
}]
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
id: nextCommentId(comments),
|
|
52
|
+
author: input.author,
|
|
53
|
+
date: input.date ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
54
|
+
parentId: threadRootId,
|
|
55
|
+
content: [replyParagraph],
|
|
56
|
+
...input.initials !== void 0 ? { initials: input.initials } : {}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Append a reply to `parentCommentId` in `doc`'s comment list, mutating the
|
|
61
|
+
* document model in place, and return the created reply. Returns `null` when the
|
|
62
|
+
* parent comment does not exist or cannot anchor a thread (see
|
|
63
|
+
* {@link createReply}).
|
|
64
|
+
*/
|
|
65
|
+
const replyToComment = (doc, parentCommentId, input) => {
|
|
66
|
+
const comments = doc.package.document.comments ?? [];
|
|
67
|
+
const reply = createReply(comments, parentCommentId, input);
|
|
68
|
+
if (!reply) return null;
|
|
69
|
+
doc.package.document.comments = [...comments, reply];
|
|
70
|
+
return reply;
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
export { createReply, replyToComment };
|