@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,14 +1,19 @@
|
|
|
1
1
|
import { canonicalJson } from "../../utils/canonicalJson.js";
|
|
2
2
|
import { isValidHexColor } from "../../utils/colorResolver.js";
|
|
3
|
-
import {
|
|
3
|
+
import { serializePreservedAttributes } from "../attributeRemainder.js";
|
|
4
|
+
import { withPreservedChildren } from "../containerChildren.js";
|
|
5
|
+
import { TRANSITIONAL_NAME_BY_STRICT_NAME } from "../strictNames.gen.js";
|
|
4
6
|
import { TABLE_LOOK_FLAGS } from "../tableLook.js";
|
|
5
|
-
import { parseTableCellProperties, parseTableGrid, parseTableProperties, parseTableRowProperties } from "../tableParser.js";
|
|
6
|
-
import {
|
|
7
|
-
import { NAMESPACES, OOXML_NAMESPACE_SCOPE, parseXml } from "../xmlParser.js";
|
|
7
|
+
import { parseTableCellProperties, parseTableGrid, parseTableProperties, parseTablePropertyExceptions, parseTableRowProperties } from "../tableParser.js";
|
|
8
|
+
import { OOXML_NAMESPACE_SCOPE, parseXml } from "../xmlParser.js";
|
|
8
9
|
import { serializeBorder } from "./borderSerializer.js";
|
|
10
|
+
import { serializeBookmarkMarker } from "./markupRangeAttributes.js";
|
|
11
|
+
import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
|
|
9
12
|
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
10
13
|
import { intAttr } from "./xmlUtils.js";
|
|
11
|
-
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
14
|
+
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
15
|
+
import { themeColorToken } from "@stll/docx-core/model";
|
|
16
|
+
import { serializeSequenceChildren } from "@stll/docx-core/schema";
|
|
12
17
|
//#region src/docx/serializer/tableSerializer.ts
|
|
13
18
|
/**
|
|
14
19
|
* The captured element with the revision children written back into it.
|
|
@@ -29,20 +34,36 @@ const withRevisionChildren = (sourceXml, revisions) => {
|
|
|
29
34
|
};
|
|
30
35
|
/** `w:trPr/w:ins` | `w:trPr/w:del`, the row's own structural revision. */
|
|
31
36
|
const rowStructuralChangeXml = (change) => {
|
|
32
|
-
if (change?.type === "tableRowInsertion") return
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
if (change?.type === "tableRowInsertion") return {
|
|
38
|
+
name: "ins",
|
|
39
|
+
xml: `<w:ins ${serializeTrackedChangeAttributes(change.info)}/>`
|
|
40
|
+
};
|
|
41
|
+
if (change?.type === "tableRowDeletion") return {
|
|
42
|
+
name: "del",
|
|
43
|
+
xml: `<w:del ${serializeTrackedChangeAttributes(change.info)}/>`
|
|
44
|
+
};
|
|
35
45
|
};
|
|
36
46
|
/** `w:tcPr/w:cellIns` | `w:cellDel` | `w:cellMerge`, the cell's own. */
|
|
37
47
|
const cellStructuralChangeXml = (change) => {
|
|
38
|
-
if (change?.type === "tableCellInsertion") return
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
if (change?.type === "tableCellInsertion") return {
|
|
49
|
+
name: "cellIns",
|
|
50
|
+
xml: `<w:cellIns ${serializeTrackedChangeAttributes(change.info)}/>`
|
|
51
|
+
};
|
|
52
|
+
if (change?.type === "tableCellDeletion") return {
|
|
53
|
+
name: "cellDel",
|
|
54
|
+
xml: `<w:cellDel ${serializeTrackedChangeAttributes(change.info)}/>`
|
|
55
|
+
};
|
|
56
|
+
if (change?.type !== "tableCellMerge") return;
|
|
41
57
|
const attrs = [serializeTrackedChangeAttributes(change.info)];
|
|
42
58
|
if (change.verticalMerge) attrs.push(`w:vMerge="${change.verticalMerge === "continue" ? "cont" : "rest"}"`);
|
|
43
59
|
if (change.verticalMergeOriginal) attrs.push(`w:vMergeOrig="${change.verticalMergeOriginal === "continue" ? "cont" : "rest"}"`);
|
|
44
|
-
return
|
|
60
|
+
return {
|
|
61
|
+
name: "cellMerge",
|
|
62
|
+
xml: `<w:cellMerge ${attrs.join(" ")}/>`
|
|
63
|
+
};
|
|
45
64
|
};
|
|
65
|
+
/** The one structural revision a property set carries, as a modelled entry. */
|
|
66
|
+
const structuralChangeEntry = (name, change) => [name, change?.name === name ? change.xml : ""];
|
|
46
67
|
/**
|
|
47
68
|
* A property set without the elements kept beside it. Only the typed values
|
|
48
69
|
* decide whether a capture still describes the node; the captures themselves
|
|
@@ -81,6 +102,16 @@ function serializeMeasurement(measurement, elementName) {
|
|
|
81
102
|
return `<w:${elementName} ${[`w:w="${intAttr(measurement.value)}"`, `w:type="${measurement.type}"`].join(" ")}/>`;
|
|
82
103
|
}
|
|
83
104
|
/**
|
|
105
|
+
* The side names folio writes, from the table the census reads.
|
|
106
|
+
*
|
|
107
|
+
* A Strict producer spells these `w:start` and `w:end`; folio rebuilds every
|
|
108
|
+
* package as Transitional and writes one spelling, and taking it from the
|
|
109
|
+
* generated table is what keeps the writer and the survival law's equivalence
|
|
110
|
+
* from drifting apart.
|
|
111
|
+
*/
|
|
112
|
+
const BORDER_LEFT = TRANSITIONAL_NAME_BY_STRICT_NAME["CT_Border start"];
|
|
113
|
+
const BORDER_RIGHT = TRANSITIONAL_NAME_BY_STRICT_NAME["CT_Border end"];
|
|
114
|
+
/**
|
|
84
115
|
* Serialize table borders (w:tblBorders or w:tcBorders)
|
|
85
116
|
*/
|
|
86
117
|
function serializeTableBorderParts(borders) {
|
|
@@ -90,9 +121,9 @@ function serializeTableBorderParts(borders) {
|
|
|
90
121
|
if (xml) parts.push(xml);
|
|
91
122
|
};
|
|
92
123
|
appendBorder(borders.top, "top");
|
|
93
|
-
appendBorder(borders.left,
|
|
124
|
+
appendBorder(borders.left, BORDER_LEFT);
|
|
94
125
|
appendBorder(borders.bottom, "bottom");
|
|
95
|
-
appendBorder(borders.right,
|
|
126
|
+
appendBorder(borders.right, BORDER_RIGHT);
|
|
96
127
|
appendBorder(borders.insideH, "insideH");
|
|
97
128
|
appendBorder(borders.insideV, "insideV");
|
|
98
129
|
return parts;
|
|
@@ -112,6 +143,9 @@ function serializeTableCellBorders(borders) {
|
|
|
112
143
|
if (topRightToBottomLeft) parts.push(topRightToBottomLeft);
|
|
113
144
|
return parts.length > 0 ? `<w:tcBorders>${parts.join("")}</w:tcBorders>` : "";
|
|
114
145
|
}
|
|
146
|
+
/** The same rename one type over: a cell margin is a `CT_TblWidth`. */
|
|
147
|
+
const MARGIN_LEFT = TRANSITIONAL_NAME_BY_STRICT_NAME["CT_TblWidth start"];
|
|
148
|
+
const MARGIN_RIGHT = TRANSITIONAL_NAME_BY_STRICT_NAME["CT_TblWidth end"];
|
|
115
149
|
/**
|
|
116
150
|
* Serialize cell margins (w:tblCellMar or w:tcMar)
|
|
117
151
|
*/
|
|
@@ -119,9 +153,9 @@ function serializeCellMargins(margins, elementName) {
|
|
|
119
153
|
if (!margins) return "";
|
|
120
154
|
const parts = [];
|
|
121
155
|
if (margins.top) parts.push(serializeMeasurement(margins.top, "top"));
|
|
122
|
-
if (margins.left) parts.push(serializeMeasurement(margins.left,
|
|
156
|
+
if (margins.left) parts.push(serializeMeasurement(margins.left, MARGIN_LEFT));
|
|
123
157
|
if (margins.bottom) parts.push(serializeMeasurement(margins.bottom, "bottom"));
|
|
124
|
-
if (margins.right) parts.push(serializeMeasurement(margins.right,
|
|
158
|
+
if (margins.right) parts.push(serializeMeasurement(margins.right, MARGIN_RIGHT));
|
|
125
159
|
if (parts.length === 0) return "";
|
|
126
160
|
return `<w:${elementName}>${parts.join("")}</w:${elementName}>`;
|
|
127
161
|
}
|
|
@@ -135,9 +169,12 @@ function serializeShading(shading) {
|
|
|
135
169
|
else attrs.push("w:val=\"clear\"");
|
|
136
170
|
if (shading.color?.rgb && isValidHexColor(shading.color.rgb)) attrs.push(`w:color="${escapeXmlAttribute(shading.color.rgb)}"`);
|
|
137
171
|
else if (shading.color?.auto) attrs.push("w:color=\"auto\"");
|
|
172
|
+
if (shading.color?.themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColorToken(shading.color.themeColor))}"`);
|
|
173
|
+
if (shading.color?.themeTint) attrs.push(`w:themeTint="${escapeXmlAttribute(shading.color.themeTint)}"`);
|
|
174
|
+
if (shading.color?.themeShade) attrs.push(`w:themeShade="${escapeXmlAttribute(shading.color.themeShade)}"`);
|
|
138
175
|
if (shading.fill?.rgb && isValidHexColor(shading.fill.rgb)) attrs.push(`w:fill="${escapeXmlAttribute(shading.fill.rgb)}"`);
|
|
139
176
|
else if (shading.fill?.auto) attrs.push("w:fill=\"auto\"");
|
|
140
|
-
if (shading.fill?.themeColor) attrs.push(`w:themeFill="${escapeXmlAttribute(shading.fill.themeColor)}"`);
|
|
177
|
+
if (shading.fill?.themeColor) attrs.push(`w:themeFill="${escapeXmlAttribute(themeColorToken(shading.fill.themeColor))}"`);
|
|
141
178
|
if (shading.fill?.themeTint) attrs.push(`w:themeFillTint="${escapeXmlAttribute(shading.fill.themeTint)}"`);
|
|
142
179
|
if (shading.fill?.themeShade) attrs.push(`w:themeFillShade="${escapeXmlAttribute(shading.fill.themeShade)}"`);
|
|
143
180
|
if (attrs.length === 0) return "";
|
|
@@ -182,37 +219,39 @@ function serializeFloatingTableProperties(floating) {
|
|
|
182
219
|
if (attrs.length === 0) return "";
|
|
183
220
|
return `<w:tblpPr ${attrs.join(" ")}/>`;
|
|
184
221
|
}
|
|
222
|
+
/** `<w:name w:val="…"/>`, or nothing when the model holds no value. */
|
|
223
|
+
const tagWithVal = (name, value) => value === void 0 ? "" : `<w:${name} w:val="${escapeXmlAttribute(value)}"/>`;
|
|
224
|
+
const numberTag = (name, value) => value === void 0 ? "" : `<w:${name} w:val="${intAttr(value)}"/>`;
|
|
185
225
|
/**
|
|
186
226
|
* Serialize table formatting properties (w:tblPr)
|
|
187
227
|
*/
|
|
188
228
|
function serializeTableFormatting(formatting, propertyChanges) {
|
|
189
229
|
const tableSource = verifiedSourceXml(formatting, parseTableProperties);
|
|
190
230
|
if (tableSource !== null) return withRevisionChildren(tableSource, (propertyChanges ?? []).map((change) => serializeTablePropertyChange(change)));
|
|
191
|
-
const parts =
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
if (propertyChanges && propertyChanges.length > 0) parts.push(...propertyChanges.map((change) => serializeTablePropertyChange(change)));
|
|
231
|
+
const parts = serializeSequenceChildren({
|
|
232
|
+
container: "table-properties",
|
|
233
|
+
modelled: [
|
|
234
|
+
["tblStyle", formatting?.styleId ? tagWithVal("tblStyle", formatting.styleId) : ""],
|
|
235
|
+
["tblpPr", serializeFloatingTableProperties(formatting?.floating)],
|
|
236
|
+
["tblOverlap", formatting?.overlap ? `<w:tblOverlap w:val="${formatting.overlap}"/>` : ""],
|
|
237
|
+
["bidiVisual", serializeOnOffElement(formatting?.bidi, "bidiVisual")],
|
|
238
|
+
["tblStyleRowBandSize", numberTag("tblStyleRowBandSize", formatting?.rowBandSize)],
|
|
239
|
+
["tblStyleColBandSize", numberTag("tblStyleColBandSize", formatting?.columnBandSize)],
|
|
240
|
+
["tblW", serializeMeasurement(formatting?.width, "tblW")],
|
|
241
|
+
["jc", formatting?.justification ? `<w:jc w:val="${formatting.justification}"/>` : ""],
|
|
242
|
+
["tblCellSpacing", serializeMeasurement(formatting?.cellSpacing, "tblCellSpacing")],
|
|
243
|
+
["tblInd", serializeMeasurement(formatting?.indent, "tblInd")],
|
|
244
|
+
["tblBorders", serializeTableBorders(formatting?.borders, "tblBorders")],
|
|
245
|
+
["shd", serializeShading(formatting?.shading)],
|
|
246
|
+
["tblLayout", formatting?.layout ? `<w:tblLayout w:type="${formatting.layout}"/>` : ""],
|
|
247
|
+
["tblCellMar", serializeCellMargins(formatting?.cellMargins, "tblCellMar")],
|
|
248
|
+
["tblLook", serializeTableLook(formatting?.look)],
|
|
249
|
+
["tblCaption", tagWithVal("tblCaption", formatting?.caption)],
|
|
250
|
+
["tblDescription", tagWithVal("tblDescription", formatting?.description)],
|
|
251
|
+
["tblPrChange", (propertyChanges ?? []).map((change) => serializeTablePropertyChange(change)).join("")]
|
|
252
|
+
],
|
|
253
|
+
preserved: formatting?.preserved
|
|
254
|
+
});
|
|
216
255
|
if (parts.length === 0) return "";
|
|
217
256
|
return `<w:tblPr>${parts.join("")}</w:tblPr>`;
|
|
218
257
|
}
|
|
@@ -226,32 +265,73 @@ function serializeTablePropertyChange(change) {
|
|
|
226
265
|
return `<w:tblPrChange ${attrs}>${previousTblPrInner.length > 0 ? `<w:tblPr>${previousTblPrInner}</w:tblPr>` : "<w:tblPr/>"}</w:tblPrChange>`;
|
|
227
266
|
}
|
|
228
267
|
/**
|
|
268
|
+
* Serialize a row's table property exceptions (w:tblPrEx).
|
|
269
|
+
*
|
|
270
|
+
* `CT_TblPrEx` is a sequence like `CT_TblPr`, and the nine children it shares
|
|
271
|
+
* with it are written by the same statements: the modelled half is keyed by
|
|
272
|
+
* element name and `serializeSequenceChildren` puts it in the generated order,
|
|
273
|
+
* so the exception and the property it overrides cannot come out spelled two
|
|
274
|
+
* different ways.
|
|
275
|
+
*/
|
|
276
|
+
function serializeTablePropertyExceptions(exceptions, propertyChanges) {
|
|
277
|
+
if (exceptions === void 0 && (propertyChanges ?? []).length === 0) return "";
|
|
278
|
+
const exceptionSource = verifiedSourceXml(exceptions, parseTablePropertyExceptions);
|
|
279
|
+
if (exceptionSource !== null) return withRevisionChildren(exceptionSource, (propertyChanges ?? []).map((change) => serializeTablePropertyExceptionChange(change)));
|
|
280
|
+
const parts = serializeSequenceChildren({
|
|
281
|
+
container: "table-property-exceptions",
|
|
282
|
+
modelled: [
|
|
283
|
+
["tblW", serializeMeasurement(exceptions?.width, "tblW")],
|
|
284
|
+
["jc", exceptions?.justification ? `<w:jc w:val="${exceptions.justification}"/>` : ""],
|
|
285
|
+
["tblCellSpacing", serializeMeasurement(exceptions?.cellSpacing, "tblCellSpacing")],
|
|
286
|
+
["tblInd", serializeMeasurement(exceptions?.indent, "tblInd")],
|
|
287
|
+
["tblBorders", serializeTableBorders(exceptions?.borders, "tblBorders")],
|
|
288
|
+
["shd", serializeShading(exceptions?.shading)],
|
|
289
|
+
["tblLayout", exceptions?.layout ? `<w:tblLayout w:type="${exceptions.layout}"/>` : ""],
|
|
290
|
+
["tblCellMar", serializeCellMargins(exceptions?.cellMargins, "tblCellMar")],
|
|
291
|
+
["tblLook", serializeTableLook(exceptions?.look)],
|
|
292
|
+
["tblPrExChange", (propertyChanges ?? []).map((change) => serializeTablePropertyExceptionChange(change)).join("")]
|
|
293
|
+
],
|
|
294
|
+
preserved: exceptions?.preserved
|
|
295
|
+
});
|
|
296
|
+
return parts.length === 0 ? "<w:tblPrEx/>" : `<w:tblPrEx>${parts.join("")}</w:tblPrEx>`;
|
|
297
|
+
}
|
|
298
|
+
function serializeTablePropertyExceptionChange(change) {
|
|
299
|
+
return `<w:tblPrExChange ${serializeTrackedChangeAttributes(change.info)}>${serializeTablePropertyExceptions(change.previousFormatting) || "<w:tblPrEx/>"}</w:tblPrExChange>`;
|
|
300
|
+
}
|
|
301
|
+
/** `w:trHeight`, whose value rides `w:val` rather than `w:w`. */
|
|
302
|
+
const serializeRowHeight = (formatting) => {
|
|
303
|
+
if (!formatting?.height) return "";
|
|
304
|
+
const attrs = [`w:val="${intAttr(formatting.height.value)}"`];
|
|
305
|
+
if (formatting.heightRule) attrs.push(`w:hRule="${formatting.heightRule}"`);
|
|
306
|
+
return `<w:trHeight ${attrs.join(" ")}/>`;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
229
309
|
* Serialize table row formatting properties (w:trPr)
|
|
230
310
|
*/
|
|
231
311
|
function serializeTableRowFormatting(formatting, propertyChanges, structuralChange) {
|
|
312
|
+
const rowStructuralChange = rowStructuralChangeXml(structuralChange);
|
|
232
313
|
const rowSource = verifiedSourceXml(formatting, parseTableRowProperties);
|
|
233
|
-
if (rowSource !== null) return withRevisionChildren(rowSource, [...
|
|
234
|
-
const parts =
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
if (parts.length === 0) return "";
|
|
314
|
+
if (rowSource !== null) return withRevisionChildren(rowSource, [...rowStructuralChange ? [rowStructuralChange.xml] : [], ...(propertyChanges ?? []).map((change) => serializeTableRowPropertyChange(change))]);
|
|
315
|
+
const parts = serializeSequenceChildren({
|
|
316
|
+
container: "row-properties",
|
|
317
|
+
modelled: [
|
|
318
|
+
["cnfStyle", serializeConditionalFormatStyle(formatting?.conditionalFormat)],
|
|
319
|
+
["gridBefore", formatting?.gridBefore ? `<w:gridBefore w:val="${intAttr(formatting.gridBefore)}"/>` : ""],
|
|
320
|
+
["gridAfter", formatting?.gridAfter ? `<w:gridAfter w:val="${intAttr(formatting.gridAfter)}"/>` : ""],
|
|
321
|
+
["wBefore", serializeMeasurement(formatting?.widthBefore, "wBefore")],
|
|
322
|
+
["wAfter", serializeMeasurement(formatting?.widthAfter, "wAfter")],
|
|
323
|
+
["cantSplit", serializeOnOffElement(formatting?.cantSplit, "cantSplit")],
|
|
324
|
+
["trHeight", serializeRowHeight(formatting)],
|
|
325
|
+
["tblHeader", serializeOnOffElement(formatting?.header, "tblHeader")],
|
|
326
|
+
["jc", formatting?.justification ? `<w:jc w:val="${formatting.justification}"/>` : ""],
|
|
327
|
+
["hidden", serializeOnOffElement(formatting?.hidden, "hidden")],
|
|
328
|
+
structuralChangeEntry("ins", rowStructuralChange),
|
|
329
|
+
structuralChangeEntry("del", rowStructuralChange),
|
|
330
|
+
["trPrChange", (propertyChanges ?? []).map((change) => serializeTableRowPropertyChange(change)).join("")]
|
|
331
|
+
],
|
|
332
|
+
preserved: formatting?.preserved
|
|
333
|
+
});
|
|
334
|
+
if (parts.length === 0) return formatting === void 0 ? "" : "<w:trPr/>";
|
|
255
335
|
return `<w:trPr>${parts.join("")}</w:trPr>`;
|
|
256
336
|
}
|
|
257
337
|
function extractTrPrInner(trPrXml) {
|
|
@@ -285,37 +365,41 @@ function serializeConditionalFormatStyle(style) {
|
|
|
285
365
|
if (val === "000000000000") return "";
|
|
286
366
|
return `<w:cnfStyle w:val="${val}"/>`;
|
|
287
367
|
}
|
|
368
|
+
/** `w:vMerge`: no `w:val` is the continuation, so only a restart states one. */
|
|
369
|
+
const serializeVerticalMerge = (vMerge) => {
|
|
370
|
+
if (vMerge === void 0) return "";
|
|
371
|
+
return vMerge === "restart" ? "<w:vMerge w:val=\"restart\"/>" : "<w:vMerge/>";
|
|
372
|
+
};
|
|
288
373
|
/**
|
|
289
374
|
* Serialize table cell formatting properties (w:tcPr)
|
|
290
375
|
*/
|
|
291
376
|
function serializeTableCellFormatting(formatting, propertyChanges, structuralChange) {
|
|
377
|
+
const cellStructuralChange = cellStructuralChangeXml(structuralChange);
|
|
292
378
|
const cellSource = verifiedSourceXml(formatting, parseTableCellProperties);
|
|
293
|
-
if (cellSource !== null) return withRevisionChildren(cellSource, [...
|
|
294
|
-
const parts =
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
parts.
|
|
317
|
-
if (propertyChanges && propertyChanges.length > 0) parts.push(...propertyChanges.map((change) => serializeTableCellPropertyChange(change)));
|
|
318
|
-
if (parts.length === 0) return "";
|
|
379
|
+
if (cellSource !== null) return withRevisionChildren(cellSource, [...cellStructuralChange ? [cellStructuralChange.xml] : [], ...(propertyChanges ?? []).map((change) => serializeTableCellPropertyChange(change))]);
|
|
380
|
+
const parts = serializeSequenceChildren({
|
|
381
|
+
container: "cell-properties",
|
|
382
|
+
modelled: [
|
|
383
|
+
["cnfStyle", serializeConditionalFormatStyle(formatting?.conditionalFormat)],
|
|
384
|
+
["tcW", serializeMeasurement(formatting?.width, "tcW")],
|
|
385
|
+
["gridSpan", formatting?.gridSpan && formatting.gridSpan > 1 ? `<w:gridSpan w:val="${intAttr(formatting.gridSpan)}"/>` : ""],
|
|
386
|
+
["vMerge", serializeVerticalMerge(formatting?.vMerge)],
|
|
387
|
+
["tcBorders", serializeTableCellBorders(formatting?.borders)],
|
|
388
|
+
["shd", serializeShading(formatting?.shading)],
|
|
389
|
+
["noWrap", serializeOnOffElement(formatting?.noWrap, "noWrap")],
|
|
390
|
+
["tcMar", serializeCellMargins(formatting?.margins, "tcMar")],
|
|
391
|
+
["textDirection", formatting?.textDirection ? `<w:textDirection w:val="${formatting.textDirection}"/>` : ""],
|
|
392
|
+
["tcFitText", serializeOnOffElement(formatting?.fitText, "tcFitText")],
|
|
393
|
+
["vAlign", formatting?.verticalAlign ? `<w:vAlign w:val="${formatting.verticalAlign}"/>` : ""],
|
|
394
|
+
["hideMark", serializeOnOffElement(formatting?.hideMark, "hideMark")],
|
|
395
|
+
structuralChangeEntry("cellIns", cellStructuralChange),
|
|
396
|
+
structuralChangeEntry("cellDel", cellStructuralChange),
|
|
397
|
+
structuralChangeEntry("cellMerge", cellStructuralChange),
|
|
398
|
+
["tcPrChange", (propertyChanges ?? []).map((change) => serializeTableCellPropertyChange(change)).join("")]
|
|
399
|
+
],
|
|
400
|
+
preserved: formatting?.preserved
|
|
401
|
+
});
|
|
402
|
+
if (parts.length === 0) return formatting === void 0 ? "" : "<w:tcPr/>";
|
|
319
403
|
return `<w:tcPr>${parts.join("")}</w:tcPr>`;
|
|
320
404
|
}
|
|
321
405
|
function extractTcPrInner(tcPrXml) {
|
|
@@ -324,7 +408,7 @@ function extractTcPrInner(tcPrXml) {
|
|
|
324
408
|
}
|
|
325
409
|
function serializeTableCellPropertyChange(change) {
|
|
326
410
|
const attrs = serializeTrackedChangeAttributes(change.info);
|
|
327
|
-
const previousTcPrInner = extractTcPrInner(serializeTableCellFormatting(change.previousFormatting) || "<w:tcPr/>");
|
|
411
|
+
const previousTcPrInner = extractTcPrInner(serializeTableCellFormatting(change.previousFormatting, void 0, change.previousStructuralChange) || "<w:tcPr/>");
|
|
328
412
|
return `<w:tcPrChange ${attrs}>${previousTcPrInner.length > 0 ? `<w:tcPr>${previousTcPrInner}</w:tcPr>` : "<w:tcPr/>"}</w:tcPrChange>`;
|
|
329
413
|
}
|
|
330
414
|
/**
|
|
@@ -353,24 +437,90 @@ function serializeTableGrid(table) {
|
|
|
353
437
|
if (gridSourceXml !== void 0) {
|
|
354
438
|
if (canonicalJson(parseTableGrid(parseXml(gridSourceXml, OOXML_NAMESPACE_SCOPE).elements?.[0] ?? null)) === canonicalJson(columnWidths)) return gridSourceXml;
|
|
355
439
|
}
|
|
356
|
-
const
|
|
440
|
+
const change = table.formatting?.gridChange;
|
|
441
|
+
const gridChange = change === void 0 ? "" : serializeTableGridChange(change);
|
|
357
442
|
if (columnWidths && columnWidths.length > 0) return `<w:tblGrid>${columnWidths.map((w) => `<w:gridCol w:w="${intAttr(w)}"/>`).join("")}${gridChange}</w:tblGrid>`;
|
|
358
443
|
const columns = gridColumnCount(table);
|
|
359
444
|
return columns === 0 && gridChange === "" ? "<w:tblGrid/>" : `<w:tblGrid>${"<w:gridCol/>".repeat(columns)}${gridChange}</w:tblGrid>`;
|
|
360
445
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
446
|
+
/**
|
|
447
|
+
* Serialize `w:tblGridChange`: the grid a reviewer replaced, from the change's
|
|
448
|
+
* own record rather than from the bytes it arrived as.
|
|
449
|
+
*
|
|
450
|
+
* `w:w` is optional on a `w:gridCol`, so a column the snapshot recorded no
|
|
451
|
+
* measure for is written back without one; spelling it as a zero would claim a
|
|
452
|
+
* width the source never stated.
|
|
453
|
+
*/
|
|
454
|
+
const serializeTableGridChange = ({ id, columnWidths }) => {
|
|
455
|
+
const columns = columnWidths.map((width) => width === void 0 ? "<w:gridCol/>" : `<w:gridCol w:w="${intAttr(width)}"/>`).join("");
|
|
456
|
+
return `<w:tblGridChange w:id="${intAttr(id)}"><w:tblGrid>${columns}</w:tblGrid></w:tblGridChange>`;
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* What makes two rows members of the same control.
|
|
460
|
+
*
|
|
461
|
+
* The control's record is on every child it held, so the wrapper is rebuilt
|
|
462
|
+
* by grouping consecutive children that name the same control. Equality is
|
|
463
|
+
* the record's canonical spelling rather than object identity, because the
|
|
464
|
+
* editor carries these records through JSON — a Yjs sync, a snapshot, a
|
|
465
|
+
* structured clone — and hands back an equal record rather than the same one.
|
|
466
|
+
* A wrapper that split in two there would mint a second `w:id` for one
|
|
467
|
+
* control, which is the defect, not the fix.
|
|
468
|
+
*
|
|
469
|
+
* The cost is the other direction: two adjacent rows the author put in two
|
|
470
|
+
* separate but identically spelled controls come back as one. Word mints a
|
|
471
|
+
* distinct `w:id` per control, so that needs a producer that writes none; the
|
|
472
|
+
* inline wrapper stack makes the same trade for the same reason.
|
|
473
|
+
*/
|
|
474
|
+
const contentControlKey = (properties) => canonicalJson(properties);
|
|
475
|
+
/**
|
|
476
|
+
* Re-open each control around the run of children that named it, outermost
|
|
477
|
+
* first.
|
|
478
|
+
*
|
|
479
|
+
* @param depth which layer of the stack this call is opening
|
|
480
|
+
*/
|
|
481
|
+
const serializeControlledChildren = (children, depth) => {
|
|
482
|
+
const parts = [];
|
|
483
|
+
let index = 0;
|
|
484
|
+
while (index < children.length) {
|
|
485
|
+
const child = children[index];
|
|
486
|
+
const control = child.controls[depth];
|
|
487
|
+
if (control === void 0) {
|
|
488
|
+
parts.push(child.xml);
|
|
489
|
+
index += 1;
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
const key = contentControlKey(control);
|
|
493
|
+
let end = index + 1;
|
|
494
|
+
while (end < children.length) {
|
|
495
|
+
const next = children[end]?.controls[depth];
|
|
496
|
+
if (next === void 0 || contentControlKey(next) !== key) break;
|
|
497
|
+
end += 1;
|
|
498
|
+
}
|
|
499
|
+
const inner = serializeControlledChildren(children.slice(index, end), depth + 1);
|
|
500
|
+
parts.push(serializeSdtWrapper(control, inner));
|
|
501
|
+
index = end;
|
|
502
|
+
}
|
|
503
|
+
return parts.join("");
|
|
504
|
+
};
|
|
505
|
+
/** A capture from the sink, with the controls it sat inside when parsed. */
|
|
506
|
+
const preservedChild = (xml, child) => ({
|
|
507
|
+
controls: child.contentControls ?? [],
|
|
508
|
+
xml
|
|
367
509
|
});
|
|
368
510
|
/**
|
|
369
511
|
* Serialize cell content (paragraphs, nested tables)
|
|
370
512
|
*/
|
|
371
513
|
function serializeCellContent(content, serializeParagraph) {
|
|
372
|
-
const parts =
|
|
373
|
-
|
|
514
|
+
const parts = content.map((block) => {
|
|
515
|
+
switch (block.type) {
|
|
516
|
+
case "paragraph": return serializeParagraph(block);
|
|
517
|
+
case "table": return serializeTable(block, serializeParagraph);
|
|
518
|
+
case "preservedBlock": return block.xml;
|
|
519
|
+
case "bookmarkStart":
|
|
520
|
+
case "bookmarkEnd": return serializeBookmarkMarker(block);
|
|
521
|
+
default: return block;
|
|
522
|
+
}
|
|
523
|
+
});
|
|
374
524
|
if (parts.length === 0) parts.push("<w:p/>");
|
|
375
525
|
return parts.join("");
|
|
376
526
|
}
|
|
@@ -385,14 +535,37 @@ function serializeTableCell(cell, serializeParagraph) {
|
|
|
385
535
|
return `<w:tc>${parts.join("")}</w:tc>`;
|
|
386
536
|
}
|
|
387
537
|
/**
|
|
538
|
+
* A container's verbatim sink and its bookmark markers, as one positioned list.
|
|
539
|
+
*
|
|
540
|
+
* Both stand between the same two modelled children and both record where by
|
|
541
|
+
* counting the ones before them, so one writer puts both back. Two entries
|
|
542
|
+
* recorded at the same index keep their group's order, with the sink's first;
|
|
543
|
+
* the source order between a capture and a bookmark sharing a slot is the one
|
|
544
|
+
* thing an index cannot say, and it changes nothing a reader can see.
|
|
545
|
+
*/
|
|
546
|
+
const positionedChildren = (preserved, bookmarks) => {
|
|
547
|
+
if (bookmarks === void 0 || bookmarks.length === 0) return preserved;
|
|
548
|
+
return { children: [...preserved?.children ?? [], ...bookmarks.map(({ index, marker, contentControls }) => ({
|
|
549
|
+
index,
|
|
550
|
+
xml: serializeBookmarkMarker(marker),
|
|
551
|
+
...contentControls === void 0 ? {} : { contentControls }
|
|
552
|
+
}))] };
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
388
555
|
* Serialize a table row (w:tr)
|
|
389
556
|
*/
|
|
390
557
|
function serializeTableRow(row, serializeParagraph) {
|
|
391
558
|
const parts = [];
|
|
559
|
+
const tblPrExXml = serializeTablePropertyExceptions(row.tablePropertyExceptions, row.tablePropertyExceptionChanges);
|
|
560
|
+
if (tblPrExXml) parts.push(tblPrExXml);
|
|
392
561
|
const trPrXml = serializeTableRowFormatting(row.formatting, row.propertyChanges, row.structuralChange);
|
|
393
562
|
if (trPrXml) parts.push(trPrXml);
|
|
394
|
-
|
|
395
|
-
|
|
563
|
+
parts.push(serializeControlledChildren(withPreservedChildren(row.cells.map((cell) => ({
|
|
564
|
+
controls: cell.contentControls ?? [],
|
|
565
|
+
xml: serializeTableCell(cell, serializeParagraph)
|
|
566
|
+
})), positionedChildren(row.preserved, row.bookmarks), preservedChild), 0));
|
|
567
|
+
const attrs = serializePreservedAttributes([], row.preservedAttributes);
|
|
568
|
+
return `<w:tr${attrs.length > 0 ? ` ${attrs.join(" ")}` : ""}>${parts.join("")}</w:tr>`;
|
|
396
569
|
}
|
|
397
570
|
/**
|
|
398
571
|
* Serialize a table to OOXML XML (w:tbl)
|
|
@@ -401,9 +574,14 @@ function serializeTableRow(row, serializeParagraph) {
|
|
|
401
574
|
* @returns XML string for the table
|
|
402
575
|
*/
|
|
403
576
|
function serializeTable(table, serializeParagraph) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
577
|
+
return `<w:tbl>${[
|
|
578
|
+
serializeTableFormatting(table.formatting, table.propertyChanges) || "<w:tblPr/>",
|
|
579
|
+
serializeTableGrid(table),
|
|
580
|
+
serializeControlledChildren(withPreservedChildren(table.rows.map((row) => ({
|
|
581
|
+
controls: row.contentControls ?? [],
|
|
582
|
+
xml: serializeTableRow(row, serializeParagraph)
|
|
583
|
+
})), positionedChildren(table.preserved, table.bookmarks), preservedChild), 0)
|
|
584
|
+
].join("")}</w:tbl>`;
|
|
407
585
|
}
|
|
408
586
|
/**
|
|
409
587
|
* Serialize multiple tables to OOXML XML
|
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { DeclaredChild } from "../containerChildren.gen.js";
|
|
2
3
|
//#region src/docx/serializer/textFormattingSerializer.d.ts
|
|
3
|
-
type ClassifiedShadingField = "color" | "fill" | "pattern";
|
|
4
|
+
type ClassifiedShadingField = "color" | "fill" | "pattern" | "preservedAttributes";
|
|
4
5
|
type ExhaustiveShadingProperties = document_d_exports.ExhaustiveFields<document_d_exports.ShadingProperties, ClassifiedShadingField>;
|
|
5
|
-
type ClassifiedTextFormattingField = "bold" | "boldCs" | "italic" | "italicCs" | "underline" | "strike" | "doubleStrike" | "vertAlign" | "smallCaps" | "allCaps" | "hidden" | "noProof" | "color" | "highlight" | "shading" | "fontSize" | "fontSizeCs" | "fontFamily" | "language" | "spacing" | "position" | "scale" | "kerning" | "effect" | "emphasisMark" | "emboss" | "imprint" | "outline" | "shadow" | "rtl" | "cs" | "styleId";
|
|
6
|
+
type ClassifiedTextFormattingField = "bold" | "boldCs" | "italic" | "italicCs" | "underline" | "strike" | "doubleStrike" | "vertAlign" | "smallCaps" | "allCaps" | "hidden" | "noProof" | "color" | "highlight" | "shading" | "fontSize" | "fontSizeCs" | "fontFamily" | "language" | "spacing" | "position" | "scale" | "kerning" | "effect" | "emphasisMark" | "emboss" | "imprint" | "outline" | "shadow" | "rtl" | "cs" | "styleId" | "preserved";
|
|
6
7
|
type ExhaustiveTextFormatting = document_d_exports.ExhaustiveFields<document_d_exports.TextFormatting, ClassifiedTextFormattingField>;
|
|
8
|
+
/**
|
|
9
|
+
* A child of this `w:rPr` that another record owns, named by its declared
|
|
10
|
+
* child so the sequence places it.
|
|
11
|
+
*
|
|
12
|
+
* A run's `w:rPrChange` and the paragraph mark's revision and `w:specVanish`
|
|
13
|
+
* are read by the run's and the paragraph's own records, so they arrive here
|
|
14
|
+
* as markup rather than as a field. Naming each one means the schema decides
|
|
15
|
+
* where it goes, exactly as it does for the modelled children.
|
|
16
|
+
*/
|
|
17
|
+
type OwnedRunPropertyChild = readonly [name: DeclaredChild<"run-properties">, xml: string];
|
|
7
18
|
/**
|
|
8
19
|
* Serialize shading properties (w:shd)
|
|
9
20
|
*/
|
|
10
21
|
declare function serializeShading(shading: ExhaustiveShadingProperties | undefined): string;
|
|
11
22
|
/**
|
|
12
|
-
*
|
|
23
|
+
* The single `w:rPr` writer.
|
|
24
|
+
*
|
|
25
|
+
* A run, the paragraph mark, a style, a numbering level and the snapshot
|
|
26
|
+
* inside either kind of `w:rPrChange` all write their run properties through
|
|
27
|
+
* here, so none of them can grow its own order or its own idea of which
|
|
28
|
+
* children exist. `EG_RPrBase` is an `xsd:choice` referenced
|
|
29
|
+
* `maxOccurs="unbounded"`, so a `w:rPr` in any order is valid and the order
|
|
30
|
+
* below is a canonical form rather than a validity rule: it is the one Word
|
|
31
|
+
* writes, and writing it from the generated declared-child list is what stops
|
|
32
|
+
* two of folio's serializers from disagreeing. The restatement is what
|
|
33
|
+
* drifted, and it is why folio wrote `w:vanish` before `w:noProof` while the
|
|
34
|
+
* schema declares the reverse.
|
|
35
|
+
*
|
|
36
|
+
* @param owned children a sibling record holds; see {@link OwnedRunPropertyChild}
|
|
13
37
|
*/
|
|
14
|
-
declare function serializeTextFormatting(input: ExhaustiveTextFormatting | undefined): string;
|
|
38
|
+
declare function serializeTextFormatting(input: ExhaustiveTextFormatting | undefined, owned?: readonly OwnedRunPropertyChild[]): string;
|
|
15
39
|
//#endregion
|
|
16
40
|
export { serializeShading, serializeTextFormatting };
|