@stll/folio-core 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +26 -24
- package/dist/ai-edits/headless.js +1 -1
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/content-controls/checkboxDisplay.d.ts +8 -2
- package/dist/content-controls/checkboxDisplay.js +11 -5
- package/dist/content-controls/mutateContentControls.js +41 -42
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +7 -7
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -20
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +93 -13
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +1 -19
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +34 -1
- package/dist/docx/attributeRemainder.js +49 -3
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +39 -67
- package/dist/docx/blockPlainText.js +3 -1
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentParser.js +3 -3
- package/dist/docx/commentRangeIntegrity.js +1 -1
- package/dist/docx/commentRangeJoin.js +1 -1
- package/dist/docx/commentReferenceNormalization.js +3 -2
- package/dist/docx/commentReplyMarkers.js +1 -1
- package/dist/docx/compatibility.js +56 -42
- package/dist/docx/containerChildren.d.ts +110 -13
- package/dist/docx/containerChildren.gen.d.ts +16 -1
- package/dist/docx/containerChildren.gen.js +18 -1
- package/dist/docx/containerChildren.js +63 -13
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.js +4 -1
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterReferenceNormalization.js +1 -1
- package/dist/docx/hyperlinkParser.d.ts +45 -7
- package/dist/docx/hyperlinkParser.js +126 -57
- package/dist/docx/imageParser.js +127 -107
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +84 -3
- package/dist/docx/inlineWrapperContent.js +85 -4
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +4 -2
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +91 -1
- package/dist/docx/paraIdAttribute.js +79 -1
- package/dist/docx/paragraphParser.d.ts +9 -24
- package/dist/docx/paragraphParser.js +212 -396
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +2 -0
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +14 -7
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +47 -49
- package/dist/docx/parseWarningMessage.js +3 -0
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.js +16 -6
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -2
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +78 -9
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +54 -18
- package/dist/docx/runParser.js +379 -295
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +236 -240
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +21 -2
- package/dist/docx/selectiveXmlPatch.js +195 -99
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +10 -8
- package/dist/docx/serializer/documentSerializer.js +3 -0
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +3 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +3 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +88 -188
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +109 -59
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +34 -45
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +268 -100
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +18 -16
- package/dist/docx/server/migrateYjsAttrSchema.js +3 -3
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +8 -3
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +10 -1
- package/dist/docx/tableParser.js +505 -181
- package/dist/docx/textBoxParser.d.ts +3 -1
- package/dist/docx/textBoxParser.js +18 -8
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/vmlImageParser.d.ts +13 -4
- package/dist/docx/vmlImageParser.js +74 -31
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlParser.d.ts +14 -1
- package/dist/docx/xmlParser.js +18 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +3 -1
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +177 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +47 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderPage.js +6 -4
- package/dist/layout-painter/renderParagraph.d.ts +2 -1
- package/dist/layout-painter/renderParagraph.js +13 -26
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/markdown/renderBlock.js +3 -1
- package/dist/markdown/renderRuns.js +7 -2
- package/dist/markdown/renderTable.js +2 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/prosemirror/attrs/index.d.ts +22 -4
- package/dist/prosemirror/attrs/index.js +498 -60
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +24 -19
- package/dist/prosemirror/commands/image.d.ts +1 -1
- package/dist/prosemirror/commands/image.js +4 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +18 -2
- package/dist/prosemirror/conversion/fromProseDoc.js +330 -183
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.js +371 -141
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +8 -2
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +19 -15
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +26 -2
- package/dist/prosemirror/extensions/markRegistry.js +73 -10
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +17 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.js +2 -1
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +10 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +8 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +4 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +141 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.js +20 -3
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.js +24 -6
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -0
- package/dist/prosemirror/runFormattingInlineCarriers.js +2 -0
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +23 -4
- package/dist/prosemirror/schema/nodes.d.ts +220 -24
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +17 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +2 -2
- package/dist/prosemirror/yjsDocumentMetadata.js +428 -7
- package/dist/prosemirror/zeroWidthAnchors.js +4 -0
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/mergeDocumentContent.js +5 -3
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -1
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -52
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
package/dist/docx/imageParser.js
CHANGED
|
@@ -2,15 +2,44 @@ import { normalizeImageLuminancePercent } from "../utils/imageLuminance.js";
|
|
|
2
2
|
import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
|
|
3
3
|
import { emuToPixels } from "../utils/units.js";
|
|
4
4
|
import { sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
5
|
-
import {
|
|
5
|
+
import { WORDPROCESSING_DRAWING_NAMESPACE_URIS, parseDrawingAnchor } from "./drawingAnchor.js";
|
|
6
|
+
import { findWrapElement, parseAnchorBehindDoc, parseDrawingEffectExtent, parseInlineWrap, parsePositionH, parsePositionV, parseWrapElement } from "./drawingUtils.js";
|
|
6
7
|
import { parseGraphicFrameLocks } from "./graphicFrameLocks.js";
|
|
7
8
|
import { parseNonVisualDrawingNames } from "./nonVisualDrawingProps.js";
|
|
8
9
|
import { RELATIONSHIP_TYPES, resolveRelationshipIdOfType } from "./relsParser.js";
|
|
9
10
|
import { isTextBoxDrawing } from "./textBoxParser.js";
|
|
10
11
|
import { percentageSpelling } from "./transitionalSpelling.js";
|
|
11
12
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
12
|
-
import { findByFullName,
|
|
13
|
+
import { findByFullName, findChildByNamespaceUri, findChildrenByNamespaceUri, getAttribute, getChildElements, getLocalName, getNamespaceUri, parseNumericAttribute, parseOnOffAttribute, parseOnOffValue } from "./xmlParser.js";
|
|
14
|
+
import { relationshipIdOf } from "@stll/docx-core/model";
|
|
13
15
|
//#region src/docx/imageParser.ts
|
|
16
|
+
/**
|
|
17
|
+
* Image Parser - Parse embedded images from w:drawing elements
|
|
18
|
+
*
|
|
19
|
+
* DOCX images are contained in <w:drawing> elements with either:
|
|
20
|
+
* - wp:inline - Inline images that flow with text
|
|
21
|
+
* - wp:anchor - Floating/anchored images with text wrapping
|
|
22
|
+
*
|
|
23
|
+
* OOXML Structure:
|
|
24
|
+
* w:drawing
|
|
25
|
+
* ├── wp:inline or wp:anchor
|
|
26
|
+
* │ ├── wp:extent (size: cx, cy in EMUs)
|
|
27
|
+
* │ ├── wp:effectExtent (effect margins)
|
|
28
|
+
* │ ├── wp:docPr (document properties: id, name, descr, title)
|
|
29
|
+
* │ ├── wp:positionH / wp:positionV (for anchor only)
|
|
30
|
+
* │ ├── wp:wrap* (wrapping mode for anchor: wrapNone, wrapSquare, etc.)
|
|
31
|
+
* │ └── a:graphic
|
|
32
|
+
* │ └── a:graphicData
|
|
33
|
+
* │ └── pic:pic
|
|
34
|
+
* │ ├── pic:nvPicPr (non-visual properties)
|
|
35
|
+
* │ ├── pic:blipFill
|
|
36
|
+
* │ │ └── a:blip (r:embed = rId)
|
|
37
|
+
* │ └── pic:spPr
|
|
38
|
+
* │ └── a:xfrm (transform: rotation, flip)
|
|
39
|
+
*
|
|
40
|
+
* EMU (English Metric Units): 914400 EMU = 1 inch
|
|
41
|
+
* Conversion: pixels = (emu * 96) / 914400
|
|
42
|
+
*/
|
|
14
43
|
const DRAWINGML_MAIN_NAMESPACE_URIS = /* @__PURE__ */ new Set(["http://schemas.openxmlformats.org/drawingml/2006/main", "http://purl.oclc.org/ooxml/drawingml/main"]);
|
|
15
44
|
const FIXED_PERCENTAGE = /^-?\d+$/u;
|
|
16
45
|
/**
|
|
@@ -26,13 +55,13 @@ function rotToDegrees(rot) {
|
|
|
26
55
|
return val / 6e4;
|
|
27
56
|
}
|
|
28
57
|
/**
|
|
29
|
-
*
|
|
58
|
+
* A child of `wp:inline` or `wp:anchor`, resolved by namespace.
|
|
59
|
+
*
|
|
60
|
+
* The `wp` prefix is the producer's choice, not the document's meaning: a
|
|
61
|
+
* package that binds the WordprocessingDrawing namespace to another prefix
|
|
62
|
+
* carries the same `wp:extent` and a prefix-matched read finds none of it.
|
|
30
63
|
*/
|
|
31
|
-
|
|
32
|
-
const children = getChildElements(parent);
|
|
33
|
-
for (const child of children) if (names.includes(child.name || "")) return child;
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
64
|
+
const findDrawingChild = (parent, localName) => findChildByNamespaceUri(parent, WORDPROCESSING_DRAWING_NAMESPACE_URIS, localName);
|
|
36
65
|
/**
|
|
37
66
|
* Parse extent element for image size
|
|
38
67
|
*
|
|
@@ -50,26 +79,6 @@ function parseExtent(extent) {
|
|
|
50
79
|
};
|
|
51
80
|
}
|
|
52
81
|
/**
|
|
53
|
-
* Parse effect extent for shadow/effect margins
|
|
54
|
-
*
|
|
55
|
-
* @param effectExtent - wp:effectExtent element
|
|
56
|
-
* @returns Padding for effects
|
|
57
|
-
*/
|
|
58
|
-
function parseEffectExtent(effectExtent) {
|
|
59
|
-
if (!effectExtent) return;
|
|
60
|
-
const l = parseNumericAttribute(effectExtent, null, "l") ?? 0;
|
|
61
|
-
const t = parseNumericAttribute(effectExtent, null, "t") ?? 0;
|
|
62
|
-
const r = parseNumericAttribute(effectExtent, null, "r") ?? 0;
|
|
63
|
-
const b = parseNumericAttribute(effectExtent, null, "b") ?? 0;
|
|
64
|
-
if (l === 0 && t === 0 && r === 0 && b === 0) return;
|
|
65
|
-
return {
|
|
66
|
-
left: l,
|
|
67
|
-
top: t,
|
|
68
|
-
right: r,
|
|
69
|
-
bottom: b
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
82
|
* The `a:ext` uri under which Word records that a drawing is decorative. The
|
|
74
83
|
* extension holds `<adec:decorative val="…"/>`; `CT_NonVisualDrawingProps` has
|
|
75
84
|
* no `@decorative` attribute for it to be written as.
|
|
@@ -111,6 +120,22 @@ const parseDocPropsExtensions = (docPr) => {
|
|
|
111
120
|
return result;
|
|
112
121
|
};
|
|
113
122
|
/**
|
|
123
|
+
* One of `wp:docPr`'s two `CT_Hyperlink` children, as the source wrote it.
|
|
124
|
+
*
|
|
125
|
+
* Resolved by namespace URI rather than by the `a:` prefix: a producer is free
|
|
126
|
+
* to bind DrawingML's namespace to another prefix, and a prefix-matched read
|
|
127
|
+
* would drop the whole link for a document that does.
|
|
128
|
+
*/
|
|
129
|
+
const parseDocPrLink = (docPr, localName) => {
|
|
130
|
+
const element = findChildByNamespaceUri(docPr, DRAWINGML_NAMESPACE_URIS, localName);
|
|
131
|
+
if (!element) return;
|
|
132
|
+
const rId = getAttribute(element, "r", "id");
|
|
133
|
+
return {
|
|
134
|
+
xml: captureVerbatimXml(element),
|
|
135
|
+
...rId == null ? {} : { rId }
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
114
139
|
* Parse document properties (wp:docPr)
|
|
115
140
|
*
|
|
116
141
|
* @param docPr - wp:docPr element
|
|
@@ -122,17 +147,35 @@ function parseDocProps(docPr) {
|
|
|
122
147
|
const names = parseNonVisualDrawingNames(docPr);
|
|
123
148
|
const hidden = parseOnOffAttribute(docPr, null, "hidden");
|
|
124
149
|
const { decorative, other: docPrExtensions } = parseDocPropsExtensions(docPr);
|
|
125
|
-
const
|
|
126
|
-
const
|
|
150
|
+
const hlinkClickSource = parseDocPrLink(docPr, "hlinkClick");
|
|
151
|
+
const hlinkHoverSource = parseDocPrLink(docPr, "hlinkHover");
|
|
127
152
|
return {
|
|
128
153
|
...id != null ? { id } : {},
|
|
129
154
|
...names,
|
|
130
155
|
...decorative === void 0 ? {} : { decorative },
|
|
131
156
|
...hidden === void 0 ? {} : { hidden },
|
|
132
157
|
...docPrExtensions.length > 0 ? { docPrExtensions } : {},
|
|
133
|
-
...
|
|
158
|
+
...hlinkClickSource === void 0 ? {} : { hlinkClickSource },
|
|
159
|
+
...hlinkHoverSource === void 0 ? {} : { hlinkHoverSource }
|
|
134
160
|
};
|
|
135
161
|
}
|
|
162
|
+
const safeDocPrLinks = ({ props, rels }) => {
|
|
163
|
+
const targetOf = (link) => {
|
|
164
|
+
if (link === void 0) return;
|
|
165
|
+
if (link.rId === void 0) return "";
|
|
166
|
+
const resolved = resolveRelationshipIdOfType(rels, link.rId, RELATIONSHIP_TYPES.hyperlink);
|
|
167
|
+
return resolved.status === "resolved" ? sanitizeExternalUrl(resolved.relationship.target) : void 0;
|
|
168
|
+
};
|
|
169
|
+
const click = props.hlinkClickSource;
|
|
170
|
+
const clickHref = targetOf(click);
|
|
171
|
+
const hoverKept = targetOf(props.hlinkHoverSource) !== void 0;
|
|
172
|
+
return {
|
|
173
|
+
...clickHref ? { hlinkHref: clickHref } : {},
|
|
174
|
+
...clickHref !== void 0 && click?.rId !== void 0 ? { hlinkRId: click.rId } : {},
|
|
175
|
+
...clickHref === void 0 || click === void 0 ? {} : { hlinkClickSource: click },
|
|
176
|
+
...hoverKept && props.hlinkHoverSource !== void 0 ? { hlinkHoverXml: props.hlinkHoverSource.xml } : {}
|
|
177
|
+
};
|
|
178
|
+
};
|
|
136
179
|
/**
|
|
137
180
|
* Parse transform properties from a:xfrm
|
|
138
181
|
*/
|
|
@@ -157,13 +200,22 @@ function parseTransform(xfrm) {
|
|
|
157
200
|
* `a:srcRect` crop element, so callers that need either share this walk.
|
|
158
201
|
*/
|
|
159
202
|
function findBlipFillElement(container) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
203
|
+
return findByFullName(findPictureElement(container), "pic:blipFill");
|
|
204
|
+
}
|
|
205
|
+
/** `a:graphic > a:graphicData > pic:pic`, the one walk every picture read shares. */
|
|
206
|
+
function findPictureElement(container) {
|
|
207
|
+
return findByFullName(findByFullName(findByFullName(container, "a:graphic"), "a:graphicData"), "pic:pic");
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* `pic:cNvPr` — the picture's own name, alt text and title.
|
|
211
|
+
*
|
|
212
|
+
* Not `wp:docPr`'s. They are two `CT_NonVisualDrawingProps` elements on the
|
|
213
|
+
* same drawing and a reader names the object from whichever one it is looking
|
|
214
|
+
* at, so folding them together loses whichever the source did not repeat.
|
|
215
|
+
*/
|
|
216
|
+
function findPictureNonVisualProps(container) {
|
|
217
|
+
const pic = findPictureElement(container);
|
|
218
|
+
return pic ? findByFullName(findByFullName(pic, "pic:nvPicPr"), "pic:cNvPr") : null;
|
|
167
219
|
}
|
|
168
220
|
/**
|
|
169
221
|
* Parse `<a:srcRect l="..." t="..." r="..." b="..."/>` inside `pic:blipFill`.
|
|
@@ -194,16 +246,6 @@ function parseImageCrop(blipFill) {
|
|
|
194
246
|
return crop;
|
|
195
247
|
}
|
|
196
248
|
/**
|
|
197
|
-
* Parse an OOXML `ST_OnOff` attribute on an element. Accepts the full
|
|
198
|
-
* set of literals the spec allows (`"1"`/`"true"`/`"on"` and
|
|
199
|
-
* `"0"`/`"false"`/`"off"`); anything else (including an absent
|
|
200
|
-
* attribute) folds back to `undefined` so callers can apply the
|
|
201
|
-
* spec-defined default.
|
|
202
|
-
*/
|
|
203
|
-
function parseOnOffAttr(element, name) {
|
|
204
|
-
return parseOnOffValue(getAttribute(element, null, name));
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
249
|
* Parse `<a:alphaModFix amt="..."/>` inside the `a:blip` element. The
|
|
208
250
|
* `amt` value is in 1/100000; convert to a fraction in [0, 1] for CSS
|
|
209
251
|
* `opacity`. Returns undefined when no alpha modifier is present (fully
|
|
@@ -249,12 +291,7 @@ function parseImageLuminance(blip) {
|
|
|
249
291
|
*/
|
|
250
292
|
function extractBlipRId(blip) {
|
|
251
293
|
if (!blip) return;
|
|
252
|
-
|
|
253
|
-
if (rEmbed) return rEmbed;
|
|
254
|
-
const embed = getAttribute(blip, null, "embed");
|
|
255
|
-
if (embed) return embed;
|
|
256
|
-
const rLink = getAttribute(blip, "r", "link");
|
|
257
|
-
if (rLink) return rLink;
|
|
294
|
+
return relationshipIdOf(getAttribute(blip, "r", "embed")) ?? relationshipIdOf(getAttribute(blip, null, "embed")) ?? relationshipIdOf(getAttribute(blip, "r", "link"));
|
|
258
295
|
}
|
|
259
296
|
/**
|
|
260
297
|
* Find transform (a:xfrm) from picture shape properties
|
|
@@ -262,15 +299,7 @@ function extractBlipRId(blip) {
|
|
|
262
299
|
* Path: a:graphic > a:graphicData > pic:pic > pic:spPr > a:xfrm
|
|
263
300
|
*/
|
|
264
301
|
function findPictureTransform(container) {
|
|
265
|
-
|
|
266
|
-
if (!graphic) return null;
|
|
267
|
-
const graphicData = findByFullName(graphic, "a:graphicData");
|
|
268
|
-
if (!graphicData) return null;
|
|
269
|
-
const pic = findByFullName(graphicData, "pic:pic");
|
|
270
|
-
if (!pic) return null;
|
|
271
|
-
const spPr = findByFullName(pic, "pic:spPr");
|
|
272
|
-
if (!spPr) return null;
|
|
273
|
-
return findByFullName(spPr, "a:xfrm");
|
|
302
|
+
return findByFullName(findByFullName(findPictureElement(container), "pic:spPr"), "a:xfrm");
|
|
274
303
|
}
|
|
275
304
|
/**
|
|
276
305
|
* Normalize a target path to the standard word/media/... format
|
|
@@ -362,10 +391,11 @@ function resolveImageData(rId, rels, media) {
|
|
|
362
391
|
* @returns Parsed Image object
|
|
363
392
|
*/
|
|
364
393
|
function parseInline(inlineEl, rels, media) {
|
|
365
|
-
const size = parseExtent(
|
|
366
|
-
const padding =
|
|
367
|
-
const props = parseDocProps(
|
|
394
|
+
const size = parseExtent(findDrawingChild(inlineEl, "extent"));
|
|
395
|
+
const padding = parseDrawingEffectExtent(findDrawingChild(inlineEl, "effectExtent"));
|
|
396
|
+
const props = parseDocProps(findDrawingChild(inlineEl, "docPr"));
|
|
368
397
|
const frameLocks = parseGraphicFrameLocks(inlineEl);
|
|
398
|
+
const pictureNames = parseNonVisualDrawingNames(findPictureNonVisualProps(inlineEl));
|
|
369
399
|
const blipFill = findBlipFillElement(inlineEl);
|
|
370
400
|
const blip = blipFill ? findByFullName(blipFill, "a:blip") : null;
|
|
371
401
|
const rId = extractBlipRId(blip);
|
|
@@ -374,15 +404,7 @@ function parseInline(inlineEl, rels, media) {
|
|
|
374
404
|
const effects = parseImageLuminance(blip);
|
|
375
405
|
const imageData = resolveImageData(rId, rels, media);
|
|
376
406
|
const transform = parseTransform(findPictureTransform(inlineEl));
|
|
377
|
-
const
|
|
378
|
-
const distB = parseNumericAttribute(inlineEl, null, "distB") ?? void 0;
|
|
379
|
-
const distL = parseNumericAttribute(inlineEl, null, "distL") ?? void 0;
|
|
380
|
-
const distR = parseNumericAttribute(inlineEl, null, "distR") ?? void 0;
|
|
381
|
-
const wrap = { type: "inline" };
|
|
382
|
-
if (distT !== void 0) wrap.distT = distT;
|
|
383
|
-
if (distB !== void 0) wrap.distB = distB;
|
|
384
|
-
if (distL !== void 0) wrap.distL = distL;
|
|
385
|
-
if (distR !== void 0) wrap.distR = distR;
|
|
407
|
+
const wrap = parseInlineWrap(inlineEl);
|
|
386
408
|
const image = {
|
|
387
409
|
type: "image",
|
|
388
410
|
...rId === void 0 ? {} : { rId },
|
|
@@ -393,6 +415,7 @@ function parseInline(inlineEl, rels, media) {
|
|
|
393
415
|
if (props.name !== void 0) image.docPrName = props.name;
|
|
394
416
|
if (props.alt !== void 0) image.alt = props.alt;
|
|
395
417
|
if (props.title !== void 0) image.title = props.title;
|
|
418
|
+
if (Object.keys(pictureNames).length > 0) image.pictureNames = pictureNames;
|
|
396
419
|
if (props.decorative !== void 0) image.decorative = props.decorative;
|
|
397
420
|
if (props.hidden !== void 0) image.hidden = props.hidden;
|
|
398
421
|
if (props.docPrExtensions !== void 0) image.docPrExtensions = props.docPrExtensions;
|
|
@@ -406,14 +429,10 @@ function parseInline(inlineEl, rels, media) {
|
|
|
406
429
|
if (opacity !== void 0) image.opacity = opacity;
|
|
407
430
|
if (effects !== void 0) image.effects = effects;
|
|
408
431
|
if (frameLocks) image.frameLocks = frameLocks;
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
image.hlinkHref = safeHref;
|
|
414
|
-
image.hlinkRId = hlink.relationship.id;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
432
|
+
Object.assign(image, safeDocPrLinks({
|
|
433
|
+
props,
|
|
434
|
+
rels
|
|
435
|
+
}));
|
|
417
436
|
return image;
|
|
418
437
|
}
|
|
419
438
|
/**
|
|
@@ -425,13 +444,14 @@ function parseInline(inlineEl, rels, media) {
|
|
|
425
444
|
* @returns Parsed Image object
|
|
426
445
|
*/
|
|
427
446
|
function parseAnchor(anchorEl, rels, media) {
|
|
428
|
-
const size = parseExtent(
|
|
429
|
-
const
|
|
430
|
-
const
|
|
447
|
+
const size = parseExtent(findDrawingChild(anchorEl, "extent"));
|
|
448
|
+
const effectExtent = findDrawingChild(anchorEl, "effectExtent");
|
|
449
|
+
const padding = parseDrawingEffectExtent(effectExtent);
|
|
450
|
+
const props = parseDocProps(findDrawingChild(anchorEl, "docPr"));
|
|
431
451
|
const frameLocks = parseGraphicFrameLocks(anchorEl);
|
|
452
|
+
const pictureNames = parseNonVisualDrawingNames(findPictureNonVisualProps(anchorEl));
|
|
432
453
|
const behindDoc = parseAnchorBehindDoc(anchorEl);
|
|
433
|
-
const
|
|
434
|
-
const allowOverlap = parseOnOffAttr(anchorEl, "allowOverlap");
|
|
454
|
+
const anchor = parseDrawingAnchor(anchorEl);
|
|
435
455
|
const anchorDistT = parseNumericAttribute(anchorEl, null, "distT");
|
|
436
456
|
const anchorDistB = parseNumericAttribute(anchorEl, null, "distB");
|
|
437
457
|
const anchorDistL = parseNumericAttribute(anchorEl, null, "distL");
|
|
@@ -442,9 +462,15 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
442
462
|
...anchorDistL != null ? { distL: anchorDistL } : {},
|
|
443
463
|
...anchorDistR != null ? { distR: anchorDistR } : {}
|
|
444
464
|
};
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
|
|
465
|
+
const anchorEffectExtent = parseDrawingEffectExtent(effectExtent);
|
|
466
|
+
const wrap = parseWrapElement({
|
|
467
|
+
wrapEl: findWrapElement(anchorEl),
|
|
468
|
+
behindDoc,
|
|
469
|
+
anchorDistances,
|
|
470
|
+
...anchorEffectExtent === void 0 ? {} : { anchorEffectExtent }
|
|
471
|
+
});
|
|
472
|
+
const posH = findDrawingChild(anchorEl, "positionH");
|
|
473
|
+
const posV = findDrawingChild(anchorEl, "positionV");
|
|
448
474
|
const horizontal = parsePositionH(posH);
|
|
449
475
|
const vertical = parsePositionV(posV);
|
|
450
476
|
let position;
|
|
@@ -470,6 +496,7 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
470
496
|
if (props.name !== void 0) image.docPrName = props.name;
|
|
471
497
|
if (props.alt !== void 0) image.alt = props.alt;
|
|
472
498
|
if (props.title !== void 0) image.title = props.title;
|
|
499
|
+
if (Object.keys(pictureNames).length > 0) image.pictureNames = pictureNames;
|
|
473
500
|
if (props.decorative !== void 0) image.decorative = props.decorative;
|
|
474
501
|
if (props.hidden !== void 0) image.hidden = props.hidden;
|
|
475
502
|
if (props.docPrExtensions !== void 0) image.docPrExtensions = props.docPrExtensions;
|
|
@@ -484,16 +511,11 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
484
511
|
if (opacity !== void 0) image.opacity = opacity;
|
|
485
512
|
if (effects !== void 0) image.effects = effects;
|
|
486
513
|
if (frameLocks) image.frameLocks = frameLocks;
|
|
487
|
-
if (
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
if (safeHref) {
|
|
493
|
-
image.hlinkHref = safeHref;
|
|
494
|
-
image.hlinkRId = hlink.relationship.id;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
514
|
+
if (anchor !== void 0) image.anchor = anchor;
|
|
515
|
+
Object.assign(image, safeDocPrLinks({
|
|
516
|
+
props,
|
|
517
|
+
rels
|
|
518
|
+
}));
|
|
497
519
|
return image;
|
|
498
520
|
}
|
|
499
521
|
/**
|
|
@@ -508,12 +530,10 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
508
530
|
*/
|
|
509
531
|
function parseDrawing(drawingEl, rels, media) {
|
|
510
532
|
if (isTextBoxDrawing(drawingEl)) return null;
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
return null;
|
|
533
|
+
const inline = findDrawingChild(drawingEl, "inline");
|
|
534
|
+
if (inline) return parseInline(inline, rels, media);
|
|
535
|
+
const anchor = findDrawingChild(drawingEl, "anchor");
|
|
536
|
+
return anchor ? parseAnchor(anchor, rels, media) : null;
|
|
517
537
|
}
|
|
518
538
|
/**
|
|
519
539
|
* Parse an image from a w:drawing element
|
package/dist/docx/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getCachedNumberingMap } from "./numberingParser.js";
|
|
2
2
|
import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError, DocxEncryptionErrorCode, isDocxEncryptionError } from "./encryption/errors.js";
|
|
3
3
|
import { DecryptDocxOptions, DecryptDocxResult, decryptDocxIfNeeded, openDocxBuffer } from "./encryption/openEncryptedDocx.js";
|
|
4
|
+
import { NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, ParagraphNumberingOverride, ParagraphNumberingSlots, ResolvedParagraphNumbering, isNumberingReference, mergeParagraphNumbering, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReferenceId, paragraphNumberingSlots, readParagraphNumbering, resolveParagraphNumbering, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering } from "./numberingReference.js";
|
|
4
5
|
import { FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FolioDocumentMetadataProperty, FolioDocumentPrivacyArchiveError, FolioDocumentPrivacyOptions, FolioDocumentPrivacyReport, FolioDocumentPrivacyTransform, InvalidFolioDocumentPrivacyOptionsError, RewriteDocxMetadataPrivacyResult, isFolioDocumentPrivacyTransform, rewriteDocxMetadataPrivacy } from "./metadataPrivacy.js";
|
|
5
|
-
export { DOCX_ENCRYPTION_ERROR_CODES, type DecryptDocxOptions, type DecryptDocxResult, DocxEncryptionError, type DocxEncryptionErrorCode, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, type FolioDocumentMetadataProperty, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, InvalidFolioDocumentPrivacyOptionsError, type RewriteDocxMetadataPrivacyResult, decryptDocxIfNeeded, getCachedNumberingMap, isDocxEncryptionError, isFolioDocumentPrivacyTransform, openDocxBuffer, rewriteDocxMetadataPrivacy };
|
|
6
|
+
export { DOCX_ENCRYPTION_ERROR_CODES, type DecryptDocxOptions, type DecryptDocxResult, DocxEncryptionError, type DocxEncryptionErrorCode, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, type FolioDocumentMetadataProperty, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, InvalidFolioDocumentPrivacyOptionsError, NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, type ParagraphNumberingOverride, type ParagraphNumberingSlots, type ResolvedParagraphNumbering, type RewriteDocxMetadataPrivacyResult, decryptDocxIfNeeded, getCachedNumberingMap, isDocxEncryptionError, isFolioDocumentPrivacyTransform, isNumberingReference, mergeParagraphNumbering, openDocxBuffer, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReferenceId, paragraphNumberingSlots, readParagraphNumbering, resolveParagraphNumbering, rewriteDocxMetadataPrivacy, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering };
|
package/dist/docx/index.js
CHANGED
|
@@ -2,4 +2,5 @@ import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError, isDocxEncryptionError
|
|
|
2
2
|
import { decryptDocxIfNeeded, openDocxBuffer } from "./encryption/openEncryptedDocx.js";
|
|
3
3
|
import { FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FolioDocumentPrivacyArchiveError, InvalidFolioDocumentPrivacyOptionsError, isFolioDocumentPrivacyTransform, rewriteDocxMetadataPrivacy } from "./metadataPrivacy.js";
|
|
4
4
|
import { getCachedNumberingMap } from "./numberingParser.js";
|
|
5
|
-
|
|
5
|
+
import { NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, isNumberingReference, mergeParagraphNumbering, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReferenceId, paragraphNumberingSlots, readParagraphNumbering, resolveParagraphNumbering, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering } from "./numberingReference.js";
|
|
6
|
+
export { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FolioDocumentPrivacyArchiveError, InvalidFolioDocumentPrivacyOptionsError, NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, decryptDocxIfNeeded, getCachedNumberingMap, isDocxEncryptionError, isFolioDocumentPrivacyTransform, isNumberingReference, mergeParagraphNumbering, openDocxBuffer, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReferenceId, paragraphNumberingSlots, readParagraphNumbering, resolveParagraphNumbering, rewriteDocxMetadataPrivacy, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InlineContentSlot } from "./paragraphTraversal.js";
|
|
2
|
+
//#region src/docx/inlineContentRemovals.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Positions marked for removal, per inline-content array.
|
|
5
|
+
*
|
|
6
|
+
* Removal shifts every later index in that array, so a normaliser records the
|
|
7
|
+
* positions while it reads and drops them once, after it has finished reading.
|
|
8
|
+
*/
|
|
9
|
+
declare class InlineContentRemovals {
|
|
10
|
+
#private;
|
|
11
|
+
mark({ content, index }: Pick<InlineContentSlot, "content" | "index">): void;
|
|
12
|
+
/**
|
|
13
|
+
* Applies every marked removal and answers how many items were dropped.
|
|
14
|
+
*
|
|
15
|
+
* Consolidation is re-run over each array a removal touched, because every
|
|
16
|
+
* inline item that is not a run is a merge boundary: `parseParagraph`
|
|
17
|
+
* consolidated the array while the removed item still stood between its
|
|
18
|
+
* neighbours, so dropping it leaves two runs adjacent that the next parse
|
|
19
|
+
* merges. That is an oscillation rather than a loss, save 1 writes the pair
|
|
20
|
+
* and save 2 writes one run, and it reaches every normaliser that removes an
|
|
21
|
+
* item, not only the one it was found through. Restoring the invariant here
|
|
22
|
+
* makes the parse a fixed point by construction; an array nothing was
|
|
23
|
+
* removed from is not touched.
|
|
24
|
+
*/
|
|
25
|
+
apply(): number;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { InlineContentRemovals };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { consolidateParagraphContent } from "./runConsolidator.js";
|
|
2
|
+
//#region src/docx/inlineContentRemovals.ts
|
|
3
|
+
/**
|
|
4
|
+
* Positions marked for removal, per inline-content array.
|
|
5
|
+
*
|
|
6
|
+
* Removal shifts every later index in that array, so a normaliser records the
|
|
7
|
+
* positions while it reads and drops them once, after it has finished reading.
|
|
8
|
+
*/
|
|
9
|
+
var InlineContentRemovals = class {
|
|
10
|
+
#byContent = /* @__PURE__ */ new Map();
|
|
11
|
+
mark({ content, index }) {
|
|
12
|
+
const indexes = this.#byContent.get(content);
|
|
13
|
+
if (indexes) {
|
|
14
|
+
indexes.add(index);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.#byContent.set(content, /* @__PURE__ */ new Set([index]));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Applies every marked removal and answers how many items were dropped.
|
|
21
|
+
*
|
|
22
|
+
* Consolidation is re-run over each array a removal touched, because every
|
|
23
|
+
* inline item that is not a run is a merge boundary: `parseParagraph`
|
|
24
|
+
* consolidated the array while the removed item still stood between its
|
|
25
|
+
* neighbours, so dropping it leaves two runs adjacent that the next parse
|
|
26
|
+
* merges. That is an oscillation rather than a loss, save 1 writes the pair
|
|
27
|
+
* and save 2 writes one run, and it reaches every normaliser that removes an
|
|
28
|
+
* item, not only the one it was found through. Restoring the invariant here
|
|
29
|
+
* makes the parse a fixed point by construction; an array nothing was
|
|
30
|
+
* removed from is not touched.
|
|
31
|
+
*/
|
|
32
|
+
apply() {
|
|
33
|
+
let removed = 0;
|
|
34
|
+
for (const [content, indexes] of this.#byContent) {
|
|
35
|
+
if (indexes.size === 0) continue;
|
|
36
|
+
const kept = content.filter((_, index) => !indexes.has(index));
|
|
37
|
+
removed += content.length - kept.length;
|
|
38
|
+
const next = consolidateParagraphContent(kept);
|
|
39
|
+
content.length = 0;
|
|
40
|
+
content.push(...next);
|
|
41
|
+
}
|
|
42
|
+
return removed;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { InlineContentRemovals };
|
|
@@ -45,11 +45,23 @@ declare const TRACKED_CHANGE_WRAPPER_CONTENT: {
|
|
|
45
45
|
* the bidirectional wrapper: OOXML allows runs, hyperlinks, simple/complex
|
|
46
46
|
* fields, nested SDTs, tracked insertions/deletions/moves, math, markup folio
|
|
47
47
|
* does not model, and the bidirectional controls directly inside
|
|
48
|
-
* `<w:sdtContent>`.
|
|
49
|
-
*
|
|
48
|
+
* `<w:sdtContent>`.
|
|
49
|
+
*
|
|
50
|
+
* The bookmark boundaries are admitted for the reason the revision wrapper
|
|
51
|
+
* admits them: `CT_SdtContentRun` reaches `EG_RangeMarkupElements` through
|
|
52
|
+
* `EG_RunLevelElts`, so the marker is valid where Word wrote it, and lifting
|
|
53
|
+
* it out changes what the bookmark covers. A range whose extent was the
|
|
54
|
+
* control's content comes back covering the control plus whatever follows, so
|
|
55
|
+
* a `REF` field or a link to it resolves to the wrong text.
|
|
56
|
+
*
|
|
57
|
+
* The other range markers are not: a `w:commentRangeStart` or a
|
|
58
|
+
* `w:moveFromRangeStart` inside the control is a marker the control does not
|
|
59
|
+
* own, and the pairing passes read it as a paragraph-level sibling.
|
|
50
60
|
*/
|
|
51
61
|
declare const INLINE_SDT_CONTENT: {
|
|
52
62
|
readonly inlineWrapper: true;
|
|
63
|
+
readonly bookmarkEnd: true;
|
|
64
|
+
readonly bookmarkStart: true;
|
|
53
65
|
readonly complexField: true;
|
|
54
66
|
readonly deletion: true;
|
|
55
67
|
readonly hyperlink: true;
|
|
@@ -61,15 +73,80 @@ declare const INLINE_SDT_CONTENT: {
|
|
|
61
73
|
readonly preservedInline: true;
|
|
62
74
|
readonly run: true;
|
|
63
75
|
readonly simpleField: true;
|
|
76
|
+
readonly commentRangeEnd: false;
|
|
77
|
+
readonly commentRangeStart: false;
|
|
78
|
+
readonly commentReference: false;
|
|
79
|
+
readonly moveFromRangeEnd: false;
|
|
80
|
+
readonly moveFromRangeStart: false;
|
|
81
|
+
readonly moveToRangeEnd: false;
|
|
82
|
+
readonly moveToRangeStart: false;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* What a `w:hyperlink` keeps inside itself (CT_Hyperlink).
|
|
86
|
+
*
|
|
87
|
+
* Runs, the bookmark boundaries a link's target sits on, markup folio does not
|
|
88
|
+
* model, and the four transparent wrappers: `CT_Hyperlink` is `EG_PContent`,
|
|
89
|
+
* which declares `w:bdo`, `w:dir`, `w:smartTag` and the run-level
|
|
90
|
+
* `w:customXml`, so `w:hyperlink > w:bdo > w:r` is a link an author may write
|
|
91
|
+
* and folio reads it as authored.
|
|
92
|
+
*
|
|
93
|
+
* A revision is not admitted, and the exclusion is the model's, not the
|
|
94
|
+
* schema's: OOXML nests `w:ins` inside `w:hyperlink` and folio nests the link
|
|
95
|
+
* inside the revision, so the paragraph parser hoists one around the link.
|
|
96
|
+
*/
|
|
97
|
+
declare const HYPERLINK_CONTENT: {
|
|
98
|
+
readonly bookmarkEnd: true;
|
|
99
|
+
readonly bookmarkStart: true;
|
|
100
|
+
readonly inlineWrapper: true;
|
|
101
|
+
readonly preservedInline: true;
|
|
102
|
+
readonly run: true;
|
|
103
|
+
readonly commentRangeEnd: false;
|
|
104
|
+
readonly commentRangeStart: false;
|
|
105
|
+
readonly commentReference: false;
|
|
106
|
+
readonly complexField: false;
|
|
107
|
+
readonly deletion: false;
|
|
108
|
+
readonly hyperlink: false;
|
|
109
|
+
readonly inlineSdt: false;
|
|
110
|
+
readonly insertion: false;
|
|
111
|
+
readonly mathEquation: false;
|
|
112
|
+
readonly moveFrom: false;
|
|
113
|
+
readonly moveFromRangeEnd: false;
|
|
114
|
+
readonly moveFromRangeStart: false;
|
|
115
|
+
readonly moveTo: false;
|
|
116
|
+
readonly moveToRangeEnd: false;
|
|
117
|
+
readonly moveToRangeStart: false;
|
|
118
|
+
readonly simpleField: false;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* What a `w:fldSimple` keeps inside itself (CT_SimpleField).
|
|
122
|
+
*
|
|
123
|
+
* The cached result's runs and the link one may carry, the same four
|
|
124
|
+
* transparent wrappers `EG_PContent` declares, and markup folio does not
|
|
125
|
+
* model. `w:fldData` is the field's own child rather than its content, so it
|
|
126
|
+
* rides `dispatchChildren`'s sink like any other capture.
|
|
127
|
+
*/
|
|
128
|
+
declare const SIMPLE_FIELD_CONTENT: {
|
|
129
|
+
readonly hyperlink: true;
|
|
130
|
+
readonly inlineWrapper: true;
|
|
131
|
+
readonly preservedInline: true;
|
|
132
|
+
readonly run: true;
|
|
64
133
|
readonly bookmarkEnd: false;
|
|
65
134
|
readonly bookmarkStart: false;
|
|
66
135
|
readonly commentRangeEnd: false;
|
|
67
136
|
readonly commentRangeStart: false;
|
|
68
137
|
readonly commentReference: false;
|
|
138
|
+
readonly complexField: false;
|
|
139
|
+
readonly deletion: false;
|
|
140
|
+
readonly inlineSdt: false;
|
|
141
|
+
readonly insertion: false;
|
|
142
|
+
readonly mathEquation: false;
|
|
143
|
+
readonly moveFrom: false;
|
|
69
144
|
readonly moveFromRangeEnd: false;
|
|
70
145
|
readonly moveFromRangeStart: false;
|
|
146
|
+
readonly moveTo: false;
|
|
71
147
|
readonly moveToRangeEnd: false;
|
|
72
148
|
readonly moveToRangeStart: false;
|
|
149
|
+
readonly simpleField: false;
|
|
73
150
|
};
|
|
74
151
|
/**
|
|
75
152
|
* Whether a revision wrapper keeps this content inside itself.
|
|
@@ -81,5 +158,9 @@ declare const INLINE_SDT_CONTENT: {
|
|
|
81
158
|
declare const isTrackedChangeWrapperChild: <Content extends document_d_exports.ParagraphContent>(content: Content) => content is Extract<Content, document_d_exports.TrackedRunContent>;
|
|
82
159
|
/** Whether an inline content control keeps this content inside `<w:sdtContent>`. */
|
|
83
160
|
declare const isInlineSdtContent: <Content extends document_d_exports.ParagraphContent>(content: Content) => content is Extract<Content, document_d_exports.InlineSdt["content"][number]>;
|
|
161
|
+
/** Whether a `w:hyperlink` keeps this content inside itself. */
|
|
162
|
+
declare const isHyperlinkContent: <Content extends document_d_exports.ParagraphContent>(content: Content) => content is Extract<Content, document_d_exports.Hyperlink["children"][number]>;
|
|
163
|
+
/** Whether a `w:fldSimple` keeps this content inside itself. */
|
|
164
|
+
declare const isSimpleFieldContent: <Content extends document_d_exports.ParagraphContent>(content: Content) => content is Extract<Content, document_d_exports.SimpleField["content"][number]>;
|
|
84
165
|
//#endregion
|
|
85
|
-
export { INLINE_SDT_CONTENT, TRACKED_CHANGE_WRAPPER_CONTENT, isInlineSdtContent, isTrackedChangeWrapperChild };
|
|
166
|
+
export { HYPERLINK_CONTENT, INLINE_SDT_CONTENT, SIMPLE_FIELD_CONTENT, TRACKED_CHANGE_WRAPPER_CONTENT, isHyperlinkContent, isInlineSdtContent, isSimpleFieldContent, isTrackedChangeWrapperChild };
|