@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,559 @@
|
|
|
1
|
+
import { numPrEqual } from "../numberingParser.js";
|
|
2
|
+
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
3
|
+
import { reconcileRawSdtPr } from "../sdtPropertiesPatch.js";
|
|
4
|
+
import { serializeBorder } from "./borderSerializer.js";
|
|
5
|
+
import { serializeRun, serializeTextFormatting } from "./runSerializer.js";
|
|
6
|
+
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
7
|
+
//#region src/docx/serializer/paragraphSerializer.ts
|
|
8
|
+
/**
|
|
9
|
+
* Serialize paragraph borders (w:pBdr)
|
|
10
|
+
*/
|
|
11
|
+
function serializeParagraphBorders(borders) {
|
|
12
|
+
if (!borders) return "";
|
|
13
|
+
const parts = [];
|
|
14
|
+
if (borders.top) {
|
|
15
|
+
const topXml = serializeBorder(borders.top, "top");
|
|
16
|
+
if (topXml) parts.push(topXml);
|
|
17
|
+
}
|
|
18
|
+
if (borders.left) {
|
|
19
|
+
const leftXml = serializeBorder(borders.left, "left");
|
|
20
|
+
if (leftXml) parts.push(leftXml);
|
|
21
|
+
}
|
|
22
|
+
if (borders.bottom) {
|
|
23
|
+
const bottomXml = serializeBorder(borders.bottom, "bottom");
|
|
24
|
+
if (bottomXml) parts.push(bottomXml);
|
|
25
|
+
}
|
|
26
|
+
if (borders.right) {
|
|
27
|
+
const rightXml = serializeBorder(borders.right, "right");
|
|
28
|
+
if (rightXml) parts.push(rightXml);
|
|
29
|
+
}
|
|
30
|
+
if (borders.between) {
|
|
31
|
+
const betweenXml = serializeBorder(borders.between, "between");
|
|
32
|
+
if (betweenXml) parts.push(betweenXml);
|
|
33
|
+
}
|
|
34
|
+
if (borders.bar) {
|
|
35
|
+
const barXml = serializeBorder(borders.bar, "bar");
|
|
36
|
+
if (barXml) parts.push(barXml);
|
|
37
|
+
}
|
|
38
|
+
if (parts.length === 0) return "";
|
|
39
|
+
return `<w:pBdr>${parts.join("")}</w:pBdr>`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Serialize shading properties (w:shd)
|
|
43
|
+
*/
|
|
44
|
+
function serializeShading(shading) {
|
|
45
|
+
if (!shading) return "";
|
|
46
|
+
const attrs = [];
|
|
47
|
+
if (shading.pattern) attrs.push(`w:val="${shading.pattern}"`);
|
|
48
|
+
else attrs.push("w:val=\"clear\"");
|
|
49
|
+
if (shading.color?.rgb) attrs.push(`w:color="${shading.color.rgb}"`);
|
|
50
|
+
else if (shading.color?.auto) attrs.push("w:color=\"auto\"");
|
|
51
|
+
if (shading.fill?.rgb) attrs.push(`w:fill="${shading.fill.rgb}"`);
|
|
52
|
+
else if (shading.fill?.auto) attrs.push("w:fill=\"auto\"");
|
|
53
|
+
if (shading.fill?.themeColor) attrs.push(`w:themeFill="${shading.fill.themeColor}"`);
|
|
54
|
+
if (shading.fill?.themeTint) attrs.push(`w:themeFillTint="${shading.fill.themeTint}"`);
|
|
55
|
+
if (shading.fill?.themeShade) attrs.push(`w:themeFillShade="${shading.fill.themeShade}"`);
|
|
56
|
+
if (attrs.length === 0) return "";
|
|
57
|
+
return `<w:shd ${attrs.join(" ")}/>`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Serialize tab stops (w:tabs)
|
|
61
|
+
*/
|
|
62
|
+
function serializeTabStops(tabs) {
|
|
63
|
+
if (!tabs || tabs.length === 0) return "";
|
|
64
|
+
return `<w:tabs>${tabs.map((tab) => {
|
|
65
|
+
const attrs = [`w:val="${tab.alignment}"`, `w:pos="${intAttr(tab.position)}"`];
|
|
66
|
+
if (tab.leader && tab.leader !== "none") attrs.push(`w:leader="${tab.leader}"`);
|
|
67
|
+
return `<w:tab ${attrs.join(" ")}/>`;
|
|
68
|
+
}).join("")}</w:tabs>`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Serialize spacing properties (w:spacing)
|
|
72
|
+
*/
|
|
73
|
+
function serializeSpacing(formatting) {
|
|
74
|
+
const attrs = [];
|
|
75
|
+
if (formatting.spaceBefore !== void 0) attrs.push(`w:before="${intAttr(formatting.spaceBefore)}"`);
|
|
76
|
+
if (formatting.spaceAfter !== void 0) attrs.push(`w:after="${intAttr(formatting.spaceAfter)}"`);
|
|
77
|
+
if (formatting.lineSpacing !== void 0) attrs.push(`w:line="${intAttr(formatting.lineSpacing)}"`);
|
|
78
|
+
if (formatting.lineSpacingRule) attrs.push(`w:lineRule="${formatting.lineSpacingRule}"`);
|
|
79
|
+
if (formatting.beforeAutospacing !== void 0) attrs.push(`w:beforeAutospacing="${formatting.beforeAutospacing ? "1" : "0"}"`);
|
|
80
|
+
if (formatting.afterAutospacing !== void 0) attrs.push(`w:afterAutospacing="${formatting.afterAutospacing ? "1" : "0"}"`);
|
|
81
|
+
if (attrs.length === 0) return "";
|
|
82
|
+
return `<w:spacing ${attrs.join(" ")}/>`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Serialize indentation properties (w:ind)
|
|
86
|
+
*/
|
|
87
|
+
function serializeIndentation(formatting) {
|
|
88
|
+
const attrs = [];
|
|
89
|
+
if (formatting.indentLeft !== void 0) attrs.push(`w:left="${intAttr(formatting.indentLeft)}"`);
|
|
90
|
+
if (formatting.indentRight !== void 0) attrs.push(`w:right="${intAttr(formatting.indentRight)}"`);
|
|
91
|
+
if (formatting.indentFirstLine !== void 0) {
|
|
92
|
+
if (formatting.hangingIndent) attrs.push(`w:hanging="${intAttr(Math.abs(formatting.indentFirstLine))}"`);
|
|
93
|
+
else if (formatting.indentFirstLine !== 0) attrs.push(`w:firstLine="${intAttr(formatting.indentFirstLine)}"`);
|
|
94
|
+
}
|
|
95
|
+
if (attrs.length === 0) return "";
|
|
96
|
+
return `<w:ind ${attrs.join(" ")}/>`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Serialize numbering properties (w:numPr)
|
|
100
|
+
*/
|
|
101
|
+
function serializeNumbering(numPr) {
|
|
102
|
+
if (!numPr) return "";
|
|
103
|
+
const parts = [];
|
|
104
|
+
if (numPr.ilvl !== void 0) parts.push(`<w:ilvl w:val="${intAttr(numPr.ilvl)}"/>`);
|
|
105
|
+
if (numPr.numId !== void 0) parts.push(`<w:numId w:val="${intAttr(numPr.numId)}"/>`);
|
|
106
|
+
if (parts.length === 0) return "";
|
|
107
|
+
return `<w:numPr>${parts.join("")}</w:numPr>`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Serialize frame properties (w:framePr)
|
|
111
|
+
*/
|
|
112
|
+
function serializeFrameProperties(frame) {
|
|
113
|
+
if (!frame) return "";
|
|
114
|
+
const attrs = [];
|
|
115
|
+
if (frame.width !== void 0) attrs.push(`w:w="${intAttr(frame.width)}"`);
|
|
116
|
+
if (frame.height !== void 0) attrs.push(`w:h="${intAttr(frame.height)}"`);
|
|
117
|
+
if (frame.hAnchor) attrs.push(`w:hAnchor="${frame.hAnchor}"`);
|
|
118
|
+
if (frame.vAnchor) attrs.push(`w:vAnchor="${frame.vAnchor}"`);
|
|
119
|
+
if (frame.x !== void 0) attrs.push(`w:x="${frame.x}"`);
|
|
120
|
+
if (frame.y !== void 0) attrs.push(`w:y="${frame.y}"`);
|
|
121
|
+
if (frame.xAlign) attrs.push(`w:xAlign="${frame.xAlign}"`);
|
|
122
|
+
if (frame.yAlign) attrs.push(`w:yAlign="${frame.yAlign}"`);
|
|
123
|
+
if (frame.wrap) attrs.push(`w:wrap="${frame.wrap}"`);
|
|
124
|
+
if (attrs.length === 0) return "";
|
|
125
|
+
return `<w:framePr ${attrs.join(" ")}/>`;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Serialize paragraph formatting properties to w:pPr XML
|
|
129
|
+
*/
|
|
130
|
+
function serializeTrackedChangeAttrs(info) {
|
|
131
|
+
const parts = [`w:id="${info.id}"`, `w:author="${escapeXml(info.author)}"`];
|
|
132
|
+
if (info.date !== void 0) parts.push(`w:date="${escapeXml(info.date)}"`);
|
|
133
|
+
return parts.join(" ");
|
|
134
|
+
}
|
|
135
|
+
function serializeParagraphMarkChange(mark) {
|
|
136
|
+
const attrs = serializeTrackedChangeAttrs(mark.info);
|
|
137
|
+
return `<w:${mark.kind} ${attrs}/>`;
|
|
138
|
+
}
|
|
139
|
+
function serializeParagraphFormatting(formatting, propertyChanges, pPrMark) {
|
|
140
|
+
const parts = [];
|
|
141
|
+
const pushToggle = (name, value) => {
|
|
142
|
+
if (value === true) parts.push(`<w:${name}/>`);
|
|
143
|
+
else if (value === false) parts.push(`<w:${name} w:val="0"/>`);
|
|
144
|
+
};
|
|
145
|
+
if (formatting) {
|
|
146
|
+
if (formatting.styleId) parts.push(`<w:pStyle w:val="${escapeXml(formatting.styleId)}"/>`);
|
|
147
|
+
pushToggle("keepNext", formatting.keepNext);
|
|
148
|
+
pushToggle("keepLines", formatting.keepLines);
|
|
149
|
+
pushToggle("contextualSpacing", formatting.contextualSpacing);
|
|
150
|
+
pushToggle("pageBreakBefore", formatting.pageBreakBefore);
|
|
151
|
+
const frameXml = serializeFrameProperties(formatting.frame);
|
|
152
|
+
if (frameXml) parts.push(frameXml);
|
|
153
|
+
pushToggle("widowControl", formatting.widowControl);
|
|
154
|
+
const numPrXml = formatting.numPrFromStyle != null && numPrEqual(formatting.numPr, formatting.numPrFromStyle) ? "" : serializeNumbering(formatting.numPr);
|
|
155
|
+
if (numPrXml) parts.push(numPrXml);
|
|
156
|
+
const bordersXml = serializeParagraphBorders(formatting.borders);
|
|
157
|
+
if (bordersXml) parts.push(bordersXml);
|
|
158
|
+
const shadingXml = serializeShading(formatting.shading);
|
|
159
|
+
if (shadingXml) parts.push(shadingXml);
|
|
160
|
+
const tabsXml = serializeTabStops(formatting.tabs);
|
|
161
|
+
if (tabsXml) parts.push(tabsXml);
|
|
162
|
+
pushToggle("suppressLineNumbers", formatting.suppressLineNumbers);
|
|
163
|
+
pushToggle("suppressAutoHyphens", formatting.suppressAutoHyphens);
|
|
164
|
+
const spacingXml = serializeSpacing(formatting);
|
|
165
|
+
if (spacingXml) parts.push(spacingXml);
|
|
166
|
+
const indXml = serializeIndentation(formatting);
|
|
167
|
+
if (indXml) parts.push(indXml);
|
|
168
|
+
pushToggle("bidi", formatting.bidi);
|
|
169
|
+
if (formatting.alignment) parts.push(`<w:jc w:val="${formatting.alignment}"/>`);
|
|
170
|
+
if (formatting.outlineLevel !== void 0) parts.push(`<w:outlineLvl w:val="${formatting.outlineLevel}"/>`);
|
|
171
|
+
if (pPrMark || formatting.runProperties || formatting.runInWithNext) {
|
|
172
|
+
const fullInner = `${pPrMark ? serializeParagraphMarkChange(pPrMark) : ""}${formatting.runProperties ? extractRPrInner(serializeTextFormatting(formatting.runProperties)) : ""}${formatting.runInWithNext ? "<w:specVanish/>" : ""}`;
|
|
173
|
+
if (fullInner.length > 0) parts.push(`<w:rPr>${fullInner}</w:rPr>`);
|
|
174
|
+
}
|
|
175
|
+
} else if (pPrMark) parts.push(`<w:rPr>${serializeParagraphMarkChange(pPrMark)}</w:rPr>`);
|
|
176
|
+
if (propertyChanges && propertyChanges.length > 0) parts.push(...propertyChanges.map((change) => serializeParagraphPropertyChange(change)));
|
|
177
|
+
if (parts.length === 0) return "";
|
|
178
|
+
return `<w:pPr>${parts.join("")}</w:pPr>`;
|
|
179
|
+
}
|
|
180
|
+
function extractPPrInner(pPrXml) {
|
|
181
|
+
if (!pPrXml.startsWith("<w:pPr>") || !pPrXml.endsWith("</w:pPr>")) return "";
|
|
182
|
+
return pPrXml.slice(7, -8);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Strip the outer `<w:rPr>...</w:rPr>` wrapper so callers can splice
|
|
186
|
+
* additional rPr children (e.g. `<w:specVanish/>`) and re-emit a
|
|
187
|
+
* single rPr element.
|
|
188
|
+
*/
|
|
189
|
+
function extractRPrInner(rPrXml) {
|
|
190
|
+
if (!rPrXml.startsWith("<w:rPr>") || !rPrXml.endsWith("</w:rPr>")) return "";
|
|
191
|
+
return rPrXml.slice(7, -8);
|
|
192
|
+
}
|
|
193
|
+
function serializeParagraphPropertyChange(change) {
|
|
194
|
+
const normalizedId = Number.isInteger(change.info.id) && change.info.id >= 0 ? change.info.id : 0;
|
|
195
|
+
const authorCandidate = typeof change.info.author === "string" ? change.info.author.trim() : "";
|
|
196
|
+
const normalizedAuthor = authorCandidate.length > 0 ? authorCandidate : "Unknown";
|
|
197
|
+
const normalizedDate = typeof change.info.date === "string" ? change.info.date.trim() : void 0;
|
|
198
|
+
const normalizedRsid = typeof change.info.rsid === "string" ? change.info.rsid.trim() : void 0;
|
|
199
|
+
const attrs = [`w:id="${normalizedId}"`, `w:author="${escapeXml(normalizedAuthor)}"`];
|
|
200
|
+
if (normalizedDate) attrs.push(`w:date="${escapeXml(normalizedDate)}"`);
|
|
201
|
+
if (normalizedRsid) attrs.push(`w:rsid="${escapeXml(normalizedRsid)}"`);
|
|
202
|
+
const previousPPrInner = extractPPrInner(serializeParagraphFormatting(change.previousFormatting) || "<w:pPr/>");
|
|
203
|
+
const normalizedPreviousPPr = previousPPrInner.length > 0 ? `<w:pPr>${previousPPrInner}</w:pPr>` : "<w:pPr/>";
|
|
204
|
+
return `<w:pPrChange ${attrs.join(" ")}>${normalizedPreviousPPr}</w:pPrChange>`;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Serialize a hyperlink (w:hyperlink)
|
|
208
|
+
*/
|
|
209
|
+
function serializeHyperlink(hyperlink) {
|
|
210
|
+
const attrs = [];
|
|
211
|
+
if (hyperlink.rId) attrs.push(`r:id="${hyperlink.rId}"`);
|
|
212
|
+
if (hyperlink.anchor) attrs.push(`w:anchor="${escapeXml(hyperlink.anchor)}"`);
|
|
213
|
+
if (hyperlink.tooltip) attrs.push(`w:tooltip="${escapeXml(hyperlink.tooltip)}"`);
|
|
214
|
+
if (hyperlink.target) attrs.push(`w:tgtFrame="${escapeXml(hyperlink.target)}"`);
|
|
215
|
+
if (hyperlink.history === true) attrs.push("w:history=\"1\"");
|
|
216
|
+
else if (hyperlink.history === false) attrs.push("w:history=\"0\"");
|
|
217
|
+
if (hyperlink.docLocation) attrs.push(`w:docLocation="${escapeXml(hyperlink.docLocation)}"`);
|
|
218
|
+
const childrenXml = hyperlink.children.map((child) => {
|
|
219
|
+
if (child.type === "run") return serializeRun(child);
|
|
220
|
+
if (child.type === "bookmarkStart") return serializeBookmarkStart(child);
|
|
221
|
+
return serializeBookmarkEnd(child);
|
|
222
|
+
}).join("");
|
|
223
|
+
return `<w:hyperlink${attrs.length > 0 ? ` ${attrs.join(" ")}` : ""}>${childrenXml}</w:hyperlink>`;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Serialize bookmark start (w:bookmarkStart)
|
|
227
|
+
*/
|
|
228
|
+
function serializeBookmarkStart(bookmark) {
|
|
229
|
+
const attrs = [`w:id="${bookmark.id}"`, `w:name="${escapeXml(bookmark.name)}"`];
|
|
230
|
+
if (bookmark.colFirst !== void 0) attrs.push(`w:colFirst="${bookmark.colFirst}"`);
|
|
231
|
+
if (bookmark.colLast !== void 0) attrs.push(`w:colLast="${bookmark.colLast}"`);
|
|
232
|
+
return `<w:bookmarkStart ${attrs.join(" ")}/>`;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Serialize bookmark end (w:bookmarkEnd)
|
|
236
|
+
*/
|
|
237
|
+
function serializeBookmarkEnd(bookmark) {
|
|
238
|
+
return `<w:bookmarkEnd w:id="${bookmark.id}"/>`;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Serialize a simple field as a complex field (fldChar begin/separate/end).
|
|
242
|
+
* Complex field format is more widely supported by OOXML consumers
|
|
243
|
+
* (Google Docs, Apple Pages) than w:fldSimple.
|
|
244
|
+
*/
|
|
245
|
+
function serializeSimpleField(field) {
|
|
246
|
+
const parts = [];
|
|
247
|
+
const firstRun = field.content.find((c) => c.type === "run");
|
|
248
|
+
const rPrXml = firstRun?.formatting ? serializeTextFormatting(firstRun.formatting) : "";
|
|
249
|
+
const beginAttrs = ["w:fldCharType=\"begin\""];
|
|
250
|
+
if (field.fldLock) beginAttrs.push("w:fldLock=\"true\"");
|
|
251
|
+
parts.push(`<w:r>${rPrXml}<w:fldChar ${beginAttrs.join(" ")}/></w:r>`);
|
|
252
|
+
const spaceAttr = field.instruction.startsWith(" ") || field.instruction.endsWith(" ") || field.instruction.includes(" ") ? " xml:space=\"preserve\"" : "";
|
|
253
|
+
parts.push(`<w:r>${rPrXml}<w:instrText${spaceAttr}>${escapeXml(field.instruction)}</w:instrText></w:r>`);
|
|
254
|
+
parts.push(`<w:r>${rPrXml}<w:fldChar w:fldCharType="separate"/></w:r>`);
|
|
255
|
+
for (const item of field.content) if (item.type === "run") parts.push(serializeRun(item));
|
|
256
|
+
parts.push(`<w:r>${rPrXml}<w:fldChar w:fldCharType="end"/></w:r>`);
|
|
257
|
+
return parts.join("");
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Serialize a complex field
|
|
261
|
+
* Complex fields are represented by multiple runs with fldChar elements,
|
|
262
|
+
* so we convert them back to that structure
|
|
263
|
+
*/
|
|
264
|
+
function serializeComplexField(field) {
|
|
265
|
+
const parts = [];
|
|
266
|
+
const structuralFormatting = field.formatting ?? field.fieldResult[0]?.formatting;
|
|
267
|
+
const rPrXml = structuralFormatting ? serializeTextFormatting(structuralFormatting) : "";
|
|
268
|
+
const beginAttrs = ["w:fldCharType=\"begin\""];
|
|
269
|
+
if (field.fldLock) beginAttrs.push("w:fldLock=\"true\"");
|
|
270
|
+
parts.push(`<w:r>${rPrXml}<w:fldChar ${beginAttrs.join(" ")}/></w:r>`);
|
|
271
|
+
if (field.fieldCode.length > 0) parts.push(...field.fieldCode.map((run) => serializeRun(run)));
|
|
272
|
+
else {
|
|
273
|
+
const spaceAttr = field.instruction.startsWith(" ") || field.instruction.endsWith(" ") || field.instruction.includes(" ") ? " xml:space=\"preserve\"" : "";
|
|
274
|
+
parts.push(`<w:r>${rPrXml}<w:instrText${spaceAttr}>${escapeXml(field.instruction)}</w:instrText></w:r>`);
|
|
275
|
+
}
|
|
276
|
+
parts.push(`<w:r>${rPrXml}<w:fldChar w:fldCharType="separate"/></w:r>`);
|
|
277
|
+
parts.push(...field.fieldResult.map((run) => serializeRun(run)));
|
|
278
|
+
parts.push(`<w:r>${rPrXml}<w:fldChar w:fldCharType="end"/></w:r>`);
|
|
279
|
+
return parts.join("");
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Synthesize a `<w:sdtPr>` from the modeled {@link SdtProperties}.
|
|
283
|
+
*
|
|
284
|
+
* Only reached for an inline SDT that carries no captured `rawPropertiesXml`
|
|
285
|
+
* (constructed programmatically rather than parsed from a DOCX). Mirrors the
|
|
286
|
+
* block-SDT fallback: emit `w:id` first so the parsed numeric id survives,
|
|
287
|
+
* then the shared identity fields, then the type-defining marker.
|
|
288
|
+
*/
|
|
289
|
+
function synthesizeInlineSdtPr(props) {
|
|
290
|
+
const prParts = [];
|
|
291
|
+
if (typeof props.id === "number") prParts.push(`<w:id w:val="${props.id}"/>`);
|
|
292
|
+
if (props.alias) prParts.push(`<w:alias w:val="${escapeXml(props.alias)}"/>`);
|
|
293
|
+
if (props.tag) prParts.push(`<w:tag w:val="${escapeXml(props.tag)}"/>`);
|
|
294
|
+
if (props.lock && props.lock !== "unlocked") prParts.push(`<w:lock w:val="${props.lock}"/>`);
|
|
295
|
+
if (props.placeholder) prParts.push(`<w:placeholder><w:docPart w:val="${escapeXml(props.placeholder)}"/></w:placeholder>`);
|
|
296
|
+
if (props.showingPlaceholder) prParts.push("<w:showingPlcHdr/>");
|
|
297
|
+
switch (props.sdtType) {
|
|
298
|
+
case "plainText":
|
|
299
|
+
prParts.push("<w:text/>");
|
|
300
|
+
break;
|
|
301
|
+
case "date": {
|
|
302
|
+
const fullDateAttr = props.dateValueISO ? ` w:fullDate="${escapeXml(props.dateValueISO)}"` : "";
|
|
303
|
+
const formatChild = props.dateFormat ? `<w:dateFormat w:val="${escapeXml(props.dateFormat)}"/>` : "";
|
|
304
|
+
if (fullDateAttr || formatChild) prParts.push(`<w:date${fullDateAttr}>${formatChild}</w:date>`);
|
|
305
|
+
else prParts.push("<w:date/>");
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
case "dropdown": {
|
|
309
|
+
const items = (props.listItems ?? []).map((i) => `<w:listItem w:displayText="${escapeXml(i.displayText)}" w:value="${escapeXml(i.value)}"/>`).join("");
|
|
310
|
+
prParts.push(`<w:dropDownList>${items}</w:dropDownList>`);
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
case "comboBox": {
|
|
314
|
+
const items = (props.listItems ?? []).map((i) => `<w:listItem w:displayText="${escapeXml(i.displayText)}" w:value="${escapeXml(i.value)}"/>`).join("");
|
|
315
|
+
prParts.push(`<w:comboBox>${items}</w:comboBox>`);
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
case "checkbox":
|
|
319
|
+
prParts.push(`<w14:checkbox><w14:checked w14:val="${props.checked ? "1" : "0"}"/></w14:checkbox>`);
|
|
320
|
+
break;
|
|
321
|
+
case "picture":
|
|
322
|
+
prParts.push("<w:picture/>");
|
|
323
|
+
break;
|
|
324
|
+
case "richText":
|
|
325
|
+
case "buildingBlockGallery":
|
|
326
|
+
case "group":
|
|
327
|
+
case "unknown": break;
|
|
328
|
+
}
|
|
329
|
+
return `<w:sdtPr>${prParts.join("")}</w:sdtPr>`;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Serialize an inline SDT (w:sdt).
|
|
333
|
+
*
|
|
334
|
+
* Replays the captured `<w:sdtPr>` / `<w:sdtEndPr>` verbatim so unmodeled
|
|
335
|
+
* OOXML features (`w:id`, `w:dataBinding`, `w15:*`, custom XML mappings)
|
|
336
|
+
* survive the round-trip, mirroring the block-SDT serializer. Without this
|
|
337
|
+
* the properties block was re-synthesized from the modeled projection alone,
|
|
338
|
+
* silently dropping every unmodeled feature (and `w:sdtEndPr`) on save.
|
|
339
|
+
*/
|
|
340
|
+
function serializeInlineSdt(sdt) {
|
|
341
|
+
const props = sdt.properties;
|
|
342
|
+
const contentXml = sdt.content.map((item) => {
|
|
343
|
+
switch (item.type) {
|
|
344
|
+
case "run": return serializeRun(item);
|
|
345
|
+
case "hyperlink": return serializeHyperlink(item);
|
|
346
|
+
case "simpleField": return serializeSimpleField(item);
|
|
347
|
+
case "complexField": return serializeComplexField(item);
|
|
348
|
+
case "inlineSdt": return serializeInlineSdt(item);
|
|
349
|
+
case "mathEquation": return item.ommlXml || "";
|
|
350
|
+
default: return item;
|
|
351
|
+
}
|
|
352
|
+
}).join("");
|
|
353
|
+
const baseSdtPr = props.rawPropertiesXml ?? synthesizeInlineSdtPr(props);
|
|
354
|
+
const dateFullDate = props.sdtType === "date" && props.dateValueISO ? props.dateValueISO : void 0;
|
|
355
|
+
const dropdownLastValue = (props.sdtType === "dropdown" || props.sdtType === "comboBox") && typeof props.dropdownLastValue === "string" ? props.dropdownLastValue : void 0;
|
|
356
|
+
return `<w:sdt>${reconcileRawSdtPr(baseSdtPr, props, {
|
|
357
|
+
...dateFullDate !== void 0 ? { dateFullDate } : {},
|
|
358
|
+
...dropdownLastValue !== void 0 ? { dropdownLastValue } : {}
|
|
359
|
+
})}${props.rawEndPropertiesXml ?? ""}<w:sdtContent>${contentXml}</w:sdtContent></w:sdt>`;
|
|
360
|
+
}
|
|
361
|
+
function serializeMoveRangeStart(tag, marker) {
|
|
362
|
+
return `<w:${tag} ${[`w:id="${marker.id}"`, `w:name="${escapeXml(marker.name)}"`].join(" ")}/>`;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Serialize a tracked change wrapper (ins/del/moveFrom/moveTo)
|
|
366
|
+
*/
|
|
367
|
+
function rewriteRunTextAsDeleted(xml) {
|
|
368
|
+
return xml.replace(/<w:t\b/gu, "<w:delText").replace(/<\/w:t>/gu, "</w:delText>").replace(/<w:instrText\b/gu, "<w:delInstrText").replace(/<\/w:instrText>/gu, "</w:delInstrText>");
|
|
369
|
+
}
|
|
370
|
+
function serializeTrackedChange(tag, change) {
|
|
371
|
+
const info = change.info;
|
|
372
|
+
const normalizedId = Number.isInteger(info.id) && info.id >= 0 ? info.id : 0;
|
|
373
|
+
const authorCandidate = typeof info.author === "string" ? info.author.trim() : "";
|
|
374
|
+
const normalizedAuthor = authorCandidate.length > 0 ? authorCandidate : "Unknown";
|
|
375
|
+
const normalizedDate = typeof info.date === "string" ? info.date.trim() : void 0;
|
|
376
|
+
const attrs = [`w:id="${normalizedId}"`, `w:author="${escapeXml(normalizedAuthor)}"`];
|
|
377
|
+
if (normalizedDate) attrs.push(`w:date="${escapeXml(normalizedDate)}"`);
|
|
378
|
+
const serializeDeletedRun = (run) => {
|
|
379
|
+
const xml = serializeRun(run);
|
|
380
|
+
if (!run.content.some((c) => c.type === "drawing" || c.type === "shape")) return rewriteRunTextAsDeleted(xml);
|
|
381
|
+
if (!run.content.some((c) => c.type !== "drawing" && c.type !== "shape")) return xml;
|
|
382
|
+
return run.content.map((content) => {
|
|
383
|
+
const contentXml = serializeRun({
|
|
384
|
+
...run,
|
|
385
|
+
content: [content]
|
|
386
|
+
});
|
|
387
|
+
if (content.type === "drawing" || content.type === "shape") return contentXml;
|
|
388
|
+
return rewriteRunTextAsDeleted(contentXml);
|
|
389
|
+
}).join("");
|
|
390
|
+
};
|
|
391
|
+
const contentXml = change.content.map((item) => {
|
|
392
|
+
if (item.type === "run") {
|
|
393
|
+
if (tag === "del" || tag === "moveFrom") return serializeDeletedRun(item);
|
|
394
|
+
return serializeRun(item);
|
|
395
|
+
}
|
|
396
|
+
return serializeHyperlink(item);
|
|
397
|
+
}).join("");
|
|
398
|
+
return `<w:${tag} ${attrs.join(" ")}>${contentXml}</w:${tag}>`;
|
|
399
|
+
}
|
|
400
|
+
/** Emit the `<w:commentReference>` run Word places after a comment range end. */
|
|
401
|
+
function serializeCommentReferenceRun(id) {
|
|
402
|
+
return `<w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="${id}"/></w:r>`;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Serialize a single paragraph content item.
|
|
406
|
+
*
|
|
407
|
+
* `explicitCommentReferenceIds` holds the comment ids that already have their
|
|
408
|
+
* own `commentReference` node in this paragraph (the parsed-from-Word shape).
|
|
409
|
+
* For those, the `commentRangeEnd` marker must NOT also synthesize a reference
|
|
410
|
+
* run, or a save→parse round-trip doubles the `<w:commentReference>`. The
|
|
411
|
+
* editor (fromProseDoc) path emits range markers with no reference node, so the
|
|
412
|
+
* synthetic run is still written when the id is absent from the set.
|
|
413
|
+
*/
|
|
414
|
+
function serializeParagraphContent(content, explicitCommentReferenceIds) {
|
|
415
|
+
switch (content.type) {
|
|
416
|
+
case "run": return serializeRun(content);
|
|
417
|
+
case "hyperlink": return serializeHyperlink(content);
|
|
418
|
+
case "bookmarkStart": return serializeBookmarkStart(content);
|
|
419
|
+
case "bookmarkEnd": return serializeBookmarkEnd(content);
|
|
420
|
+
case "simpleField": return serializeSimpleField(content);
|
|
421
|
+
case "complexField": return serializeComplexField(content);
|
|
422
|
+
case "inlineSdt": return serializeInlineSdt(content);
|
|
423
|
+
case "commentRangeStart": return `<w:commentRangeStart w:id="${content.id}"/>`;
|
|
424
|
+
case "commentRangeEnd": return explicitCommentReferenceIds.has(content.id) ? `<w:commentRangeEnd w:id="${content.id}"/>` : `<w:commentRangeEnd w:id="${content.id}"/>${serializeCommentReferenceRun(content.id)}`;
|
|
425
|
+
case "commentReference": return serializeCommentReferenceRun(content.id);
|
|
426
|
+
case "insertion": return serializeTrackedChange("ins", content);
|
|
427
|
+
case "deletion": return serializeTrackedChange("del", content);
|
|
428
|
+
case "moveFrom": return serializeTrackedChange("moveFrom", content);
|
|
429
|
+
case "moveTo": return serializeTrackedChange("moveTo", content);
|
|
430
|
+
case "moveFromRangeStart": return serializeMoveRangeStart("moveFromRangeStart", content);
|
|
431
|
+
case "moveFromRangeEnd": return `<w:moveFromRangeEnd w:id="${content.id}"/>`;
|
|
432
|
+
case "moveToRangeStart": return serializeMoveRangeStart("moveToRangeStart", content);
|
|
433
|
+
case "moveToRangeEnd": return `<w:moveToRangeEnd w:id="${content.id}"/>`;
|
|
434
|
+
case "mathEquation": return content.ommlXml || "";
|
|
435
|
+
default: return "";
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Serialize a paragraph to OOXML XML (w:p)
|
|
440
|
+
*
|
|
441
|
+
* @param paragraph - The paragraph to serialize
|
|
442
|
+
* @returns XML string for the paragraph
|
|
443
|
+
*/
|
|
444
|
+
function serializeParagraph(paragraph) {
|
|
445
|
+
const parts = [];
|
|
446
|
+
const attrs = [];
|
|
447
|
+
if (paragraph.paraId) attrs.push(`w14:paraId="${paragraph.paraId}"`);
|
|
448
|
+
if (paragraph.textId) attrs.push(`w14:textId="${paragraph.textId}"`);
|
|
449
|
+
const attrsStr = attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
450
|
+
const pPrXml = serializeParagraphFormatting(paragraph.formatting, paragraph.propertyChanges, paragraph.pPrMark);
|
|
451
|
+
const sectionPropertiesXml = serializeSectionProperties(paragraph.sectionProperties);
|
|
452
|
+
if (pPrXml || sectionPropertiesXml) parts.push(`<w:pPr>${extractPPrInner(pPrXml)}${sectionPropertiesXml}</w:pPr>`);
|
|
453
|
+
const explicitCommentReferenceIds = /* @__PURE__ */ new Set();
|
|
454
|
+
for (const content of paragraph.content) if (content.type === "commentReference") explicitCommentReferenceIds.add(content.id);
|
|
455
|
+
let pendingRenderedPageBreak = paragraph.renderedPageBreakBefore === true;
|
|
456
|
+
for (const content of paragraph.content) {
|
|
457
|
+
let contentXml = serializeParagraphContent(content, explicitCommentReferenceIds);
|
|
458
|
+
if (contentXml) {
|
|
459
|
+
if (pendingRenderedPageBreak) {
|
|
460
|
+
const next = injectRenderedPageBreakIntoFirstRun(contentXml);
|
|
461
|
+
if (next) {
|
|
462
|
+
contentXml = next;
|
|
463
|
+
pendingRenderedPageBreak = false;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
parts.push(contentXml);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return `<w:p${attrsStr}>${parts.join("")}</w:p>`;
|
|
470
|
+
}
|
|
471
|
+
function injectRenderedPageBreakIntoFirstRun(xml) {
|
|
472
|
+
const runOpeningTag = /<w:r(?=[\s>/])[^>]*>/u;
|
|
473
|
+
if (!runOpeningTag.test(xml)) return null;
|
|
474
|
+
return xml.replace(runOpeningTag, (match) => `${match}<w:lastRenderedPageBreak/>`);
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Serialize multiple paragraphs to OOXML XML
|
|
478
|
+
*
|
|
479
|
+
* @param paragraphs - The paragraphs to serialize
|
|
480
|
+
* @returns XML string for all paragraphs
|
|
481
|
+
*/
|
|
482
|
+
function serializeParagraphs(paragraphs) {
|
|
483
|
+
return paragraphs.map(serializeParagraph).join("");
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Check if a paragraph has any content
|
|
487
|
+
*/
|
|
488
|
+
function hasParagraphContent(paragraph) {
|
|
489
|
+
return paragraph.content.length > 0;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Check if a paragraph has formatting
|
|
493
|
+
*/
|
|
494
|
+
function hasParagraphFormatting(paragraph) {
|
|
495
|
+
return paragraph.formatting !== void 0 && Object.keys(paragraph.formatting).length > 0;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Get plain text from a paragraph (for comparison/debugging)
|
|
499
|
+
*/
|
|
500
|
+
function getParagraphPlainText(paragraph) {
|
|
501
|
+
const texts = [];
|
|
502
|
+
for (const content of paragraph.content) if (content.type === "run") {
|
|
503
|
+
for (const item of content.content) if (item.type === "text") texts.push(item.text);
|
|
504
|
+
else if (item.type === "tab") texts.push(" ");
|
|
505
|
+
else if (item.type === "break") texts.push("\n");
|
|
506
|
+
} else if (content.type === "hyperlink") {
|
|
507
|
+
for (const child of content.children) if (child.type === "run") {
|
|
508
|
+
for (const item of child.content) if (item.type === "text") texts.push(item.text);
|
|
509
|
+
}
|
|
510
|
+
} else if (content.type === "simpleField" || content.type === "inlineSdt" || content.type === "insertion" || content.type === "deletion" || content.type === "moveFrom" || content.type === "moveTo") {
|
|
511
|
+
for (const item of content.content) if (item.type === "run") {
|
|
512
|
+
for (const subItem of item.content) if (subItem.type === "text") texts.push(subItem.text);
|
|
513
|
+
}
|
|
514
|
+
} else if (content.type === "complexField") {
|
|
515
|
+
for (const run of content.fieldResult) for (const item of run.content) if (item.type === "text") texts.push(item.text);
|
|
516
|
+
}
|
|
517
|
+
return texts.join("");
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Create an empty paragraph
|
|
521
|
+
*/
|
|
522
|
+
function createEmptyParagraph(formatting) {
|
|
523
|
+
return {
|
|
524
|
+
type: "paragraph",
|
|
525
|
+
...formatting !== void 0 ? { formatting } : {},
|
|
526
|
+
content: []
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Create a paragraph with a single text run
|
|
531
|
+
*/
|
|
532
|
+
function createTextParagraph(text, paragraphFormatting, textFormatting) {
|
|
533
|
+
return {
|
|
534
|
+
type: "paragraph",
|
|
535
|
+
...paragraphFormatting !== void 0 ? { formatting: paragraphFormatting } : {},
|
|
536
|
+
content: [{
|
|
537
|
+
type: "run",
|
|
538
|
+
...textFormatting !== void 0 ? { formatting: textFormatting } : {},
|
|
539
|
+
content: [{
|
|
540
|
+
type: "text",
|
|
541
|
+
text
|
|
542
|
+
}]
|
|
543
|
+
}]
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Check if paragraph is a list item
|
|
548
|
+
*/
|
|
549
|
+
function isListParagraph(paragraph) {
|
|
550
|
+
return paragraph.formatting?.numPr !== void 0;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Get list level of a paragraph (0-8, or -1 if not a list)
|
|
554
|
+
*/
|
|
555
|
+
function getListLevel(paragraph) {
|
|
556
|
+
return paragraph.formatting?.numPr?.ilvl ?? -1;
|
|
557
|
+
}
|
|
558
|
+
//#endregion
|
|
559
|
+
export { createEmptyParagraph, createTextParagraph, getListLevel, getParagraphPlainText, hasParagraphContent, hasParagraphFormatting, isListParagraph, serializeParagraph, serializeParagraphFormatting, serializeParagraphs };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
|
|
3
|
+
//#region src/docx/serializer/runSerializer.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reset the auto-incrementing ID counter. Call before each serialization pass
|
|
6
|
+
* to keep IDs deterministic across saves.
|
|
7
|
+
*/
|
|
8
|
+
declare function resetAutoIdCounter(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Serialize text formatting properties to w:rPr XML
|
|
11
|
+
*/
|
|
12
|
+
declare function serializeTextFormatting(formatting: document_d_exports.TextFormatting | undefined): string;
|
|
13
|
+
/**
|
|
14
|
+
* Serialize a run to OOXML XML (w:r)
|
|
15
|
+
*
|
|
16
|
+
* @param run - The run to serialize
|
|
17
|
+
* @returns XML string for the run
|
|
18
|
+
*/
|
|
19
|
+
declare function serializeRun(run: document_d_exports.Run): string;
|
|
20
|
+
/**
|
|
21
|
+
* Serialize multiple runs to OOXML XML
|
|
22
|
+
*
|
|
23
|
+
* @param runs - The runs to serialize
|
|
24
|
+
* @returns XML string for all runs
|
|
25
|
+
*/
|
|
26
|
+
declare function serializeRuns(runs: document_d_exports.Run[]): string;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a run has any content
|
|
29
|
+
*/
|
|
30
|
+
declare function hasRunContent(run: document_d_exports.Run): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a run has formatting
|
|
33
|
+
*/
|
|
34
|
+
declare function hasRunFormatting(run: document_d_exports.Run): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get plain text from a run (for comparison/debugging)
|
|
37
|
+
*/
|
|
38
|
+
declare function getRunPlainText(run: document_d_exports.Run): string;
|
|
39
|
+
/**
|
|
40
|
+
* Create an empty run
|
|
41
|
+
*/
|
|
42
|
+
declare function createEmptyRun(): document_d_exports.Run;
|
|
43
|
+
/**
|
|
44
|
+
* Create a text run
|
|
45
|
+
*/
|
|
46
|
+
declare function createTextRun(text: string, formatting?: document_d_exports.TextFormatting): document_d_exports.Run;
|
|
47
|
+
/**
|
|
48
|
+
* Create a break run
|
|
49
|
+
*/
|
|
50
|
+
declare function createBreakRun(breakType?: "page" | "column" | "textWrapping", formatting?: document_d_exports.TextFormatting): document_d_exports.Run;
|
|
51
|
+
/**
|
|
52
|
+
* Create a tab run
|
|
53
|
+
*/
|
|
54
|
+
declare function createTabRun(formatting?: document_d_exports.TextFormatting): document_d_exports.Run;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText, hasRunContent, hasRunFormatting, resetAutoIdCounter, serializeRun, serializeRuns, serializeTextFormatting };
|