@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,1550 @@
|
|
|
1
|
+
import { OUTLINE_STYLE_CSS_ALIASES } from "../../types/documentEnumValues.js";
|
|
2
|
+
import { ShapeOutlineStyleSchema, narrowEnum } from "../../docx/parserEnums.js";
|
|
3
|
+
import { pixelsToEmu } from "../../utils/units.js";
|
|
4
|
+
import { numPrEqual } from "../../docx/numberingParser.js";
|
|
5
|
+
import { directionToBidi } from "../paragraphDirection.js";
|
|
6
|
+
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
|
|
7
|
+
import { autospacingMatchesBase, hasAutospacingBaseSide } from "../autospacingBase.js";
|
|
8
|
+
import { runShadingAttrsToShading } from "./runShadingMark.js";
|
|
9
|
+
import { assertValidProseMirrorDocument } from "../validation.js";
|
|
10
|
+
//#region src/prosemirror/conversion/fromProseDoc.ts
|
|
11
|
+
function normalizeShapeOutlineStyle(style) {
|
|
12
|
+
if (!style) return;
|
|
13
|
+
if (style in OUTLINE_STYLE_CSS_ALIASES) return OUTLINE_STYLE_CSS_ALIASES[style];
|
|
14
|
+
return narrowEnum(style, ShapeOutlineStyleSchema);
|
|
15
|
+
}
|
|
16
|
+
function parseTransformAttr(transformStr) {
|
|
17
|
+
if (!transformStr) return;
|
|
18
|
+
const transform = {};
|
|
19
|
+
const rotateMatch = /rotate\((?<deg>[-\d.]+)deg\)/u.exec(transformStr);
|
|
20
|
+
if (rotateMatch) {
|
|
21
|
+
const rotation = Number.parseFloat(rotateMatch.groups["deg"]);
|
|
22
|
+
if (Number.isFinite(rotation)) transform.rotation = rotation;
|
|
23
|
+
}
|
|
24
|
+
if (transformStr.includes("scaleX(-1)")) transform.flipH = true;
|
|
25
|
+
if (transformStr.includes("scaleY(-1)")) transform.flipV = true;
|
|
26
|
+
if (transform.rotation === void 0 && !transform.flipH && !transform.flipV) return;
|
|
27
|
+
return transform;
|
|
28
|
+
}
|
|
29
|
+
function imagePositionFromAttrs(attrs) {
|
|
30
|
+
const horizontalPosition = attrs?.horizontal;
|
|
31
|
+
const verticalPosition = attrs?.vertical;
|
|
32
|
+
if (!horizontalPosition || !verticalPosition) return;
|
|
33
|
+
const horizontal = { relativeTo: horizontalPosition.relativeTo || "column" };
|
|
34
|
+
if (horizontalPosition.align) horizontal.alignment = horizontalPosition.align;
|
|
35
|
+
if (horizontalPosition.posOffset !== void 0) horizontal.posOffset = horizontalPosition.posOffset;
|
|
36
|
+
const vertical = { relativeTo: verticalPosition.relativeTo || "paragraph" };
|
|
37
|
+
if (verticalPosition.align) vertical.alignment = verticalPosition.align;
|
|
38
|
+
if (verticalPosition.posOffset !== void 0) vertical.posOffset = verticalPosition.posOffset;
|
|
39
|
+
return {
|
|
40
|
+
horizontal,
|
|
41
|
+
vertical
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function textBoxWrapFromAttrs(attrs) {
|
|
45
|
+
if (!(attrs.wrapType !== void 0 && attrs.wrapType !== "inline" || attrs.wrapText !== void 0 || attrs.distTop !== void 0 || attrs.distBottom !== void 0 || attrs.distLeft !== void 0 || attrs.distRight !== void 0)) return;
|
|
46
|
+
const wrap = { type: attrs.wrapType ?? "inline" };
|
|
47
|
+
if (attrs.wrapText !== void 0) wrap.wrapText = attrs.wrapText;
|
|
48
|
+
if (attrs.distTop !== void 0) wrap.distT = pixelsToEmu(attrs.distTop);
|
|
49
|
+
if (attrs.distBottom !== void 0) wrap.distB = pixelsToEmu(attrs.distBottom);
|
|
50
|
+
if (attrs.distLeft !== void 0) wrap.distL = pixelsToEmu(attrs.distLeft);
|
|
51
|
+
if (attrs.distRight !== void 0) wrap.distR = pixelsToEmu(attrs.distRight);
|
|
52
|
+
return wrap;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Convert a ProseMirror document to our Document type
|
|
56
|
+
*/
|
|
57
|
+
function fromProseDoc(pmDoc, baseDocument) {
|
|
58
|
+
assertValidProseMirrorDocument(pmDoc, "Cannot convert invalid ProseMirror document to DOCX model");
|
|
59
|
+
const documentBody = { content: extractBlocks(pmDoc) };
|
|
60
|
+
if (baseDocument?.package.document.finalSectionProperties) documentBody.finalSectionProperties = baseDocument.package.document.finalSectionProperties;
|
|
61
|
+
if (baseDocument?.package.document.sections) documentBody.sections = baseDocument.package.document.sections;
|
|
62
|
+
if (baseDocument?.package.document.comments) documentBody.comments = baseDocument.package.document.comments;
|
|
63
|
+
if (baseDocument) return {
|
|
64
|
+
...baseDocument,
|
|
65
|
+
package: {
|
|
66
|
+
...baseDocument.package,
|
|
67
|
+
document: documentBody
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return { package: { document: documentBody } };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Extract block content (paragraphs, tables, block SDTs) from a ProseMirror
|
|
74
|
+
* document.
|
|
75
|
+
*/
|
|
76
|
+
function extractBlocks(pmDoc) {
|
|
77
|
+
const blocks = [];
|
|
78
|
+
const documentCounts = buildDocumentTrackedChangeCounts(pmDoc);
|
|
79
|
+
let pendingPageBreaks = 0;
|
|
80
|
+
let previousStandaloneTextBox = null;
|
|
81
|
+
const flushPendingPageBreaks = () => {
|
|
82
|
+
for (let index = 0; index < pendingPageBreaks; index += 1) blocks.push(createPageBreakParagraph());
|
|
83
|
+
pendingPageBreaks = 0;
|
|
84
|
+
};
|
|
85
|
+
const appendPendingPageBreaksToPreviousParagraph = () => {
|
|
86
|
+
const previousBlock = blocks.at(-1);
|
|
87
|
+
if (previousBlock?.type !== "paragraph") return false;
|
|
88
|
+
appendPageBreaks(previousBlock, pendingPageBreaks);
|
|
89
|
+
pendingPageBreaks = 0;
|
|
90
|
+
return true;
|
|
91
|
+
};
|
|
92
|
+
pmDoc.forEach((node) => {
|
|
93
|
+
if (node.type.name === "pageBreak") {
|
|
94
|
+
pendingPageBreaks += 1;
|
|
95
|
+
previousStandaloneTextBox = null;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (node.type.name === "paragraph") {
|
|
99
|
+
const paragraph = convertPMParagraph(node, documentCounts);
|
|
100
|
+
prependPageBreaks(paragraph, pendingPageBreaks);
|
|
101
|
+
pendingPageBreaks = 0;
|
|
102
|
+
blocks.push(paragraph);
|
|
103
|
+
previousStandaloneTextBox = null;
|
|
104
|
+
} else if (node.type.name === "table") {
|
|
105
|
+
if (pendingPageBreaks > 0 && !appendPendingPageBreaksToPreviousParagraph()) flushPendingPageBreaks();
|
|
106
|
+
blocks.push(convertPMTable(node, documentCounts));
|
|
107
|
+
previousStandaloneTextBox = null;
|
|
108
|
+
} else if (node.type.name === "textBox") {
|
|
109
|
+
previousStandaloneTextBox = appendTextBoxBlock(blocks, node, {
|
|
110
|
+
pendingPageBreaks,
|
|
111
|
+
previousStandaloneTextBox
|
|
112
|
+
});
|
|
113
|
+
pendingPageBreaks = 0;
|
|
114
|
+
} else if (node.type.name === "blockSdt") {
|
|
115
|
+
if (pendingPageBreaks > 0 && !appendPendingPageBreaksToPreviousParagraph()) flushPendingPageBreaks();
|
|
116
|
+
blocks.push(convertPMBlockSdt(node));
|
|
117
|
+
previousStandaloneTextBox = null;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (pendingPageBreaks > 0 && !appendPendingPageBreaksToPreviousParagraph()) flushPendingPageBreaks();
|
|
121
|
+
return blocks;
|
|
122
|
+
}
|
|
123
|
+
function convertPMBlockSdt(node) {
|
|
124
|
+
const attrs = expectBlockSdtAttrs(node);
|
|
125
|
+
const properties = { sdtType: attrs.sdtType };
|
|
126
|
+
if (attrs.alias) properties.alias = attrs.alias;
|
|
127
|
+
if (attrs.tag) properties.tag = attrs.tag;
|
|
128
|
+
if (typeof attrs.id === "number") properties.id = attrs.id;
|
|
129
|
+
if (attrs.lock) properties.lock = attrs.lock;
|
|
130
|
+
if (attrs.placeholder) properties.placeholder = attrs.placeholder;
|
|
131
|
+
if (attrs.showingPlaceholder !== void 0) properties.showingPlaceholder = attrs.showingPlaceholder;
|
|
132
|
+
if (attrs.dateFormat) properties.dateFormat = attrs.dateFormat;
|
|
133
|
+
if (attrs.dateValueISO) properties.dateValueISO = attrs.dateValueISO;
|
|
134
|
+
if (attrs.listItems) {
|
|
135
|
+
const items = parseListItemsJson(attrs.listItems);
|
|
136
|
+
if (items) properties.listItems = items;
|
|
137
|
+
}
|
|
138
|
+
if (typeof attrs.dropdownLastValue === "string") properties.dropdownLastValue = attrs.dropdownLastValue;
|
|
139
|
+
if (typeof attrs.checked === "boolean") properties.checked = attrs.checked;
|
|
140
|
+
if (attrs.rawPropertiesXml) properties.rawPropertiesXml = attrs.rawPropertiesXml;
|
|
141
|
+
if (attrs.rawEndPropertiesXml) properties.rawEndPropertiesXml = attrs.rawEndPropertiesXml;
|
|
142
|
+
if (attrs.rawSdtChildrenBeforeContent) properties.rawSdtChildrenBeforeContent = attrs.rawSdtChildrenBeforeContent;
|
|
143
|
+
if (attrs.rawSdtChildrenAfterContent) properties.rawSdtChildrenAfterContent = attrs.rawSdtChildrenAfterContent;
|
|
144
|
+
const extracted = extractBlocks(node.type.schema.node("doc", null, node.content));
|
|
145
|
+
return {
|
|
146
|
+
type: "blockSdt",
|
|
147
|
+
properties,
|
|
148
|
+
content: attrs._originallyEmpty === true && isStillSyntheticFiller(extracted) ? [] : extracted
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function isStillSyntheticFiller(blocks) {
|
|
152
|
+
if (blocks.length !== 1) return false;
|
|
153
|
+
const block = blocks[0];
|
|
154
|
+
if (!block || block.type !== "paragraph") return false;
|
|
155
|
+
if (block.content.length !== 0) return false;
|
|
156
|
+
if (block.formatting !== void 0) return false;
|
|
157
|
+
if (block.sectionProperties !== void 0) return false;
|
|
158
|
+
if (block.propertyChanges !== void 0) return false;
|
|
159
|
+
if (block.pPrMark !== void 0) return false;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
function parseListItemsJson(raw) {
|
|
163
|
+
try {
|
|
164
|
+
const parsed = JSON.parse(raw);
|
|
165
|
+
if (!Array.isArray(parsed)) return;
|
|
166
|
+
const items = [];
|
|
167
|
+
for (const entry of parsed) if (entry !== null && typeof entry === "object" && "displayText" in entry && "value" in entry && typeof entry.displayText === "string" && typeof entry.value === "string") items.push(entry);
|
|
168
|
+
return items.length > 0 ? items : void 0;
|
|
169
|
+
} catch {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function appendTextBoxBlock(blocks, node, options) {
|
|
174
|
+
const attrs = expectTextBoxAttrs(node);
|
|
175
|
+
const paragraph = convertPMTextBox(node);
|
|
176
|
+
const previousBlock = blocks.at(-1);
|
|
177
|
+
if (attrs._docxPlacement === "inlineWithPrevious" && previousBlock?.type === "paragraph") {
|
|
178
|
+
appendPageBreaks(previousBlock, options.pendingPageBreaks);
|
|
179
|
+
previousBlock.content.push(...paragraph.content);
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
if (attrs._docxPlacement === "standalone" && attrs._docxGroupId && options.previousStandaloneTextBox?.groupId === attrs._docxGroupId) {
|
|
183
|
+
options.previousStandaloneTextBox.paragraph.content.push(...paragraph.content);
|
|
184
|
+
return options.previousStandaloneTextBox;
|
|
185
|
+
}
|
|
186
|
+
prependPageBreaks(paragraph, options.pendingPageBreaks);
|
|
187
|
+
blocks.push(paragraph);
|
|
188
|
+
return attrs._docxPlacement === "standalone" && attrs._docxGroupId ? {
|
|
189
|
+
paragraph,
|
|
190
|
+
groupId: attrs._docxGroupId
|
|
191
|
+
} : null;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Inverse of toProseDoc's listRendering → list* attrs flattening. Markdown
|
|
195
|
+
* export (`toMarkdown`) and re-layout of the rebuilt Document key off
|
|
196
|
+
* `paragraph.listRendering`; without this, every edited document loses its
|
|
197
|
+
* list markers on the way out of the editor.
|
|
198
|
+
*/
|
|
199
|
+
function listRenderingFromAttrs(attrs) {
|
|
200
|
+
const numId = attrs.numPr?.numId;
|
|
201
|
+
if (numId === void 0 || numId === 0) return;
|
|
202
|
+
if (!(attrs.listMarker != null || attrs.listIsBullet || attrs.listNumFmt != null)) return;
|
|
203
|
+
return {
|
|
204
|
+
marker: attrs.listMarker ?? "",
|
|
205
|
+
level: attrs.numPr?.ilvl ?? 0,
|
|
206
|
+
numId,
|
|
207
|
+
isBullet: attrs.listIsBullet ?? false,
|
|
208
|
+
...attrs.listIsLegal != null && { isLegal: attrs.listIsLegal },
|
|
209
|
+
...attrs.listNumFmt != null && { numFmt: attrs.listNumFmt },
|
|
210
|
+
...attrs.listMarkerHidden != null && { markerHidden: attrs.listMarkerHidden },
|
|
211
|
+
...attrs.listMarkerFontFamily != null && { markerFontFamily: attrs.listMarkerFontFamily },
|
|
212
|
+
...attrs.listMarkerFontSize != null && { markerFontSize: attrs.listMarkerFontSize },
|
|
213
|
+
...attrs.listMarkerSuffix != null && { markerSuffix: attrs.listMarkerSuffix },
|
|
214
|
+
...attrs.listMarkerAllCaps != null && { markerAllCaps: attrs.listMarkerAllCaps },
|
|
215
|
+
...attrs.listImplicitChildLevelAdvances != null && { implicitChildLevelAdvances: attrs.listImplicitChildLevelAdvances },
|
|
216
|
+
...attrs.listMarkerSecondSlotOffsetTwips != null && { markerSecondSlotOffsetTwips: attrs.listMarkerSecondSlotOffsetTwips },
|
|
217
|
+
...attrs.listLevelNumFmts != null && { levelNumFmts: attrs.listLevelNumFmts },
|
|
218
|
+
...attrs.listAbstractNumId != null && { abstractNumId: attrs.listAbstractNumId },
|
|
219
|
+
...attrs.listStartOverride != null && { startOverride: attrs.listStartOverride }
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Create a paragraph containing only a page break run (for DOCX serialization)
|
|
224
|
+
*/
|
|
225
|
+
function createPageBreakParagraph() {
|
|
226
|
+
return {
|
|
227
|
+
type: "paragraph",
|
|
228
|
+
content: [{
|
|
229
|
+
type: "run",
|
|
230
|
+
content: [{
|
|
231
|
+
type: "break",
|
|
232
|
+
breakType: "page"
|
|
233
|
+
}]
|
|
234
|
+
}]
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function createPageBreakRun() {
|
|
238
|
+
return {
|
|
239
|
+
type: "run",
|
|
240
|
+
content: [{
|
|
241
|
+
type: "break",
|
|
242
|
+
breakType: "page"
|
|
243
|
+
}]
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function prependPageBreaks(paragraph, count) {
|
|
247
|
+
for (let index = 0; index < count; index += 1) paragraph.content.unshift(createPageBreakRun());
|
|
248
|
+
}
|
|
249
|
+
function appendPageBreaks(paragraph, count) {
|
|
250
|
+
for (let index = 0; index < count; index += 1) paragraph.content.push(createPageBreakRun());
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Convert a ProseMirror paragraph node to our Paragraph type
|
|
254
|
+
*/
|
|
255
|
+
function convertPMParagraph(node, documentCounts) {
|
|
256
|
+
const attrs = expectParagraphAttrs(node);
|
|
257
|
+
let content = extractParagraphContent(node, documentCounts, attrs._emptyHyperlinks ?? void 0);
|
|
258
|
+
const bookmarks = attrs.bookmarks;
|
|
259
|
+
if (bookmarks && bookmarks.length > 0) {
|
|
260
|
+
const starts = bookmarks.map((b) => ({
|
|
261
|
+
type: "bookmarkStart",
|
|
262
|
+
id: b.id,
|
|
263
|
+
name: b.name
|
|
264
|
+
}));
|
|
265
|
+
const ends = bookmarks.map((b) => ({
|
|
266
|
+
type: "bookmarkEnd",
|
|
267
|
+
id: b.id
|
|
268
|
+
}));
|
|
269
|
+
content = [
|
|
270
|
+
...starts,
|
|
271
|
+
...content,
|
|
272
|
+
...ends
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
const paragraph = {
|
|
276
|
+
type: "paragraph",
|
|
277
|
+
content
|
|
278
|
+
};
|
|
279
|
+
if (attrs.paraId) paragraph.paraId = attrs.paraId;
|
|
280
|
+
if (attrs.textId) paragraph.textId = attrs.textId;
|
|
281
|
+
const pFormatting = paragraphAttrsToFormatting(attrs);
|
|
282
|
+
if (pFormatting) paragraph.formatting = pFormatting;
|
|
283
|
+
const listRendering = listRenderingFromAttrs(attrs);
|
|
284
|
+
if (listRendering) paragraph.listRendering = listRendering;
|
|
285
|
+
if (attrs.renderedPageBreakBefore) paragraph.renderedPageBreakBefore = true;
|
|
286
|
+
if (attrs._sectionProperties) paragraph.sectionProperties = attrs._sectionProperties;
|
|
287
|
+
else if (attrs.sectionBreakType) paragraph.sectionProperties = { sectionStart: attrs.sectionBreakType };
|
|
288
|
+
if (Array.isArray(attrs._propertyChanges) && attrs._propertyChanges.length > 0) paragraph.propertyChanges = [...attrs._propertyChanges];
|
|
289
|
+
if (attrs.pPrMark) paragraph.pPrMark = attrs.pPrMark;
|
|
290
|
+
return paragraph;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Whether the paragraph's numbering still comes verbatim from its style —
|
|
294
|
+
* serialize no direct `<w:numPr>` then. The moment a list command changes
|
|
295
|
+
* `numPr` the values diverge and the numbering serializes as direct
|
|
296
|
+
* formatting, so a stale provenance value can never swallow a user edit.
|
|
297
|
+
*/
|
|
298
|
+
function isStyleSourcedNumPr(attrs) {
|
|
299
|
+
return attrs.numPrFromStyle != null && attrs.numPr != null && numPrEqual(attrs.numPr, attrs.numPrFromStyle);
|
|
300
|
+
}
|
|
301
|
+
function assignBooleanToggle(result, attrs, orig, key) {
|
|
302
|
+
const value = attrs[key] ?? void 0;
|
|
303
|
+
if (value === (orig[key] ?? void 0)) return;
|
|
304
|
+
if (value === void 0) Reflect.deleteProperty(result, key);
|
|
305
|
+
else result[key] = value;
|
|
306
|
+
}
|
|
307
|
+
function paragraphAttrsToFormatting(attrs) {
|
|
308
|
+
const spaceBefore = Reflect.get(attrs, "spaceBefore");
|
|
309
|
+
const spaceAfter = Reflect.get(attrs, "spaceAfter");
|
|
310
|
+
const beforeHasAutospacingBase = hasAutospacingBaseSide(attrs._autospacingBase, "before");
|
|
311
|
+
const afterHasAutospacingBase = hasAutospacingBaseSide(attrs._autospacingBase, "after");
|
|
312
|
+
const beforeOriginalAutospacing = attrs._originalFormatting?.beforeAutospacing === true;
|
|
313
|
+
const afterOriginalAutospacing = attrs._originalFormatting?.afterAutospacing === true;
|
|
314
|
+
const beforeAutospacingEdited = beforeHasAutospacingBase ? !autospacingMatchesBase(attrs._autospacingBase, "before", spaceBefore) : beforeOriginalAutospacing && attrs._autospacingBase == null;
|
|
315
|
+
const afterAutospacingEdited = afterHasAutospacingBase ? !autospacingMatchesBase(attrs._autospacingBase, "after", spaceAfter) : afterOriginalAutospacing && attrs._autospacingBase == null;
|
|
316
|
+
const shouldSerializeSpaceBefore = typeof spaceBefore === "number" && (!beforeHasAutospacingBase || beforeAutospacingEdited);
|
|
317
|
+
const shouldSerializeSpaceAfter = typeof spaceAfter === "number" && (!afterHasAutospacingBase || afterAutospacingEdited);
|
|
318
|
+
if (attrs._originalFormatting) {
|
|
319
|
+
const orig = attrs._originalFormatting;
|
|
320
|
+
const result = { ...orig };
|
|
321
|
+
if (beforeAutospacingEdited) {
|
|
322
|
+
result.beforeAutospacing = false;
|
|
323
|
+
if (typeof spaceBefore === "number") result.spaceBefore = spaceBefore;
|
|
324
|
+
else delete result.spaceBefore;
|
|
325
|
+
}
|
|
326
|
+
if (afterAutospacingEdited) {
|
|
327
|
+
result.afterAutospacing = false;
|
|
328
|
+
if (typeof spaceAfter === "number") result.spaceAfter = spaceAfter;
|
|
329
|
+
else delete result.spaceAfter;
|
|
330
|
+
}
|
|
331
|
+
if (attrs.alignment !== (orig.alignment ?? void 0)) if (attrs.alignment) result.alignment = attrs.alignment;
|
|
332
|
+
else delete result.alignment;
|
|
333
|
+
if (isStyleSourcedNumPr(attrs)) {
|
|
334
|
+
delete result.numPr;
|
|
335
|
+
delete result.numPrFromStyle;
|
|
336
|
+
} else if (attrs.numPr !== orig.numPr && !numPrEqual(attrs.numPr, orig.numPr)) {
|
|
337
|
+
if (attrs.numPr) result.numPr = attrs.numPr;
|
|
338
|
+
else delete result.numPr;
|
|
339
|
+
delete result.numPrFromStyle;
|
|
340
|
+
}
|
|
341
|
+
if (attrs.styleId !== (orig.styleId ?? void 0)) if (attrs.styleId) result.styleId = attrs.styleId;
|
|
342
|
+
else delete result.styleId;
|
|
343
|
+
assignBooleanToggle(result, attrs, orig, "pageBreakBefore");
|
|
344
|
+
if (attrs.spacingExplicit !== orig.spacingExplicit) if (attrs.spacingExplicit) result.spacingExplicit = attrs.spacingExplicit;
|
|
345
|
+
else delete result.spacingExplicit;
|
|
346
|
+
const bidi = directionToBidi(attrs.direction);
|
|
347
|
+
if (bidi !== (orig.bidi ?? void 0)) if (bidi === void 0) delete result.bidi;
|
|
348
|
+
else result.bidi = bidi;
|
|
349
|
+
return result;
|
|
350
|
+
}
|
|
351
|
+
const outlineLevel = Reflect.get(attrs, "outlineLevel");
|
|
352
|
+
const bidi = directionToBidi(attrs.direction);
|
|
353
|
+
if (!(attrs.alignment || shouldSerializeSpaceBefore || shouldSerializeSpaceAfter || beforeAutospacingEdited || afterAutospacingEdited || attrs.lineSpacing || attrs.indentLeft || attrs.indentRight || attrs.indentFirstLine || attrs.numPr || attrs.styleId || attrs.borders || attrs.shading || attrs.tabs || typeof outlineLevel === "number" || attrs.contextualSpacing || attrs.spacingExplicit || bidi != null || attrs.pageBreakBefore != null)) return;
|
|
354
|
+
const f = {};
|
|
355
|
+
if (attrs.alignment) f.alignment = attrs.alignment;
|
|
356
|
+
if (shouldSerializeSpaceBefore) f.spaceBefore = spaceBefore;
|
|
357
|
+
if (beforeAutospacingEdited) f.beforeAutospacing = false;
|
|
358
|
+
if (shouldSerializeSpaceAfter) f.spaceAfter = spaceAfter;
|
|
359
|
+
if (afterAutospacingEdited) f.afterAutospacing = false;
|
|
360
|
+
if (attrs.lineSpacing) f.lineSpacing = attrs.lineSpacing;
|
|
361
|
+
if (attrs.lineSpacingRule) f.lineSpacingRule = attrs.lineSpacingRule;
|
|
362
|
+
if (attrs.spacingExplicit) f.spacingExplicit = attrs.spacingExplicit;
|
|
363
|
+
if (attrs.indentLeft) f.indentLeft = attrs.indentLeft;
|
|
364
|
+
if (attrs.indentRight) f.indentRight = attrs.indentRight;
|
|
365
|
+
if (attrs.indentFirstLine) f.indentFirstLine = attrs.indentFirstLine;
|
|
366
|
+
if (attrs.hangingIndent) f.hangingIndent = attrs.hangingIndent;
|
|
367
|
+
if (attrs.numPr && !isStyleSourcedNumPr(attrs)) f.numPr = attrs.numPr;
|
|
368
|
+
if (attrs.styleId) f.styleId = attrs.styleId;
|
|
369
|
+
if (attrs.borders) f.borders = attrs.borders;
|
|
370
|
+
if (attrs.shading) f.shading = attrs.shading;
|
|
371
|
+
if (attrs.tabs) f.tabs = attrs.tabs;
|
|
372
|
+
if (typeof outlineLevel === "number") f.outlineLevel = outlineLevel;
|
|
373
|
+
if (attrs.contextualSpacing) f.contextualSpacing = attrs.contextualSpacing;
|
|
374
|
+
if (bidi != null) f.bidi = bidi;
|
|
375
|
+
if (attrs.pageBreakBefore != null) f.pageBreakBefore = attrs.pageBreakBefore;
|
|
376
|
+
return f;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Extract paragraph content (runs, hyperlinks) from ProseMirror paragraph
|
|
380
|
+
*
|
|
381
|
+
* Coalesces consecutive text with the same marks into single Runs
|
|
382
|
+
* for efficient DOCX representation.
|
|
383
|
+
*/
|
|
384
|
+
function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks) {
|
|
385
|
+
const content = [];
|
|
386
|
+
const sortedEmptyHyperlinks = (emptyHyperlinks ?? []).map((attrs, order) => ({
|
|
387
|
+
attrs,
|
|
388
|
+
order
|
|
389
|
+
})).toSorted((left, right) => left.attrs.offset - right.attrs.offset || left.order - right.order);
|
|
390
|
+
let nextEmptyHyperlink = 0;
|
|
391
|
+
let currentRun = null;
|
|
392
|
+
let currentMarksKey = null;
|
|
393
|
+
let currentHyperlink = null;
|
|
394
|
+
let currentHyperlinkKey = null;
|
|
395
|
+
const openedComments = /* @__PURE__ */ new Set();
|
|
396
|
+
const commentLastOffset = /* @__PURE__ */ new Map();
|
|
397
|
+
paragraph.forEach((node, offset) => {
|
|
398
|
+
for (const commentId of getCommentMarkIds(node.marks)) commentLastOffset.set(commentId, offset);
|
|
399
|
+
});
|
|
400
|
+
const flushCurrentInline = () => {
|
|
401
|
+
if (currentRun) {
|
|
402
|
+
content.push(currentRun);
|
|
403
|
+
currentRun = null;
|
|
404
|
+
currentMarksKey = null;
|
|
405
|
+
}
|
|
406
|
+
if (currentHyperlink) {
|
|
407
|
+
content.push(currentHyperlink);
|
|
408
|
+
currentHyperlink = null;
|
|
409
|
+
currentHyperlinkKey = null;
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
const syncCommentRanges = (node, offset) => {
|
|
413
|
+
const nodeCommentIds = getCommentMarkIds(node.marks);
|
|
414
|
+
const toClose = [];
|
|
415
|
+
for (const commentId of openedComments) {
|
|
416
|
+
const lastOffset = commentLastOffset.get(commentId) ?? offset;
|
|
417
|
+
if (!nodeCommentIds.has(commentId) && lastOffset <= offset) toClose.push(commentId);
|
|
418
|
+
}
|
|
419
|
+
const toOpen = [];
|
|
420
|
+
for (const commentId of nodeCommentIds) if (!openedComments.has(commentId)) toOpen.push(commentId);
|
|
421
|
+
if (toClose.length === 0 && toOpen.length === 0) return;
|
|
422
|
+
flushCurrentInline();
|
|
423
|
+
for (const commentId of toClose.toSorted((a, b) => a - b)) {
|
|
424
|
+
content.push({
|
|
425
|
+
type: "commentRangeEnd",
|
|
426
|
+
id: commentId
|
|
427
|
+
});
|
|
428
|
+
openedComments.delete(commentId);
|
|
429
|
+
}
|
|
430
|
+
for (const commentId of toOpen.toSorted((a, b) => a - b)) {
|
|
431
|
+
content.push({
|
|
432
|
+
type: "commentRangeStart",
|
|
433
|
+
id: commentId
|
|
434
|
+
});
|
|
435
|
+
openedComments.add(commentId);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
const flushEmptyHyperlinksThroughOffset = (offset) => {
|
|
439
|
+
while (nextEmptyHyperlink < sortedEmptyHyperlinks.length) {
|
|
440
|
+
const item = sortedEmptyHyperlinks[nextEmptyHyperlink];
|
|
441
|
+
if (!item || item.attrs.offset > offset) break;
|
|
442
|
+
nextEmptyHyperlink += 1;
|
|
443
|
+
flushCurrentInline();
|
|
444
|
+
content.push(createEmptyHyperlink(item.attrs));
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const processInlineNode = (node, offset) => {
|
|
448
|
+
syncCommentRanges(node, offset);
|
|
449
|
+
const linkMark = node.marks.find((m) => m.type.name === "hyperlink");
|
|
450
|
+
const noteRefMark = node.marks.find((m) => m.type.name === "footnoteRef");
|
|
451
|
+
if (noteRefMark && !linkMark) {
|
|
452
|
+
flushCurrentInline();
|
|
453
|
+
content.push(createNoteReferenceRun(noteRefMark, node.marks));
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
const insertionMark = node.marks.find((m) => m.type.name === "insertion");
|
|
457
|
+
const deletionMark = node.marks.find((m) => m.type.name === "deletion");
|
|
458
|
+
if (insertionMark || deletionMark) {
|
|
459
|
+
flushCurrentInline();
|
|
460
|
+
const changeMark = insertionMark ?? deletionMark;
|
|
461
|
+
if (!changeMark) return;
|
|
462
|
+
const changeAttrs = expectTrackedChangeMarkAttrs(changeMark);
|
|
463
|
+
const run = createTrackedChangeRun(node, node.marks.filter((m) => m.type.name !== "insertion" && m.type.name !== "deletion"));
|
|
464
|
+
if (!run) return;
|
|
465
|
+
const info = {
|
|
466
|
+
id: changeAttrs.revisionId,
|
|
467
|
+
author: changeAttrs.author || "Unknown"
|
|
468
|
+
};
|
|
469
|
+
if (changeAttrs.date) info.date = changeAttrs.date;
|
|
470
|
+
if (insertionMark) if (changeAttrs.moveKind === "moveTo") content.push({
|
|
471
|
+
type: "moveTo",
|
|
472
|
+
info,
|
|
473
|
+
content: [run]
|
|
474
|
+
});
|
|
475
|
+
else content.push({
|
|
476
|
+
type: "insertion",
|
|
477
|
+
info,
|
|
478
|
+
content: [run]
|
|
479
|
+
});
|
|
480
|
+
else if (changeAttrs.moveKind === "moveFrom") content.push({
|
|
481
|
+
type: "moveFrom",
|
|
482
|
+
info,
|
|
483
|
+
content: [run]
|
|
484
|
+
});
|
|
485
|
+
else content.push({
|
|
486
|
+
type: "deletion",
|
|
487
|
+
info,
|
|
488
|
+
content: [run]
|
|
489
|
+
});
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (linkMark) {
|
|
493
|
+
const linkKey = getLinkKey(linkMark);
|
|
494
|
+
if (currentHyperlink && currentHyperlinkKey === linkKey) addNodeToHyperlink(currentHyperlink, node);
|
|
495
|
+
else {
|
|
496
|
+
flushCurrentInline();
|
|
497
|
+
currentHyperlink = createHyperlink(linkMark);
|
|
498
|
+
currentHyperlinkKey = linkKey;
|
|
499
|
+
addNodeToHyperlink(currentHyperlink, node);
|
|
500
|
+
}
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (currentHyperlink) flushCurrentInline();
|
|
504
|
+
if (node.isText) {
|
|
505
|
+
const marksKey = getMarksKey(node.marks);
|
|
506
|
+
if (currentRun && currentMarksKey === marksKey) appendTextToRun(currentRun, node.text || "");
|
|
507
|
+
else {
|
|
508
|
+
if (currentRun) content.push(currentRun);
|
|
509
|
+
currentRun = createRunFromText(node.text || "", node.marks);
|
|
510
|
+
currentMarksKey = marksKey;
|
|
511
|
+
}
|
|
512
|
+
} else if (node.type.name === "hardBreak") {
|
|
513
|
+
flushCurrentInline();
|
|
514
|
+
content.push(createBreakRun(readHardBreakType(node)));
|
|
515
|
+
} else if (node.type.name === "image") {
|
|
516
|
+
flushCurrentInline();
|
|
517
|
+
content.push(createImageRun(node));
|
|
518
|
+
} else if (node.type.name === "shape") {
|
|
519
|
+
flushCurrentInline();
|
|
520
|
+
content.push(createShapeRun(node));
|
|
521
|
+
} else if (node.type.name === "tab") {
|
|
522
|
+
flushCurrentInline();
|
|
523
|
+
content.push(createTabRun());
|
|
524
|
+
} else if (node.type.name === "field") {
|
|
525
|
+
flushCurrentInline();
|
|
526
|
+
content.push(createFieldFromNode(node, node.marks));
|
|
527
|
+
} else if (node.type.name === "sdt") {
|
|
528
|
+
flushCurrentInline();
|
|
529
|
+
content.push(createInlineSdtFromNode(node));
|
|
530
|
+
} else if (node.type.name === "math") {
|
|
531
|
+
flushCurrentInline();
|
|
532
|
+
content.push(createMathFromNode(node));
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
paragraph.forEach((node, offset) => {
|
|
536
|
+
flushEmptyHyperlinksThroughOffset(offset);
|
|
537
|
+
if (node.isText && node.text) {
|
|
538
|
+
let consumed = 0;
|
|
539
|
+
const textEndOffset = offset + node.nodeSize;
|
|
540
|
+
while (nextEmptyHyperlink < sortedEmptyHyperlinks.length) {
|
|
541
|
+
const item = sortedEmptyHyperlinks[nextEmptyHyperlink];
|
|
542
|
+
if (!item || item.attrs.offset >= textEndOffset) break;
|
|
543
|
+
const splitOffset = Math.max(item.attrs.offset - offset, consumed);
|
|
544
|
+
const segment = node.text.slice(consumed, splitOffset);
|
|
545
|
+
if (segment) processInlineNode(node.type.schema.text(segment, node.marks), offset);
|
|
546
|
+
flushCurrentInline();
|
|
547
|
+
content.push(createEmptyHyperlink(item.attrs));
|
|
548
|
+
nextEmptyHyperlink += 1;
|
|
549
|
+
consumed = splitOffset;
|
|
550
|
+
}
|
|
551
|
+
const remainder = node.text.slice(consumed);
|
|
552
|
+
if (remainder) processInlineNode(node.type.schema.text(remainder, node.marks), offset);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
processInlineNode(node, offset);
|
|
556
|
+
});
|
|
557
|
+
flushEmptyHyperlinksThroughOffset(Number.POSITIVE_INFINITY);
|
|
558
|
+
flushCurrentInline();
|
|
559
|
+
for (const commentId of openedComments) content.push({
|
|
560
|
+
type: "commentRangeEnd",
|
|
561
|
+
id: commentId
|
|
562
|
+
});
|
|
563
|
+
return content;
|
|
564
|
+
}
|
|
565
|
+
function createTrackedChangeRun(node, marks) {
|
|
566
|
+
if (node.isText) {
|
|
567
|
+
const formatting = marksToTextFormatting(marks);
|
|
568
|
+
return {
|
|
569
|
+
type: "run",
|
|
570
|
+
content: node.text ? [{
|
|
571
|
+
type: "text",
|
|
572
|
+
text: node.text
|
|
573
|
+
}] : [],
|
|
574
|
+
...Object.keys(formatting).length > 0 ? { formatting } : {}
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (node.type.name === "hardBreak") return createBreakRun(readHardBreakType(node));
|
|
578
|
+
if (node.type.name === "image") return createImageRun(node);
|
|
579
|
+
if (node.type.name === "shape") return createShapeRun(node);
|
|
580
|
+
if (node.type.name === "tab") return createTabRun();
|
|
581
|
+
return null;
|
|
582
|
+
}
|
|
583
|
+
function createEmptyHyperlink(attrs) {
|
|
584
|
+
const hyperlink = {
|
|
585
|
+
type: "hyperlink",
|
|
586
|
+
children: []
|
|
587
|
+
};
|
|
588
|
+
if (attrs.href !== void 0) hyperlink.href = attrs.href;
|
|
589
|
+
if (attrs.anchor !== void 0) hyperlink.anchor = attrs.anchor;
|
|
590
|
+
if (attrs.tooltip !== void 0) hyperlink.tooltip = attrs.tooltip;
|
|
591
|
+
if (attrs.rId !== void 0) hyperlink.rId = attrs.rId;
|
|
592
|
+
return hyperlink;
|
|
593
|
+
}
|
|
594
|
+
function getCommentMarkIds(marks) {
|
|
595
|
+
const commentIds = /* @__PURE__ */ new Set();
|
|
596
|
+
for (const mark of marks) if (mark.type.name === "comment") commentIds.add(expectCommentMarkAttrs(mark).commentId);
|
|
597
|
+
return commentIds;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Build document-wide tracked change counts by scanning all nodes.
|
|
601
|
+
* Used for cross-paragraph move pair detection (moveFrom in one paragraph,
|
|
602
|
+
* moveTo in another).
|
|
603
|
+
*/
|
|
604
|
+
function buildDocumentTrackedChangeCounts(pmDoc) {
|
|
605
|
+
const insertionById = /* @__PURE__ */ new Map();
|
|
606
|
+
const deletionById = /* @__PURE__ */ new Map();
|
|
607
|
+
pmDoc.descendants((node) => {
|
|
608
|
+
const insertionMark = node.marks.find((m) => m.type.name === "insertion");
|
|
609
|
+
const deletionMark = node.marks.find((m) => m.type.name === "deletion");
|
|
610
|
+
if (insertionMark) {
|
|
611
|
+
const { revisionId } = expectTrackedChangeMarkAttrs(insertionMark);
|
|
612
|
+
insertionById.set(revisionId, (insertionById.get(revisionId) ?? 0) + 1);
|
|
613
|
+
}
|
|
614
|
+
if (deletionMark) {
|
|
615
|
+
const { revisionId } = expectTrackedChangeMarkAttrs(deletionMark);
|
|
616
|
+
deletionById.set(revisionId, (deletionById.get(revisionId) ?? 0) + 1);
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
return {
|
|
620
|
+
insertionById,
|
|
621
|
+
deletionById
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Create a unique key for a link mark
|
|
626
|
+
*/
|
|
627
|
+
function getLinkKey(mark) {
|
|
628
|
+
const attrs = expectHyperlinkMarkAttrs(mark);
|
|
629
|
+
return [
|
|
630
|
+
attrs.href,
|
|
631
|
+
attrs.rId ?? "",
|
|
632
|
+
attrs.tooltip ?? "",
|
|
633
|
+
attrs._docxHyperlinkIndex ?? ""
|
|
634
|
+
].join("\0");
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Create a unique key for a set of marks (excluding hyperlink)
|
|
638
|
+
*/
|
|
639
|
+
function getMarksKey(marks) {
|
|
640
|
+
const nonLinkMarks = marks.filter((m) => m.type.name !== "hyperlink");
|
|
641
|
+
if (nonLinkMarks.length === 0) return "";
|
|
642
|
+
return nonLinkMarks.map((m) => `${m.type.name}:${JSON.stringify(m.attrs)}`).toSorted().join("|");
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Create a Hyperlink from a link mark
|
|
646
|
+
*/
|
|
647
|
+
function createHyperlink(linkMark) {
|
|
648
|
+
const attrs = expectHyperlinkMarkAttrs(linkMark);
|
|
649
|
+
const href = attrs.href;
|
|
650
|
+
if (href.startsWith("#")) {
|
|
651
|
+
const hyperlink = {
|
|
652
|
+
type: "hyperlink",
|
|
653
|
+
anchor: href.slice(1),
|
|
654
|
+
children: []
|
|
655
|
+
};
|
|
656
|
+
if (attrs.tooltip) hyperlink.tooltip = attrs.tooltip;
|
|
657
|
+
return hyperlink;
|
|
658
|
+
}
|
|
659
|
+
const hyperlink = {
|
|
660
|
+
type: "hyperlink",
|
|
661
|
+
href,
|
|
662
|
+
children: []
|
|
663
|
+
};
|
|
664
|
+
if (attrs.tooltip) hyperlink.tooltip = attrs.tooltip;
|
|
665
|
+
if (attrs.rId) hyperlink.rId = attrs.rId;
|
|
666
|
+
return hyperlink;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Add a node to a hyperlink
|
|
670
|
+
*/
|
|
671
|
+
function addNodeToHyperlink(hyperlink, node) {
|
|
672
|
+
const noteRefMark = node.marks.find((m) => m.type.name === "footnoteRef");
|
|
673
|
+
if (noteRefMark) {
|
|
674
|
+
hyperlink.children.push(createNoteReferenceRun(noteRefMark, node.marks));
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
const nonLinkMarks = node.marks.filter((m) => m.type.name !== "hyperlink");
|
|
678
|
+
if (node.isText && node.text) {
|
|
679
|
+
const run = createRunFromText(node.text, nonLinkMarks);
|
|
680
|
+
hyperlink.children.push(run);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (node.type.name === "hardBreak") {
|
|
684
|
+
hyperlink.children.push(createBreakRun(readHardBreakType(node), nonLinkMarks));
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (node.type.name === "tab") {
|
|
688
|
+
hyperlink.children.push(createTabRun(nonLinkMarks));
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (node.type.name === "image") {
|
|
692
|
+
hyperlink.children.push(createImageRun(node));
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (node.type.name === "shape") hyperlink.children.push(createShapeRun(node));
|
|
696
|
+
}
|
|
697
|
+
function getNoteReferenceVertAlign(noteAttrs, marks) {
|
|
698
|
+
if (marks.some((mark) => mark.type.name === "subscript")) return "subscript";
|
|
699
|
+
if (marks.some((mark) => mark.type.name === "superscript")) return "superscript";
|
|
700
|
+
if (noteAttrs.vertAlign === "baseline" || noteAttrs.vertAlign === "superscript") return noteAttrs.vertAlign;
|
|
701
|
+
}
|
|
702
|
+
function createNoteReferenceRun(noteRefMark, marks) {
|
|
703
|
+
const noteAttrs = expectFootnoteRefMarkAttrs(noteRefMark);
|
|
704
|
+
const run = {
|
|
705
|
+
type: "run",
|
|
706
|
+
content: [{
|
|
707
|
+
type: noteAttrs.noteType === "endnote" ? "endnoteRef" : "footnoteRef",
|
|
708
|
+
id: typeof noteAttrs.id === "string" ? Number.parseInt(noteAttrs.id, 10) || 0 : noteAttrs.id
|
|
709
|
+
}]
|
|
710
|
+
};
|
|
711
|
+
const vertAlign = getNoteReferenceVertAlign(noteAttrs, marks);
|
|
712
|
+
if (vertAlign) run.formatting = { vertAlign };
|
|
713
|
+
return run;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Create a Run from text and marks
|
|
717
|
+
*/
|
|
718
|
+
function createRunFromText(text, marks) {
|
|
719
|
+
const formatting = getRunFormattingFromMarks(marks);
|
|
720
|
+
const run = {
|
|
721
|
+
type: "run",
|
|
722
|
+
content: [{
|
|
723
|
+
type: "text",
|
|
724
|
+
text
|
|
725
|
+
}]
|
|
726
|
+
};
|
|
727
|
+
if (formatting) run.formatting = formatting;
|
|
728
|
+
return run;
|
|
729
|
+
}
|
|
730
|
+
function getRunFormattingFromMarks(marks) {
|
|
731
|
+
if (!marks || marks.length === 0) return;
|
|
732
|
+
const formatting = marksToTextFormatting(marks);
|
|
733
|
+
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Append text to an existing run
|
|
737
|
+
*/
|
|
738
|
+
function appendTextToRun(run, text) {
|
|
739
|
+
const lastContent = run.content.at(-1);
|
|
740
|
+
if (lastContent && lastContent.type === "text") lastContent.text += text;
|
|
741
|
+
else run.content.push({
|
|
742
|
+
type: "text",
|
|
743
|
+
text
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Create a Run containing a line break
|
|
748
|
+
*/
|
|
749
|
+
function createBreakRun(breakType = "textWrapping", marks) {
|
|
750
|
+
const run = {
|
|
751
|
+
type: "run",
|
|
752
|
+
content: [{
|
|
753
|
+
type: "break",
|
|
754
|
+
breakType
|
|
755
|
+
}]
|
|
756
|
+
};
|
|
757
|
+
const formatting = getRunFormattingFromMarks(marks);
|
|
758
|
+
if (formatting) run.formatting = formatting;
|
|
759
|
+
return run;
|
|
760
|
+
}
|
|
761
|
+
function readHardBreakType(node) {
|
|
762
|
+
return expectHardBreakAttrs(node).breakType ?? "textWrapping";
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Create a Run containing a tab
|
|
766
|
+
*/
|
|
767
|
+
function createTabRun(marks) {
|
|
768
|
+
const run = {
|
|
769
|
+
type: "run",
|
|
770
|
+
content: [{ type: "tab" }]
|
|
771
|
+
};
|
|
772
|
+
const formatting = getRunFormattingFromMarks(marks);
|
|
773
|
+
if (formatting) run.formatting = formatting;
|
|
774
|
+
return run;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Create a SimpleField or ComplexField from a PM field node
|
|
778
|
+
*/
|
|
779
|
+
function createFieldFromNode(node, marks) {
|
|
780
|
+
const attrs = expectFieldAttrs(node);
|
|
781
|
+
const formatting = marks && marks.length > 0 ? marksToTextFormatting(marks) : void 0;
|
|
782
|
+
let displayText = attrs.displayText || "";
|
|
783
|
+
if (!displayText) switch (attrs.fieldType) {
|
|
784
|
+
case "PAGE":
|
|
785
|
+
displayText = "1";
|
|
786
|
+
break;
|
|
787
|
+
case "NUMPAGES":
|
|
788
|
+
displayText = "1";
|
|
789
|
+
break;
|
|
790
|
+
default:
|
|
791
|
+
displayText = " ";
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
const displayRun = {
|
|
795
|
+
type: "run",
|
|
796
|
+
content: [{
|
|
797
|
+
type: "text",
|
|
798
|
+
text: displayText
|
|
799
|
+
}],
|
|
800
|
+
...formatting && Object.keys(formatting).length > 0 ? { formatting } : {}
|
|
801
|
+
};
|
|
802
|
+
if (attrs.fieldKind === "complex") {
|
|
803
|
+
const complex = {
|
|
804
|
+
type: "complexField",
|
|
805
|
+
instruction: attrs.instruction,
|
|
806
|
+
fieldType: attrs.fieldType,
|
|
807
|
+
fieldCode: [],
|
|
808
|
+
fieldResult: [displayRun]
|
|
809
|
+
};
|
|
810
|
+
if (attrs.fldLock) complex.fldLock = true;
|
|
811
|
+
if (attrs.dirty) complex.dirty = true;
|
|
812
|
+
return complex;
|
|
813
|
+
}
|
|
814
|
+
const simple = {
|
|
815
|
+
type: "simpleField",
|
|
816
|
+
instruction: attrs.instruction,
|
|
817
|
+
fieldType: attrs.fieldType,
|
|
818
|
+
content: [displayRun]
|
|
819
|
+
};
|
|
820
|
+
if (attrs.fldLock) simple.fldLock = true;
|
|
821
|
+
if (attrs.dirty) simple.dirty = true;
|
|
822
|
+
return simple;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Create a MathEquation from a PM math node
|
|
826
|
+
*/
|
|
827
|
+
function createMathFromNode(node) {
|
|
828
|
+
const attrs = expectMathAttrs(node);
|
|
829
|
+
const math = {
|
|
830
|
+
type: "mathEquation",
|
|
831
|
+
display: attrs.display ?? "inline",
|
|
832
|
+
ommlXml: attrs.ommlXml
|
|
833
|
+
};
|
|
834
|
+
if (attrs.plainText) math.plainText = attrs.plainText;
|
|
835
|
+
return math;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Create an InlineSdt from a PM sdt node
|
|
839
|
+
*/
|
|
840
|
+
function createInlineSdtFromNode(node) {
|
|
841
|
+
const attrs = expectSdtAttrs(node);
|
|
842
|
+
const properties = { sdtType: attrs.sdtType };
|
|
843
|
+
if (attrs.alias) properties.alias = attrs.alias;
|
|
844
|
+
if (attrs.tag) properties.tag = attrs.tag;
|
|
845
|
+
if (typeof attrs.id === "number") properties.id = attrs.id;
|
|
846
|
+
if (attrs.lock) properties.lock = attrs.lock;
|
|
847
|
+
if (attrs.placeholder) properties.placeholder = attrs.placeholder;
|
|
848
|
+
if (attrs.showingPlaceholder !== void 0) properties.showingPlaceholder = attrs.showingPlaceholder;
|
|
849
|
+
if (attrs.dateFormat) properties.dateFormat = attrs.dateFormat;
|
|
850
|
+
if (attrs.dateValueISO) properties.dateValueISO = attrs.dateValueISO;
|
|
851
|
+
if (attrs.listItems) properties.listItems = parseSdtListItems(attrs.listItems);
|
|
852
|
+
if (typeof attrs.dropdownLastValue === "string") properties.dropdownLastValue = attrs.dropdownLastValue;
|
|
853
|
+
if (typeof attrs.checked === "boolean") properties.checked = attrs.checked;
|
|
854
|
+
if (attrs.rawPropertiesXml) properties.rawPropertiesXml = attrs.rawPropertiesXml;
|
|
855
|
+
if (attrs.rawEndPropertiesXml) properties.rawEndPropertiesXml = attrs.rawEndPropertiesXml;
|
|
856
|
+
return {
|
|
857
|
+
type: "inlineSdt",
|
|
858
|
+
properties,
|
|
859
|
+
content: extractParagraphContent(node).filter((c) => c.type === "run" || c.type === "hyperlink" || c.type === "simpleField" || c.type === "complexField" || c.type === "inlineSdt" || c.type === "mathEquation")
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
function parseSdtListItems(rawItems) {
|
|
863
|
+
const parsed = JSON.parse(rawItems);
|
|
864
|
+
if (!Array.isArray(parsed)) throw new TypeError("Invalid ProseMirror sdt attrs: listItems is not an array");
|
|
865
|
+
return parsed.map((item) => {
|
|
866
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) throw new TypeError("Invalid ProseMirror sdt attrs: listItems contains an invalid item");
|
|
867
|
+
const itemAttrs = item;
|
|
868
|
+
if (typeof itemAttrs.displayText !== "string" || typeof itemAttrs.value !== "string") throw new TypeError("Invalid ProseMirror sdt attrs: listItems contains an invalid item");
|
|
869
|
+
return {
|
|
870
|
+
displayText: itemAttrs.displayText,
|
|
871
|
+
value: itemAttrs.value
|
|
872
|
+
};
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Create a Run containing an image
|
|
877
|
+
*/
|
|
878
|
+
function createImageRun(node) {
|
|
879
|
+
const attrs = expectImageAttrs(node);
|
|
880
|
+
const wrap = { type: attrs.wrapType || "inline" };
|
|
881
|
+
if (attrs.distTop !== void 0) wrap.distT = pixelsToEmu(attrs.distTop);
|
|
882
|
+
if (attrs.distBottom !== void 0) wrap.distB = pixelsToEmu(attrs.distBottom);
|
|
883
|
+
if (attrs.distLeft !== void 0) wrap.distL = pixelsToEmu(attrs.distLeft);
|
|
884
|
+
if (attrs.distRight !== void 0) wrap.distR = pixelsToEmu(attrs.distRight);
|
|
885
|
+
if (attrs.wrapText) wrap.wrapText = attrs.wrapText;
|
|
886
|
+
const image = {
|
|
887
|
+
type: "image",
|
|
888
|
+
rId: attrs.rId || "",
|
|
889
|
+
src: attrs.src,
|
|
890
|
+
size: {
|
|
891
|
+
width: pixelsToEmu(attrs.width || 0),
|
|
892
|
+
height: pixelsToEmu(attrs.height || 0)
|
|
893
|
+
},
|
|
894
|
+
wrap
|
|
895
|
+
};
|
|
896
|
+
if (attrs.alt) image.alt = attrs.alt;
|
|
897
|
+
if (attrs.title) image.title = attrs.title;
|
|
898
|
+
const imageTransform = parseTransformAttr(attrs.transform);
|
|
899
|
+
if (imageTransform) image.transform = imageTransform;
|
|
900
|
+
if (attrs.opacity != null) image.opacity = attrs.opacity;
|
|
901
|
+
const imagePosition = imagePositionFromAttrs(attrs.position);
|
|
902
|
+
if (imagePosition) image.position = imagePosition;
|
|
903
|
+
if (attrs.borderWidth && attrs.borderWidth > 0) {
|
|
904
|
+
const outline = {
|
|
905
|
+
width: pixelsToEmu(attrs.borderWidth),
|
|
906
|
+
style: attrs.borderStyle ? {
|
|
907
|
+
solid: "solid",
|
|
908
|
+
dotted: "dot",
|
|
909
|
+
dashed: "dash",
|
|
910
|
+
double: "solid",
|
|
911
|
+
groove: "solid",
|
|
912
|
+
ridge: "solid",
|
|
913
|
+
inset: "solid",
|
|
914
|
+
outset: "solid"
|
|
915
|
+
}[attrs.borderStyle] || "solid" : "solid"
|
|
916
|
+
};
|
|
917
|
+
if (attrs.borderColor) outline.color = { rgb: attrs.borderColor.replace("#", "") };
|
|
918
|
+
image.outline = outline;
|
|
919
|
+
}
|
|
920
|
+
if (attrs.hlinkHref) image.hlinkHref = attrs.hlinkHref;
|
|
921
|
+
const cropTop = attrs.cropTop != null && attrs.cropTop > 0 ? attrs.cropTop : void 0;
|
|
922
|
+
const cropRight = attrs.cropRight != null && attrs.cropRight > 0 ? attrs.cropRight : void 0;
|
|
923
|
+
const cropBottom = attrs.cropBottom != null && attrs.cropBottom > 0 ? attrs.cropBottom : void 0;
|
|
924
|
+
const cropLeft = attrs.cropLeft != null && attrs.cropLeft > 0 ? attrs.cropLeft : void 0;
|
|
925
|
+
if (cropTop !== void 0 || cropRight !== void 0 || cropBottom !== void 0 || cropLeft !== void 0) {
|
|
926
|
+
const crop = {};
|
|
927
|
+
if (cropTop !== void 0) crop.top = cropTop;
|
|
928
|
+
if (cropRight !== void 0) crop.right = cropRight;
|
|
929
|
+
if (cropBottom !== void 0) crop.bottom = cropBottom;
|
|
930
|
+
if (cropLeft !== void 0) crop.left = cropLeft;
|
|
931
|
+
image.crop = crop;
|
|
932
|
+
}
|
|
933
|
+
const drawingContent = {
|
|
934
|
+
type: "drawing",
|
|
935
|
+
image
|
|
936
|
+
};
|
|
937
|
+
if (attrs._docxRawXml) drawingContent.rawXml = attrs._docxRawXml;
|
|
938
|
+
return {
|
|
939
|
+
type: "run",
|
|
940
|
+
content: [drawingContent]
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Create a Run from a ProseMirror shape node
|
|
945
|
+
*/
|
|
946
|
+
function createShapeRun(node) {
|
|
947
|
+
const attrs = expectShapeAttrs(node);
|
|
948
|
+
const shape = {
|
|
949
|
+
type: "shape",
|
|
950
|
+
shapeType: attrs.shapeType || "rect",
|
|
951
|
+
size: {
|
|
952
|
+
width: attrs.width ? pixelsToEmu(attrs.width) : 0,
|
|
953
|
+
height: attrs.height ? pixelsToEmu(attrs.height) : 0
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
if (attrs.shapeId) shape.id = attrs.shapeId;
|
|
957
|
+
const shapeTransform = parseTransformAttr(attrs.transform);
|
|
958
|
+
if (shapeTransform) shape.transform = shapeTransform;
|
|
959
|
+
const wrap = { type: attrs.wrapType || "inline" };
|
|
960
|
+
if (attrs.distTop !== void 0) wrap.distT = pixelsToEmu(attrs.distTop);
|
|
961
|
+
if (attrs.distBottom !== void 0) wrap.distB = pixelsToEmu(attrs.distBottom);
|
|
962
|
+
if (attrs.distLeft !== void 0) wrap.distL = pixelsToEmu(attrs.distLeft);
|
|
963
|
+
if (attrs.distRight !== void 0) wrap.distR = pixelsToEmu(attrs.distRight);
|
|
964
|
+
if (attrs.wrapText) wrap.wrapText = attrs.wrapText;
|
|
965
|
+
shape.wrap = wrap;
|
|
966
|
+
const shapePosition = imagePositionFromAttrs(attrs.position);
|
|
967
|
+
if (shapePosition) shape.position = shapePosition;
|
|
968
|
+
if (attrs.fillType === "gradient" && attrs.gradientStops) try {
|
|
969
|
+
const parsed = JSON.parse(attrs.gradientStops);
|
|
970
|
+
const gradient = {
|
|
971
|
+
type: attrs.gradientType || "linear",
|
|
972
|
+
stops: parsed.map((s) => ({
|
|
973
|
+
position: s.position,
|
|
974
|
+
color: { rgb: s.color.replace("#", "") }
|
|
975
|
+
}))
|
|
976
|
+
};
|
|
977
|
+
if (attrs.gradientAngle) gradient.angle = attrs.gradientAngle;
|
|
978
|
+
shape.fill = {
|
|
979
|
+
type: "gradient",
|
|
980
|
+
gradient
|
|
981
|
+
};
|
|
982
|
+
} catch {
|
|
983
|
+
shape.fill = {
|
|
984
|
+
type: "solid",
|
|
985
|
+
color: { rgb: (attrs.fillColor || "000000").replace("#", "") }
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
else if (attrs.fillColor) shape.fill = {
|
|
989
|
+
type: attrs.fillType ?? "solid",
|
|
990
|
+
color: { rgb: attrs.fillColor.replace("#", "") }
|
|
991
|
+
};
|
|
992
|
+
else if (attrs.fillType === "none") shape.fill = { type: "none" };
|
|
993
|
+
if (attrs.outlineStyle !== "none" && (attrs.outlineWidth !== void 0 && attrs.outlineWidth > 0 || attrs.outlineColor || attrs.outlineStyle || attrs.outlineCap || attrs.outlineHeadEnd || attrs.outlineTailEnd)) {
|
|
994
|
+
const shapeOutline = {};
|
|
995
|
+
if (attrs.outlineWidth !== void 0 && attrs.outlineWidth > 0) shapeOutline.width = pixelsToEmu(attrs.outlineWidth);
|
|
996
|
+
if (attrs.outlineStyle) shapeOutline.style = normalizeShapeOutlineStyle(attrs.outlineStyle) ?? "solid";
|
|
997
|
+
if (attrs.outlineCap) shapeOutline.cap = attrs.outlineCap;
|
|
998
|
+
if (attrs.outlineHeadEnd) shapeOutline.headEnd = attrs.outlineHeadEnd;
|
|
999
|
+
if (attrs.outlineTailEnd) shapeOutline.tailEnd = attrs.outlineTailEnd;
|
|
1000
|
+
if (attrs.outlineColor) shapeOutline.color = { rgb: attrs.outlineColor.replace("#", "") };
|
|
1001
|
+
shape.outline = shapeOutline;
|
|
1002
|
+
}
|
|
1003
|
+
return {
|
|
1004
|
+
type: "run",
|
|
1005
|
+
content: [{
|
|
1006
|
+
type: "shape",
|
|
1007
|
+
shape
|
|
1008
|
+
}]
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Convert ProseMirror marks to TextFormatting
|
|
1013
|
+
*/
|
|
1014
|
+
function marksToTextFormatting(marks) {
|
|
1015
|
+
const formatting = {};
|
|
1016
|
+
let characterStyleRPr;
|
|
1017
|
+
for (const mark of marks) switch (mark.type.name) {
|
|
1018
|
+
case "bold":
|
|
1019
|
+
formatting.bold = true;
|
|
1020
|
+
formatting.boldCs = true;
|
|
1021
|
+
break;
|
|
1022
|
+
case "italic":
|
|
1023
|
+
formatting.italic = true;
|
|
1024
|
+
formatting.italicCs = true;
|
|
1025
|
+
break;
|
|
1026
|
+
case "underline": {
|
|
1027
|
+
const attrs = expectUnderlineMarkAttrs(mark);
|
|
1028
|
+
const uline = { style: attrs.style || "single" };
|
|
1029
|
+
if (attrs.color) uline.color = attrs.color;
|
|
1030
|
+
formatting.underline = uline;
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
case "strike":
|
|
1034
|
+
if (expectStrikeMarkAttrs(mark).double) formatting.doubleStrike = true;
|
|
1035
|
+
else formatting.strike = true;
|
|
1036
|
+
break;
|
|
1037
|
+
case "textColor": {
|
|
1038
|
+
const attrs = expectTextColorMarkAttrs(mark);
|
|
1039
|
+
const colorVal = {};
|
|
1040
|
+
if (attrs.rgb) colorVal.rgb = attrs.rgb;
|
|
1041
|
+
if (attrs.themeColor) colorVal.themeColor = attrs.themeColor;
|
|
1042
|
+
if (attrs.themeTint) colorVal.themeTint = attrs.themeTint;
|
|
1043
|
+
if (attrs.themeShade) colorVal.themeShade = attrs.themeShade;
|
|
1044
|
+
formatting.color = colorVal;
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
case "highlight":
|
|
1048
|
+
formatting.highlight = expectHighlightMarkAttrs(mark).color;
|
|
1049
|
+
break;
|
|
1050
|
+
case "runShading":
|
|
1051
|
+
formatting.shading = runShadingAttrsToShading(expectRunShadingMarkAttrs(mark));
|
|
1052
|
+
break;
|
|
1053
|
+
case "fontSize": {
|
|
1054
|
+
const attrs = expectFontSizeMarkAttrs(mark);
|
|
1055
|
+
formatting.fontSize = attrs.size;
|
|
1056
|
+
formatting.fontSizeCs = attrs.size;
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
1059
|
+
case "fontFamily": {
|
|
1060
|
+
const attrs = expectFontFamilyMarkAttrs(mark);
|
|
1061
|
+
const ff = {};
|
|
1062
|
+
if (attrs.ascii) ff.ascii = attrs.ascii;
|
|
1063
|
+
if (attrs.hAnsi) ff.hAnsi = attrs.hAnsi;
|
|
1064
|
+
if (attrs.eastAsia) ff.eastAsia = attrs.eastAsia;
|
|
1065
|
+
const csVal = attrs.cs || attrs.ascii;
|
|
1066
|
+
if (csVal) ff.cs = csVal;
|
|
1067
|
+
if (attrs.asciiTheme) ff.asciiTheme = attrs.asciiTheme;
|
|
1068
|
+
if (attrs.hAnsiTheme) ff.hAnsiTheme = attrs.hAnsiTheme;
|
|
1069
|
+
if (attrs.eastAsiaTheme) ff.eastAsiaTheme = attrs.eastAsiaTheme;
|
|
1070
|
+
if (attrs.csTheme) ff.csTheme = attrs.csTheme;
|
|
1071
|
+
formatting.fontFamily = ff;
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
case "superscript":
|
|
1075
|
+
formatting.vertAlign = "superscript";
|
|
1076
|
+
break;
|
|
1077
|
+
case "subscript":
|
|
1078
|
+
formatting.vertAlign = "subscript";
|
|
1079
|
+
break;
|
|
1080
|
+
case "allCaps":
|
|
1081
|
+
formatting.allCaps = true;
|
|
1082
|
+
break;
|
|
1083
|
+
case "smallCaps":
|
|
1084
|
+
formatting.smallCaps = true;
|
|
1085
|
+
break;
|
|
1086
|
+
case "characterSpacing": {
|
|
1087
|
+
const attrs = expectCharacterSpacingMarkAttrs(mark);
|
|
1088
|
+
if (attrs.spacing !== void 0) formatting.spacing = attrs.spacing;
|
|
1089
|
+
if (attrs.position !== void 0) formatting.position = attrs.position;
|
|
1090
|
+
if (attrs.scale !== void 0) formatting.scale = attrs.scale;
|
|
1091
|
+
if (attrs.kerning !== void 0) formatting.kerning = attrs.kerning;
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
case "emboss":
|
|
1095
|
+
formatting.emboss = true;
|
|
1096
|
+
break;
|
|
1097
|
+
case "imprint":
|
|
1098
|
+
formatting.imprint = true;
|
|
1099
|
+
break;
|
|
1100
|
+
case "hidden":
|
|
1101
|
+
formatting.hidden = true;
|
|
1102
|
+
break;
|
|
1103
|
+
case "textShadow":
|
|
1104
|
+
formatting.shadow = true;
|
|
1105
|
+
break;
|
|
1106
|
+
case "emphasisMark":
|
|
1107
|
+
formatting.emphasisMark = expectEmphasisMarkAttrs(mark).type || "dot";
|
|
1108
|
+
break;
|
|
1109
|
+
case "textOutline":
|
|
1110
|
+
formatting.outline = true;
|
|
1111
|
+
break;
|
|
1112
|
+
case "rtl":
|
|
1113
|
+
formatting.rtl = true;
|
|
1114
|
+
break;
|
|
1115
|
+
case "textEffect":
|
|
1116
|
+
formatting.effect = expectTextEffectMarkAttrs(mark).effect;
|
|
1117
|
+
break;
|
|
1118
|
+
case "runFormattingOverride":
|
|
1119
|
+
applyRunFormattingOverrideAttrs(formatting, expectRunFormattingOverrideMarkAttrs(mark));
|
|
1120
|
+
break;
|
|
1121
|
+
case "characterStyle": {
|
|
1122
|
+
const attrs = expectCharacterStyleMarkAttrs(mark);
|
|
1123
|
+
formatting.styleId = attrs.styleId;
|
|
1124
|
+
characterStyleRPr = attrs._styleRPr;
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
default: break;
|
|
1128
|
+
}
|
|
1129
|
+
if (characterStyleRPr) return subtractCharacterStyleFormatting(formatting, characterStyleRPr);
|
|
1130
|
+
return formatting;
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Negatable boolean run-property keys whose serializer emits an explicit
|
|
1134
|
+
* `w:val="0"` override when the value is `false` (see `serializeTextFormatting`
|
|
1135
|
+
* in `runSerializer.ts`). Each entry pairs a base key with the complex-script
|
|
1136
|
+
* mirror that `marksToTextFormatting` sets alongside it (the bold/italic marks
|
|
1137
|
+
* set `*Cs` too), so a negative override disables both. Keys without a complex
|
|
1138
|
+
* mirror use `null`.
|
|
1139
|
+
*/
|
|
1140
|
+
const NEGATABLE_STYLE_KEYS = [
|
|
1141
|
+
["bold", "boldCs"],
|
|
1142
|
+
["italic", "italicCs"],
|
|
1143
|
+
["strike", null],
|
|
1144
|
+
["doubleStrike", null],
|
|
1145
|
+
["allCaps", null],
|
|
1146
|
+
["smallCaps", null],
|
|
1147
|
+
["hidden", null],
|
|
1148
|
+
["emboss", null],
|
|
1149
|
+
["imprint", null],
|
|
1150
|
+
["shadow", null],
|
|
1151
|
+
["outline", null],
|
|
1152
|
+
["rtl", null]
|
|
1153
|
+
];
|
|
1154
|
+
/**
|
|
1155
|
+
* Drop run formatting values that the run's character style already provides
|
|
1156
|
+
* (the `w:rStyle` reference re-imposes them on load), so a styled run
|
|
1157
|
+
* serializes back to a style reference instead of baked direct formatting.
|
|
1158
|
+
*
|
|
1159
|
+
* `styleRPr` is the load-time snapshot from the characterStyle mark, captured
|
|
1160
|
+
* in the same normal form this module produces from marks, so value equality
|
|
1161
|
+
* is a faithful "came from the style and is unchanged" check. Values that
|
|
1162
|
+
* differ (user edits, direct overrides from the source document) stay as
|
|
1163
|
+
* direct formatting, which wins over the style per the OOXML cascade.
|
|
1164
|
+
*
|
|
1165
|
+
* When the user *removes* a boolean property the style supplied (e.g. toggling
|
|
1166
|
+
* off bold on text whose `w:rStyle` is bold), that key is no longer present in
|
|
1167
|
+
* `formatting`, so the subtraction loop above never sees it. Without a counter,
|
|
1168
|
+
* the run keeps the style reference and Word re-applies the removed formatting
|
|
1169
|
+
* on load. The second pass emits an explicit negative override (`false`) for
|
|
1170
|
+
* each negatable boolean the style set to `true` but the run no longer carries.
|
|
1171
|
+
*/
|
|
1172
|
+
function subtractCharacterStyleFormatting(formatting, styleRPr) {
|
|
1173
|
+
const result = {};
|
|
1174
|
+
for (const key of Object.keys(formatting)) {
|
|
1175
|
+
const value = formatting[key];
|
|
1176
|
+
if (value === void 0) continue;
|
|
1177
|
+
const styleValue = key === "styleId" ? void 0 : styleRPr[key];
|
|
1178
|
+
if (styleValue !== void 0 && JSON.stringify(value) === JSON.stringify(styleValue)) continue;
|
|
1179
|
+
result[key] = value;
|
|
1180
|
+
}
|
|
1181
|
+
for (const [key, csKey] of NEGATABLE_STYLE_KEYS) {
|
|
1182
|
+
if (styleRPr[key] !== true || formatting[key] !== void 0) continue;
|
|
1183
|
+
result[key] = false;
|
|
1184
|
+
if (csKey !== null) result[csKey] = false;
|
|
1185
|
+
}
|
|
1186
|
+
return result;
|
|
1187
|
+
}
|
|
1188
|
+
function applyRunFormattingOverrideAttrs(formatting, attrs) {
|
|
1189
|
+
if (attrs.bold === false) formatting.bold = false;
|
|
1190
|
+
if (attrs.italic === false) formatting.italic = false;
|
|
1191
|
+
if (attrs.underline === "none") formatting.underline = { style: "none" };
|
|
1192
|
+
if (attrs.strike === false) formatting.strike = false;
|
|
1193
|
+
if (attrs.doubleStrike === false) formatting.doubleStrike = false;
|
|
1194
|
+
if (attrs.allCaps === false) formatting.allCaps = false;
|
|
1195
|
+
if (attrs.smallCaps === false) formatting.smallCaps = false;
|
|
1196
|
+
if (attrs.hidden === false) formatting.hidden = false;
|
|
1197
|
+
if (attrs.emboss === false) formatting.emboss = false;
|
|
1198
|
+
if (attrs.imprint === false) formatting.imprint = false;
|
|
1199
|
+
if (attrs.shadow === false) formatting.shadow = false;
|
|
1200
|
+
if (attrs.outline === false) formatting.outline = false;
|
|
1201
|
+
if (attrs.rtl === false) formatting.rtl = false;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Convert a ProseMirror table node to our Table type
|
|
1205
|
+
*/
|
|
1206
|
+
function inferTableBorders(rows) {
|
|
1207
|
+
for (const row of rows) for (const cell of row.cells) {
|
|
1208
|
+
const borders = cell.formatting?.borders;
|
|
1209
|
+
if (borders) {
|
|
1210
|
+
const base = borders.top || borders.left || borders.right || borders.bottom || borders.insideH || borders.insideV;
|
|
1211
|
+
if (!base) return;
|
|
1212
|
+
return {
|
|
1213
|
+
top: borders.top ?? base,
|
|
1214
|
+
bottom: borders.bottom ?? base,
|
|
1215
|
+
left: borders.left ?? base,
|
|
1216
|
+
right: borders.right ?? base,
|
|
1217
|
+
insideH: borders.insideH ?? borders.bottom ?? base,
|
|
1218
|
+
insideV: borders.insideV ?? borders.right ?? base
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
function convertPMTable(node, documentCounts) {
|
|
1224
|
+
const attrs = expectTableAttrs(node);
|
|
1225
|
+
const rows = convertPMTableRows(node, documentCounts);
|
|
1226
|
+
const formatting = tableAttrsToFormatting(attrs) || void 0;
|
|
1227
|
+
if (!formatting?.borders) {
|
|
1228
|
+
const inferredBorders = inferTableBorders(rows);
|
|
1229
|
+
if (inferredBorders) if (formatting) formatting.borders = inferredBorders;
|
|
1230
|
+
else {
|
|
1231
|
+
const minTable = {
|
|
1232
|
+
type: "table",
|
|
1233
|
+
formatting: { borders: inferredBorders },
|
|
1234
|
+
rows
|
|
1235
|
+
};
|
|
1236
|
+
if (attrs.columnWidths) minTable.columnWidths = attrs.columnWidths;
|
|
1237
|
+
return minTable;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
const table = {
|
|
1241
|
+
type: "table",
|
|
1242
|
+
rows
|
|
1243
|
+
};
|
|
1244
|
+
if (attrs.columnWidths) table.columnWidths = attrs.columnWidths;
|
|
1245
|
+
if (formatting) table.formatting = formatting;
|
|
1246
|
+
return table;
|
|
1247
|
+
}
|
|
1248
|
+
function convertPMTableRows(node, documentCounts) {
|
|
1249
|
+
const rows = [];
|
|
1250
|
+
const activeVerticalMerges = /* @__PURE__ */ new Map();
|
|
1251
|
+
node.forEach((rowNode) => {
|
|
1252
|
+
if (rowNode.type.name === "tableRow") rows.push(convertPMTableRow(rowNode, documentCounts, activeVerticalMerges));
|
|
1253
|
+
});
|
|
1254
|
+
return rows;
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Build CellMargins from PM margin attrs (top/bottom/left/right as number|null|undefined)
|
|
1258
|
+
*/
|
|
1259
|
+
function buildCellMarginsFromAttrs(m) {
|
|
1260
|
+
const margins = {};
|
|
1261
|
+
if (m.top !== null && m.top !== void 0) margins.top = {
|
|
1262
|
+
value: m.top,
|
|
1263
|
+
type: "dxa"
|
|
1264
|
+
};
|
|
1265
|
+
if (m.bottom !== null && m.bottom !== void 0) margins.bottom = {
|
|
1266
|
+
value: m.bottom,
|
|
1267
|
+
type: "dxa"
|
|
1268
|
+
};
|
|
1269
|
+
if (m.left !== null && m.left !== void 0) margins.left = {
|
|
1270
|
+
value: m.left,
|
|
1271
|
+
type: "dxa"
|
|
1272
|
+
};
|
|
1273
|
+
if (m.right !== null && m.right !== void 0) margins.right = {
|
|
1274
|
+
value: m.right,
|
|
1275
|
+
type: "dxa"
|
|
1276
|
+
};
|
|
1277
|
+
return margins;
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Convert ProseMirror table attrs to TableFormatting
|
|
1281
|
+
*/
|
|
1282
|
+
function tableAttrsToFormatting(attrs) {
|
|
1283
|
+
if (attrs._originalFormatting) {
|
|
1284
|
+
const orig = attrs._originalFormatting;
|
|
1285
|
+
const result = { ...orig };
|
|
1286
|
+
if (attrs.styleId !== (orig.styleId ?? void 0)) if (attrs.styleId) result.styleId = attrs.styleId;
|
|
1287
|
+
else delete result.styleId;
|
|
1288
|
+
if (attrs.justification !== (orig.justification ?? void 0)) if (attrs.justification) result.justification = attrs.justification;
|
|
1289
|
+
else delete result.justification;
|
|
1290
|
+
if (attrs.floating !== (orig.floating ?? void 0)) if (attrs.floating) result.floating = attrs.floating;
|
|
1291
|
+
else delete result.floating;
|
|
1292
|
+
if (attrs.look !== (orig.look ?? void 0)) if (attrs.look) result.look = attrs.look;
|
|
1293
|
+
else delete result.look;
|
|
1294
|
+
if (attrs.borders !== (orig.borders ?? void 0)) if (attrs.borders) result.borders = attrs.borders;
|
|
1295
|
+
else delete result.borders;
|
|
1296
|
+
const tableWidth = attrs.width;
|
|
1297
|
+
const tableWidthType = attrs.widthType;
|
|
1298
|
+
const origWidthVal = orig.width?.value;
|
|
1299
|
+
const origWidthType = orig.width?.type;
|
|
1300
|
+
if (tableWidth !== origWidthVal || tableWidthType !== origWidthType) if (tableWidth !== void 0 || tableWidthType !== void 0) result.width = {
|
|
1301
|
+
value: tableWidth ?? 0,
|
|
1302
|
+
type: tableWidthType ?? "dxa"
|
|
1303
|
+
};
|
|
1304
|
+
else delete result.width;
|
|
1305
|
+
if (attrs.cellMargins) result.cellMargins = buildCellMarginsFromAttrs(attrs.cellMargins);
|
|
1306
|
+
return result;
|
|
1307
|
+
}
|
|
1308
|
+
const tableWidth = attrs.width;
|
|
1309
|
+
const tableWidthType = attrs.widthType;
|
|
1310
|
+
if (!(attrs.styleId || tableWidth !== void 0 || tableWidthType !== void 0 || attrs.justification || attrs.floating || attrs.cellMargins || attrs.look || attrs.borders)) return;
|
|
1311
|
+
const cellMargins = attrs.cellMargins ? buildCellMarginsFromAttrs(attrs.cellMargins) : void 0;
|
|
1312
|
+
let width;
|
|
1313
|
+
if (tableWidth !== void 0 || tableWidthType !== void 0) width = {
|
|
1314
|
+
value: tableWidth ?? 0,
|
|
1315
|
+
type: tableWidthType ?? "dxa"
|
|
1316
|
+
};
|
|
1317
|
+
const f = {};
|
|
1318
|
+
if (attrs.styleId) f.styleId = attrs.styleId;
|
|
1319
|
+
if (width) f.width = width;
|
|
1320
|
+
if (attrs.justification) f.justification = attrs.justification;
|
|
1321
|
+
if (attrs.floating) f.floating = attrs.floating;
|
|
1322
|
+
if (cellMargins) f.cellMargins = cellMargins;
|
|
1323
|
+
if (attrs.look) f.look = attrs.look;
|
|
1324
|
+
if (attrs.borders) f.borders = attrs.borders;
|
|
1325
|
+
return f;
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Convert a ProseMirror table row node to our TableRow type
|
|
1329
|
+
*/
|
|
1330
|
+
function convertPMTableRow(node, documentCounts, activeVerticalMerges) {
|
|
1331
|
+
const attrs = expectTableRowAttrs(node);
|
|
1332
|
+
const cells = [];
|
|
1333
|
+
let gridColumn = 0;
|
|
1334
|
+
const appendActiveVerticalMerges = () => {
|
|
1335
|
+
if (!activeVerticalMerges) return;
|
|
1336
|
+
let activeMerge = activeVerticalMerges.get(gridColumn);
|
|
1337
|
+
while (activeMerge) {
|
|
1338
|
+
const preservedCell = activeMerge.continuationCells?.shift();
|
|
1339
|
+
cells.push(preservedCell ?? createVerticalMergeContinuationCell(activeMerge.colspan));
|
|
1340
|
+
activeMerge.remainingRows -= 1;
|
|
1341
|
+
if (activeMerge.remainingRows <= 0) activeVerticalMerges.delete(gridColumn);
|
|
1342
|
+
gridColumn += activeMerge.colspan;
|
|
1343
|
+
activeMerge = activeVerticalMerges.get(gridColumn);
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
node.forEach((cellNode) => {
|
|
1347
|
+
appendActiveVerticalMerges();
|
|
1348
|
+
if (cellNode.type.name === "tableCell" || cellNode.type.name === "tableHeader") {
|
|
1349
|
+
const cellAttrs = expectTableCellAttrs(cellNode);
|
|
1350
|
+
const colspan = Math.max(cellAttrs.colspan, 1);
|
|
1351
|
+
cells.push(convertPMTableCell(cellNode, documentCounts));
|
|
1352
|
+
if (cellAttrs.rowspan > 1) {
|
|
1353
|
+
const continuationCells = cellAttrs._docxVMergeContinuationCells;
|
|
1354
|
+
activeVerticalMerges?.set(gridColumn, {
|
|
1355
|
+
remainingRows: cellAttrs.rowspan - 1,
|
|
1356
|
+
colspan,
|
|
1357
|
+
...continuationCells ? { continuationCells: [...continuationCells] } : {}
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
gridColumn += colspan;
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
appendActiveVerticalMerges();
|
|
1364
|
+
const row = {
|
|
1365
|
+
type: "tableRow",
|
|
1366
|
+
cells
|
|
1367
|
+
};
|
|
1368
|
+
const rowFormatting = tableRowAttrsToFormatting(attrs);
|
|
1369
|
+
if (rowFormatting) row.formatting = rowFormatting;
|
|
1370
|
+
return row;
|
|
1371
|
+
}
|
|
1372
|
+
function createVerticalMergeContinuationCell(colspan) {
|
|
1373
|
+
const formatting = { vMerge: "continue" };
|
|
1374
|
+
if (colspan > 1) formatting.gridSpan = colspan;
|
|
1375
|
+
return {
|
|
1376
|
+
type: "tableCell",
|
|
1377
|
+
content: [{
|
|
1378
|
+
type: "paragraph",
|
|
1379
|
+
content: []
|
|
1380
|
+
}],
|
|
1381
|
+
formatting
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Convert ProseMirror table row attrs to TableRowFormatting
|
|
1386
|
+
*/
|
|
1387
|
+
function tableRowAttrsToFormatting(attrs) {
|
|
1388
|
+
if (attrs._originalFormatting) {
|
|
1389
|
+
const orig = attrs._originalFormatting;
|
|
1390
|
+
const result = { ...orig };
|
|
1391
|
+
if (attrs.height !== (orig.height?.value ?? void 0)) if (attrs.height) result.height = {
|
|
1392
|
+
value: attrs.height,
|
|
1393
|
+
type: "dxa"
|
|
1394
|
+
};
|
|
1395
|
+
else delete result.height;
|
|
1396
|
+
if (attrs.heightRule !== (orig.heightRule ?? void 0)) if (attrs.heightRule) result.heightRule = attrs.heightRule;
|
|
1397
|
+
else delete result.heightRule;
|
|
1398
|
+
if (attrs.isHeader !== (orig.header ?? void 0)) if (attrs.isHeader) result.header = attrs.isHeader;
|
|
1399
|
+
else delete result.header;
|
|
1400
|
+
return result;
|
|
1401
|
+
}
|
|
1402
|
+
if (!(attrs.height || attrs.isHeader)) return;
|
|
1403
|
+
const f = {};
|
|
1404
|
+
if (attrs.height) f.height = {
|
|
1405
|
+
value: attrs.height,
|
|
1406
|
+
type: "dxa"
|
|
1407
|
+
};
|
|
1408
|
+
if (attrs.heightRule) f.heightRule = attrs.heightRule;
|
|
1409
|
+
if (attrs.isHeader) f.header = attrs.isHeader;
|
|
1410
|
+
return f;
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Convert a ProseMirror table cell node to our TableCell type
|
|
1414
|
+
*/
|
|
1415
|
+
function convertPMTableCell(node, documentCounts) {
|
|
1416
|
+
const attrs = expectTableCellAttrs(node);
|
|
1417
|
+
const content = [];
|
|
1418
|
+
node.forEach((contentNode) => {
|
|
1419
|
+
if (contentNode.type.name === "paragraph") content.push(convertPMParagraph(contentNode, documentCounts));
|
|
1420
|
+
else if (contentNode.type.name === "table") content.push(convertPMTable(contentNode, documentCounts));
|
|
1421
|
+
});
|
|
1422
|
+
const cell = {
|
|
1423
|
+
type: "tableCell",
|
|
1424
|
+
content
|
|
1425
|
+
};
|
|
1426
|
+
const cellFormatting = tableCellAttrsToFormatting(attrs);
|
|
1427
|
+
if (cellFormatting) cell.formatting = cellFormatting;
|
|
1428
|
+
return cell;
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Convert ProseMirror table cell attrs to TableCellFormatting
|
|
1432
|
+
* Borders are stored as full BorderSpec objects — no conversion needed.
|
|
1433
|
+
*/
|
|
1434
|
+
function tableCellAttrsToFormatting(attrs) {
|
|
1435
|
+
if (attrs._originalFormatting) {
|
|
1436
|
+
const orig = attrs._originalFormatting;
|
|
1437
|
+
const result = { ...orig };
|
|
1438
|
+
if (attrs.colspan > 1) result.gridSpan = attrs.colspan;
|
|
1439
|
+
if (attrs.rowspan > 1) result.vMerge = "restart";
|
|
1440
|
+
else if (result.vMerge === "restart" && !attrs._preserveVMergeRestart) delete result.vMerge;
|
|
1441
|
+
const cellWidth = attrs.width;
|
|
1442
|
+
if (cellWidth !== void 0) result.width = {
|
|
1443
|
+
value: cellWidth,
|
|
1444
|
+
type: attrs.widthType ?? "dxa"
|
|
1445
|
+
};
|
|
1446
|
+
if (attrs.verticalAlign !== (orig.verticalAlign ?? void 0)) if (attrs.verticalAlign) result.verticalAlign = attrs.verticalAlign;
|
|
1447
|
+
else delete result.verticalAlign;
|
|
1448
|
+
if (attrs.backgroundColor) result.shading = { fill: { rgb: attrs.backgroundColor } };
|
|
1449
|
+
else if (!attrs.backgroundColor && orig.shading) delete result.shading;
|
|
1450
|
+
if (attrs.borders) result.borders = attrs.borders;
|
|
1451
|
+
if (attrs.margins) result.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
1452
|
+
if (attrs.textDirection !== (orig.textDirection ?? void 0)) if (attrs.textDirection) result.textDirection = attrs.textDirection;
|
|
1453
|
+
else delete result.textDirection;
|
|
1454
|
+
return result;
|
|
1455
|
+
}
|
|
1456
|
+
const cellWidth = attrs.width;
|
|
1457
|
+
if (!(attrs.colspan > 1 || attrs.rowspan > 1 || cellWidth !== void 0 || attrs.verticalAlign || attrs.backgroundColor || attrs.borders || attrs.margins || attrs.textDirection)) return;
|
|
1458
|
+
const f = {};
|
|
1459
|
+
if (attrs.colspan > 1) f.gridSpan = attrs.colspan;
|
|
1460
|
+
if (attrs.rowspan > 1) f.vMerge = "restart";
|
|
1461
|
+
if (cellWidth !== void 0) f.width = {
|
|
1462
|
+
value: cellWidth,
|
|
1463
|
+
type: attrs.widthType ?? "dxa"
|
|
1464
|
+
};
|
|
1465
|
+
if (attrs.verticalAlign) f.verticalAlign = attrs.verticalAlign;
|
|
1466
|
+
if (attrs.textDirection) f.textDirection = attrs.textDirection;
|
|
1467
|
+
if (attrs.backgroundColor) f.shading = { fill: { rgb: attrs.backgroundColor } };
|
|
1468
|
+
if (attrs.borders) f.borders = attrs.borders;
|
|
1469
|
+
if (attrs.margins) f.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
1470
|
+
return f;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Convert a ProseMirror textBox node back to a Paragraph wrapping a ShapeContent run.
|
|
1474
|
+
* The text box content becomes a Shape with textBody.
|
|
1475
|
+
*/
|
|
1476
|
+
function convertPMTextBox(node) {
|
|
1477
|
+
const attrs = expectTextBoxAttrs(node);
|
|
1478
|
+
const childParagraphs = [];
|
|
1479
|
+
node.forEach((child) => {
|
|
1480
|
+
if (child.type.name === "paragraph") childParagraphs.push(convertPMParagraph(child));
|
|
1481
|
+
});
|
|
1482
|
+
const shape = {
|
|
1483
|
+
type: "shape",
|
|
1484
|
+
shapeType: "textBox",
|
|
1485
|
+
size: {
|
|
1486
|
+
width: attrs.width ? pixelsToEmu(attrs.width) : 0,
|
|
1487
|
+
height: attrs.height ? pixelsToEmu(attrs.height) : 0
|
|
1488
|
+
},
|
|
1489
|
+
textBody: {
|
|
1490
|
+
content: childParagraphs.length > 0 ? childParagraphs : [{
|
|
1491
|
+
type: "paragraph",
|
|
1492
|
+
content: []
|
|
1493
|
+
}],
|
|
1494
|
+
margins: (() => {
|
|
1495
|
+
const m = {};
|
|
1496
|
+
if (typeof attrs.marginTop === "number") m.top = pixelsToEmu(attrs.marginTop);
|
|
1497
|
+
if (typeof attrs.marginBottom === "number") m.bottom = pixelsToEmu(attrs.marginBottom);
|
|
1498
|
+
if (typeof attrs.marginLeft === "number") m.left = pixelsToEmu(attrs.marginLeft);
|
|
1499
|
+
if (typeof attrs.marginRight === "number") m.right = pixelsToEmu(attrs.marginRight);
|
|
1500
|
+
return m;
|
|
1501
|
+
})()
|
|
1502
|
+
}
|
|
1503
|
+
};
|
|
1504
|
+
if (attrs.textBoxId) shape.id = attrs.textBoxId;
|
|
1505
|
+
if (attrs.fillColor) shape.fill = {
|
|
1506
|
+
type: "solid",
|
|
1507
|
+
color: { rgb: attrs.fillColor.replace("#", "") }
|
|
1508
|
+
};
|
|
1509
|
+
if (attrs.outlineStyle !== "none" && attrs.outlineWidth && attrs.outlineWidth > 0) {
|
|
1510
|
+
const tbOutline = {
|
|
1511
|
+
width: pixelsToEmu(attrs.outlineWidth),
|
|
1512
|
+
style: normalizeShapeOutlineStyle(attrs.outlineStyle) ?? "solid"
|
|
1513
|
+
};
|
|
1514
|
+
if (attrs.outlineColor) tbOutline.color = { rgb: attrs.outlineColor.replace("#", "") };
|
|
1515
|
+
shape.outline = tbOutline;
|
|
1516
|
+
}
|
|
1517
|
+
const wrap = textBoxWrapFromAttrs(attrs);
|
|
1518
|
+
if (wrap) shape.wrap = wrap;
|
|
1519
|
+
const position = imagePositionFromAttrs(attrs.position);
|
|
1520
|
+
if (position) shape.position = position;
|
|
1521
|
+
return {
|
|
1522
|
+
type: "paragraph",
|
|
1523
|
+
content: [{
|
|
1524
|
+
type: "run",
|
|
1525
|
+
content: [{
|
|
1526
|
+
type: "shape",
|
|
1527
|
+
shape
|
|
1528
|
+
}]
|
|
1529
|
+
}]
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* Update a Document with content from a ProseMirror document
|
|
1534
|
+
* Preserves all non-content parts of the original document
|
|
1535
|
+
*/
|
|
1536
|
+
function updateDocumentContent(originalDocument, pmDoc) {
|
|
1537
|
+
return fromProseDoc(pmDoc, originalDocument);
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Convert a ProseMirror document back to an array of `BlockContent` blocks
|
|
1541
|
+
* (paragraphs, tables, and block-level content controls).
|
|
1542
|
+
*
|
|
1543
|
+
* Used for converting edited header/footer PM content back to the document
|
|
1544
|
+
* model.
|
|
1545
|
+
*/
|
|
1546
|
+
function proseDocToBlocks(pmDoc) {
|
|
1547
|
+
return extractBlocks(pmDoc);
|
|
1548
|
+
}
|
|
1549
|
+
//#endregion
|
|
1550
|
+
export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, updateDocumentContent };
|