@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,905 @@
|
|
|
1
|
+
import { findChild, findChildren, getAttribute, getLocalName, parseBooleanElement, parseNumericAttribute, parseXmlDocument } from "./xmlParser.js";
|
|
2
|
+
import { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FontThemeSchema, HighlightColorSchema, LineSpacingRuleSchema, ParagraphAlignmentSchema, ShadingPatternSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
3
|
+
import { resolveThemeFontRef } from "./themeParser.js";
|
|
4
|
+
import { mergeTextFormatting } from "../utils/textFormattingMerge.js";
|
|
5
|
+
import { mergeParagraphFormatting } from "../utils/paragraphFormattingMerge.js";
|
|
6
|
+
//#region src/docx/styleParser.ts
|
|
7
|
+
/**
|
|
8
|
+
* Parse text formatting properties (w:rPr)
|
|
9
|
+
*/
|
|
10
|
+
function parseRunProperties(rPr, theme) {
|
|
11
|
+
if (!rPr) return;
|
|
12
|
+
const formatting = {};
|
|
13
|
+
const b = findChild(rPr, "w", "b");
|
|
14
|
+
if (b) formatting.bold = parseBooleanElement(b);
|
|
15
|
+
const bCs = findChild(rPr, "w", "bCs");
|
|
16
|
+
if (bCs) formatting.boldCs = parseBooleanElement(bCs);
|
|
17
|
+
const i = findChild(rPr, "w", "i");
|
|
18
|
+
if (i) formatting.italic = parseBooleanElement(i);
|
|
19
|
+
const iCs = findChild(rPr, "w", "iCs");
|
|
20
|
+
if (iCs) formatting.italicCs = parseBooleanElement(iCs);
|
|
21
|
+
const u = findChild(rPr, "w", "u");
|
|
22
|
+
if (u) {
|
|
23
|
+
const style = narrowEnum(getAttribute(u, "w", "val"), UnderlineStyleSchema);
|
|
24
|
+
if (style) {
|
|
25
|
+
formatting.underline = { style };
|
|
26
|
+
const colorVal = getAttribute(u, "w", "color");
|
|
27
|
+
const themeColor = getAttribute(u, "w", "themeColor");
|
|
28
|
+
if (colorVal || themeColor) formatting.underline.color = parseColorValue(colorVal, themeColor, getAttribute(u, "w", "themeTint"), getAttribute(u, "w", "themeShade"));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const strike = findChild(rPr, "w", "strike");
|
|
32
|
+
if (strike) formatting.strike = parseBooleanElement(strike);
|
|
33
|
+
const dstrike = findChild(rPr, "w", "dstrike");
|
|
34
|
+
if (dstrike) formatting.doubleStrike = parseBooleanElement(dstrike);
|
|
35
|
+
const vertAlign = findChild(rPr, "w", "vertAlign");
|
|
36
|
+
if (vertAlign) {
|
|
37
|
+
const val = getAttribute(vertAlign, "w", "val");
|
|
38
|
+
if (val === "superscript" || val === "subscript" || val === "baseline") formatting.vertAlign = val;
|
|
39
|
+
}
|
|
40
|
+
const smallCaps = findChild(rPr, "w", "smallCaps");
|
|
41
|
+
if (smallCaps) formatting.smallCaps = parseBooleanElement(smallCaps);
|
|
42
|
+
const caps = findChild(rPr, "w", "caps");
|
|
43
|
+
if (caps) formatting.allCaps = parseBooleanElement(caps);
|
|
44
|
+
const vanish = findChild(rPr, "w", "vanish");
|
|
45
|
+
if (vanish) formatting.hidden = parseBooleanElement(vanish);
|
|
46
|
+
const color = findChild(rPr, "w", "color");
|
|
47
|
+
if (color) formatting.color = parseColorValue(getAttribute(color, "w", "val"), getAttribute(color, "w", "themeColor"), getAttribute(color, "w", "themeTint"), getAttribute(color, "w", "themeShade"));
|
|
48
|
+
const highlight = findChild(rPr, "w", "highlight");
|
|
49
|
+
if (highlight) {
|
|
50
|
+
const val = narrowEnum(getAttribute(highlight, "w", "val"), HighlightColorSchema);
|
|
51
|
+
if (val) formatting.highlight = val;
|
|
52
|
+
}
|
|
53
|
+
const shd = findChild(rPr, "w", "shd");
|
|
54
|
+
if (shd) {
|
|
55
|
+
const shadingResult = parseShadingProperties(shd);
|
|
56
|
+
if (shadingResult) formatting.shading = shadingResult;
|
|
57
|
+
}
|
|
58
|
+
const sz = findChild(rPr, "w", "sz");
|
|
59
|
+
if (sz) {
|
|
60
|
+
const val = parseNumericAttribute(sz, "w", "val");
|
|
61
|
+
if (val !== void 0) formatting.fontSize = val;
|
|
62
|
+
}
|
|
63
|
+
const szCs = findChild(rPr, "w", "szCs");
|
|
64
|
+
if (szCs) {
|
|
65
|
+
const val = parseNumericAttribute(szCs, "w", "val");
|
|
66
|
+
if (val !== void 0) formatting.fontSizeCs = val;
|
|
67
|
+
}
|
|
68
|
+
const rFonts = findChild(rPr, "w", "rFonts");
|
|
69
|
+
if (rFonts) {
|
|
70
|
+
const fontFamily = {};
|
|
71
|
+
const ascii = getAttribute(rFonts, "w", "ascii");
|
|
72
|
+
if (ascii) fontFamily.ascii = ascii;
|
|
73
|
+
const hAnsi = getAttribute(rFonts, "w", "hAnsi");
|
|
74
|
+
if (hAnsi) fontFamily.hAnsi = hAnsi;
|
|
75
|
+
const eastAsia = getAttribute(rFonts, "w", "eastAsia");
|
|
76
|
+
if (eastAsia) fontFamily.eastAsia = eastAsia;
|
|
77
|
+
const csFont = getAttribute(rFonts, "w", "cs");
|
|
78
|
+
if (csFont) fontFamily.cs = csFont;
|
|
79
|
+
const asciiTheme = narrowEnum(getAttribute(rFonts, "w", "asciiTheme"), FontThemeSchema);
|
|
80
|
+
if (asciiTheme) {
|
|
81
|
+
fontFamily.asciiTheme = asciiTheme;
|
|
82
|
+
if (theme && !fontFamily.ascii) {
|
|
83
|
+
const resolved = resolveThemeFontRef(theme, asciiTheme);
|
|
84
|
+
if (resolved) fontFamily.ascii = resolved;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const hAnsiTheme = getAttribute(rFonts, "w", "hAnsiTheme");
|
|
88
|
+
if (hAnsiTheme) {
|
|
89
|
+
fontFamily.hAnsiTheme = hAnsiTheme;
|
|
90
|
+
if (theme && !fontFamily.hAnsi) {
|
|
91
|
+
const resolved = resolveThemeFontRef(theme, hAnsiTheme);
|
|
92
|
+
if (resolved) fontFamily.hAnsi = resolved;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const eastAsiaTheme = getAttribute(rFonts, "w", "eastAsiaTheme");
|
|
96
|
+
if (eastAsiaTheme) {
|
|
97
|
+
fontFamily.eastAsiaTheme = eastAsiaTheme;
|
|
98
|
+
if (theme && !fontFamily.eastAsia) {
|
|
99
|
+
const resolved = resolveThemeFontRef(theme, eastAsiaTheme);
|
|
100
|
+
if (resolved) fontFamily.eastAsia = resolved;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const csTheme = getAttribute(rFonts, "w", "cstheme");
|
|
104
|
+
if (csTheme) {
|
|
105
|
+
fontFamily.csTheme = csTheme;
|
|
106
|
+
if (theme && !fontFamily.cs) {
|
|
107
|
+
const resolved = resolveThemeFontRef(theme, csTheme);
|
|
108
|
+
if (resolved) fontFamily.cs = resolved;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
formatting.fontFamily = fontFamily;
|
|
112
|
+
}
|
|
113
|
+
const spacing = findChild(rPr, "w", "spacing");
|
|
114
|
+
if (spacing) {
|
|
115
|
+
const val = parseNumericAttribute(spacing, "w", "val");
|
|
116
|
+
if (val !== void 0) formatting.spacing = val;
|
|
117
|
+
}
|
|
118
|
+
const position = findChild(rPr, "w", "position");
|
|
119
|
+
if (position) {
|
|
120
|
+
const val = parseNumericAttribute(position, "w", "val");
|
|
121
|
+
if (val !== void 0) formatting.position = val;
|
|
122
|
+
}
|
|
123
|
+
const w = findChild(rPr, "w", "w");
|
|
124
|
+
if (w) {
|
|
125
|
+
const val = parseNumericAttribute(w, "w", "val");
|
|
126
|
+
if (val !== void 0) formatting.scale = val;
|
|
127
|
+
}
|
|
128
|
+
const kern = findChild(rPr, "w", "kern");
|
|
129
|
+
if (kern) {
|
|
130
|
+
const val = parseNumericAttribute(kern, "w", "val");
|
|
131
|
+
if (val !== void 0) formatting.kerning = val;
|
|
132
|
+
}
|
|
133
|
+
const effect = findChild(rPr, "w", "effect");
|
|
134
|
+
if (effect) {
|
|
135
|
+
const val = narrowEnum(getAttribute(effect, "w", "val"), TextEffectSchema);
|
|
136
|
+
if (val) formatting.effect = val;
|
|
137
|
+
}
|
|
138
|
+
const em = findChild(rPr, "w", "em");
|
|
139
|
+
if (em) {
|
|
140
|
+
const val = narrowEnum(getAttribute(em, "w", "val"), EmphasisMarkSchema);
|
|
141
|
+
if (val) formatting.emphasisMark = val;
|
|
142
|
+
}
|
|
143
|
+
const emboss = findChild(rPr, "w", "emboss");
|
|
144
|
+
if (emboss) formatting.emboss = parseBooleanElement(emboss);
|
|
145
|
+
const imprint = findChild(rPr, "w", "imprint");
|
|
146
|
+
if (imprint) formatting.imprint = parseBooleanElement(imprint);
|
|
147
|
+
const outline = findChild(rPr, "w", "outline");
|
|
148
|
+
if (outline) formatting.outline = parseBooleanElement(outline);
|
|
149
|
+
const shadow = findChild(rPr, "w", "shadow");
|
|
150
|
+
if (shadow) formatting.shadow = parseBooleanElement(shadow);
|
|
151
|
+
const rtl = findChild(rPr, "w", "rtl");
|
|
152
|
+
if (rtl) formatting.rtl = parseBooleanElement(rtl);
|
|
153
|
+
const cs = findChild(rPr, "w", "cs");
|
|
154
|
+
if (cs) formatting.cs = parseBooleanElement(cs);
|
|
155
|
+
const rStyle = findChild(rPr, "w", "rStyle");
|
|
156
|
+
if (rStyle) {
|
|
157
|
+
const val = getAttribute(rStyle, "w", "val");
|
|
158
|
+
if (val) formatting.styleId = val;
|
|
159
|
+
}
|
|
160
|
+
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Parse color value from attributes
|
|
164
|
+
*/
|
|
165
|
+
function parseColorValue(rgb, themeColor, themeTint, themeShade) {
|
|
166
|
+
const color = {};
|
|
167
|
+
if (rgb && rgb !== "auto") color.rgb = rgb;
|
|
168
|
+
else if (rgb === "auto") color.auto = true;
|
|
169
|
+
const validatedThemeColor = narrowEnum(themeColor, ThemeColorSlotSchema);
|
|
170
|
+
if (validatedThemeColor) color.themeColor = validatedThemeColor;
|
|
171
|
+
if (themeTint) color.themeTint = themeTint;
|
|
172
|
+
if (themeShade) color.themeShade = themeShade;
|
|
173
|
+
return color;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Parse shading properties (w:shd)
|
|
177
|
+
*/
|
|
178
|
+
function parseShadingProperties(shd) {
|
|
179
|
+
if (!shd) return;
|
|
180
|
+
const props = {};
|
|
181
|
+
const color = getAttribute(shd, "w", "color");
|
|
182
|
+
if (color && color !== "auto") props.color = { rgb: color };
|
|
183
|
+
const fill = getAttribute(shd, "w", "fill");
|
|
184
|
+
if (fill && fill !== "auto") props.fill = { rgb: fill };
|
|
185
|
+
const validatedThemeFill = narrowEnum(getAttribute(shd, "w", "themeFill"), ThemeColorSlotSchema);
|
|
186
|
+
if (validatedThemeFill) {
|
|
187
|
+
if (!props.fill) props.fill = {};
|
|
188
|
+
props.fill.themeColor = validatedThemeFill;
|
|
189
|
+
}
|
|
190
|
+
const themeFillTint = getAttribute(shd, "w", "themeFillTint");
|
|
191
|
+
if (themeFillTint && props.fill) props.fill.themeTint = themeFillTint;
|
|
192
|
+
const themeFillShade = getAttribute(shd, "w", "themeFillShade");
|
|
193
|
+
if (themeFillShade && props.fill) props.fill.themeShade = themeFillShade;
|
|
194
|
+
const pattern = narrowEnum(getAttribute(shd, "w", "val"), ShadingPatternSchema);
|
|
195
|
+
if (pattern) props.pattern = pattern;
|
|
196
|
+
return Object.keys(props).length > 0 ? props : void 0;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Parse border specification
|
|
200
|
+
*/
|
|
201
|
+
function parseBorderSpec(border) {
|
|
202
|
+
if (!border) return;
|
|
203
|
+
const rawStyle = getAttribute(border, "w", "val");
|
|
204
|
+
if (!rawStyle) return;
|
|
205
|
+
const spec = { style: narrowEnum(rawStyle, BorderStyleSchema) ?? rawStyle };
|
|
206
|
+
const colorVal = getAttribute(border, "w", "color");
|
|
207
|
+
const themeColor = getAttribute(border, "w", "themeColor");
|
|
208
|
+
if (colorVal || themeColor) spec.color = parseColorValue(colorVal, themeColor, getAttribute(border, "w", "themeTint"), getAttribute(border, "w", "themeShade"));
|
|
209
|
+
const sz = parseNumericAttribute(border, "w", "sz");
|
|
210
|
+
if (sz !== void 0) spec.size = sz;
|
|
211
|
+
const space = parseNumericAttribute(border, "w", "space");
|
|
212
|
+
if (space !== void 0) spec.space = space;
|
|
213
|
+
const shadowAttr = getAttribute(border, "w", "shadow");
|
|
214
|
+
if (shadowAttr) spec.shadow = shadowAttr === "1" || shadowAttr === "true";
|
|
215
|
+
const frame = getAttribute(border, "w", "frame");
|
|
216
|
+
if (frame) spec.frame = frame === "1" || frame === "true";
|
|
217
|
+
return spec;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Parse tab stops (w:tabs)
|
|
221
|
+
*/
|
|
222
|
+
function parseTabStops(tabs) {
|
|
223
|
+
if (!tabs) return;
|
|
224
|
+
const tabElements = findChildren(tabs, "w", "tab");
|
|
225
|
+
if (tabElements.length === 0) return;
|
|
226
|
+
const result = [];
|
|
227
|
+
for (const tab of tabElements) {
|
|
228
|
+
const pos = parseNumericAttribute(tab, "w", "pos");
|
|
229
|
+
const alignment = narrowEnum(getAttribute(tab, "w", "val"), TabStopAlignmentSchema);
|
|
230
|
+
if (pos !== void 0 && alignment) {
|
|
231
|
+
const tabStop = {
|
|
232
|
+
position: pos,
|
|
233
|
+
alignment
|
|
234
|
+
};
|
|
235
|
+
const leader = narrowEnum(getAttribute(tab, "w", "leader"), TabLeaderSchema);
|
|
236
|
+
if (leader) tabStop.leader = leader;
|
|
237
|
+
result.push(tabStop);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return result.length > 0 ? result : void 0;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Parse paragraph formatting properties (w:pPr)
|
|
244
|
+
*/
|
|
245
|
+
function parseParagraphProperties(pPr, theme) {
|
|
246
|
+
if (!pPr) return;
|
|
247
|
+
const formatting = {};
|
|
248
|
+
const jc = findChild(pPr, "w", "jc");
|
|
249
|
+
if (jc) {
|
|
250
|
+
const val = narrowEnum(getAttribute(jc, "w", "val"), ParagraphAlignmentSchema);
|
|
251
|
+
if (val) formatting.alignment = val;
|
|
252
|
+
}
|
|
253
|
+
const bidi = findChild(pPr, "w", "bidi");
|
|
254
|
+
if (bidi) formatting.bidi = parseBooleanElement(bidi);
|
|
255
|
+
const spacing = findChild(pPr, "w", "spacing");
|
|
256
|
+
if (spacing) {
|
|
257
|
+
const before = parseNumericAttribute(spacing, "w", "before");
|
|
258
|
+
if (before !== void 0) formatting.spaceBefore = before;
|
|
259
|
+
const after = parseNumericAttribute(spacing, "w", "after");
|
|
260
|
+
if (after !== void 0) formatting.spaceAfter = after;
|
|
261
|
+
const line = parseNumericAttribute(spacing, "w", "line");
|
|
262
|
+
if (line !== void 0) formatting.lineSpacing = line;
|
|
263
|
+
const lineRule = narrowEnum(getAttribute(spacing, "w", "lineRule"), LineSpacingRuleSchema);
|
|
264
|
+
if (lineRule) formatting.lineSpacingRule = lineRule;
|
|
265
|
+
const beforeAuto = getAttribute(spacing, "w", "beforeAutospacing");
|
|
266
|
+
if (beforeAuto) formatting.beforeAutospacing = beforeAuto === "1" || beforeAuto === "true";
|
|
267
|
+
const afterAuto = getAttribute(spacing, "w", "afterAutospacing");
|
|
268
|
+
if (afterAuto) formatting.afterAutospacing = afterAuto === "1" || afterAuto === "true";
|
|
269
|
+
}
|
|
270
|
+
const ind = findChild(pPr, "w", "ind");
|
|
271
|
+
if (ind) {
|
|
272
|
+
const left = parseNumericAttribute(ind, "w", "left");
|
|
273
|
+
if (left !== void 0) formatting.indentLeft = left;
|
|
274
|
+
const right = parseNumericAttribute(ind, "w", "right");
|
|
275
|
+
if (right !== void 0) formatting.indentRight = right;
|
|
276
|
+
const firstLine = parseNumericAttribute(ind, "w", "firstLine");
|
|
277
|
+
if (firstLine !== void 0) formatting.indentFirstLine = firstLine;
|
|
278
|
+
const hanging = parseNumericAttribute(ind, "w", "hanging");
|
|
279
|
+
if (hanging !== void 0) {
|
|
280
|
+
formatting.indentFirstLine = -hanging;
|
|
281
|
+
formatting.hangingIndent = true;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const pBdr = findChild(pPr, "w", "pBdr");
|
|
285
|
+
if (pBdr) {
|
|
286
|
+
const borders = {};
|
|
287
|
+
const top = parseBorderSpec(findChild(pBdr, "w", "top"));
|
|
288
|
+
if (top) borders.top = top;
|
|
289
|
+
const bottom = parseBorderSpec(findChild(pBdr, "w", "bottom"));
|
|
290
|
+
if (bottom) borders.bottom = bottom;
|
|
291
|
+
const left = parseBorderSpec(findChild(pBdr, "w", "left"));
|
|
292
|
+
if (left) borders.left = left;
|
|
293
|
+
const right = parseBorderSpec(findChild(pBdr, "w", "right"));
|
|
294
|
+
if (right) borders.right = right;
|
|
295
|
+
const between = parseBorderSpec(findChild(pBdr, "w", "between"));
|
|
296
|
+
if (between) borders.between = between;
|
|
297
|
+
const bar = parseBorderSpec(findChild(pBdr, "w", "bar"));
|
|
298
|
+
if (bar) borders.bar = bar;
|
|
299
|
+
if (Object.keys(borders).length > 0) formatting.borders = borders;
|
|
300
|
+
}
|
|
301
|
+
const shd = findChild(pPr, "w", "shd");
|
|
302
|
+
if (shd) {
|
|
303
|
+
const shadingResult = parseShadingProperties(shd);
|
|
304
|
+
if (shadingResult) formatting.shading = shadingResult;
|
|
305
|
+
}
|
|
306
|
+
const tabs = findChild(pPr, "w", "tabs");
|
|
307
|
+
if (tabs) {
|
|
308
|
+
const tabStops = parseTabStops(tabs);
|
|
309
|
+
if (tabStops) formatting.tabs = tabStops;
|
|
310
|
+
}
|
|
311
|
+
const keepNext = findChild(pPr, "w", "keepNext");
|
|
312
|
+
if (keepNext) formatting.keepNext = parseBooleanElement(keepNext);
|
|
313
|
+
const keepLines = findChild(pPr, "w", "keepLines");
|
|
314
|
+
if (keepLines) formatting.keepLines = parseBooleanElement(keepLines);
|
|
315
|
+
const widowControl = findChild(pPr, "w", "widowControl");
|
|
316
|
+
if (widowControl) formatting.widowControl = parseBooleanElement(widowControl);
|
|
317
|
+
const pageBreakBefore = findChild(pPr, "w", "pageBreakBefore");
|
|
318
|
+
if (pageBreakBefore) formatting.pageBreakBefore = parseBooleanElement(pageBreakBefore);
|
|
319
|
+
const contextualSpacing = findChild(pPr, "w", "contextualSpacing");
|
|
320
|
+
if (contextualSpacing) formatting.contextualSpacing = parseBooleanElement(contextualSpacing);
|
|
321
|
+
const numPr = findChild(pPr, "w", "numPr");
|
|
322
|
+
if (numPr) {
|
|
323
|
+
const numId = findChild(numPr, "w", "numId");
|
|
324
|
+
const ilvl = findChild(numPr, "w", "ilvl");
|
|
325
|
+
if (numId || ilvl) {
|
|
326
|
+
formatting.numPr = {};
|
|
327
|
+
if (numId) {
|
|
328
|
+
const val = parseNumericAttribute(numId, "w", "val");
|
|
329
|
+
if (val !== void 0) formatting.numPr.numId = val;
|
|
330
|
+
}
|
|
331
|
+
if (ilvl) {
|
|
332
|
+
const val = parseNumericAttribute(ilvl, "w", "val");
|
|
333
|
+
if (val !== void 0) formatting.numPr.ilvl = val;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const outlineLvl = findChild(pPr, "w", "outlineLvl");
|
|
338
|
+
if (outlineLvl) {
|
|
339
|
+
const val = parseNumericAttribute(outlineLvl, "w", "val");
|
|
340
|
+
if (val !== void 0) formatting.outlineLevel = val;
|
|
341
|
+
}
|
|
342
|
+
const pStyle = findChild(pPr, "w", "pStyle");
|
|
343
|
+
if (pStyle) {
|
|
344
|
+
const val = getAttribute(pStyle, "w", "val");
|
|
345
|
+
if (val) formatting.styleId = val;
|
|
346
|
+
}
|
|
347
|
+
const suppressLineNumbers = findChild(pPr, "w", "suppressLineNumbers");
|
|
348
|
+
if (suppressLineNumbers) formatting.suppressLineNumbers = parseBooleanElement(suppressLineNumbers);
|
|
349
|
+
const suppressAutoHyphens = findChild(pPr, "w", "suppressAutoHyphens");
|
|
350
|
+
if (suppressAutoHyphens) formatting.suppressAutoHyphens = parseBooleanElement(suppressAutoHyphens);
|
|
351
|
+
const rPr = findChild(pPr, "w", "rPr");
|
|
352
|
+
if (rPr) {
|
|
353
|
+
const runProps = parseRunProperties(rPr, theme);
|
|
354
|
+
if (runProps) formatting.runProperties = runProps;
|
|
355
|
+
}
|
|
356
|
+
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Parse table measurement (width/height with type)
|
|
360
|
+
*/
|
|
361
|
+
function parseTableMeasurement(element) {
|
|
362
|
+
if (!element) return;
|
|
363
|
+
const w = parseNumericAttribute(element, "w", "w");
|
|
364
|
+
const rawType = getAttribute(element, "w", "type");
|
|
365
|
+
const type = rawType === null ? "dxa" : narrowEnum(rawType, TableWidthTypeSchema);
|
|
366
|
+
if (w !== void 0 && type) return {
|
|
367
|
+
value: w,
|
|
368
|
+
type
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Parse table borders
|
|
373
|
+
*/
|
|
374
|
+
function parseTableBorders(tblBorders) {
|
|
375
|
+
if (!tblBorders) return;
|
|
376
|
+
const borders = {};
|
|
377
|
+
const top = parseBorderSpec(findChild(tblBorders, "w", "top"));
|
|
378
|
+
if (top) borders.top = top;
|
|
379
|
+
const bottom = parseBorderSpec(findChild(tblBorders, "w", "bottom"));
|
|
380
|
+
if (bottom) borders.bottom = bottom;
|
|
381
|
+
const left = parseBorderSpec(findChild(tblBorders, "w", "left") ?? findChild(tblBorders, "w", "start"));
|
|
382
|
+
if (left) borders.left = left;
|
|
383
|
+
const right = parseBorderSpec(findChild(tblBorders, "w", "right") ?? findChild(tblBorders, "w", "end"));
|
|
384
|
+
if (right) borders.right = right;
|
|
385
|
+
const insideH = parseBorderSpec(findChild(tblBorders, "w", "insideH"));
|
|
386
|
+
if (insideH) borders.insideH = insideH;
|
|
387
|
+
const insideV = parseBorderSpec(findChild(tblBorders, "w", "insideV"));
|
|
388
|
+
if (insideV) borders.insideV = insideV;
|
|
389
|
+
return Object.keys(borders).length > 0 ? borders : void 0;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Parse cell margins
|
|
393
|
+
*/
|
|
394
|
+
function parseCellMargins(tblCellMar) {
|
|
395
|
+
if (!tblCellMar) return;
|
|
396
|
+
const margins = {};
|
|
397
|
+
const top = parseTableMeasurement(findChild(tblCellMar, "w", "top"));
|
|
398
|
+
if (top) margins.top = top;
|
|
399
|
+
const bottom = parseTableMeasurement(findChild(tblCellMar, "w", "bottom"));
|
|
400
|
+
if (bottom) margins.bottom = bottom;
|
|
401
|
+
const left = parseTableMeasurement(findChild(tblCellMar, "w", "left"));
|
|
402
|
+
if (left) margins.left = left;
|
|
403
|
+
const right = parseTableMeasurement(findChild(tblCellMar, "w", "right"));
|
|
404
|
+
if (right) margins.right = right;
|
|
405
|
+
return Object.keys(margins).length > 0 ? margins : void 0;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Parse table look flags
|
|
409
|
+
*/
|
|
410
|
+
function parseTableLook(tblLook) {
|
|
411
|
+
if (!tblLook) return;
|
|
412
|
+
const look = {};
|
|
413
|
+
const val = getAttribute(tblLook, "w", "val");
|
|
414
|
+
if (val) {
|
|
415
|
+
const num = Number.parseInt(val, 16);
|
|
416
|
+
if (!Number.isNaN(num)) {
|
|
417
|
+
look.firstRow = (num & 32) !== 0;
|
|
418
|
+
look.lastRow = (num & 64) !== 0;
|
|
419
|
+
look.firstColumn = (num & 128) !== 0;
|
|
420
|
+
look.lastColumn = (num & 256) !== 0;
|
|
421
|
+
look.noHBand = (num & 512) !== 0;
|
|
422
|
+
look.noVBand = (num & 1024) !== 0;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const firstColumn = getAttribute(tblLook, "w", "firstColumn");
|
|
426
|
+
if (firstColumn) look.firstColumn = firstColumn === "1";
|
|
427
|
+
const firstRow = getAttribute(tblLook, "w", "firstRow");
|
|
428
|
+
if (firstRow) look.firstRow = firstRow === "1";
|
|
429
|
+
const lastColumn = getAttribute(tblLook, "w", "lastColumn");
|
|
430
|
+
if (lastColumn) look.lastColumn = lastColumn === "1";
|
|
431
|
+
const lastRow = getAttribute(tblLook, "w", "lastRow");
|
|
432
|
+
if (lastRow) look.lastRow = lastRow === "1";
|
|
433
|
+
const noHBand = getAttribute(tblLook, "w", "noHBand");
|
|
434
|
+
if (noHBand) look.noHBand = noHBand === "1";
|
|
435
|
+
const noVBand = getAttribute(tblLook, "w", "noVBand");
|
|
436
|
+
if (noVBand) look.noVBand = noVBand === "1";
|
|
437
|
+
return Object.keys(look).length > 0 ? look : void 0;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Parse table formatting properties (w:tblPr)
|
|
441
|
+
*/
|
|
442
|
+
function parseTableProperties(tblPr, _theme) {
|
|
443
|
+
if (!tblPr) return;
|
|
444
|
+
const formatting = {};
|
|
445
|
+
const tblW = findChild(tblPr, "w", "tblW");
|
|
446
|
+
if (tblW) {
|
|
447
|
+
const widthResult = parseTableMeasurement(tblW);
|
|
448
|
+
if (widthResult) formatting.width = widthResult;
|
|
449
|
+
}
|
|
450
|
+
const jc = findChild(tblPr, "w", "jc");
|
|
451
|
+
if (jc) {
|
|
452
|
+
const val = getAttribute(jc, "w", "val");
|
|
453
|
+
if (val === "left" || val === "center" || val === "right") formatting.justification = val;
|
|
454
|
+
}
|
|
455
|
+
const tblCellSpacing = findChild(tblPr, "w", "tblCellSpacing");
|
|
456
|
+
if (tblCellSpacing) {
|
|
457
|
+
const cellSpacingResult = parseTableMeasurement(tblCellSpacing);
|
|
458
|
+
if (cellSpacingResult) formatting.cellSpacing = cellSpacingResult;
|
|
459
|
+
}
|
|
460
|
+
const tblInd = findChild(tblPr, "w", "tblInd");
|
|
461
|
+
if (tblInd) {
|
|
462
|
+
const indentResult = parseTableMeasurement(tblInd);
|
|
463
|
+
if (indentResult) formatting.indent = indentResult;
|
|
464
|
+
}
|
|
465
|
+
const tblBorders = findChild(tblPr, "w", "tblBorders");
|
|
466
|
+
if (tblBorders) {
|
|
467
|
+
const bordersResult = parseTableBorders(tblBorders);
|
|
468
|
+
if (bordersResult) formatting.borders = bordersResult;
|
|
469
|
+
}
|
|
470
|
+
const tblCellMar = findChild(tblPr, "w", "tblCellMar");
|
|
471
|
+
if (tblCellMar) {
|
|
472
|
+
const marginsResult = parseCellMargins(tblCellMar);
|
|
473
|
+
if (marginsResult) formatting.cellMargins = marginsResult;
|
|
474
|
+
}
|
|
475
|
+
const tblLayout = findChild(tblPr, "w", "tblLayout");
|
|
476
|
+
if (tblLayout) {
|
|
477
|
+
const val = getAttribute(tblLayout, "w", "type");
|
|
478
|
+
if (val === "fixed" || val === "autofit") formatting.layout = val;
|
|
479
|
+
}
|
|
480
|
+
const tblStyle = findChild(tblPr, "w", "tblStyle");
|
|
481
|
+
if (tblStyle) {
|
|
482
|
+
const val = getAttribute(tblStyle, "w", "val");
|
|
483
|
+
if (val) formatting.styleId = val;
|
|
484
|
+
}
|
|
485
|
+
const tblLook = findChild(tblPr, "w", "tblLook");
|
|
486
|
+
if (tblLook) {
|
|
487
|
+
const lookResult = parseTableLook(tblLook);
|
|
488
|
+
if (lookResult) formatting.look = lookResult;
|
|
489
|
+
}
|
|
490
|
+
const shd = findChild(tblPr, "w", "shd");
|
|
491
|
+
if (shd) {
|
|
492
|
+
const shadingResult = parseShadingProperties(shd);
|
|
493
|
+
if (shadingResult) formatting.shading = shadingResult;
|
|
494
|
+
}
|
|
495
|
+
const bidiVisual = findChild(tblPr, "w", "bidiVisual");
|
|
496
|
+
if (bidiVisual) formatting.bidi = parseBooleanElement(bidiVisual);
|
|
497
|
+
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Parse table row formatting properties (w:trPr)
|
|
501
|
+
*/
|
|
502
|
+
function parseTableRowProperties(trPr) {
|
|
503
|
+
if (!trPr) return;
|
|
504
|
+
const formatting = {};
|
|
505
|
+
const trHeight = findChild(trPr, "w", "trHeight");
|
|
506
|
+
if (trHeight) {
|
|
507
|
+
const heightResult = parseTableMeasurement(trHeight);
|
|
508
|
+
if (heightResult) formatting.height = heightResult;
|
|
509
|
+
const hRule = narrowEnum(getAttribute(trHeight, "w", "hRule"), TableRowHeightRuleSchema);
|
|
510
|
+
if (hRule) formatting.heightRule = hRule;
|
|
511
|
+
}
|
|
512
|
+
const tblHeader = findChild(trPr, "w", "tblHeader");
|
|
513
|
+
if (tblHeader) formatting.header = parseBooleanElement(tblHeader);
|
|
514
|
+
const cantSplit = findChild(trPr, "w", "cantSplit");
|
|
515
|
+
if (cantSplit) formatting.cantSplit = parseBooleanElement(cantSplit);
|
|
516
|
+
const jc = findChild(trPr, "w", "jc");
|
|
517
|
+
if (jc) {
|
|
518
|
+
const val = getAttribute(jc, "w", "val");
|
|
519
|
+
if (val === "left" || val === "center" || val === "right") formatting.justification = val;
|
|
520
|
+
}
|
|
521
|
+
const hidden = findChild(trPr, "w", "hidden");
|
|
522
|
+
if (hidden) formatting.hidden = parseBooleanElement(hidden);
|
|
523
|
+
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Parse table cell formatting properties (w:tcPr)
|
|
527
|
+
*/
|
|
528
|
+
function parseTableCellProperties(tcPr, _theme) {
|
|
529
|
+
if (!tcPr) return;
|
|
530
|
+
const formatting = {};
|
|
531
|
+
const tcW = findChild(tcPr, "w", "tcW");
|
|
532
|
+
if (tcW) {
|
|
533
|
+
const widthResult = parseTableMeasurement(tcW);
|
|
534
|
+
if (widthResult) formatting.width = widthResult;
|
|
535
|
+
}
|
|
536
|
+
const tcBorders = findChild(tcPr, "w", "tcBorders");
|
|
537
|
+
if (tcBorders) {
|
|
538
|
+
const bordersResult = parseTableBorders(tcBorders);
|
|
539
|
+
if (bordersResult) formatting.borders = bordersResult;
|
|
540
|
+
}
|
|
541
|
+
const tcMar = findChild(tcPr, "w", "tcMar");
|
|
542
|
+
if (tcMar) {
|
|
543
|
+
const marginsResult = parseCellMargins(tcMar);
|
|
544
|
+
if (marginsResult) formatting.margins = marginsResult;
|
|
545
|
+
}
|
|
546
|
+
const shd = findChild(tcPr, "w", "shd");
|
|
547
|
+
if (shd) {
|
|
548
|
+
const shadingResult = parseShadingProperties(shd);
|
|
549
|
+
if (shadingResult) formatting.shading = shadingResult;
|
|
550
|
+
}
|
|
551
|
+
const vAlign = findChild(tcPr, "w", "vAlign");
|
|
552
|
+
if (vAlign) {
|
|
553
|
+
const val = getAttribute(vAlign, "w", "val");
|
|
554
|
+
if (val === "top" || val === "center" || val === "bottom") formatting.verticalAlign = val;
|
|
555
|
+
}
|
|
556
|
+
const textDirection = findChild(tcPr, "w", "textDirection");
|
|
557
|
+
if (textDirection) {
|
|
558
|
+
const val = narrowEnum(getAttribute(textDirection, "w", "val"), TableCellTextDirectionSchema);
|
|
559
|
+
if (val) formatting.textDirection = val;
|
|
560
|
+
}
|
|
561
|
+
const gridSpan = findChild(tcPr, "w", "gridSpan");
|
|
562
|
+
if (gridSpan) {
|
|
563
|
+
const val = parseNumericAttribute(gridSpan, "w", "val");
|
|
564
|
+
if (val !== void 0) formatting.gridSpan = val;
|
|
565
|
+
}
|
|
566
|
+
const vMerge = findChild(tcPr, "w", "vMerge");
|
|
567
|
+
if (vMerge) formatting.vMerge = getAttribute(vMerge, "w", "val") === "restart" ? "restart" : "continue";
|
|
568
|
+
const tcFitText = findChild(tcPr, "w", "tcFitText");
|
|
569
|
+
if (tcFitText) formatting.fitText = parseBooleanElement(tcFitText);
|
|
570
|
+
const noWrap = findChild(tcPr, "w", "noWrap");
|
|
571
|
+
if (noWrap) formatting.noWrap = parseBooleanElement(noWrap);
|
|
572
|
+
const hideMark = findChild(tcPr, "w", "hideMark");
|
|
573
|
+
if (hideMark) formatting.hideMark = parseBooleanElement(hideMark);
|
|
574
|
+
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
575
|
+
}
|
|
576
|
+
function collectStyleChildren(styleEl) {
|
|
577
|
+
const children = { tblStylePrs: [] };
|
|
578
|
+
for (const child of styleEl.elements ?? []) {
|
|
579
|
+
if (child.type !== "element") continue;
|
|
580
|
+
switch (getLocalName(child.name || "")) {
|
|
581
|
+
case "basedOn":
|
|
582
|
+
children.basedOn ??= child;
|
|
583
|
+
break;
|
|
584
|
+
case "hidden":
|
|
585
|
+
children.hidden ??= child;
|
|
586
|
+
break;
|
|
587
|
+
case "link":
|
|
588
|
+
children.link ??= child;
|
|
589
|
+
break;
|
|
590
|
+
case "name":
|
|
591
|
+
children.name ??= child;
|
|
592
|
+
break;
|
|
593
|
+
case "next":
|
|
594
|
+
children.next ??= child;
|
|
595
|
+
break;
|
|
596
|
+
case "personal":
|
|
597
|
+
children.personal ??= child;
|
|
598
|
+
break;
|
|
599
|
+
case "pPr":
|
|
600
|
+
children.pPr ??= child;
|
|
601
|
+
break;
|
|
602
|
+
case "qFormat":
|
|
603
|
+
children.qFormat ??= child;
|
|
604
|
+
break;
|
|
605
|
+
case "rPr":
|
|
606
|
+
children.rPr ??= child;
|
|
607
|
+
break;
|
|
608
|
+
case "semiHidden":
|
|
609
|
+
children.semiHidden ??= child;
|
|
610
|
+
break;
|
|
611
|
+
case "tblPr":
|
|
612
|
+
children.tblPr ??= child;
|
|
613
|
+
break;
|
|
614
|
+
case "tblStylePr":
|
|
615
|
+
children.tblStylePrs.push(child);
|
|
616
|
+
break;
|
|
617
|
+
case "tcPr":
|
|
618
|
+
children.tcPr ??= child;
|
|
619
|
+
break;
|
|
620
|
+
case "trPr":
|
|
621
|
+
children.trPr ??= child;
|
|
622
|
+
break;
|
|
623
|
+
case "uiPriority":
|
|
624
|
+
children.uiPriority ??= child;
|
|
625
|
+
break;
|
|
626
|
+
case "unhideWhenUsed":
|
|
627
|
+
children.unhideWhenUsed ??= child;
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return children;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Parse a single style element (w:style)
|
|
635
|
+
*/
|
|
636
|
+
function parseStyle(styleEl, theme) {
|
|
637
|
+
const rawType = getAttribute(styleEl, "w", "type");
|
|
638
|
+
const style = {
|
|
639
|
+
styleId: getAttribute(styleEl, "w", "styleId") ?? "",
|
|
640
|
+
type: narrowEnum(rawType, StyleTypeSchema) ?? "paragraph"
|
|
641
|
+
};
|
|
642
|
+
const defaultAttr = getAttribute(styleEl, "w", "default");
|
|
643
|
+
if (defaultAttr) style.default = defaultAttr === "1" || defaultAttr === "true";
|
|
644
|
+
const children = collectStyleChildren(styleEl);
|
|
645
|
+
const nameEl = children.name;
|
|
646
|
+
if (nameEl) {
|
|
647
|
+
const nameVal = getAttribute(nameEl, "w", "val");
|
|
648
|
+
if (nameVal) style.name = nameVal;
|
|
649
|
+
}
|
|
650
|
+
const basedOn = children.basedOn;
|
|
651
|
+
if (basedOn) {
|
|
652
|
+
const basedOnVal = getAttribute(basedOn, "w", "val");
|
|
653
|
+
if (basedOnVal) style.basedOn = basedOnVal;
|
|
654
|
+
}
|
|
655
|
+
const next = children.next;
|
|
656
|
+
if (next) {
|
|
657
|
+
const nextVal = getAttribute(next, "w", "val");
|
|
658
|
+
if (nextVal) style.next = nextVal;
|
|
659
|
+
}
|
|
660
|
+
const link = children.link;
|
|
661
|
+
if (link) {
|
|
662
|
+
const linkVal = getAttribute(link, "w", "val");
|
|
663
|
+
if (linkVal) style.link = linkVal;
|
|
664
|
+
}
|
|
665
|
+
const uiPriority = children.uiPriority;
|
|
666
|
+
if (uiPriority) {
|
|
667
|
+
const val = parseNumericAttribute(uiPriority, "w", "val");
|
|
668
|
+
if (val !== void 0) style.uiPriority = val;
|
|
669
|
+
}
|
|
670
|
+
const hidden = children.hidden;
|
|
671
|
+
if (hidden) style.hidden = parseBooleanElement(hidden);
|
|
672
|
+
const semiHidden = children.semiHidden;
|
|
673
|
+
if (semiHidden) style.semiHidden = parseBooleanElement(semiHidden);
|
|
674
|
+
const unhideWhenUsed = children.unhideWhenUsed;
|
|
675
|
+
if (unhideWhenUsed) style.unhideWhenUsed = parseBooleanElement(unhideWhenUsed);
|
|
676
|
+
const qFormat = children.qFormat;
|
|
677
|
+
if (qFormat) style.qFormat = parseBooleanElement(qFormat);
|
|
678
|
+
const personal = children.personal;
|
|
679
|
+
if (personal) style.personal = parseBooleanElement(personal);
|
|
680
|
+
const pPr = children.pPr;
|
|
681
|
+
if (pPr) {
|
|
682
|
+
const pPrResult = parseParagraphProperties(pPr, theme);
|
|
683
|
+
if (pPrResult) style.pPr = pPrResult;
|
|
684
|
+
}
|
|
685
|
+
const rPr = children.rPr;
|
|
686
|
+
if (rPr) {
|
|
687
|
+
const rPrResult = parseRunProperties(rPr, theme);
|
|
688
|
+
if (rPrResult) style.rPr = rPrResult;
|
|
689
|
+
}
|
|
690
|
+
const tblPr = children.tblPr;
|
|
691
|
+
if (tblPr) {
|
|
692
|
+
const tblPrResult = parseTableProperties(tblPr, theme);
|
|
693
|
+
if (tblPrResult) style.tblPr = tblPrResult;
|
|
694
|
+
}
|
|
695
|
+
const trPr = children.trPr;
|
|
696
|
+
if (trPr) {
|
|
697
|
+
const trPrResult = parseTableRowProperties(trPr);
|
|
698
|
+
if (trPrResult) style.trPr = trPrResult;
|
|
699
|
+
}
|
|
700
|
+
const tcPr = children.tcPr;
|
|
701
|
+
if (tcPr) {
|
|
702
|
+
const tcPrResult = parseTableCellProperties(tcPr, theme);
|
|
703
|
+
if (tcPrResult) style.tcPr = tcPrResult;
|
|
704
|
+
}
|
|
705
|
+
const tblStylePrs = children.tblStylePrs;
|
|
706
|
+
if (tblStylePrs.length > 0) {
|
|
707
|
+
style.tblStylePr = [];
|
|
708
|
+
for (const tblStylePr of tblStylePrs) {
|
|
709
|
+
const conditionalType = narrowEnum(getAttribute(tblStylePr, "w", "type"), ConditionalStyleTypeSchema);
|
|
710
|
+
if (conditionalType) {
|
|
711
|
+
const conditionalStyle = { type: conditionalType };
|
|
712
|
+
const condPPr = findChild(tblStylePr, "w", "pPr");
|
|
713
|
+
if (condPPr) {
|
|
714
|
+
const condPPrResult = parseParagraphProperties(condPPr, theme);
|
|
715
|
+
if (condPPrResult) conditionalStyle.pPr = condPPrResult;
|
|
716
|
+
}
|
|
717
|
+
const condRPr = findChild(tblStylePr, "w", "rPr");
|
|
718
|
+
if (condRPr) {
|
|
719
|
+
const condRPrResult = parseRunProperties(condRPr, theme);
|
|
720
|
+
if (condRPrResult) conditionalStyle.rPr = condRPrResult;
|
|
721
|
+
}
|
|
722
|
+
const condTblPr = findChild(tblStylePr, "w", "tblPr");
|
|
723
|
+
if (condTblPr) {
|
|
724
|
+
const condTblPrResult = parseTableProperties(condTblPr, theme);
|
|
725
|
+
if (condTblPrResult) conditionalStyle.tblPr = condTblPrResult;
|
|
726
|
+
}
|
|
727
|
+
const condTrPr = findChild(tblStylePr, "w", "trPr");
|
|
728
|
+
if (condTrPr) {
|
|
729
|
+
const condTrPrResult = parseTableRowProperties(condTrPr);
|
|
730
|
+
if (condTrPrResult) conditionalStyle.trPr = condTrPrResult;
|
|
731
|
+
}
|
|
732
|
+
const condTcPr = findChild(tblStylePr, "w", "tcPr");
|
|
733
|
+
if (condTcPr) {
|
|
734
|
+
const condTcPrResult = parseTableCellProperties(condTcPr, theme);
|
|
735
|
+
if (condTcPrResult) conditionalStyle.tcPr = condTcPrResult;
|
|
736
|
+
}
|
|
737
|
+
style.tblStylePr.push(conditionalStyle);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return style;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Parse document defaults (w:docDefaults)
|
|
745
|
+
*/
|
|
746
|
+
function parseDocDefaults(docDefaults, theme) {
|
|
747
|
+
if (!docDefaults) return;
|
|
748
|
+
const result = {};
|
|
749
|
+
const rPrDefault = findChild(docDefaults, "w", "rPrDefault");
|
|
750
|
+
if (rPrDefault) {
|
|
751
|
+
const rPr = findChild(rPrDefault, "w", "rPr");
|
|
752
|
+
if (rPr) {
|
|
753
|
+
const rPrResult = parseRunProperties(rPr, theme);
|
|
754
|
+
if (rPrResult) result.rPr = rPrResult;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
const pPrDefault = findChild(docDefaults, "w", "pPrDefault");
|
|
758
|
+
if (pPrDefault) {
|
|
759
|
+
const pPr = findChild(pPrDefault, "w", "pPr");
|
|
760
|
+
if (pPr) {
|
|
761
|
+
const pPrResult = parseParagraphProperties(pPr, theme);
|
|
762
|
+
if (pPrResult) result.pPr = pPrResult;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return result;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Resolve style inheritance chain
|
|
769
|
+
*/
|
|
770
|
+
function resolveStyleInheritance(style, styleMap, visited = /* @__PURE__ */ new Set()) {
|
|
771
|
+
if (visited.has(style.styleId)) return style;
|
|
772
|
+
visited.add(style.styleId);
|
|
773
|
+
if (!style.basedOn) return style;
|
|
774
|
+
const parentStyle = styleMap.get(style.basedOn);
|
|
775
|
+
if (!parentStyle) return style;
|
|
776
|
+
const resolvedParent = resolveStyleInheritance(parentStyle, styleMap, visited);
|
|
777
|
+
const resolved = { ...style };
|
|
778
|
+
const mergedPPr = mergeParagraphFormatting(resolvedParent.pPr, style.pPr);
|
|
779
|
+
if (mergedPPr) resolved.pPr = mergedPPr;
|
|
780
|
+
const mergedRPr = mergeTextFormatting(resolvedParent.rPr, style.rPr);
|
|
781
|
+
if (mergedRPr) resolved.rPr = mergedRPr;
|
|
782
|
+
if (style.type === "table") {
|
|
783
|
+
if (resolvedParent.tblPr || style.tblPr) resolved.tblPr = {
|
|
784
|
+
...resolvedParent.tblPr,
|
|
785
|
+
...style.tblPr
|
|
786
|
+
};
|
|
787
|
+
if (resolvedParent.trPr || style.trPr) resolved.trPr = {
|
|
788
|
+
...resolvedParent.trPr,
|
|
789
|
+
...style.trPr
|
|
790
|
+
};
|
|
791
|
+
if (resolvedParent.tcPr || style.tcPr) resolved.tcPr = {
|
|
792
|
+
...resolvedParent.tcPr,
|
|
793
|
+
...style.tcPr
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
return resolved;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Parse styles.xml content
|
|
800
|
+
*
|
|
801
|
+
* @param stylesXml - XML content of styles.xml
|
|
802
|
+
* @param theme - Parsed theme for resolving theme references
|
|
803
|
+
* @returns StyleMap with resolved inheritance
|
|
804
|
+
*/
|
|
805
|
+
function parseStyles(stylesXml, theme) {
|
|
806
|
+
const doc = parseXmlDocument(stylesXml);
|
|
807
|
+
if (!doc) return /* @__PURE__ */ new Map();
|
|
808
|
+
return parseStylesFromDocument(doc, theme);
|
|
809
|
+
}
|
|
810
|
+
function parseStylesFromDocument(doc, theme) {
|
|
811
|
+
const styleMap = /* @__PURE__ */ new Map();
|
|
812
|
+
try {
|
|
813
|
+
const styleElements = findChildren(doc, "w", "style");
|
|
814
|
+
for (const styleEl of styleElements) {
|
|
815
|
+
const style = parseStyle(styleEl, theme);
|
|
816
|
+
if (style.styleId) styleMap.set(style.styleId, style);
|
|
817
|
+
}
|
|
818
|
+
for (const [styleId, style] of styleMap) {
|
|
819
|
+
const resolved = resolveStyleInheritance(style, styleMap);
|
|
820
|
+
styleMap.set(styleId, resolved);
|
|
821
|
+
}
|
|
822
|
+
} catch {}
|
|
823
|
+
return styleMap;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Parse complete style definitions including docDefaults
|
|
827
|
+
*
|
|
828
|
+
* @param stylesXml - XML content of styles.xml
|
|
829
|
+
* @param theme - Parsed theme for resolving theme references
|
|
830
|
+
* @returns StyleDefinitions with docDefaults and resolved styles
|
|
831
|
+
*/
|
|
832
|
+
function parseStyleDefinitions(stylesXml, theme, resolvedStyles) {
|
|
833
|
+
const doc = parseXmlDocument(stylesXml);
|
|
834
|
+
if (!doc) return { styles: [] };
|
|
835
|
+
return parseStyleDefinitionsFromDocument(doc, theme, resolvedStyles);
|
|
836
|
+
}
|
|
837
|
+
function parseStyleDefinitionsFromDocument(doc, theme, resolvedStyles) {
|
|
838
|
+
const result = { styles: [] };
|
|
839
|
+
try {
|
|
840
|
+
const parsedDocDefaults = parseDocDefaults(findChild(doc, "w", "docDefaults"), theme);
|
|
841
|
+
if (parsedDocDefaults) result.docDefaults = parsedDocDefaults;
|
|
842
|
+
const latentStylesEl = findChild(doc, "w", "latentStyles");
|
|
843
|
+
if (latentStylesEl) {
|
|
844
|
+
const latentStyles = {
|
|
845
|
+
defLockedState: getAttribute(latentStylesEl, "w", "defLockedState") === "1",
|
|
846
|
+
defSemiHidden: getAttribute(latentStylesEl, "w", "defSemiHidden") === "1",
|
|
847
|
+
defUnhideWhenUsed: getAttribute(latentStylesEl, "w", "defUnhideWhenUsed") === "1",
|
|
848
|
+
defQFormat: getAttribute(latentStylesEl, "w", "defQFormat") === "1"
|
|
849
|
+
};
|
|
850
|
+
const defUIPriority = parseNumericAttribute(latentStylesEl, "w", "defUIPriority");
|
|
851
|
+
if (defUIPriority !== void 0) latentStyles.defUIPriority = defUIPriority;
|
|
852
|
+
const count = parseNumericAttribute(latentStylesEl, "w", "count");
|
|
853
|
+
if (count !== void 0) latentStyles.count = count;
|
|
854
|
+
result.latentStyles = latentStyles;
|
|
855
|
+
}
|
|
856
|
+
const styleMap = resolvedStyles ?? parseStylesFromDocument(doc, theme);
|
|
857
|
+
result.styles = Array.from(styleMap.values());
|
|
858
|
+
} catch {}
|
|
859
|
+
return result;
|
|
860
|
+
}
|
|
861
|
+
function parseStylesPackage(stylesXml, theme) {
|
|
862
|
+
const doc = parseXmlDocument(stylesXml);
|
|
863
|
+
if (!doc) return {
|
|
864
|
+
styleDefinitions: { styles: [] },
|
|
865
|
+
styles: /* @__PURE__ */ new Map()
|
|
866
|
+
};
|
|
867
|
+
const styles = parseStylesFromDocument(doc, theme);
|
|
868
|
+
return {
|
|
869
|
+
styleDefinitions: parseStyleDefinitionsFromDocument(doc, theme, styles),
|
|
870
|
+
styles
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Get the resolved properties for a style
|
|
875
|
+
*
|
|
876
|
+
* @param styleId - Style ID to look up
|
|
877
|
+
* @param styleMap - Style map from parseStyles
|
|
878
|
+
* @returns Resolved style or undefined
|
|
879
|
+
*/
|
|
880
|
+
function getResolvedStyle(styleId, styleMap) {
|
|
881
|
+
return styleMap.get(styleId);
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Get the default paragraph style
|
|
885
|
+
*/
|
|
886
|
+
function getDefaultParagraphStyle(styleMap) {
|
|
887
|
+
for (const style of styleMap.values()) if (style.type === "paragraph" && style.default) return style;
|
|
888
|
+
return styleMap.get("Normal");
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Get the default character style
|
|
892
|
+
*/
|
|
893
|
+
function getDefaultCharacterStyle(styleMap) {
|
|
894
|
+
for (const style of styleMap.values()) if (style.type === "character" && style.default) return style;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Get all styles of a specific type
|
|
898
|
+
*/
|
|
899
|
+
function getStylesByType(styleMap, type) {
|
|
900
|
+
const result = [];
|
|
901
|
+
for (const style of styleMap.values()) if (style.type === type) result.push(style);
|
|
902
|
+
return result;
|
|
903
|
+
}
|
|
904
|
+
//#endregion
|
|
905
|
+
export { getDefaultCharacterStyle, getDefaultParagraphStyle, getResolvedStyle, getStylesByType, parseStyleDefinitions, parseStyles, parseStylesPackage };
|