@stll/folio-core 0.45.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 +85 -43
- package/dist/ai-edits/headless.js +2 -2
- 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/compare.js +2 -5
- 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/scenario.js +2 -5
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +17 -0
- package/dist/content-controls/checkboxDisplay.js +46 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +57 -43
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -18
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +113 -14
- 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 +11 -21
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +76 -0
- package/dist/docx/attributeRemainder.js +111 -0
- package/dist/docx/blockContentParser.d.ts +3 -1
- package/dist/docx/blockContentParser.js +102 -106
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +3 -0
- 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.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +56 -39
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +3 -1
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/compatibility.js +56 -41
- package/dist/docx/containerChildren.d.ts +208 -0
- package/dist/docx/containerChildren.gen.d.ts +43 -0
- package/dist/docx/containerChildren.gen.js +263 -0
- package/dist/docx/containerChildren.js +153 -0
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +7 -4
- 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/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +66 -9
- package/dist/docx/hyperlinkParser.js +153 -26
- package/dist/docx/imageParser.js +160 -115
- 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 +166 -0
- package/dist/docx/inlineWrapperContent.js +165 -0
- 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 +12 -1
- 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 +111 -0
- package/dist/docx/paraIdAttribute.js +142 -0
- package/dist/docx/paragraphParser.d.ts +10 -25
- package/dist/docx/paragraphParser.js +421 -496
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
- package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +53 -52
- package/dist/docx/parseWarningMessage.js +5 -1
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +96 -0
- 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 +4 -6
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +152 -27
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +55 -19
- package/dist/docx/runParser.js +394 -306
- 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 +241 -238
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +66 -3
- package/dist/docx/selectiveXmlPatch.js +276 -133
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +12 -10
- package/dist/docx/serializer/commentSerializer.js +5 -7
- package/dist/docx/serializer/documentSerializer.js +11 -11
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +10 -9
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +11 -8
- 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 +156 -236
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +134 -75
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +283 -105
- 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 +20 -16
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- 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 +13 -8
- 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 +11 -2
- package/dist/docx/tableParser.js +665 -220
- package/dist/docx/textBoxParser.d.ts +28 -3
- package/dist/docx/textBoxParser.js +69 -9
- 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/unzip.js +5 -4
- package/dist/docx/vmlImageParser.d.ts +30 -5
- package/dist/docx/vmlImageParser.js +91 -32
- 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/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +23 -1
- package/dist/docx/xmlParser.js +31 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +12 -1
- 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/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
- 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 +267 -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/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- 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 +69 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +10 -3
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +10 -4
- package/dist/layout-painter/renderParagraph.d.ts +14 -1
- package/dist/layout-painter/renderParagraph.js +34 -28
- 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/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +12 -4
- package/dist/markdown/renderBlock.js +3 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +34 -6
- package/dist/markdown/renderTable.js +24 -6
- package/dist/markdown/trailers.js +4 -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/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +34 -5
- package/dist/prosemirror/attrs/index.js +639 -48
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- 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 +33 -20
- package/dist/prosemirror/commands/image.d.ts +10 -3
- package/dist/prosemirror/commands/image.js +46 -29
- package/dist/prosemirror/commands/pageBreak.js +1 -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/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
- package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
- 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.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +801 -411
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +14 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- 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 +65 -0
- package/dist/prosemirror/extensions/markRegistry.js +138 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
- 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.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
- 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.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -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/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -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 +7 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
- 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.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +92 -0
- 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/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- 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 +59 -0
- package/dist/prosemirror/replacedAnnotations.js +183 -0
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
- 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 +3 -3
- package/dist/prosemirror/schema/marks.d.ts +47 -4
- package/dist/prosemirror/schema/nodes.d.ts +309 -26
- package/dist/prosemirror/schema/nodes.js +16 -1
- 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 +4 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +31 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
- package/dist/prosemirror/zeroWidthAnchors.js +6 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- 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/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +27 -1
- 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/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +12 -20
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -0
- 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/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -50
- 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
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { isValidHexId } from "../utils/hexId.js";
|
|
2
|
+
import { attributeRemainder } from "./attributeRemainder.js";
|
|
2
3
|
import { parseBookmarkEnd as parseBookmarkEnd$1, parseBookmarkStart as parseBookmarkStart$1 } from "./bookmarkParser.js";
|
|
3
|
-
import {
|
|
4
|
+
import { CAPTURE, dispatchChildren, ownedElsewhere, transitionalNamespaceOf, withPreservedChildren } from "./containerChildren.js";
|
|
4
5
|
import { parseFieldType } from "./fieldParser.js";
|
|
5
|
-
import {
|
|
6
|
+
import { fieldStateOf, parseFieldState } from "./fieldState.js";
|
|
7
|
+
import { hyperlinkChildHandlers, parseHyperlink as parseHyperlink$1 } from "./hyperlinkParser.js";
|
|
8
|
+
import { isHyperlinkContent, isInlineSdtContent, isTrackedChangeWrapperChild } from "./inlineWrapperContent.js";
|
|
9
|
+
import { inlineWrapperOf } from "./inlineWrapperParser.js";
|
|
6
10
|
import { parseMarkupRangeMarker, parseMoveBookmarkMarker } from "./markupRangeMarker.js";
|
|
7
|
-
import { markerFormattingFromLevel, numberingLevelHasMarkerSlot } from "./numberingParser.js";
|
|
8
|
-
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
|
+
import { paraIdAttribute, textIdAttribute } from "./paraIdAttribute.js";
|
|
9
14
|
import { paraIdInRange } from "./paraIdRangeNormalization.js";
|
|
15
|
+
import { parseParagraphProperties } from "./paragraphProperties.js";
|
|
10
16
|
import { assignParagraphPropertySource } from "./paragraphPropertySource.js";
|
|
11
|
-
import {
|
|
17
|
+
import { preserveInlineChild, preserveRunChild, preservedInlineCapture } from "./preservedRunContent.js";
|
|
12
18
|
import { consolidateParagraphContent } from "./runConsolidator.js";
|
|
13
|
-
import { parseRun
|
|
14
|
-
import {
|
|
19
|
+
import { parseRun } from "./runParser.js";
|
|
20
|
+
import { runHoldsPayload } from "./runPayload.js";
|
|
21
|
+
import { captureSdtSiblingMarkers, parseSdtProperties } from "./sdtProperties.js";
|
|
15
22
|
import { parseSectionProperties } from "./sectionParser.js";
|
|
16
|
-
import {
|
|
23
|
+
import { hasAttributeAnySpelling } from "./strictNames.js";
|
|
24
|
+
import { scanRunForTextBoxDrawings } from "./textBoxParser.js";
|
|
17
25
|
import { parsePropertyChangeInfo, parseTrackedChangeInfo } from "./trackedChangeInfo.js";
|
|
18
26
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
19
|
-
import {
|
|
27
|
+
import { isVmlPictParsedByRunParser } from "./vmlImageParser.js";
|
|
28
|
+
import { WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, findChild, findChildByNamespaceUri, findChildrenByNamespaceUri, findWordprocessingChild, getAttribute, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespaceUri, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute, selectAlternateContentBranch } from "./xmlParser.js";
|
|
20
29
|
import { panic } from "better-result";
|
|
21
|
-
import {
|
|
30
|
+
import { PARAGRAPH_MARK_CHANGE_KINDS, REVIEW_CARRIERS } from "@stll/docx-core/model";
|
|
22
31
|
//#region src/docx/paragraphParser.ts
|
|
23
32
|
const FOLIO_REVIEW_HISTORY_NAMESPACES = /* @__PURE__ */ new Set(["urn:stella:folio:review-history:1"]);
|
|
24
33
|
/**
|
|
@@ -38,293 +47,6 @@ function extractMathText(el) {
|
|
|
38
47
|
return text;
|
|
39
48
|
}
|
|
40
49
|
/**
|
|
41
|
-
* Parse tab stops (w:tabs)
|
|
42
|
-
*/
|
|
43
|
-
function parseTabStops(tabs) {
|
|
44
|
-
if (!tabs) return;
|
|
45
|
-
const tabElements = findChildren(tabs, "w", "tab");
|
|
46
|
-
if (tabElements.length === 0) return;
|
|
47
|
-
const result = [];
|
|
48
|
-
for (const tab of tabElements) {
|
|
49
|
-
const pos = parseNumericAttribute(tab, "w", "pos");
|
|
50
|
-
const alignment = narrowEnum(getAttribute(tab, "w", "val"), TabStopAlignmentSchema);
|
|
51
|
-
if (pos !== void 0 && alignment) {
|
|
52
|
-
const tabStop = {
|
|
53
|
-
position: pos,
|
|
54
|
-
alignment
|
|
55
|
-
};
|
|
56
|
-
const leader = narrowEnum(getAttribute(tab, "w", "leader"), TabLeaderSchema);
|
|
57
|
-
if (leader && leader !== "none") tabStop.leader = leader;
|
|
58
|
-
result.push(tabStop);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return result.length > 0 ? result : void 0;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Parse frame properties (w:framePr)
|
|
65
|
-
*/
|
|
66
|
-
function parseFrameProperties(framePr) {
|
|
67
|
-
if (!framePr) return;
|
|
68
|
-
const frame = {};
|
|
69
|
-
const dropCap = getAttribute(framePr, "w", "dropCap");
|
|
70
|
-
if (dropCap === "none" || dropCap === "drop" || dropCap === "margin") frame.dropCap = dropCap;
|
|
71
|
-
const lines = parseNumericAttribute(framePr, "w", "lines");
|
|
72
|
-
if (lines !== void 0) frame.lines = lines;
|
|
73
|
-
const w = parseNumericAttribute(framePr, "w", "w");
|
|
74
|
-
if (w !== void 0) frame.width = w;
|
|
75
|
-
const h = parseNumericAttribute(framePr, "w", "h");
|
|
76
|
-
if (h !== void 0) frame.height = h;
|
|
77
|
-
const hSpace = parseNumericAttribute(framePr, "w", "hSpace");
|
|
78
|
-
if (hSpace !== void 0) frame.hSpace = hSpace;
|
|
79
|
-
const vSpace = parseNumericAttribute(framePr, "w", "vSpace");
|
|
80
|
-
if (vSpace !== void 0) frame.vSpace = vSpace;
|
|
81
|
-
const hAnchor = getAttribute(framePr, "w", "hAnchor");
|
|
82
|
-
if (hAnchor === "text" || hAnchor === "margin" || hAnchor === "page") frame.hAnchor = hAnchor;
|
|
83
|
-
const vAnchor = getAttribute(framePr, "w", "vAnchor");
|
|
84
|
-
if (vAnchor === "text" || vAnchor === "margin" || vAnchor === "page") frame.vAnchor = vAnchor;
|
|
85
|
-
const x = parseNumericAttribute(framePr, "w", "x");
|
|
86
|
-
if (x !== void 0) frame.x = x;
|
|
87
|
-
const y = parseNumericAttribute(framePr, "w", "y");
|
|
88
|
-
if (y !== void 0) frame.y = y;
|
|
89
|
-
const xAlign = narrowEnum(getAttribute(framePr, "w", "xAlign"), FrameXAlignSchema);
|
|
90
|
-
if (xAlign) frame.xAlign = xAlign;
|
|
91
|
-
const yAlign = narrowEnum(getAttribute(framePr, "w", "yAlign"), FrameYAlignSchema);
|
|
92
|
-
if (yAlign) frame.yAlign = yAlign;
|
|
93
|
-
const wrap = narrowEnum(getAttribute(framePr, "w", "wrap"), FrameWrapSchema);
|
|
94
|
-
if (wrap) frame.wrap = wrap;
|
|
95
|
-
return Object.keys(frame).length > 0 ? frame : void 0;
|
|
96
|
-
}
|
|
97
|
-
function collectFirstParagraphPropertyChildren(pPr) {
|
|
98
|
-
const children = {};
|
|
99
|
-
for (const child of pPr.elements ?? []) {
|
|
100
|
-
if (child.type !== "element") continue;
|
|
101
|
-
switch (getLocalName(child.name)) {
|
|
102
|
-
case "bidi":
|
|
103
|
-
children.bidi ??= child;
|
|
104
|
-
break;
|
|
105
|
-
case "contextualSpacing":
|
|
106
|
-
children.contextualSpacing ??= child;
|
|
107
|
-
break;
|
|
108
|
-
case "framePr":
|
|
109
|
-
children.framePr ??= child;
|
|
110
|
-
break;
|
|
111
|
-
case "ind":
|
|
112
|
-
children.ind ??= child;
|
|
113
|
-
break;
|
|
114
|
-
case "jc":
|
|
115
|
-
children.jc ??= child;
|
|
116
|
-
break;
|
|
117
|
-
case "keepLines":
|
|
118
|
-
children.keepLines ??= child;
|
|
119
|
-
break;
|
|
120
|
-
case "keepNext":
|
|
121
|
-
children.keepNext ??= child;
|
|
122
|
-
break;
|
|
123
|
-
case "kinsoku":
|
|
124
|
-
children.kinsoku ??= child;
|
|
125
|
-
break;
|
|
126
|
-
case "numPr":
|
|
127
|
-
children.numPr ??= child;
|
|
128
|
-
break;
|
|
129
|
-
case "outlineLvl":
|
|
130
|
-
children.outlineLvl ??= child;
|
|
131
|
-
break;
|
|
132
|
-
case "overflowPunct":
|
|
133
|
-
children.overflowPunct ??= child;
|
|
134
|
-
break;
|
|
135
|
-
case "pageBreakBefore":
|
|
136
|
-
children.pageBreakBefore ??= child;
|
|
137
|
-
break;
|
|
138
|
-
case "pBdr":
|
|
139
|
-
children.pBdr ??= child;
|
|
140
|
-
break;
|
|
141
|
-
case "pStyle":
|
|
142
|
-
children.pStyle ??= child;
|
|
143
|
-
break;
|
|
144
|
-
case "rPr":
|
|
145
|
-
children.rPr ??= child;
|
|
146
|
-
break;
|
|
147
|
-
case "shd":
|
|
148
|
-
children.shd ??= child;
|
|
149
|
-
break;
|
|
150
|
-
case "snapToGrid":
|
|
151
|
-
children.snapToGrid ??= child;
|
|
152
|
-
break;
|
|
153
|
-
case "spacing":
|
|
154
|
-
children.spacing ??= child;
|
|
155
|
-
break;
|
|
156
|
-
case "suppressAutoHyphens":
|
|
157
|
-
children.suppressAutoHyphens ??= child;
|
|
158
|
-
break;
|
|
159
|
-
case "suppressLineNumbers":
|
|
160
|
-
children.suppressLineNumbers ??= child;
|
|
161
|
-
break;
|
|
162
|
-
case "tabs":
|
|
163
|
-
children.tabs ??= child;
|
|
164
|
-
break;
|
|
165
|
-
case "widowControl":
|
|
166
|
-
children.widowControl ??= child;
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return children;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Parse paragraph formatting properties (w:pPr)
|
|
174
|
-
*
|
|
175
|
-
* Handles ALL pPr properties:
|
|
176
|
-
* - w:jc (alignment: left, center, right, both/justify)
|
|
177
|
-
* - w:spacing (before, after, line, lineRule)
|
|
178
|
-
* - w:ind (left, right, firstLine, hanging)
|
|
179
|
-
* - w:pBdr (paragraph borders: top, bottom, left, right, between)
|
|
180
|
-
* - w:shd (paragraph shading/background)
|
|
181
|
-
* - w:tabs (tab stops with positions and types)
|
|
182
|
-
* - w:keepNext, w:keepLines, w:widowControl, w:pageBreakBefore
|
|
183
|
-
* - w:bidi (right-to-left)
|
|
184
|
-
* - w:numPr (list info)
|
|
185
|
-
* - w:pStyle (style reference)
|
|
186
|
-
* - w:outlineLvl (outline level)
|
|
187
|
-
* - w:framePr (frame properties)
|
|
188
|
-
* - w:rPr (default run properties)
|
|
189
|
-
*/
|
|
190
|
-
function parseParagraphProperties(pPr, theme, styles) {
|
|
191
|
-
if (!pPr) return;
|
|
192
|
-
const formatting = {};
|
|
193
|
-
const propertyChildren = collectFirstParagraphPropertyChildren(pPr);
|
|
194
|
-
const kinsoku = propertyChildren.kinsoku;
|
|
195
|
-
if (kinsoku) formatting.kinsoku = parseBooleanElement(kinsoku);
|
|
196
|
-
const overflowPunct = propertyChildren.overflowPunct;
|
|
197
|
-
if (overflowPunct) formatting.overflowPunctuation = parseBooleanElement(overflowPunct);
|
|
198
|
-
const jc = propertyChildren.jc;
|
|
199
|
-
if (jc) {
|
|
200
|
-
const val = narrowEnum(getAttribute(jc, "w", "val"), ParagraphAlignmentSchema);
|
|
201
|
-
if (val) formatting.alignment = val;
|
|
202
|
-
}
|
|
203
|
-
const bidi = propertyChildren.bidi;
|
|
204
|
-
if (bidi) formatting.bidi = parseBooleanElement(bidi);
|
|
205
|
-
const snapToGrid = propertyChildren.snapToGrid;
|
|
206
|
-
if (snapToGrid) formatting.snapToGrid = parseBooleanElement(snapToGrid);
|
|
207
|
-
const spacing = propertyChildren.spacing;
|
|
208
|
-
if (spacing) {
|
|
209
|
-
const before = parseNumericAttribute(spacing, "w", "before");
|
|
210
|
-
if (before !== void 0) formatting.spaceBefore = before;
|
|
211
|
-
const after = parseNumericAttribute(spacing, "w", "after");
|
|
212
|
-
if (after !== void 0) formatting.spaceAfter = after;
|
|
213
|
-
const line = parseNumericAttribute(spacing, "w", "line");
|
|
214
|
-
if (line !== void 0) formatting.lineSpacing = line;
|
|
215
|
-
const spacingExplicit = {};
|
|
216
|
-
if (before !== void 0) spacingExplicit.before = true;
|
|
217
|
-
if (after !== void 0) spacingExplicit.after = true;
|
|
218
|
-
if (spacingExplicit.before || spacingExplicit.after) formatting.spacingExplicit = spacingExplicit;
|
|
219
|
-
const lineRule = narrowEnum(getAttribute(spacing, "w", "lineRule"), LineSpacingRuleSchema);
|
|
220
|
-
if (lineRule) formatting.lineSpacingRule = lineRule;
|
|
221
|
-
const beforeAutospacing = parseOnOffAttribute(spacing, "w", "beforeAutospacing");
|
|
222
|
-
if (beforeAutospacing !== void 0) formatting.beforeAutospacing = beforeAutospacing;
|
|
223
|
-
const afterAutospacing = parseOnOffAttribute(spacing, "w", "afterAutospacing");
|
|
224
|
-
if (afterAutospacing !== void 0) formatting.afterAutospacing = afterAutospacing;
|
|
225
|
-
}
|
|
226
|
-
const ind = propertyChildren.ind;
|
|
227
|
-
if (ind) {
|
|
228
|
-
const left = parseNumericAttribute(ind, "w", "left");
|
|
229
|
-
if (left !== void 0) formatting.indentLeft = left;
|
|
230
|
-
const right = parseNumericAttribute(ind, "w", "right");
|
|
231
|
-
if (right !== void 0) formatting.indentRight = right;
|
|
232
|
-
const firstLine = parseNumericAttribute(ind, "w", "firstLine");
|
|
233
|
-
if (firstLine !== void 0) formatting.indentFirstLine = firstLine;
|
|
234
|
-
const hanging = parseNumericAttribute(ind, "w", "hanging");
|
|
235
|
-
if (hanging !== void 0) {
|
|
236
|
-
formatting.indentFirstLine = -hanging;
|
|
237
|
-
formatting.hangingIndent = true;
|
|
238
|
-
}
|
|
239
|
-
const start = parseNumericAttribute(ind, "w", "start");
|
|
240
|
-
if (start !== void 0 && formatting.indentLeft === void 0) formatting.indentLeft = start;
|
|
241
|
-
const end = parseNumericAttribute(ind, "w", "end");
|
|
242
|
-
if (end !== void 0 && formatting.indentRight === void 0) formatting.indentRight = end;
|
|
243
|
-
}
|
|
244
|
-
const pBdr = propertyChildren.pBdr;
|
|
245
|
-
if (pBdr) {
|
|
246
|
-
const borders = {};
|
|
247
|
-
const top = parseBorderSpec(findChild(pBdr, "w", "top"));
|
|
248
|
-
if (top) borders.top = top;
|
|
249
|
-
const bottom = parseBorderSpec(findChild(pBdr, "w", "bottom"));
|
|
250
|
-
if (bottom) borders.bottom = bottom;
|
|
251
|
-
const left = parseBorderSpec(findChild(pBdr, "w", "left"));
|
|
252
|
-
if (left) borders.left = left;
|
|
253
|
-
const right = parseBorderSpec(findChild(pBdr, "w", "right"));
|
|
254
|
-
if (right) borders.right = right;
|
|
255
|
-
const between = parseBorderSpec(findChild(pBdr, "w", "between"));
|
|
256
|
-
if (between) borders.between = between;
|
|
257
|
-
const bar = parseBorderSpec(findChild(pBdr, "w", "bar"));
|
|
258
|
-
if (bar) borders.bar = bar;
|
|
259
|
-
if (Object.keys(borders).length > 0) formatting.borders = borders;
|
|
260
|
-
}
|
|
261
|
-
const shd = propertyChildren.shd;
|
|
262
|
-
if (shd) {
|
|
263
|
-
const shadingResult = parseShading(shd);
|
|
264
|
-
if (shadingResult !== void 0) formatting.shading = shadingResult;
|
|
265
|
-
}
|
|
266
|
-
const tabs = propertyChildren.tabs;
|
|
267
|
-
if (tabs) {
|
|
268
|
-
const tabsResult = parseTabStops(tabs);
|
|
269
|
-
if (tabsResult !== void 0) formatting.tabs = tabsResult;
|
|
270
|
-
}
|
|
271
|
-
const keepNext = propertyChildren.keepNext;
|
|
272
|
-
if (keepNext) formatting.keepNext = parseBooleanElement(keepNext);
|
|
273
|
-
const keepLines = propertyChildren.keepLines;
|
|
274
|
-
if (keepLines) formatting.keepLines = parseBooleanElement(keepLines);
|
|
275
|
-
const widowControl = propertyChildren.widowControl;
|
|
276
|
-
if (widowControl) formatting.widowControl = parseBooleanElement(widowControl);
|
|
277
|
-
const pageBreakBefore = propertyChildren.pageBreakBefore;
|
|
278
|
-
if (pageBreakBefore) formatting.pageBreakBefore = parseBooleanElement(pageBreakBefore);
|
|
279
|
-
const contextualSpacing = propertyChildren.contextualSpacing;
|
|
280
|
-
if (contextualSpacing) formatting.contextualSpacing = parseBooleanElement(contextualSpacing);
|
|
281
|
-
const numPr = propertyChildren.numPr;
|
|
282
|
-
if (numPr) {
|
|
283
|
-
const numIdEl = findChild(numPr, "w", "numId");
|
|
284
|
-
const ilvlEl = findChild(numPr, "w", "ilvl");
|
|
285
|
-
if (numIdEl || ilvlEl) {
|
|
286
|
-
formatting.numPr = {};
|
|
287
|
-
if (numIdEl) {
|
|
288
|
-
const val = parseNumericAttribute(numIdEl, "w", "val");
|
|
289
|
-
if (val !== void 0) formatting.numPr.numId = val;
|
|
290
|
-
}
|
|
291
|
-
if (ilvlEl) {
|
|
292
|
-
const val = parseNumberingLevelAttribute(ilvlEl);
|
|
293
|
-
if (val !== void 0) formatting.numPr.ilvl = val;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
const numberingChange = findChild(numPr, "w", "numberingChange");
|
|
297
|
-
if (numberingChange) formatting.numberingChangeXml = captureVerbatimXml(numberingChange);
|
|
298
|
-
}
|
|
299
|
-
const outlineLvl = propertyChildren.outlineLvl;
|
|
300
|
-
if (outlineLvl) {
|
|
301
|
-
const val = parseNumericAttribute(outlineLvl, "w", "val");
|
|
302
|
-
if (val !== void 0) formatting.outlineLevel = val;
|
|
303
|
-
}
|
|
304
|
-
const pStyle = propertyChildren.pStyle;
|
|
305
|
-
if (pStyle) {
|
|
306
|
-
const val = getAttribute(pStyle, "w", "val");
|
|
307
|
-
if (val) formatting.styleId = val;
|
|
308
|
-
}
|
|
309
|
-
const framePr = propertyChildren.framePr;
|
|
310
|
-
if (framePr) {
|
|
311
|
-
const frameResult = parseFrameProperties(framePr);
|
|
312
|
-
if (frameResult !== void 0) formatting.frame = frameResult;
|
|
313
|
-
}
|
|
314
|
-
const suppressLineNumbers = propertyChildren.suppressLineNumbers;
|
|
315
|
-
if (suppressLineNumbers) formatting.suppressLineNumbers = parseBooleanElement(suppressLineNumbers);
|
|
316
|
-
const suppressAutoHyphens = propertyChildren.suppressAutoHyphens;
|
|
317
|
-
if (suppressAutoHyphens) formatting.suppressAutoHyphens = parseBooleanElement(suppressAutoHyphens);
|
|
318
|
-
const rPr = propertyChildren.rPr;
|
|
319
|
-
if (rPr) {
|
|
320
|
-
const runPropsResult = parseRunProperties(rPr, theme, styles);
|
|
321
|
-
if (runPropsResult !== void 0) formatting.runProperties = runPropsResult;
|
|
322
|
-
const specVanish = findChild(rPr, "w", "specVanish");
|
|
323
|
-
if (specVanish && parseBooleanElement(specVanish)) formatting.runInWithNext = true;
|
|
324
|
-
}
|
|
325
|
-
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
50
|
* Capture the authored paragraph properties separately from structural and
|
|
329
51
|
* revision children, which have their own model fields and lifecycles.
|
|
330
52
|
*/
|
|
@@ -448,10 +170,10 @@ function normalizeDeletionContentElement(node) {
|
|
|
448
170
|
...node.elements ? { elements: node.elements.map(normalizeDeletionContentElement) } : {}
|
|
449
171
|
});
|
|
450
172
|
}
|
|
451
|
-
function parseParagraphPropertyChanges(pPr, theme,
|
|
173
|
+
function parseParagraphPropertyChanges(pPr, theme, currentFormatting) {
|
|
452
174
|
if (!pPr) return;
|
|
453
175
|
const changes = findChildrenByNamespaceUri(pPr, WORDPROCESSINGML_NAMESPACE_URIS, "pPrChange").map((changeElement) => {
|
|
454
|
-
const previousFormatting = parseParagraphProperties(findChildByNamespaceUri(changeElement, WORDPROCESSINGML_NAMESPACE_URIS, "pPr"), theme
|
|
176
|
+
const previousFormatting = parseParagraphProperties(findChildByNamespaceUri(changeElement, WORDPROCESSINGML_NAMESPACE_URIS, "pPr"), theme);
|
|
455
177
|
const change = {
|
|
456
178
|
type: "paragraphPropertyChange",
|
|
457
179
|
info: parsePropertyChangeInfo(changeElement)
|
|
@@ -459,7 +181,7 @@ function parseParagraphPropertyChanges(pPr, theme, styles, currentFormatting) {
|
|
|
459
181
|
if (previousFormatting !== void 0) change.previousFormatting = previousFormatting;
|
|
460
182
|
if (currentFormatting !== void 0) change.currentFormatting = currentFormatting;
|
|
461
183
|
return change;
|
|
462
|
-
})
|
|
184
|
+
});
|
|
463
185
|
return changes.length > 0 ? changes : void 0;
|
|
464
186
|
}
|
|
465
187
|
/**
|
|
@@ -480,12 +202,6 @@ function parseParagraphMarkChange(pPr) {
|
|
|
480
202
|
};
|
|
481
203
|
}
|
|
482
204
|
}
|
|
483
|
-
function isTrackedChangeWrapperChild(content) {
|
|
484
|
-
return content.type === "run" || content.type === "hyperlink" || content.type === "bookmarkStart" || content.type === "bookmarkEnd" || content.type === "simpleField" || content.type === "complexField" || content.type === "mathEquation" || content.type === "insertion" || content.type === "deletion" || content.type === "moveFrom" || content.type === "moveTo";
|
|
485
|
-
}
|
|
486
|
-
function isInlineSdtContent(content) {
|
|
487
|
-
return content.type === "run" || content.type === "hyperlink" || content.type === "simpleField" || content.type === "complexField" || content.type === "inlineSdt" || content.type === "insertion" || content.type === "deletion" || content.type === "moveFrom" || content.type === "moveTo" || content.type === "mathEquation";
|
|
488
|
-
}
|
|
489
205
|
function pushTrackedChangeWrapper({ contents, type, info, content, preserveEmpty = false }) {
|
|
490
206
|
if (content.length === 0 && !preserveEmpty) return;
|
|
491
207
|
if (type === "insertion") {
|
|
@@ -590,38 +306,42 @@ function pushInlineSdtSegments({ contents, properties, parsedContent }) {
|
|
|
590
306
|
function parseHyperlink(node, rels, styles, theme, media, rootXmlns = {}) {
|
|
591
307
|
return parseHyperlink$1(node, rels, styles, theme, media, rootXmlns);
|
|
592
308
|
}
|
|
593
|
-
/**
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
309
|
+
/**
|
|
310
|
+
* The four `CT_RunTrackChange` wrappers a `w:hyperlink` may hold.
|
|
311
|
+
*
|
|
312
|
+
* What to *do* with each is the dispatcher's handler map; this set only
|
|
313
|
+
* answers whether the link needs segmenting at all, which decides between one
|
|
314
|
+
* link and a sequence of links and revisions.
|
|
315
|
+
*/
|
|
316
|
+
const HYPERLINK_REVISION_WRAPPERS = /* @__PURE__ */ new Set([
|
|
317
|
+
"del",
|
|
318
|
+
"ins",
|
|
319
|
+
"moveFrom",
|
|
320
|
+
"moveTo"
|
|
321
|
+
]);
|
|
603
322
|
const OMML_NAMESPACE = "http://schemas.openxmlformats.org/officeDocument/2006/math";
|
|
604
323
|
/**
|
|
605
|
-
*
|
|
324
|
+
* An OMML element as an equation, or nothing when the child is not one.
|
|
606
325
|
*
|
|
607
|
-
* `m:
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
326
|
+
* `m:oMathPara` is the display form and `m:oMath` the inline one. The rest of
|
|
327
|
+
* `m:EG_OMathMathElements` — `m:f`, `m:acc`, `m:rad` and their siblings — the
|
|
328
|
+
* schema admits wherever `m:oMath` is admitted, so `<w:ins><m:f/></w:ins>` is
|
|
329
|
+
* a tracked insertion of a fraction with no `m:oMath` around it. None of them
|
|
330
|
+
* carries structure the editable model holds, so all travel as the markup
|
|
331
|
+
* they arrived as.
|
|
612
332
|
*/
|
|
613
333
|
const mathContentOf = (child) => {
|
|
614
|
-
|
|
334
|
+
const namespace = getNamespaceUri(child);
|
|
335
|
+
if (namespace === void 0 || transitionalNamespaceOf(namespace) !== OMML_NAMESPACE) return;
|
|
615
336
|
const equation = {
|
|
616
337
|
type: "mathEquation",
|
|
617
|
-
display: "inline",
|
|
338
|
+
display: getLocalName(child.name) === "oMathPara" ? "block" : "inline",
|
|
618
339
|
ommlXml: captureVerbatimXml(child)
|
|
619
340
|
};
|
|
620
341
|
const plainText = extractMathText(child);
|
|
621
342
|
if (plainText) equation.plainText = plainText;
|
|
622
343
|
return equation;
|
|
623
344
|
};
|
|
624
|
-
const isHyperlinkChildContent = (content) => content.type === "run" || content.type === "bookmarkStart" || content.type === "bookmarkEnd";
|
|
625
345
|
/**
|
|
626
346
|
* A `w:hyperlink` as paragraph content, with any revision wrapper it holds
|
|
627
347
|
* hoisted around it.
|
|
@@ -632,31 +352,16 @@ const isHyperlinkChildContent = (content) => content.type === "run" || content.t
|
|
|
632
352
|
* inverse of what the serializer writes, so a package survives the round trip.
|
|
633
353
|
*/
|
|
634
354
|
function parseHyperlinkParagraphContents(node, rels, styles, theme, media, rootXmlns) {
|
|
635
|
-
|
|
636
|
-
if (!children.some((child) => hyperlinkRevisionWrapperType(child) !== void 0)) return [parseHyperlink(node, rels, styles, theme, media, rootXmlns)];
|
|
355
|
+
if (!getChildElements(node).some((child) => HYPERLINK_REVISION_WRAPPERS.has(getLocalName(child.name)))) return [parseHyperlink(node, rels, styles, theme, media, rootXmlns)];
|
|
637
356
|
const inScopeXmlns = mergeXmlnsDeclarations(rootXmlns, node);
|
|
638
357
|
const shell = parseHyperlink(node, rels, styles, theme, media, rootXmlns);
|
|
639
358
|
const linkOver = (linkChildren) => ({
|
|
640
359
|
...shell,
|
|
641
360
|
children: [...linkChildren]
|
|
642
361
|
});
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
if (plain.length > 0) {
|
|
647
|
-
contents.push(linkOver(plain));
|
|
648
|
-
plain = [];
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
for (const child of children) {
|
|
652
|
-
const wrapperType = hyperlinkRevisionWrapperType(child);
|
|
653
|
-
if (wrapperType === void 0) {
|
|
654
|
-
const parsed = parseHyperlinkChild(child, styles, theme, rels, media, inScopeXmlns);
|
|
655
|
-
if (parsed) plain.push(parsed);
|
|
656
|
-
continue;
|
|
657
|
-
}
|
|
658
|
-
flushPlain();
|
|
659
|
-
const wrapped = parseParagraphContents(child, styles, theme, null, rels, media, wrapperType === "deletion" || wrapperType === "moveFrom" ? "deletion" : "default", inScopeXmlns);
|
|
362
|
+
const items = [];
|
|
363
|
+
const hoistRevision = (wrapper) => (child) => {
|
|
364
|
+
const wrapped = parseParagraphContents(child, styles, theme, null, rels, media, wrapper === "deletion" || wrapper === "moveFrom" ? "deletion" : "default", inScopeXmlns);
|
|
660
365
|
const content = [];
|
|
661
366
|
let linked = [];
|
|
662
367
|
const flushLinked = () => {
|
|
@@ -666,7 +371,7 @@ function parseHyperlinkParagraphContents(node, rels, styles, theme, media, rootX
|
|
|
666
371
|
}
|
|
667
372
|
};
|
|
668
373
|
for (const item of wrapped) {
|
|
669
|
-
if (
|
|
374
|
+
if (isHyperlinkContent(item)) {
|
|
670
375
|
linked.push(item);
|
|
671
376
|
continue;
|
|
672
377
|
}
|
|
@@ -674,11 +379,53 @@ function parseHyperlinkParagraphContents(node, rels, styles, theme, media, rootX
|
|
|
674
379
|
if (isTrackedChangeWrapperChild(item)) content.push(item);
|
|
675
380
|
}
|
|
676
381
|
flushLinked();
|
|
382
|
+
items.push({
|
|
383
|
+
type: "hoistedRevision",
|
|
384
|
+
wrapper,
|
|
385
|
+
info: parseTrackedChangeInfo(child),
|
|
386
|
+
content
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
const preserved = dispatchChildren({
|
|
390
|
+
element: node,
|
|
391
|
+
container: "w:hyperlink",
|
|
392
|
+
capturePosition: () => items.length,
|
|
393
|
+
handlers: {
|
|
394
|
+
...hyperlinkChildHandlers({
|
|
395
|
+
push: (child) => {
|
|
396
|
+
items.push(child);
|
|
397
|
+
},
|
|
398
|
+
styles,
|
|
399
|
+
theme,
|
|
400
|
+
rels,
|
|
401
|
+
media,
|
|
402
|
+
inScopeXmlns
|
|
403
|
+
}),
|
|
404
|
+
ins: hoistRevision("insertion"),
|
|
405
|
+
del: hoistRevision("deletion"),
|
|
406
|
+
moveFrom: hoistRevision("moveFrom"),
|
|
407
|
+
moveTo: hoistRevision("moveTo")
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
const contents = [];
|
|
411
|
+
let plain = [];
|
|
412
|
+
const flushPlain = () => {
|
|
413
|
+
if (plain.length > 0) {
|
|
414
|
+
contents.push(linkOver(plain));
|
|
415
|
+
plain = [];
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
for (const item of withPreservedChildren(items, preserved, preservedInlineCapture)) {
|
|
419
|
+
if (item.type !== "hoistedRevision") {
|
|
420
|
+
plain.push(item);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
flushPlain();
|
|
677
424
|
pushTrackedChangeWrapper({
|
|
678
425
|
contents,
|
|
679
|
-
type:
|
|
680
|
-
info:
|
|
681
|
-
content,
|
|
426
|
+
type: item.wrapper,
|
|
427
|
+
info: item.info,
|
|
428
|
+
content: item.content,
|
|
682
429
|
preserveEmpty: true
|
|
683
430
|
});
|
|
684
431
|
}
|
|
@@ -708,22 +455,154 @@ function parseSimpleField(node, styles, theme, rels, media, rootXmlns = {}) {
|
|
|
708
455
|
type: "simpleField",
|
|
709
456
|
instruction,
|
|
710
457
|
fieldType: parseFieldType(instruction),
|
|
711
|
-
content: []
|
|
458
|
+
content: [],
|
|
459
|
+
...parseFieldState(node)
|
|
712
460
|
};
|
|
713
|
-
if (parseOnOffAttribute(node, "w", "fldLock") === true) field.fldLock = true;
|
|
714
|
-
if (parseOnOffAttribute(node, "w", "dirty") === true) field.dirty = true;
|
|
715
461
|
const inScopeXmlns = mergeXmlnsDeclarations(rootXmlns, node);
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
462
|
+
const content = [];
|
|
463
|
+
field.content = withPreservedChildren(content, dispatchChildren({
|
|
464
|
+
element: node,
|
|
465
|
+
container: "w:fldSimple",
|
|
466
|
+
capturePosition: () => content.length,
|
|
467
|
+
handlers: simpleFieldChildHandlers({
|
|
468
|
+
push: (child) => {
|
|
469
|
+
content.push(child);
|
|
470
|
+
},
|
|
471
|
+
styles,
|
|
472
|
+
theme,
|
|
473
|
+
rels,
|
|
474
|
+
media,
|
|
475
|
+
inScopeXmlns
|
|
476
|
+
})
|
|
477
|
+
}), preservedInlineCapture);
|
|
722
478
|
return field;
|
|
723
479
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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
|
+
};
|
|
564
|
+
const hasRunPayload = ({ run, runElement, rels, media }) => {
|
|
565
|
+
if (runHoldsPayload(run)) return true;
|
|
566
|
+
const { textBoxDrawings, vmlTextBoxes } = scanRunForTextBoxDrawings({
|
|
567
|
+
xmlRun: runElement,
|
|
568
|
+
claimedByRunParser: (pictElement) => isVmlPictParsedByRunParser(pictElement, rels, media)
|
|
569
|
+
});
|
|
570
|
+
return textBoxDrawings.length > 0 || vmlTextBoxes.length > 0;
|
|
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
|
+
};
|
|
727
606
|
const LEGACY_FORM_CHECKBOX_GLYPHS = {
|
|
728
607
|
checked: "☒",
|
|
729
608
|
unchecked: "☐"
|
|
@@ -766,33 +645,64 @@ function isLegacyFormCheckboxInstruction(instruction) {
|
|
|
766
645
|
return instruction.trim().split(/\s+/u).at(0)?.toUpperCase() === LEGACY_FORM_CHECKBOX_INSTRUCTION;
|
|
767
646
|
}
|
|
768
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
|
+
/**
|
|
769
670
|
* Parse all content within a paragraph
|
|
770
671
|
*
|
|
771
672
|
* Returns the parsed content and any complex fields that span multiple runs
|
|
772
673
|
*/
|
|
773
674
|
function parseParagraphContents(paraElement, styles, theme, _numbering, rels, media, trackedContext = "default", rootXmlns = {}) {
|
|
774
675
|
const contents = [];
|
|
775
|
-
const children = getChildElements(paraElement);
|
|
776
676
|
const inScopeXmlns = mergeXmlnsDeclarations(rootXmlns, paraElement);
|
|
777
677
|
let inComplexField = false;
|
|
778
678
|
let complexFieldInstr = "";
|
|
779
679
|
let complexFieldCodeRuns = [];
|
|
780
680
|
let complexFieldResultRuns = [];
|
|
681
|
+
let complexFieldOpenRuns = [];
|
|
781
682
|
let afterSeparator = false;
|
|
782
|
-
let
|
|
783
|
-
let complexFieldDirty = false;
|
|
683
|
+
let complexFieldState = {};
|
|
784
684
|
let complexFieldFallbackDisplay;
|
|
785
685
|
let complexFieldFormatting;
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
686
|
+
const parseInlineWrapper = (child, element) => inlineWrapperOf(element, child, parseParagraphContents(child, styles, theme, null, rels, media, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child)));
|
|
687
|
+
const preserved = dispatchChildren({
|
|
688
|
+
element: paraElement,
|
|
689
|
+
container: "run-level-content",
|
|
690
|
+
capturePosition: () => contents.length,
|
|
691
|
+
undeclared: { AlternateContent: (child) => {
|
|
692
|
+
const selectedBranch = selectAlternateContentBranch(child);
|
|
693
|
+
if (selectedBranch) contents.push(...parseParagraphContents(selectedBranch, styles, theme, null, rels, media, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child)));
|
|
694
|
+
} },
|
|
695
|
+
undeclaredNamespaces: { [OMML_NAMESPACE]: (child) => {
|
|
696
|
+
const equation = mathContentOf(child);
|
|
697
|
+
if (equation !== void 0) contents.push(equation);
|
|
698
|
+
} },
|
|
699
|
+
handlers: {
|
|
700
|
+
r: (child) => {
|
|
790
701
|
const runElement = trackedContext === "deletion" ? normalizeDeletionContentElement(child) : child;
|
|
791
702
|
const run = parseRun(runElement, styles, theme, rels, media, inScopeXmlns);
|
|
792
703
|
const commentReferenceId = getCommentReferenceId(runElement);
|
|
793
704
|
let hasFieldBegin = false;
|
|
794
|
-
let
|
|
795
|
-
let beginDirty = false;
|
|
705
|
+
let beginFieldState = {};
|
|
796
706
|
const beginFallbackDisplay = getLegacyFormCheckboxDisplay(runElement);
|
|
797
707
|
let hasFieldSeparate = false;
|
|
798
708
|
let hasFieldEnd = false;
|
|
@@ -800,8 +710,7 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
800
710
|
let instrText = "";
|
|
801
711
|
for (const content of run.content) if (content.type === "fieldChar") if (content.charType === "begin") {
|
|
802
712
|
hasFieldBegin = true;
|
|
803
|
-
|
|
804
|
-
beginDirty = content.dirty === true;
|
|
713
|
+
beginFieldState = fieldStateOf(content);
|
|
805
714
|
} else if (content.charType === "separate") hasFieldSeparate = true;
|
|
806
715
|
else {
|
|
807
716
|
hasFieldEnd = true;
|
|
@@ -818,12 +727,13 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
818
727
|
complexFieldInstr = "";
|
|
819
728
|
complexFieldCodeRuns = [];
|
|
820
729
|
complexFieldResultRuns = [];
|
|
821
|
-
|
|
822
|
-
|
|
730
|
+
complexFieldOpenRuns = [];
|
|
731
|
+
complexFieldState = beginFieldState;
|
|
823
732
|
complexFieldFallbackDisplay = beginFallbackDisplay;
|
|
824
733
|
complexFieldFormatting = run.formatting;
|
|
825
734
|
}
|
|
826
735
|
if (inComplexField) {
|
|
736
|
+
complexFieldOpenRuns.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
827
737
|
if (instrText) complexFieldInstr += instrText;
|
|
828
738
|
if ((!complexFieldFormatting || Object.keys(complexFieldFormatting).length === 0) && run.formatting && Object.keys(run.formatting).length > 0) complexFieldFormatting = run.formatting;
|
|
829
739
|
let inFieldCodeRegion = !hasFieldBegin && !afterSeparator;
|
|
@@ -858,10 +768,9 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
858
768
|
instruction: complexFieldInstr,
|
|
859
769
|
fieldType: parseFieldType(complexFieldInstr),
|
|
860
770
|
fieldCode: complexFieldCodeRuns,
|
|
861
|
-
fieldResult: resultRuns
|
|
771
|
+
fieldResult: resultRuns,
|
|
772
|
+
...complexFieldState
|
|
862
773
|
};
|
|
863
|
-
if (complexFieldLock) complexField.fldLock = true;
|
|
864
|
-
if (complexFieldDirty) complexField.dirty = true;
|
|
865
774
|
if (complexFieldFormatting) complexField.formatting = complexFieldFormatting;
|
|
866
775
|
contents.push(complexField);
|
|
867
776
|
if (commentReferenceId !== null) contents.push({
|
|
@@ -871,158 +780,154 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
|
|
|
871
780
|
inComplexField = false;
|
|
872
781
|
}
|
|
873
782
|
} else if (commentReferenceId !== null) {
|
|
874
|
-
if (run
|
|
783
|
+
if (runHoldsPayload(run)) contents.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
875
784
|
contents.push({
|
|
876
785
|
type: "commentReference",
|
|
877
786
|
id: commentReferenceId
|
|
878
787
|
});
|
|
879
|
-
} else if (
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
case "hyperlink":
|
|
788
|
+
} else if (hasRunPayload({
|
|
789
|
+
run,
|
|
790
|
+
runElement,
|
|
791
|
+
rels,
|
|
792
|
+
media
|
|
793
|
+
})) contents.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
794
|
+
},
|
|
795
|
+
hyperlink: (child) => {
|
|
888
796
|
contents.push(...parseHyperlinkParagraphContents(child, rels, styles, theme, media, inScopeXmlns));
|
|
889
|
-
|
|
890
|
-
|
|
797
|
+
},
|
|
798
|
+
bookmarkStart: (child) => {
|
|
891
799
|
contents.push(parseBookmarkStart(child));
|
|
892
|
-
|
|
893
|
-
|
|
800
|
+
},
|
|
801
|
+
bookmarkEnd: (child) => {
|
|
894
802
|
contents.push(parseBookmarkEnd(child));
|
|
895
|
-
|
|
896
|
-
|
|
803
|
+
},
|
|
804
|
+
fldSimple: (child) => {
|
|
897
805
|
contents.push(parseSimpleField(child, styles, theme, rels, media, inScopeXmlns));
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
806
|
+
},
|
|
807
|
+
pPr: PARAGRAPH_PROPERTIES_OWNER,
|
|
808
|
+
customXml: (child) => {
|
|
809
|
+
contents.push(parseInlineWrapper(child, "customXml"));
|
|
810
|
+
},
|
|
811
|
+
proofErr: CAPTURE,
|
|
812
|
+
permStart: CAPTURE,
|
|
813
|
+
permEnd: CAPTURE,
|
|
814
|
+
subDoc: CAPTURE,
|
|
815
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
816
|
+
customXmlDelRangeStart: CAPTURE,
|
|
817
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
818
|
+
customXmlInsRangeStart: CAPTURE,
|
|
819
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
820
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
821
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
822
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
823
|
+
smartTagPr: SMART_TAG_PROPERTIES_OWNER,
|
|
824
|
+
customXmlPr: CUSTOM_XML_PROPERTIES_OWNER,
|
|
825
|
+
sdt: (child) => {
|
|
826
|
+
const sdtPr = findWordprocessingChild(child, "sdtPr");
|
|
827
|
+
const sdtEndPr = findWordprocessingChild(child, "sdtEndPr");
|
|
828
|
+
const sdtContentEl = findWordprocessingChild(child, "sdtContent");
|
|
908
829
|
if (sdtContentEl) {
|
|
909
830
|
const sdtParsed = parseParagraphContents(sdtContentEl, styles, theme, null, rels, media, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child));
|
|
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;
|
|
910
835
|
pushInlineSdtSegments({
|
|
911
836
|
contents,
|
|
912
|
-
properties
|
|
837
|
+
properties,
|
|
913
838
|
parsedContent: sdtParsed
|
|
914
839
|
});
|
|
915
840
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
841
|
+
},
|
|
842
|
+
ins: (child) => {
|
|
843
|
+
const insInfo = parseTrackedChangeInfo(child);
|
|
844
|
+
const insContent = parseParagraphContents(child, styles, theme, null, rels, media, "default", inScopeXmlns);
|
|
919
845
|
pushTrackedChangeSegments({
|
|
920
846
|
contents,
|
|
921
847
|
type: "insertion",
|
|
922
|
-
info:
|
|
923
|
-
parsedContent:
|
|
848
|
+
info: insInfo,
|
|
849
|
+
parsedContent: insContent
|
|
924
850
|
});
|
|
925
|
-
|
|
926
|
-
|
|
851
|
+
},
|
|
852
|
+
del: (child) => {
|
|
853
|
+
const delInfo = parseTrackedChangeInfo(child);
|
|
854
|
+
const delContent = parseParagraphContents(child, styles, theme, null, rels, media, "deletion", inScopeXmlns);
|
|
927
855
|
pushTrackedChangeSegments({
|
|
928
856
|
contents,
|
|
929
857
|
type: "deletion",
|
|
930
|
-
info:
|
|
931
|
-
parsedContent:
|
|
858
|
+
info: delInfo,
|
|
859
|
+
parsedContent: delContent
|
|
932
860
|
});
|
|
933
|
-
|
|
934
|
-
|
|
861
|
+
},
|
|
862
|
+
moveFrom: (child) => {
|
|
863
|
+
const moveFromInfo = parseTrackedChangeInfo(child);
|
|
864
|
+
const moveFromContent = parseParagraphContents(child, styles, theme, null, rels, media, "deletion", inScopeXmlns);
|
|
935
865
|
pushTrackedChangeSegments({
|
|
936
866
|
contents,
|
|
937
867
|
type: "moveFrom",
|
|
938
|
-
info:
|
|
939
|
-
parsedContent:
|
|
868
|
+
info: moveFromInfo,
|
|
869
|
+
parsedContent: moveFromContent
|
|
940
870
|
});
|
|
941
|
-
|
|
942
|
-
|
|
871
|
+
},
|
|
872
|
+
moveTo: (child) => {
|
|
873
|
+
const moveToInfo = parseTrackedChangeInfo(child);
|
|
874
|
+
const moveToContent = parseParagraphContents(child, styles, theme, null, rels, media, "default", inScopeXmlns);
|
|
943
875
|
pushTrackedChangeSegments({
|
|
944
876
|
contents,
|
|
945
877
|
type: "moveTo",
|
|
946
|
-
info:
|
|
947
|
-
parsedContent:
|
|
878
|
+
info: moveToInfo,
|
|
879
|
+
parsedContent: moveToContent
|
|
948
880
|
});
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
}
|
|
955
|
-
case "moveFromRangeStart":
|
|
881
|
+
},
|
|
882
|
+
smartTag: (child) => {
|
|
883
|
+
contents.push(parseInlineWrapper(child, "smartTag"));
|
|
884
|
+
},
|
|
885
|
+
moveFromRangeStart: (child) => {
|
|
956
886
|
contents.push({
|
|
957
887
|
type: "moveFromRangeStart",
|
|
958
888
|
...parseMoveBookmarkMarker(child)
|
|
959
889
|
});
|
|
960
|
-
|
|
961
|
-
|
|
890
|
+
},
|
|
891
|
+
moveFromRangeEnd: (child) => {
|
|
962
892
|
contents.push({
|
|
963
893
|
type: "moveFromRangeEnd",
|
|
964
894
|
...parseMarkupRangeMarker(child)
|
|
965
895
|
});
|
|
966
|
-
|
|
967
|
-
|
|
896
|
+
},
|
|
897
|
+
moveToRangeStart: (child) => {
|
|
968
898
|
contents.push({
|
|
969
899
|
type: "moveToRangeStart",
|
|
970
900
|
...parseMoveBookmarkMarker(child)
|
|
971
901
|
});
|
|
972
|
-
|
|
973
|
-
|
|
902
|
+
},
|
|
903
|
+
moveToRangeEnd: (child) => {
|
|
974
904
|
contents.push({
|
|
975
905
|
type: "moveToRangeEnd",
|
|
976
906
|
...parseMarkupRangeMarker(child)
|
|
977
907
|
});
|
|
978
|
-
|
|
979
|
-
|
|
908
|
+
},
|
|
909
|
+
commentRangeStart: (child) => {
|
|
980
910
|
contents.push({
|
|
981
911
|
type: "commentRangeStart",
|
|
982
912
|
...parseMarkupRangeMarker(child)
|
|
983
913
|
});
|
|
984
|
-
|
|
985
|
-
|
|
914
|
+
},
|
|
915
|
+
commentRangeEnd: (child) => {
|
|
986
916
|
contents.push({
|
|
987
917
|
type: "commentRangeEnd",
|
|
988
918
|
...parseMarkupRangeMarker(child)
|
|
989
919
|
});
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
control: localName === "bdo" ? BIDI_CONTROLS.override : BIDI_CONTROLS.embedding,
|
|
997
|
-
content: parseParagraphContents(child, styles, theme, null, rels, media, trackedContext, inScopeXmlns)
|
|
998
|
-
};
|
|
999
|
-
if (direction === "ltr" || direction === "rtl") wrapper.direction = direction;
|
|
1000
|
-
contents.push(wrapper);
|
|
1001
|
-
break;
|
|
1002
|
-
}
|
|
1003
|
-
case "oMath":
|
|
1004
|
-
case "oMathPara": {
|
|
1005
|
-
const isBlock = localName === "oMathPara";
|
|
1006
|
-
const ommlXml = captureVerbatimXml(child);
|
|
1007
|
-
const plainText = extractMathText(child);
|
|
1008
|
-
const mathEq = {
|
|
1009
|
-
type: "mathEquation",
|
|
1010
|
-
display: isBlock ? "block" : "inline",
|
|
1011
|
-
ommlXml
|
|
1012
|
-
};
|
|
1013
|
-
if (plainText) mathEq.plainText = plainText;
|
|
1014
|
-
contents.push(mathEq);
|
|
1015
|
-
break;
|
|
1016
|
-
}
|
|
1017
|
-
default: {
|
|
1018
|
-
const mathElement = mathContentOf(child);
|
|
1019
|
-
if (mathElement !== void 0) contents.push(mathElement);
|
|
1020
|
-
break;
|
|
920
|
+
},
|
|
921
|
+
bdo: (child) => {
|
|
922
|
+
contents.push(parseInlineWrapper(child, "bdo"));
|
|
923
|
+
},
|
|
924
|
+
dir: (child) => {
|
|
925
|
+
contents.push(parseInlineWrapper(child, "dir"));
|
|
1021
926
|
}
|
|
1022
927
|
}
|
|
1023
|
-
}
|
|
1024
|
-
if (inComplexField
|
|
1025
|
-
return contents;
|
|
928
|
+
});
|
|
929
|
+
if (inComplexField) contents.push(...complexFieldOpenRuns);
|
|
930
|
+
return withPreservedChildren(contents, preserved, preservedInlineCapture);
|
|
1026
931
|
}
|
|
1027
932
|
function getCommentReferenceId(runElement) {
|
|
1028
933
|
const commentReference = findChild(runElement, "w", "commentReference");
|
|
@@ -1031,6 +936,18 @@ function getCommentReferenceId(runElement) {
|
|
|
1031
936
|
return Number.isFinite(id) ? id : null;
|
|
1032
937
|
}
|
|
1033
938
|
/**
|
|
939
|
+
* Attribute local names `w:p` has a model field for.
|
|
940
|
+
*
|
|
941
|
+
* `w14:paraId` and `w14:textId` are read below and written by
|
|
942
|
+
* `serializeParagraph`; `folio:reviewCarrier` is folio's own. Everything else
|
|
943
|
+
* the element carried is the attribute remainder.
|
|
944
|
+
*/
|
|
945
|
+
const PARAGRAPH_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
946
|
+
"paraId",
|
|
947
|
+
"textId",
|
|
948
|
+
"reviewCarrier"
|
|
949
|
+
]);
|
|
950
|
+
/**
|
|
1034
951
|
* Parse a paragraph element (w:p)
|
|
1035
952
|
*
|
|
1036
953
|
* @param node - The w:p XML element
|
|
@@ -1047,48 +964,51 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
1047
964
|
type: "paragraph",
|
|
1048
965
|
content: []
|
|
1049
966
|
};
|
|
1050
|
-
const paraId =
|
|
967
|
+
const paraId = paraIdAttribute(node);
|
|
1051
968
|
if (paraId && isValidHexId(paraId)) paragraph.paraId = paraIdInRange(paraId);
|
|
1052
|
-
const textId =
|
|
969
|
+
const textId = textIdAttribute(node);
|
|
1053
970
|
if (textId && isValidHexId(textId)) paragraph.textId = paraIdInRange(textId);
|
|
971
|
+
const remainder = attributeRemainder({
|
|
972
|
+
element: node,
|
|
973
|
+
modelled: PARAGRAPH_ATTRIBUTES
|
|
974
|
+
});
|
|
975
|
+
if (remainder) paragraph.preservedAttributes = remainder;
|
|
1054
976
|
if (getAttributeByNamespaceUri(node, FOLIO_REVIEW_HISTORY_NAMESPACES, "reviewCarrier") === REVIEW_CARRIERS.TERMINAL_TABLE) paragraph.reviewCarrier = REVIEW_CARRIERS.TERMINAL_TABLE;
|
|
1055
977
|
if (!options?.inHeaderFooter && paragraphStartsWithRenderedPageBreak(node)) paragraph.renderedPageBreakBefore = true;
|
|
1056
978
|
const pPr = findChild(node, "w", "pPr");
|
|
1057
979
|
if (pPr) {
|
|
1058
|
-
const formattingResult = parseParagraphProperties(pPr, theme
|
|
980
|
+
const formattingResult = parseParagraphProperties(pPr, theme);
|
|
1059
981
|
if (formattingResult !== void 0) paragraph.formatting = formattingResult;
|
|
1060
|
-
const propertyChangesResult = parseParagraphPropertyChanges(pPr, theme,
|
|
982
|
+
const propertyChangesResult = parseParagraphPropertyChanges(pPr, theme, paragraph.formatting);
|
|
1061
983
|
if (propertyChangesResult !== void 0) paragraph.propertyChanges = propertyChangesResult;
|
|
1062
984
|
const pPrMarkResult = parseParagraphMarkChange(pPr);
|
|
1063
985
|
if (pPrMarkResult !== void 0) paragraph.pPrMark = pPrMarkResult;
|
|
1064
986
|
const sectPr = findChild(pPr, "w", "sectPr");
|
|
1065
987
|
if (sectPr) paragraph.sectionProperties = parseSectionProperties(sectPr);
|
|
1066
988
|
}
|
|
1067
|
-
|
|
989
|
+
const rawContent = parseParagraphContents(node, styles, theme, numbering, rels, media, "default", options?.rootXmlns ?? {});
|
|
990
|
+
paragraph.content = options?.runConsolidation === "deferred" ? rawContent : consolidateParagraphContent(rawContent);
|
|
1068
991
|
const paragraphFormatting = paragraph.formatting;
|
|
1069
992
|
const directNumPr = paragraphFormatting?.numPr;
|
|
1070
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");
|
|
1071
995
|
let effectiveNumPr = directNumPr;
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
effectiveNumPr =
|
|
1075
|
-
...styleNumPr,
|
|
1076
|
-
...directNumPr
|
|
1077
|
-
};
|
|
1078
|
-
numPrFromStyle = true;
|
|
1079
|
-
paragraphFormatting.numPr = effectiveNumPr;
|
|
996
|
+
if (paragraphFormatting && numPrFromStyle) {
|
|
997
|
+
effectiveNumPr = mergeParagraphNumbering$1(styleNumPr, directNumPr);
|
|
998
|
+
if (effectiveNumPr !== void 0) paragraphFormatting.numPr = effectiveNumPr;
|
|
1080
999
|
paragraphFormatting.numPrFromStyle = styleNumPr;
|
|
1081
1000
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
if (
|
|
1001
|
+
const resolvedNumbering = resolveParagraphNumbering$1(effectiveNumPr);
|
|
1002
|
+
if (numbering) {
|
|
1003
|
+
if (resolvedNumbering.kind === "reference") {
|
|
1004
|
+
const { numId, ilvl } = resolvedNumbering;
|
|
1085
1005
|
const level = numbering.getLevel(numId, ilvl);
|
|
1086
1006
|
if (level) {
|
|
1087
1007
|
const levelNumFmts = [];
|
|
1088
1008
|
const levelStarts = [];
|
|
1089
1009
|
for (let levelIndex = 0; levelIndex <= ilvl; levelIndex += 1) {
|
|
1090
1010
|
const listLevel = numbering.getLevel(numId, levelIndex);
|
|
1091
|
-
levelNumFmts.push(level.isLgl ? "decimal" : listLevel
|
|
1011
|
+
levelNumFmts.push(level.isLgl || !listLevel ? "decimal" : counterFormatOf(listLevel));
|
|
1092
1012
|
levelStarts.push(listLevel?.start ?? 1);
|
|
1093
1013
|
}
|
|
1094
1014
|
const listRendering = {
|
|
@@ -1105,12 +1025,13 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
1105
1025
|
if (instance?.abstractNumId !== void 0) listRendering.abstractNumId = instance.abstractNumId;
|
|
1106
1026
|
if (overrideForLevel?.startOverride !== void 0) listRendering.startOverride = overrideForLevel.startOverride;
|
|
1107
1027
|
if (level.isLgl) listRendering.isLegal = true;
|
|
1108
|
-
listRendering.numFmt = level.isLgl ? "decimal" : level
|
|
1028
|
+
listRendering.numFmt = level.isLgl ? "decimal" : counterFormatOf(level);
|
|
1109
1029
|
if (level.rPr?.hidden) listRendering.markerHidden = true;
|
|
1110
1030
|
const markerFormatting = markerFormattingFromLevel(level.rPr);
|
|
1111
1031
|
if (markerFormatting) listRendering.markerFormatting = markerFormatting;
|
|
1112
1032
|
if (level.rPr?.allCaps) listRendering.markerAllCaps = true;
|
|
1113
|
-
|
|
1033
|
+
const markerAlignment = markerAlignmentForLevel(level.lvlJc);
|
|
1034
|
+
if (markerAlignment !== void 0) listRendering.markerAlignment = markerAlignment;
|
|
1114
1035
|
if (level.suffix) listRendering.markerSuffix = level.suffix;
|
|
1115
1036
|
let implicitChildLevelAdvances = 0;
|
|
1116
1037
|
const foldedMarkerSuffix = [];
|
|
@@ -1155,7 +1076,7 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
1155
1076
|
if (level.pPr) {
|
|
1156
1077
|
if (!paragraph.formatting) paragraph.formatting = {};
|
|
1157
1078
|
const directInd = pPr ? findChild(pPr, "w", "ind") : null;
|
|
1158
|
-
const hasDirectLeft =
|
|
1079
|
+
const hasDirectLeft = hasAttributeAnySpelling(directInd, "CT_Ind @left");
|
|
1159
1080
|
const directFirstLine = directInd ? parseNumericAttribute(directInd, "w", "firstLine") : void 0;
|
|
1160
1081
|
const directHanging = directInd ? parseNumericAttribute(directInd, "w", "hanging") : void 0;
|
|
1161
1082
|
const hasDirectFirstLineOrHanging = directFirstLine !== void 0 && directFirstLine !== 0 || directHanging !== void 0 && directHanging !== 0;
|
|
@@ -1205,6 +1126,7 @@ const getRunContentText = (content) => {
|
|
|
1205
1126
|
case "break": return content.breakType === "page" ? "\f" : "\n";
|
|
1206
1127
|
case "noBreakHyphen": return "‑";
|
|
1207
1128
|
case "softHyphen": return "";
|
|
1129
|
+
case "preservedXml": return content.text;
|
|
1208
1130
|
case "drawing":
|
|
1209
1131
|
case "endnoteRef":
|
|
1210
1132
|
case "fieldChar":
|
|
@@ -1225,6 +1147,8 @@ const getHyperlinkText = (hyperlink) => hyperlink.children.map((child) => {
|
|
|
1225
1147
|
case "run": return getRunText(child);
|
|
1226
1148
|
case "bookmarkStart":
|
|
1227
1149
|
case "bookmarkEnd": return "";
|
|
1150
|
+
case "preservedInline": return child.text;
|
|
1151
|
+
case "inlineWrapper": return child.content.map(getParagraphContentText).join("");
|
|
1228
1152
|
default: return panic(`Unsupported hyperlink child in plain-text extraction: ${JSON.stringify(child)}`);
|
|
1229
1153
|
}
|
|
1230
1154
|
}).join("");
|
|
@@ -1237,10 +1161,11 @@ const getParagraphContentText = (content) => {
|
|
|
1237
1161
|
case "inlineSdt": return content.content.map(getParagraphContentText).join("");
|
|
1238
1162
|
case "insertion":
|
|
1239
1163
|
case "moveTo":
|
|
1240
|
-
case "
|
|
1164
|
+
case "inlineWrapper": return content.content.map(getParagraphContentText).join("");
|
|
1241
1165
|
case "deletion":
|
|
1242
1166
|
case "moveFrom": return "";
|
|
1243
1167
|
case "mathEquation": return content.plainText ?? "";
|
|
1168
|
+
case "preservedInline": return content.text;
|
|
1244
1169
|
case "bookmarkEnd":
|
|
1245
1170
|
case "bookmarkStart":
|
|
1246
1171
|
case "commentRangeEnd":
|
|
@@ -1278,7 +1203,7 @@ function isEmptyParagraph(paragraph) {
|
|
|
1278
1203
|
* @returns true if paragraph has numbering properties
|
|
1279
1204
|
*/
|
|
1280
1205
|
function isListItem(paragraph) {
|
|
1281
|
-
return
|
|
1206
|
+
return paragraphNumberingReferenceId$1(paragraph.formatting?.numPr) !== void 0;
|
|
1282
1207
|
}
|
|
1283
1208
|
/**
|
|
1284
1209
|
* Get the list level of a paragraph (0-8)
|
|
@@ -1287,8 +1212,8 @@ function isListItem(paragraph) {
|
|
|
1287
1212
|
* @returns List level or undefined if not a list item
|
|
1288
1213
|
*/
|
|
1289
1214
|
function getListLevel(paragraph) {
|
|
1290
|
-
|
|
1291
|
-
return
|
|
1215
|
+
const resolved = resolveParagraphNumbering$1(paragraph.formatting?.numPr);
|
|
1216
|
+
return resolved.kind === "reference" ? resolved.ilvl : void 0;
|
|
1292
1217
|
}
|
|
1293
1218
|
/**
|
|
1294
1219
|
* Check if paragraph has a specific style
|
|
@@ -1315,4 +1240,4 @@ function getTemplateVariable(paragraph) {
|
|
|
1315
1240
|
return text.slice(start + 2, end);
|
|
1316
1241
|
}
|
|
1317
1242
|
//#endregion
|
|
1318
|
-
export { getListLevel, getParagraphText, getTemplateVariable, hasStyle, isEmptyParagraph, isListItem, parseParagraph,
|
|
1243
|
+
export { getListLevel, getParagraphText, getTemplateVariable, hasStyle, isEmptyParagraph, isListItem, parseParagraph, parseParagraphPropertyChanges };
|