@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,811 @@
|
|
|
1
|
+
import { findChild, findChildByLocalName, findChildren, getAttribute, getChildElements, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
2
|
+
import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
3
|
+
import { BorderStyleSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, ShadingPatternSchema, TableCellTextDirectionSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
|
|
4
|
+
import { parseParagraph } from "./paragraphParser.js";
|
|
5
|
+
import { appendBookmarkMarkerToLastParagraphInBlocks, appendBookmarkMarkerToLastParagraphInCells, prependBookmarkMarkersToFirstParagraphInBlocks, prependBookmarkMarkersToFirstParagraphInCell } from "./bookmarkPlacement.js";
|
|
6
|
+
//#region src/docx/tableParser.ts
|
|
7
|
+
/**
|
|
8
|
+
* Parse a table measurement (width, height, etc.)
|
|
9
|
+
*
|
|
10
|
+
* @param element - Element with w:w and w:type attributes
|
|
11
|
+
* @returns Parsed measurement or undefined
|
|
12
|
+
*/
|
|
13
|
+
function parseTableMeasurement(element) {
|
|
14
|
+
if (!element) return;
|
|
15
|
+
const value = parseNumericAttribute(element, "w", "w") ?? 0;
|
|
16
|
+
const typeStr = getAttribute(element, "w", "type") ?? "dxa";
|
|
17
|
+
let type = "dxa";
|
|
18
|
+
if (typeStr === "auto" || typeStr === "dxa" || typeStr === "nil" || typeStr === "pct") type = typeStr;
|
|
19
|
+
return {
|
|
20
|
+
value,
|
|
21
|
+
type
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse width from an element (shorthand for common case)
|
|
26
|
+
*/
|
|
27
|
+
function parseWidth(element) {
|
|
28
|
+
return parseTableMeasurement(element);
|
|
29
|
+
}
|
|
30
|
+
function parseTrackedChangeInfo(node) {
|
|
31
|
+
const rawId = getAttribute(node, "w", "id");
|
|
32
|
+
const parsedId = rawId ? Number.parseInt(rawId, 10) : 0;
|
|
33
|
+
const author = (getAttribute(node, "w", "author") ?? "").trim();
|
|
34
|
+
const date = (getAttribute(node, "w", "date") ?? "").trim();
|
|
35
|
+
const info = {
|
|
36
|
+
id: Number.isInteger(parsedId) && parsedId >= 0 ? parsedId : 0,
|
|
37
|
+
author: author.length > 0 ? author : "Unknown"
|
|
38
|
+
};
|
|
39
|
+
if (date.length > 0) info.date = date;
|
|
40
|
+
return info;
|
|
41
|
+
}
|
|
42
|
+
function parsePropertyChangeInfo(node) {
|
|
43
|
+
const base = parseTrackedChangeInfo(node);
|
|
44
|
+
const rsid = (getAttribute(node, "w", "rsid") ?? "").trim();
|
|
45
|
+
return rsid.length > 0 ? {
|
|
46
|
+
...base,
|
|
47
|
+
rsid
|
|
48
|
+
} : base;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse a single border specification
|
|
52
|
+
*
|
|
53
|
+
* @param element - Border element (w:top, w:bottom, etc.)
|
|
54
|
+
* @returns Parsed border or undefined
|
|
55
|
+
*/
|
|
56
|
+
function parseBorderSpec(element) {
|
|
57
|
+
if (!element) return;
|
|
58
|
+
const rawStyle = getAttribute(element, "w", "val") ?? "none";
|
|
59
|
+
const border = { style: narrowEnum(rawStyle, BorderStyleSchema) ?? rawStyle };
|
|
60
|
+
const sz = parseNumericAttribute(element, "w", "sz");
|
|
61
|
+
if (sz !== void 0) border.size = sz;
|
|
62
|
+
const space = parseNumericAttribute(element, "w", "space");
|
|
63
|
+
if (space !== void 0) border.space = space;
|
|
64
|
+
const color = getAttribute(element, "w", "color");
|
|
65
|
+
const themeColor = getAttribute(element, "w", "themeColor");
|
|
66
|
+
const themeTint = getAttribute(element, "w", "themeTint");
|
|
67
|
+
const themeShade = getAttribute(element, "w", "themeShade");
|
|
68
|
+
if (color || themeColor || themeTint || themeShade) {
|
|
69
|
+
const colorVal = {};
|
|
70
|
+
if (color === "auto") colorVal.auto = true;
|
|
71
|
+
else if (color !== null) colorVal.rgb = color;
|
|
72
|
+
const validatedThemeColor = narrowEnum(themeColor, ThemeColorSlotSchema);
|
|
73
|
+
if (validatedThemeColor) colorVal.themeColor = validatedThemeColor;
|
|
74
|
+
if (themeTint !== null) colorVal.themeTint = themeTint;
|
|
75
|
+
if (themeShade !== null) colorVal.themeShade = themeShade;
|
|
76
|
+
border.color = colorVal;
|
|
77
|
+
}
|
|
78
|
+
const shadow = getAttribute(element, "w", "shadow");
|
|
79
|
+
if (shadow === "1" || shadow === "true") border.shadow = true;
|
|
80
|
+
const frame = getAttribute(element, "w", "frame");
|
|
81
|
+
if (frame === "1" || frame === "true") border.frame = true;
|
|
82
|
+
return border;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Parse table borders (w:tblBorders or w:tcBorders)
|
|
86
|
+
*
|
|
87
|
+
* @param bordersElement - The borders container element
|
|
88
|
+
* @returns Parsed borders or undefined
|
|
89
|
+
*/
|
|
90
|
+
function parseTableBorders(bordersElement) {
|
|
91
|
+
if (!bordersElement) return;
|
|
92
|
+
const borders = {};
|
|
93
|
+
const top = parseBorderSpec(findChild(bordersElement, "w", "top"));
|
|
94
|
+
if (top) borders.top = top;
|
|
95
|
+
const bottom = parseBorderSpec(findChild(bordersElement, "w", "bottom"));
|
|
96
|
+
if (bottom) borders.bottom = bottom;
|
|
97
|
+
const left = parseBorderSpec(findChild(bordersElement, "w", "left") ?? findChild(bordersElement, "w", "start"));
|
|
98
|
+
if (left) borders.left = left;
|
|
99
|
+
const right = parseBorderSpec(findChild(bordersElement, "w", "right") ?? findChild(bordersElement, "w", "end"));
|
|
100
|
+
if (right) borders.right = right;
|
|
101
|
+
const insideH = parseBorderSpec(findChild(bordersElement, "w", "insideH"));
|
|
102
|
+
if (insideH) borders.insideH = insideH;
|
|
103
|
+
const insideV = parseBorderSpec(findChild(bordersElement, "w", "insideV"));
|
|
104
|
+
if (insideV) borders.insideV = insideV;
|
|
105
|
+
if (Object.keys(borders).length === 0) return;
|
|
106
|
+
return borders;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parse cell margins (w:tblCellMar or w:tcMar)
|
|
110
|
+
*
|
|
111
|
+
* @param marginsElement - The margins container element
|
|
112
|
+
* @returns Parsed margins or undefined
|
|
113
|
+
*/
|
|
114
|
+
function parseCellMargins(marginsElement) {
|
|
115
|
+
if (!marginsElement) return;
|
|
116
|
+
const margins = {};
|
|
117
|
+
const top = parseWidth(findChild(marginsElement, "w", "top"));
|
|
118
|
+
if (top) margins.top = top;
|
|
119
|
+
const bottom = parseWidth(findChild(marginsElement, "w", "bottom"));
|
|
120
|
+
if (bottom) margins.bottom = bottom;
|
|
121
|
+
const left = parseWidth(findChild(marginsElement, "w", "left") ?? findChild(marginsElement, "w", "start"));
|
|
122
|
+
if (left) margins.left = left;
|
|
123
|
+
const right = parseWidth(findChild(marginsElement, "w", "right") ?? findChild(marginsElement, "w", "end"));
|
|
124
|
+
if (right) margins.right = right;
|
|
125
|
+
if (Object.keys(margins).length === 0) return;
|
|
126
|
+
return margins;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Parse shading properties (w:shd)
|
|
130
|
+
*
|
|
131
|
+
* @param shdElement - The w:shd element
|
|
132
|
+
* @returns Parsed shading or undefined
|
|
133
|
+
*/
|
|
134
|
+
function parseShading(shdElement) {
|
|
135
|
+
if (!shdElement) return;
|
|
136
|
+
const shading = {};
|
|
137
|
+
const fillStr = getAttribute(shdElement, "w", "fill");
|
|
138
|
+
if (fillStr && fillStr !== "auto") shading.fill = { rgb: fillStr };
|
|
139
|
+
const themeFill = narrowEnum(getAttribute(shdElement, "w", "themeFill"), ThemeColorSlotSchema);
|
|
140
|
+
if (themeFill) {
|
|
141
|
+
shading.fill = { themeColor: themeFill };
|
|
142
|
+
const themeFillTint = getAttribute(shdElement, "w", "themeFillTint");
|
|
143
|
+
if (themeFillTint) shading.fill.themeTint = themeFillTint;
|
|
144
|
+
const themeFillShade = getAttribute(shdElement, "w", "themeFillShade");
|
|
145
|
+
if (themeFillShade) shading.fill.themeShade = themeFillShade;
|
|
146
|
+
}
|
|
147
|
+
const colorStr = getAttribute(shdElement, "w", "color");
|
|
148
|
+
if (colorStr && colorStr !== "auto") shading.color = { rgb: colorStr };
|
|
149
|
+
const pattern = narrowEnum(getAttribute(shdElement, "w", "val"), ShadingPatternSchema);
|
|
150
|
+
if (pattern) shading.pattern = pattern;
|
|
151
|
+
if (Object.keys(shading).length === 0) return;
|
|
152
|
+
return shading;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Parse table look flags (w:tblLook)
|
|
156
|
+
*
|
|
157
|
+
* @param lookElement - The w:tblLook element
|
|
158
|
+
* @returns Parsed table look or undefined
|
|
159
|
+
*/
|
|
160
|
+
function parseTableLook(lookElement) {
|
|
161
|
+
if (!lookElement) return;
|
|
162
|
+
const look = {};
|
|
163
|
+
const firstRow = getAttribute(lookElement, "w", "firstRow");
|
|
164
|
+
if (firstRow === "1" || firstRow === "true") look.firstRow = true;
|
|
165
|
+
const lastRow = getAttribute(lookElement, "w", "lastRow");
|
|
166
|
+
if (lastRow === "1" || lastRow === "true") look.lastRow = true;
|
|
167
|
+
const firstColumn = getAttribute(lookElement, "w", "firstColumn");
|
|
168
|
+
if (firstColumn === "1" || firstColumn === "true") look.firstColumn = true;
|
|
169
|
+
const lastColumn = getAttribute(lookElement, "w", "lastColumn");
|
|
170
|
+
if (lastColumn === "1" || lastColumn === "true") look.lastColumn = true;
|
|
171
|
+
const noHBand = getAttribute(lookElement, "w", "noHBand");
|
|
172
|
+
if (noHBand === "1" || noHBand === "true") look.noHBand = true;
|
|
173
|
+
const noVBand = getAttribute(lookElement, "w", "noVBand");
|
|
174
|
+
if (noVBand === "1" || noVBand === "true") look.noVBand = true;
|
|
175
|
+
const val = getAttribute(lookElement, "w", "val");
|
|
176
|
+
if (val) {
|
|
177
|
+
const flags = Number.parseInt(val, 16);
|
|
178
|
+
if (!Number.isNaN(flags)) {
|
|
179
|
+
if (flags & 32) look.firstRow = true;
|
|
180
|
+
if (flags & 64) look.lastRow = true;
|
|
181
|
+
if (flags & 128) look.firstColumn = true;
|
|
182
|
+
if (flags & 256) look.lastColumn = true;
|
|
183
|
+
if (flags & 512) look.noHBand = true;
|
|
184
|
+
if (flags & 1024) look.noVBand = true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (Object.keys(look).length === 0) return;
|
|
188
|
+
return look;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Parse floating table properties (w:tblpPr)
|
|
192
|
+
*
|
|
193
|
+
* @param tblpPrElement - The w:tblpPr element
|
|
194
|
+
* @returns Parsed floating properties or undefined
|
|
195
|
+
*/
|
|
196
|
+
function parseFloatingTableProperties(tblpPrElement) {
|
|
197
|
+
if (!tblpPrElement) return;
|
|
198
|
+
const floating = {};
|
|
199
|
+
const horzAnchor = getAttribute(tblpPrElement, "w", "horzAnchor");
|
|
200
|
+
if (horzAnchor === "margin" || horzAnchor === "page" || horzAnchor === "text") floating.horzAnchor = horzAnchor;
|
|
201
|
+
const vertAnchor = getAttribute(tblpPrElement, "w", "vertAnchor");
|
|
202
|
+
if (vertAnchor === "margin" || vertAnchor === "page" || vertAnchor === "text") floating.vertAnchor = vertAnchor;
|
|
203
|
+
const tblpX = parseNumericAttribute(tblpPrElement, "w", "tblpX");
|
|
204
|
+
if (tblpX !== void 0) floating.tblpX = tblpX;
|
|
205
|
+
const tblpXSpec = narrowEnum(getAttribute(tblpPrElement, "w", "tblpXSpec"), FloatingTableXSpecSchema);
|
|
206
|
+
if (tblpXSpec) floating.tblpXSpec = tblpXSpec;
|
|
207
|
+
const tblpY = parseNumericAttribute(tblpPrElement, "w", "tblpY");
|
|
208
|
+
if (tblpY !== void 0) floating.tblpY = tblpY;
|
|
209
|
+
const tblpYSpec = narrowEnum(getAttribute(tblpPrElement, "w", "tblpYSpec"), FloatingTableYSpecSchema);
|
|
210
|
+
if (tblpYSpec) floating.tblpYSpec = tblpYSpec;
|
|
211
|
+
const topFromText = parseNumericAttribute(tblpPrElement, "w", "topFromText");
|
|
212
|
+
if (topFromText !== void 0) floating.topFromText = topFromText;
|
|
213
|
+
const bottomFromText = parseNumericAttribute(tblpPrElement, "w", "bottomFromText");
|
|
214
|
+
if (bottomFromText !== void 0) floating.bottomFromText = bottomFromText;
|
|
215
|
+
const leftFromText = parseNumericAttribute(tblpPrElement, "w", "leftFromText");
|
|
216
|
+
if (leftFromText !== void 0) floating.leftFromText = leftFromText;
|
|
217
|
+
const rightFromText = parseNumericAttribute(tblpPrElement, "w", "rightFromText");
|
|
218
|
+
if (rightFromText !== void 0) floating.rightFromText = rightFromText;
|
|
219
|
+
if (Object.keys(floating).length === 0) return;
|
|
220
|
+
return floating;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Parse table properties (w:tblPr)
|
|
224
|
+
*
|
|
225
|
+
* @param tblPrElement - The w:tblPr element
|
|
226
|
+
* @returns Parsed table formatting
|
|
227
|
+
*/
|
|
228
|
+
function parseTableProperties(tblPrElement) {
|
|
229
|
+
if (!tblPrElement) return;
|
|
230
|
+
const formatting = {};
|
|
231
|
+
const width = parseWidth(findChild(tblPrElement, "w", "tblW"));
|
|
232
|
+
if (width) formatting.width = width;
|
|
233
|
+
const jcElement = findChild(tblPrElement, "w", "jc");
|
|
234
|
+
if (jcElement) {
|
|
235
|
+
const jcVal = getAttribute(jcElement, "w", "val");
|
|
236
|
+
if (jcVal === "left" || jcVal === "center" || jcVal === "right" || jcVal === "start") formatting.justification = jcVal === "start" ? "left" : jcVal;
|
|
237
|
+
}
|
|
238
|
+
const cellSpacing = parseWidth(findChild(tblPrElement, "w", "tblCellSpacing"));
|
|
239
|
+
if (cellSpacing) formatting.cellSpacing = cellSpacing;
|
|
240
|
+
const indent = parseWidth(findChild(tblPrElement, "w", "tblInd"));
|
|
241
|
+
if (indent) formatting.indent = indent;
|
|
242
|
+
const borders = parseTableBorders(findChild(tblPrElement, "w", "tblBorders"));
|
|
243
|
+
if (borders) formatting.borders = borders;
|
|
244
|
+
const cellMargins = parseCellMargins(findChild(tblPrElement, "w", "tblCellMar"));
|
|
245
|
+
if (cellMargins) formatting.cellMargins = cellMargins;
|
|
246
|
+
const layoutElement = findChild(tblPrElement, "w", "tblLayout");
|
|
247
|
+
if (layoutElement) {
|
|
248
|
+
const layoutVal = getAttribute(layoutElement, "w", "type");
|
|
249
|
+
if (layoutVal === "fixed" || layoutVal === "autofit") formatting.layout = layoutVal;
|
|
250
|
+
}
|
|
251
|
+
const styleElement = findChild(tblPrElement, "w", "tblStyle");
|
|
252
|
+
if (styleElement) {
|
|
253
|
+
const styleId = getAttribute(styleElement, "w", "val");
|
|
254
|
+
if (styleId) formatting.styleId = styleId;
|
|
255
|
+
}
|
|
256
|
+
const look = parseTableLook(findChild(tblPrElement, "w", "tblLook"));
|
|
257
|
+
if (look) formatting.look = look;
|
|
258
|
+
const shading = parseShading(findChild(tblPrElement, "w", "shd"));
|
|
259
|
+
if (shading) formatting.shading = shading;
|
|
260
|
+
const overlapElement = findChild(tblPrElement, "w", "tblOverlap");
|
|
261
|
+
if (overlapElement) {
|
|
262
|
+
const overlapVal = getAttribute(overlapElement, "w", "val");
|
|
263
|
+
if (overlapVal === "never" || overlapVal === "overlap") formatting.overlap = overlapVal;
|
|
264
|
+
}
|
|
265
|
+
const floating = parseFloatingTableProperties(findChild(tblPrElement, "w", "tblpPr"));
|
|
266
|
+
if (floating) formatting.floating = floating;
|
|
267
|
+
if (parseBooleanElement(findChild(tblPrElement, "w", "bidiVisual"))) formatting.bidi = true;
|
|
268
|
+
if (Object.keys(formatting).length === 0) return;
|
|
269
|
+
return formatting;
|
|
270
|
+
}
|
|
271
|
+
function parseTablePropertyChanges(tblPrElement, currentFormatting) {
|
|
272
|
+
if (!tblPrElement) return;
|
|
273
|
+
const changes = findChildren(tblPrElement, "w", "tblPrChange").map((changeElement) => {
|
|
274
|
+
const previousTblPr = findChild(changeElement, "w", "tblPr");
|
|
275
|
+
const change = {
|
|
276
|
+
type: "tablePropertyChange",
|
|
277
|
+
info: parsePropertyChangeInfo(changeElement)
|
|
278
|
+
};
|
|
279
|
+
const prev = parseTableProperties(previousTblPr);
|
|
280
|
+
if (prev !== void 0) change.previousFormatting = prev;
|
|
281
|
+
if (currentFormatting !== void 0) change.currentFormatting = currentFormatting;
|
|
282
|
+
return change;
|
|
283
|
+
}).filter((change) => change.previousFormatting || change.currentFormatting);
|
|
284
|
+
return changes.length > 0 ? changes : void 0;
|
|
285
|
+
}
|
|
286
|
+
function parseTableRowPropertyChanges(trPrElement, currentFormatting) {
|
|
287
|
+
if (!trPrElement) return;
|
|
288
|
+
const changes = findChildren(trPrElement, "w", "trPrChange").map((changeElement) => {
|
|
289
|
+
const previousTrPr = findChild(changeElement, "w", "trPr");
|
|
290
|
+
const change = {
|
|
291
|
+
type: "tableRowPropertyChange",
|
|
292
|
+
info: parsePropertyChangeInfo(changeElement)
|
|
293
|
+
};
|
|
294
|
+
const prev = parseTableRowProperties(previousTrPr);
|
|
295
|
+
if (prev !== void 0) change.previousFormatting = prev;
|
|
296
|
+
if (currentFormatting !== void 0) change.currentFormatting = currentFormatting;
|
|
297
|
+
return change;
|
|
298
|
+
}).filter((change) => change.previousFormatting || change.currentFormatting);
|
|
299
|
+
return changes.length > 0 ? changes : void 0;
|
|
300
|
+
}
|
|
301
|
+
function parseTableCellPropertyChanges(tcPrElement, currentFormatting) {
|
|
302
|
+
if (!tcPrElement) return;
|
|
303
|
+
const changes = findChildren(tcPrElement, "w", "tcPrChange").map((changeElement) => {
|
|
304
|
+
const previousTcPr = findChild(changeElement, "w", "tcPr");
|
|
305
|
+
const change = {
|
|
306
|
+
type: "tableCellPropertyChange",
|
|
307
|
+
info: parsePropertyChangeInfo(changeElement)
|
|
308
|
+
};
|
|
309
|
+
const prev = parseTableCellProperties(previousTcPr);
|
|
310
|
+
if (prev !== void 0) change.previousFormatting = prev;
|
|
311
|
+
if (currentFormatting !== void 0) change.currentFormatting = currentFormatting;
|
|
312
|
+
return change;
|
|
313
|
+
}).filter((change) => change.previousFormatting || change.currentFormatting);
|
|
314
|
+
return changes.length > 0 ? changes : void 0;
|
|
315
|
+
}
|
|
316
|
+
function parseTableRowStructuralChange(trPrElement) {
|
|
317
|
+
if (!trPrElement) return;
|
|
318
|
+
const insertion = findChild(trPrElement, "w", "ins");
|
|
319
|
+
if (insertion) return {
|
|
320
|
+
type: "tableRowInsertion",
|
|
321
|
+
info: parseTrackedChangeInfo(insertion)
|
|
322
|
+
};
|
|
323
|
+
const deletion = findChild(trPrElement, "w", "del");
|
|
324
|
+
if (deletion) return {
|
|
325
|
+
type: "tableRowDeletion",
|
|
326
|
+
info: parseTrackedChangeInfo(deletion)
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function parseTableCellStructuralChange(tcPrElement) {
|
|
330
|
+
if (!tcPrElement) return;
|
|
331
|
+
const insertion = findChild(tcPrElement, "w", "cellIns");
|
|
332
|
+
if (insertion) return {
|
|
333
|
+
type: "tableCellInsertion",
|
|
334
|
+
info: parseTrackedChangeInfo(insertion)
|
|
335
|
+
};
|
|
336
|
+
const deletion = findChild(tcPrElement, "w", "cellDel");
|
|
337
|
+
if (deletion) return {
|
|
338
|
+
type: "tableCellDeletion",
|
|
339
|
+
info: parseTrackedChangeInfo(deletion)
|
|
340
|
+
};
|
|
341
|
+
const merge = findChild(tcPrElement, "w", "cellMerge");
|
|
342
|
+
if (merge) return {
|
|
343
|
+
type: "tableCellMerge",
|
|
344
|
+
info: parseTrackedChangeInfo(merge)
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Parse table row properties (w:trPr)
|
|
349
|
+
*
|
|
350
|
+
* @param trPrElement - The w:trPr element
|
|
351
|
+
* @returns Parsed row formatting
|
|
352
|
+
*/
|
|
353
|
+
function parseTableRowProperties(trPrElement) {
|
|
354
|
+
if (!trPrElement) return;
|
|
355
|
+
const formatting = {};
|
|
356
|
+
const heightElement = findChild(trPrElement, "w", "trHeight");
|
|
357
|
+
if (heightElement) {
|
|
358
|
+
const heightVal = parseNumericAttribute(heightElement, "w", "val");
|
|
359
|
+
if (heightVal !== void 0 && heightVal > 0) formatting.height = {
|
|
360
|
+
value: heightVal,
|
|
361
|
+
type: "dxa"
|
|
362
|
+
};
|
|
363
|
+
const hRule = getAttribute(heightElement, "w", "hRule");
|
|
364
|
+
if (hRule === "auto" || hRule === "atLeast" || hRule === "exact") formatting.heightRule = hRule;
|
|
365
|
+
}
|
|
366
|
+
if (parseBooleanElement(findChild(trPrElement, "w", "tblHeader"))) formatting.header = true;
|
|
367
|
+
if (parseBooleanElement(findChild(trPrElement, "w", "cantSplit"))) formatting.cantSplit = true;
|
|
368
|
+
const jcElement = findChild(trPrElement, "w", "jc");
|
|
369
|
+
if (jcElement) {
|
|
370
|
+
const jcVal = getAttribute(jcElement, "w", "val");
|
|
371
|
+
if (jcVal === "left" || jcVal === "center" || jcVal === "right") formatting.justification = jcVal;
|
|
372
|
+
}
|
|
373
|
+
if (parseBooleanElement(findChild(trPrElement, "w", "hidden"))) formatting.hidden = true;
|
|
374
|
+
const conditionalFormat = parseConditionalFormatStyle(findChild(trPrElement, "w", "cnfStyle"));
|
|
375
|
+
if (conditionalFormat) formatting.conditionalFormat = conditionalFormat;
|
|
376
|
+
if (Object.keys(formatting).length === 0) return;
|
|
377
|
+
return formatting;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Parse conditional format style (for table style conditional formatting)
|
|
381
|
+
*
|
|
382
|
+
* @param cnfElement - The w:cnfStyle element
|
|
383
|
+
* @returns Parsed conditional format or undefined
|
|
384
|
+
*/
|
|
385
|
+
function parseConditionalFormatStyle(cnfElement) {
|
|
386
|
+
if (!cnfElement) return;
|
|
387
|
+
const style = {};
|
|
388
|
+
const firstRow = getAttribute(cnfElement, "w", "firstRow");
|
|
389
|
+
if (firstRow === "1" || firstRow === "true") style.firstRow = true;
|
|
390
|
+
const lastRow = getAttribute(cnfElement, "w", "lastRow");
|
|
391
|
+
if (lastRow === "1" || lastRow === "true") style.lastRow = true;
|
|
392
|
+
const firstColumn = getAttribute(cnfElement, "w", "firstColumn");
|
|
393
|
+
if (firstColumn === "1" || firstColumn === "true") style.firstColumn = true;
|
|
394
|
+
const lastColumn = getAttribute(cnfElement, "w", "lastColumn");
|
|
395
|
+
if (lastColumn === "1" || lastColumn === "true") style.lastColumn = true;
|
|
396
|
+
const oddHBand = getAttribute(cnfElement, "w", "oddHBand");
|
|
397
|
+
if (oddHBand === "1" || oddHBand === "true") style.oddHBand = true;
|
|
398
|
+
const evenHBand = getAttribute(cnfElement, "w", "evenHBand");
|
|
399
|
+
if (evenHBand === "1" || evenHBand === "true") style.evenHBand = true;
|
|
400
|
+
const oddVBand = getAttribute(cnfElement, "w", "oddVBand");
|
|
401
|
+
if (oddVBand === "1" || oddVBand === "true") style.oddVBand = true;
|
|
402
|
+
const evenVBand = getAttribute(cnfElement, "w", "evenVBand");
|
|
403
|
+
if (evenVBand === "1" || evenVBand === "true") style.evenVBand = true;
|
|
404
|
+
const nwCell = getAttribute(cnfElement, "w", "firstRowFirstColumn");
|
|
405
|
+
if (nwCell === "1" || nwCell === "true") style.nwCell = true;
|
|
406
|
+
const neCell = getAttribute(cnfElement, "w", "firstRowLastColumn");
|
|
407
|
+
if (neCell === "1" || neCell === "true") style.neCell = true;
|
|
408
|
+
const swCell = getAttribute(cnfElement, "w", "lastRowFirstColumn");
|
|
409
|
+
if (swCell === "1" || swCell === "true") style.swCell = true;
|
|
410
|
+
const seCell = getAttribute(cnfElement, "w", "lastRowLastColumn");
|
|
411
|
+
if (seCell === "1" || seCell === "true") style.seCell = true;
|
|
412
|
+
const val = getAttribute(cnfElement, "w", "val");
|
|
413
|
+
if (val && val.length === 12) {
|
|
414
|
+
if (val[0] === "1") style.firstRow = true;
|
|
415
|
+
if (val[1] === "1") style.lastRow = true;
|
|
416
|
+
if (val[2] === "1") style.firstColumn = true;
|
|
417
|
+
if (val[3] === "1") style.lastColumn = true;
|
|
418
|
+
if (val[4] === "1") style.oddVBand = true;
|
|
419
|
+
if (val[5] === "1") style.evenVBand = true;
|
|
420
|
+
if (val[6] === "1") style.oddHBand = true;
|
|
421
|
+
if (val[7] === "1") style.evenHBand = true;
|
|
422
|
+
if (val[8] === "1") style.nwCell = true;
|
|
423
|
+
if (val[9] === "1") style.neCell = true;
|
|
424
|
+
if (val[10] === "1") style.swCell = true;
|
|
425
|
+
if (val[11] === "1") style.seCell = true;
|
|
426
|
+
}
|
|
427
|
+
if (Object.keys(style).length === 0) return;
|
|
428
|
+
return style;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Parse table cell properties (w:tcPr)
|
|
432
|
+
*
|
|
433
|
+
* @param tcPrElement - The w:tcPr element
|
|
434
|
+
* @returns Parsed cell formatting
|
|
435
|
+
*/
|
|
436
|
+
function parseTableCellProperties(tcPrElement) {
|
|
437
|
+
if (!tcPrElement) return;
|
|
438
|
+
const formatting = {};
|
|
439
|
+
const width = parseWidth(findChild(tcPrElement, "w", "tcW"));
|
|
440
|
+
if (width) formatting.width = width;
|
|
441
|
+
const borders = parseTableBorders(findChild(tcPrElement, "w", "tcBorders"));
|
|
442
|
+
if (borders) formatting.borders = borders;
|
|
443
|
+
const margins = parseCellMargins(findChild(tcPrElement, "w", "tcMar"));
|
|
444
|
+
if (margins) formatting.margins = margins;
|
|
445
|
+
const shading = parseShading(findChild(tcPrElement, "w", "shd"));
|
|
446
|
+
if (shading) formatting.shading = shading;
|
|
447
|
+
const vAlignElement = findChild(tcPrElement, "w", "vAlign");
|
|
448
|
+
if (vAlignElement) {
|
|
449
|
+
const vAlign = getAttribute(vAlignElement, "w", "val");
|
|
450
|
+
if (vAlign === "top" || vAlign === "center" || vAlign === "bottom") formatting.verticalAlign = vAlign;
|
|
451
|
+
}
|
|
452
|
+
const textDirElement = findChild(tcPrElement, "w", "textDirection");
|
|
453
|
+
if (textDirElement) {
|
|
454
|
+
const textDir = narrowEnum(getAttribute(textDirElement, "w", "val"), TableCellTextDirectionSchema);
|
|
455
|
+
if (textDir) formatting.textDirection = textDir;
|
|
456
|
+
}
|
|
457
|
+
const gridSpanElement = findChild(tcPrElement, "w", "gridSpan");
|
|
458
|
+
if (gridSpanElement) {
|
|
459
|
+
const gridSpan = parseNumericAttribute(gridSpanElement, "w", "val");
|
|
460
|
+
if (gridSpan !== void 0 && gridSpan > 1) formatting.gridSpan = gridSpan;
|
|
461
|
+
}
|
|
462
|
+
const vMergeElement = findChild(tcPrElement, "w", "vMerge");
|
|
463
|
+
if (vMergeElement) if (getAttribute(vMergeElement, "w", "val") === "restart") formatting.vMerge = "restart";
|
|
464
|
+
else formatting.vMerge = "continue";
|
|
465
|
+
if (parseBooleanElement(findChild(tcPrElement, "w", "tcFitText"))) formatting.fitText = true;
|
|
466
|
+
if (parseBooleanElement(findChild(tcPrElement, "w", "noWrap"))) formatting.noWrap = true;
|
|
467
|
+
if (parseBooleanElement(findChild(tcPrElement, "w", "hideMark"))) formatting.hideMark = true;
|
|
468
|
+
const conditionalFormat = parseConditionalFormatStyle(findChild(tcPrElement, "w", "cnfStyle"));
|
|
469
|
+
if (conditionalFormat) formatting.conditionalFormat = conditionalFormat;
|
|
470
|
+
if (Object.keys(formatting).length === 0) return;
|
|
471
|
+
return formatting;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Accumulate a table container's own `xmlns:*` onto the inherited in-scope set,
|
|
475
|
+
* so a `w:pict` nested inside a cell still resolves prefixes scoped on the
|
|
476
|
+
* `w:tbl` / `w:tr` / `w:tc` wrapper.
|
|
477
|
+
*/
|
|
478
|
+
function withContainerXmlns(options, element) {
|
|
479
|
+
return {
|
|
480
|
+
...options,
|
|
481
|
+
rootXmlns: mergeXmlnsDeclarations(options?.rootXmlns ?? {}, element)
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function parseCellContent(tcElement, styles, theme, numbering, rels, media, options) {
|
|
485
|
+
const content = [];
|
|
486
|
+
const pendingBookmarkMarkers = [];
|
|
487
|
+
const elements = getChildElements(tcElement);
|
|
488
|
+
for (const child of elements) {
|
|
489
|
+
if (!child.name) continue;
|
|
490
|
+
const localName = getLocalName(child.name);
|
|
491
|
+
if (localName === "p") {
|
|
492
|
+
const para = parseParagraph(child, styles, theme, numbering, rels, media, options);
|
|
493
|
+
prependPendingBookmarkMarkers(para, pendingBookmarkMarkers);
|
|
494
|
+
content.push(para);
|
|
495
|
+
} else if (localName === "tbl") {
|
|
496
|
+
const table = parseTable(child, styles, theme, numbering, rels, media, options);
|
|
497
|
+
if (prependBookmarkMarkersToFirstParagraphInBlocks([table], pendingBookmarkMarkers)) pendingBookmarkMarkers.length = 0;
|
|
498
|
+
content.push(table);
|
|
499
|
+
} else if (localName === "bookmarkStart" || localName === "bookmarkEnd") {
|
|
500
|
+
const marker = parseBookmarkMarker(child, localName);
|
|
501
|
+
if (!appendBookmarkMarkerToLastParagraphInBlocks(content, marker)) pendingBookmarkMarkers.push(marker);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (content.length === 0) content.push({
|
|
505
|
+
type: "paragraph",
|
|
506
|
+
content: [...pendingBookmarkMarkers]
|
|
507
|
+
});
|
|
508
|
+
else if (pendingBookmarkMarkers.length > 0) appendBookmarkMarkersToLastParagraphInBlocks(content, pendingBookmarkMarkers);
|
|
509
|
+
return content;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Parse a table cell (w:tc)
|
|
513
|
+
*
|
|
514
|
+
* @param tcElement - The w:tc element
|
|
515
|
+
* @param styles - Style definitions
|
|
516
|
+
* @param theme - Theme for color/font resolution
|
|
517
|
+
* @param numbering - Numbering definitions for lists
|
|
518
|
+
* @param rels - Relationships for hyperlinks
|
|
519
|
+
* @param media - Media files for images
|
|
520
|
+
* @returns Parsed table cell
|
|
521
|
+
*/
|
|
522
|
+
function parseTableCell(tcElement, styles, theme, numbering, rels, media, options) {
|
|
523
|
+
const cell = {
|
|
524
|
+
type: "tableCell",
|
|
525
|
+
content: []
|
|
526
|
+
};
|
|
527
|
+
const tcPrElement = findChild(tcElement, "w", "tcPr");
|
|
528
|
+
const formatting = parseTableCellProperties(tcPrElement);
|
|
529
|
+
if (formatting) cell.formatting = formatting;
|
|
530
|
+
const cellPropChanges = parseTableCellPropertyChanges(tcPrElement, formatting);
|
|
531
|
+
if (cellPropChanges !== void 0) cell.propertyChanges = cellPropChanges;
|
|
532
|
+
const cellStructChange = parseTableCellStructuralChange(tcPrElement);
|
|
533
|
+
if (cellStructChange !== void 0) cell.structuralChange = cellStructChange;
|
|
534
|
+
cell.content = parseCellContent(tcElement, styles, theme, numbering, rels, media, withContainerXmlns(options, tcElement));
|
|
535
|
+
return cell;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Parse a table row (w:tr)
|
|
539
|
+
*
|
|
540
|
+
* @param trElement - The w:tr element
|
|
541
|
+
* @param styles - Style definitions
|
|
542
|
+
* @param theme - Theme for color/font resolution
|
|
543
|
+
* @param numbering - Numbering definitions for lists
|
|
544
|
+
* @param rels - Relationships for hyperlinks
|
|
545
|
+
* @param media - Media files for images
|
|
546
|
+
* @returns Parsed table row
|
|
547
|
+
*/
|
|
548
|
+
function parseTableRow(trElement, styles, theme, numbering, rels, media, options) {
|
|
549
|
+
const row = {
|
|
550
|
+
type: "tableRow",
|
|
551
|
+
cells: []
|
|
552
|
+
};
|
|
553
|
+
const trPrElement = findChild(trElement, "w", "trPr");
|
|
554
|
+
const formatting = parseTableRowProperties(trPrElement);
|
|
555
|
+
if (formatting) row.formatting = formatting;
|
|
556
|
+
const rowPropChanges = parseTableRowPropertyChanges(trPrElement, formatting);
|
|
557
|
+
if (rowPropChanges !== void 0) row.propertyChanges = rowPropChanges;
|
|
558
|
+
const rowStructChange = parseTableRowStructuralChange(trPrElement);
|
|
559
|
+
if (rowStructChange !== void 0) row.structuralChange = rowStructChange;
|
|
560
|
+
const rowOptions = withContainerXmlns(options, trElement);
|
|
561
|
+
const pendingBookmarkMarkers = [];
|
|
562
|
+
const parseRowChild = (child) => {
|
|
563
|
+
const localName = getLocalName(child.name);
|
|
564
|
+
if (localName === "tc") {
|
|
565
|
+
const cell = parseTableCell(child, styles, theme, numbering, rels, media, rowOptions);
|
|
566
|
+
if (pendingBookmarkMarkers.length > 0) {
|
|
567
|
+
prependBookmarkMarkersToFirstParagraphInCell(cell, pendingBookmarkMarkers);
|
|
568
|
+
pendingBookmarkMarkers.length = 0;
|
|
569
|
+
}
|
|
570
|
+
row.cells.push(cell);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (localName === "sdt") {
|
|
574
|
+
const sdtContent = findChildByLocalName(child, "sdtContent");
|
|
575
|
+
if (!sdtContent) return;
|
|
576
|
+
for (const sdtChild of getChildElements(sdtContent)) parseRowChild(sdtChild);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (localName !== "bookmarkStart" && localName !== "bookmarkEnd") return;
|
|
580
|
+
const marker = parseBookmarkMarker(child, localName);
|
|
581
|
+
if (!appendBookmarkMarkerToLastParagraphInCells(row.cells, marker)) pendingBookmarkMarkers.push(marker);
|
|
582
|
+
};
|
|
583
|
+
for (const child of getChildElements(trElement)) parseRowChild(child);
|
|
584
|
+
if (pendingBookmarkMarkers.length > 0) appendBookmarkMarkersToLastCell(row, pendingBookmarkMarkers);
|
|
585
|
+
return row;
|
|
586
|
+
}
|
|
587
|
+
function getLocalName(name) {
|
|
588
|
+
if (!name) return "";
|
|
589
|
+
const colonIndex = name.indexOf(":");
|
|
590
|
+
return colonIndex === -1 ? name : name.slice(colonIndex + 1);
|
|
591
|
+
}
|
|
592
|
+
function parseBookmarkMarker(child, localName) {
|
|
593
|
+
if (localName === "bookmarkStart") return parseBookmarkStart(child);
|
|
594
|
+
return parseBookmarkEnd(child);
|
|
595
|
+
}
|
|
596
|
+
function prependPendingBookmarkMarkers(paragraph, pendingBookmarkMarkers) {
|
|
597
|
+
if (pendingBookmarkMarkers.length === 0) return;
|
|
598
|
+
paragraph.content.unshift(...pendingBookmarkMarkers);
|
|
599
|
+
pendingBookmarkMarkers.length = 0;
|
|
600
|
+
}
|
|
601
|
+
function appendBookmarkMarkersToLastParagraphInBlocks(blocks, markers) {
|
|
602
|
+
for (const marker of markers) appendBookmarkMarkerToLastParagraphInBlocks(blocks, marker);
|
|
603
|
+
}
|
|
604
|
+
function appendBookmarkMarkersToLastCell(row, markers) {
|
|
605
|
+
const lastCell = row.cells.at(-1);
|
|
606
|
+
if (!lastCell) return;
|
|
607
|
+
for (const marker of markers) appendBookmarkMarkerToLastParagraphInBlocks(lastCell.content, marker);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Parse table grid (w:tblGrid) for column widths
|
|
611
|
+
*
|
|
612
|
+
* @param tblGridElement - The w:tblGrid element
|
|
613
|
+
* @returns Array of column widths in twips
|
|
614
|
+
*/
|
|
615
|
+
function parseTableGrid(tblGridElement) {
|
|
616
|
+
if (!tblGridElement) return;
|
|
617
|
+
const widths = [];
|
|
618
|
+
const gridCols = findChildren(tblGridElement, "w", "gridCol");
|
|
619
|
+
for (const col of gridCols) {
|
|
620
|
+
const width = parseNumericAttribute(col, "w", "w") ?? 0;
|
|
621
|
+
widths.push(width);
|
|
622
|
+
}
|
|
623
|
+
if (widths.length > 0 && widths.every((width) => width <= 0)) return;
|
|
624
|
+
return widths.length > 0 ? widths : void 0;
|
|
625
|
+
}
|
|
626
|
+
function hasRowGridOffsets(rowElement) {
|
|
627
|
+
const trPrElement = findChild(rowElement, "w", "trPr");
|
|
628
|
+
if (!trPrElement) return false;
|
|
629
|
+
const gridBefore = parseNumericAttribute(findChild(trPrElement, "w", "gridBefore"), "w", "val") ?? 0;
|
|
630
|
+
const gridAfter = parseNumericAttribute(findChild(trPrElement, "w", "gridAfter"), "w", "val") ?? 0;
|
|
631
|
+
return gridBefore > 0 || gridAfter > 0;
|
|
632
|
+
}
|
|
633
|
+
function getTableGridWidth(table) {
|
|
634
|
+
const totalWidth = table.columnWidths?.reduce((sum, width) => sum + width, 0);
|
|
635
|
+
if (!totalWidth || totalWidth <= 0) return null;
|
|
636
|
+
return totalWidth;
|
|
637
|
+
}
|
|
638
|
+
function cellWidthCoversTableGrid(cell, tableGridWidth) {
|
|
639
|
+
const width = cell.formatting?.width;
|
|
640
|
+
if (!width || width.type !== "dxa" || tableGridWidth === null) return false;
|
|
641
|
+
return width.value >= tableGridWidth;
|
|
642
|
+
}
|
|
643
|
+
function inferImplicitSingleCellRowSpans(table, rowsWithGridOffsets) {
|
|
644
|
+
const gridColumnCount = table.columnWidths?.length ?? 0;
|
|
645
|
+
if (gridColumnCount <= 1) return;
|
|
646
|
+
const tableGridWidth = getTableGridWidth(table);
|
|
647
|
+
if (tableGridWidth === null) return;
|
|
648
|
+
for (const [rowIndex, row] of table.rows.entries()) {
|
|
649
|
+
if (row.cells.length !== 1) continue;
|
|
650
|
+
if (rowsWithGridOffsets.has(rowIndex)) continue;
|
|
651
|
+
const cell = row.cells.at(0);
|
|
652
|
+
if (!cell) continue;
|
|
653
|
+
if ((cell.formatting?.gridSpan ?? 1) >= gridColumnCount) continue;
|
|
654
|
+
if (cell.formatting?.vMerge) continue;
|
|
655
|
+
if (cell.formatting?.gridSpan != null) continue;
|
|
656
|
+
if (!cellWidthCoversTableGrid(cell, tableGridWidth)) continue;
|
|
657
|
+
cell.formatting = {
|
|
658
|
+
...cell.formatting,
|
|
659
|
+
gridSpan: gridColumnCount
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Parse a table element (w:tbl)
|
|
665
|
+
*
|
|
666
|
+
* @param tblElement - The w:tbl element
|
|
667
|
+
* @param styles - Style definitions
|
|
668
|
+
* @param theme - Theme for color/font resolution
|
|
669
|
+
* @param numbering - Numbering definitions for lists
|
|
670
|
+
* @param rels - Relationships for hyperlinks
|
|
671
|
+
* @param media - Media files for images
|
|
672
|
+
* @returns Parsed table
|
|
673
|
+
*/
|
|
674
|
+
function parseTable(tblElement, styles, theme, numbering, rels, media, options) {
|
|
675
|
+
const table = {
|
|
676
|
+
type: "table",
|
|
677
|
+
rows: []
|
|
678
|
+
};
|
|
679
|
+
const tblPrElement = findChild(tblElement, "w", "tblPr");
|
|
680
|
+
const formatting = parseTableProperties(tblPrElement);
|
|
681
|
+
if (formatting) table.formatting = formatting;
|
|
682
|
+
const tblPropChanges = parseTablePropertyChanges(tblPrElement, formatting);
|
|
683
|
+
if (tblPropChanges !== void 0) table.propertyChanges = tblPropChanges;
|
|
684
|
+
const columnWidths = parseTableGrid(findChild(tblElement, "w", "tblGrid"));
|
|
685
|
+
if (columnWidths) table.columnWidths = columnWidths;
|
|
686
|
+
const tableOptions = withContainerXmlns(options, tblElement);
|
|
687
|
+
const rowsWithGridOffsets = /* @__PURE__ */ new Set();
|
|
688
|
+
const parseTableChild = (child) => {
|
|
689
|
+
const localName = getLocalName(child.name);
|
|
690
|
+
if (localName === "tr") {
|
|
691
|
+
const rowIndex = table.rows.length;
|
|
692
|
+
const row = parseTableRow(child, styles, theme, numbering, rels, media, tableOptions);
|
|
693
|
+
table.rows.push(row);
|
|
694
|
+
if (hasRowGridOffsets(child)) rowsWithGridOffsets.add(rowIndex);
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
if (localName !== "sdt") return;
|
|
698
|
+
const sdtContent = findChildByLocalName(child, "sdtContent");
|
|
699
|
+
if (!sdtContent) return;
|
|
700
|
+
for (const sdtChild of getChildElements(sdtContent)) parseTableChild(sdtChild);
|
|
701
|
+
};
|
|
702
|
+
for (const child of getChildElements(tblElement)) parseTableChild(child);
|
|
703
|
+
inferImplicitSingleCellRowSpans(table, rowsWithGridOffsets);
|
|
704
|
+
return table;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Get the number of columns in a table
|
|
708
|
+
*
|
|
709
|
+
* Uses the table grid if available, otherwise counts cells in first row.
|
|
710
|
+
*
|
|
711
|
+
* @param table - The table to measure
|
|
712
|
+
* @returns Number of columns
|
|
713
|
+
*/
|
|
714
|
+
function getTableColumnCount(table) {
|
|
715
|
+
if (table.columnWidths && table.columnWidths.length > 0) return table.columnWidths.length;
|
|
716
|
+
if (table.rows.length === 0) return 0;
|
|
717
|
+
return table.rows[0].cells.reduce((count, cell) => count + (cell.formatting?.gridSpan ?? 1), 0);
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Get the number of rows in a table
|
|
721
|
+
*
|
|
722
|
+
* @param table - The table to measure
|
|
723
|
+
* @returns Number of rows
|
|
724
|
+
*/
|
|
725
|
+
function getTableRowCount(table) {
|
|
726
|
+
return table.rows.length;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Check if a cell is part of a vertical merge
|
|
730
|
+
*
|
|
731
|
+
* @param cell - The cell to check
|
|
732
|
+
* @returns true if cell continues a vertical merge
|
|
733
|
+
*/
|
|
734
|
+
function isCellMergeContinuation(cell) {
|
|
735
|
+
return cell.formatting?.vMerge === "continue";
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Check if a cell starts a vertical merge
|
|
739
|
+
*
|
|
740
|
+
* @param cell - The cell to check
|
|
741
|
+
* @returns true if cell starts a vertical merge
|
|
742
|
+
*/
|
|
743
|
+
function isCellMergeStart(cell) {
|
|
744
|
+
return cell.formatting?.vMerge === "restart";
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Check if a cell spans multiple columns
|
|
748
|
+
*
|
|
749
|
+
* @param cell - The cell to check
|
|
750
|
+
* @returns true if cell spans multiple columns
|
|
751
|
+
*/
|
|
752
|
+
function isCellHorizontallyMerged(cell) {
|
|
753
|
+
return (cell.formatting?.gridSpan ?? 1) > 1;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Get the plain text content of a table
|
|
757
|
+
*
|
|
758
|
+
* @param table - The table to extract text from
|
|
759
|
+
* @returns Plain text content
|
|
760
|
+
*/
|
|
761
|
+
function getTableText(table) {
|
|
762
|
+
const rows = [];
|
|
763
|
+
for (const row of table.rows) {
|
|
764
|
+
const cells = [];
|
|
765
|
+
for (const cell of row.cells) {
|
|
766
|
+
const cellText = cell.content.filter((c) => c.type === "paragraph").map((p) => getParagraphText(p)).join("\n");
|
|
767
|
+
cells.push(cellText);
|
|
768
|
+
}
|
|
769
|
+
rows.push(cells.join(" "));
|
|
770
|
+
}
|
|
771
|
+
return rows.join("\n");
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Helper to get paragraph text (simplified)
|
|
775
|
+
*/
|
|
776
|
+
function getParagraphText(para) {
|
|
777
|
+
return para.content.filter((c) => "content" in c).flatMap((run) => {
|
|
778
|
+
if (!("content" in run) || !Array.isArray(run.content)) return [];
|
|
779
|
+
return run.content.filter((c) => typeof c === "object" && c !== null && "type" in c && c.type === "text" && "text" in c).map((c) => c.text);
|
|
780
|
+
}).join("");
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Check if table has header row
|
|
784
|
+
*
|
|
785
|
+
* @param table - The table to check
|
|
786
|
+
* @returns true if first row is marked as header
|
|
787
|
+
*/
|
|
788
|
+
function hasHeaderRow(table) {
|
|
789
|
+
if (table.rows.length === 0) return false;
|
|
790
|
+
return table.rows[0].formatting?.header === true;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Get all header rows from a table
|
|
794
|
+
*
|
|
795
|
+
* @param table - The table to search
|
|
796
|
+
* @returns Array of header rows
|
|
797
|
+
*/
|
|
798
|
+
function getHeaderRows(table) {
|
|
799
|
+
return table.rows.filter((row) => row.formatting?.header === true);
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Check if table is a floating table
|
|
803
|
+
*
|
|
804
|
+
* @param table - The table to check
|
|
805
|
+
* @returns true if table has floating properties
|
|
806
|
+
*/
|
|
807
|
+
function isFloatingTable(table) {
|
|
808
|
+
return table.formatting?.floating !== void 0;
|
|
809
|
+
}
|
|
810
|
+
//#endregion
|
|
811
|
+
export { getHeaderRows, getTableColumnCount, getTableRowCount, getTableText, hasHeaderRow, isCellHorizontallyMerged, isCellMergeContinuation, isCellMergeStart, isFloatingTable, parseBorderSpec, parseCellMargins, parseConditionalFormatStyle, parseFloatingTableProperties, parseShading, parseTable, parseTableBorders, parseTableCell, parseTableCellProperties, parseTableGrid, parseTableLook, parseTableMeasurement, parseTableProperties, parseTableRow, parseTableRowProperties };
|