@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { XmlElement } from "./xmlParser.js";
|
|
3
|
+
//#region src/docx/paragraphProperties.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Read `w:pPr` into {@link ParagraphFormatting}, every declared child carrying
|
|
6
|
+
* a decision.
|
|
7
|
+
*
|
|
8
|
+
* One reader serves all four owners of the set — a paragraph's own properties,
|
|
9
|
+
* the `CT_PPrGeneral` a style carries, a numbering level's, and the
|
|
10
|
+
* `CT_PPrBase` snapshot inside `w:pPrChange` — so a property is read the same
|
|
11
|
+
* way wherever it was authored, and the handler map is total over the content
|
|
12
|
+
* model rather than over whichever names a `switch` happened to list.
|
|
13
|
+
*
|
|
14
|
+
* Three children belong to other readers and are neither modelled nor captured
|
|
15
|
+
* here, because capturing one as well would write it twice: `w:sectPr` is read
|
|
16
|
+
* by the section parser off the paragraph, `w:pPrChange` by the
|
|
17
|
+
* property-change parser, and `w:rPr` is the paragraph mark's own property
|
|
18
|
+
* set, read below off the element for the same reason a run's is read off the
|
|
19
|
+
* run.
|
|
20
|
+
*/
|
|
21
|
+
declare function parseParagraphProperties(pPr: XmlElement | null, theme: document_d_exports.Theme | null): document_d_exports.ParagraphFormatting | undefined;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { parseParagraphProperties };
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { readAttributeBag } from "./attributeRemainder.js";
|
|
2
|
+
import { parseBorderSpec } from "./borderParser.js";
|
|
3
|
+
import { CAPTURE, dispatchChildren, ownedElsewhere, sequencePositions } from "./containerChildren.js";
|
|
4
|
+
import { readParagraphNumbering } from "./numberingReference.js";
|
|
5
|
+
import { FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, LineSpacingRuleSchema, ParagraphAlignmentSchema, TabLeaderSchema, TabStopAlignmentSchema, narrowEnum } from "./parserEnums.js";
|
|
6
|
+
import { FRAME_ATTRIBUTES, INDENTATION_ATTRIBUTES, SPACING_ATTRIBUTES, TAB_STOP_ATTRIBUTES } from "./propertyElementAttributes.js";
|
|
7
|
+
import { RUN_PROPERTY_OWNERS, parseRunProperties } from "./runParser.js";
|
|
8
|
+
import { parseShading } from "./shadingParser.js";
|
|
9
|
+
import { numericAttributeAnySpelling } from "./strictNames.js";
|
|
10
|
+
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
11
|
+
import { findChild, findChildren, getAttribute, parseBooleanElement, parseNumericAttribute, parseOnOffAttribute, parseOnOffChild } from "./xmlParser.js";
|
|
12
|
+
import { outlineLevelFromStatedValue } from "@stll/docx-core/model";
|
|
13
|
+
//#region src/docx/paragraphProperties.ts
|
|
14
|
+
/**
|
|
15
|
+
* Parse tab stops (w:tabs)
|
|
16
|
+
*/
|
|
17
|
+
function parseTabStops(tabs) {
|
|
18
|
+
if (!tabs) return;
|
|
19
|
+
const tabElements = findChildren(tabs, "w", "tab");
|
|
20
|
+
if (tabElements.length === 0) return;
|
|
21
|
+
const result = [];
|
|
22
|
+
for (const tab of tabElements) {
|
|
23
|
+
const pos = parseNumericAttribute(tab, "w", "pos");
|
|
24
|
+
const alignment = narrowEnum(getAttribute(tab, "w", "val"), TabStopAlignmentSchema);
|
|
25
|
+
if (pos !== void 0 && alignment) {
|
|
26
|
+
const tabStop = {
|
|
27
|
+
position: pos,
|
|
28
|
+
alignment
|
|
29
|
+
};
|
|
30
|
+
const leader = narrowEnum(getAttribute(tab, "w", "leader"), TabLeaderSchema);
|
|
31
|
+
if (leader && leader !== "none") tabStop.leader = leader;
|
|
32
|
+
const preservedAttributes = readAttributeBag(tab, TAB_STOP_ATTRIBUTES);
|
|
33
|
+
if (preservedAttributes) tabStop.preservedAttributes = preservedAttributes;
|
|
34
|
+
result.push(tabStop);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result.length > 0 ? result : void 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parse frame properties (w:framePr)
|
|
41
|
+
*/
|
|
42
|
+
function parseFrameProperties(framePr) {
|
|
43
|
+
if (!framePr) return;
|
|
44
|
+
const frame = {};
|
|
45
|
+
const dropCap = getAttribute(framePr, "w", "dropCap");
|
|
46
|
+
if (dropCap === "none" || dropCap === "drop" || dropCap === "margin") frame.dropCap = dropCap;
|
|
47
|
+
const lines = parseNumericAttribute(framePr, "w", "lines");
|
|
48
|
+
if (lines !== void 0) frame.lines = lines;
|
|
49
|
+
const w = parseNumericAttribute(framePr, "w", "w");
|
|
50
|
+
if (w !== void 0) frame.width = w;
|
|
51
|
+
const h = parseNumericAttribute(framePr, "w", "h");
|
|
52
|
+
if (h !== void 0) frame.height = h;
|
|
53
|
+
const hSpace = parseNumericAttribute(framePr, "w", "hSpace");
|
|
54
|
+
if (hSpace !== void 0) frame.hSpace = hSpace;
|
|
55
|
+
const vSpace = parseNumericAttribute(framePr, "w", "vSpace");
|
|
56
|
+
if (vSpace !== void 0) frame.vSpace = vSpace;
|
|
57
|
+
const hAnchor = getAttribute(framePr, "w", "hAnchor");
|
|
58
|
+
if (hAnchor === "text" || hAnchor === "margin" || hAnchor === "page") frame.hAnchor = hAnchor;
|
|
59
|
+
const vAnchor = getAttribute(framePr, "w", "vAnchor");
|
|
60
|
+
if (vAnchor === "text" || vAnchor === "margin" || vAnchor === "page") frame.vAnchor = vAnchor;
|
|
61
|
+
const x = parseNumericAttribute(framePr, "w", "x");
|
|
62
|
+
if (x !== void 0) frame.x = x;
|
|
63
|
+
const y = parseNumericAttribute(framePr, "w", "y");
|
|
64
|
+
if (y !== void 0) frame.y = y;
|
|
65
|
+
const xAlign = narrowEnum(getAttribute(framePr, "w", "xAlign"), FrameXAlignSchema);
|
|
66
|
+
if (xAlign) frame.xAlign = xAlign;
|
|
67
|
+
const yAlign = narrowEnum(getAttribute(framePr, "w", "yAlign"), FrameYAlignSchema);
|
|
68
|
+
if (yAlign) frame.yAlign = yAlign;
|
|
69
|
+
const wrap = narrowEnum(getAttribute(framePr, "w", "wrap"), FrameWrapSchema);
|
|
70
|
+
if (wrap) frame.wrap = wrap;
|
|
71
|
+
if (Object.keys(frame).length === 0) return;
|
|
72
|
+
const preservedAttributes = readAttributeBag(framePr, FRAME_ATTRIBUTES);
|
|
73
|
+
if (preservedAttributes) frame.preservedAttributes = preservedAttributes;
|
|
74
|
+
return frame;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Read `w:pPr` into {@link ParagraphFormatting}, every declared child carrying
|
|
78
|
+
* a decision.
|
|
79
|
+
*
|
|
80
|
+
* One reader serves all four owners of the set — a paragraph's own properties,
|
|
81
|
+
* the `CT_PPrGeneral` a style carries, a numbering level's, and the
|
|
82
|
+
* `CT_PPrBase` snapshot inside `w:pPrChange` — so a property is read the same
|
|
83
|
+
* way wherever it was authored, and the handler map is total over the content
|
|
84
|
+
* model rather than over whichever names a `switch` happened to list.
|
|
85
|
+
*
|
|
86
|
+
* Three children belong to other readers and are neither modelled nor captured
|
|
87
|
+
* here, because capturing one as well would write it twice: `w:sectPr` is read
|
|
88
|
+
* by the section parser off the paragraph, `w:pPrChange` by the
|
|
89
|
+
* property-change parser, and `w:rPr` is the paragraph mark's own property
|
|
90
|
+
* set, read below off the element for the same reason a run's is read off the
|
|
91
|
+
* run.
|
|
92
|
+
*/
|
|
93
|
+
function parseParagraphProperties(pPr, theme) {
|
|
94
|
+
if (!pPr) return;
|
|
95
|
+
const formatting = {};
|
|
96
|
+
const taken = /* @__PURE__ */ new Set();
|
|
97
|
+
const once = (name, read) => (child) => {
|
|
98
|
+
if (taken.has(name) || !read(child)) return CAPTURE;
|
|
99
|
+
taken.add(name);
|
|
100
|
+
};
|
|
101
|
+
const toggle = (name, field) => once(name, (child) => {
|
|
102
|
+
formatting[field] = parseBooleanElement(child);
|
|
103
|
+
return true;
|
|
104
|
+
});
|
|
105
|
+
const preserved = dispatchChildren({
|
|
106
|
+
element: pPr,
|
|
107
|
+
container: "paragraph-properties",
|
|
108
|
+
capturePosition: sequencePositions("paragraph-properties", pPr),
|
|
109
|
+
handlers: {
|
|
110
|
+
pStyle: once("pStyle", (child) => {
|
|
111
|
+
const val = getAttribute(child, "w", "val");
|
|
112
|
+
if (!val) return false;
|
|
113
|
+
formatting.styleId = val;
|
|
114
|
+
return true;
|
|
115
|
+
}),
|
|
116
|
+
keepNext: toggle("keepNext", "keepNext"),
|
|
117
|
+
keepLines: toggle("keepLines", "keepLines"),
|
|
118
|
+
pageBreakBefore: toggle("pageBreakBefore", "pageBreakBefore"),
|
|
119
|
+
framePr: once("framePr", (child) => {
|
|
120
|
+
const frame = parseFrameProperties(child);
|
|
121
|
+
if (frame === void 0) return false;
|
|
122
|
+
formatting.frame = frame;
|
|
123
|
+
return true;
|
|
124
|
+
}),
|
|
125
|
+
widowControl: toggle("widowControl", "widowControl"),
|
|
126
|
+
numPr: once("numPr", (child) => {
|
|
127
|
+
const stated = readParagraphNumbering(child);
|
|
128
|
+
if (stated !== void 0) formatting.numPr = stated;
|
|
129
|
+
const numberingChange = findChild(child, "w", "numberingChange");
|
|
130
|
+
if (numberingChange) formatting.numberingChangeXml = captureVerbatimXml(numberingChange);
|
|
131
|
+
const statedLevel = parseNumericAttribute(findChild(child, "w", "ilvl"), "w", "val");
|
|
132
|
+
return stated !== void 0 || numberingChange !== null || statedLevel === -1;
|
|
133
|
+
}),
|
|
134
|
+
suppressLineNumbers: toggle("suppressLineNumbers", "suppressLineNumbers"),
|
|
135
|
+
pBdr: once("pBdr", (child) => {
|
|
136
|
+
const borders = {};
|
|
137
|
+
for (const side of PARAGRAPH_BORDER_SIDES) {
|
|
138
|
+
const border = parseBorderSpec(findChild(child, "w", side));
|
|
139
|
+
if (border) borders[side] = border;
|
|
140
|
+
}
|
|
141
|
+
if (Object.keys(borders).length === 0) return false;
|
|
142
|
+
formatting.borders = borders;
|
|
143
|
+
return true;
|
|
144
|
+
}),
|
|
145
|
+
shd: once("shd", (child) => {
|
|
146
|
+
const shading = parseShading(child);
|
|
147
|
+
if (shading === void 0) return false;
|
|
148
|
+
formatting.shading = shading;
|
|
149
|
+
return true;
|
|
150
|
+
}),
|
|
151
|
+
tabs: once("tabs", (child) => {
|
|
152
|
+
const tabs = parseTabStops(child);
|
|
153
|
+
if (tabs === void 0) return false;
|
|
154
|
+
formatting.tabs = tabs;
|
|
155
|
+
return true;
|
|
156
|
+
}),
|
|
157
|
+
suppressAutoHyphens: toggle("suppressAutoHyphens", "suppressAutoHyphens"),
|
|
158
|
+
kinsoku: toggle("kinsoku", "kinsoku"),
|
|
159
|
+
wordWrap: CAPTURE,
|
|
160
|
+
overflowPunct: toggle("overflowPunct", "overflowPunctuation"),
|
|
161
|
+
topLinePunct: CAPTURE,
|
|
162
|
+
autoSpaceDE: CAPTURE,
|
|
163
|
+
autoSpaceDN: CAPTURE,
|
|
164
|
+
bidi: toggle("bidi", "bidi"),
|
|
165
|
+
adjustRightInd: CAPTURE,
|
|
166
|
+
snapToGrid: toggle("snapToGrid", "snapToGrid"),
|
|
167
|
+
spacing: once("spacing", (child) => readParagraphSpacing(child, formatting)),
|
|
168
|
+
ind: once("ind", (child) => readParagraphIndentation(child, formatting)),
|
|
169
|
+
contextualSpacing: toggle("contextualSpacing", "contextualSpacing"),
|
|
170
|
+
mirrorIndents: CAPTURE,
|
|
171
|
+
suppressOverlap: CAPTURE,
|
|
172
|
+
jc: once("jc", (child) => {
|
|
173
|
+
const val = narrowEnum(getAttribute(child, "w", "val"), ParagraphAlignmentSchema);
|
|
174
|
+
if (!val) return false;
|
|
175
|
+
formatting.alignment = val;
|
|
176
|
+
return true;
|
|
177
|
+
}),
|
|
178
|
+
textDirection: CAPTURE,
|
|
179
|
+
textAlignment: CAPTURE,
|
|
180
|
+
textboxTightWrap: CAPTURE,
|
|
181
|
+
outlineLvl: once("outlineLvl", (child) => {
|
|
182
|
+
const val = parseNumericAttribute(child, "w", "val");
|
|
183
|
+
const level = val === void 0 ? void 0 : outlineLevelFromStatedValue(val);
|
|
184
|
+
if (level === void 0) return val === -1;
|
|
185
|
+
formatting.outlineLevel = level;
|
|
186
|
+
return true;
|
|
187
|
+
}),
|
|
188
|
+
divId: CAPTURE,
|
|
189
|
+
cnfStyle: CAPTURE,
|
|
190
|
+
rPr: ownedElsewhere({
|
|
191
|
+
container: "paragraph-properties",
|
|
192
|
+
child: "rPr",
|
|
193
|
+
reader: "paragraphProperties#parseParagraphProperties"
|
|
194
|
+
}),
|
|
195
|
+
sectPr: ownedElsewhere({
|
|
196
|
+
container: "paragraph-properties",
|
|
197
|
+
child: "sectPr",
|
|
198
|
+
reader: "sectionParser#parseSectionProperties"
|
|
199
|
+
}),
|
|
200
|
+
pPrChange: ownedElsewhere({
|
|
201
|
+
container: "paragraph-properties",
|
|
202
|
+
child: "pPrChange",
|
|
203
|
+
reader: "paragraphParser#parseParagraphPropertyChanges"
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
const rPr = findChild(pPr, "w", "rPr");
|
|
208
|
+
if (rPr) {
|
|
209
|
+
const runPropsResult = parseRunProperties(rPr, theme, RUN_PROPERTY_OWNERS.paragraphMark);
|
|
210
|
+
if (runPropsResult !== void 0) formatting.runProperties = runPropsResult;
|
|
211
|
+
const specVanish = parseOnOffChild(rPr, "w", "specVanish");
|
|
212
|
+
if (specVanish !== void 0) formatting.runInWithNext = specVanish;
|
|
213
|
+
}
|
|
214
|
+
if (preserved) formatting.preserved = preserved;
|
|
215
|
+
return Object.keys(formatting).length > 0 ? formatting : void 0;
|
|
216
|
+
}
|
|
217
|
+
/** `w:pBdr`'s sides, in the order `CT_PBdr` declares them. */
|
|
218
|
+
const PARAGRAPH_BORDER_SIDES = [
|
|
219
|
+
"top",
|
|
220
|
+
"left",
|
|
221
|
+
"bottom",
|
|
222
|
+
"right",
|
|
223
|
+
"between",
|
|
224
|
+
"bar"
|
|
225
|
+
];
|
|
226
|
+
/**
|
|
227
|
+
* `w:spacing`, which states up to six independent values.
|
|
228
|
+
*
|
|
229
|
+
* @returns whether any of them was taken; an element that states none keeps
|
|
230
|
+
* its bytes instead, because a `<w:spacing/>` the model cannot rebuild is
|
|
231
|
+
* markup the author wrote.
|
|
232
|
+
*/
|
|
233
|
+
const readParagraphSpacing = (spacing, formatting) => {
|
|
234
|
+
const before = parseNumericAttribute(spacing, "w", "before");
|
|
235
|
+
if (before !== void 0) formatting.spaceBefore = before;
|
|
236
|
+
const after = parseNumericAttribute(spacing, "w", "after");
|
|
237
|
+
if (after !== void 0) formatting.spaceAfter = after;
|
|
238
|
+
const line = parseNumericAttribute(spacing, "w", "line");
|
|
239
|
+
if (line !== void 0) formatting.lineSpacing = line;
|
|
240
|
+
const spacingExplicit = {};
|
|
241
|
+
if (before !== void 0) spacingExplicit.before = true;
|
|
242
|
+
if (after !== void 0) spacingExplicit.after = true;
|
|
243
|
+
if (spacingExplicit.before || spacingExplicit.after) formatting.spacingExplicit = spacingExplicit;
|
|
244
|
+
const lineRule = narrowEnum(getAttribute(spacing, "w", "lineRule"), LineSpacingRuleSchema);
|
|
245
|
+
if (lineRule) formatting.lineSpacingRule = lineRule;
|
|
246
|
+
const beforeAutospacing = parseOnOffAttribute(spacing, "w", "beforeAutospacing");
|
|
247
|
+
if (beforeAutospacing !== void 0) formatting.beforeAutospacing = beforeAutospacing;
|
|
248
|
+
const afterAutospacing = parseOnOffAttribute(spacing, "w", "afterAutospacing");
|
|
249
|
+
if (afterAutospacing !== void 0) formatting.afterAutospacing = afterAutospacing;
|
|
250
|
+
if (!(before !== void 0 || after !== void 0 || line !== void 0 || lineRule !== void 0 || beforeAutospacing !== void 0 || afterAutospacing !== void 0)) return false;
|
|
251
|
+
const preservedAttributes = readAttributeBag(spacing, SPACING_ATTRIBUTES);
|
|
252
|
+
if (preservedAttributes) formatting.spacingPreservedAttributes = preservedAttributes;
|
|
253
|
+
return true;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* `w:ind`. `w:start`/`w:end` are the Strict spellings of `w:left`/`w:right`,
|
|
257
|
+
* so they fill the same fields when the Transitional pair is absent.
|
|
258
|
+
*
|
|
259
|
+
* @returns whether any indent was taken.
|
|
260
|
+
*/
|
|
261
|
+
const readParagraphIndentation = (ind, formatting) => {
|
|
262
|
+
const left = numericAttributeAnySpelling(ind, "CT_Ind @left");
|
|
263
|
+
if (left !== void 0) formatting.indentLeft = left;
|
|
264
|
+
const right = numericAttributeAnySpelling(ind, "CT_Ind @right");
|
|
265
|
+
if (right !== void 0) formatting.indentRight = right;
|
|
266
|
+
const firstLine = parseNumericAttribute(ind, "w", "firstLine");
|
|
267
|
+
if (firstLine !== void 0) formatting.indentFirstLine = firstLine;
|
|
268
|
+
const hanging = parseNumericAttribute(ind, "w", "hanging");
|
|
269
|
+
if (hanging !== void 0) {
|
|
270
|
+
formatting.indentFirstLine = -hanging;
|
|
271
|
+
formatting.hangingIndent = true;
|
|
272
|
+
}
|
|
273
|
+
if (!(left !== void 0 || right !== void 0 || firstLine !== void 0 || hanging !== void 0)) return false;
|
|
274
|
+
const preservedAttributes = readAttributeBag(ind, INDENTATION_ATTRIBUTES);
|
|
275
|
+
if (preservedAttributes) formatting.indentPreservedAttributes = preservedAttributes;
|
|
276
|
+
return true;
|
|
277
|
+
};
|
|
278
|
+
//#endregion
|
|
279
|
+
export { parseParagraphProperties };
|
|
@@ -261,11 +261,14 @@ const invalidTableCellParagraphSourcePayload = (classification, path) => {
|
|
|
261
261
|
};
|
|
262
262
|
const tableCellBlockTraversalByType = {
|
|
263
263
|
blockSdt: "blockSdt",
|
|
264
|
+
bookmarkEnd: "leaf",
|
|
265
|
+
bookmarkStart: "leaf",
|
|
264
266
|
paragraph: "paragraph",
|
|
267
|
+
preservedBlock: "leaf",
|
|
265
268
|
table: "table"
|
|
266
269
|
};
|
|
267
270
|
const tableCellParagraphContentTraversalByType = {
|
|
268
|
-
|
|
271
|
+
inlineWrapper: "content",
|
|
269
272
|
bookmarkEnd: "leaf",
|
|
270
273
|
bookmarkStart: "leaf",
|
|
271
274
|
commentRangeEnd: "leaf",
|
|
@@ -283,6 +286,7 @@ const tableCellParagraphContentTraversalByType = {
|
|
|
283
286
|
moveTo: "content",
|
|
284
287
|
moveToRangeEnd: "leaf",
|
|
285
288
|
moveToRangeStart: "leaf",
|
|
289
|
+
preservedInline: "leaf",
|
|
286
290
|
run: "run",
|
|
287
291
|
simpleField: "content"
|
|
288
292
|
};
|
|
@@ -294,6 +298,7 @@ const tableCellRunContentTraversalByType = {
|
|
|
294
298
|
footnoteRef: "leaf",
|
|
295
299
|
instrText: "leaf",
|
|
296
300
|
noBreakHyphen: "leaf",
|
|
301
|
+
preservedXml: "leaf",
|
|
297
302
|
renderedPageBreak: "leaf",
|
|
298
303
|
shape: "shape",
|
|
299
304
|
softHyphen: "leaf",
|
|
@@ -453,6 +458,7 @@ function visitDecodedTableCellBlock(value, path, context) {
|
|
|
453
458
|
for (const [index, child] of content.entries()) visitDecodedTableCellBlock(child, `${path}.content[${index}]`, context);
|
|
454
459
|
return;
|
|
455
460
|
}
|
|
461
|
+
case "leaf": return;
|
|
456
462
|
default: return traversal;
|
|
457
463
|
}
|
|
458
464
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ParseContext } from "./parseContext.js";
|
|
4
4
|
import { XmlElement } from "./xmlParser.js";
|
|
5
|
+
import { StyleMap } from "./styleParser.js";
|
|
5
6
|
import { TableParserFn } from "./textBoxParser.js";
|
|
6
7
|
//#region src/docx/paragraphTextBoxEnrichment.d.ts
|
|
7
|
-
declare const enrichParagraphTextBoxes: (paragraph: document_d_exports.Paragraph, paraXml: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, parseTable: TableParserFn) => void;
|
|
8
|
+
declare const enrichParagraphTextBoxes: (paragraph: document_d_exports.Paragraph, paraXml: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, parseTable: TableParserFn, context?: ParseContext) => void;
|
|
8
9
|
//#endregion
|
|
9
10
|
export { enrichParagraphTextBoxes };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { pixelsToEmu } from "../utils/units.js";
|
|
2
2
|
import { parseParagraph } from "./paragraphParser.js";
|
|
3
|
-
import {
|
|
3
|
+
import { consolidateParagraphContent } from "./runConsolidator.js";
|
|
4
|
+
import { getTextBoxContentElement, parseTextBox, parseTextBoxContent, scanRunForTextBoxDrawings } from "./textBoxParser.js";
|
|
5
|
+
import { isVmlPictParsedByRunParser } from "./vmlImageParser.js";
|
|
4
6
|
import { findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
|
|
5
7
|
//#region src/docx/paragraphTextBoxEnrichment.ts
|
|
6
8
|
const VML_HORIZONTAL_RELATIVES = /* @__PURE__ */ new Set([
|
|
@@ -119,7 +121,7 @@ const vmlWrapType = (positioned, zIndex) => {
|
|
|
119
121
|
if (Number.isFinite(zIndex) && zIndex < 0) return "behind";
|
|
120
122
|
return "inFront";
|
|
121
123
|
};
|
|
122
|
-
const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering, rels, media, parseTable) => {
|
|
124
|
+
const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering, rels, media, parseTable, context) => {
|
|
123
125
|
enrichTextBoxRuns({
|
|
124
126
|
content: paragraph.content,
|
|
125
127
|
xmlChildren: getChildElements(paraXml),
|
|
@@ -128,15 +130,17 @@ const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering,
|
|
|
128
130
|
numbering,
|
|
129
131
|
rels,
|
|
130
132
|
media,
|
|
131
|
-
parseTable
|
|
133
|
+
parseTable,
|
|
134
|
+
context
|
|
132
135
|
});
|
|
136
|
+
paragraph.content = consolidateParagraphContent(paragraph.content);
|
|
133
137
|
};
|
|
134
138
|
const trackedChangeTypeFromXml = (localName) => {
|
|
135
139
|
if (localName === "ins") return "insertion";
|
|
136
140
|
if (localName === "del") return "deletion";
|
|
137
141
|
if (localName === "moveFrom" || localName === "moveTo") return localName;
|
|
138
142
|
};
|
|
139
|
-
const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rels, media, parseTable }) => {
|
|
143
|
+
const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rels, media, parseTable, context }) => {
|
|
140
144
|
let parsedIndex = 0;
|
|
141
145
|
let lastConsumedRun;
|
|
142
146
|
for (const xmlChild of xmlChildren) {
|
|
@@ -152,7 +156,8 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
|
|
|
152
156
|
numbering,
|
|
153
157
|
rels,
|
|
154
158
|
media,
|
|
155
|
-
parseTable
|
|
159
|
+
parseTable,
|
|
160
|
+
context
|
|
156
161
|
});
|
|
157
162
|
if (localName === "sdt" && parsedContent?.type === "inlineSdt") {
|
|
158
163
|
const properties = parsedContent.properties;
|
|
@@ -173,7 +178,8 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
|
|
|
173
178
|
numbering,
|
|
174
179
|
rels,
|
|
175
180
|
media,
|
|
176
|
-
parseTable
|
|
181
|
+
parseTable,
|
|
182
|
+
context
|
|
177
183
|
});
|
|
178
184
|
parsedIndex = lastSegmentIndex + 1;
|
|
179
185
|
continue;
|
|
@@ -182,12 +188,16 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
|
|
|
182
188
|
if (parsedIndex < content.length && parsedContent?.type !== "run") parsedIndex += 1;
|
|
183
189
|
continue;
|
|
184
190
|
}
|
|
185
|
-
const { textBoxDrawings, vmlTextBoxes, hasNonTextBoxContent } = scanRunForTextBoxDrawings(
|
|
191
|
+
const { textBoxDrawings, vmlTextBoxes, hasNonTextBoxContent } = scanRunForTextBoxDrawings({
|
|
192
|
+
xmlRun: xmlChild,
|
|
193
|
+
claimedByRunParser: (pictElement) => isVmlPictParsedByRunParser(pictElement, rels, media)
|
|
194
|
+
});
|
|
186
195
|
const parsedRun = parsedContent?.type === "run" ? parsedContent : void 0;
|
|
187
196
|
const targetRun = parsedRun ?? (hasNonTextBoxContent ? lastConsumedRun : void 0);
|
|
188
197
|
const targetRunMatchesXml = targetRun !== void 0 && (hasNonTextBoxContent || parsedRun?.content.length === 0);
|
|
198
|
+
const fillsEmptyCarrier = targetRunMatchesXml && !hasNonTextBoxContent && parsedRun !== void 0;
|
|
189
199
|
for (const runEl of textBoxDrawings) {
|
|
190
|
-
const textBox = parseTextBox(runEl);
|
|
200
|
+
const textBox = parseTextBox(runEl, context);
|
|
191
201
|
if (!textBox) continue;
|
|
192
202
|
const wsp = findDeep(runEl, "wps", "wsp");
|
|
193
203
|
if (wsp) {
|
|
@@ -203,6 +213,7 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
|
|
|
203
213
|
...textBox.title !== void 0 ? { title: textBox.title } : {},
|
|
204
214
|
...textBox.position !== void 0 ? { position: textBox.position } : {},
|
|
205
215
|
...textBox.wrap !== void 0 ? { wrap: textBox.wrap } : {},
|
|
216
|
+
...textBox.anchor !== void 0 ? { anchor: textBox.anchor } : {},
|
|
206
217
|
...textBox.fill !== void 0 ? { fill: textBox.fill } : {},
|
|
207
218
|
...textBox.outline !== void 0 ? { outline: textBox.outline } : {},
|
|
208
219
|
textBody: {
|
|
@@ -248,62 +259,12 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
|
|
|
248
259
|
parsedIndex += 1;
|
|
249
260
|
}
|
|
250
261
|
}
|
|
251
|
-
if (hasNonTextBoxContent && parsedRun) {
|
|
262
|
+
if ((hasNonTextBoxContent || fillsEmptyCarrier) && parsedRun) {
|
|
252
263
|
lastConsumedRun = parsedRun;
|
|
253
264
|
parsedIndex += 1;
|
|
254
265
|
}
|
|
255
266
|
}
|
|
256
267
|
};
|
|
257
|
-
const scanRunForTextBoxDrawings = (xmlRun) => {
|
|
258
|
-
const textBoxDrawings = [];
|
|
259
|
-
const vmlTextBoxes = [];
|
|
260
|
-
let hasNonTextBoxContent = false;
|
|
261
|
-
const visitDrawing = (drawingEl) => {
|
|
262
|
-
if (isTextBoxDrawing(drawingEl)) {
|
|
263
|
-
textBoxDrawings.push(drawingEl);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
hasNonTextBoxContent = true;
|
|
267
|
-
};
|
|
268
|
-
for (const el of getChildElements(xmlRun)) {
|
|
269
|
-
const name = getLocalName(el.name ?? "");
|
|
270
|
-
if (name === "rPr") continue;
|
|
271
|
-
if (name === "drawing") {
|
|
272
|
-
visitDrawing(el);
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
if (name === "pict") {
|
|
276
|
-
if (findDeep(el, "v", "textbox")) if (findDeep(el, "v", "imagedata")) hasNonTextBoxContent = true;
|
|
277
|
-
else vmlTextBoxes.push(el);
|
|
278
|
-
else hasNonTextBoxContent = true;
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (name === "AlternateContent") {
|
|
282
|
-
const branches = getChildElements(el);
|
|
283
|
-
const choice = branches.find((branch) => getLocalName(branch.name ?? "") === "Choice");
|
|
284
|
-
const fallback = branches.find((branch) => getLocalName(branch.name ?? "") === "Fallback");
|
|
285
|
-
const tryBranch = (branch) => {
|
|
286
|
-
if (!branch) return false;
|
|
287
|
-
let found = false;
|
|
288
|
-
for (const innerEl of getChildElements(branch)) if (getLocalName(innerEl.name ?? "") === "drawing") {
|
|
289
|
-
visitDrawing(innerEl);
|
|
290
|
-
found = true;
|
|
291
|
-
}
|
|
292
|
-
return found;
|
|
293
|
-
};
|
|
294
|
-
let foundInBranch = tryBranch(choice);
|
|
295
|
-
if (!foundInBranch) foundInBranch = tryBranch(fallback);
|
|
296
|
-
if (!foundInBranch) hasNonTextBoxContent = true;
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
hasNonTextBoxContent = true;
|
|
300
|
-
}
|
|
301
|
-
return {
|
|
302
|
-
textBoxDrawings,
|
|
303
|
-
vmlTextBoxes,
|
|
304
|
-
hasNonTextBoxContent
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
268
|
const parseVmlTextBoxShape = (pictEl, styles, theme, numbering, rels, media, parseTable) => {
|
|
308
269
|
const shapeEl = findDeep(pictEl, "v", "shape");
|
|
309
270
|
const textBoxEl = shapeEl ? findDeep(shapeEl, "v", "textbox") : null;
|
|
@@ -33,18 +33,22 @@ type InlineContentSlot = {
|
|
|
33
33
|
* only, and a run is not a marker position.
|
|
34
34
|
*/
|
|
35
35
|
declare const visitInlineContentSlots: (paragraph: document_d_exports.Paragraph, visit: (slot: InlineContentSlot) => void) => void;
|
|
36
|
+
/** What the walk does below a record it has just visited. */
|
|
37
|
+
declare const BLOCK_TREE_DESCENT: {
|
|
38
|
+
readonly descend: "descend";
|
|
39
|
+
readonly prune: "prune";
|
|
40
|
+
};
|
|
41
|
+
type BlockTreeDescent = (typeof BLOCK_TREE_DESCENT)[keyof typeof BLOCK_TREE_DESCENT];
|
|
36
42
|
/**
|
|
37
|
-
*
|
|
43
|
+
* Every record a block tree owns in document order: a paragraph, table, and
|
|
44
|
+
* table row. These are the records that carry authored state by identity.
|
|
38
45
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
46
|
+
* A block container is not always reached through a block. `w:txbxContent`
|
|
47
|
+
* hangs off a shape inside a run, so a walk that recurses on block children
|
|
48
|
+
* alone enters the body, a cell and an `w:sdt` and never enters a text box:
|
|
49
|
+
* every record inside one is then invisible to whatever the walk is deciding.
|
|
41
50
|
*/
|
|
42
|
-
declare
|
|
43
|
-
#private;
|
|
44
|
-
mark({ content, index }: Pick<InlineContentSlot, "content" | "index">): void;
|
|
45
|
-
/** Applies every marked removal and answers how many items were dropped. */
|
|
46
|
-
apply(): number;
|
|
47
|
-
}
|
|
51
|
+
declare const visitBlockTreeRecords: (blocks: readonly document_d_exports.BlockContent[], visit: (record: document_d_exports.Paragraph | document_d_exports.Table | document_d_exports.TableRow) => BlockTreeDescent) => void;
|
|
48
52
|
declare const visitDocxParagraphs: ({ documentBody, headers, footers, footnotes, endnotes }: DocxParagraphSurfaces, visit: (paragraph: document_d_exports.Paragraph) => void) => void;
|
|
49
53
|
//#endregion
|
|
50
|
-
export {
|
|
54
|
+
export { BLOCK_TREE_DESCENT, BlockTreeDescent, DocxParagraphSurfaces, InlineContentSlot, visitBlockTreeRecords, visitDocxParagraphs, visitInlineContentSlots, visitParagraphRuns };
|