@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,5 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
+
import { ParseContext } from "./parseContext.js";
|
|
3
4
|
import { XmlElement } from "./xmlParser.js";
|
|
4
5
|
import { StyleMap } from "./styleParser.js";
|
|
5
6
|
//#region src/docx/textBoxParser.d.ts
|
|
@@ -42,9 +43,10 @@ declare function isShapeTextBox(wsp: XmlElement): boolean;
|
|
|
42
43
|
* parseTextBoxContent() separately with the required parsers.
|
|
43
44
|
*
|
|
44
45
|
* @param drawingEl - The w:drawing XML element
|
|
46
|
+
* @param context - Where an outline dash outside `ST_PresetLineDashVal` is reported
|
|
45
47
|
* @returns TextBox object with placeholder content, or null if not a text box
|
|
46
48
|
*/
|
|
47
|
-
declare function parseTextBox(drawingEl: XmlElement): document_d_exports.TextBox | null;
|
|
49
|
+
declare function parseTextBox(drawingEl: XmlElement, context?: ParseContext): document_d_exports.TextBox | null;
|
|
48
50
|
/**
|
|
49
51
|
* Parse text box content XML element
|
|
50
52
|
* @param wsp - The wps:wsp element containing the text box
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { emuToPixels } from "../utils/units.js";
|
|
2
|
-
import {
|
|
2
|
+
import { WORDPROCESSING_DRAWING_NAMESPACE_URIS, parseDrawingAnchor } from "./drawingAnchor.js";
|
|
3
|
+
import { parseAnchorPosition, parseAnchorWrap, parseFill, parseInlineWrap, parseOutline, resolveColorValueToHex } from "./drawingUtils.js";
|
|
3
4
|
import { parseNonVisualDrawingNames } from "./nonVisualDrawingProps.js";
|
|
4
5
|
import { findByFullName, findChildByLocalName, findChildByNamespaceUri, findChildrenByLocalName, findChildrenByNamespaceUri, findDeep, getAttribute, getChildElements, getLocalName, parseNumericAttribute, parseOnOffAttribute } from "./xmlParser.js";
|
|
5
6
|
//#region src/docx/textBoxParser.ts
|
|
@@ -98,11 +99,17 @@ function parseTextBoxContent(txbxContent, parseParagraph, parseTable, styles, th
|
|
|
98
99
|
return blocks;
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
102
|
+
* The `wp:inline` or `wp:anchor` a drawing hangs off, resolved by namespace:
|
|
103
|
+
* the `wp` prefix is the producer's choice and a package free to bind the
|
|
104
|
+
* namespace elsewhere writes the same text box.
|
|
105
|
+
*/
|
|
106
|
+
const findDrawingContainer = (drawingEl) => findChildByNamespaceUri(drawingEl, WORDPROCESSING_DRAWING_NAMESPACE_URIS, "inline") ?? findChildByNamespaceUri(drawingEl, WORDPROCESSING_DRAWING_NAMESPACE_URIS, "anchor");
|
|
107
|
+
/**
|
|
101
108
|
* Check if a drawing element contains a text box
|
|
102
109
|
* Text boxes are shapes with wps:txbx content
|
|
103
110
|
*/
|
|
104
111
|
function isTextBoxDrawing(drawingEl) {
|
|
105
|
-
const container =
|
|
112
|
+
const container = findDrawingContainer(drawingEl);
|
|
106
113
|
if (!container) return false;
|
|
107
114
|
const graphic = findByFullName(container, "a:graphic");
|
|
108
115
|
if (!graphic) return false;
|
|
@@ -127,12 +134,13 @@ function isShapeTextBox(wsp) {
|
|
|
127
134
|
* parseTextBoxContent() separately with the required parsers.
|
|
128
135
|
*
|
|
129
136
|
* @param drawingEl - The w:drawing XML element
|
|
137
|
+
* @param context - Where an outline dash outside `ST_PresetLineDashVal` is reported
|
|
130
138
|
* @returns TextBox object with placeholder content, or null if not a text box
|
|
131
139
|
*/
|
|
132
|
-
function parseTextBox(drawingEl) {
|
|
133
|
-
const container =
|
|
140
|
+
function parseTextBox(drawingEl, context) {
|
|
141
|
+
const container = findDrawingContainer(drawingEl);
|
|
134
142
|
if (!container) return null;
|
|
135
|
-
const isAnchor = container.name === "
|
|
143
|
+
const isAnchor = getLocalName(container.name) === "anchor";
|
|
136
144
|
const graphic = findByFullName(container, "a:graphic");
|
|
137
145
|
if (!graphic) return null;
|
|
138
146
|
const graphicData = findByFullName(graphic, "a:graphicData");
|
|
@@ -151,7 +159,7 @@ function parseTextBox(drawingEl) {
|
|
|
151
159
|
const id = docPr ? getAttribute(docPr, null, "id") ?? void 0 : void 0;
|
|
152
160
|
const names = parseNonVisualDrawingNames(docPr);
|
|
153
161
|
const fill = parseFill(spPr ?? null);
|
|
154
|
-
const outline = parseOutline(spPr ?? null);
|
|
162
|
+
const outline = parseOutline(spPr ?? null, context);
|
|
155
163
|
const bodyProps = parseBodyProperties(bodyPr ?? null);
|
|
156
164
|
const textBox = {
|
|
157
165
|
type: "textBox",
|
|
@@ -172,7 +180,9 @@ function parseTextBox(drawingEl) {
|
|
|
172
180
|
if (position) textBox.position = position;
|
|
173
181
|
const wrap = parseAnchorWrap(container);
|
|
174
182
|
if (wrap) textBox.wrap = wrap;
|
|
175
|
-
|
|
183
|
+
const anchor = parseDrawingAnchor(container);
|
|
184
|
+
if (anchor) textBox.anchor = anchor;
|
|
185
|
+
} else textBox.wrap = parseInlineWrap(container);
|
|
176
186
|
return textBox;
|
|
177
187
|
}
|
|
178
188
|
/**
|
|
@@ -290,7 +300,7 @@ const getTextBoxBlockText = (block) => {
|
|
|
290
300
|
return runTexts.join("");
|
|
291
301
|
}
|
|
292
302
|
if (block.type === "table") return block.rows.map((row) => row.cells.map((cell) => cell.content.map(getTextBoxBlockText).join("\n")).join(" ")).join("\n");
|
|
293
|
-
if (block.type
|
|
303
|
+
if (block.type !== "blockSdt") return "";
|
|
294
304
|
return block.content.map(getTextBoxBlockText).join("\n");
|
|
295
305
|
};
|
|
296
306
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ParseContext } from "./parseContext.js";
|
|
2
|
+
import { ThemeColorValue } from "@stll/docx-core/model";
|
|
3
|
+
//#region src/docx/themeColorAttribute.d.ts
|
|
4
|
+
type ThemeColorAttributeOptions = {
|
|
5
|
+
/** The attribute as written, or `null` when the element does not carry it. */
|
|
6
|
+
raw: string | null | undefined;
|
|
7
|
+
/** The element the attribute sits on, for the warning's location. */
|
|
8
|
+
element?: string | undefined;
|
|
9
|
+
context?: ParseContext | undefined;
|
|
10
|
+
};
|
|
11
|
+
declare const parseThemeColorAttribute: ({ raw, element, context }: ThemeColorAttributeOptions) => ThemeColorValue | undefined;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ThemeColorAttributeOptions, parseThemeColorAttribute };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PARSE_WARNING_CODES, readThemeColor } from "@stll/docx-core/model";
|
|
2
|
+
//#region src/docx/themeColorAttribute.ts
|
|
3
|
+
/**
|
|
4
|
+
* The one reader for a theme-colour attribute.
|
|
5
|
+
*
|
|
6
|
+
* `w:themeColor`, `w:themeFill` and the `w:clrSchemeMapping` values are all
|
|
7
|
+
* `ST_ThemeColor`. Before this the attribute was narrowed against a union that
|
|
8
|
+
* carried DrawingML slot names instead, so `hyperlink` — the token Word writes
|
|
9
|
+
* for a hyperlink's colour — failed to narrow and the attribute was dropped at
|
|
10
|
+
* parse time, taking it out of the next save. The enumeration is now generated
|
|
11
|
+
* from the schema, and a token outside it is captured rather than refused, the
|
|
12
|
+
* way `CT_Border/@w:val` already keeps a style outside `ST_Border`.
|
|
13
|
+
*/
|
|
14
|
+
const parseThemeColorAttribute = ({ raw, element, context }) => {
|
|
15
|
+
const value = readThemeColor(raw);
|
|
16
|
+
if (value !== void 0 && typeof value !== "string") context?.warn({
|
|
17
|
+
code: PARSE_WARNING_CODES.unrecognisedThemeColor,
|
|
18
|
+
value: value.raw,
|
|
19
|
+
...element === void 0 ? {} : { element }
|
|
20
|
+
});
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { parseThemeColorAttribute };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { InlineContentRemovals
|
|
1
|
+
import { InlineContentRemovals } from "./inlineContentRemovals.js";
|
|
2
|
+
import { visitDocxParagraphs, visitInlineContentSlots } from "./paragraphTraversal.js";
|
|
2
3
|
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
3
4
|
//#region src/docx/trackedMoveRangeNormalization.ts
|
|
4
5
|
/** The code this normalisation is reported under, owned here, not at the caller. */
|
|
@@ -5,10 +5,19 @@ import { XmlElement } from "./xmlParser.js";
|
|
|
5
5
|
* Whether a `w:pict` that resolved to no image must still be kept verbatim.
|
|
6
6
|
*
|
|
7
7
|
* VML has no serializer of its own, so an unresolved `w:pict` is only ever
|
|
8
|
-
* preserved or lost.
|
|
9
|
-
* text-box enrichment pass, which rebuilds it as an editable shape, and
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* preserved or lost. One owner is excluded: a `v:textbox` belongs to the
|
|
9
|
+
* text-box enrichment pass, which rebuilds it as an editable shape, and
|
|
10
|
+
* preserving it here as well would emit the same artwork twice.
|
|
11
|
+
*
|
|
12
|
+
* A watermark shape is not a second exclusion. Declining for one was a guess
|
|
13
|
+
* about another module, and `watermarkParser` claims by a far narrower rule
|
|
14
|
+
* than `isWatermarkShape` states: a direct `v:shape` child of a `w:pict`,
|
|
15
|
+
* carrying a non-empty `v:textpath` or a `v:imagedata`, alone in its paragraph,
|
|
16
|
+
* in a header. A `v:oval`, a shape nested in a `v:group`, a shape sharing its
|
|
17
|
+
* paragraph with text, and every `w:pict` in a footer or in the body fall
|
|
18
|
+
* outside it, so their artwork was declined here and claimed by no one. The
|
|
19
|
+
* watermark owner removes its own artwork from the model instead, by emptying
|
|
20
|
+
* the paragraph it detached, so this predicate need not guess who claimed what.
|
|
12
21
|
*/
|
|
13
22
|
declare function shouldPreserveRawVmlPict(pictElement: XmlElement): boolean;
|
|
14
23
|
/**
|
|
@@ -1,12 +1,45 @@
|
|
|
1
1
|
import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
|
|
2
2
|
import { pixelsToEmu } from "../utils/units.js";
|
|
3
3
|
import { resolveImageData } from "./imageParser.js";
|
|
4
|
+
import { imageRawXmlFingerprint } from "./imageRawXml.js";
|
|
4
5
|
import { PREVIEW_KINDS } from "./previewBudget.js";
|
|
5
6
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
6
7
|
import { isValidVmlPreviewDimension, parseVmlNumber, parseVmlStyle, renderStandaloneVmlPreview, renderVmlGroupPreview, vmlCssLengthToPx, vmlSvgDataUrl } from "./vmlPreview.js";
|
|
7
8
|
import { isWatermarkShape } from "./watermarkParser.js";
|
|
8
9
|
import { cloneWithXmlnsDeclarations, findAllDeep, findChild, findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
|
|
10
|
+
import { DRAWING_RAW_XML_MODES, relationshipIdOf } from "@stll/docx-core/model";
|
|
9
11
|
//#region src/docx/vmlImageParser.ts
|
|
12
|
+
/**
|
|
13
|
+
* VML image parser — legacy `w:pict` inline pictures.
|
|
14
|
+
*
|
|
15
|
+
* Older Word documents (and some exporters) embed inline pictures such as
|
|
16
|
+
* header logos as VML instead of DrawingML:
|
|
17
|
+
*
|
|
18
|
+
* <w:r><w:pict>
|
|
19
|
+
* <v:shape id="Picture 1" type="#_x0000_t75" style="width:120pt;height:40pt">
|
|
20
|
+
* <v:imagedata r:id="rId7" o:title="logo"/>
|
|
21
|
+
* </v:shape>
|
|
22
|
+
* </w:pict></w:r>
|
|
23
|
+
*
|
|
24
|
+
* The run parser used to drop `w:pict` entirely, so these pictures never
|
|
25
|
+
* rendered. This resolves `<v:imagedata r:id>` to the same media part a
|
|
26
|
+
* DrawingML image uses and produces the identical `DrawingContent` / `Image`
|
|
27
|
+
* node, so the rest of the pipeline (ProseMirror conversion, layout, painter)
|
|
28
|
+
* renders it through the existing inline-image path.
|
|
29
|
+
*
|
|
30
|
+
* The original VML is preserved verbatim on the returned drawing's `rawXml`:
|
|
31
|
+
* the serializer has no VML synthesis path (it only emits DrawingML), so
|
|
32
|
+
* without this a `w:pict` would round-trip as a `<w:drawing>`. Emitting the
|
|
33
|
+
* captured XML keeps save byte-for-byte for these runs.
|
|
34
|
+
*
|
|
35
|
+
* A watermark `watermarkParser` claimed is detached from its hosting
|
|
36
|
+
* paragraph, so modelling it here as well would paint it twice; the
|
|
37
|
+
* `isWatermarkShape` guard below keeps this reader off that shape. It does not
|
|
38
|
+
* decide whether the markup survives: what nothing claims is preserved
|
|
39
|
+
* verbatim by `shouldPreserveRawVmlPict`.
|
|
40
|
+
*
|
|
41
|
+
* Ported from eigenpal/docx-editor `vmlImageParser.ts`.
|
|
42
|
+
*/
|
|
10
43
|
const VML_POSITION_ABSOLUTE = "absolute";
|
|
11
44
|
const IMAGE_WRAP_INLINE = "inline";
|
|
12
45
|
const IMAGE_WRAP_BEHIND = "behind";
|
|
@@ -68,31 +101,33 @@ const previewImage = (pictElement, svg, widthPx, heightPx, style, rootXmlns) =>
|
|
|
68
101
|
const horizontalRelative = style["mso-position-horizontal-relative"] === "page";
|
|
69
102
|
const verticalRelative = style["mso-position-vertical-relative"] === "page";
|
|
70
103
|
const zIndex = parseVmlNumber(style["z-index"]);
|
|
71
|
-
|
|
72
|
-
type: "
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
const image = {
|
|
105
|
+
type: "image",
|
|
106
|
+
src,
|
|
107
|
+
mimeType: PREVIEW_KINDS.vmlShape.mimeType,
|
|
108
|
+
filename: PREVIEW_KINDS.vmlShape.filename,
|
|
109
|
+
size: {
|
|
110
|
+
width: pixelsToEmu(widthPx),
|
|
111
|
+
height: pixelsToEmu(heightPx)
|
|
112
|
+
},
|
|
113
|
+
wrap: { type: zIndex !== void 0 && zIndex >= 0 ? "inFront" : "behind" },
|
|
114
|
+
position: {
|
|
115
|
+
horizontal: {
|
|
116
|
+
relativeTo: horizontalRelative ? "page" : "character",
|
|
117
|
+
posOffset: pixelsToSafeEmu(leftPx) ?? 0
|
|
82
118
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
relativeTo: horizontalRelative ? "page" : "character",
|
|
87
|
-
posOffset: pixelsToSafeEmu(leftPx) ?? 0
|
|
88
|
-
},
|
|
89
|
-
vertical: {
|
|
90
|
-
relativeTo: verticalRelative ? "page" : "paragraph",
|
|
91
|
-
posOffset: pixelsToSafeEmu(topPx) ?? 0
|
|
92
|
-
}
|
|
119
|
+
vertical: {
|
|
120
|
+
relativeTo: verticalRelative ? "page" : "paragraph",
|
|
121
|
+
posOffset: pixelsToSafeEmu(topPx) ?? 0
|
|
93
122
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
type: "drawing",
|
|
127
|
+
image,
|
|
128
|
+
rawXml: captureVerbatimXml(cloneWithXmlnsDeclarations(pictElement, rootXmlns)),
|
|
129
|
+
rawImageFingerprint: imageRawXmlFingerprint(image),
|
|
130
|
+
rawXmlMode: DRAWING_RAW_XML_MODES.PREVIEW_ONLY
|
|
96
131
|
};
|
|
97
132
|
};
|
|
98
133
|
const previewDrawing = (pictElement, preview, rootXmlns) => {
|
|
@@ -120,15 +155,23 @@ const VML_DRAWABLE_SHAPES = [
|
|
|
120
155
|
* Whether a `w:pict` that resolved to no image must still be kept verbatim.
|
|
121
156
|
*
|
|
122
157
|
* VML has no serializer of its own, so an unresolved `w:pict` is only ever
|
|
123
|
-
* preserved or lost.
|
|
124
|
-
* text-box enrichment pass, which rebuilds it as an editable shape, and
|
|
125
|
-
*
|
|
126
|
-
*
|
|
158
|
+
* preserved or lost. One owner is excluded: a `v:textbox` belongs to the
|
|
159
|
+
* text-box enrichment pass, which rebuilds it as an editable shape, and
|
|
160
|
+
* preserving it here as well would emit the same artwork twice.
|
|
161
|
+
*
|
|
162
|
+
* A watermark shape is not a second exclusion. Declining for one was a guess
|
|
163
|
+
* about another module, and `watermarkParser` claims by a far narrower rule
|
|
164
|
+
* than `isWatermarkShape` states: a direct `v:shape` child of a `w:pict`,
|
|
165
|
+
* carrying a non-empty `v:textpath` or a `v:imagedata`, alone in its paragraph,
|
|
166
|
+
* in a header. A `v:oval`, a shape nested in a `v:group`, a shape sharing its
|
|
167
|
+
* paragraph with text, and every `w:pict` in a footer or in the body fall
|
|
168
|
+
* outside it, so their artwork was declined here and claimed by no one. The
|
|
169
|
+
* watermark owner removes its own artwork from the model instead, by emptying
|
|
170
|
+
* the paragraph it detached, so this predicate need not guess who claimed what.
|
|
127
171
|
*/
|
|
128
172
|
function shouldPreserveRawVmlPict(pictElement) {
|
|
129
173
|
if (findDeep(pictElement, "v", "textbox")) return false;
|
|
130
|
-
|
|
131
|
-
return shapes.length > 0 && !shapes.some((shape) => isWatermarkShape(shape));
|
|
174
|
+
return VML_DRAWABLE_SHAPES.some((localName) => findDeep(pictElement, "v", localName) !== null);
|
|
132
175
|
}
|
|
133
176
|
/**
|
|
134
177
|
* Whether the run parser turns this `w:pict` into run content of its own.
|
|
@@ -173,8 +216,8 @@ function parseVmlImageContent(pictElement, rels, media, rootXmlns = {}) {
|
|
|
173
216
|
for (const shape of shapes) {
|
|
174
217
|
const imagedata = findChild(shape, "v", "imagedata");
|
|
175
218
|
if (!imagedata) continue;
|
|
176
|
-
const rId = readImageDataRId(imagedata);
|
|
177
|
-
if (rId === void 0
|
|
219
|
+
const rId = relationshipIdOf(readImageDataRId(imagedata));
|
|
220
|
+
if (rId === void 0) continue;
|
|
178
221
|
if (isWatermarkShape(shape)) continue;
|
|
179
222
|
const { src, mimeType, filename } = resolveImageData(rId, rels ?? void 0, media ?? void 0);
|
|
180
223
|
const shapeStyle = parseVmlStyle(getAttribute(shape, null, "style"));
|
package/dist/docx/vmlPreview.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PREVIEW_KINDS } from "./previewBudget.js";
|
|
2
2
|
import { findChild, findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
|
|
3
3
|
//#region src/docx/vmlPreview.ts
|
|
4
4
|
const MAX_VML_PREVIEW_DEPTH = 16;
|
|
@@ -84,7 +84,7 @@ const parseVmlNumber = (raw) => {
|
|
|
84
84
|
/** Check a physical preview dimension against the retained SVG layout bound. */
|
|
85
85
|
const isValidVmlPreviewDimension = (value) => value !== void 0 && value > 0 && value <= MAX_VML_PREVIEW_DIMENSION_PX;
|
|
86
86
|
/** Encode a generated, already-sanitized SVG without exceeding its output cap. */
|
|
87
|
-
const vmlSvgDataUrl = (svg) => svg.length <= MAX_VML_SVG_CHARACTERS ? `${
|
|
87
|
+
const vmlSvgDataUrl = (svg) => svg.length <= MAX_VML_SVG_CHARACTERS ? `${PREVIEW_KINDS.vmlShape.srcPrefix}${encodeURIComponent(svg)}` : void 0;
|
|
88
88
|
const validCoordinate = (value) => value !== void 0 && Math.abs(value) <= MAX_VML_PREVIEW_COORDINATE;
|
|
89
89
|
const validExtent = (value) => value !== void 0 && value > 0 && value <= MAX_VML_PREVIEW_COORDINATE;
|
|
90
90
|
const coordinatePair = (raw) => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
//#region src/docx/wrapPolygon.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The polygon a `wp:wrapTight` or `wp:wrapThrough` states: the authored one, or
|
|
5
|
+
* the rectangle when the model holds none.
|
|
6
|
+
*
|
|
7
|
+
* An authored path is written back as it stands, including one shorter than
|
|
8
|
+
* `CT_WrapPath`'s two `wp:lineTo`. folio is not the validator of its input, and
|
|
9
|
+
* replacing a short outline with the full extent of the drawing would move text
|
|
10
|
+
* that the source flows through the object — the same silent substitution this
|
|
11
|
+
* module exists to end. The rectangle is minted only where the alternative is
|
|
12
|
+
* omitting a child the type requires.
|
|
13
|
+
*/
|
|
14
|
+
declare const requiredWrapPolygon: (authored: document_d_exports.ImageWrapPolygon | undefined) => document_d_exports.ImageWrapPolygon;
|
|
15
|
+
/**
|
|
16
|
+
* The polygon a wrap of `type` has to state, or undefined when its type
|
|
17
|
+
* declares none.
|
|
18
|
+
*
|
|
19
|
+
* The editor command that changes a wrap type calls this, so a drawing that
|
|
20
|
+
* becomes tight or through is minted its rectangle once — at the edit, as a
|
|
21
|
+
* fact of the document the author can see and undo — and every save after that
|
|
22
|
+
* writes back what the model then holds.
|
|
23
|
+
*/
|
|
24
|
+
declare const wrapPolygonFor: (type: document_d_exports.ImageWrap["type"], authored: document_d_exports.ImageWrapPolygon | undefined) => document_d_exports.ImageWrapPolygon | undefined;
|
|
25
|
+
/** A copy, deep enough that a ProseMirror attr cannot share a point with the model. */
|
|
26
|
+
declare const copiedWrapPolygon: (polygon: document_d_exports.ImageWrapPolygon | undefined) => document_d_exports.ImageWrapPolygon | undefined;
|
|
27
|
+
/** `wp:wrapPolygon`, written from a polygon {@link wrapPolygonFor} has approved. */
|
|
28
|
+
declare const serializeWrapPolygon: (polygon: document_d_exports.ImageWrapPolygon) => string;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { copiedWrapPolygon, requiredWrapPolygon, serializeWrapPolygon, wrapPolygonFor };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { intAttr } from "./serializer/xmlUtils.js";
|
|
2
|
+
//#region src/docx/wrapPolygon.ts
|
|
3
|
+
/** `CT_WrapPath` coordinates are relative to a box of this many units. */
|
|
4
|
+
const WRAP_PATH_EXTENT = 21600;
|
|
5
|
+
/**
|
|
6
|
+
* The whole drawing, as a closed rectangle in the path's relative space: the
|
|
7
|
+
* polygon that leaves text flowing exactly as the wrap's bounding box would.
|
|
8
|
+
* The only wrap outline folio invents.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_WRAP_POLYGON = {
|
|
11
|
+
edited: false,
|
|
12
|
+
start: {
|
|
13
|
+
x: 0,
|
|
14
|
+
y: 0
|
|
15
|
+
},
|
|
16
|
+
lineTo: [
|
|
17
|
+
{
|
|
18
|
+
x: 0,
|
|
19
|
+
y: WRAP_PATH_EXTENT
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
x: WRAP_PATH_EXTENT,
|
|
23
|
+
y: WRAP_PATH_EXTENT
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
x: WRAP_PATH_EXTENT,
|
|
27
|
+
y: 0
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The polygon a `wp:wrapTight` or `wp:wrapThrough` states: the authored one, or
|
|
37
|
+
* the rectangle when the model holds none.
|
|
38
|
+
*
|
|
39
|
+
* An authored path is written back as it stands, including one shorter than
|
|
40
|
+
* `CT_WrapPath`'s two `wp:lineTo`. folio is not the validator of its input, and
|
|
41
|
+
* replacing a short outline with the full extent of the drawing would move text
|
|
42
|
+
* that the source flows through the object — the same silent substitution this
|
|
43
|
+
* module exists to end. The rectangle is minted only where the alternative is
|
|
44
|
+
* omitting a child the type requires.
|
|
45
|
+
*/
|
|
46
|
+
const requiredWrapPolygon = (authored) => authored ?? DEFAULT_WRAP_POLYGON;
|
|
47
|
+
/**
|
|
48
|
+
* The polygon a wrap of `type` has to state, or undefined when its type
|
|
49
|
+
* declares none.
|
|
50
|
+
*
|
|
51
|
+
* The editor command that changes a wrap type calls this, so a drawing that
|
|
52
|
+
* becomes tight or through is minted its rectangle once — at the edit, as a
|
|
53
|
+
* fact of the document the author can see and undo — and every save after that
|
|
54
|
+
* writes back what the model then holds.
|
|
55
|
+
*/
|
|
56
|
+
const wrapPolygonFor = (type, authored) => type === "tight" || type === "through" ? requiredWrapPolygon(authored) : void 0;
|
|
57
|
+
/** A copy, deep enough that a ProseMirror attr cannot share a point with the model. */
|
|
58
|
+
const copiedWrapPolygon = (polygon) => polygon === void 0 ? void 0 : {
|
|
59
|
+
...polygon,
|
|
60
|
+
start: { ...polygon.start },
|
|
61
|
+
lineTo: polygon.lineTo.map((point) => ({ ...point }))
|
|
62
|
+
};
|
|
63
|
+
/** `wp:wrapPolygon`, written from a polygon {@link wrapPolygonFor} has approved. */
|
|
64
|
+
const serializeWrapPolygon = (polygon) => {
|
|
65
|
+
const edited = polygon.edited === void 0 ? "" : ` edited="${polygon.edited ? "1" : "0"}"`;
|
|
66
|
+
const lineTo = polygon.lineTo.map((point) => `<wp:lineTo x="${intAttr(point.x)}" y="${intAttr(point.y)}"/>`).join("");
|
|
67
|
+
return `<wp:wrapPolygon${edited}><wp:start x="${intAttr(polygon.start.x)}" y="${intAttr(polygon.start.y)}"/>${lineTo}</wp:wrapPolygon>`;
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { copiedWrapPolygon, requiredWrapPolygon, serializeWrapPolygon, wrapPolygonFor };
|
package/dist/docx/xmlParser.d.ts
CHANGED
|
@@ -124,6 +124,8 @@ declare const OFFICE_RELATIONSHIP_NAMESPACE_URIS: ReadonlySet<string>;
|
|
|
124
124
|
* from a foreign namespace is not accepted.
|
|
125
125
|
*/
|
|
126
126
|
declare function findChildByNamespaceUri(parent: XmlElement | null | undefined, namespaceUris: ReadonlySet<string>, localName: string): XmlElement | null;
|
|
127
|
+
/** First direct child in either supported WordprocessingML namespace. */
|
|
128
|
+
declare const findWordprocessingChild: (parent: XmlElement | null | undefined, localName: string) => XmlElement | null;
|
|
127
129
|
/** All direct children whose local name and resolved namespace both match. */
|
|
128
130
|
declare function findChildrenByNamespaceUri(parent: XmlElement | null | undefined, namespaceUris: ReadonlySet<string>, localName: string): XmlElement[];
|
|
129
131
|
type XmlAttributeMatch = {
|
|
@@ -333,6 +335,17 @@ declare function parseOnOffValue(value: string | null | undefined, context?: Par
|
|
|
333
335
|
* @returns boolean value
|
|
334
336
|
*/
|
|
335
337
|
declare function parseBooleanElement(element: XmlElement | null | undefined, namespace?: string, context?: ParseContext): boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Read a `CT_OnOff` child as the three states it has.
|
|
340
|
+
*
|
|
341
|
+
* `parseBooleanElement` answers a two-state question, so it folds an absent
|
|
342
|
+
* element into the same `false` as an explicit `w:val="0"`. They are not the
|
|
343
|
+
* same thing: absent inherits the style hierarchy, and an explicit off is the
|
|
344
|
+
* only thing that cancels an inherited on. A property set that has to survive
|
|
345
|
+
* a save reads its toggles through here, and writes what it gets back —
|
|
346
|
+
* `undefined` included — so the element it did not carry stays uncarried.
|
|
347
|
+
*/
|
|
348
|
+
declare function parseOnOffChild(parent: XmlElement | null | undefined, namespace: string, localName: string, context?: ParseContext): boolean | undefined;
|
|
336
349
|
/**
|
|
337
350
|
* Deep find - search recursively for an element
|
|
338
351
|
*
|
|
@@ -392,4 +405,4 @@ declare function cloneWithXmlnsDeclarations(element: XmlElement, xmlnsDecls: Rec
|
|
|
392
405
|
*/
|
|
393
406
|
declare function cloneElement(element: XmlElement, overrides: Partial<XmlElement>): XmlElement;
|
|
394
407
|
//#endregion
|
|
395
|
-
export { NAMESPACES, OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, XmlAttributeMatch, XmlElement, XmlNamespaceScope, attachXmlNamespaceContext, cloneElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findChildrenByNamespaceUri, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffAttribute, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument, resolveAttributeNamespaceUri, selectAlternateContentBranch };
|
|
408
|
+
export { NAMESPACES, OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, XmlAttributeMatch, XmlElement, XmlNamespaceScope, attachXmlNamespaceContext, cloneElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findChildrenByNamespaceUri, findDeep, findWordprocessingChild, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffAttribute, parseOnOffChild, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument, resolveAttributeNamespaceUri, selectAlternateContentBranch };
|
package/dist/docx/xmlParser.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NUMBERS_PER_PERCENT, percentageSpelling, transitionalSlotEncoding } from "./transitionalSpelling.js";
|
|
2
2
|
import { universalMeasureAs } from "./universalMeasure.js";
|
|
3
3
|
import { escapeXmlAttribute, escapeXmlText } from "@stll/docx-core";
|
|
4
|
+
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
4
5
|
import { XMLParser } from "fast-xml-parser";
|
|
5
6
|
import { OOXML_NS } from "@stll/docx-utils";
|
|
6
|
-
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
7
7
|
//#region src/docx/xmlParser.ts
|
|
8
8
|
/**
|
|
9
9
|
* XML Parser Utilities for OOXML
|
|
@@ -273,6 +273,8 @@ function findChildByNamespaceUri(parent, namespaceUris, localName) {
|
|
|
273
273
|
for (const child of parent.elements) if (child.type === "element" && hasLocalName(child.name, localName) && namespaceUris.has(child.namespaceUri ?? "")) return child;
|
|
274
274
|
return null;
|
|
275
275
|
}
|
|
276
|
+
/** First direct child in either supported WordprocessingML namespace. */
|
|
277
|
+
const findWordprocessingChild = (parent, localName) => findChildByNamespaceUri(parent, WORDPROCESSINGML_NAMESPACE_URIS, localName);
|
|
276
278
|
/** All direct children whose local name and resolved namespace both match. */
|
|
277
279
|
function findChildrenByNamespaceUri(parent, namespaceUris, localName) {
|
|
278
280
|
if (!parent?.elements) return [];
|
|
@@ -674,6 +676,20 @@ function parseBooleanElement(element, namespace = "w", context) {
|
|
|
674
676
|
return parseOnOffValue(val, context, elementName) ?? false;
|
|
675
677
|
}
|
|
676
678
|
/**
|
|
679
|
+
* Read a `CT_OnOff` child as the three states it has.
|
|
680
|
+
*
|
|
681
|
+
* `parseBooleanElement` answers a two-state question, so it folds an absent
|
|
682
|
+
* element into the same `false` as an explicit `w:val="0"`. They are not the
|
|
683
|
+
* same thing: absent inherits the style hierarchy, and an explicit off is the
|
|
684
|
+
* only thing that cancels an inherited on. A property set that has to survive
|
|
685
|
+
* a save reads its toggles through here, and writes what it gets back —
|
|
686
|
+
* `undefined` included — so the element it did not carry stays uncarried.
|
|
687
|
+
*/
|
|
688
|
+
function parseOnOffChild(parent, namespace, localName, context) {
|
|
689
|
+
const element = findChildren(parent, namespace, localName).at(-1);
|
|
690
|
+
return element === void 0 ? void 0 : parseBooleanElement(element, namespace, context);
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
677
693
|
* Deep find - search recursively for an element
|
|
678
694
|
*
|
|
679
695
|
* @param root - Root element to search from
|
|
@@ -868,4 +884,4 @@ function cloneElement(element, overrides) {
|
|
|
868
884
|
return clone;
|
|
869
885
|
}
|
|
870
886
|
//#endregion
|
|
871
|
-
export { NAMESPACES, OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, attachXmlNamespaceContext, cloneElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findChildrenByNamespaceUri, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffAttribute, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument, resolveAttributeNamespaceUri, selectAlternateContentBranch };
|
|
887
|
+
export { NAMESPACES, OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, attachXmlNamespaceContext, cloneElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findChildrenByNamespaceUri, findDeep, findWordprocessingChild, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffAttribute, parseOnOffChild, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument, resolveAttributeNamespaceUri, selectAlternateContentBranch };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { parseFontTable } from "../docx/fontTableParser.js";
|
|
1
2
|
import { parseRelationships, resolveRelativePath } from "../docx/relsParser.js";
|
|
2
3
|
import { unzipDocx } from "../docx/unzip.js";
|
|
3
4
|
import { generateHexId } from "../utils/hexId.js";
|
|
4
|
-
import { parseEmbeddedFontTable } from "./embeddedFontTable.js";
|
|
5
5
|
import { deobfuscateFont, isValidFontKey } from "./fontDeobfuscation.js";
|
|
6
6
|
//#region src/fonts/embeddedFonts.ts
|
|
7
7
|
/**
|
|
@@ -69,7 +69,7 @@ function lookupFontData(resolvedPath, fonts) {
|
|
|
69
69
|
for (const [path, data] of fonts) if (normalizePackagePath(path) === wanted) return data;
|
|
70
70
|
}
|
|
71
71
|
function resolveFace(originalFamily, ref, kind, fonts, rels, docNonce) {
|
|
72
|
-
const target = rels.get(ref.
|
|
72
|
+
const target = rels.get(ref.id)?.target;
|
|
73
73
|
if (!target) return null;
|
|
74
74
|
const raw = lookupFontData(resolveRelativePath(FONTTABLE_RELS_BASE_PATH, target), fonts);
|
|
75
75
|
if (!raw) return null;
|
|
@@ -95,7 +95,7 @@ function resolveFace(originalFamily, ref, kind, fonts, rels, docNonce) {
|
|
|
95
95
|
* an explicit value for deterministic tests.
|
|
96
96
|
*/
|
|
97
97
|
function getEmbeddedFontFaces(parts, docNonce = generateHexId()) {
|
|
98
|
-
const entries =
|
|
98
|
+
const entries = parseFontTable(parts.fontTableXml)?.fonts ?? [];
|
|
99
99
|
if (entries.length === 0) return [];
|
|
100
100
|
if (!parts.fontTableRelsXml || parts.fonts.size === 0) return [];
|
|
101
101
|
const rels = parseRelationships(parts.fontTableRelsXml);
|
package/dist/headless-layout.js
CHANGED
|
@@ -90,6 +90,7 @@ const buildFlowOptions = (document, pageContentHeight) => {
|
|
|
90
90
|
const settings = document.package.settings;
|
|
91
91
|
const options = {
|
|
92
92
|
pageContentHeight,
|
|
93
|
+
defaultSize: 10,
|
|
93
94
|
fontAlternates: buildFontAlternates(document.package.fontTable),
|
|
94
95
|
...document.package.styles ? { styles: document.package.styles } : {}
|
|
95
96
|
};
|
|
@@ -116,6 +117,7 @@ const buildBlockLookup = (blocks, measures) => new Map(blocks.flatMap((block, in
|
|
|
116
117
|
}]];
|
|
117
118
|
}));
|
|
118
119
|
const buildStoryOptions = (flowOptions) => ({
|
|
120
|
+
...flowOptions.defaultSize === void 0 ? {} : { defaultSize: flowOptions.defaultSize },
|
|
119
121
|
...flowOptions.styles === void 0 ? {} : { styles: flowOptions.styles },
|
|
120
122
|
...flowOptions.theme === void 0 ? {} : { theme: flowOptions.theme },
|
|
121
123
|
...flowOptions.fontAlternates === void 0 ? {} : { fontAlternates: flowOptions.fontAlternates },
|