@stll/folio-core 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +85 -43
- package/dist/ai-edits/headless.js +2 -2
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +17 -0
- package/dist/content-controls/checkboxDisplay.js +46 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +57 -43
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -18
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +113 -14
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +11 -21
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +76 -0
- package/dist/docx/attributeRemainder.js +111 -0
- package/dist/docx/blockContentParser.d.ts +3 -1
- package/dist/docx/blockContentParser.js +102 -106
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +3 -0
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +56 -39
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +3 -1
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/compatibility.js +56 -41
- package/dist/docx/containerChildren.d.ts +208 -0
- package/dist/docx/containerChildren.gen.d.ts +43 -0
- package/dist/docx/containerChildren.gen.js +263 -0
- package/dist/docx/containerChildren.js +153 -0
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +7 -4
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +66 -9
- package/dist/docx/hyperlinkParser.js +153 -26
- package/dist/docx/imageParser.js +160 -115
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +166 -0
- package/dist/docx/inlineWrapperContent.js +165 -0
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +12 -1
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +111 -0
- package/dist/docx/paraIdAttribute.js +142 -0
- package/dist/docx/paragraphParser.d.ts +10 -25
- package/dist/docx/paragraphParser.js +421 -496
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
- package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +53 -52
- package/dist/docx/parseWarningMessage.js +5 -1
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +96 -0
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +4 -6
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +152 -27
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +55 -19
- package/dist/docx/runParser.js +394 -306
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +241 -238
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +66 -3
- package/dist/docx/selectiveXmlPatch.js +276 -133
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +12 -10
- package/dist/docx/serializer/commentSerializer.js +5 -7
- package/dist/docx/serializer/documentSerializer.js +11 -11
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +10 -9
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +11 -8
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +156 -236
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +134 -75
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +283 -105
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +20 -16
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +13 -8
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +11 -2
- package/dist/docx/tableParser.js +665 -220
- package/dist/docx/textBoxParser.d.ts +28 -3
- package/dist/docx/textBoxParser.js +69 -9
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/unzip.js +5 -4
- package/dist/docx/vmlImageParser.d.ts +30 -5
- package/dist/docx/vmlImageParser.js +91 -32
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +23 -1
- package/dist/docx/xmlParser.js +31 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +12 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +267 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +69 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +10 -3
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +10 -4
- package/dist/layout-painter/renderParagraph.d.ts +14 -1
- package/dist/layout-painter/renderParagraph.js +34 -28
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +12 -4
- package/dist/markdown/renderBlock.js +3 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +34 -6
- package/dist/markdown/renderTable.js +24 -6
- package/dist/markdown/trailers.js +4 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +34 -5
- package/dist/prosemirror/attrs/index.js +639 -48
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +33 -20
- package/dist/prosemirror/commands/image.d.ts +10 -3
- package/dist/prosemirror/commands/image.js +46 -29
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
- package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +801 -411
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +14 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +65 -0
- package/dist/prosemirror/extensions/markRegistry.js +138 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +7 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +92 -0
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +183 -0
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +47 -4
- package/dist/prosemirror/schema/nodes.d.ts +309 -26
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +4 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +31 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
- package/dist/prosemirror/zeroWidthAnchors.js +6 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +27 -1
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +12 -20
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -0
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -50
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { isValidHexColor } from "../../utils/colorResolver.js";
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeImageLuminancePercent } from "../../utils/imageLuminance.js";
|
|
3
|
+
import { serializePreservedAttributes } from "../attributeRemainder.js";
|
|
4
|
+
import { resolveEffectExtents, resolveWrapDistances, serializeAnchorAttributes, serializeEffectExtent, serializeInlineAttributes, serializeSimplePos, serializeWrapDistances } from "../drawingAnchor.js";
|
|
5
|
+
import { fieldStateAttributes } from "../fieldState.js";
|
|
3
6
|
import { serializeGraphicFrameLocks } from "../graphicFrameLocks.js";
|
|
4
7
|
import { DECORATIVE_EXTENSION_URI, DECORATIVE_NAMESPACE } from "../imageParser.js";
|
|
5
8
|
import { canReplayEditableImageRawXml } from "../imageRawXml.js";
|
|
6
9
|
import { serializeNonVisualDrawingNames } from "../nonVisualDrawingProps.js";
|
|
10
|
+
import { runHoldsPayload } from "../runPayload.js";
|
|
11
|
+
import { requiredWrapPolygon, serializeWrapPolygon } from "../wrapPolygon.js";
|
|
7
12
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
8
13
|
import { serializeTable } from "./tableSerializer.js";
|
|
9
14
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
@@ -11,6 +16,7 @@ import { getSingularRunPropertyChange, serializeTrackedChangeAttributes } from "
|
|
|
11
16
|
import { intAttr } from "./xmlUtils.js";
|
|
12
17
|
import { panic } from "better-result";
|
|
13
18
|
import { escapeXmlAttribute, escapeXmlText, requiresXmlSpacePreserve } from "@stll/docx-core";
|
|
19
|
+
import { SCHEME_COLOR_VALUE_BY_THEME_COLOR, knownThemeColor, presetLineDashToken } from "@stll/docx-core/model";
|
|
14
20
|
//#region src/docx/serializer/runSerializer.ts
|
|
15
21
|
/**
|
|
16
22
|
* Run Serializer - Serialize runs to OOXML XML
|
|
@@ -41,21 +47,13 @@ function getUniqueId(id) {
|
|
|
41
47
|
if (id !== void 0 && id !== "" && id !== 0) return String(id);
|
|
42
48
|
return String(nextAutoId++);
|
|
43
49
|
}
|
|
44
|
-
function extractRPrInner(rPrXml) {
|
|
45
|
-
if (!rPrXml.startsWith("<w:rPr>") || !rPrXml.endsWith("</w:rPr>")) return "";
|
|
46
|
-
return rPrXml.slice(7, -8);
|
|
47
|
-
}
|
|
48
50
|
function serializeRunPropertyChange(change) {
|
|
49
51
|
const previousRPrXml = serializeTextFormatting(change.previousFormatting) || "<w:rPr/>";
|
|
50
52
|
return `<w:rPrChange ${serializeTrackedChangeAttributes(change.info)}>${previousRPrXml}</w:rPrChange>`;
|
|
51
53
|
}
|
|
52
54
|
function serializeRunProperties(formatting, propertyChanges) {
|
|
53
|
-
const currentRPrXml = serializeTextFormatting(formatting);
|
|
54
|
-
const currentInner = currentRPrXml ? extractRPrInner(currentRPrXml) : "";
|
|
55
55
|
const propertyChange = getSingularRunPropertyChange(propertyChanges);
|
|
56
|
-
|
|
57
|
-
if (!combined) return "";
|
|
58
|
-
return `<w:rPr>${combined}</w:rPr>`;
|
|
56
|
+
return serializeTextFormatting(formatting, propertyChange ? [["rPrChange", serializeRunPropertyChange(propertyChange)]] : []);
|
|
59
57
|
}
|
|
60
58
|
/**
|
|
61
59
|
* Serialize text content (w:t)
|
|
@@ -103,10 +101,7 @@ function serializeNoteReference(content) {
|
|
|
103
101
|
* Serialize field character (w:fldChar)
|
|
104
102
|
*/
|
|
105
103
|
function serializeFieldChar(content) {
|
|
106
|
-
|
|
107
|
-
if (content.fldLock) attrs.push("w:fldLock=\"true\"");
|
|
108
|
-
if (content.dirty) attrs.push("w:dirty=\"true\"");
|
|
109
|
-
return `<w:fldChar ${attrs.join(" ")}/>`;
|
|
104
|
+
return `<w:fldChar ${[`w:fldCharType="${content.charType}"`, ...fieldStateAttributes(content)].join(" ")}/>`;
|
|
110
105
|
}
|
|
111
106
|
/**
|
|
112
107
|
* Serialize field instruction text (w:instrText)
|
|
@@ -130,8 +125,10 @@ function serializeNoBreakHyphen(_content) {
|
|
|
130
125
|
function serializeDrawingColor(color) {
|
|
131
126
|
if (!color) return "";
|
|
132
127
|
if (color.rgb && isValidHexColor(color.rgb)) return `<a:srgbClr val="${escapeXmlAttribute(color.rgb.replace("#", ""))}"/>`;
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
const themeColor = color.themeColor && knownThemeColor(color.themeColor);
|
|
129
|
+
const schemeColor = themeColor ? SCHEME_COLOR_VALUE_BY_THEME_COLOR[themeColor] : null;
|
|
130
|
+
if (schemeColor !== null) {
|
|
131
|
+
let clr = `<a:schemeClr val="${schemeColor}"`;
|
|
135
132
|
if (color.themeTint) clr += `><a:tint val="${escapeXmlAttribute(color.themeTint)}"/></a:schemeClr>`;
|
|
136
133
|
else if (color.themeShade) clr += `><a:shade val="${escapeXmlAttribute(color.themeShade)}"/></a:schemeClr>`;
|
|
137
134
|
else clr += `/>`;
|
|
@@ -171,7 +168,7 @@ function serializeOutline(outline) {
|
|
|
171
168
|
if (outline.cap) attrs.push(`cap="${serializeLineCap(outline.cap)}"`);
|
|
172
169
|
const parts = [];
|
|
173
170
|
if (outline.color) parts.push(`<a:solidFill>${serializeDrawingColor(outline.color)}</a:solidFill>`);
|
|
174
|
-
if (outline.
|
|
171
|
+
if (outline.dash) parts.push(`<a:prstDash val="${escapeXmlAttribute(presetLineDashToken(outline.dash))}"/>`);
|
|
175
172
|
if (outline.join === "bevel") parts.push("<a:bevel/>");
|
|
176
173
|
else if (outline.join === "round") parts.push("<a:round/>");
|
|
177
174
|
else if (outline.join === "miter") parts.push("<a:miter/>");
|
|
@@ -195,20 +192,77 @@ function serializePosition(pos) {
|
|
|
195
192
|
parts.push("</wp:positionV>");
|
|
196
193
|
return parts.join("");
|
|
197
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* The insets each `EG_WrapType` member's own type declares.
|
|
197
|
+
*
|
|
198
|
+
* Total over the wrap kinds, so a kind added to the model has to say which of
|
|
199
|
+
* the four its element may carry. A key this map does not list cannot be
|
|
200
|
+
* written on that element without failing the schema, whatever the drawing's
|
|
201
|
+
* slots hold.
|
|
202
|
+
*/
|
|
203
|
+
const WRAP_CHILD_DISTANCE_KEYS = {
|
|
204
|
+
square: [
|
|
205
|
+
"distT",
|
|
206
|
+
"distB",
|
|
207
|
+
"distL",
|
|
208
|
+
"distR"
|
|
209
|
+
],
|
|
210
|
+
tight: ["distL", "distR"],
|
|
211
|
+
through: ["distL", "distR"],
|
|
212
|
+
topAndBottom: ["distT", "distB"],
|
|
213
|
+
behind: [],
|
|
214
|
+
inFront: [],
|
|
215
|
+
inline: []
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Which `EG_WrapType` members declare a `wp:effectExtent` of their own.
|
|
219
|
+
*
|
|
220
|
+
* Total over the wrap kinds for {@link WRAP_CHILD_DISTANCE_KEYS}'s reason: a
|
|
221
|
+
* kind added to the model has to say whether its element may carry one, and
|
|
222
|
+
* writing it where the type does not declare it fails the schema.
|
|
223
|
+
*/
|
|
224
|
+
const WRAP_CHILD_DECLARES_EFFECT_EXTENT = {
|
|
225
|
+
square: true,
|
|
226
|
+
tight: false,
|
|
227
|
+
through: false,
|
|
228
|
+
topAndBottom: true,
|
|
229
|
+
behind: false,
|
|
230
|
+
inFront: false,
|
|
231
|
+
inline: false
|
|
232
|
+
};
|
|
198
233
|
/** Serialize wrap type to wp:wrap* element */
|
|
199
|
-
function serializeWrap(wrap) {
|
|
234
|
+
function serializeWrap(wrap, effectExtent) {
|
|
200
235
|
const wrapText = wrap.wrapText ? ` wrapText="${wrap.wrapText}"` : " wrapText=\"bothSides\"";
|
|
236
|
+
const authored = resolveWrapDistances(wrap).wrapChild;
|
|
237
|
+
const distances = {};
|
|
238
|
+
for (const key of WRAP_CHILD_DISTANCE_KEYS[wrap.type]) {
|
|
239
|
+
const value = authored[key];
|
|
240
|
+
if (value !== void 0) distances[key] = value;
|
|
241
|
+
}
|
|
242
|
+
const dist = serializeWrapDistances(distances);
|
|
243
|
+
const extent = effectExtent !== void 0 && WRAP_CHILD_DECLARES_EFFECT_EXTENT[wrap.type] ? serializeEffectExtent(effectExtent) : "";
|
|
201
244
|
switch (wrap.type) {
|
|
202
|
-
case "square": return `<wp:wrapSquare${wrapText}/>`;
|
|
203
|
-
case "tight": return `<wp:wrapTight${wrapText}
|
|
204
|
-
case "through": return `<wp:wrapThrough${wrapText}
|
|
205
|
-
case "topAndBottom": return
|
|
245
|
+
case "square": return extent ? `<wp:wrapSquare${wrapText}${dist}>${extent}</wp:wrapSquare>` : `<wp:wrapSquare${wrapText}${dist}/>`;
|
|
246
|
+
case "tight": return `<wp:wrapTight${wrapText}${dist}>${serializeWrapPolygon(requiredWrapPolygon(wrap.polygon))}</wp:wrapTight>`;
|
|
247
|
+
case "through": return `<wp:wrapThrough${wrapText}${dist}>${serializeWrapPolygon(requiredWrapPolygon(wrap.polygon))}</wp:wrapThrough>`;
|
|
248
|
+
case "topAndBottom": return extent ? `<wp:wrapTopAndBottom${dist}>${extent}</wp:wrapTopAndBottom>` : `<wp:wrapTopAndBottom${dist}/>`;
|
|
206
249
|
case "behind":
|
|
207
250
|
case "inFront": return "<wp:wrapNone/>";
|
|
208
251
|
case "inline": return "<wp:wrapNone/>";
|
|
209
252
|
}
|
|
210
253
|
}
|
|
211
254
|
/**
|
|
255
|
+
* `a:xfrm` attributes for an authored transform.
|
|
256
|
+
*
|
|
257
|
+
* Written iff authored: `rot="0"` and `flipH="0"` are OOXML's defaults, so a
|
|
258
|
+
* truthiness guard cannot tell "the author said none" from "the author said
|
|
259
|
+
* nothing", and a save erased an authored zero.
|
|
260
|
+
*/
|
|
261
|
+
const serializeTransformAttrs = (transform) => {
|
|
262
|
+
if (transform === void 0) return "";
|
|
263
|
+
return `${transform.rotation === void 0 ? "" : ` rot="${Math.round(transform.rotation * 6e4)}"`}${transform.flipH === void 0 ? "" : ` flipH="${transform.flipH ? 1 : 0}"`}${transform.flipV === void 0 ? "" : ` flipV="${transform.flipV ? 1 : 0}"`}`;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
212
266
|
* Build the common a:graphic > pic:pic element for images.
|
|
213
267
|
*
|
|
214
268
|
* Takes the relationship id as a separate argument so the caller has to have
|
|
@@ -220,25 +274,28 @@ function serializePicGraphic(image, imageRId, sharedId) {
|
|
|
220
274
|
const cy = image.size.height;
|
|
221
275
|
const rId = escapeXmlAttribute(imageRId);
|
|
222
276
|
const id = sharedId;
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
277
|
+
const picNames = serializeNonVisualDrawingNames({
|
|
278
|
+
...image.pictureNames,
|
|
279
|
+
name: image.pictureNames?.name ?? image.filename ?? `image${id}`
|
|
280
|
+
});
|
|
281
|
+
const xfrmAttrs = serializeTransformAttrs(image.transform);
|
|
228
282
|
const cropAttrs = [];
|
|
229
283
|
if (image.crop?.left) cropAttrs.push(`l="${Math.round(image.crop.left * 1e5)}"`);
|
|
230
284
|
if (image.crop?.top) cropAttrs.push(`t="${Math.round(image.crop.top * 1e5)}"`);
|
|
231
285
|
if (image.crop?.right) cropAttrs.push(`r="${Math.round(image.crop.right * 1e5)}"`);
|
|
232
286
|
if (image.crop?.bottom) cropAttrs.push(`b="${Math.round(image.crop.bottom * 1e5)}"`);
|
|
233
287
|
const srcRectEl = cropAttrs.length > 0 ? `<a:srcRect ${cropAttrs.join(" ")}/>` : "";
|
|
234
|
-
const
|
|
235
|
-
|
|
288
|
+
const luminanceAttrs = [];
|
|
289
|
+
if (image.effects?.brightness !== void 0 && Number.isFinite(image.effects.brightness)) luminanceAttrs.push(`bright="${Math.round(normalizeImageLuminancePercent(image.effects.brightness) * 1e3)}"`);
|
|
290
|
+
if (image.effects?.contrast !== void 0 && Number.isFinite(image.effects.contrast)) luminanceAttrs.push(`contrast="${Math.round(normalizeImageLuminancePercent(image.effects.contrast) * 1e3)}"`);
|
|
291
|
+
const blipChildren = `${luminanceAttrs.length === 0 ? "" : `<a:lum ${luminanceAttrs.join(" ")}/>`}${image.opacity !== void 0 && image.opacity < 1 ? `<a:alphaModFix amt="${Math.round(Math.max(0, image.opacity) * 1e5)}"/>` : ""}`;
|
|
292
|
+
const blipEl = blipChildren ? `<a:blip r:embed="${rId}">${blipChildren}</a:blip>` : `<a:blip r:embed="${rId}"/>`;
|
|
236
293
|
return [
|
|
237
294
|
"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">",
|
|
238
295
|
"<a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">",
|
|
239
296
|
"<pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">",
|
|
240
297
|
"<pic:nvPicPr>",
|
|
241
|
-
`<pic:cNvPr id="${id}"
|
|
298
|
+
`<pic:cNvPr id="${id}"${picNames}/>`,
|
|
242
299
|
"<pic:cNvPicPr/>",
|
|
243
300
|
"</pic:nvPicPr>",
|
|
244
301
|
"<pic:blipFill>",
|
|
@@ -260,18 +317,6 @@ function serializePicGraphic(image, imageRId, sharedId) {
|
|
|
260
317
|
].join("");
|
|
261
318
|
}
|
|
262
319
|
/**
|
|
263
|
-
* Serialize only authored wrap-distance attributes. OOXML defaults omitted
|
|
264
|
-
* values to zero, but preserving absence keeps untouched models stable.
|
|
265
|
-
*/
|
|
266
|
-
function serializeWrapDistanceAttrs(wrap) {
|
|
267
|
-
const attrs = [];
|
|
268
|
-
if (wrap?.distT !== void 0) attrs.push(`distT="${intAttr(wrap.distT)}"`);
|
|
269
|
-
if (wrap?.distB !== void 0) attrs.push(`distB="${intAttr(wrap.distB)}"`);
|
|
270
|
-
if (wrap?.distL !== void 0) attrs.push(`distL="${intAttr(wrap.distL)}"`);
|
|
271
|
-
if (wrap?.distR !== void 0) attrs.push(`distR="${intAttr(wrap.distR)}"`);
|
|
272
|
-
return attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
320
|
* Serialize the `wp:docPr` extension list.
|
|
276
321
|
*
|
|
277
322
|
* The decorative flag is the one extension folio models; every other `a:ext`
|
|
@@ -285,6 +330,23 @@ function serializeDocPrExtensions(image) {
|
|
|
285
330
|
return entries ? `<a:extLst>${entries}</a:extLst>` : "";
|
|
286
331
|
}
|
|
287
332
|
/**
|
|
333
|
+
* Serialize `wp:docPr`'s two link children, in the order the schema declares.
|
|
334
|
+
*
|
|
335
|
+
* The click element is replayed from the source while the model still names the
|
|
336
|
+
* target it named, which keeps `tooltip`, `tgtFrame`, `history` and the rest of
|
|
337
|
+
* `CT_Hyperlink` that the model has no field for. A link the editor retargeted
|
|
338
|
+
* no longer agrees with those bytes, so it is rebuilt from the target instead —
|
|
339
|
+
* the alternative is writing a tooltip that points somewhere else. The hover
|
|
340
|
+
* element has no modelled half to disagree with it, so it always replays.
|
|
341
|
+
*/
|
|
342
|
+
function serializeDocPrLinks(image) {
|
|
343
|
+
const hover = image.hlinkHoverXml ?? "";
|
|
344
|
+
const source = image.hlinkClickSource;
|
|
345
|
+
if (source !== void 0 && source.rId === image.hlinkRId) return `${source.xml}${hover}`;
|
|
346
|
+
if (image.hlinkRId === void 0) return hover;
|
|
347
|
+
return `<a:hlinkClick r:id="${escapeXmlAttribute(image.hlinkRId)}"/>${hover}`;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
288
350
|
* Serialize drawing/image content (w:drawing) to full DrawingML XML
|
|
289
351
|
*/
|
|
290
352
|
function serializeDrawingContent(content) {
|
|
@@ -292,19 +354,15 @@ function serializeDrawingContent(content) {
|
|
|
292
354
|
const isFloating = image.wrap.type !== "inline";
|
|
293
355
|
const cx = image.size.width;
|
|
294
356
|
const cy = image.size.height;
|
|
295
|
-
const
|
|
296
|
-
const
|
|
297
|
-
const effT = image.padding?.top ?? 0;
|
|
298
|
-
const effR = image.padding?.right ?? 0;
|
|
299
|
-
const effB = image.padding?.bottom ?? 0;
|
|
300
|
-
const effectExtentEl = `<wp:effectExtent l="${intAttr(effL)}" t="${intAttr(effT)}" r="${intAttr(effR)}" b="${intAttr(effB)}"/>`;
|
|
357
|
+
const effectExtents = resolveEffectExtents(image.wrap, image.padding);
|
|
358
|
+
const effectExtentEl = serializeEffectExtent(effectExtents.drawing);
|
|
301
359
|
const docPrId = getUniqueId(image.id);
|
|
302
360
|
const docPrNames = serializeNonVisualDrawingNames({
|
|
303
361
|
...image.docPrName !== void 0 ? { name: image.docPrName } : {},
|
|
304
362
|
...image.alt !== void 0 ? { alt: image.alt } : {},
|
|
305
363
|
...image.title !== void 0 ? { title: image.title } : {}
|
|
306
364
|
});
|
|
307
|
-
const hlinkClick =
|
|
365
|
+
const hlinkClick = serializeDocPrLinks(image);
|
|
308
366
|
const docPrAttrs = `id="${docPrId}"${docPrNames}${image.hidden === void 0 ? "" : ` hidden="${image.hidden ? "1" : "0"}"`}`;
|
|
309
367
|
const docPrChildren = `${hlinkClick}${serializeDocPrExtensions(image)}`;
|
|
310
368
|
const docPr = docPrChildren ? `<wp:docPr ${docPrAttrs}>${docPrChildren}</wp:docPr>` : `<wp:docPr ${docPrAttrs}/>`;
|
|
@@ -312,7 +370,7 @@ function serializeDrawingContent(content) {
|
|
|
312
370
|
const graphic = image.rId === void 0 ? "" : serializePicGraphic(image, image.rId, docPrId);
|
|
313
371
|
if (!isFloating) return [
|
|
314
372
|
"<w:drawing>",
|
|
315
|
-
`<wp:inline${
|
|
373
|
+
`<wp:inline${serializeInlineAttributes(image.wrap)}>`,
|
|
316
374
|
`<wp:extent cx="${intAttr(cx)}" cy="${intAttr(cy)}"/>`,
|
|
317
375
|
effectExtentEl,
|
|
318
376
|
docPr,
|
|
@@ -321,13 +379,16 @@ function serializeDrawingContent(content) {
|
|
|
321
379
|
"</wp:inline>",
|
|
322
380
|
"</w:drawing>"
|
|
323
381
|
].join("");
|
|
324
|
-
const behindDoc = image.wrap.type === "behind" ? "1" : "0";
|
|
325
382
|
const position = image.position ? serializePosition(image.position) : "<wp:positionH relativeFrom=\"column\"><wp:posOffset>0</wp:posOffset></wp:positionH><wp:positionV relativeFrom=\"paragraph\"><wp:posOffset>0</wp:posOffset></wp:positionV>";
|
|
326
|
-
const wrap = serializeWrap(image.wrap);
|
|
383
|
+
const wrap = serializeWrap(image.wrap, effectExtents.wrapChild);
|
|
327
384
|
return [
|
|
328
385
|
"<w:drawing>",
|
|
329
|
-
`<wp:anchor${
|
|
330
|
-
|
|
386
|
+
`<wp:anchor${serializeAnchorAttributes({
|
|
387
|
+
anchor: image.anchor,
|
|
388
|
+
wrap: image.wrap,
|
|
389
|
+
behindDoc: image.wrap.type === "behind"
|
|
390
|
+
})}>`,
|
|
391
|
+
serializeSimplePos(image.anchor),
|
|
331
392
|
position,
|
|
332
393
|
`<wp:extent cx="${intAttr(cx)}" cy="${intAttr(cy)}"/>`,
|
|
333
394
|
effectExtentEl,
|
|
@@ -366,20 +427,16 @@ function serializeShapeContent(content) {
|
|
|
366
427
|
const cy = shape.size.height;
|
|
367
428
|
const isTextBox = shape.shapeType === "textBox";
|
|
368
429
|
const isFloating = shape.wrap && shape.wrap.type !== "inline";
|
|
369
|
-
const wrapDistances = serializeWrapDistanceAttrs(shape.wrap);
|
|
370
430
|
const docPrId = getUniqueId(shape.id);
|
|
371
431
|
const docPrNames = serializeNonVisualDrawingNames({
|
|
372
432
|
...shape.name !== void 0 ? { name: shape.name } : {},
|
|
373
433
|
...shape.alt !== void 0 ? { alt: shape.alt } : {},
|
|
374
434
|
...shape.title !== void 0 ? { title: shape.title } : {}
|
|
375
435
|
});
|
|
376
|
-
|
|
377
|
-
if (shape.transform?.rotation) xfrmAttrs += ` rot="${Math.round(shape.transform.rotation * 6e4)}"`;
|
|
378
|
-
if (shape.transform?.flipH) xfrmAttrs += " flipH=\"1\"";
|
|
379
|
-
if (shape.transform?.flipV) xfrmAttrs += " flipV=\"1\"";
|
|
436
|
+
const shapeNames = shape.shapeNames === void 0 ? "" : `<wps:cNvPr id="${docPrId}"${serializeNonVisualDrawingNames(shape.shapeNames)}/>`;
|
|
380
437
|
const spPr = [
|
|
381
438
|
"<wps:spPr>",
|
|
382
|
-
`<a:xfrm${
|
|
439
|
+
`<a:xfrm${serializeTransformAttrs(shape.transform)}>`,
|
|
383
440
|
"<a:off x=\"0\" y=\"0\"/>",
|
|
384
441
|
`<a:ext cx="${intAttr(cx)}" cy="${intAttr(cy)}"/>`,
|
|
385
442
|
"</a:xfrm>",
|
|
@@ -421,6 +478,7 @@ function serializeShapeContent(content) {
|
|
|
421
478
|
"<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">",
|
|
422
479
|
[
|
|
423
480
|
"<wps:wsp>",
|
|
481
|
+
shapeNames,
|
|
424
482
|
`<wps:cNvSpPr${isTextBox ? " txBox=\"1\"" : ""}/>`,
|
|
425
483
|
spPr,
|
|
426
484
|
textBody === "" ? "<wps:bodyPr/>" : textBody,
|
|
@@ -429,28 +487,32 @@ function serializeShapeContent(content) {
|
|
|
429
487
|
"</a:graphicData>",
|
|
430
488
|
"</a:graphic>"
|
|
431
489
|
].join("");
|
|
490
|
+
const shapeEffectExtents = resolveEffectExtents(shape.wrap, shape.wrap?.effectExtentSlots?.drawing);
|
|
432
491
|
if (!isFloating) return [
|
|
433
492
|
"<w:drawing>",
|
|
434
|
-
`<wp:inline${
|
|
493
|
+
`<wp:inline${serializeInlineAttributes(shape.wrap)}>`,
|
|
435
494
|
`<wp:extent cx="${intAttr(cx)}" cy="${intAttr(cy)}"/>`,
|
|
436
|
-
|
|
495
|
+
serializeEffectExtent(shapeEffectExtents.drawing),
|
|
437
496
|
`<wp:docPr id="${docPrId}"${docPrNames}/>`,
|
|
438
497
|
"<wp:cNvGraphicFramePr/>",
|
|
439
498
|
graphic,
|
|
440
499
|
"</wp:inline>",
|
|
441
500
|
"</w:drawing>"
|
|
442
501
|
].join("");
|
|
443
|
-
const behindDoc = shape.wrap?.type === "behind" ? "1" : "0";
|
|
444
502
|
const position = shape.position ? serializePosition(shape.position) : "<wp:positionH relativeFrom=\"column\"><wp:posOffset>0</wp:posOffset></wp:positionH><wp:positionV relativeFrom=\"paragraph\"><wp:posOffset>0</wp:posOffset></wp:positionV>";
|
|
445
503
|
if (!shape.wrap) panic("Floating shape must have a wrap property");
|
|
446
|
-
const wrap = serializeWrap(shape.wrap);
|
|
504
|
+
const wrap = serializeWrap(shape.wrap, shapeEffectExtents.wrapChild);
|
|
447
505
|
return [
|
|
448
506
|
"<w:drawing>",
|
|
449
|
-
`<wp:anchor${
|
|
450
|
-
|
|
507
|
+
`<wp:anchor${serializeAnchorAttributes({
|
|
508
|
+
anchor: shape.anchor,
|
|
509
|
+
wrap: shape.wrap,
|
|
510
|
+
behindDoc: shape.wrap.type === "behind"
|
|
511
|
+
})}>`,
|
|
512
|
+
serializeSimplePos(shape.anchor),
|
|
451
513
|
position,
|
|
452
514
|
`<wp:extent cx="${intAttr(cx)}" cy="${intAttr(cy)}"/>`,
|
|
453
|
-
|
|
515
|
+
serializeEffectExtent(shapeEffectExtents.drawing),
|
|
454
516
|
wrap,
|
|
455
517
|
`<wp:docPr id="${docPrId}"${docPrNames}/>`,
|
|
456
518
|
"<wp:cNvGraphicFramePr/>",
|
|
@@ -475,6 +537,7 @@ function serializeRunContent(content) {
|
|
|
475
537
|
case "softHyphen": return serializeSoftHyphen(content);
|
|
476
538
|
case "noBreakHyphen": return serializeNoBreakHyphen(content);
|
|
477
539
|
case "renderedPageBreak": return "<w:lastRenderedPageBreak/>";
|
|
540
|
+
case "preservedXml": return content.xml;
|
|
478
541
|
case "drawing":
|
|
479
542
|
if (content.rawXml && canReplayEditableImageRawXml(content)) return content.rawXml;
|
|
480
543
|
return serializeDrawingContent(content);
|
|
@@ -489,6 +552,7 @@ function serializeRunContent(content) {
|
|
|
489
552
|
* @returns XML string for the run
|
|
490
553
|
*/
|
|
491
554
|
function serializeRun(run) {
|
|
555
|
+
if (!runHoldsPayload(run)) return "";
|
|
492
556
|
const parts = [];
|
|
493
557
|
const rPrXml = serializeRunProperties(run.formatting, run.propertyChanges);
|
|
494
558
|
if (rPrXml) parts.push(rPrXml);
|
|
@@ -496,7 +560,8 @@ function serializeRun(run) {
|
|
|
496
560
|
const contentXml = serializeRunContent(content);
|
|
497
561
|
if (contentXml) parts.push(contentXml);
|
|
498
562
|
}
|
|
499
|
-
|
|
563
|
+
const attrs = serializePreservedAttributes([], run.preservedAttributes);
|
|
564
|
+
return `<w:r${attrs.length > 0 ? ` ${attrs.join(" ")}` : ""}>${parts.join("")}</w:r>`;
|
|
500
565
|
}
|
|
501
566
|
/**
|
|
502
567
|
* Serialize multiple runs to OOXML XML
|
|
@@ -508,12 +573,6 @@ function serializeRuns(runs) {
|
|
|
508
573
|
return runs.map(serializeRun).join("");
|
|
509
574
|
}
|
|
510
575
|
/**
|
|
511
|
-
* Check if a run has any content
|
|
512
|
-
*/
|
|
513
|
-
function hasRunContent(run) {
|
|
514
|
-
return run.content.length > 0;
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
576
|
* Check if a run has formatting
|
|
518
577
|
*/
|
|
519
578
|
function hasRunFormatting(run) {
|
|
@@ -571,4 +630,4 @@ function createTabRun(formatting) {
|
|
|
571
630
|
};
|
|
572
631
|
}
|
|
573
632
|
//#endregion
|
|
574
|
-
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText,
|
|
633
|
+
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText, hasRunFormatting, resetAutoIdCounter, serializeRun, serializeRuns };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
//#region src/docx/serializer/sdtPropertiesSerializer.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* `<w:sdtPr>` from the model: the modelled children, the preserved ones, in
|
|
5
|
+
* schema order.
|
|
6
|
+
*
|
|
7
|
+
* An empty property set is written as an empty element rather than left out.
|
|
8
|
+
* `<w:sdtPr/>` and no `w:sdtPr` at all are different documents — the first is
|
|
9
|
+
* a richText control that states nothing, the second is markup the schema does
|
|
10
|
+
* not admit under `w:sdt` — and folio used to write the second for both.
|
|
11
|
+
*/
|
|
12
|
+
declare const serializeSdtProperties: (props: document_d_exports.SdtProperties) => string;
|
|
13
|
+
/**
|
|
14
|
+
* `w:sdtEndPr`, replayed when the parse captured it and written from the
|
|
15
|
+
* record otherwise.
|
|
16
|
+
*
|
|
17
|
+
* The record's presence is the element's: `<w:sdtEndPr/>` with no `w:rPr` is
|
|
18
|
+
* what Word writes for most controls and differs from a missing element.
|
|
19
|
+
*/
|
|
20
|
+
declare const serializeSdtEndProperties: (properties: document_d_exports.SdtProperties) => string;
|
|
21
|
+
/** `w:sdtPr` followed by `w:sdtEndPr`, in schema order. */
|
|
22
|
+
declare const serializeSdtPropertyElements: (properties: document_d_exports.SdtProperties) => string;
|
|
23
|
+
/** The one writer of an SDT wrapper at every content-model level. */
|
|
24
|
+
declare const serializeSdtWrapper: (properties: document_d_exports.SdtProperties, contentXml: string) => string;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { serializeSdtEndProperties, serializeSdtProperties, serializeSdtPropertyElements, serializeSdtWrapper };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { statesControlKind } from "../sdtProperties.js";
|
|
2
|
+
import { withModelledControlState } from "../sdtPropertiesPatch.js";
|
|
3
|
+
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
4
|
+
import { isSingleWellFormedElement } from "./xmlUtils.js";
|
|
5
|
+
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
6
|
+
import { assertSafePreservedMarkup, serializeSequenceChildren } from "@stll/docx-core/schema";
|
|
7
|
+
//#region src/docx/serializer/sdtPropertiesSerializer.ts
|
|
8
|
+
/**
|
|
9
|
+
* The one writer of `<w:sdtPr>`.
|
|
10
|
+
*
|
|
11
|
+
* Every content control — block, inline, row and cell — writes its property
|
|
12
|
+
* set here. There used to be three producers: a fallback projection on the
|
|
13
|
+
* block path, a second one on the inline path, and a regex pass over the
|
|
14
|
+
* source's captured bytes that patched an interactive change back into them.
|
|
15
|
+
* The three agreed on nothing in particular, and the patching pass existed
|
|
16
|
+
* only because the replay was the serialization source.
|
|
17
|
+
*
|
|
18
|
+
* It is not any more. `parseSdtProperties` puts every child folio does not
|
|
19
|
+
* model into `SdtProperties.preserved` at its `CT_SdtPr` ordinal, so the model
|
|
20
|
+
* holds the whole element and the writer merges its two halves back in schema
|
|
21
|
+
* order — which `CT_SdtPr` demands, and Word repairs a file that disregards.
|
|
22
|
+
*/
|
|
23
|
+
const listElement = (name, props) => {
|
|
24
|
+
return `<w:${name}${props.dropdownLastValue === void 0 ? "" : ` w:lastValue="${escapeXmlAttribute(props.dropdownLastValue)}"`}>${(props.listItems ?? []).map((item) => `<w:listItem w:displayText="${escapeXmlAttribute(item.displayText)}" w:value="${escapeXmlAttribute(item.value)}"/>`).join("")}</w:${name}>`;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The kind marker for a control that carries none of its own.
|
|
28
|
+
*
|
|
29
|
+
* Only reached for a control built in code rather than parsed: a parsed one
|
|
30
|
+
* keeps the element its author wrote, in the sink, glyph elements and all.
|
|
31
|
+
* `richText` is the format's default and `unknown` is folio's word for a kind
|
|
32
|
+
* it could not read, so neither writes a marker — a bare `w:sdtPr` already
|
|
33
|
+
* means richText.
|
|
34
|
+
*
|
|
35
|
+
* A checkbox has no declared kind element at all: `w14:checkbox` is an
|
|
36
|
+
* extension the Transitional content model does not know, so it is filed
|
|
37
|
+
* under the slot the kind choice occupies, which is where Word writes it.
|
|
38
|
+
*/
|
|
39
|
+
const synthesizedKind = (props) => {
|
|
40
|
+
switch (props.sdtType) {
|
|
41
|
+
case "plainText": return ["text", "<w:text/>"];
|
|
42
|
+
case "date": return ["date", `<w:date${props.dateValueISO ? ` w:fullDate="${escapeXmlAttribute(props.dateValueISO)}"` : ""}>${props.dateFormat ? `<w:dateFormat w:val="${escapeXmlAttribute(props.dateFormat)}"/>` : ""}</w:date>`];
|
|
43
|
+
case "dropdown": return ["dropDownList", listElement("dropDownList", props)];
|
|
44
|
+
case "comboBox": return ["comboBox", listElement("comboBox", props)];
|
|
45
|
+
case "checkbox": return ["equation", `<w14:checkbox><w14:checked w14:val="${props.checked ? "1" : "0"}"/></w14:checkbox>`];
|
|
46
|
+
case "picture": return ["picture", "<w:picture/>"];
|
|
47
|
+
case "buildingBlockGallery": return ["docPartObj", "<w:docPartObj/>"];
|
|
48
|
+
case "group": return ["group", "<w:group/>"];
|
|
49
|
+
case "richText":
|
|
50
|
+
case "unknown": return ["richText", ""];
|
|
51
|
+
default: return props.sdtType;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* `<w:sdtPr>` from the model: the modelled children, the preserved ones, in
|
|
56
|
+
* schema order.
|
|
57
|
+
*
|
|
58
|
+
* An empty property set is written as an empty element rather than left out.
|
|
59
|
+
* `<w:sdtPr/>` and no `w:sdtPr` at all are different documents — the first is
|
|
60
|
+
* a richText control that states nothing, the second is markup the schema does
|
|
61
|
+
* not admit under `w:sdt` — and folio used to write the second for both.
|
|
62
|
+
*/
|
|
63
|
+
const serializeSdtProperties = (props) => {
|
|
64
|
+
assertSafePreservedMarkup(props.preserved);
|
|
65
|
+
const modelled = [];
|
|
66
|
+
if (props.alias !== void 0) modelled.push(["alias", `<w:alias w:val="${escapeXmlAttribute(props.alias)}"/>`]);
|
|
67
|
+
if (props.tag !== void 0) modelled.push(["tag", `<w:tag w:val="${escapeXmlAttribute(props.tag)}"/>`]);
|
|
68
|
+
if (props.id !== void 0) modelled.push(["id", `<w:id w:val="${props.id}"/>`]);
|
|
69
|
+
if (props.lock !== void 0) modelled.push(["lock", `<w:lock w:val="${props.lock}"/>`]);
|
|
70
|
+
if (props.placeholder !== void 0) modelled.push(["placeholder", `<w:placeholder><w:docPart w:val="${escapeXmlAttribute(props.placeholder)}"/></w:placeholder>`]);
|
|
71
|
+
if (props.showingPlaceholder !== void 0) modelled.push(["showingPlcHdr", serializeOnOffElement(props.showingPlaceholder, "showingPlcHdr")]);
|
|
72
|
+
const captured = props.preserved?.children ?? [];
|
|
73
|
+
let statedKind = false;
|
|
74
|
+
const preserved = captured.map((child) => {
|
|
75
|
+
if (!statesControlKind(child.xml)) return child;
|
|
76
|
+
statedKind = true;
|
|
77
|
+
return {
|
|
78
|
+
index: child.index,
|
|
79
|
+
xml: withModelledControlState(child.xml, props)
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
if (!statedKind) modelled.push(synthesizedKind(props));
|
|
83
|
+
const body = serializeSequenceChildren({
|
|
84
|
+
container: "content-control-properties",
|
|
85
|
+
modelled,
|
|
86
|
+
preserved: props.preserved === void 0 ? void 0 : { children: preserved }
|
|
87
|
+
}).join("");
|
|
88
|
+
return body.length === 0 ? "<w:sdtPr/>" : `<w:sdtPr>${body}</w:sdtPr>`;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* `w:sdtEndPr`, replayed when the parse captured it and written from the
|
|
92
|
+
* record otherwise.
|
|
93
|
+
*
|
|
94
|
+
* The record's presence is the element's: `<w:sdtEndPr/>` with no `w:rPr` is
|
|
95
|
+
* what Word writes for most controls and differs from a missing element.
|
|
96
|
+
*/
|
|
97
|
+
const serializeSdtEndProperties = (properties) => {
|
|
98
|
+
if (properties.rawEndPropertiesXml && isSingleWellFormedElement(properties.rawEndPropertiesXml, "sdtEndPr")) return properties.rawEndPropertiesXml;
|
|
99
|
+
const endProperties = properties.endProperties;
|
|
100
|
+
if (endProperties === void 0) return "";
|
|
101
|
+
const runProperties = serializeTextFormatting(endProperties.runProperties);
|
|
102
|
+
return runProperties.length > 0 ? `<w:sdtEndPr>${runProperties}</w:sdtEndPr>` : "<w:sdtEndPr/>";
|
|
103
|
+
};
|
|
104
|
+
/** `w:sdtPr` followed by `w:sdtEndPr`, in schema order. */
|
|
105
|
+
const serializeSdtPropertyElements = (properties) => `${serializeSdtProperties(properties)}${serializeSdtEndProperties(properties)}`;
|
|
106
|
+
/** The one writer of an SDT wrapper at every content-model level. */
|
|
107
|
+
const serializeSdtWrapper = (properties, contentXml) => {
|
|
108
|
+
return `<w:sdt>${serializeSdtPropertyElements(properties)}${properties.rawSdtChildrenBeforeContent ?? ""}<w:sdtContent>${contentXml}</w:sdtContent>${properties.rawSdtChildrenAfterContent ?? ""}</w:sdt>`;
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { serializeSdtEndProperties, serializeSdtProperties, serializeSdtPropertyElements, serializeSdtWrapper };
|