@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
package/dist/docx/imageParser.js
CHANGED
|
@@ -1,34 +1,67 @@
|
|
|
1
|
+
import { normalizeImageLuminancePercent } from "../utils/imageLuminance.js";
|
|
1
2
|
import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
|
|
2
3
|
import { emuToPixels } from "../utils/units.js";
|
|
3
4
|
import { sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
4
|
-
import {
|
|
5
|
+
import { WORDPROCESSING_DRAWING_NAMESPACE_URIS, parseDrawingAnchor } from "./drawingAnchor.js";
|
|
6
|
+
import { findWrapElement, parseAnchorBehindDoc, parseDrawingEffectExtent, parseInlineWrap, parsePositionH, parsePositionV, parseWrapElement } from "./drawingUtils.js";
|
|
5
7
|
import { parseGraphicFrameLocks } from "./graphicFrameLocks.js";
|
|
6
8
|
import { parseNonVisualDrawingNames } from "./nonVisualDrawingProps.js";
|
|
7
9
|
import { RELATIONSHIP_TYPES, resolveRelationshipIdOfType } from "./relsParser.js";
|
|
8
10
|
import { isTextBoxDrawing } from "./textBoxParser.js";
|
|
11
|
+
import { percentageSpelling } from "./transitionalSpelling.js";
|
|
9
12
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
10
|
-
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";
|
|
11
15
|
//#region src/docx/imageParser.ts
|
|
12
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
|
+
*/
|
|
43
|
+
const DRAWINGML_MAIN_NAMESPACE_URIS = /* @__PURE__ */ new Set(["http://schemas.openxmlformats.org/drawingml/2006/main", "http://purl.oclc.org/ooxml/drawingml/main"]);
|
|
44
|
+
const FIXED_PERCENTAGE = /^-?\d+$/u;
|
|
45
|
+
/**
|
|
13
46
|
* Convert rotation value (1/60000 of a degree) to degrees
|
|
14
47
|
*
|
|
15
48
|
* @param rot - Rotation in 60000ths of a degree
|
|
16
49
|
* @returns Rotation in degrees
|
|
17
50
|
*/
|
|
18
51
|
function rotToDegrees(rot) {
|
|
19
|
-
if (
|
|
52
|
+
if (rot === null || rot === void 0) return;
|
|
20
53
|
const val = Number.parseInt(rot, 10);
|
|
21
54
|
if (Number.isNaN(val)) return;
|
|
22
55
|
return val / 6e4;
|
|
23
56
|
}
|
|
24
57
|
/**
|
|
25
|
-
*
|
|
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.
|
|
26
63
|
*/
|
|
27
|
-
|
|
28
|
-
const children = getChildElements(parent);
|
|
29
|
-
for (const child of children) if (names.includes(child.name || "")) return child;
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
64
|
+
const findDrawingChild = (parent, localName) => findChildByNamespaceUri(parent, WORDPROCESSING_DRAWING_NAMESPACE_URIS, localName);
|
|
32
65
|
/**
|
|
33
66
|
* Parse extent element for image size
|
|
34
67
|
*
|
|
@@ -46,26 +79,6 @@ function parseExtent(extent) {
|
|
|
46
79
|
};
|
|
47
80
|
}
|
|
48
81
|
/**
|
|
49
|
-
* Parse effect extent for shadow/effect margins
|
|
50
|
-
*
|
|
51
|
-
* @param effectExtent - wp:effectExtent element
|
|
52
|
-
* @returns Padding for effects
|
|
53
|
-
*/
|
|
54
|
-
function parseEffectExtent(effectExtent) {
|
|
55
|
-
if (!effectExtent) return;
|
|
56
|
-
const l = parseNumericAttribute(effectExtent, null, "l") ?? 0;
|
|
57
|
-
const t = parseNumericAttribute(effectExtent, null, "t") ?? 0;
|
|
58
|
-
const r = parseNumericAttribute(effectExtent, null, "r") ?? 0;
|
|
59
|
-
const b = parseNumericAttribute(effectExtent, null, "b") ?? 0;
|
|
60
|
-
if (l === 0 && t === 0 && r === 0 && b === 0) return;
|
|
61
|
-
return {
|
|
62
|
-
left: l,
|
|
63
|
-
top: t,
|
|
64
|
-
right: r,
|
|
65
|
-
bottom: b
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
82
|
* The `a:ext` uri under which Word records that a drawing is decorative. The
|
|
70
83
|
* extension holds `<adec:decorative val="…"/>`; `CT_NonVisualDrawingProps` has
|
|
71
84
|
* no `@decorative` attribute for it to be written as.
|
|
@@ -107,6 +120,22 @@ const parseDocPropsExtensions = (docPr) => {
|
|
|
107
120
|
return result;
|
|
108
121
|
};
|
|
109
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
|
+
/**
|
|
110
139
|
* Parse document properties (wp:docPr)
|
|
111
140
|
*
|
|
112
141
|
* @param docPr - wp:docPr element
|
|
@@ -118,31 +147,48 @@ function parseDocProps(docPr) {
|
|
|
118
147
|
const names = parseNonVisualDrawingNames(docPr);
|
|
119
148
|
const hidden = parseOnOffAttribute(docPr, null, "hidden");
|
|
120
149
|
const { decorative, other: docPrExtensions } = parseDocPropsExtensions(docPr);
|
|
121
|
-
const
|
|
122
|
-
const
|
|
150
|
+
const hlinkClickSource = parseDocPrLink(docPr, "hlinkClick");
|
|
151
|
+
const hlinkHoverSource = parseDocPrLink(docPr, "hlinkHover");
|
|
123
152
|
return {
|
|
124
153
|
...id != null ? { id } : {},
|
|
125
154
|
...names,
|
|
126
155
|
...decorative === void 0 ? {} : { decorative },
|
|
127
156
|
...hidden === void 0 ? {} : { hidden },
|
|
128
157
|
...docPrExtensions.length > 0 ? { docPrExtensions } : {},
|
|
129
|
-
...
|
|
158
|
+
...hlinkClickSource === void 0 ? {} : { hlinkClickSource },
|
|
159
|
+
...hlinkHoverSource === void 0 ? {} : { hlinkHoverSource }
|
|
130
160
|
};
|
|
131
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
|
+
};
|
|
132
179
|
/**
|
|
133
180
|
* Parse transform properties from a:xfrm
|
|
134
181
|
*/
|
|
135
182
|
function parseTransform(xfrm) {
|
|
136
183
|
if (!xfrm) return;
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
if (rotation === void 0 && !flipH && !flipV) return;
|
|
184
|
+
const flipH = parseOnOffValue(getAttribute(xfrm, null, "flipH"));
|
|
185
|
+
const flipV = parseOnOffValue(getAttribute(xfrm, null, "flipV"));
|
|
186
|
+
const rotation = rotToDegrees(getAttribute(xfrm, null, "rot"));
|
|
187
|
+
if (rotation === void 0 && flipH === void 0 && flipV === void 0) return;
|
|
142
188
|
const transform = {};
|
|
143
189
|
if (rotation !== void 0) transform.rotation = rotation;
|
|
144
|
-
if (flipH) transform.flipH =
|
|
145
|
-
if (flipV) transform.flipV =
|
|
190
|
+
if (flipH !== void 0) transform.flipH = flipH;
|
|
191
|
+
if (flipV !== void 0) transform.flipV = flipV;
|
|
146
192
|
return transform;
|
|
147
193
|
}
|
|
148
194
|
/**
|
|
@@ -154,13 +200,22 @@ function parseTransform(xfrm) {
|
|
|
154
200
|
* `a:srcRect` crop element, so callers that need either share this walk.
|
|
155
201
|
*/
|
|
156
202
|
function findBlipFillElement(container) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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;
|
|
164
219
|
}
|
|
165
220
|
/**
|
|
166
221
|
* Parse `<a:srcRect l="..." t="..." r="..." b="..."/>` inside `pic:blipFill`.
|
|
@@ -191,16 +246,6 @@ function parseImageCrop(blipFill) {
|
|
|
191
246
|
return crop;
|
|
192
247
|
}
|
|
193
248
|
/**
|
|
194
|
-
* Parse an OOXML `ST_OnOff` attribute on an element. Accepts the full
|
|
195
|
-
* set of literals the spec allows (`"1"`/`"true"`/`"on"` and
|
|
196
|
-
* `"0"`/`"false"`/`"off"`); anything else (including an absent
|
|
197
|
-
* attribute) folds back to `undefined` so callers can apply the
|
|
198
|
-
* spec-defined default.
|
|
199
|
-
*/
|
|
200
|
-
function parseOnOffAttr(element, name) {
|
|
201
|
-
return parseOnOffValue(getAttribute(element, null, name));
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
249
|
* Parse `<a:alphaModFix amt="..."/>` inside the `a:blip` element. The
|
|
205
250
|
* `amt` value is in 1/100000; convert to a fraction in [0, 1] for CSS
|
|
206
251
|
* `opacity`. Returns undefined when no alpha modifier is present (fully
|
|
@@ -219,6 +264,24 @@ function parseImageOpacity(blip) {
|
|
|
219
264
|
if (amt === void 0 || amt >= 1e5) return;
|
|
220
265
|
return Math.max(0, amt / 1e5);
|
|
221
266
|
}
|
|
267
|
+
const parseLuminancePercent = (luminance, attribute) => {
|
|
268
|
+
const raw = getAttribute(luminance, null, attribute);
|
|
269
|
+
if (raw === null) return;
|
|
270
|
+
const percent = percentageSpelling(raw) ?? (FIXED_PERCENTAGE.test(raw.trim()) ? Number(raw) / 1e3 : void 0);
|
|
271
|
+
return percent === void 0 || !Number.isFinite(percent) ? void 0 : normalizeImageLuminancePercent(percent);
|
|
272
|
+
};
|
|
273
|
+
/** Parse DrawingML `a:lum` into signed percentage values, preserving explicit zeroes. */
|
|
274
|
+
function parseImageLuminance(blip) {
|
|
275
|
+
const luminance = findChildByNamespaceUri(blip, DRAWINGML_MAIN_NAMESPACE_URIS, "lum");
|
|
276
|
+
if (!luminance) return;
|
|
277
|
+
const brightness = parseLuminancePercent(luminance, "bright");
|
|
278
|
+
const contrast = parseLuminancePercent(luminance, "contrast");
|
|
279
|
+
if (brightness === void 0 && contrast === void 0) return;
|
|
280
|
+
return {
|
|
281
|
+
...brightness === void 0 ? {} : { brightness },
|
|
282
|
+
...contrast === void 0 ? {} : { contrast }
|
|
283
|
+
};
|
|
284
|
+
}
|
|
222
285
|
/**
|
|
223
286
|
* Extract rId from a:blip element.
|
|
224
287
|
*
|
|
@@ -228,12 +291,7 @@ function parseImageOpacity(blip) {
|
|
|
228
291
|
*/
|
|
229
292
|
function extractBlipRId(blip) {
|
|
230
293
|
if (!blip) return;
|
|
231
|
-
|
|
232
|
-
if (rEmbed) return rEmbed;
|
|
233
|
-
const embed = getAttribute(blip, null, "embed");
|
|
234
|
-
if (embed) return embed;
|
|
235
|
-
const rLink = getAttribute(blip, "r", "link");
|
|
236
|
-
if (rLink) return rLink;
|
|
294
|
+
return relationshipIdOf(getAttribute(blip, "r", "embed")) ?? relationshipIdOf(getAttribute(blip, null, "embed")) ?? relationshipIdOf(getAttribute(blip, "r", "link"));
|
|
237
295
|
}
|
|
238
296
|
/**
|
|
239
297
|
* Find transform (a:xfrm) from picture shape properties
|
|
@@ -241,15 +299,7 @@ function extractBlipRId(blip) {
|
|
|
241
299
|
* Path: a:graphic > a:graphicData > pic:pic > pic:spPr > a:xfrm
|
|
242
300
|
*/
|
|
243
301
|
function findPictureTransform(container) {
|
|
244
|
-
|
|
245
|
-
if (!graphic) return null;
|
|
246
|
-
const graphicData = findByFullName(graphic, "a:graphicData");
|
|
247
|
-
if (!graphicData) return null;
|
|
248
|
-
const pic = findByFullName(graphicData, "pic:pic");
|
|
249
|
-
if (!pic) return null;
|
|
250
|
-
const spPr = findByFullName(pic, "pic:spPr");
|
|
251
|
-
if (!spPr) return null;
|
|
252
|
-
return findByFullName(spPr, "a:xfrm");
|
|
302
|
+
return findByFullName(findByFullName(findPictureElement(container), "pic:spPr"), "a:xfrm");
|
|
253
303
|
}
|
|
254
304
|
/**
|
|
255
305
|
* Normalize a target path to the standard word/media/... format
|
|
@@ -341,26 +391,20 @@ function resolveImageData(rId, rels, media) {
|
|
|
341
391
|
* @returns Parsed Image object
|
|
342
392
|
*/
|
|
343
393
|
function parseInline(inlineEl, rels, media) {
|
|
344
|
-
const size = parseExtent(
|
|
345
|
-
const padding =
|
|
346
|
-
const props = parseDocProps(
|
|
394
|
+
const size = parseExtent(findDrawingChild(inlineEl, "extent"));
|
|
395
|
+
const padding = parseDrawingEffectExtent(findDrawingChild(inlineEl, "effectExtent"));
|
|
396
|
+
const props = parseDocProps(findDrawingChild(inlineEl, "docPr"));
|
|
347
397
|
const frameLocks = parseGraphicFrameLocks(inlineEl);
|
|
398
|
+
const pictureNames = parseNonVisualDrawingNames(findPictureNonVisualProps(inlineEl));
|
|
348
399
|
const blipFill = findBlipFillElement(inlineEl);
|
|
349
400
|
const blip = blipFill ? findByFullName(blipFill, "a:blip") : null;
|
|
350
401
|
const rId = extractBlipRId(blip);
|
|
351
402
|
const crop = parseImageCrop(blipFill);
|
|
352
403
|
const opacity = parseImageOpacity(blip);
|
|
404
|
+
const effects = parseImageLuminance(blip);
|
|
353
405
|
const imageData = resolveImageData(rId, rels, media);
|
|
354
406
|
const transform = parseTransform(findPictureTransform(inlineEl));
|
|
355
|
-
const
|
|
356
|
-
const distB = parseNumericAttribute(inlineEl, null, "distB") ?? void 0;
|
|
357
|
-
const distL = parseNumericAttribute(inlineEl, null, "distL") ?? void 0;
|
|
358
|
-
const distR = parseNumericAttribute(inlineEl, null, "distR") ?? void 0;
|
|
359
|
-
const wrap = { type: "inline" };
|
|
360
|
-
if (distT !== void 0) wrap.distT = distT;
|
|
361
|
-
if (distB !== void 0) wrap.distB = distB;
|
|
362
|
-
if (distL !== void 0) wrap.distL = distL;
|
|
363
|
-
if (distR !== void 0) wrap.distR = distR;
|
|
407
|
+
const wrap = parseInlineWrap(inlineEl);
|
|
364
408
|
const image = {
|
|
365
409
|
type: "image",
|
|
366
410
|
...rId === void 0 ? {} : { rId },
|
|
@@ -371,6 +415,7 @@ function parseInline(inlineEl, rels, media) {
|
|
|
371
415
|
if (props.name !== void 0) image.docPrName = props.name;
|
|
372
416
|
if (props.alt !== void 0) image.alt = props.alt;
|
|
373
417
|
if (props.title !== void 0) image.title = props.title;
|
|
418
|
+
if (Object.keys(pictureNames).length > 0) image.pictureNames = pictureNames;
|
|
374
419
|
if (props.decorative !== void 0) image.decorative = props.decorative;
|
|
375
420
|
if (props.hidden !== void 0) image.hidden = props.hidden;
|
|
376
421
|
if (props.docPrExtensions !== void 0) image.docPrExtensions = props.docPrExtensions;
|
|
@@ -382,15 +427,12 @@ function parseInline(inlineEl, rels, media) {
|
|
|
382
427
|
if (transform) image.transform = transform;
|
|
383
428
|
if (crop) image.crop = crop;
|
|
384
429
|
if (opacity !== void 0) image.opacity = opacity;
|
|
430
|
+
if (effects !== void 0) image.effects = effects;
|
|
385
431
|
if (frameLocks) image.frameLocks = frameLocks;
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
image.hlinkHref = safeHref;
|
|
391
|
-
image.hlinkRId = hlink.relationship.id;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
432
|
+
Object.assign(image, safeDocPrLinks({
|
|
433
|
+
props,
|
|
434
|
+
rels
|
|
435
|
+
}));
|
|
394
436
|
return image;
|
|
395
437
|
}
|
|
396
438
|
/**
|
|
@@ -402,13 +444,14 @@ function parseInline(inlineEl, rels, media) {
|
|
|
402
444
|
* @returns Parsed Image object
|
|
403
445
|
*/
|
|
404
446
|
function parseAnchor(anchorEl, rels, media) {
|
|
405
|
-
const size = parseExtent(
|
|
406
|
-
const
|
|
407
|
-
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"));
|
|
408
451
|
const frameLocks = parseGraphicFrameLocks(anchorEl);
|
|
452
|
+
const pictureNames = parseNonVisualDrawingNames(findPictureNonVisualProps(anchorEl));
|
|
409
453
|
const behindDoc = parseAnchorBehindDoc(anchorEl);
|
|
410
|
-
const
|
|
411
|
-
const allowOverlap = parseOnOffAttr(anchorEl, "allowOverlap");
|
|
454
|
+
const anchor = parseDrawingAnchor(anchorEl);
|
|
412
455
|
const anchorDistT = parseNumericAttribute(anchorEl, null, "distT");
|
|
413
456
|
const anchorDistB = parseNumericAttribute(anchorEl, null, "distB");
|
|
414
457
|
const anchorDistL = parseNumericAttribute(anchorEl, null, "distL");
|
|
@@ -419,9 +462,15 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
419
462
|
...anchorDistL != null ? { distL: anchorDistL } : {},
|
|
420
463
|
...anchorDistR != null ? { distR: anchorDistR } : {}
|
|
421
464
|
};
|
|
422
|
-
const
|
|
423
|
-
const
|
|
424
|
-
|
|
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");
|
|
425
474
|
const horizontal = parsePositionH(posH);
|
|
426
475
|
const vertical = parsePositionV(posV);
|
|
427
476
|
let position;
|
|
@@ -434,6 +483,7 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
434
483
|
const rId = extractBlipRId(blip);
|
|
435
484
|
const crop = parseImageCrop(blipFill);
|
|
436
485
|
const opacity = parseImageOpacity(blip);
|
|
486
|
+
const effects = parseImageLuminance(blip);
|
|
437
487
|
const imageData = resolveImageData(rId, rels, media);
|
|
438
488
|
const transform = parseTransform(findPictureTransform(anchorEl));
|
|
439
489
|
const image = {
|
|
@@ -446,6 +496,7 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
446
496
|
if (props.name !== void 0) image.docPrName = props.name;
|
|
447
497
|
if (props.alt !== void 0) image.alt = props.alt;
|
|
448
498
|
if (props.title !== void 0) image.title = props.title;
|
|
499
|
+
if (Object.keys(pictureNames).length > 0) image.pictureNames = pictureNames;
|
|
449
500
|
if (props.decorative !== void 0) image.decorative = props.decorative;
|
|
450
501
|
if (props.hidden !== void 0) image.hidden = props.hidden;
|
|
451
502
|
if (props.docPrExtensions !== void 0) image.docPrExtensions = props.docPrExtensions;
|
|
@@ -458,17 +509,13 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
458
509
|
if (transform) image.transform = transform;
|
|
459
510
|
if (crop) image.crop = crop;
|
|
460
511
|
if (opacity !== void 0) image.opacity = opacity;
|
|
512
|
+
if (effects !== void 0) image.effects = effects;
|
|
461
513
|
if (frameLocks) image.frameLocks = frameLocks;
|
|
462
|
-
if (
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
if (safeHref) {
|
|
468
|
-
image.hlinkHref = safeHref;
|
|
469
|
-
image.hlinkRId = hlink.relationship.id;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
514
|
+
if (anchor !== void 0) image.anchor = anchor;
|
|
515
|
+
Object.assign(image, safeDocPrLinks({
|
|
516
|
+
props,
|
|
517
|
+
rels
|
|
518
|
+
}));
|
|
472
519
|
return image;
|
|
473
520
|
}
|
|
474
521
|
/**
|
|
@@ -483,12 +530,10 @@ function parseAnchor(anchorEl, rels, media) {
|
|
|
483
530
|
*/
|
|
484
531
|
function parseDrawing(drawingEl, rels, media) {
|
|
485
532
|
if (isTextBoxDrawing(drawingEl)) return null;
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
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;
|
|
492
537
|
}
|
|
493
538
|
/**
|
|
494
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 };
|