@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
|
@@ -1,28 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ParseContext } from "./parseContext.js";
|
|
2
3
|
import { XmlElement } from "./xmlParser.js";
|
|
3
4
|
//#region src/docx/drawingUtils.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Map normalized theme color slots back to DrawingML scheme color names.
|
|
6
|
-
* DrawingML uses bg1/bg2/tx1/tx2 where the document model uses descriptive names.
|
|
7
|
-
*/
|
|
8
|
-
declare const THEME_COLOR_TO_DRAWING_SCHEME: {
|
|
9
|
-
readonly dk1: "dk1";
|
|
10
|
-
readonly lt1: "lt1";
|
|
11
|
-
readonly dk2: "dk2";
|
|
12
|
-
readonly lt2: "lt2";
|
|
13
|
-
readonly accent1: "accent1";
|
|
14
|
-
readonly accent2: "accent2";
|
|
15
|
-
readonly accent3: "accent3";
|
|
16
|
-
readonly accent4: "accent4";
|
|
17
|
-
readonly accent5: "accent5";
|
|
18
|
-
readonly accent6: "accent6";
|
|
19
|
-
readonly hlink: "hlink";
|
|
20
|
-
readonly folHlink: "folHlink";
|
|
21
|
-
readonly background1: "bg1";
|
|
22
|
-
readonly text1: "tx1";
|
|
23
|
-
readonly background2: "bg2";
|
|
24
|
-
readonly text2: "tx2";
|
|
25
|
-
};
|
|
26
5
|
/**
|
|
27
6
|
* Parse a color value from a DrawingML element.
|
|
28
7
|
* Handles: a:srgbClr, a:schemeClr, a:sysClr, a:prstClr
|
|
@@ -36,10 +15,7 @@ declare function parseFill(spPr: XmlElement | null): document_d_exports.ShapeFil
|
|
|
36
15
|
/**
|
|
37
16
|
* Parse outline from shape properties (a:ln).
|
|
38
17
|
*/
|
|
39
|
-
declare function parseOutline(spPr: XmlElement | null): document_d_exports.ShapeOutline | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Parse horizontal position from wp:positionH element.
|
|
42
|
-
*/
|
|
18
|
+
declare function parseOutline(spPr: XmlElement | null, context?: ParseContext): document_d_exports.ShapeOutline | undefined;
|
|
43
19
|
declare function parsePositionH(posH: XmlElement | null): document_d_exports.ImagePosition["horizontal"] | undefined;
|
|
44
20
|
/**
|
|
45
21
|
* Parse vertical position from wp:positionV element.
|
|
@@ -49,21 +25,50 @@ declare function parsePositionV(posV: XmlElement | null): document_d_exports.Ima
|
|
|
49
25
|
* Parse position for anchored drawings (combines positionH + positionV).
|
|
50
26
|
*/
|
|
51
27
|
declare function parseAnchorPosition(anchor: XmlElement): document_d_exports.ImagePosition;
|
|
52
|
-
/**
|
|
53
|
-
declare
|
|
28
|
+
/** The `EG_WrapType` child of a `wp:anchor`, resolved by namespace. */
|
|
29
|
+
declare function findWrapElement(anchor: XmlElement): XmlElement | null;
|
|
30
|
+
/**
|
|
31
|
+
* `wp:effectExtent`'s four sides in EMU, exactly as the element states them.
|
|
32
|
+
*
|
|
33
|
+
* `CT_EffectExtent` requires all four, so a missing one is a malformed element
|
|
34
|
+
* rather than an unstated side, and zero is its own value: an explicit all-zero
|
|
35
|
+
* reservation on a wrap child says "this wrap reserves nothing", which is not
|
|
36
|
+
* what an absent element says.
|
|
37
|
+
*/
|
|
38
|
+
declare const parseEffectExtent: (el: XmlElement | null) => document_d_exports.ImagePadding | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The drawing's own `wp:effectExtent`, which is also what `Image.padding` holds.
|
|
41
|
+
*
|
|
42
|
+
* An all-zero reservation is what Word writes on a drawing with no effect, and
|
|
43
|
+
* a rebuild writes zeros for a drawing the record holds none for, so the two
|
|
44
|
+
* are the same document and neither the padding nor the slot keeps it. The wrap
|
|
45
|
+
* child's is read as authored instead: an absent one there inherits the
|
|
46
|
+
* drawing's, so an explicit all-zero says something an absent one does not.
|
|
47
|
+
*/
|
|
48
|
+
declare const parseDrawingEffectExtent: (el: XmlElement | null) => document_d_exports.ImagePadding | undefined;
|
|
49
|
+
/** The wrap insets `CT_Inline` carries, read the same way for every graphic. */
|
|
50
|
+
declare function parseInlineWrap(inlineEl: XmlElement): document_d_exports.ImageWrap;
|
|
51
|
+
type WrapElementOptions = {
|
|
52
|
+
/** The `EG_WrapType` child of the anchor, or null when it declared none. */
|
|
53
|
+
wrapEl: XmlElement | null;
|
|
54
|
+
/** `wp:anchor/@behindDoc`, which decides which side of the text a `wrapNone` sits on. */
|
|
55
|
+
behindDoc: boolean;
|
|
56
|
+
/** The insets `wp:anchor` itself states. */
|
|
57
|
+
anchorDistances?: document_d_exports.WrapDistances;
|
|
58
|
+
/** The `wp:effectExtent` `wp:anchor` itself states. */
|
|
59
|
+
anchorEffectExtent?: document_d_exports.ImagePadding;
|
|
60
|
+
};
|
|
54
61
|
/**
|
|
55
62
|
* Parse wrap settings from a wrap element.
|
|
56
63
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
64
|
+
* Both the insets and the effect extent are declared twice over — on the
|
|
65
|
+
* drawing and on the wrap child — and each is kept in the slot that stated it.
|
|
66
|
+
* The insets differ in that the wrap child's take priority as the value in
|
|
67
|
+
* force; the two effect extents are two values (the object's own reservation
|
|
68
|
+
* and the one the text flow is computed against), so neither overrides the
|
|
69
|
+
* other.
|
|
60
70
|
*/
|
|
61
|
-
declare function parseWrapElement(wrapEl
|
|
62
|
-
distT?: number;
|
|
63
|
-
distB?: number;
|
|
64
|
-
distL?: number;
|
|
65
|
-
distR?: number;
|
|
66
|
-
}): document_d_exports.ImageWrap;
|
|
71
|
+
declare function parseWrapElement({ wrapEl, behindDoc, anchorDistances, anchorEffectExtent }: WrapElementOptions): document_d_exports.ImageWrap;
|
|
67
72
|
/**
|
|
68
73
|
* Parse wrap from an anchor element (finds wrap child internally).
|
|
69
74
|
*/
|
|
@@ -81,4 +86,4 @@ declare function parseAnchorWrap(anchor: XmlElement): document_d_exports.ImageWr
|
|
|
81
86
|
*/
|
|
82
87
|
declare function resolveColorValueToHex(color: document_d_exports.ColorValue | undefined): string | undefined;
|
|
83
88
|
//#endregion
|
|
84
|
-
export {
|
|
89
|
+
export { WrapElementOptions, findWrapElement, parseAnchorBehindDoc, parseAnchorPosition, parseAnchorWrap, parseColorElement, parseDrawingEffectExtent, parseEffectExtent, parseFill, parseInlineWrap, parseOutline, parsePositionH, parsePositionV, parseWrapElement, resolveColorValueToHex };
|
|
@@ -1,51 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WORDPROCESSING_DRAWING_NAMESPACE_URIS } from "./drawingAnchor.js";
|
|
2
|
+
import { ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, narrowEnum } from "./parserEnums.js";
|
|
2
3
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
3
|
-
import {
|
|
4
|
+
import { findChildByLocalName, findChildByNamespaceUri, findChildrenByLocalName, getAttribute, getChildElements, getLocalName, getNamespaceUri, getTextContent, parseNumericAttribute, parseOnOffValue } from "./xmlParser.js";
|
|
5
|
+
import { PARSE_WARNING_CODES, THEME_COLOR_BY_SCHEME_COLOR_VALUE, isPresetLineDashVal, isSchemeColorValue, presetLineDashFrom, themeColorSlot } from "@stll/docx-core/model";
|
|
4
6
|
//#region src/docx/drawingUtils.ts
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
+
* Shared DrawingML Parsing Utilities
|
|
9
|
+
*
|
|
10
|
+
* Common functions used by imageParser and textBoxParser
|
|
11
|
+
* for parsing DrawingML elements (positions, wrapping, colors, fills, outlines).
|
|
8
12
|
*/
|
|
9
|
-
const SCHEME_TO_THEME_COLOR = {
|
|
10
|
-
accent1: "accent1",
|
|
11
|
-
accent2: "accent2",
|
|
12
|
-
accent3: "accent3",
|
|
13
|
-
accent4: "accent4",
|
|
14
|
-
accent5: "accent5",
|
|
15
|
-
accent6: "accent6",
|
|
16
|
-
dk1: "dk1",
|
|
17
|
-
lt1: "lt1",
|
|
18
|
-
dk2: "dk2",
|
|
19
|
-
lt2: "lt2",
|
|
20
|
-
tx1: "text1",
|
|
21
|
-
tx2: "text2",
|
|
22
|
-
bg1: "background1",
|
|
23
|
-
bg2: "background2",
|
|
24
|
-
hlink: "hlink",
|
|
25
|
-
folHlink: "folHlink"
|
|
26
|
-
};
|
|
27
13
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
14
|
+
* `a:schemeClr/@val` as a WordprocessingML theme colour, for the one DrawingML
|
|
15
|
+
* reference a document part carries inline.
|
|
16
|
+
*
|
|
17
|
+
* Both directions live in `@stll/docx-core/model`, total over their schema
|
|
18
|
+
* enumerations, so neither can omit a token.
|
|
30
19
|
*/
|
|
31
|
-
const
|
|
32
|
-
dk1: "dk1",
|
|
33
|
-
lt1: "lt1",
|
|
34
|
-
dk2: "dk2",
|
|
35
|
-
lt2: "lt2",
|
|
36
|
-
accent1: "accent1",
|
|
37
|
-
accent2: "accent2",
|
|
38
|
-
accent3: "accent3",
|
|
39
|
-
accent4: "accent4",
|
|
40
|
-
accent5: "accent5",
|
|
41
|
-
accent6: "accent6",
|
|
42
|
-
hlink: "hlink",
|
|
43
|
-
folHlink: "folHlink",
|
|
44
|
-
background1: "bg1",
|
|
45
|
-
text1: "tx1",
|
|
46
|
-
background2: "bg2",
|
|
47
|
-
text2: "tx2"
|
|
48
|
-
};
|
|
20
|
+
const schemeColorToThemeColor = (value) => isSchemeColorValue(value) ? THEME_COLOR_BY_SCHEME_COLOR_VALUE[value] ?? void 0 : void 0;
|
|
49
21
|
/**
|
|
50
22
|
* sRGB hex per OOXML (ST_HexColorRGB): exactly six hex digits, case-insensitive.
|
|
51
23
|
* Anything else is rejected so untrusted DOCX input cannot smuggle markup through
|
|
@@ -101,8 +73,8 @@ function parseColorElement(element) {
|
|
|
101
73
|
}
|
|
102
74
|
const schemeClr = children.find((el) => el.name === "a:schemeClr");
|
|
103
75
|
if (schemeClr) {
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
76
|
+
const themeColor = schemeColorToThemeColor(getAttribute(schemeClr, null, "val") ?? "");
|
|
77
|
+
if (themeColor !== void 0) return applyColorModifiers({ themeColor }, schemeClr);
|
|
106
78
|
}
|
|
107
79
|
const sysClr = children.find((el) => el.name === "a:sysClr");
|
|
108
80
|
if (sysClr) {
|
|
@@ -174,7 +146,7 @@ function parseGradientFill(gradientFill) {
|
|
|
174
146
|
/**
|
|
175
147
|
* Parse outline from shape properties (a:ln).
|
|
176
148
|
*/
|
|
177
|
-
function parseOutline(spPr) {
|
|
149
|
+
function parseOutline(spPr, context) {
|
|
178
150
|
const ln = spPr ? findChildByLocalName(spPr, "ln") : null;
|
|
179
151
|
if (!ln) return;
|
|
180
152
|
if (findChildByLocalName(ln, "noFill")) return;
|
|
@@ -197,9 +169,14 @@ function parseOutline(spPr) {
|
|
|
197
169
|
if (color !== void 0) outline.color = color;
|
|
198
170
|
}
|
|
199
171
|
const prstDash = findChildByLocalName(ln, "prstDash");
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (
|
|
172
|
+
const rawDash = prstDash ? getAttribute(prstDash, null, "val") : null;
|
|
173
|
+
if (rawDash) {
|
|
174
|
+
if (!isPresetLineDashVal(rawDash)) context?.warn({
|
|
175
|
+
code: PARSE_WARNING_CODES.outlineDashOutsideEnum,
|
|
176
|
+
element: prstDash?.name ?? "a:prstDash",
|
|
177
|
+
value: rawDash
|
|
178
|
+
});
|
|
179
|
+
outline.dash = presetLineDashFrom(rawDash);
|
|
203
180
|
}
|
|
204
181
|
const headEnd = findChildByLocalName(ln, "headEnd");
|
|
205
182
|
if (headEnd) outline.headEnd = parseLineEnd(headEnd);
|
|
@@ -231,10 +208,12 @@ function parseLineEnd(element) {
|
|
|
231
208
|
/**
|
|
232
209
|
* Parse horizontal position from wp:positionH element.
|
|
233
210
|
*/
|
|
211
|
+
/** A child of a WordprocessingDrawing element, resolved by namespace. */
|
|
212
|
+
const findDrawingChild = (parent, localName) => findChildByNamespaceUri(parent, WORDPROCESSING_DRAWING_NAMESPACE_URIS, localName);
|
|
234
213
|
function parsePositionH(posH) {
|
|
235
214
|
if (!posH) return;
|
|
236
215
|
const relativeTo = narrowEnum(getAttribute(posH, null, "relativeFrom"), ImageHorizontalRelativeToSchema) ?? "column";
|
|
237
|
-
const alignEl =
|
|
216
|
+
const alignEl = findDrawingChild(posH, "align");
|
|
238
217
|
if (alignEl) {
|
|
239
218
|
const alignment = narrowEnum(getTextContent(alignEl), ImageHorizontalAlignmentSchema);
|
|
240
219
|
if (alignment) return {
|
|
@@ -242,7 +221,7 @@ function parsePositionH(posH) {
|
|
|
242
221
|
alignment
|
|
243
222
|
};
|
|
244
223
|
}
|
|
245
|
-
const posOffsetEl =
|
|
224
|
+
const posOffsetEl = findDrawingChild(posH, "posOffset");
|
|
246
225
|
if (posOffsetEl) {
|
|
247
226
|
const text = getTextContent(posOffsetEl);
|
|
248
227
|
const posOffset = Number.parseInt(text, 10);
|
|
@@ -262,7 +241,7 @@ function parsePositionH(posH) {
|
|
|
262
241
|
function parsePositionV(posV) {
|
|
263
242
|
if (!posV) return;
|
|
264
243
|
const relativeTo = narrowEnum(getAttribute(posV, null, "relativeFrom"), ImageVerticalRelativeToSchema) ?? "paragraph";
|
|
265
|
-
const alignEl =
|
|
244
|
+
const alignEl = findDrawingChild(posV, "align");
|
|
266
245
|
if (alignEl) {
|
|
267
246
|
const alignment = narrowEnum(getTextContent(alignEl), ImageVerticalAlignmentSchema);
|
|
268
247
|
if (alignment) return {
|
|
@@ -270,7 +249,7 @@ function parsePositionV(posV) {
|
|
|
270
249
|
alignment
|
|
271
250
|
};
|
|
272
251
|
}
|
|
273
|
-
const posOffsetEl =
|
|
252
|
+
const posOffsetEl = findDrawingChild(posV, "posOffset");
|
|
274
253
|
if (posOffsetEl) {
|
|
275
254
|
const text = getTextContent(posOffsetEl);
|
|
276
255
|
const posOffset = Number.parseInt(text, 10);
|
|
@@ -288,8 +267,8 @@ function parsePositionV(posV) {
|
|
|
288
267
|
* Parse position for anchored drawings (combines positionH + positionV).
|
|
289
268
|
*/
|
|
290
269
|
function parseAnchorPosition(anchor) {
|
|
291
|
-
const positionH =
|
|
292
|
-
const positionV =
|
|
270
|
+
const positionH = findDrawingChild(anchor, "positionH");
|
|
271
|
+
const positionV = findDrawingChild(anchor, "positionV");
|
|
293
272
|
return {
|
|
294
273
|
horizontal: parsePositionH(positionH) ?? {
|
|
295
274
|
relativeTo: "column",
|
|
@@ -301,61 +280,176 @@ function parseAnchorPosition(anchor) {
|
|
|
301
280
|
}
|
|
302
281
|
};
|
|
303
282
|
}
|
|
304
|
-
/**
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
283
|
+
/**
|
|
284
|
+
* `EG_WrapType`'s members, by local name: the `wp` prefix is the producer's
|
|
285
|
+
* choice and a package free to bind the namespace elsewhere writes the same
|
|
286
|
+
* wrap.
|
|
287
|
+
*/
|
|
288
|
+
const WRAP_ELEMENT_LOCAL_NAMES = {
|
|
289
|
+
wrapNone: "inFront",
|
|
290
|
+
wrapSquare: "square",
|
|
291
|
+
wrapTight: "tight",
|
|
292
|
+
wrapThrough: "through",
|
|
293
|
+
wrapTopAndBottom: "topAndBottom"
|
|
294
|
+
};
|
|
295
|
+
/** The `EG_WrapType` child of a `wp:anchor`, resolved by namespace. */
|
|
296
|
+
function findWrapElement(anchor) {
|
|
297
|
+
for (const child of getChildElements(anchor)) if (getLocalName(child.name) in WRAP_ELEMENT_LOCAL_NAMES && WORDPROCESSING_DRAWING_NAMESPACE_URIS.has(getNamespaceUri(child) ?? "")) return child;
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
/** The inset attributes `CT_Inline`, `CT_Anchor` and the wrap children share. */
|
|
301
|
+
const WRAP_DISTANCE_KEYS = [
|
|
302
|
+
"distT",
|
|
303
|
+
"distB",
|
|
304
|
+
"distL",
|
|
305
|
+
"distR"
|
|
311
306
|
];
|
|
312
307
|
/**
|
|
308
|
+
* The insets one element states, or undefined when it states none.
|
|
309
|
+
*
|
|
310
|
+
* A wrap child's type declares a subset — `CT_WrapTight` and `CT_WrapThrough`
|
|
311
|
+
* only `distL`/`distR`, `CT_WrapTopBottom` only `distT`/`distB` — and an
|
|
312
|
+
* attribute the type does not declare cannot be present to read.
|
|
313
|
+
*/
|
|
314
|
+
const parseWrapDistances = (el) => {
|
|
315
|
+
if (!el) return;
|
|
316
|
+
const distances = {};
|
|
317
|
+
let stated = false;
|
|
318
|
+
for (const key of WRAP_DISTANCE_KEYS) {
|
|
319
|
+
const value = parseNumericAttribute(el, null, key);
|
|
320
|
+
if (value !== void 0) {
|
|
321
|
+
distances[key] = value;
|
|
322
|
+
stated = true;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return stated ? distances : void 0;
|
|
326
|
+
};
|
|
327
|
+
/** The slot record for a drawing, or undefined when neither element stated an inset. */
|
|
328
|
+
const wrapDistanceSlots = (drawing, wrapChild) => drawing === void 0 && wrapChild === void 0 ? void 0 : {
|
|
329
|
+
...drawing === void 0 ? {} : { drawing },
|
|
330
|
+
...wrapChild === void 0 ? {} : { wrapChild }
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* `wp:effectExtent`'s four sides in EMU, exactly as the element states them.
|
|
334
|
+
*
|
|
335
|
+
* `CT_EffectExtent` requires all four, so a missing one is a malformed element
|
|
336
|
+
* rather than an unstated side, and zero is its own value: an explicit all-zero
|
|
337
|
+
* reservation on a wrap child says "this wrap reserves nothing", which is not
|
|
338
|
+
* what an absent element says.
|
|
339
|
+
*/
|
|
340
|
+
const parseEffectExtent = (el) => el === null ? void 0 : {
|
|
341
|
+
left: parseNumericAttribute(el, null, "l") ?? 0,
|
|
342
|
+
top: parseNumericAttribute(el, null, "t") ?? 0,
|
|
343
|
+
right: parseNumericAttribute(el, null, "r") ?? 0,
|
|
344
|
+
bottom: parseNumericAttribute(el, null, "b") ?? 0
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* The drawing's own `wp:effectExtent`, which is also what `Image.padding` holds.
|
|
348
|
+
*
|
|
349
|
+
* An all-zero reservation is what Word writes on a drawing with no effect, and
|
|
350
|
+
* a rebuild writes zeros for a drawing the record holds none for, so the two
|
|
351
|
+
* are the same document and neither the padding nor the slot keeps it. The wrap
|
|
352
|
+
* child's is read as authored instead: an absent one there inherits the
|
|
353
|
+
* drawing's, so an explicit all-zero says something an absent one does not.
|
|
354
|
+
*/
|
|
355
|
+
const parseDrawingEffectExtent = (el) => {
|
|
356
|
+
const extent = parseEffectExtent(el);
|
|
357
|
+
if (extent === void 0) return;
|
|
358
|
+
return extent.left === 0 && extent.top === 0 && extent.right === 0 && extent.bottom === 0 ? void 0 : extent;
|
|
359
|
+
};
|
|
360
|
+
/** The slot record, or undefined when neither element stated an effect extent. */
|
|
361
|
+
const effectExtentSlots = (drawing, wrapChild) => drawing === void 0 && wrapChild === void 0 ? void 0 : {
|
|
362
|
+
...drawing === void 0 ? {} : { drawing },
|
|
363
|
+
...wrapChild === void 0 ? {} : { wrapChild }
|
|
364
|
+
};
|
|
365
|
+
/** The wrap insets `CT_Inline` carries, read the same way for every graphic. */
|
|
366
|
+
function parseInlineWrap(inlineEl) {
|
|
367
|
+
const wrap = { type: "inline" };
|
|
368
|
+
const drawing = parseWrapDistances(inlineEl);
|
|
369
|
+
for (const key of WRAP_DISTANCE_KEYS) {
|
|
370
|
+
const value = drawing?.[key];
|
|
371
|
+
if (value !== void 0) wrap[key] = value;
|
|
372
|
+
}
|
|
373
|
+
const slots = wrapDistanceSlots(drawing, void 0);
|
|
374
|
+
if (slots !== void 0) wrap.distanceSlots = slots;
|
|
375
|
+
const extents = effectExtentSlots(parseDrawingEffectExtent(findDrawingChild(inlineEl, "effectExtent")), void 0);
|
|
376
|
+
if (extents !== void 0) wrap.effectExtentSlots = extents;
|
|
377
|
+
return wrap;
|
|
378
|
+
}
|
|
379
|
+
/** A `CT_Point2D`, which requires both coordinates. */
|
|
380
|
+
const parseWrapPolygonPoint = (el) => {
|
|
381
|
+
const x = parseNumericAttribute(el, null, "x");
|
|
382
|
+
const y = parseNumericAttribute(el, null, "y");
|
|
383
|
+
return x === void 0 || y === void 0 ? void 0 : {
|
|
384
|
+
x,
|
|
385
|
+
y
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* `wp:wrapPolygon`, the outline `wp:wrapTight` and `wp:wrapThrough` require.
|
|
390
|
+
*
|
|
391
|
+
* Undefined when the element is absent or states no `wp:start`, which
|
|
392
|
+
* `CT_WrapPath` requires and a rebuild has nothing to write without. A path
|
|
393
|
+
* with fewer `wp:lineTo` than the type admits is kept as it stands: reading it
|
|
394
|
+
* as no polygon at all would hand the drawing the minted rectangle and move
|
|
395
|
+
* text the source flows through the object.
|
|
396
|
+
*/
|
|
397
|
+
const parseWrapPolygon = (wrapEl) => {
|
|
398
|
+
const polygonEl = findDrawingChild(wrapEl, "wrapPolygon");
|
|
399
|
+
if (!polygonEl) return;
|
|
400
|
+
const startEl = findDrawingChild(polygonEl, "start");
|
|
401
|
+
const start = parseWrapPolygonPoint(startEl);
|
|
402
|
+
if (start === void 0) return;
|
|
403
|
+
const lineTo = getChildElements(polygonEl).filter((child) => getLocalName(child.name) === "lineTo" && WORDPROCESSING_DRAWING_NAMESPACE_URIS.has(getNamespaceUri(child) ?? "")).flatMap((child) => {
|
|
404
|
+
const point = parseWrapPolygonPoint(child);
|
|
405
|
+
return point === void 0 ? [] : [point];
|
|
406
|
+
});
|
|
407
|
+
const edited = parseOnOffValue(getAttribute(polygonEl, null, "edited"));
|
|
408
|
+
return {
|
|
409
|
+
...edited === void 0 ? {} : { edited },
|
|
410
|
+
start,
|
|
411
|
+
lineTo
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
313
415
|
* Parse wrap settings from a wrap element.
|
|
314
416
|
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
417
|
+
* Both the insets and the effect extent are declared twice over — on the
|
|
418
|
+
* drawing and on the wrap child — and each is kept in the slot that stated it.
|
|
419
|
+
* The insets differ in that the wrap child's take priority as the value in
|
|
420
|
+
* force; the two effect extents are two values (the object's own reservation
|
|
421
|
+
* and the one the text flow is computed against), so neither overrides the
|
|
422
|
+
* other.
|
|
318
423
|
*/
|
|
319
|
-
function parseWrapElement(wrapEl, behindDoc, anchorDistances) {
|
|
424
|
+
function parseWrapElement({ wrapEl, behindDoc, anchorDistances, anchorEffectExtent }) {
|
|
425
|
+
const drawingDistances = anchorDistances !== void 0 && WRAP_DISTANCE_KEYS.some((key) => anchorDistances[key] != null) ? anchorDistances : void 0;
|
|
320
426
|
if (!wrapEl) {
|
|
321
427
|
const wrap = { type: behindDoc ? "behind" : "inFront" };
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
428
|
+
for (const key of WRAP_DISTANCE_KEYS) {
|
|
429
|
+
const value = drawingDistances?.[key];
|
|
430
|
+
if (value !== void 0) wrap[key] = value;
|
|
431
|
+
}
|
|
432
|
+
const slots = wrapDistanceSlots(drawingDistances, void 0);
|
|
433
|
+
if (slots !== void 0) wrap.distanceSlots = slots;
|
|
434
|
+
const extents = effectExtentSlots(anchorEffectExtent, void 0);
|
|
435
|
+
if (extents !== void 0) wrap.effectExtentSlots = extents;
|
|
326
436
|
return wrap;
|
|
327
437
|
}
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
switch (wrapType) {
|
|
331
|
-
case "wrapNone":
|
|
332
|
-
type = behindDoc ? "behind" : "inFront";
|
|
333
|
-
break;
|
|
334
|
-
case "wrapSquare":
|
|
335
|
-
type = "square";
|
|
336
|
-
break;
|
|
337
|
-
case "wrapTight":
|
|
338
|
-
type = "tight";
|
|
339
|
-
break;
|
|
340
|
-
case "wrapThrough":
|
|
341
|
-
type = "through";
|
|
342
|
-
break;
|
|
343
|
-
case "wrapTopAndBottom":
|
|
344
|
-
type = "topAndBottom";
|
|
345
|
-
break;
|
|
346
|
-
default: type = "square";
|
|
347
|
-
}
|
|
348
|
-
const wrap = { type };
|
|
438
|
+
const named = WRAP_ELEMENT_LOCAL_NAMES[getLocalName(wrapEl.name)] ?? "square";
|
|
439
|
+
const wrap = { type: named === "inFront" && behindDoc ? "behind" : named };
|
|
349
440
|
const wrapText = narrowEnum(getAttribute(wrapEl, null, "wrapText"), ImageWrapTextSchema);
|
|
350
441
|
if (wrapText) wrap.wrapText = wrapText;
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
|
|
442
|
+
const wrapChildDistances = parseWrapDistances(wrapEl);
|
|
443
|
+
for (const key of WRAP_DISTANCE_KEYS) {
|
|
444
|
+
const value = wrapChildDistances?.[key] ?? drawingDistances?.[key];
|
|
445
|
+
if (value !== void 0) wrap[key] = value;
|
|
446
|
+
}
|
|
447
|
+
const slots = wrapDistanceSlots(drawingDistances, wrapChildDistances);
|
|
448
|
+
if (slots !== void 0) wrap.distanceSlots = slots;
|
|
449
|
+
const extents = effectExtentSlots(anchorEffectExtent, parseEffectExtent(findDrawingChild(wrapEl, "effectExtent")));
|
|
450
|
+
if (extents !== void 0) wrap.effectExtentSlots = extents;
|
|
451
|
+
const polygon = parseWrapPolygon(wrapEl);
|
|
452
|
+
if (polygon !== void 0) wrap.polygon = polygon;
|
|
359
453
|
return wrap;
|
|
360
454
|
}
|
|
361
455
|
/**
|
|
@@ -371,20 +465,14 @@ function parseAnchorBehindDoc(anchor) {
|
|
|
371
465
|
return parseOnOffValue(getAttribute(anchor, null, "behindDoc")) ?? false;
|
|
372
466
|
}
|
|
373
467
|
function parseAnchorWrap(anchor) {
|
|
374
|
-
const
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
...distT != null ? { distT } : {},
|
|
383
|
-
...distB != null ? { distB } : {},
|
|
384
|
-
...distL != null ? { distL } : {},
|
|
385
|
-
...distR != null ? { distR } : {}
|
|
386
|
-
};
|
|
387
|
-
return parseWrapElement(wrapEl ?? null, behindDoc, anchorDistances);
|
|
468
|
+
const anchorDistances = parseWrapDistances(anchor);
|
|
469
|
+
const anchorEffectExtent = parseDrawingEffectExtent(findDrawingChild(anchor, "effectExtent"));
|
|
470
|
+
return parseWrapElement({
|
|
471
|
+
wrapEl: findWrapElement(anchor),
|
|
472
|
+
behindDoc: parseAnchorBehindDoc(anchor),
|
|
473
|
+
...anchorDistances === void 0 ? {} : { anchorDistances },
|
|
474
|
+
...anchorEffectExtent === void 0 ? {} : { anchorEffectExtent }
|
|
475
|
+
});
|
|
388
476
|
}
|
|
389
477
|
/**
|
|
390
478
|
* Default theme color fallbacks (Office 2016 defaults).
|
|
@@ -401,10 +489,6 @@ const DEFAULT_THEME_COLOR_HEX = {
|
|
|
401
489
|
lt1: "FFFFFF",
|
|
402
490
|
dk2: "1F497D",
|
|
403
491
|
lt2: "EEECE1",
|
|
404
|
-
text1: "000000",
|
|
405
|
-
text2: "1F497D",
|
|
406
|
-
background1: "FFFFFF",
|
|
407
|
-
background2: "EEECE1",
|
|
408
492
|
hlink: "0563C1",
|
|
409
493
|
folHlink: "954F72"
|
|
410
494
|
};
|
|
@@ -415,7 +499,10 @@ const DEFAULT_THEME_COLOR_HEX = {
|
|
|
415
499
|
function resolveColorValueToHex(color) {
|
|
416
500
|
if (!color) return;
|
|
417
501
|
if (color.rgb) return `#${color.rgb}`;
|
|
418
|
-
if (color.themeColor)
|
|
502
|
+
if (color.themeColor) {
|
|
503
|
+
const slot = themeColorSlot(color.themeColor);
|
|
504
|
+
return `#${slot === void 0 ? "000000" : DEFAULT_THEME_COLOR_HEX[slot]}`;
|
|
505
|
+
}
|
|
419
506
|
}
|
|
420
507
|
//#endregion
|
|
421
|
-
export {
|
|
508
|
+
export { findWrapElement, parseAnchorBehindDoc, parseAnchorPosition, parseAnchorWrap, parseColorElement, parseDrawingEffectExtent, parseEffectExtent, parseFill, parseInlineWrap, parseOutline, parsePositionH, parsePositionV, parseWrapElement, resolveColorValueToHex };
|