@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,4 +1,17 @@
|
|
|
1
|
+
import { TABLE_JUSTIFICATION_VALUES } from "../types/documentEnumValues.js";
|
|
1
2
|
//#region src/utils/tableOperations.ts
|
|
3
|
+
const TABLE_PROPERTY_JUSTIFICATION_ORDER = {
|
|
4
|
+
left: 0,
|
|
5
|
+
center: 1,
|
|
6
|
+
right: 2,
|
|
7
|
+
start: 3,
|
|
8
|
+
end: 4
|
|
9
|
+
};
|
|
10
|
+
const TABLE_PROPERTY_JUSTIFICATIONS = Object.freeze(TABLE_JUSTIFICATION_VALUES.toSorted((left, right) => TABLE_PROPERTY_JUSTIFICATION_ORDER[left] - TABLE_PROPERTY_JUSTIFICATION_ORDER[right]));
|
|
11
|
+
const toTablePropertyJustification = (value) => {
|
|
12
|
+
for (const justification of TABLE_PROPERTY_JUSTIFICATIONS) if (value === justification) return justification;
|
|
13
|
+
return "left";
|
|
14
|
+
};
|
|
2
15
|
const getColumnCount = (table) => {
|
|
3
16
|
let maxCols = 0;
|
|
4
17
|
for (const row of table.rows) {
|
|
@@ -256,4 +269,4 @@ const splitCell = (table, rowIndex, columnIndex) => {
|
|
|
256
269
|
};
|
|
257
270
|
};
|
|
258
271
|
//#endregion
|
|
259
|
-
export { addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell };
|
|
272
|
+
export { TABLE_PROPERTY_JUSTIFICATIONS, addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell, toTablePropertyJustification };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TableAlignment } from "../types/formatting.js";
|
|
2
|
+
//#region src/utils/tablePlacement.d.ts
|
|
3
|
+
type PhysicalTableAlignment = "left" | "center" | "right";
|
|
4
|
+
/** Resolve an OOXML table placement to a physical inline alignment. */
|
|
5
|
+
declare const resolveTablePlacementAlignment: (placement: TableAlignment, rightToLeft: boolean) => PhysicalTableAlignment;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { PhysicalTableAlignment, resolveTablePlacementAlignment };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/utils/tablePlacement.ts
|
|
2
|
+
/** Resolve an OOXML table placement to a physical inline alignment. */
|
|
3
|
+
const resolveTablePlacementAlignment = (placement, rightToLeft) => {
|
|
4
|
+
switch (placement) {
|
|
5
|
+
case "center": return "center";
|
|
6
|
+
case "left":
|
|
7
|
+
case "start": return rightToLeft ? "right" : "left";
|
|
8
|
+
case "right":
|
|
9
|
+
case "end": return rightToLeft ? "left" : "right";
|
|
10
|
+
default: return placement;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { resolveTablePlacementAlignment };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TextDirection } from "@stll/docx-core/model";
|
|
2
|
+
//#region src/utils/textDirectionFlow.d.ts
|
|
3
|
+
type TextFlowCss = {
|
|
4
|
+
/** `horizontal-tb` needs no declaration; the others are written out. */
|
|
5
|
+
writingMode: "horizontal-tb" | "vertical-lr" | "vertical-rl";
|
|
6
|
+
/**
|
|
7
|
+
* CSS has no writing mode for a bottom-to-top flow, so the nearest one is
|
|
8
|
+
* turned upside down.
|
|
9
|
+
*/
|
|
10
|
+
rotateDegrees?: 180;
|
|
11
|
+
};
|
|
12
|
+
/** The CSS a `w:textDirection` token renders as, through the flow it names. */
|
|
13
|
+
declare const textFlowCss: (direction: TextDirection) => TextFlowCss;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { TextFlowCss, textFlowCss };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TEXT_DIRECTION_FLOW_BY_TOKEN } from "@stll/docx-core/model";
|
|
2
|
+
//#region src/utils/textDirectionFlow.ts
|
|
3
|
+
/**
|
|
4
|
+
* The CSS one `w:textDirection` flow renders as.
|
|
5
|
+
*
|
|
6
|
+
* `ST_TextDirection` spells each of its six flows twice — a Strict spelling
|
|
7
|
+
* and a Transitional one — so rendering is decided per flow and read through
|
|
8
|
+
* `TEXT_DIRECTION_FLOW_BY_TOKEN`. Both CSS projections, the editor's inline
|
|
9
|
+
* style and `tableCellToStyle`, read this one map: a cell written `tbRl` and
|
|
10
|
+
* its Strict twin written `rl` cannot render differently in one and the same
|
|
11
|
+
* in the other.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Each text flow, and the CSS that renders it.
|
|
15
|
+
*
|
|
16
|
+
* `tb` and `tbV` are the horizontal flows. `rl` and `rlV` run their lines
|
|
17
|
+
* right to left, `lrV` runs them left to right, and `lr` runs them left to
|
|
18
|
+
* right with its characters bottom-to-top, which CSS cannot express: it takes
|
|
19
|
+
* the nearest writing mode turned over.
|
|
20
|
+
*
|
|
21
|
+
* Total over the flows on purpose: a flow nobody mapped would otherwise render
|
|
22
|
+
* as horizontal text with nothing to say it had been dropped.
|
|
23
|
+
*/
|
|
24
|
+
const TEXT_FLOW_CSS = {
|
|
25
|
+
tb: { writingMode: "horizontal-tb" },
|
|
26
|
+
tbV: { writingMode: "horizontal-tb" },
|
|
27
|
+
rl: { writingMode: "vertical-rl" },
|
|
28
|
+
rlV: { writingMode: "vertical-rl" },
|
|
29
|
+
lrV: { writingMode: "vertical-lr" },
|
|
30
|
+
lr: {
|
|
31
|
+
writingMode: "vertical-lr",
|
|
32
|
+
rotateDegrees: 180
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/** The CSS a `w:textDirection` token renders as, through the flow it names. */
|
|
36
|
+
const textFlowCss = (direction) => TEXT_FLOW_CSS[TEXT_DIRECTION_FLOW_BY_TOKEN[direction]];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { textFlowCss };
|
|
@@ -31,14 +31,26 @@ function mergeStyleTextFormatting(target, source) {
|
|
|
31
31
|
}
|
|
32
32
|
return result;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* A merge answers "what does this text look like once the style, the paragraph
|
|
36
|
+
* mark and the run have all had their say". `preserved` is not a value: it is
|
|
37
|
+
* the bytes one specific `w:rPr` held, and carrying it across a merge would
|
|
38
|
+
* write a style's or a paragraph mark's markup into every run that inherits
|
|
39
|
+
* from it. So no merged formatting has one, on any path out of the function.
|
|
40
|
+
*/
|
|
41
|
+
const withoutPreserved = (formatting) => {
|
|
42
|
+
if (formatting.preserved === void 0) return formatting;
|
|
43
|
+
const { preserved: _preserved, ...values } = formatting;
|
|
44
|
+
return values;
|
|
45
|
+
};
|
|
34
46
|
function mergeTextFormatting(target, source) {
|
|
35
47
|
if (!source && !target) return;
|
|
36
|
-
if (!source) return target;
|
|
37
|
-
if (!target) return { ...source };
|
|
38
|
-
const result = { ...target };
|
|
48
|
+
if (!source) return target && withoutPreserved(target);
|
|
49
|
+
if (!target) return withoutPreserved({ ...source });
|
|
50
|
+
const result = { ...withoutPreserved(target) };
|
|
39
51
|
for (const key of Object.keys(source)) {
|
|
40
52
|
const value = source[key];
|
|
41
|
-
if (value === void 0) continue;
|
|
53
|
+
if (value === void 0 || key === "preserved") continue;
|
|
42
54
|
if (key === "fontFamily" && typeof value === "object") {
|
|
43
55
|
result["fontFamily"] = mergeFontFamily(target.fontFamily, value);
|
|
44
56
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
@@ -24,6 +24,13 @@
|
|
|
24
24
|
"url": "https://github.com/stella/folio.git",
|
|
25
25
|
"directory": "packages/core"
|
|
26
26
|
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"skills",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"NOTICE.md"
|
|
33
|
+
],
|
|
27
34
|
"type": "module",
|
|
28
35
|
"sideEffects": false,
|
|
29
36
|
"exports": {
|
|
@@ -121,7 +128,7 @@
|
|
|
121
128
|
"perf": "bun scripts/profile-editor.ts"
|
|
122
129
|
},
|
|
123
130
|
"dependencies": {
|
|
124
|
-
"@stll/docx-core": "^0.
|
|
131
|
+
"@stll/docx-core": "^0.25.0",
|
|
125
132
|
"@stll/docx-utils": "^0.1.0",
|
|
126
133
|
"@stll/template-conditions": ">=0.4.0 <1.0.0",
|
|
127
134
|
"better-result": "3.0.1",
|
|
@@ -152,12 +159,5 @@
|
|
|
152
159
|
"@types/hyphen": "1.14.0"
|
|
153
160
|
},
|
|
154
161
|
"main": "./dist/index.js",
|
|
155
|
-
"types": "./dist/index.d.ts"
|
|
156
|
-
"files": [
|
|
157
|
-
"dist",
|
|
158
|
-
"skills",
|
|
159
|
-
"README.md",
|
|
160
|
-
"LICENSE",
|
|
161
|
-
"NOTICE.md"
|
|
162
|
-
]
|
|
162
|
+
"types": "./dist/index.d.ts"
|
|
163
163
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/ai-edits/__fixtures__/paragraphs.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* The smallest `.docx` that carries a list of paragraphs, generated rather
|
|
4
|
-
* than committed as bytes so a test's input is legible in its own diff.
|
|
5
|
-
*/
|
|
6
|
-
type ParagraphsDocxOptions = {
|
|
7
|
-
/**
|
|
8
|
-
* Wrap the paragraphs in a single table cell, followed by one body
|
|
9
|
-
* paragraph. The cell's last paragraph then has a sibling in the document
|
|
10
|
-
* and none in its own container, which is the case a paragraph-mark
|
|
11
|
-
* deletion must refuse.
|
|
12
|
-
*/
|
|
13
|
-
inTableCell?: boolean;
|
|
14
|
-
};
|
|
15
|
-
declare const buildParagraphsDocx: (paragraphs: readonly string[], { inTableCell }?: ParagraphsDocxOptions) => Promise<ArrayBuffer>;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { ParagraphsDocxOptions, buildParagraphsDocx };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { escapeXmlText } from "@stll/docx-core";
|
|
2
|
-
import JSZip from "jszip";
|
|
3
|
-
//#region src/ai-edits/__fixtures__/paragraphs.ts
|
|
4
|
-
/**
|
|
5
|
-
* The smallest `.docx` that carries a list of paragraphs, generated rather
|
|
6
|
-
* than committed as bytes so a test's input is legible in its own diff.
|
|
7
|
-
*/
|
|
8
|
-
const NAMESPACE = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
9
|
-
const RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
10
|
-
const OFFICE_RELATIONSHIPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
11
|
-
const WORDPROCESSING = "application/vnd.openxmlformats-officedocument.wordprocessingml";
|
|
12
|
-
/** Pinned, with no folder entries, so two builds produce identical bytes. */
|
|
13
|
-
const ZIP_ENTRY_OPTIONS = {
|
|
14
|
-
date: new Date(Date.UTC(2e3, 0, 1)),
|
|
15
|
-
createFolders: false
|
|
16
|
-
};
|
|
17
|
-
const paragraphXml = (text) => `<w:p><w:r><w:t xml:space="preserve">${escapeXmlText(text)}</w:t></w:r></w:p>`;
|
|
18
|
-
const buildParagraphsDocx = async (paragraphs, { inTableCell } = {}) => {
|
|
19
|
-
const paragraphsXml = paragraphs.map(paragraphXml).join("");
|
|
20
|
-
const body = inTableCell ? `<w:tbl><w:tblPr><w:tblW w:w="0" w:type="auto"/></w:tblPr><w:tblGrid><w:gridCol w:w="9360"/></w:tblGrid><w:tr><w:tc><w:tcPr><w:tcW w:w="9360" w:type="dxa"/></w:tcPr>${paragraphsXml}</w:tc></w:tr></w:tbl>` + paragraphXml("After the table.") : paragraphsXml;
|
|
21
|
-
const parts = {
|
|
22
|
-
"[Content_Types].xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="${WORDPROCESSING}.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="${WORDPROCESSING}.styles+xml"/></Types>`,
|
|
23
|
-
"_rels/.rels": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${RELATIONSHIPS}"><Relationship Id="rId1" Type="${OFFICE_RELATIONSHIPS}/officeDocument" Target="word/document.xml"/></Relationships>`,
|
|
24
|
-
"word/_rels/document.xml.rels": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${RELATIONSHIPS}"><Relationship Id="rId1" Type="${OFFICE_RELATIONSHIPS}/styles" Target="styles.xml"/></Relationships>`,
|
|
25
|
-
"word/styles.xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="${NAMESPACE}"><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/></w:style></w:styles>`,
|
|
26
|
-
"word/document.xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="${NAMESPACE}"><w:body>${body}<w:sectPr><w:pgSz w:w="12240" w:h="15840"/></w:sectPr></w:body></w:document>`
|
|
27
|
-
};
|
|
28
|
-
const zip = new JSZip();
|
|
29
|
-
for (const name of Object.keys(parts).toSorted()) zip.file(name, parts[name] ?? "", ZIP_ENTRY_OPTIONS);
|
|
30
|
-
return await zip.generateAsync({ type: "arraybuffer" });
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
export { buildParagraphsDocx };
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
//#region src/compare/__fixtures__/body-sequence.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* A document body written from a sequence of paragraphs and tables.
|
|
4
|
-
*
|
|
5
|
-
* The edit-script DSL can move words and rows but cannot append a table, so a
|
|
6
|
-
* pair whose difference is "a paragraph AND a table were added after the last
|
|
7
|
-
* one" has to be authored as two packages. Generating both from one description
|
|
8
|
-
* keeps the difference visible in the diff instead of hidden in bytes.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* One cell's content: a line of text, or a sequence of its own — which is how
|
|
12
|
-
* a nested table, a blank line inside a cell, or a cell that ends with a table
|
|
13
|
-
* gets written.
|
|
14
|
-
*/
|
|
15
|
-
type CellContent = string | readonly BodyItem[];
|
|
16
|
-
/** `w:tcPr` children a fixture can author, each named after the element. */
|
|
17
|
-
type CellProperties = {
|
|
18
|
-
/** `w:gridSpan`: grid columns this cell occupies. */
|
|
19
|
-
gridSpan?: number;
|
|
20
|
-
/** `w:vMerge`: the cell starts a vertical merge, or continues one. */
|
|
21
|
-
verticalMerge?: "restart" | "continue";
|
|
22
|
-
/** `w:tcW` in twips. */
|
|
23
|
-
width?: number;
|
|
24
|
-
/** `w:shd` fill colour, as six hex digits. */
|
|
25
|
-
shadingFill?: string;
|
|
26
|
-
/** `w:vAlign`. */
|
|
27
|
-
verticalAlign?: "top" | "center" | "bottom";
|
|
28
|
-
/** `w:tcBorders`, single style on all four sides, in eighths of a point. */
|
|
29
|
-
borderSize?: number;
|
|
30
|
-
/** `w:tcMar`, the same margin on all four sides, in twips. */
|
|
31
|
-
margin?: number;
|
|
32
|
-
};
|
|
33
|
-
/** A cell: its content alone, or its content and its own `w:tcPr`. */
|
|
34
|
-
type Cell = CellContent | ({
|
|
35
|
-
content: CellContent;
|
|
36
|
-
} & CellProperties);
|
|
37
|
-
/** A row: its cells alone, or its cells and its own `w:trPr`. */
|
|
38
|
-
type TableRow = readonly Cell[] | {
|
|
39
|
-
cells: readonly Cell[];
|
|
40
|
-
/** `w:trHeight` in twips. */
|
|
41
|
-
height?: number;
|
|
42
|
-
/** `w:tblHeader`: the row repeats at the top of every page. */
|
|
43
|
-
header?: boolean;
|
|
44
|
-
/** `w:jc` on the row. */
|
|
45
|
-
justification?: "left" | "center" | "right";
|
|
46
|
-
};
|
|
47
|
-
/** `w:tblPr` children a fixture can author, each named after the element. */
|
|
48
|
-
type TableProperties = {
|
|
49
|
-
/** `w:tblStyle`. */
|
|
50
|
-
styleId?: string;
|
|
51
|
-
/** `w:tblW`. */
|
|
52
|
-
width?: {
|
|
53
|
-
value: number;
|
|
54
|
-
type: "auto" | "dxa" | "pct";
|
|
55
|
-
};
|
|
56
|
-
/** `w:bidiVisual`. */
|
|
57
|
-
bidi?: boolean;
|
|
58
|
-
/** `w:jc` on the table. */
|
|
59
|
-
justification?: "left" | "center" | "right";
|
|
60
|
-
/** `w:tblInd` in twips. */
|
|
61
|
-
indent?: number;
|
|
62
|
-
/** `w:tblCellSpacing` in twips. */
|
|
63
|
-
cellSpacing?: number;
|
|
64
|
-
/** `w:tblBorders`, single style on every side, in eighths of a point. */
|
|
65
|
-
borderSize?: number;
|
|
66
|
-
/** `w:shd` fill colour on the table, as six hex digits. */
|
|
67
|
-
shadingFill?: string;
|
|
68
|
-
/** `w:tblLayout`. */
|
|
69
|
-
layout?: "fixed" | "autofit";
|
|
70
|
-
/** `w:tblCellMar`, the same margin on all four sides, in twips. */
|
|
71
|
-
cellMargin?: number;
|
|
72
|
-
/** `w:tblLook` value, as four hex digits. */
|
|
73
|
-
look?: string;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* One inline of a paragraph: plain text, or text carrying an external
|
|
77
|
-
* hyperlink. A link is the case where a revision wrapper and the linked runs
|
|
78
|
-
* have to nest one inside the other, so the fixture has to be able to author
|
|
79
|
-
* one.
|
|
80
|
-
*/
|
|
81
|
-
type ParagraphInline = string | {
|
|
82
|
-
text: string;
|
|
83
|
-
href: string;
|
|
84
|
-
};
|
|
85
|
-
/** One body-level item: a paragraph, or a table given row by row. */
|
|
86
|
-
type BodyItem = {
|
|
87
|
-
kind: "paragraph";
|
|
88
|
-
text: string | readonly ParagraphInline[];
|
|
89
|
-
styleId?: string;
|
|
90
|
-
/**
|
|
91
|
-
* An authored `w14:paraId`, for a package whose ids a producer wrote
|
|
92
|
-
* without respecting the 31-bit bound the schema puts on them.
|
|
93
|
-
*/
|
|
94
|
-
paraId?: string;
|
|
95
|
-
} | {
|
|
96
|
-
kind: "table";
|
|
97
|
-
rows: readonly TableRow[];
|
|
98
|
-
/** `w:tblPr` children, written in the order the schema requires. */
|
|
99
|
-
properties?: TableProperties;
|
|
100
|
-
/** `w:tblGrid` column widths, in twips. One per grid column. */
|
|
101
|
-
columnWidths?: readonly number[];
|
|
102
|
-
/**
|
|
103
|
-
* Rows a package hides with `w:hidden`. The snapshot skips their whole
|
|
104
|
-
* subtree, so a document that has one is the case where the snapshot
|
|
105
|
-
* walk and the live walk could disagree.
|
|
106
|
-
*/
|
|
107
|
-
hiddenRows?: readonly number[];
|
|
108
|
-
};
|
|
109
|
-
type BodySequenceOptions = {
|
|
110
|
-
/**
|
|
111
|
-
* A default header part, written as its own sequence. A header is a story of
|
|
112
|
-
* its own: it ends with its own paragraph, and a comparison writes it with
|
|
113
|
-
* its own revision ids.
|
|
114
|
-
*/
|
|
115
|
-
header?: readonly BodyItem[];
|
|
116
|
-
};
|
|
117
|
-
declare const buildBodySequenceDocx: (items: readonly BodyItem[], { header }?: BodySequenceOptions) => Promise<ArrayBuffer>;
|
|
118
|
-
//#endregion
|
|
119
|
-
export { BodyItem, BodySequenceOptions, Cell, CellContent, CellProperties, ParagraphInline, TableProperties, TableRow, buildBodySequenceDocx };
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import JSZip from "jszip";
|
|
2
|
-
//#region src/compare/__fixtures__/body-sequence.ts
|
|
3
|
-
/**
|
|
4
|
-
* A document body written from a sequence of paragraphs and tables.
|
|
5
|
-
*
|
|
6
|
-
* The edit-script DSL can move words and rows but cannot append a table, so a
|
|
7
|
-
* pair whose difference is "a paragraph AND a table were added after the last
|
|
8
|
-
* one" has to be authored as two packages. Generating both from one description
|
|
9
|
-
* keeps the difference visible in the diff instead of hidden in bytes.
|
|
10
|
-
*/
|
|
11
|
-
const NAMESPACE = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
12
|
-
const RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
13
|
-
const OFFICE_RELATIONSHIPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
14
|
-
const WORDPROCESSING = "application/vnd.openxmlformats-officedocument.wordprocessingml";
|
|
15
|
-
const MARKUP_COMPATIBILITY = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
16
|
-
const PACKAGE_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006";
|
|
17
|
-
const CORE_PROPERTIES_TYPE = "application/vnd.openxmlformats-package.core-properties+xml";
|
|
18
|
-
const EXTENDED_PROPERTIES = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";
|
|
19
|
-
const EXTENDED_PROPERTIES_TYPE = "application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
|
20
|
-
const WORDML_2010 = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
21
|
-
/**
|
|
22
|
-
* `createFolders: false` because JSZip stamps the folder entries it
|
|
23
|
-
* synthesizes with `new Date()`, which the fixed date above does not reach.
|
|
24
|
-
*/
|
|
25
|
-
const ZIP_ENTRY_OPTIONS = {
|
|
26
|
-
date: new Date(Date.UTC(2e3, 0, 1)),
|
|
27
|
-
createFolders: false
|
|
28
|
-
};
|
|
29
|
-
const isRowOptions = (row) => "cells" in row;
|
|
30
|
-
const isCellSpec = (cell) => typeof cell === "object" && "content" in cell;
|
|
31
|
-
const rowCells = (row) => isRowOptions(row) ? row.cells : row;
|
|
32
|
-
const rowOptions = (row) => isRowOptions(row) ? row : {};
|
|
33
|
-
const cellContent = (cell) => isCellSpec(cell) ? cell.content : cell;
|
|
34
|
-
const cellProperties = (cell) => isCellSpec(cell) ? cell : {};
|
|
35
|
-
/**
|
|
36
|
-
* A paragraph's id is derived from its own content, not from its position.
|
|
37
|
-
*
|
|
38
|
-
* Two packages authored from two descriptions are a base and a target, and a
|
|
39
|
-
* paragraph that appears in both is the same paragraph. Numbering the ids in
|
|
40
|
-
* document order would instead give the same id to the paragraph that happens
|
|
41
|
-
* to sit at the same index, which is how the fixture would tell a comparison
|
|
42
|
-
* that a removed paragraph was a rewrite of the one after it.
|
|
43
|
-
*/
|
|
44
|
-
const createParaIdAllocator = () => {
|
|
45
|
-
const taken = /* @__PURE__ */ new Set();
|
|
46
|
-
return (content) => {
|
|
47
|
-
let hash = 2166136261;
|
|
48
|
-
for (let index = 0; index < content.length; index += 1) hash = Math.imul(hash ^ content.charCodeAt(index), 16777619) >>> 0;
|
|
49
|
-
let candidate = hash % 2147483646;
|
|
50
|
-
while (taken.has((candidate + 1).toString(16).toUpperCase().padStart(8, "0"))) candidate = (candidate + 1) % 2147483646;
|
|
51
|
-
const paraId = (candidate + 1).toString(16).toUpperCase().padStart(8, "0");
|
|
52
|
-
taken.add(paraId);
|
|
53
|
-
return paraId;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const run = (text) => `<w:r><w:t xml:space="preserve">${text}</w:t></w:r>`;
|
|
57
|
-
const inlineXml = (inline, { links }) => typeof inline === "string" ? run(inline) : `<w:hyperlink r:id="${links.get(inline.href) ?? ""}">${run(inline.text)}</w:hyperlink>`;
|
|
58
|
-
/**
|
|
59
|
-
* An empty paragraph is a `w:p` with no run at all, which is what a package
|
|
60
|
-
* holds for a blank line or an empty cell. It is not the same thing as a
|
|
61
|
-
* paragraph whose run carries an empty string, and both shapes occur.
|
|
62
|
-
*/
|
|
63
|
-
/** A blank line carries no run at all, so an empty string is no inline. */
|
|
64
|
-
const nonEmptyInlines = (text) => text.length === 0 ? [] : [text];
|
|
65
|
-
const paragraph = (text, context, { styleId, paraId } = {}) => {
|
|
66
|
-
const properties = styleId === void 0 ? "" : `<w:pPr><w:pStyle w:val="${styleId}"/></w:pPr>`;
|
|
67
|
-
const inlines = typeof text === "string" ? nonEmptyInlines(text) : text;
|
|
68
|
-
const content = inlines.map((inline) => typeof inline === "string" ? inline : inline.text).join("");
|
|
69
|
-
const id = paraId ?? context.paraId(`${styleId ?? ""}|${content}`);
|
|
70
|
-
return `<w:p w14:paraId="${id}" w14:textId="${id}">${properties}${inlines.map((inline) => inlineXml(inline, context)).join("")}</w:p>`;
|
|
71
|
-
};
|
|
72
|
-
/** Every href the body carries, in document order, so the ids are stable. */
|
|
73
|
-
const collectHrefs = (items, hrefs) => {
|
|
74
|
-
for (const item of items) {
|
|
75
|
-
if (item.kind === "paragraph") {
|
|
76
|
-
if (typeof item.text === "string") continue;
|
|
77
|
-
for (const inline of item.text) if (typeof inline !== "string" && !hrefs.includes(inline.href)) hrefs.push(inline.href);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
for (const row of item.rows) for (const cell of rowCells(row)) {
|
|
81
|
-
const content = cellContent(cell);
|
|
82
|
-
if (typeof content !== "string") collectHrefs(content, hrefs);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const EMPTY_PARAGRAPH = {
|
|
87
|
-
kind: "paragraph",
|
|
88
|
-
text: ""
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Most fixtures add a paragraph after a table so later paragraph insertions
|
|
92
|
-
* have an explicit anchor. Tests for a schema-valid terminal table remove that
|
|
93
|
-
* convenience paragraph deliberately.
|
|
94
|
-
*/
|
|
95
|
-
const closedSequence = (items) => {
|
|
96
|
-
const last = items.at(-1);
|
|
97
|
-
return last === void 0 || last.kind === "table" ? [...items, EMPTY_PARAGRAPH] : items;
|
|
98
|
-
};
|
|
99
|
-
/** A cell must also contain a paragraph, which the empty sequence supplies. */
|
|
100
|
-
const cellXml = (content, context) => typeof content === "string" ? paragraph(content, context) : itemsXml(closedSequence(content), context);
|
|
101
|
-
/** `w:tbl` is `w:tblPr, w:tblGrid, rows`: a fixture without the grid is not one. */
|
|
102
|
-
const tableGrid = (item) => {
|
|
103
|
-
if (item.columnWidths) return `<w:tblGrid>${item.columnWidths.map((width) => `<w:gridCol w:w="${String(width)}"/>`).join("")}</w:tblGrid>`;
|
|
104
|
-
let columns = 0;
|
|
105
|
-
for (const row of item.rows) {
|
|
106
|
-
let spanned = 0;
|
|
107
|
-
for (const cell of rowCells(row)) spanned += cellProperties(cell).gridSpan ?? 1;
|
|
108
|
-
columns = Math.max(columns, spanned);
|
|
109
|
-
}
|
|
110
|
-
return `<w:tblGrid>${`<w:gridCol w:w="2000"/>`.repeat(columns)}</w:tblGrid>`;
|
|
111
|
-
};
|
|
112
|
-
const BORDER_SIDES = [
|
|
113
|
-
"top",
|
|
114
|
-
"left",
|
|
115
|
-
"bottom",
|
|
116
|
-
"right",
|
|
117
|
-
"insideH",
|
|
118
|
-
"insideV"
|
|
119
|
-
];
|
|
120
|
-
const CELL_BORDER_SIDES = [
|
|
121
|
-
"top",
|
|
122
|
-
"left",
|
|
123
|
-
"bottom",
|
|
124
|
-
"right"
|
|
125
|
-
];
|
|
126
|
-
const MARGIN_SIDES = [
|
|
127
|
-
"top",
|
|
128
|
-
"left",
|
|
129
|
-
"bottom",
|
|
130
|
-
"right"
|
|
131
|
-
];
|
|
132
|
-
const borders = (element, sides, size) => `<w:${element}>${sides.map((side) => `<w:${side} w:val="single" w:sz="${String(size)}" w:space="0" w:color="000000"/>`).join("")}</w:${element}>`;
|
|
133
|
-
const margins = (element, value) => `<w:${element}>${MARGIN_SIDES.map((side) => `<w:${side} w:w="${String(value)}" w:type="dxa"/>`).join("")}</w:${element}>`;
|
|
134
|
-
/**
|
|
135
|
-
* `w:tblPr` children in the order CT_TblPrBase declares: tblStyle, bidiVisual,
|
|
136
|
-
* tblW, jc, tblCellSpacing, tblInd, tblBorders, shd, tblLayout, tblCellMar,
|
|
137
|
-
* tblLook. `w:tblW` is always written.
|
|
138
|
-
*/
|
|
139
|
-
const tableProperties = ({ properties }) => {
|
|
140
|
-
const width = properties?.width ?? {
|
|
141
|
-
value: 0,
|
|
142
|
-
type: "auto"
|
|
143
|
-
};
|
|
144
|
-
return `<w:tblPr>${[
|
|
145
|
-
...properties?.styleId === void 0 ? [] : [`<w:tblStyle w:val="${properties.styleId}"/>`],
|
|
146
|
-
...properties?.bidi === void 0 ? [] : [properties.bidi ? "<w:bidiVisual/>" : "<w:bidiVisual w:val=\"0\"/>"],
|
|
147
|
-
`<w:tblW w:w="${String(width.value)}" w:type="${width.type}"/>`,
|
|
148
|
-
...properties?.justification === void 0 ? [] : [`<w:jc w:val="${properties.justification}"/>`],
|
|
149
|
-
...properties?.cellSpacing === void 0 ? [] : [`<w:tblCellSpacing w:w="${String(properties.cellSpacing)}" w:type="dxa"/>`],
|
|
150
|
-
...properties?.indent === void 0 ? [] : [`<w:tblInd w:w="${String(properties.indent)}" w:type="dxa"/>`],
|
|
151
|
-
...properties?.borderSize === void 0 ? [] : [borders("tblBorders", BORDER_SIDES, properties.borderSize)],
|
|
152
|
-
...properties?.shadingFill === void 0 ? [] : [`<w:shd w:val="clear" w:color="auto" w:fill="${properties.shadingFill}"/>`],
|
|
153
|
-
...properties?.layout === void 0 ? [] : [`<w:tblLayout w:type="${properties.layout}"/>`],
|
|
154
|
-
...properties?.cellMargin === void 0 ? [] : [margins("tblCellMar", properties.cellMargin)],
|
|
155
|
-
...properties?.look === void 0 ? [] : [`<w:tblLook w:val="${properties.look}"/>`]
|
|
156
|
-
].join("")}</w:tblPr>`;
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* `w:trPr` children. `CT_TrPrBase` is a repeated choice rather than a
|
|
160
|
-
* sequence, so the order here is the readable one rather than a required one.
|
|
161
|
-
*/
|
|
162
|
-
const rowProperties = (row, hidden) => {
|
|
163
|
-
const { header, height, justification } = rowOptions(row);
|
|
164
|
-
const parts = [
|
|
165
|
-
...height === void 0 ? [] : [`<w:trHeight w:val="${String(height)}"/>`],
|
|
166
|
-
...header === true ? ["<w:tblHeader/>"] : [],
|
|
167
|
-
...justification === void 0 ? [] : [`<w:jc w:val="${justification}"/>`],
|
|
168
|
-
...hidden ? ["<w:hidden/>"] : []
|
|
169
|
-
];
|
|
170
|
-
return parts.length === 0 ? "" : `<w:trPr>${parts.join("")}</w:trPr>`;
|
|
171
|
-
};
|
|
172
|
-
/** `w:tcPr` children in schema order; `w:tcW` is always written. */
|
|
173
|
-
const cellPropertiesXml = (cell) => {
|
|
174
|
-
const properties = cellProperties(cell);
|
|
175
|
-
return `<w:tcPr>${[
|
|
176
|
-
`<w:tcW w:w="${String(properties.width ?? 2e3)}" w:type="dxa"/>`,
|
|
177
|
-
...properties.gridSpan === void 0 ? [] : [`<w:gridSpan w:val="${String(properties.gridSpan)}"/>`],
|
|
178
|
-
...properties.verticalMerge === void 0 ? [] : [properties.verticalMerge === "restart" ? `<w:vMerge w:val="restart"/>` : `<w:vMerge/>`],
|
|
179
|
-
...properties.borderSize === void 0 ? [] : [borders("tcBorders", CELL_BORDER_SIDES, properties.borderSize)],
|
|
180
|
-
...properties.shadingFill === void 0 ? [] : [`<w:shd w:val="clear" w:color="auto" w:fill="${properties.shadingFill}"/>`],
|
|
181
|
-
...properties.margin === void 0 ? [] : [margins("tcMar", properties.margin)],
|
|
182
|
-
...properties.verticalAlign === void 0 ? [] : [`<w:vAlign w:val="${properties.verticalAlign}"/>`]
|
|
183
|
-
].join("")}</w:tcPr>`;
|
|
184
|
-
};
|
|
185
|
-
const table = (item, context) => {
|
|
186
|
-
const hidden = new Set(item.hiddenRows ?? []);
|
|
187
|
-
return `<w:tbl>${tableProperties(item)}` + tableGrid(item) + item.rows.map((row, rowIndex) => `<w:tr>${rowProperties(row, hidden.has(rowIndex))}${rowCells(row).map((cell) => `<w:tc>${cellPropertiesXml(cell)}${cellXml(cellContent(cell), context)}</w:tc>`).join("")}</w:tr>`).join("") + `</w:tbl>`;
|
|
188
|
-
};
|
|
189
|
-
const itemsXml = (items, context) => items.map((item) => item.kind === "paragraph" ? paragraph(item.text, context, {
|
|
190
|
-
...item.styleId === void 0 ? {} : { styleId: item.styleId },
|
|
191
|
-
...item.paraId === void 0 ? {} : { paraId: item.paraId }
|
|
192
|
-
}) : table(item, context)).join("");
|
|
193
|
-
const bodyXml = (items, context) => itemsXml(closedSequence(items), context);
|
|
194
|
-
/** The relationship id the default header takes when a fixture asks for one. */
|
|
195
|
-
const HEADER_RELATIONSHIP_ID = "rId2";
|
|
196
|
-
const buildBodySequenceDocx = async (items, { header } = {}) => {
|
|
197
|
-
const hrefs = [];
|
|
198
|
-
collectHrefs(closedSequence(items), hrefs);
|
|
199
|
-
collectHrefs(closedSequence(header ?? []), hrefs);
|
|
200
|
-
const firstLinkRelationship = header ? 3 : 2;
|
|
201
|
-
const links = new Map(hrefs.map((href, index) => [href, `rId${index + firstLinkRelationship}`]));
|
|
202
|
-
const linkRelationships = hrefs.map((href, index) => `<Relationship Id="rId${index + firstLinkRelationship}" Type="${OFFICE_RELATIONSHIPS}/hyperlink" Target="${href}" TargetMode="External"/>`).join("");
|
|
203
|
-
const paraId = createParaIdAllocator();
|
|
204
|
-
const parts = {
|
|
205
|
-
"[Content_Types].xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="${WORDPROCESSING}.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="${WORDPROCESSING}.styles+xml"/>` + (header ? `<Override PartName="/word/header1.xml" ContentType="${WORDPROCESSING}.header+xml"/>` : "") + `<Override PartName="/docProps/core.xml" ContentType="${CORE_PROPERTIES_TYPE}"/><Override PartName="/docProps/app.xml" ContentType="${EXTENDED_PROPERTIES_TYPE}"/></Types>`,
|
|
206
|
-
"_rels/.rels": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${RELATIONSHIPS}"><Relationship Id="rId1" Type="${OFFICE_RELATIONSHIPS}/officeDocument" Target="word/document.xml"/><Relationship Id="rId2" Type="${PACKAGE_RELATIONSHIPS}/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId3" Type="${OFFICE_RELATIONSHIPS}/extended-properties" Target="docProps/app.xml"/></Relationships>`,
|
|
207
|
-
"docProps/core.xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cp:coreProperties xmlns:cp="${PACKAGE_RELATIONSHIPS}/metadata/core-properties" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dcterms:created xsi:type="dcterms:W3CDTF">2000-01-01T00:00:00Z</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">2000-01-01T00:00:00Z</dcterms:modified></cp:coreProperties>`,
|
|
208
|
-
"docProps/app.xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Properties xmlns="${EXTENDED_PROPERTIES}"><AppVersion>1.0.0</AppVersion></Properties>`,
|
|
209
|
-
"word/_rels/document.xml.rels": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${RELATIONSHIPS}"><Relationship Id="rId1" Type="${OFFICE_RELATIONSHIPS}/styles" Target="styles.xml"/>` + (header ? `<Relationship Id="${HEADER_RELATIONSHIP_ID}" Type="${OFFICE_RELATIONSHIPS}/header" Target="header1.xml"/>` : "") + linkRelationships + `</Relationships>`,
|
|
210
|
-
"word/styles.xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="${NAMESPACE}"><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/></w:style><w:style w:type="paragraph" w:styleId="Heading1"><w:name w:val="heading 1"/></w:style></w:styles>`,
|
|
211
|
-
"word/document.xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="${NAMESPACE}" xmlns:r="${OFFICE_RELATIONSHIPS}" xmlns:mc="${MARKUP_COMPATIBILITY}" xmlns:w14="${WORDML_2010}" mc:Ignorable="w14"><w:body>` + bodyXml(items, {
|
|
212
|
-
links,
|
|
213
|
-
paraId
|
|
214
|
-
}) + `<w:sectPr>` + (header ? `<w:headerReference w:type="default" r:id="${HEADER_RELATIONSHIP_ID}"/>` : "") + "<w:pgSz w:w=\"12240\" w:h=\"15840\"/><w:pgMar w:top=\"1440\" w:right=\"1440\" w:bottom=\"1440\" w:left=\"1440\"/></w:sectPr></w:body></w:document>",
|
|
215
|
-
...header ? { "word/header1.xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:hdr xmlns:w="${NAMESPACE}" xmlns:r="${OFFICE_RELATIONSHIPS}" xmlns:mc="${MARKUP_COMPATIBILITY}" xmlns:w14="${WORDML_2010}" mc:Ignorable="w14">${itemsXml(closedSequence(header), {
|
|
216
|
-
links,
|
|
217
|
-
paraId
|
|
218
|
-
})}</w:hdr>` } : {}
|
|
219
|
-
};
|
|
220
|
-
const zip = new JSZip();
|
|
221
|
-
for (const name of Object.keys(parts).toSorted()) zip.file(name, parts[name] ?? "", ZIP_ENTRY_OPTIONS);
|
|
222
|
-
return await zip.generateAsync({ type: "arraybuffer" });
|
|
223
|
-
};
|
|
224
|
-
//#endregion
|
|
225
|
-
export { buildBodySequenceDocx };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/compare/__fixtures__/nested-table.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* A document that ends with a table whose last cell holds another table.
|
|
4
|
-
*
|
|
5
|
-
* The shape matters because the story's last block is then two levels deep,
|
|
6
|
-
* and a paragraph appended after the whole table has no block to anchor to
|
|
7
|
-
* that is not inside a cell. Authored here rather than committed as bytes so
|
|
8
|
-
* the structure under test is legible in the diff.
|
|
9
|
-
*/
|
|
10
|
-
type NestedTableDocxOptions = {
|
|
11
|
-
/** Appended after the outer table, at body level, when set. */
|
|
12
|
-
trailingParagraph?: string;
|
|
13
|
-
};
|
|
14
|
-
declare const buildNestedTableDocx: ({ trailingParagraph }?: NestedTableDocxOptions) => Promise<ArrayBuffer>;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { NestedTableDocxOptions, buildNestedTableDocx };
|