@stll/folio-core 0.46.0 → 0.47.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/dist/ai-edits/apply.js +26 -24
- package/dist/ai-edits/headless.js +1 -1
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/content-controls/checkboxDisplay.d.ts +8 -2
- package/dist/content-controls/checkboxDisplay.js +11 -5
- package/dist/content-controls/mutateContentControls.js +41 -42
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +7 -7
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -20
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +93 -13
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +1 -19
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +34 -1
- package/dist/docx/attributeRemainder.js +49 -3
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +39 -67
- package/dist/docx/blockPlainText.js +3 -1
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentParser.js +3 -3
- package/dist/docx/commentRangeIntegrity.js +1 -1
- package/dist/docx/commentRangeJoin.js +1 -1
- package/dist/docx/commentReferenceNormalization.js +3 -2
- package/dist/docx/commentReplyMarkers.js +1 -1
- package/dist/docx/compatibility.js +56 -42
- package/dist/docx/containerChildren.d.ts +110 -13
- package/dist/docx/containerChildren.gen.d.ts +16 -1
- package/dist/docx/containerChildren.gen.js +18 -1
- package/dist/docx/containerChildren.js +63 -13
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.js +4 -1
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterReferenceNormalization.js +1 -1
- package/dist/docx/hyperlinkParser.d.ts +45 -7
- package/dist/docx/hyperlinkParser.js +126 -57
- package/dist/docx/imageParser.js +127 -107
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +84 -3
- package/dist/docx/inlineWrapperContent.js +85 -4
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +4 -2
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +91 -1
- package/dist/docx/paraIdAttribute.js +79 -1
- package/dist/docx/paragraphParser.d.ts +9 -24
- package/dist/docx/paragraphParser.js +212 -396
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +2 -0
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +14 -7
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +47 -49
- package/dist/docx/parseWarningMessage.js +3 -0
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.js +16 -6
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -2
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +78 -9
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +54 -18
- package/dist/docx/runParser.js +379 -295
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +236 -240
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +21 -2
- package/dist/docx/selectiveXmlPatch.js +195 -99
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +10 -8
- package/dist/docx/serializer/documentSerializer.js +3 -0
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +3 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +3 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +88 -188
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +109 -59
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +34 -45
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +268 -100
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +18 -16
- package/dist/docx/server/migrateYjsAttrSchema.js +3 -3
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +8 -3
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +10 -1
- package/dist/docx/tableParser.js +505 -181
- package/dist/docx/textBoxParser.d.ts +3 -1
- package/dist/docx/textBoxParser.js +18 -8
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/vmlImageParser.d.ts +13 -4
- package/dist/docx/vmlImageParser.js +74 -31
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlParser.d.ts +14 -1
- package/dist/docx/xmlParser.js +18 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +3 -1
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +177 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +47 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderPage.js +6 -4
- package/dist/layout-painter/renderParagraph.d.ts +2 -1
- package/dist/layout-painter/renderParagraph.js +13 -26
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/markdown/renderBlock.js +3 -1
- package/dist/markdown/renderRuns.js +7 -2
- package/dist/markdown/renderTable.js +2 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/prosemirror/attrs/index.d.ts +22 -4
- package/dist/prosemirror/attrs/index.js +498 -60
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +24 -19
- package/dist/prosemirror/commands/image.d.ts +1 -1
- package/dist/prosemirror/commands/image.js +4 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +18 -2
- package/dist/prosemirror/conversion/fromProseDoc.js +330 -183
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.js +371 -141
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +8 -2
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +19 -15
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +26 -2
- package/dist/prosemirror/extensions/markRegistry.js +73 -10
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +17 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.js +2 -1
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +10 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +8 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +4 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +141 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.js +20 -3
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.js +24 -6
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -0
- package/dist/prosemirror/runFormattingInlineCarriers.js +2 -0
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +23 -4
- package/dist/prosemirror/schema/nodes.d.ts +220 -24
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +17 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +2 -2
- package/dist/prosemirror/yjsDocumentMetadata.js +428 -7
- package/dist/prosemirror/zeroWidthAnchors.js +4 -0
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/mergeDocumentContent.js +5 -3
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -1
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -52
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { isValidHexId } from "../utils/hexId.js";
|
|
2
2
|
import { attributeRemainder } from "./attributeRemainder.js";
|
|
3
3
|
import { parseBookmarkEnd as parseBookmarkEnd$1, parseBookmarkStart as parseBookmarkStart$1 } from "./bookmarkParser.js";
|
|
4
|
-
import {
|
|
5
|
-
import { CAPTURE, DROPPED_WITH_ITS_WRAPPER, OWNED_ELSEWHERE, dispatchChildren, transitionalNamespaceOf, withPreservedChildren } from "./containerChildren.js";
|
|
4
|
+
import { CAPTURE, dispatchChildren, ownedElsewhere, transitionalNamespaceOf, withPreservedChildren } from "./containerChildren.js";
|
|
6
5
|
import { parseFieldType } from "./fieldParser.js";
|
|
7
6
|
import { fieldStateOf, parseFieldState } from "./fieldState.js";
|
|
8
7
|
import { hyperlinkChildHandlers, parseHyperlink as parseHyperlink$1 } from "./hyperlinkParser.js";
|
|
9
|
-
import { isInlineSdtContent, isTrackedChangeWrapperChild } from "./inlineWrapperContent.js";
|
|
8
|
+
import { isHyperlinkContent, isInlineSdtContent, isTrackedChangeWrapperChild } from "./inlineWrapperContent.js";
|
|
9
|
+
import { inlineWrapperOf } from "./inlineWrapperParser.js";
|
|
10
10
|
import { parseMarkupRangeMarker, parseMoveBookmarkMarker } from "./markupRangeMarker.js";
|
|
11
|
-
import { markerFormattingFromLevel, numberingLevelHasMarkerSlot } from "./numberingParser.js";
|
|
12
|
-
import {
|
|
11
|
+
import { counterFormatOf, markerAlignmentForLevel, markerFormattingFromLevel, numberingLevelHasMarkerSlot } from "./numberingParser.js";
|
|
12
|
+
import { mergeParagraphNumbering as mergeParagraphNumbering$1, paragraphNumberingReferenceId as paragraphNumberingReferenceId$1, resolveParagraphNumbering as resolveParagraphNumbering$1 } from "./numberingReference.js";
|
|
13
13
|
import { paraIdAttribute, textIdAttribute } from "./paraIdAttribute.js";
|
|
14
14
|
import { paraIdInRange } from "./paraIdRangeNormalization.js";
|
|
15
|
+
import { parseParagraphProperties } from "./paragraphProperties.js";
|
|
15
16
|
import { assignParagraphPropertySource } from "./paragraphPropertySource.js";
|
|
16
|
-
import {
|
|
17
|
-
import { preserveInlineChild, preservedInlineCapture } from "./preservedRunContent.js";
|
|
17
|
+
import { preserveInlineChild, preserveRunChild, preservedInlineCapture } from "./preservedRunContent.js";
|
|
18
18
|
import { consolidateParagraphContent } from "./runConsolidator.js";
|
|
19
|
-
import { parseRun
|
|
20
|
-
import {
|
|
19
|
+
import { parseRun } from "./runParser.js";
|
|
20
|
+
import { runHoldsPayload } from "./runPayload.js";
|
|
21
|
+
import { captureSdtSiblingMarkers, parseSdtProperties } from "./sdtProperties.js";
|
|
21
22
|
import { parseSectionProperties } from "./sectionParser.js";
|
|
22
|
-
import {
|
|
23
|
+
import { hasAttributeAnySpelling } from "./strictNames.js";
|
|
23
24
|
import { scanRunForTextBoxDrawings } from "./textBoxParser.js";
|
|
24
25
|
import { parsePropertyChangeInfo, parseTrackedChangeInfo } from "./trackedChangeInfo.js";
|
|
25
26
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
26
27
|
import { isVmlPictParsedByRunParser } from "./vmlImageParser.js";
|
|
27
|
-
import { WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, findChild, findChildByNamespaceUri,
|
|
28
|
+
import { WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, findChild, findChildByNamespaceUri, findChildrenByNamespaceUri, findWordprocessingChild, getAttribute, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespaceUri, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute, selectAlternateContentBranch } from "./xmlParser.js";
|
|
28
29
|
import { panic } from "better-result";
|
|
29
|
-
import {
|
|
30
|
+
import { PARAGRAPH_MARK_CHANGE_KINDS, REVIEW_CARRIERS } from "@stll/docx-core/model";
|
|
30
31
|
//#region src/docx/paragraphParser.ts
|
|
31
32
|
const FOLIO_REVIEW_HISTORY_NAMESPACES = /* @__PURE__ */ new Set(["urn:stella:folio:review-history:1"]);
|
|
32
33
|
/**
|
|
@@ -46,293 +47,6 @@ function extractMathText(el) {
|
|
|
46
47
|
return text;
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
|
-
* Parse tab stops (w:tabs)
|
|
50
|
-
*/
|
|
51
|
-
function parseTabStops(tabs) {
|
|
52
|
-
if (!tabs) return;
|
|
53
|
-
const tabElements = findChildren(tabs, "w", "tab");
|
|
54
|
-
if (tabElements.length === 0) return;
|
|
55
|
-
const result = [];
|
|
56
|
-
for (const tab of tabElements) {
|
|
57
|
-
const pos = parseNumericAttribute(tab, "w", "pos");
|
|
58
|
-
const alignment = narrowEnum(getAttribute(tab, "w", "val"), TabStopAlignmentSchema);
|
|
59
|
-
if (pos !== void 0 && alignment) {
|
|
60
|
-
const tabStop = {
|
|
61
|
-
position: pos,
|
|
62
|
-
alignment
|
|
63
|
-
};
|
|
64
|
-
const leader = narrowEnum(getAttribute(tab, "w", "leader"), TabLeaderSchema);
|
|
65
|
-
if (leader && leader !== "none") tabStop.leader = leader;
|
|
66
|
-
result.push(tabStop);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return result.length > 0 ? result : void 0;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Parse frame properties (w:framePr)
|
|
73
|
-
*/
|
|
74
|
-
function parseFrameProperties(framePr) {
|
|
75
|
-
if (!framePr) return;
|
|
76
|
-
const frame = {};
|
|
77
|
-
const dropCap = getAttribute(framePr, "w", "dropCap");
|
|
78
|
-
if (dropCap === "none" || dropCap === "drop" || dropCap === "margin") frame.dropCap = dropCap;
|
|
79
|
-
const lines = parseNumericAttribute(framePr, "w", "lines");
|
|
80
|
-
if (lines !== void 0) frame.lines = lines;
|
|
81
|
-
const w = parseNumericAttribute(framePr, "w", "w");
|
|
82
|
-
if (w !== void 0) frame.width = w;
|
|
83
|
-
const h = parseNumericAttribute(framePr, "w", "h");
|
|
84
|
-
if (h !== void 0) frame.height = h;
|
|
85
|
-
const hSpace = parseNumericAttribute(framePr, "w", "hSpace");
|
|
86
|
-
if (hSpace !== void 0) frame.hSpace = hSpace;
|
|
87
|
-
const vSpace = parseNumericAttribute(framePr, "w", "vSpace");
|
|
88
|
-
if (vSpace !== void 0) frame.vSpace = vSpace;
|
|
89
|
-
const hAnchor = getAttribute(framePr, "w", "hAnchor");
|
|
90
|
-
if (hAnchor === "text" || hAnchor === "margin" || hAnchor === "page") frame.hAnchor = hAnchor;
|
|
91
|
-
const vAnchor = getAttribute(framePr, "w", "vAnchor");
|
|
92
|
-
if (vAnchor === "text" || vAnchor === "margin" || vAnchor === "page") frame.vAnchor = vAnchor;
|
|
93
|
-
const x = parseNumericAttribute(framePr, "w", "x");
|
|
94
|
-
if (x !== void 0) frame.x = x;
|
|
95
|
-
const y = parseNumericAttribute(framePr, "w", "y");
|
|
96
|
-
if (y !== void 0) frame.y = y;
|
|
97
|
-
const xAlign = narrowEnum(getAttribute(framePr, "w", "xAlign"), FrameXAlignSchema);
|
|
98
|
-
if (xAlign) frame.xAlign = xAlign;
|
|
99
|
-
const yAlign = narrowEnum(getAttribute(framePr, "w", "yAlign"), FrameYAlignSchema);
|
|
100
|
-
if (yAlign) frame.yAlign = yAlign;
|
|
101
|
-
const wrap = narrowEnum(getAttribute(framePr, "w", "wrap"), FrameWrapSchema);
|
|
102
|
-
if (wrap) frame.wrap = wrap;
|
|
103
|
-
return Object.keys(frame).length > 0 ? frame : void 0;
|
|
104
|
-
}
|
|
105
|
-
function collectFirstParagraphPropertyChildren(pPr) {
|
|
106
|
-
const children = {};
|
|
107
|
-
for (const child of pPr.elements ?? []) {
|
|
108
|
-
if (child.type !== "element") continue;
|
|
109
|
-
switch (getLocalName(child.name)) {
|
|
110
|
-
case "bidi":
|
|
111
|
-
children.bidi ??= child;
|
|
112
|
-
break;
|
|
113
|
-
case "contextualSpacing":
|
|
114
|
-
children.contextualSpacing ??= child;
|
|
115
|
-
break;
|
|
116
|
-
case "framePr":
|
|
117
|
-
children.framePr ??= child;
|
|
118
|
-
break;
|
|
119
|
-
case "ind":
|
|
120
|
-
children.ind ??= child;
|
|
121
|
-
break;
|
|
122
|
-
case "jc":
|
|
123
|
-
children.jc ??= child;
|
|
124
|
-
break;
|
|
125
|
-
case "keepLines":
|
|
126
|
-
children.keepLines ??= child;
|
|
127
|
-
break;
|
|
128
|
-
case "keepNext":
|
|
129
|
-
children.keepNext ??= child;
|
|
130
|
-
break;
|
|
131
|
-
case "kinsoku":
|
|
132
|
-
children.kinsoku ??= child;
|
|
133
|
-
break;
|
|
134
|
-
case "numPr":
|
|
135
|
-
children.numPr ??= child;
|
|
136
|
-
break;
|
|
137
|
-
case "outlineLvl":
|
|
138
|
-
children.outlineLvl ??= child;
|
|
139
|
-
break;
|
|
140
|
-
case "overflowPunct":
|
|
141
|
-
children.overflowPunct ??= child;
|
|
142
|
-
break;
|
|
143
|
-
case "pageBreakBefore":
|
|
144
|
-
children.pageBreakBefore ??= child;
|
|
145
|
-
break;
|
|
146
|
-
case "pBdr":
|
|
147
|
-
children.pBdr ??= child;
|
|
148
|
-
break;
|
|
149
|
-
case "pStyle":
|
|
150
|
-
children.pStyle ??= child;
|
|
151
|
-
break;
|
|
152
|
-
case "rPr":
|
|
153
|
-
children.rPr ??= child;
|
|
154
|
-
break;
|
|
155
|
-
case "shd":
|
|
156
|
-
children.shd ??= child;
|
|
157
|
-
break;
|
|
158
|
-
case "snapToGrid":
|
|
159
|
-
children.snapToGrid ??= child;
|
|
160
|
-
break;
|
|
161
|
-
case "spacing":
|
|
162
|
-
children.spacing ??= child;
|
|
163
|
-
break;
|
|
164
|
-
case "suppressAutoHyphens":
|
|
165
|
-
children.suppressAutoHyphens ??= child;
|
|
166
|
-
break;
|
|
167
|
-
case "suppressLineNumbers":
|
|
168
|
-
children.suppressLineNumbers ??= child;
|
|
169
|
-
break;
|
|
170
|
-
case "tabs":
|
|
171
|
-
children.tabs ??= child;
|
|
172
|
-
break;
|
|
173
|
-
case "widowControl":
|
|
174
|
-
children.widowControl ??= child;
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return children;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Parse paragraph formatting properties (w:pPr)
|
|
182
|
-
*
|
|
183
|
-
* Handles ALL pPr properties:
|
|
184
|
-
* - w:jc (alignment: left, center, right, both/justify)
|
|
185
|
-
* - w:spacing (before, after, line, lineRule)
|
|
186
|
-
* - w:ind (left, right, firstLine, hanging)
|
|
187
|
-
* - w:pBdr (paragraph borders: top, bottom, left, right, between)
|
|
188
|
-
* - w:shd (paragraph shading/background)
|
|
189
|
-
* - w:tabs (tab stops with positions and types)
|
|
190
|
-
* - w:keepNext, w:keepLines, w:widowControl, w:pageBreakBefore
|
|
191
|
-
* - w:bidi (right-to-left)
|
|
192
|
-
* - w:numPr (list info)
|
|
193
|
-
* - w:pStyle (style reference)
|
|
194
|
-
* - w:outlineLvl (outline level)
|
|
195
|
-
* - w:framePr (frame properties)
|
|
196
|
-
* - w:rPr (default run properties)
|
|
197
|
-
*/
|
|
198
|
-
function parseParagraphProperties(pPr, theme, styles) {
|
|
199
|
-
if (!pPr) return;
|
|
200
|
-
const formatting = {};
|
|
201
|
-
const propertyChildren = collectFirstParagraphPropertyChildren(pPr);
|
|
202
|
-
const kinsoku = propertyChildren.kinsoku;
|
|
203
|
-
if (kinsoku) formatting.kinsoku = parseBooleanElement(kinsoku);
|
|
204
|
-
const overflowPunct = propertyChildren.overflowPunct;
|
|
205
|
-
if (overflowPunct) formatting.overflowPunctuation = parseBooleanElement(overflowPunct);
|
|
206
|
-
const jc = propertyChildren.jc;
|
|
207
|
-
if (jc) {
|
|
208
|
-
const val = narrowEnum(getAttribute(jc, "w", "val"), ParagraphAlignmentSchema);
|
|
209
|
-
if (val) formatting.alignment = val;
|
|
210
|
-
}
|
|
211
|
-
const bidi = propertyChildren.bidi;
|
|
212
|
-
if (bidi) formatting.bidi = parseBooleanElement(bidi);
|
|
213
|
-
const snapToGrid = propertyChildren.snapToGrid;
|
|
214
|
-
if (snapToGrid) formatting.snapToGrid = parseBooleanElement(snapToGrid);
|
|
215
|
-
const spacing = propertyChildren.spacing;
|
|
216
|
-
if (spacing) {
|
|
217
|
-
const before = parseNumericAttribute(spacing, "w", "before");
|
|
218
|
-
if (before !== void 0) formatting.spaceBefore = before;
|
|
219
|
-
const after = parseNumericAttribute(spacing, "w", "after");
|
|
220
|
-
if (after !== void 0) formatting.spaceAfter = after;
|
|
221
|
-
const line = parseNumericAttribute(spacing, "w", "line");
|
|
222
|
-
if (line !== void 0) formatting.lineSpacing = line;
|
|
223
|
-
const spacingExplicit = {};
|
|
224
|
-
if (before !== void 0) spacingExplicit.before = true;
|
|
225
|
-
if (after !== void 0) spacingExplicit.after = true;
|
|
226
|
-
if (spacingExplicit.before || spacingExplicit.after) formatting.spacingExplicit = spacingExplicit;
|
|
227
|
-
const lineRule = narrowEnum(getAttribute(spacing, "w", "lineRule"), LineSpacingRuleSchema);
|
|
228
|
-
if (lineRule) formatting.lineSpacingRule = lineRule;
|
|
229
|
-
const beforeAutospacing = parseOnOffAttribute(spacing, "w", "beforeAutospacing");
|
|
230
|
-
if (beforeAutospacing !== void 0) formatting.beforeAutospacing = beforeAutospacing;
|
|
231
|
-
const afterAutospacing = parseOnOffAttribute(spacing, "w", "afterAutospacing");
|
|
232
|
-
if (afterAutospacing !== void 0) formatting.afterAutospacing = afterAutospacing;
|
|
233
|
-
}
|
|
234
|
-
const ind = propertyChildren.ind;
|
|
235
|
-
if (ind) {
|
|
236
|
-
const left = parseNumericAttribute(ind, "w", "left");
|
|
237
|
-
if (left !== void 0) formatting.indentLeft = left;
|
|
238
|
-
const right = parseNumericAttribute(ind, "w", "right");
|
|
239
|
-
if (right !== void 0) formatting.indentRight = right;
|
|
240
|
-
const firstLine = parseNumericAttribute(ind, "w", "firstLine");
|
|
241
|
-
if (firstLine !== void 0) formatting.indentFirstLine = firstLine;
|
|
242
|
-
const hanging = parseNumericAttribute(ind, "w", "hanging");
|
|
243
|
-
if (hanging !== void 0) {
|
|
244
|
-
formatting.indentFirstLine = -hanging;
|
|
245
|
-
formatting.hangingIndent = true;
|
|
246
|
-
}
|
|
247
|
-
const start = parseNumericAttribute(ind, "w", "start");
|
|
248
|
-
if (start !== void 0 && formatting.indentLeft === void 0) formatting.indentLeft = start;
|
|
249
|
-
const end = parseNumericAttribute(ind, "w", "end");
|
|
250
|
-
if (end !== void 0 && formatting.indentRight === void 0) formatting.indentRight = end;
|
|
251
|
-
}
|
|
252
|
-
const pBdr = propertyChildren.pBdr;
|
|
253
|
-
if (pBdr) {
|
|
254
|
-
const borders = {};
|
|
255
|
-
const top = parseBorderSpec(findChild(pBdr, "w", "top"));
|
|
256
|
-
if (top) borders.top = top;
|
|
257
|
-
const bottom = parseBorderSpec(findChild(pBdr, "w", "bottom"));
|
|
258
|
-
if (bottom) borders.bottom = bottom;
|
|
259
|
-
const left = parseBorderSpec(findChild(pBdr, "w", "left"));
|
|
260
|
-
if (left) borders.left = left;
|
|
261
|
-
const right = parseBorderSpec(findChild(pBdr, "w", "right"));
|
|
262
|
-
if (right) borders.right = right;
|
|
263
|
-
const between = parseBorderSpec(findChild(pBdr, "w", "between"));
|
|
264
|
-
if (between) borders.between = between;
|
|
265
|
-
const bar = parseBorderSpec(findChild(pBdr, "w", "bar"));
|
|
266
|
-
if (bar) borders.bar = bar;
|
|
267
|
-
if (Object.keys(borders).length > 0) formatting.borders = borders;
|
|
268
|
-
}
|
|
269
|
-
const shd = propertyChildren.shd;
|
|
270
|
-
if (shd) {
|
|
271
|
-
const shadingResult = parseShading(shd);
|
|
272
|
-
if (shadingResult !== void 0) formatting.shading = shadingResult;
|
|
273
|
-
}
|
|
274
|
-
const tabs = propertyChildren.tabs;
|
|
275
|
-
if (tabs) {
|
|
276
|
-
const tabsResult = parseTabStops(tabs);
|
|
277
|
-
if (tabsResult !== void 0) formatting.tabs = tabsResult;
|
|
278
|
-
}
|
|
279
|
-
const keepNext = propertyChildren.keepNext;
|
|
280
|
-
if (keepNext) formatting.keepNext = parseBooleanElement(keepNext);
|
|
281
|
-
const keepLines = propertyChildren.keepLines;
|
|
282
|
-
if (keepLines) formatting.keepLines = parseBooleanElement(keepLines);
|
|
283
|
-
const widowControl = propertyChildren.widowControl;
|
|
284
|
-
if (widowControl) formatting.widowControl = parseBooleanElement(widowControl);
|
|
285
|
-
const pageBreakBefore = propertyChildren.pageBreakBefore;
|
|
286
|
-
if (pageBreakBefore) formatting.pageBreakBefore = parseBooleanElement(pageBreakBefore);
|
|
287
|
-
const contextualSpacing = propertyChildren.contextualSpacing;
|
|
288
|
-
if (contextualSpacing) formatting.contextualSpacing = parseBooleanElement(contextualSpacing);
|
|
289
|
-
const numPr = propertyChildren.numPr;
|
|
290
|
-
if (numPr) {
|
|
291
|
-
const numIdEl = findChild(numPr, "w", "numId");
|
|
292
|
-
const ilvlEl = findChild(numPr, "w", "ilvl");
|
|
293
|
-
if (numIdEl || ilvlEl) {
|
|
294
|
-
formatting.numPr = {};
|
|
295
|
-
if (numIdEl) {
|
|
296
|
-
const val = parseNumericAttribute(numIdEl, "w", "val");
|
|
297
|
-
if (val !== void 0) formatting.numPr.numId = val;
|
|
298
|
-
}
|
|
299
|
-
if (ilvlEl) {
|
|
300
|
-
const val = parseNumberingLevelAttribute(ilvlEl);
|
|
301
|
-
if (val !== void 0) formatting.numPr.ilvl = val;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
const numberingChange = findChild(numPr, "w", "numberingChange");
|
|
305
|
-
if (numberingChange) formatting.numberingChangeXml = captureVerbatimXml(numberingChange);
|
|
306
|
-
}
|
|
307
|
-
const outlineLvl = propertyChildren.outlineLvl;
|
|
308
|
-
if (outlineLvl) {
|
|
309
|
-
const val = parseNumericAttribute(outlineLvl, "w", "val");
|
|
310
|
-
if (val !== void 0) formatting.outlineLevel = val;
|
|
311
|
-
}
|
|
312
|
-
const pStyle = propertyChildren.pStyle;
|
|
313
|
-
if (pStyle) {
|
|
314
|
-
const val = getAttribute(pStyle, "w", "val");
|
|
315
|
-
if (val) formatting.styleId = val;
|
|
316
|
-
}
|
|
317
|
-
const framePr = propertyChildren.framePr;
|
|
318
|
-
if (framePr) {
|
|
319
|
-
const frameResult = parseFrameProperties(framePr);
|
|
320
|
-
if (frameResult !== void 0) formatting.frame = frameResult;
|
|
321
|
-
}
|
|
322
|
-
const suppressLineNumbers = propertyChildren.suppressLineNumbers;
|
|
323
|
-
if (suppressLineNumbers) formatting.suppressLineNumbers = parseBooleanElement(suppressLineNumbers);
|
|
324
|
-
const suppressAutoHyphens = propertyChildren.suppressAutoHyphens;
|
|
325
|
-
if (suppressAutoHyphens) formatting.suppressAutoHyphens = parseBooleanElement(suppressAutoHyphens);
|
|
326
|
-
const rPr = propertyChildren.rPr;
|
|
327
|
-
if (rPr) {
|
|
328
|
-
const runPropsResult = parseRunProperties(rPr, theme, styles);
|
|
329
|
-
if (runPropsResult !== void 0) formatting.runProperties = runPropsResult;
|
|
330
|
-
const specVanish = findChild(rPr, "w", "specVanish");
|
|
331
|
-
if (specVanish && parseBooleanElement(specVanish)) formatting.runInWithNext = true;
|
|
332
|
-
}
|
|
333
|
-
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
50
|
* Capture the authored paragraph properties separately from structural and
|
|
337
51
|
* revision children, which have their own model fields and lifecycles.
|
|
338
52
|
*/
|
|
@@ -456,10 +170,10 @@ function normalizeDeletionContentElement(node) {
|
|
|
456
170
|
...node.elements ? { elements: node.elements.map(normalizeDeletionContentElement) } : {}
|
|
457
171
|
});
|
|
458
172
|
}
|
|
459
|
-
function parseParagraphPropertyChanges(pPr, theme,
|
|
173
|
+
function parseParagraphPropertyChanges(pPr, theme, currentFormatting) {
|
|
460
174
|
if (!pPr) return;
|
|
461
175
|
const changes = findChildrenByNamespaceUri(pPr, WORDPROCESSINGML_NAMESPACE_URIS, "pPrChange").map((changeElement) => {
|
|
462
|
-
const previousFormatting = parseParagraphProperties(findChildByNamespaceUri(changeElement, WORDPROCESSINGML_NAMESPACE_URIS, "pPr"), theme
|
|
176
|
+
const previousFormatting = parseParagraphProperties(findChildByNamespaceUri(changeElement, WORDPROCESSINGML_NAMESPACE_URIS, "pPr"), theme);
|
|
463
177
|
const change = {
|
|
464
178
|
type: "paragraphPropertyChange",
|
|
465
179
|
info: parsePropertyChangeInfo(changeElement)
|
|
@@ -467,7 +181,7 @@ function parseParagraphPropertyChanges(pPr, theme, styles, currentFormatting) {
|
|
|
467
181
|
if (previousFormatting !== void 0) change.previousFormatting = previousFormatting;
|
|
468
182
|
if (currentFormatting !== void 0) change.currentFormatting = currentFormatting;
|
|
469
183
|
return change;
|
|
470
|
-
})
|
|
184
|
+
});
|
|
471
185
|
return changes.length > 0 ? changes : void 0;
|
|
472
186
|
}
|
|
473
187
|
/**
|
|
@@ -628,7 +342,6 @@ const mathContentOf = (child) => {
|
|
|
628
342
|
if (plainText) equation.plainText = plainText;
|
|
629
343
|
return equation;
|
|
630
344
|
};
|
|
631
|
-
const isHyperlinkChildContent = (content) => content.type === "run" || content.type === "bookmarkStart" || content.type === "bookmarkEnd" || content.type === "preservedInline";
|
|
632
345
|
/**
|
|
633
346
|
* A `w:hyperlink` as paragraph content, with any revision wrapper it holds
|
|
634
347
|
* hoisted around it.
|
|
@@ -658,7 +371,7 @@ function parseHyperlinkParagraphContents(node, rels, styles, theme, media, rootX
|
|
|
658
371
|
}
|
|
659
372
|
};
|
|
660
373
|
for (const item of wrapped) {
|
|
661
|
-
if (
|
|
374
|
+
if (isHyperlinkContent(item)) {
|
|
662
375
|
linked.push(item);
|
|
663
376
|
continue;
|
|
664
377
|
}
|
|
@@ -676,7 +389,7 @@ function parseHyperlinkParagraphContents(node, rels, styles, theme, media, rootX
|
|
|
676
389
|
const preserved = dispatchChildren({
|
|
677
390
|
element: node,
|
|
678
391
|
container: "w:hyperlink",
|
|
679
|
-
|
|
392
|
+
capturePosition: () => items.length,
|
|
680
393
|
handlers: {
|
|
681
394
|
...hyperlinkChildHandlers({
|
|
682
395
|
push: (child) => {
|
|
@@ -750,61 +463,146 @@ function parseSimpleField(node, styles, theme, rels, media, rootXmlns = {}) {
|
|
|
750
463
|
field.content = withPreservedChildren(content, dispatchChildren({
|
|
751
464
|
element: node,
|
|
752
465
|
container: "w:fldSimple",
|
|
753
|
-
|
|
754
|
-
handlers: {
|
|
755
|
-
|
|
756
|
-
content.push(
|
|
757
|
-
},
|
|
758
|
-
hyperlink: (child) => {
|
|
759
|
-
content.push(parseHyperlink(child, rels, styles, theme, media, inScopeXmlns));
|
|
760
|
-
},
|
|
761
|
-
customXml: (child) => {
|
|
762
|
-
content.push(preserveInlineChild(child));
|
|
466
|
+
capturePosition: () => content.length,
|
|
467
|
+
handlers: simpleFieldChildHandlers({
|
|
468
|
+
push: (child) => {
|
|
469
|
+
content.push(child);
|
|
763
470
|
},
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
commentRangeEnd: CAPTURE,
|
|
771
|
-
commentRangeStart: CAPTURE,
|
|
772
|
-
customXmlDelRangeEnd: CAPTURE,
|
|
773
|
-
customXmlDelRangeStart: CAPTURE,
|
|
774
|
-
customXmlInsRangeEnd: CAPTURE,
|
|
775
|
-
customXmlInsRangeStart: CAPTURE,
|
|
776
|
-
customXmlMoveFromRangeEnd: CAPTURE,
|
|
777
|
-
customXmlMoveFromRangeStart: CAPTURE,
|
|
778
|
-
customXmlMoveToRangeEnd: CAPTURE,
|
|
779
|
-
customXmlMoveToRangeStart: CAPTURE,
|
|
780
|
-
del: CAPTURE,
|
|
781
|
-
dir: CAPTURE,
|
|
782
|
-
fldData: CAPTURE,
|
|
783
|
-
fldSimple: CAPTURE,
|
|
784
|
-
ins: CAPTURE,
|
|
785
|
-
moveFrom: CAPTURE,
|
|
786
|
-
moveFromRangeEnd: CAPTURE,
|
|
787
|
-
moveFromRangeStart: CAPTURE,
|
|
788
|
-
moveTo: CAPTURE,
|
|
789
|
-
moveToRangeEnd: CAPTURE,
|
|
790
|
-
moveToRangeStart: CAPTURE,
|
|
791
|
-
permEnd: CAPTURE,
|
|
792
|
-
permStart: CAPTURE,
|
|
793
|
-
proofErr: CAPTURE,
|
|
794
|
-
sdt: CAPTURE,
|
|
795
|
-
subDoc: CAPTURE
|
|
796
|
-
}
|
|
471
|
+
styles,
|
|
472
|
+
theme,
|
|
473
|
+
rels,
|
|
474
|
+
media,
|
|
475
|
+
inScopeXmlns
|
|
476
|
+
})
|
|
797
477
|
}), preservedInlineCapture);
|
|
798
478
|
return field;
|
|
799
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* What a `w:fldSimple` does with every child its content model declares.
|
|
482
|
+
*
|
|
483
|
+
* Two callers read this one map: {@link parseSimpleField}, and
|
|
484
|
+
* {@link parseFieldInlineWrapper} for a transparent wrapper the field holds —
|
|
485
|
+
* `CT_BdoContentRun` and its three siblings are the same `EG_PContent` the
|
|
486
|
+
* field is, so the decision per child is the field's own.
|
|
487
|
+
*/
|
|
488
|
+
const simpleFieldChildHandlers = (context) => {
|
|
489
|
+
const { push, styles, theme, rels, media, inScopeXmlns } = context;
|
|
490
|
+
const wrapper = (element) => (child) => {
|
|
491
|
+
push(parseFieldInlineWrapper(element, child, context));
|
|
492
|
+
};
|
|
493
|
+
return {
|
|
494
|
+
r: (child) => {
|
|
495
|
+
push(parseRun(child, styles, theme, rels, media, inScopeXmlns));
|
|
496
|
+
},
|
|
497
|
+
hyperlink: (child) => {
|
|
498
|
+
push(parseHyperlink(child, rels, styles, theme, media, inScopeXmlns));
|
|
499
|
+
},
|
|
500
|
+
bdo: wrapper("bdo"),
|
|
501
|
+
dir: wrapper("dir"),
|
|
502
|
+
customXml: wrapper("customXml"),
|
|
503
|
+
smartTag: wrapper("smartTag"),
|
|
504
|
+
bookmarkEnd: CAPTURE,
|
|
505
|
+
bookmarkStart: CAPTURE,
|
|
506
|
+
commentRangeEnd: CAPTURE,
|
|
507
|
+
commentRangeStart: CAPTURE,
|
|
508
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
509
|
+
customXmlDelRangeStart: CAPTURE,
|
|
510
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
511
|
+
customXmlInsRangeStart: CAPTURE,
|
|
512
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
513
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
514
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
515
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
516
|
+
del: CAPTURE,
|
|
517
|
+
fldData: CAPTURE,
|
|
518
|
+
fldSimple: (child) => {
|
|
519
|
+
push(preserveInlineChild(child));
|
|
520
|
+
},
|
|
521
|
+
ins: CAPTURE,
|
|
522
|
+
moveFrom: CAPTURE,
|
|
523
|
+
moveFromRangeEnd: CAPTURE,
|
|
524
|
+
moveFromRangeStart: CAPTURE,
|
|
525
|
+
moveTo: CAPTURE,
|
|
526
|
+
moveToRangeEnd: CAPTURE,
|
|
527
|
+
moveToRangeStart: CAPTURE,
|
|
528
|
+
permEnd: CAPTURE,
|
|
529
|
+
permStart: CAPTURE,
|
|
530
|
+
proofErr: CAPTURE,
|
|
531
|
+
sdt: CAPTURE,
|
|
532
|
+
subDoc: CAPTURE
|
|
533
|
+
};
|
|
534
|
+
};
|
|
535
|
+
/**
|
|
536
|
+
* A transparent wrapper a simple field holds, with the content the field holds.
|
|
537
|
+
*
|
|
538
|
+
* The mirror of `parseLinkedInlineWrapper`: the wrapper's declared children are
|
|
539
|
+
* run-level content, the decision per child is the container's own map, and the
|
|
540
|
+
* wrapper's properties bag is read by `inlineWrapperOf` rather than captured a
|
|
541
|
+
* second time by the sink.
|
|
542
|
+
*/
|
|
543
|
+
const parseFieldInlineWrapper = (element, node, context) => {
|
|
544
|
+
const inScopeXmlns = mergeXmlnsDeclarations(context.inScopeXmlns, node);
|
|
545
|
+
const content = [];
|
|
546
|
+
return inlineWrapperOf(element, node, withPreservedChildren(content, dispatchChildren({
|
|
547
|
+
element: node,
|
|
548
|
+
container: "run-level-content",
|
|
549
|
+
capturePosition: () => content.length,
|
|
550
|
+
handlers: {
|
|
551
|
+
...simpleFieldChildHandlers({
|
|
552
|
+
...context,
|
|
553
|
+
inScopeXmlns,
|
|
554
|
+
push: (child) => {
|
|
555
|
+
content.push(child);
|
|
556
|
+
}
|
|
557
|
+
}),
|
|
558
|
+
customXmlPr: CUSTOM_XML_PROPERTIES_OWNER,
|
|
559
|
+
smartTagPr: SMART_TAG_PROPERTIES_OWNER,
|
|
560
|
+
pPr: CAPTURE
|
|
561
|
+
}
|
|
562
|
+
}), preservedInlineCapture));
|
|
563
|
+
};
|
|
800
564
|
const hasRunPayload = ({ run, runElement, rels, media }) => {
|
|
801
|
-
if (run
|
|
565
|
+
if (runHoldsPayload(run)) return true;
|
|
802
566
|
const { textBoxDrawings, vmlTextBoxes } = scanRunForTextBoxDrawings({
|
|
803
567
|
xmlRun: runElement,
|
|
804
568
|
claimedByRunParser: (pictElement) => isVmlPictParsedByRunParser(pictElement, rels, media)
|
|
805
569
|
});
|
|
806
570
|
return textBoxDrawings.length > 0 || vmlTextBoxes.length > 0;
|
|
807
571
|
};
|
|
572
|
+
/**
|
|
573
|
+
* A field character that belongs to no field, kept as the markup it was.
|
|
574
|
+
*
|
|
575
|
+
* `FieldCharContent` is half of a `ComplexField`: `convertField` reads it off
|
|
576
|
+
* the assembled field, and one that reaches the editor's inline converter on
|
|
577
|
+
* its own is dropped. So a `w:fldChar` whose field this paragraph never closed,
|
|
578
|
+
* or one with no `begin` before it, loses the editor round trip — and the
|
|
579
|
+
* model holds nothing of its `w:ffData` either, so the save loses a legacy form
|
|
580
|
+
* field's name, macros, help text and checkbox state as well.
|
|
581
|
+
*
|
|
582
|
+
* `preservedXml` is the run's own capture member: the editor carries it as an
|
|
583
|
+
* opaque atom and the serializer replays the source bytes, `w:ffData` included.
|
|
584
|
+
* The two lists line up because `parseRunContents` walks the source children in
|
|
585
|
+
* order, so the nth `w:fldChar` child is the nth `fieldChar` content.
|
|
586
|
+
*
|
|
587
|
+
* `w:instrText` is left alone. It is fully modelled and fully serialized; what
|
|
588
|
+
* the editor does with an orphan is a separate question from what the container
|
|
589
|
+
* contract asks here, and answering it with bytes would trade a model for one.
|
|
590
|
+
*/
|
|
591
|
+
const withOrphanFieldCharsPreserved = (run, runElement) => {
|
|
592
|
+
const captured = getChildElements(runElement).filter((child) => getLocalName(child.name) === "fldChar").map(preserveRunChild);
|
|
593
|
+
if (captured.length === 0) return run;
|
|
594
|
+
let next = 0;
|
|
595
|
+
const content = run.content.map((item) => {
|
|
596
|
+
if (item.type !== "fieldChar") return item;
|
|
597
|
+
const replacement = captured[next];
|
|
598
|
+
next += 1;
|
|
599
|
+
return replacement ?? item;
|
|
600
|
+
});
|
|
601
|
+
return {
|
|
602
|
+
...run,
|
|
603
|
+
content
|
|
604
|
+
};
|
|
605
|
+
};
|
|
808
606
|
const LEGACY_FORM_CHECKBOX_GLYPHS = {
|
|
809
607
|
checked: "☒",
|
|
810
608
|
unchecked: "☐"
|
|
@@ -847,6 +645,28 @@ function isLegacyFormCheckboxInstruction(instruction) {
|
|
|
847
645
|
return instruction.trim().split(/\s+/u).at(0)?.toUpperCase() === LEGACY_FORM_CHECKBOX_INSTRUCTION;
|
|
848
646
|
}
|
|
849
647
|
/**
|
|
648
|
+
* The paragraph's own properties, read from the element by `parseParagraph`.
|
|
649
|
+
*
|
|
650
|
+
* The entry is in the inline handler map because the map covers every inline
|
|
651
|
+
* container, not because this walk reads it. Declared at module scope so the
|
|
652
|
+
* claim is registered when the module loads.
|
|
653
|
+
*/
|
|
654
|
+
const PARAGRAPH_PROPERTIES_OWNER = ownedElsewhere({
|
|
655
|
+
container: "run-level-content",
|
|
656
|
+
child: "pPr",
|
|
657
|
+
reader: "paragraphProperties#parseParagraphProperties"
|
|
658
|
+
});
|
|
659
|
+
const SMART_TAG_PROPERTIES_OWNER = ownedElsewhere({
|
|
660
|
+
container: "run-level-content",
|
|
661
|
+
child: "smartTagPr",
|
|
662
|
+
reader: "inlineWrapperParser#inlineWrapperOf"
|
|
663
|
+
});
|
|
664
|
+
const CUSTOM_XML_PROPERTIES_OWNER = ownedElsewhere({
|
|
665
|
+
container: "run-level-content",
|
|
666
|
+
child: "customXmlPr",
|
|
667
|
+
reader: "inlineWrapperParser#inlineWrapperOf"
|
|
668
|
+
});
|
|
669
|
+
/**
|
|
850
670
|
* Parse all content within a paragraph
|
|
851
671
|
*
|
|
852
672
|
* Returns the parsed content and any complex fields that span multiple runs
|
|
@@ -858,25 +678,16 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
858
678
|
let complexFieldInstr = "";
|
|
859
679
|
let complexFieldCodeRuns = [];
|
|
860
680
|
let complexFieldResultRuns = [];
|
|
681
|
+
let complexFieldOpenRuns = [];
|
|
861
682
|
let afterSeparator = false;
|
|
862
683
|
let complexFieldState = {};
|
|
863
684
|
let complexFieldFallbackDisplay;
|
|
864
685
|
let complexFieldFormatting;
|
|
865
|
-
const
|
|
866
|
-
const wrapper = {
|
|
867
|
-
type: "inlineWrapper",
|
|
868
|
-
kind: "bidi",
|
|
869
|
-
control,
|
|
870
|
-
content: parseParagraphContents(child, styles, theme, null, rels, media, trackedContext, inScopeXmlns)
|
|
871
|
-
};
|
|
872
|
-
const direction = getAttribute(child, "w", "val");
|
|
873
|
-
if (direction === "ltr" || direction === "rtl") wrapper.direction = direction;
|
|
874
|
-
return wrapper;
|
|
875
|
-
};
|
|
686
|
+
const parseInlineWrapper = (child, element) => inlineWrapperOf(element, child, parseParagraphContents(child, styles, theme, null, rels, media, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child)));
|
|
876
687
|
const preserved = dispatchChildren({
|
|
877
688
|
element: paraElement,
|
|
878
689
|
container: "run-level-content",
|
|
879
|
-
|
|
690
|
+
capturePosition: () => contents.length,
|
|
880
691
|
undeclared: { AlternateContent: (child) => {
|
|
881
692
|
const selectedBranch = selectAlternateContentBranch(child);
|
|
882
693
|
if (selectedBranch) contents.push(...parseParagraphContents(selectedBranch, styles, theme, null, rels, media, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child)));
|
|
@@ -916,11 +727,13 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
916
727
|
complexFieldInstr = "";
|
|
917
728
|
complexFieldCodeRuns = [];
|
|
918
729
|
complexFieldResultRuns = [];
|
|
730
|
+
complexFieldOpenRuns = [];
|
|
919
731
|
complexFieldState = beginFieldState;
|
|
920
732
|
complexFieldFallbackDisplay = beginFallbackDisplay;
|
|
921
733
|
complexFieldFormatting = run.formatting;
|
|
922
734
|
}
|
|
923
735
|
if (inComplexField) {
|
|
736
|
+
complexFieldOpenRuns.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
924
737
|
if (instrText) complexFieldInstr += instrText;
|
|
925
738
|
if ((!complexFieldFormatting || Object.keys(complexFieldFormatting).length === 0) && run.formatting && Object.keys(run.formatting).length > 0) complexFieldFormatting = run.formatting;
|
|
926
739
|
let inFieldCodeRegion = !hasFieldBegin && !afterSeparator;
|
|
@@ -967,7 +780,7 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
967
780
|
inComplexField = false;
|
|
968
781
|
}
|
|
969
782
|
} else if (commentReferenceId !== null) {
|
|
970
|
-
if (run
|
|
783
|
+
if (runHoldsPayload(run)) contents.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
971
784
|
contents.push({
|
|
972
785
|
type: "commentReference",
|
|
973
786
|
id: commentReferenceId
|
|
@@ -977,7 +790,7 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
977
790
|
runElement,
|
|
978
791
|
rels,
|
|
979
792
|
media
|
|
980
|
-
})) contents.push(run);
|
|
793
|
+
})) contents.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
981
794
|
},
|
|
982
795
|
hyperlink: (child) => {
|
|
983
796
|
contents.push(...parseHyperlinkParagraphContents(child, rels, styles, theme, media, inScopeXmlns));
|
|
@@ -991,9 +804,9 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
991
804
|
fldSimple: (child) => {
|
|
992
805
|
contents.push(parseSimpleField(child, styles, theme, rels, media, inScopeXmlns));
|
|
993
806
|
},
|
|
994
|
-
pPr:
|
|
807
|
+
pPr: PARAGRAPH_PROPERTIES_OWNER,
|
|
995
808
|
customXml: (child) => {
|
|
996
|
-
contents.push(
|
|
809
|
+
contents.push(parseInlineWrapper(child, "customXml"));
|
|
997
810
|
},
|
|
998
811
|
proofErr: CAPTURE,
|
|
999
812
|
permStart: CAPTURE,
|
|
@@ -1007,14 +820,18 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
1007
820
|
customXmlMoveFromRangeStart: CAPTURE,
|
|
1008
821
|
customXmlMoveToRangeEnd: CAPTURE,
|
|
1009
822
|
customXmlMoveToRangeStart: CAPTURE,
|
|
1010
|
-
smartTagPr:
|
|
823
|
+
smartTagPr: SMART_TAG_PROPERTIES_OWNER,
|
|
824
|
+
customXmlPr: CUSTOM_XML_PROPERTIES_OWNER,
|
|
1011
825
|
sdt: (child) => {
|
|
1012
|
-
const sdtPr =
|
|
1013
|
-
const sdtEndPr =
|
|
1014
|
-
const sdtContentEl =
|
|
826
|
+
const sdtPr = findWordprocessingChild(child, "sdtPr");
|
|
827
|
+
const sdtEndPr = findWordprocessingChild(child, "sdtEndPr");
|
|
828
|
+
const sdtContentEl = findWordprocessingChild(child, "sdtContent");
|
|
1015
829
|
if (sdtContentEl) {
|
|
1016
830
|
const sdtParsed = parseParagraphContents(sdtContentEl, styles, theme, null, rels, media, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child));
|
|
1017
831
|
const properties = parseSdtProperties(sdtPr, sdtEndPr);
|
|
832
|
+
const captured = captureSdtSiblingMarkers(child);
|
|
833
|
+
if (captured.before.length > 0) properties.rawSdtChildrenBeforeContent = captured.before;
|
|
834
|
+
if (captured.after.length > 0) properties.rawSdtChildrenAfterContent = captured.after;
|
|
1018
835
|
pushInlineSdtSegments({
|
|
1019
836
|
contents,
|
|
1020
837
|
properties,
|
|
@@ -1063,8 +880,7 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
1063
880
|
});
|
|
1064
881
|
},
|
|
1065
882
|
smartTag: (child) => {
|
|
1066
|
-
|
|
1067
|
-
contents.push(...inner);
|
|
883
|
+
contents.push(parseInlineWrapper(child, "smartTag"));
|
|
1068
884
|
},
|
|
1069
885
|
moveFromRangeStart: (child) => {
|
|
1070
886
|
contents.push({
|
|
@@ -1103,14 +919,14 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
1103
919
|
});
|
|
1104
920
|
},
|
|
1105
921
|
bdo: (child) => {
|
|
1106
|
-
contents.push(
|
|
922
|
+
contents.push(parseInlineWrapper(child, "bdo"));
|
|
1107
923
|
},
|
|
1108
924
|
dir: (child) => {
|
|
1109
|
-
contents.push(
|
|
925
|
+
contents.push(parseInlineWrapper(child, "dir"));
|
|
1110
926
|
}
|
|
1111
927
|
}
|
|
1112
928
|
});
|
|
1113
|
-
if (inComplexField
|
|
929
|
+
if (inComplexField) contents.push(...complexFieldOpenRuns);
|
|
1114
930
|
return withPreservedChildren(contents, preserved, preservedInlineCapture);
|
|
1115
931
|
}
|
|
1116
932
|
function getCommentReferenceId(runElement) {
|
|
@@ -1161,40 +977,38 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
1161
977
|
if (!options?.inHeaderFooter && paragraphStartsWithRenderedPageBreak(node)) paragraph.renderedPageBreakBefore = true;
|
|
1162
978
|
const pPr = findChild(node, "w", "pPr");
|
|
1163
979
|
if (pPr) {
|
|
1164
|
-
const formattingResult = parseParagraphProperties(pPr, theme
|
|
980
|
+
const formattingResult = parseParagraphProperties(pPr, theme);
|
|
1165
981
|
if (formattingResult !== void 0) paragraph.formatting = formattingResult;
|
|
1166
|
-
const propertyChangesResult = parseParagraphPropertyChanges(pPr, theme,
|
|
982
|
+
const propertyChangesResult = parseParagraphPropertyChanges(pPr, theme, paragraph.formatting);
|
|
1167
983
|
if (propertyChangesResult !== void 0) paragraph.propertyChanges = propertyChangesResult;
|
|
1168
984
|
const pPrMarkResult = parseParagraphMarkChange(pPr);
|
|
1169
985
|
if (pPrMarkResult !== void 0) paragraph.pPrMark = pPrMarkResult;
|
|
1170
986
|
const sectPr = findChild(pPr, "w", "sectPr");
|
|
1171
987
|
if (sectPr) paragraph.sectionProperties = parseSectionProperties(sectPr);
|
|
1172
988
|
}
|
|
1173
|
-
|
|
989
|
+
const rawContent = parseParagraphContents(node, styles, theme, numbering, rels, media, "default", options?.rootXmlns ?? {});
|
|
990
|
+
paragraph.content = options?.runConsolidation === "deferred" ? rawContent : consolidateParagraphContent(rawContent);
|
|
1174
991
|
const paragraphFormatting = paragraph.formatting;
|
|
1175
992
|
const directNumPr = paragraphFormatting?.numPr;
|
|
1176
993
|
const styleNumPr = paragraphFormatting?.styleId && styles ? styles.get(paragraphFormatting.styleId)?.pPr?.numPr : void 0;
|
|
994
|
+
const numPrFromStyle = styleNumPr !== void 0 && (directNumPr === void 0 || directNumPr.kind === "levelOnly");
|
|
1177
995
|
let effectiveNumPr = directNumPr;
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
effectiveNumPr =
|
|
1181
|
-
...styleNumPr,
|
|
1182
|
-
...directNumPr
|
|
1183
|
-
};
|
|
1184
|
-
numPrFromStyle = true;
|
|
1185
|
-
paragraphFormatting.numPr = effectiveNumPr;
|
|
996
|
+
if (paragraphFormatting && numPrFromStyle) {
|
|
997
|
+
effectiveNumPr = mergeParagraphNumbering$1(styleNumPr, directNumPr);
|
|
998
|
+
if (effectiveNumPr !== void 0) paragraphFormatting.numPr = effectiveNumPr;
|
|
1186
999
|
paragraphFormatting.numPrFromStyle = styleNumPr;
|
|
1187
1000
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
if (
|
|
1001
|
+
const resolvedNumbering = resolveParagraphNumbering$1(effectiveNumPr);
|
|
1002
|
+
if (numbering) {
|
|
1003
|
+
if (resolvedNumbering.kind === "reference") {
|
|
1004
|
+
const { numId, ilvl } = resolvedNumbering;
|
|
1191
1005
|
const level = numbering.getLevel(numId, ilvl);
|
|
1192
1006
|
if (level) {
|
|
1193
1007
|
const levelNumFmts = [];
|
|
1194
1008
|
const levelStarts = [];
|
|
1195
1009
|
for (let levelIndex = 0; levelIndex <= ilvl; levelIndex += 1) {
|
|
1196
1010
|
const listLevel = numbering.getLevel(numId, levelIndex);
|
|
1197
|
-
levelNumFmts.push(level.isLgl ? "decimal" : listLevel
|
|
1011
|
+
levelNumFmts.push(level.isLgl || !listLevel ? "decimal" : counterFormatOf(listLevel));
|
|
1198
1012
|
levelStarts.push(listLevel?.start ?? 1);
|
|
1199
1013
|
}
|
|
1200
1014
|
const listRendering = {
|
|
@@ -1211,12 +1025,13 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
1211
1025
|
if (instance?.abstractNumId !== void 0) listRendering.abstractNumId = instance.abstractNumId;
|
|
1212
1026
|
if (overrideForLevel?.startOverride !== void 0) listRendering.startOverride = overrideForLevel.startOverride;
|
|
1213
1027
|
if (level.isLgl) listRendering.isLegal = true;
|
|
1214
|
-
listRendering.numFmt = level.isLgl ? "decimal" : level
|
|
1028
|
+
listRendering.numFmt = level.isLgl ? "decimal" : counterFormatOf(level);
|
|
1215
1029
|
if (level.rPr?.hidden) listRendering.markerHidden = true;
|
|
1216
1030
|
const markerFormatting = markerFormattingFromLevel(level.rPr);
|
|
1217
1031
|
if (markerFormatting) listRendering.markerFormatting = markerFormatting;
|
|
1218
1032
|
if (level.rPr?.allCaps) listRendering.markerAllCaps = true;
|
|
1219
|
-
|
|
1033
|
+
const markerAlignment = markerAlignmentForLevel(level.lvlJc);
|
|
1034
|
+
if (markerAlignment !== void 0) listRendering.markerAlignment = markerAlignment;
|
|
1220
1035
|
if (level.suffix) listRendering.markerSuffix = level.suffix;
|
|
1221
1036
|
let implicitChildLevelAdvances = 0;
|
|
1222
1037
|
const foldedMarkerSuffix = [];
|
|
@@ -1261,7 +1076,7 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
1261
1076
|
if (level.pPr) {
|
|
1262
1077
|
if (!paragraph.formatting) paragraph.formatting = {};
|
|
1263
1078
|
const directInd = pPr ? findChild(pPr, "w", "ind") : null;
|
|
1264
|
-
const hasDirectLeft =
|
|
1079
|
+
const hasDirectLeft = hasAttributeAnySpelling(directInd, "CT_Ind @left");
|
|
1265
1080
|
const directFirstLine = directInd ? parseNumericAttribute(directInd, "w", "firstLine") : void 0;
|
|
1266
1081
|
const directHanging = directInd ? parseNumericAttribute(directInd, "w", "hanging") : void 0;
|
|
1267
1082
|
const hasDirectFirstLineOrHanging = directFirstLine !== void 0 && directFirstLine !== 0 || directHanging !== void 0 && directHanging !== 0;
|
|
@@ -1333,6 +1148,7 @@ const getHyperlinkText = (hyperlink) => hyperlink.children.map((child) => {
|
|
|
1333
1148
|
case "bookmarkStart":
|
|
1334
1149
|
case "bookmarkEnd": return "";
|
|
1335
1150
|
case "preservedInline": return child.text;
|
|
1151
|
+
case "inlineWrapper": return child.content.map(getParagraphContentText).join("");
|
|
1336
1152
|
default: return panic(`Unsupported hyperlink child in plain-text extraction: ${JSON.stringify(child)}`);
|
|
1337
1153
|
}
|
|
1338
1154
|
}).join("");
|
|
@@ -1387,7 +1203,7 @@ function isEmptyParagraph(paragraph) {
|
|
|
1387
1203
|
* @returns true if paragraph has numbering properties
|
|
1388
1204
|
*/
|
|
1389
1205
|
function isListItem(paragraph) {
|
|
1390
|
-
return
|
|
1206
|
+
return paragraphNumberingReferenceId$1(paragraph.formatting?.numPr) !== void 0;
|
|
1391
1207
|
}
|
|
1392
1208
|
/**
|
|
1393
1209
|
* Get the list level of a paragraph (0-8)
|
|
@@ -1396,8 +1212,8 @@ function isListItem(paragraph) {
|
|
|
1396
1212
|
* @returns List level or undefined if not a list item
|
|
1397
1213
|
*/
|
|
1398
1214
|
function getListLevel(paragraph) {
|
|
1399
|
-
|
|
1400
|
-
return
|
|
1215
|
+
const resolved = resolveParagraphNumbering$1(paragraph.formatting?.numPr);
|
|
1216
|
+
return resolved.kind === "reference" ? resolved.ilvl : void 0;
|
|
1401
1217
|
}
|
|
1402
1218
|
/**
|
|
1403
1219
|
* Check if paragraph has a specific style
|
|
@@ -1424,4 +1240,4 @@ function getTemplateVariable(paragraph) {
|
|
|
1424
1240
|
return text.slice(start + 2, end);
|
|
1425
1241
|
}
|
|
1426
1242
|
//#endregion
|
|
1427
|
-
export { getListLevel, getParagraphText, getTemplateVariable, hasStyle, isEmptyParagraph, isListItem, parseParagraph,
|
|
1243
|
+
export { getListLevel, getParagraphText, getTemplateVariable, hasStyle, isEmptyParagraph, isListItem, parseParagraph, parseParagraphPropertyChanges };
|