@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,21 +1,14 @@
|
|
|
1
|
+
import { XmlElement } from "./xmlParser.js";
|
|
2
|
+
import { NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, ParagraphNumberingOverride, ParagraphNumberingOverride as ParagraphNumberingOverride$1, ParagraphNumberingReference, ParagraphNumberingSlots, ResolvedParagraphNumbering, isNumberingReference, mergeParagraphNumbering, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId, paragraphNumberingSlots, resolveParagraphNumbering, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering } from "@stll/docx-core/model";
|
|
1
3
|
//#region src/docx/numberingReference.d.ts
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
5
|
+
* What a `<w:numPr>` states: absent (the tier states nothing), the reserved
|
|
6
|
+
* cancellation, a reference, or a level alone.
|
|
4
7
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* a heading-based style that must not be numbered). It must therefore survive a
|
|
9
|
-
* round trip: dropping the `w:numPr` would hand the numbering back.
|
|
8
|
+
* `w:numberingChange` is not read here. It is a historical record of what a
|
|
9
|
+
* reviewer changed, not a statement about this paragraph's numbering, and it
|
|
10
|
+
* travels as captured markup.
|
|
10
11
|
*/
|
|
11
|
-
declare const
|
|
12
|
-
/**
|
|
13
|
-
* Whether a `w:numId` names a numbering definition to resolve.
|
|
14
|
-
*
|
|
15
|
-
* Every lookup or validation against `numbering.nums` goes through this: an
|
|
16
|
-
* absent id has nothing to resolve, and {@link NO_NUMBERING_NUM_ID} is the
|
|
17
|
-
* "none" sentinel, never a dangling reference.
|
|
18
|
-
*/
|
|
19
|
-
declare const isNumberingReference: (numId: number | undefined) => numId is number;
|
|
12
|
+
declare const readParagraphNumbering: (numPr: XmlElement | null | undefined) => ParagraphNumberingOverride$1 | undefined;
|
|
20
13
|
//#endregion
|
|
21
|
-
export { NO_NUMBERING_NUM_ID, isNumberingReference };
|
|
14
|
+
export { NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, type ParagraphNumberingOverride, type ParagraphNumberingReference, type ParagraphNumberingSlots, type ResolvedParagraphNumbering, isNumberingReference, mergeParagraphNumbering, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId, paragraphNumberingSlots, readParagraphNumbering, resolveParagraphNumbering, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering };
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
import { findChild, parseNumberingLevelAttribute, parseNumericAttribute } from "./xmlParser.js";
|
|
2
|
+
import { NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, isNumberingReference, mergeParagraphNumbering, paragraphNumberingFromSlots, paragraphNumberingFromSlots as paragraphNumberingFromSlots$1, paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId, paragraphNumberingSlots, resolveParagraphNumbering, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering } from "@stll/docx-core/model";
|
|
1
3
|
//#region src/docx/numberingReference.ts
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
5
|
+
* What a `<w:numPr>` states: absent (the tier states nothing), the reserved
|
|
6
|
+
* cancellation, a reference, or a level alone.
|
|
4
7
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* a heading-based style that must not be numbered). It must therefore survive a
|
|
9
|
-
* round trip: dropping the `w:numPr` would hand the numbering back.
|
|
8
|
+
* `w:numberingChange` is not read here. It is a historical record of what a
|
|
9
|
+
* reviewer changed, not a statement about this paragraph's numbering, and it
|
|
10
|
+
* travels as captured markup.
|
|
10
11
|
*/
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const readParagraphNumbering = (numPr) => {
|
|
13
|
+
if (!numPr) return;
|
|
14
|
+
const numIdElement = findChild(numPr, "w", "numId");
|
|
15
|
+
const ilvlElement = findChild(numPr, "w", "ilvl");
|
|
16
|
+
return paragraphNumberingFromSlots$1({
|
|
17
|
+
numId: numIdElement ? parseNumericAttribute(numIdElement, "w", "val") : void 0,
|
|
18
|
+
ilvl: ilvlElement ? parseNumberingLevelAttribute(ilvlElement) : void 0
|
|
19
|
+
});
|
|
20
|
+
};
|
|
20
21
|
//#endregion
|
|
21
|
-
export { NO_NUMBERING_NUM_ID, isNumberingReference };
|
|
22
|
+
export { NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, isNumberingReference, mergeParagraphNumbering, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId, paragraphNumberingSlots, readParagraphNumbering, resolveParagraphNumbering, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_PARAGRAPH_NUMBERING as NO_PARAGRAPH_NUMBERING$1, paragraphNumberingReferenceId as paragraphNumberingReferenceId$1 } from "./numberingReference.js";
|
|
2
2
|
import { visitDocxParagraphs } from "./paragraphTraversal.js";
|
|
3
3
|
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
4
4
|
//#region src/docx/numberingReferenceNormalization.ts
|
|
@@ -40,9 +40,9 @@ const normalizeNumberingReferences = ({ documentBody, numbering, headers, footer
|
|
|
40
40
|
endnotes
|
|
41
41
|
}, (paragraph) => {
|
|
42
42
|
const formatting = paragraph.formatting;
|
|
43
|
-
const numId = formatting?.numPr
|
|
44
|
-
if (!formatting ||
|
|
45
|
-
formatting.numPr =
|
|
43
|
+
const numId = paragraphNumberingReferenceId$1(formatting?.numPr);
|
|
44
|
+
if (!formatting || numId === void 0 || resolvesNumbering(numId, numbering)) return;
|
|
45
|
+
formatting.numPr = NO_PARAGRAPH_NUMBERING$1;
|
|
46
46
|
delete formatting.numPrFromStyle;
|
|
47
47
|
delete paragraph.listRendering;
|
|
48
48
|
unnumberedDanglingReferences += 1;
|
|
@@ -53,9 +53,9 @@ const normalizeStyleNumberingReferences = ({ styles, numbering }) => {
|
|
|
53
53
|
const unnumberedStyleIds = [];
|
|
54
54
|
for (const style of styles) {
|
|
55
55
|
const pPr = style.pPr;
|
|
56
|
-
const numId = pPr?.numPr
|
|
57
|
-
if (!pPr ||
|
|
58
|
-
pPr.numPr =
|
|
56
|
+
const numId = paragraphNumberingReferenceId$1(pPr?.numPr);
|
|
57
|
+
if (!pPr || numId === void 0 || resolvesNumbering(numId, numbering)) continue;
|
|
58
|
+
pPr.numPr = NO_PARAGRAPH_NUMBERING$1;
|
|
59
59
|
unnumberedStyleIds.push(style.styleId);
|
|
60
60
|
}
|
|
61
61
|
return { unnumberedStyleIds };
|
|
@@ -3,6 +3,6 @@ import { document_d_exports } from "../types/document.js";
|
|
|
3
3
|
/** Zero-pad a counter to `width` digits (the `decimalZero` family). */
|
|
4
4
|
declare const padDecimal: (value: number, width: number) => string;
|
|
5
5
|
/** Format one OOXML numbering counter using Microsoft Word display semantics. */
|
|
6
|
-
declare const formatOoxmlCounter: (value: number, format: document_d_exports.
|
|
6
|
+
declare const formatOoxmlCounter: (value: number, format: document_d_exports.CounterFormat | undefined) => string;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { formatOoxmlCounter, padDecimal };
|
|
@@ -103,7 +103,10 @@ const formatOoxmlCounter = (value, format) => {
|
|
|
103
103
|
case "hindiCounting":
|
|
104
104
|
case "thaiLetters":
|
|
105
105
|
case "thaiNumbers":
|
|
106
|
-
case "thaiCounting":
|
|
106
|
+
case "thaiCounting":
|
|
107
|
+
case "bahtText":
|
|
108
|
+
case "dollarText":
|
|
109
|
+
case "custom": return String(value);
|
|
107
110
|
case "decimalZero": return padDecimal(value, 2);
|
|
108
111
|
case "decimalZero3": return padDecimal(value, 3);
|
|
109
112
|
case "decimalZero4": return padDecimal(value, 4);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { XmlElement } from "./xmlParser.js";
|
|
2
|
+
//#region src/docx/paraIdAttribute.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The namespaces a paraId-valued attribute may be written in: the Word 2010,
|
|
5
|
+
* 2012 and 2018 wordml extensions.
|
|
6
|
+
*
|
|
7
|
+
* The 2018 URI is read from the serializer's table rather than retyped, so the
|
|
8
|
+
* spelling folio writes and the spelling it accepts cannot drift.
|
|
9
|
+
*/
|
|
10
|
+
declare const PARA_ID_NAMESPACE_URIS: ReadonlySet<string>;
|
|
11
|
+
/** The paraId this element carries, or `undefined` when it carries none. */
|
|
12
|
+
declare const paraIdAttribute: (element: XmlElement) => string | undefined;
|
|
13
|
+
/** The paraId of the parent this element names, by the same rule. */
|
|
14
|
+
declare const paraIdParentAttribute: (element: XmlElement) => string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The textId this element carries: a paragraph identity written beside
|
|
17
|
+
* `paraId`, in the same namespaces and by the same rule.
|
|
18
|
+
*/
|
|
19
|
+
declare const textIdAttribute: (element: XmlElement) => string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* How a save addresses one paragraph of the part it is patching.
|
|
22
|
+
*
|
|
23
|
+
* Word 2010+ writes a `w14:paraId` on every paragraph; LibreOffice, Google
|
|
24
|
+
* Docs, python-docx and docx4j write none, and a package can carry both (Word
|
|
25
|
+
* stamps what it rewrites and leaves the rest). folio mints an id for every
|
|
26
|
+
* paragraph that arrives without one, so the model always has a key — but a
|
|
27
|
+
* minted key names nothing in the file, and looking it up there answers
|
|
28
|
+
* "absent" for every paragraph at once. Naming the two cases apart is what lets
|
|
29
|
+
* the patcher keep the id lookup where the file has an id and fall back to
|
|
30
|
+
* position only where it does not.
|
|
31
|
+
*/
|
|
32
|
+
type ParagraphIdentity =
|
|
33
|
+
/** The source part writes this paraId, so the id locates the paragraph. */
|
|
34
|
+
{
|
|
35
|
+
type: "authored";
|
|
36
|
+
paraId: string;
|
|
37
|
+
ordinal: number;
|
|
38
|
+
} |
|
|
39
|
+
/** The model's id was minted at parse; the ordinal locates the paragraph. */
|
|
40
|
+
{
|
|
41
|
+
type: "minted";
|
|
42
|
+
paraId: string;
|
|
43
|
+
ordinal: number;
|
|
44
|
+
} |
|
|
45
|
+
/** Neither side writes an id: nothing can name this paragraph to change it. */
|
|
46
|
+
{
|
|
47
|
+
type: "anonymous";
|
|
48
|
+
ordinal: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* What comparing two paragraph sequences by ordinal is worth.
|
|
52
|
+
*
|
|
53
|
+
* An ordinal only locates a paragraph when the two sequences agree on the
|
|
54
|
+
* paragraph order, and the ids they carry are the witnesses to that. The
|
|
55
|
+
* witnesses answer two separate questions, so they are reported separately
|
|
56
|
+
* rather than folded into one boolean: `consistent` says no id contradicts the
|
|
57
|
+
* ordinals, and `sharedOrdinals` counts the ids that actively confirm them. A
|
|
58
|
+
* caller comparing two views of ONE document already knows it is the same
|
|
59
|
+
* document, so absence of contradiction is its whole burden; a caller asking
|
|
60
|
+
* whether two containers of two DIFFERENT documents are the same container
|
|
61
|
+
* needs confirmation as well, or every equal-length container would pair with
|
|
62
|
+
* every other. Deciding that here, once, is what stops the save and the
|
|
63
|
+
* comparison from drifting into two answers about the same paragraphs.
|
|
64
|
+
*/
|
|
65
|
+
type ParagraphOrdinalAlignment = {
|
|
66
|
+
/** No id sits at one ordinal on one side and a different one on the other. */
|
|
67
|
+
consistent: boolean;
|
|
68
|
+
/** Ordinals carrying the same id on both sides. */
|
|
69
|
+
sharedOrdinals: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Line two paragraph sequences up by ordinal, judged by the ids they carry.
|
|
73
|
+
*
|
|
74
|
+
* An id only testifies when both sides carry it: one side alone says nothing,
|
|
75
|
+
* because a producer's id can be absent from a model that could not read it and
|
|
76
|
+
* a minted id is absent from the file it was minted for. An id both sides carry
|
|
77
|
+
* at the same ordinal confirms the alignment; at different ordinals, or written
|
|
78
|
+
* twice on either side, it refutes it.
|
|
79
|
+
*/
|
|
80
|
+
declare const alignParagraphOrdinals: (base: readonly ParagraphIdentity[], revised: readonly ParagraphIdentity[]) => ParagraphOrdinalAlignment;
|
|
81
|
+
/**
|
|
82
|
+
* Every paragraph's identity, plus whether ordinals may be trusted.
|
|
83
|
+
*
|
|
84
|
+
* `ordinalsAligned` is the evidence a `minted` splice needs. Both sequences
|
|
85
|
+
* describe one document — the source part and the model parsed from it — so
|
|
86
|
+
* {@link alignParagraphOrdinals}'s `consistent` is the whole of the question: a
|
|
87
|
+
* package with ids on some paragraphs proves its own alignment through them,
|
|
88
|
+
* and one with none is aligned vacuously behind the paragraph-count check the
|
|
89
|
+
* caller already runs.
|
|
90
|
+
*/
|
|
91
|
+
type ParagraphIdentityPlan = {
|
|
92
|
+
identities: readonly ParagraphIdentity[];
|
|
93
|
+
ordinalsAligned: boolean;
|
|
94
|
+
};
|
|
95
|
+
type ResolveParagraphIdentitiesOptions = {
|
|
96
|
+
/** The paraId written on each `<w:p>` of the source part, in document order. */
|
|
97
|
+
sourceParaIds: readonly (string | undefined)[];
|
|
98
|
+
/** The paraId the model serialized for each `<w:p>`, in the same order. */
|
|
99
|
+
serializedParaIds: readonly (string | undefined)[];
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Decide each serialized paragraph's identity against the source part.
|
|
103
|
+
*
|
|
104
|
+
* A paraId the source writes exactly once is `authored`; the same id written
|
|
105
|
+
* twice stays `authored` and is left for the caller's ambiguity check, so a
|
|
106
|
+
* duplicate is refused rather than silently addressed by position. An id the
|
|
107
|
+
* source does not write at all is `minted`.
|
|
108
|
+
*/
|
|
109
|
+
declare const resolveParagraphIdentities: ({ sourceParaIds, serializedParaIds }: ResolveParagraphIdentitiesOptions) => ParagraphIdentityPlan;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { PARA_ID_NAMESPACE_URIS, ParagraphIdentity, ParagraphIdentityPlan, ParagraphOrdinalAlignment, ResolveParagraphIdentitiesOptions, alignParagraphOrdinals, paraIdAttribute, paraIdParentAttribute, resolveParagraphIdentities, textIdAttribute };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { OOXML_NAMESPACES } from "./serializer/partNamespaces.js";
|
|
2
|
+
import { NAMESPACES, WORDPROCESSINGML_NAMESPACE_URIS, getAttributeByNamespaceUri } from "./xmlParser.js";
|
|
3
|
+
//#region src/docx/paraIdAttribute.ts
|
|
4
|
+
/**
|
|
5
|
+
* The one reader for "the paraId written on this element".
|
|
6
|
+
*
|
|
7
|
+
* A `paraId` is a join key: `w15:commentEx/@w15:paraId`,
|
|
8
|
+
* `w16cex:comment/@w16cex:paraId` and `w15:paraIdParent` all name a paragraph
|
|
9
|
+
* through the `w14:paraId` it carries. Three Word generations write the same
|
|
10
|
+
* key under three prefixes, and a producer is free to bind any of those
|
|
11
|
+
* namespaces to a prefix of its own choosing, so the key must be resolved by
|
|
12
|
+
* namespace URI. Resolving it by local name alone is worse than missing it: an
|
|
13
|
+
* unrelated `vendor:paraId` would key a comment into another thread and carry
|
|
14
|
+
* that thread's date, parent and resolved state.
|
|
15
|
+
*
|
|
16
|
+
* Every reader of the key calls this, so no call site can come to disagree
|
|
17
|
+
* with another about which attribute is a paraId.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* The namespaces a paraId-valued attribute may be written in: the Word 2010,
|
|
21
|
+
* 2012 and 2018 wordml extensions.
|
|
22
|
+
*
|
|
23
|
+
* The 2018 URI is read from the serializer's table rather than retyped, so the
|
|
24
|
+
* spelling folio writes and the spelling it accepts cannot drift.
|
|
25
|
+
*/
|
|
26
|
+
const PARA_ID_NAMESPACE_URIS = /* @__PURE__ */ new Set([
|
|
27
|
+
NAMESPACES.w14,
|
|
28
|
+
NAMESPACES.w15,
|
|
29
|
+
OOXML_NAMESPACES.w16cex.uri
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* The conventional prefixes, read literally as a last resort.
|
|
33
|
+
*
|
|
34
|
+
* A part that writes `w14:paraId` without declaring `xmlns:w14` is malformed,
|
|
35
|
+
* and no URI lookup can resolve it; Word reads those files, so folio does too.
|
|
36
|
+
*/
|
|
37
|
+
const CONVENTIONAL_PARA_ID_PREFIXES = [
|
|
38
|
+
"w14",
|
|
39
|
+
"w15",
|
|
40
|
+
"w16cex"
|
|
41
|
+
];
|
|
42
|
+
const paraIdValuedAttribute = (element, localName) => {
|
|
43
|
+
const byUri = getAttributeByNamespaceUri(element, PARA_ID_NAMESPACE_URIS, localName);
|
|
44
|
+
if (byUri !== null) return byUri;
|
|
45
|
+
for (const prefix of CONVENTIONAL_PARA_ID_PREFIXES) {
|
|
46
|
+
const literal = element.attributes?.[`${prefix}:${localName}`];
|
|
47
|
+
if (literal !== void 0) return String(literal);
|
|
48
|
+
}
|
|
49
|
+
const inWordprocessingml = getAttributeByNamespaceUri(element, WORDPROCESSINGML_NAMESPACE_URIS, localName);
|
|
50
|
+
if (inWordprocessingml !== null) return inWordprocessingml;
|
|
51
|
+
const literalW = element.attributes?.[`w:${localName}`];
|
|
52
|
+
return literalW === void 0 ? void 0 : String(literalW);
|
|
53
|
+
};
|
|
54
|
+
/** The paraId this element carries, or `undefined` when it carries none. */
|
|
55
|
+
const paraIdAttribute = (element) => paraIdValuedAttribute(element, "paraId");
|
|
56
|
+
/** The paraId of the parent this element names, by the same rule. */
|
|
57
|
+
const paraIdParentAttribute = (element) => paraIdValuedAttribute(element, "paraIdParent");
|
|
58
|
+
/**
|
|
59
|
+
* The textId this element carries: a paragraph identity written beside
|
|
60
|
+
* `paraId`, in the same namespaces and by the same rule.
|
|
61
|
+
*/
|
|
62
|
+
const textIdAttribute = (element) => paraIdValuedAttribute(element, "textId");
|
|
63
|
+
/** Ordinal per id, or `null` when the sequence writes that id more than once. */
|
|
64
|
+
const ordinalsById = (identities) => {
|
|
65
|
+
const byId = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const identity of identities) {
|
|
67
|
+
if (identity.type === "anonymous") continue;
|
|
68
|
+
byId.set(identity.paraId, byId.has(identity.paraId) ? null : identity.ordinal);
|
|
69
|
+
}
|
|
70
|
+
return byId;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Line two paragraph sequences up by ordinal, judged by the ids they carry.
|
|
74
|
+
*
|
|
75
|
+
* An id only testifies when both sides carry it: one side alone says nothing,
|
|
76
|
+
* because a producer's id can be absent from a model that could not read it and
|
|
77
|
+
* a minted id is absent from the file it was minted for. An id both sides carry
|
|
78
|
+
* at the same ordinal confirms the alignment; at different ordinals, or written
|
|
79
|
+
* twice on either side, it refutes it.
|
|
80
|
+
*/
|
|
81
|
+
const alignParagraphOrdinals = (base, revised) => {
|
|
82
|
+
if (base.length !== revised.length) return {
|
|
83
|
+
consistent: false,
|
|
84
|
+
sharedOrdinals: 0
|
|
85
|
+
};
|
|
86
|
+
const baseOrdinals = ordinalsById(base);
|
|
87
|
+
const revisedOrdinals = ordinalsById(revised);
|
|
88
|
+
let sharedOrdinals = 0;
|
|
89
|
+
for (const [paraId, baseOrdinal] of baseOrdinals) {
|
|
90
|
+
const revisedOrdinal = revisedOrdinals.get(paraId);
|
|
91
|
+
if (revisedOrdinal === void 0) continue;
|
|
92
|
+
if (baseOrdinal === null || revisedOrdinal === null || baseOrdinal !== revisedOrdinal) return {
|
|
93
|
+
consistent: false,
|
|
94
|
+
sharedOrdinals: 0
|
|
95
|
+
};
|
|
96
|
+
sharedOrdinals += 1;
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
consistent: true,
|
|
100
|
+
sharedOrdinals
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Decide each serialized paragraph's identity against the source part.
|
|
105
|
+
*
|
|
106
|
+
* A paraId the source writes exactly once is `authored`; the same id written
|
|
107
|
+
* twice stays `authored` and is left for the caller's ambiguity check, so a
|
|
108
|
+
* duplicate is refused rather than silently addressed by position. An id the
|
|
109
|
+
* source does not write at all is `minted`.
|
|
110
|
+
*/
|
|
111
|
+
const resolveParagraphIdentities = ({ sourceParaIds, serializedParaIds }) => {
|
|
112
|
+
const sourceIdentities = sourceParaIds.map((paraId, ordinal) => paraId === void 0 ? {
|
|
113
|
+
type: "anonymous",
|
|
114
|
+
ordinal
|
|
115
|
+
} : {
|
|
116
|
+
type: "authored",
|
|
117
|
+
paraId,
|
|
118
|
+
ordinal
|
|
119
|
+
});
|
|
120
|
+
const sourceIds = new Set(sourceParaIds.filter((paraId) => paraId !== void 0));
|
|
121
|
+
const identities = serializedParaIds.map((paraId, ordinal) => {
|
|
122
|
+
if (paraId === void 0) return {
|
|
123
|
+
type: "anonymous",
|
|
124
|
+
ordinal
|
|
125
|
+
};
|
|
126
|
+
return sourceIds.has(paraId) ? {
|
|
127
|
+
type: "authored",
|
|
128
|
+
paraId,
|
|
129
|
+
ordinal
|
|
130
|
+
} : {
|
|
131
|
+
type: "minted",
|
|
132
|
+
paraId,
|
|
133
|
+
ordinal
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
identities,
|
|
138
|
+
ordinalsAligned: alignParagraphOrdinals(sourceIdentities, identities).consistent
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
//#endregion
|
|
142
|
+
export { PARA_ID_NAMESPACE_URIS, alignParagraphOrdinals, paraIdAttribute, paraIdParentAttribute, resolveParagraphIdentities, textIdAttribute };
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
-
import { StyleMap } from "./styleParser.js";
|
|
4
3
|
import { XmlElement } from "./xmlParser.js";
|
|
4
|
+
import { StyleMap } from "./styleParser.js";
|
|
5
5
|
//#region src/docx/paragraphParser.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* - w:pBdr (paragraph borders: top, bottom, left, right, between)
|
|
14
|
-
* - w:shd (paragraph shading/background)
|
|
15
|
-
* - w:tabs (tab stops with positions and types)
|
|
16
|
-
* - w:keepNext, w:keepLines, w:widowControl, w:pageBreakBefore
|
|
17
|
-
* - w:bidi (right-to-left)
|
|
18
|
-
* - w:numPr (list info)
|
|
19
|
-
* - w:pStyle (style reference)
|
|
20
|
-
* - w:outlineLvl (outline level)
|
|
21
|
-
* - w:framePr (frame properties)
|
|
22
|
-
* - w:rPr (default run properties)
|
|
23
|
-
*/
|
|
24
|
-
declare function parseParagraphProperties(pPr: XmlElement | null, theme: document_d_exports.Theme | null, styles?: StyleMap): document_d_exports.ParagraphFormatting | undefined;
|
|
6
|
+
declare function parseParagraphPropertyChanges(pPr: XmlElement | null, theme: document_d_exports.Theme | null, currentFormatting: document_d_exports.ParagraphFormatting | undefined): document_d_exports.ParagraphPropertyChange[] | undefined;
|
|
7
|
+
type ParseParagraphOptions = {
|
|
8
|
+
inHeaderFooter?: boolean;
|
|
9
|
+
rootXmlns?: Record<string, string>;
|
|
10
|
+
/** Delay run merging until a source-position-dependent enrichment pass completes. */
|
|
11
|
+
runConsolidation?: "immediate" | "deferred";
|
|
12
|
+
};
|
|
25
13
|
/**
|
|
26
14
|
* Parse a paragraph element (w:p)
|
|
27
15
|
*
|
|
@@ -34,10 +22,7 @@ declare function parseParagraphProperties(pPr: XmlElement | null, theme: documen
|
|
|
34
22
|
* @param options - Parsing options for context-specific body behavior
|
|
35
23
|
* @returns Parsed Paragraph object
|
|
36
24
|
*/
|
|
37
|
-
declare function parseParagraph(node: 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, options?:
|
|
38
|
-
inHeaderFooter?: boolean;
|
|
39
|
-
rootXmlns?: Record<string, string>;
|
|
40
|
-
}): document_d_exports.Paragraph;
|
|
25
|
+
declare function parseParagraph(node: 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, options?: ParseParagraphOptions): document_d_exports.Paragraph;
|
|
41
26
|
/**
|
|
42
27
|
* Get plain text from a paragraph
|
|
43
28
|
*
|
|
@@ -82,4 +67,4 @@ declare function hasStyle(paragraph: document_d_exports.Paragraph, styleId: stri
|
|
|
82
67
|
*/
|
|
83
68
|
declare function getTemplateVariable(paragraph: document_d_exports.Paragraph): string | null;
|
|
84
69
|
//#endregion
|
|
85
|
-
export { getListLevel, getParagraphText, getTemplateVariable, hasStyle, isEmptyParagraph, isListItem, parseParagraph,
|
|
70
|
+
export { getListLevel, getParagraphText, getTemplateVariable, hasStyle, isEmptyParagraph, isListItem, parseParagraph, parseParagraphPropertyChanges };
|