@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
|
@@ -31,13 +31,5 @@ declare function createEmptyParagraph(formatting?: document_d_exports.ParagraphF
|
|
|
31
31
|
* Create a paragraph with a single text run
|
|
32
32
|
*/
|
|
33
33
|
declare function createTextParagraph(text: string, paragraphFormatting?: document_d_exports.ParagraphFormatting, textFormatting?: document_d_exports.TextFormatting): document_d_exports.Paragraph;
|
|
34
|
-
/**
|
|
35
|
-
* Check if paragraph is a list item
|
|
36
|
-
*/
|
|
37
|
-
declare function isListParagraph(paragraph: document_d_exports.Paragraph): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Get list level of a paragraph (0-8, or -1 if not a list)
|
|
40
|
-
*/
|
|
41
|
-
declare function getListLevel(paragraph: document_d_exports.Paragraph): number;
|
|
42
34
|
//#endregion
|
|
43
|
-
export { createEmptyParagraph, createTextParagraph,
|
|
35
|
+
export { createEmptyParagraph, createTextParagraph, hasParagraphContent, hasParagraphFormatting, serializeParagraph, serializeParagraphFormatting, serializeParagraphs };
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { modelParagraphFormattingEmission } from "../../internal/paragraphFormattingSerialization.js";
|
|
1
|
+
import { modelParagraphFormattingEmission, serializeParagraphPropertySet } from "../../internal/paragraphFormattingSerialization.js";
|
|
2
|
+
import { serializePreservedAttributes } from "../attributeRemainder.js";
|
|
3
|
+
import { CONTAINER_CHILDREN } from "../containerChildren.gen.js";
|
|
4
|
+
import { fieldStateAttributes } from "../fieldState.js";
|
|
2
5
|
import { getParagraphPropertySource, paragraphPropertySourceMatchesEmission } from "../paragraphPropertySource.js";
|
|
3
|
-
import { reconcileRawSdtPr } from "../sdtPropertiesPatch.js";
|
|
4
6
|
import { DATE_UTC_ATTRIBUTE } from "../trackedChangeInfo.js";
|
|
5
7
|
import { toTransitionalNamespaceUri } from "../transitionalSpelling.js";
|
|
6
8
|
import { captureVerbatimXml, sanitizeCapturedXmlElement } from "../verbatimCapture.js";
|
|
7
9
|
import { NAMESPACES, OOXML_NAMESPACE_SCOPE, cloneElement, getChildElements, getLocalName, parseXml } from "../xmlParser.js";
|
|
8
|
-
import {
|
|
10
|
+
import { markupRangeAttributes, moveBookmarkAttributes, serializeBookmarkMarker } from "./markupRangeAttributes.js";
|
|
9
11
|
import { serializeRun } from "./runSerializer.js";
|
|
12
|
+
import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
|
|
10
13
|
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
11
14
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
12
15
|
import { serializeTrackedChangeAttributes, trackedChangeAttributeRecord } from "./trackedChangeAttributes.js";
|
|
13
|
-
import { isSingleWellFormedElement } from "./xmlUtils.js";
|
|
14
16
|
import { panic } from "better-result";
|
|
15
17
|
import { escapeXmlAttribute, escapeXmlText } from "@stll/docx-core";
|
|
16
18
|
import { PARAGRAPH_MARK_CHANGE_KINDS } from "@stll/docx-core/model";
|
|
19
|
+
import { SEQUENCE_CHILDREN } from "@stll/docx-core/schema";
|
|
17
20
|
//#region src/docx/serializer/paragraphSerializer.ts
|
|
18
21
|
/**
|
|
19
22
|
* Serialize paragraph formatting properties to w:pPr XML
|
|
@@ -50,83 +53,26 @@ const PARAGRAPH_APPEND_PREFIXES = /* @__PURE__ */ new Map([
|
|
|
50
53
|
["r", NAMESPACES.r],
|
|
51
54
|
["w15", NAMESPACES.w15]
|
|
52
55
|
]);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"adjustRightInd",
|
|
74
|
-
"snapToGrid",
|
|
75
|
-
"spacing",
|
|
76
|
-
"ind",
|
|
77
|
-
"contextualSpacing",
|
|
78
|
-
"mirrorIndents",
|
|
79
|
-
"suppressOverlap",
|
|
80
|
-
"jc",
|
|
81
|
-
"textDirection",
|
|
82
|
-
"textAlignment",
|
|
83
|
-
"textboxTightWrap",
|
|
84
|
-
"outlineLvl",
|
|
85
|
-
"divId",
|
|
86
|
-
"cnfStyle",
|
|
87
|
-
"rPr"
|
|
88
|
-
].map((name, index) => [name, index]));
|
|
89
|
-
const PARAGRAPH_MARK_BASE_CHILDREN = /* @__PURE__ */ new Set([
|
|
90
|
-
"rStyle",
|
|
91
|
-
"rFonts",
|
|
92
|
-
"b",
|
|
93
|
-
"bCs",
|
|
94
|
-
"i",
|
|
95
|
-
"iCs",
|
|
96
|
-
"caps",
|
|
97
|
-
"smallCaps",
|
|
98
|
-
"strike",
|
|
99
|
-
"dstrike",
|
|
100
|
-
"outline",
|
|
101
|
-
"shadow",
|
|
102
|
-
"emboss",
|
|
103
|
-
"imprint",
|
|
104
|
-
"snapToGrid",
|
|
105
|
-
"vanish",
|
|
106
|
-
"webHidden",
|
|
107
|
-
"color",
|
|
108
|
-
"spacing",
|
|
109
|
-
"w",
|
|
110
|
-
"kern",
|
|
111
|
-
"position",
|
|
112
|
-
"sz",
|
|
113
|
-
"szCs",
|
|
114
|
-
"noProof",
|
|
115
|
-
"highlight",
|
|
116
|
-
"u",
|
|
117
|
-
"effect",
|
|
118
|
-
"bdr",
|
|
119
|
-
"shd",
|
|
120
|
-
"fitText",
|
|
121
|
-
"vertAlign",
|
|
122
|
-
"rtl",
|
|
123
|
-
"cs",
|
|
124
|
-
"em",
|
|
125
|
-
"lang",
|
|
126
|
-
"eastAsianLayout",
|
|
127
|
-
"specVanish",
|
|
128
|
-
"oMath"
|
|
129
|
-
]);
|
|
56
|
+
/**
|
|
57
|
+
* The order a replayed `w:pPr` has to already be in, from the generated table.
|
|
58
|
+
*
|
|
59
|
+
* This used to be the same list written out again, which is a mirror of the
|
|
60
|
+
* order the writer emits: the two could disagree and a capture the gate let
|
|
61
|
+
* through would then be markup the rebuild would never have written.
|
|
62
|
+
* `w:sectPr` and `w:pPrChange` are in the generated list and are refused
|
|
63
|
+
* before this map is consulted, because they have their own lifecycles.
|
|
64
|
+
*/
|
|
65
|
+
const PARAGRAPH_PROPERTY_CHILD_ORDER = new Map(SEQUENCE_CHILDREN["paragraph-properties"].map((name, index) => [name, index]));
|
|
66
|
+
/**
|
|
67
|
+
* `EG_RPrBase`: the paragraph mark's `w:rPr` children a replay may carry.
|
|
68
|
+
*
|
|
69
|
+
* Derived from the generated declared-child list rather than restated, so the
|
|
70
|
+
* set a capture is checked against and the set the parser makes a decision for
|
|
71
|
+
* are one list. The revisions `CT_ParaRPr` adds around it are excluded here
|
|
72
|
+
* and refused by {@link RESERVED_PARAGRAPH_CAPTURE_CHILDREN}, which is what
|
|
73
|
+
* keeps a replayed `w:pPr` from carrying a revision the model also writes.
|
|
74
|
+
*/
|
|
75
|
+
const PARAGRAPH_MARK_BASE_CHILDREN = new Set(CONTAINER_CHILDREN["run-properties"].filter((name) => !RESERVED_PARAGRAPH_CAPTURE_CHILDREN.has(name)));
|
|
130
76
|
const PARAGRAPH_NESTED_PROPERTY_CHILDREN = /* @__PURE__ */ new Map([
|
|
131
77
|
["numPr", /* @__PURE__ */ new Set([
|
|
132
78
|
"ilvl",
|
|
@@ -304,15 +250,12 @@ const serializeParagraphFormattingWithOptions = (formatting, { propertyChanges,
|
|
|
304
250
|
const sourceWithMark = paragraphMarkChange ? withParagraphMarkChange(verifiedSource, paragraphMarkChange) : verifiedSource;
|
|
305
251
|
return withTrailingParagraphPropertyChildren(sourceWithMark, [sectionPropertiesXml, ...propertyChangesXml]);
|
|
306
252
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const inner = parts.join("");
|
|
314
|
-
if (inner.length === 0) return "";
|
|
315
|
-
return `<w:pPr>${inner}</w:pPr>`;
|
|
253
|
+
return serializeParagraphPropertySet({
|
|
254
|
+
formatting,
|
|
255
|
+
markPropertiesPrefixXml: paragraphMarkXml,
|
|
256
|
+
sectionPropertiesXml,
|
|
257
|
+
propertyChangesXml
|
|
258
|
+
});
|
|
316
259
|
};
|
|
317
260
|
function serializeParagraphFormatting(formatting, propertyChanges, paragraphMarkChange) {
|
|
318
261
|
return serializeParagraphFormattingWithOptions(formatting, {
|
|
@@ -341,36 +284,36 @@ function hyperlinkAttributes(hyperlink) {
|
|
|
341
284
|
if (hyperlink.docLocation) attrs.push(`w:docLocation="${escapeXmlAttribute(hyperlink.docLocation)}"`);
|
|
342
285
|
return attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
343
286
|
}
|
|
344
|
-
/** One `w:hyperlink` child, with the
|
|
345
|
-
function serializeHyperlinkChild(child,
|
|
346
|
-
|
|
347
|
-
|
|
287
|
+
/** One `w:hyperlink` child, written with the link's own disposition. */
|
|
288
|
+
function serializeHyperlinkChild(child, disposition) {
|
|
289
|
+
switch (child.type) {
|
|
290
|
+
case "run": return serializeInlineRun(child, disposition);
|
|
291
|
+
case "bookmarkStart": return serializeBookmarkMarker(child);
|
|
292
|
+
case "bookmarkEnd": return serializeBookmarkMarker(child);
|
|
293
|
+
case "inlineWrapper": return serializeParagraphContent(child, disposition);
|
|
294
|
+
case "preservedInline": return child.xml;
|
|
295
|
+
default: return child;
|
|
296
|
+
}
|
|
348
297
|
}
|
|
349
298
|
/**
|
|
350
299
|
* Serialize a hyperlink (w:hyperlink)
|
|
351
300
|
*/
|
|
352
|
-
function serializeHyperlink(hyperlink) {
|
|
353
|
-
const childrenXml = hyperlink.children.map((child) => serializeHyperlinkChild(child,
|
|
301
|
+
function serializeHyperlink(hyperlink, disposition = "kept") {
|
|
302
|
+
const childrenXml = hyperlink.children.map((child) => serializeHyperlinkChild(child, disposition)).join("");
|
|
354
303
|
return `<w:hyperlink${hyperlinkAttributes(hyperlink)}>${childrenXml}</w:hyperlink>`;
|
|
355
304
|
}
|
|
356
|
-
/**
|
|
357
|
-
* Serialize bookmark start (w:bookmarkStart)
|
|
358
|
-
*/
|
|
359
|
-
function serializeBookmarkStart(bookmark) {
|
|
360
|
-
return `<w:bookmarkStart ${bookmarkRangeAttributes(bookmark).join(" ")}/>`;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Serialize bookmark end (w:bookmarkEnd)
|
|
364
|
-
*/
|
|
365
|
-
function serializeBookmarkEnd(bookmark) {
|
|
366
|
-
return `<w:bookmarkEnd ${markupRangeAttributes(bookmark).join(" ")}/>`;
|
|
367
|
-
}
|
|
368
305
|
/** Serialize a simple field without changing its authored OOXML field form. */
|
|
369
306
|
function serializeSimpleField(field) {
|
|
370
|
-
const attrs = [`w:instr="${escapeXmlAttribute(field.instruction)}"
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
307
|
+
const attrs = [`w:instr="${escapeXmlAttribute(field.instruction)}"`, ...fieldStateAttributes(field)];
|
|
308
|
+
const contentXml = field.content.map((item) => {
|
|
309
|
+
switch (item.type) {
|
|
310
|
+
case "run": return serializeRun(item);
|
|
311
|
+
case "hyperlink": return serializeHyperlink(item);
|
|
312
|
+
case "inlineWrapper": return serializeParagraphContent(item);
|
|
313
|
+
case "preservedInline": return item.xml;
|
|
314
|
+
default: return item;
|
|
315
|
+
}
|
|
316
|
+
}).join("");
|
|
374
317
|
return `<w:fldSimple ${attrs.join(" ")}>${contentXml}</w:fldSimple>`;
|
|
375
318
|
}
|
|
376
319
|
/**
|
|
@@ -382,9 +325,7 @@ function serializeComplexField(field) {
|
|
|
382
325
|
const parts = [];
|
|
383
326
|
const structuralFormatting = field.formatting ?? field.fieldResult[0]?.formatting;
|
|
384
327
|
const rPrXml = structuralFormatting ? serializeTextFormatting(structuralFormatting) : "";
|
|
385
|
-
const beginAttrs = ["w:fldCharType=\"begin\""];
|
|
386
|
-
if (field.fldLock) beginAttrs.push("w:fldLock=\"true\"");
|
|
387
|
-
if (field.dirty) beginAttrs.push("w:dirty=\"true\"");
|
|
328
|
+
const beginAttrs = ["w:fldCharType=\"begin\"", ...fieldStateAttributes(field)];
|
|
388
329
|
parts.push(`<w:r>${rPrXml}<w:fldChar ${beginAttrs.join(" ")}/></w:r>`);
|
|
389
330
|
if (field.fieldCode.length > 0) parts.push(...field.fieldCode.map((run) => serializeRun(run)));
|
|
390
331
|
else if (field.instruction.length > 0) {
|
|
@@ -397,56 +338,6 @@ function serializeComplexField(field) {
|
|
|
397
338
|
return parts.join("");
|
|
398
339
|
}
|
|
399
340
|
/**
|
|
400
|
-
* Synthesize a `<w:sdtPr>` from the modeled {@link SdtProperties}.
|
|
401
|
-
*
|
|
402
|
-
* Only reached for an inline SDT that carries no captured `rawPropertiesXml`
|
|
403
|
-
* (constructed programmatically rather than parsed from a DOCX). Mirrors the
|
|
404
|
-
* block-SDT fallback: emit `w:id` first so the parsed numeric id survives,
|
|
405
|
-
* then the shared identity fields, then the type-defining marker.
|
|
406
|
-
*/
|
|
407
|
-
function synthesizeInlineSdtPr(props) {
|
|
408
|
-
const prParts = [];
|
|
409
|
-
if (typeof props.id === "number") prParts.push(`<w:id w:val="${props.id}"/>`);
|
|
410
|
-
if (props.alias) prParts.push(`<w:alias w:val="${escapeXmlAttribute(props.alias)}"/>`);
|
|
411
|
-
if (props.tag) prParts.push(`<w:tag w:val="${escapeXmlAttribute(props.tag)}"/>`);
|
|
412
|
-
if (props.lock && props.lock !== "unlocked") prParts.push(`<w:lock w:val="${props.lock}"/>`);
|
|
413
|
-
if (props.placeholder) prParts.push(`<w:placeholder><w:docPart w:val="${escapeXmlAttribute(props.placeholder)}"/></w:placeholder>`);
|
|
414
|
-
if (props.showingPlaceholder) prParts.push("<w:showingPlcHdr/>");
|
|
415
|
-
switch (props.sdtType) {
|
|
416
|
-
case "plainText":
|
|
417
|
-
prParts.push("<w:text/>");
|
|
418
|
-
break;
|
|
419
|
-
case "date": {
|
|
420
|
-
const fullDateAttr = props.dateValueISO ? ` w:fullDate="${escapeXmlAttribute(props.dateValueISO)}"` : "";
|
|
421
|
-
const formatChild = props.dateFormat ? `<w:dateFormat w:val="${escapeXmlAttribute(props.dateFormat)}"/>` : "";
|
|
422
|
-
if (fullDateAttr || formatChild) prParts.push(`<w:date${fullDateAttr}>${formatChild}</w:date>`);
|
|
423
|
-
else prParts.push("<w:date/>");
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
case "dropdown": {
|
|
427
|
-
const items = (props.listItems ?? []).map((i) => `<w:listItem w:displayText="${escapeXmlAttribute(i.displayText)}" w:value="${escapeXmlAttribute(i.value)}"/>`).join("");
|
|
428
|
-
prParts.push(`<w:dropDownList>${items}</w:dropDownList>`);
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
case "comboBox": {
|
|
432
|
-
const items = (props.listItems ?? []).map((i) => `<w:listItem w:displayText="${escapeXmlAttribute(i.displayText)}" w:value="${escapeXmlAttribute(i.value)}"/>`).join("");
|
|
433
|
-
prParts.push(`<w:comboBox>${items}</w:comboBox>`);
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
case "checkbox":
|
|
437
|
-
prParts.push(`<w14:checkbox><w14:checked w14:val="${props.checked ? "1" : "0"}"/></w14:checkbox>`);
|
|
438
|
-
break;
|
|
439
|
-
case "picture":
|
|
440
|
-
prParts.push("<w:picture/>");
|
|
441
|
-
break;
|
|
442
|
-
case "richText":
|
|
443
|
-
case "buildingBlockGallery":
|
|
444
|
-
case "group":
|
|
445
|
-
case "unknown": break;
|
|
446
|
-
}
|
|
447
|
-
return `<w:sdtPr>${prParts.join("")}</w:sdtPr>`;
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
341
|
* Serialize an inline SDT (w:sdt).
|
|
451
342
|
*
|
|
452
343
|
* Replays the captured `<w:sdtPr>` / `<w:sdtEndPr>` verbatim so unmodeled
|
|
@@ -455,30 +346,27 @@ function synthesizeInlineSdtPr(props) {
|
|
|
455
346
|
* the properties block was re-synthesized from the modeled projection alone,
|
|
456
347
|
* silently dropping every unmodeled feature (and `w:sdtEndPr`) on save.
|
|
457
348
|
*/
|
|
458
|
-
function serializeInlineSdt(sdt) {
|
|
349
|
+
function serializeInlineSdt(sdt, disposition = "kept") {
|
|
459
350
|
const props = sdt.properties;
|
|
460
|
-
|
|
351
|
+
return serializeSdtWrapper(props, sdt.content.map((item) => {
|
|
461
352
|
switch (item.type) {
|
|
462
|
-
case "run": return
|
|
463
|
-
case "hyperlink": return serializeHyperlink(item);
|
|
353
|
+
case "run": return serializeInlineRun(item, disposition);
|
|
354
|
+
case "hyperlink": return serializeHyperlink(item, disposition);
|
|
464
355
|
case "simpleField": return serializeSimpleField(item);
|
|
465
356
|
case "complexField": return serializeComplexField(item);
|
|
466
|
-
case "inlineSdt": return serializeInlineSdt(item);
|
|
357
|
+
case "inlineSdt": return serializeInlineSdt(item, disposition);
|
|
358
|
+
case "inlineWrapper": return serializeParagraphContent(item, disposition);
|
|
359
|
+
case "bookmarkStart": return serializeBookmarkMarker(item);
|
|
360
|
+
case "bookmarkEnd": return serializeBookmarkMarker(item);
|
|
467
361
|
case "insertion": return serializeTrackedChange("ins", item);
|
|
468
362
|
case "deletion": return serializeTrackedChange("del", item);
|
|
469
363
|
case "moveFrom": return serializeTrackedChange("moveFrom", item);
|
|
470
364
|
case "moveTo": return serializeTrackedChange("moveTo", item);
|
|
471
365
|
case "mathEquation": return item.ommlXml || "";
|
|
366
|
+
case "preservedInline": return item.xml;
|
|
472
367
|
default: return item;
|
|
473
368
|
}
|
|
474
|
-
}).join("");
|
|
475
|
-
const baseSdtPr = props.rawPropertiesXml && isSingleWellFormedElement(props.rawPropertiesXml, "sdtPr") ? props.rawPropertiesXml : synthesizeInlineSdtPr(props);
|
|
476
|
-
const dateFullDate = props.sdtType === "date" && props.dateValueISO ? props.dateValueISO : void 0;
|
|
477
|
-
const dropdownLastValue = (props.sdtType === "dropdown" || props.sdtType === "comboBox") && typeof props.dropdownLastValue === "string" ? props.dropdownLastValue : void 0;
|
|
478
|
-
return `<w:sdt>${reconcileRawSdtPr(baseSdtPr, props, {
|
|
479
|
-
...dateFullDate !== void 0 ? { dateFullDate } : {},
|
|
480
|
-
...dropdownLastValue !== void 0 ? { dropdownLastValue } : {}
|
|
481
|
-
})}${props.rawEndPropertiesXml && isSingleWellFormedElement(props.rawEndPropertiesXml, "sdtEndPr") ? props.rawEndPropertiesXml : ""}<w:sdtContent>${contentXml}</w:sdtContent></w:sdt>`;
|
|
369
|
+
}).join(""));
|
|
482
370
|
}
|
|
483
371
|
function serializeMoveRangeStart(tag, marker) {
|
|
484
372
|
return `<w:${tag} ${moveBookmarkAttributes(marker).join(" ")}/>`;
|
|
@@ -489,6 +377,22 @@ function serializeMoveRangeStart(tag, marker) {
|
|
|
489
377
|
function rewriteRunTextAsDeleted(xml) {
|
|
490
378
|
return xml.replace(/<w:t\b/gu, "<w:delText").replace(/<\/w:t>/gu, "</w:delText>").replace(/<w:instrText\b/gu, "<w:delInstrText").replace(/<\/w:instrText>/gu, "</w:delInstrText>");
|
|
491
379
|
}
|
|
380
|
+
function serializeDeletedRun(run) {
|
|
381
|
+
const xml = serializeRun(run);
|
|
382
|
+
if (!run.content.some((c) => c.type === "drawing" || c.type === "shape")) return rewriteRunTextAsDeleted(xml);
|
|
383
|
+
if (!run.content.some((c) => c.type !== "drawing" && c.type !== "shape")) return xml;
|
|
384
|
+
return run.content.map((content) => {
|
|
385
|
+
const contentXml = serializeRun({
|
|
386
|
+
...run,
|
|
387
|
+
content: [content]
|
|
388
|
+
});
|
|
389
|
+
if (content.type === "drawing" || content.type === "shape") return contentXml;
|
|
390
|
+
return rewriteRunTextAsDeleted(contentXml);
|
|
391
|
+
}).join("");
|
|
392
|
+
}
|
|
393
|
+
function serializeInlineRun(run, disposition) {
|
|
394
|
+
return disposition === "removed" ? serializeDeletedRun(run) : serializeRun(run);
|
|
395
|
+
}
|
|
492
396
|
function trackedChangeTag(change) {
|
|
493
397
|
switch (change.type) {
|
|
494
398
|
case "insertion": return "ins";
|
|
@@ -499,29 +403,28 @@ function trackedChangeTag(change) {
|
|
|
499
403
|
}
|
|
500
404
|
function serializeTrackedChange(tag, change) {
|
|
501
405
|
const attrs = serializeTrackedChangeAttributes(change.info);
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
if (!run.content.some((c) => c.type === "drawing" || c.type === "shape")) return rewriteRunTextAsDeleted(xml);
|
|
505
|
-
if (!run.content.some((c) => c.type !== "drawing" && c.type !== "shape")) return xml;
|
|
506
|
-
return run.content.map((content) => {
|
|
507
|
-
const contentXml = serializeRun({
|
|
508
|
-
...run,
|
|
509
|
-
content: [content]
|
|
510
|
-
});
|
|
511
|
-
if (content.type === "drawing" || content.type === "shape") return contentXml;
|
|
512
|
-
return rewriteRunTextAsDeleted(contentXml);
|
|
513
|
-
}).join("");
|
|
514
|
-
};
|
|
515
|
-
const serializeContentRun = (run) => tag === "del" || tag === "moveFrom" ? serializeDeletedRun(run) : serializeRun(run);
|
|
406
|
+
const disposition = tag === "del" || tag === "moveFrom" ? "removed" : "kept";
|
|
407
|
+
const serializeContentRun = (run) => serializeInlineRun(run, disposition);
|
|
516
408
|
const serializeWrappedItem = (item) => {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
409
|
+
switch (item.type) {
|
|
410
|
+
case "run": return serializeContentRun(item);
|
|
411
|
+
case "simpleField":
|
|
412
|
+
case "complexField": {
|
|
413
|
+
const xml = item.type === "simpleField" ? serializeSimpleField(item) : serializeComplexField(item);
|
|
414
|
+
return disposition === "removed" ? rewriteRunTextAsDeleted(xml) : xml;
|
|
415
|
+
}
|
|
416
|
+
case "mathEquation": return item.ommlXml;
|
|
417
|
+
case "insertion":
|
|
418
|
+
case "deletion":
|
|
419
|
+
case "moveFrom":
|
|
420
|
+
case "moveTo": return serializeTrackedChange(trackedChangeTag(item), item);
|
|
421
|
+
case "bookmarkStart":
|
|
422
|
+
case "bookmarkEnd": return serializeBookmarkMarker(item);
|
|
423
|
+
case "preservedInline": return item.xml;
|
|
424
|
+
case "inlineWrapper":
|
|
425
|
+
case "inlineSdt": return serializeParagraphContent(item, disposition);
|
|
426
|
+
default: return item;
|
|
521
427
|
}
|
|
522
|
-
if (item.type === "mathEquation") return item.ommlXml;
|
|
523
|
-
if (item.type === "insertion" || item.type === "deletion" || item.type === "moveFrom" || item.type === "moveTo") return serializeTrackedChange(trackedChangeTag(item), item);
|
|
524
|
-
return item.type === "bookmarkStart" ? serializeBookmarkStart(item) : serializeBookmarkEnd(item);
|
|
525
428
|
};
|
|
526
429
|
const open = `<w:${tag} ${attrs}>`;
|
|
527
430
|
const close = `</w:${tag}>`;
|
|
@@ -538,7 +441,7 @@ function serializeTrackedChange(tag, change) {
|
|
|
538
441
|
for (const item of change.content) {
|
|
539
442
|
if (item.type === "hyperlink") {
|
|
540
443
|
flushPending();
|
|
541
|
-
const childrenXml = item.children.map((child) => serializeHyperlinkChild(child,
|
|
444
|
+
const childrenXml = item.children.map((child) => serializeHyperlinkChild(child, disposition)).join("");
|
|
542
445
|
segments.push(`<w:hyperlink${hyperlinkAttributes(item)}>${open}${childrenXml}${close}</w:hyperlink>`);
|
|
543
446
|
continue;
|
|
544
447
|
}
|
|
@@ -547,6 +450,32 @@ function serializeTrackedChange(tag, change) {
|
|
|
547
450
|
flushPending();
|
|
548
451
|
return segments.join("");
|
|
549
452
|
}
|
|
453
|
+
const TAGGED_WRAPPER_PROPERTY_NAMES = {
|
|
454
|
+
smartTag: /* @__PURE__ */ new Set(["smartTagPr"]),
|
|
455
|
+
customXml: /* @__PURE__ */ new Set(["customXmlPr"])
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Emit a `w:smartTag` or a run-level `w:customXml` around content already written.
|
|
459
|
+
*
|
|
460
|
+
* `w:element` is required by both content models, so it is always spelled;
|
|
461
|
+
* `w:uri` is written only when the source stated one, because inventing an
|
|
462
|
+
* empty namespace would change what the tag names. The properties element
|
|
463
|
+
* comes first, as both content models declare it.
|
|
464
|
+
*
|
|
465
|
+
* The captured properties are replayed only when they are structurally the one
|
|
466
|
+
* element they claim to be. The layer rides a ProseMirror mark, so a paste from
|
|
467
|
+
* outside the editor can put any string there, and a string that closed the
|
|
468
|
+
* wrapper early would splice sibling markup into the part.
|
|
469
|
+
*/
|
|
470
|
+
function serializeTaggedWrapper(kind, wrapper, inner) {
|
|
471
|
+
const uri = wrapper.uri === void 0 ? "" : ` w:uri="${escapeXmlAttribute(wrapper.uri)}"`;
|
|
472
|
+
const properties = sanitizeCapturedXmlElement(wrapper.propertiesXml, {
|
|
473
|
+
allowedLocalNames: TAGGED_WRAPPER_PROPERTY_NAMES[kind],
|
|
474
|
+
allowedNamespaceUris: WORDPROCESSINGML_NAMESPACE,
|
|
475
|
+
inheritedNamespaceScope: OOXML_NAMESPACE_SCOPE
|
|
476
|
+
}) ?? "";
|
|
477
|
+
return `<w:${kind}${uri} w:element="${escapeXmlAttribute(wrapper.element)}">${properties}${inner}</w:${kind}>`;
|
|
478
|
+
}
|
|
550
479
|
/** Emit the `<w:commentReference>` run Word places after a comment range end. */
|
|
551
480
|
function serializeCommentReferenceRun(id) {
|
|
552
481
|
return `<w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="${id}"/></w:r>`;
|
|
@@ -554,27 +483,22 @@ function serializeCommentReferenceRun(id) {
|
|
|
554
483
|
/**
|
|
555
484
|
* Serialize a single paragraph content item.
|
|
556
485
|
*
|
|
557
|
-
* `
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
* editor (fromProseDoc) path emits range markers with no reference node, so the
|
|
562
|
-
* synthetic run is still written when the id is absent from the set.
|
|
486
|
+
* A `commentRangeEnd` writes an end and nothing else. Where the comment's
|
|
487
|
+
* reference run goes is authored data the model carries as its own item, and
|
|
488
|
+
* `completeCommentReferences` fills it in for a model that arrived without
|
|
489
|
+
* one; a guess made here from one paragraph cannot see the rest of the story.
|
|
563
490
|
*/
|
|
564
|
-
function serializeParagraphContent(content,
|
|
491
|
+
function serializeParagraphContent(content, disposition = "kept") {
|
|
565
492
|
switch (content.type) {
|
|
566
|
-
case "run": return
|
|
567
|
-
case "hyperlink": return serializeHyperlink(content);
|
|
568
|
-
case "bookmarkStart":
|
|
569
|
-
case "bookmarkEnd": return
|
|
493
|
+
case "run": return serializeInlineRun(content, disposition);
|
|
494
|
+
case "hyperlink": return serializeHyperlink(content, disposition);
|
|
495
|
+
case "bookmarkStart":
|
|
496
|
+
case "bookmarkEnd": return serializeBookmarkMarker(content);
|
|
570
497
|
case "simpleField": return serializeSimpleField(content);
|
|
571
498
|
case "complexField": return serializeComplexField(content);
|
|
572
|
-
case "inlineSdt": return serializeInlineSdt(content);
|
|
499
|
+
case "inlineSdt": return serializeInlineSdt(content, disposition);
|
|
573
500
|
case "commentRangeStart": return `<w:commentRangeStart ${markupRangeAttributes(content).join(" ")}/>`;
|
|
574
|
-
case "commentRangeEnd": {
|
|
575
|
-
const end = `<w:commentRangeEnd ${markupRangeAttributes(content).join(" ")}/>`;
|
|
576
|
-
return explicitCommentReferenceIds.has(content.id) ? end : `${end}${serializeCommentReferenceRun(content.id)}`;
|
|
577
|
-
}
|
|
501
|
+
case "commentRangeEnd": return `<w:commentRangeEnd ${markupRangeAttributes(content).join(" ")}/>`;
|
|
578
502
|
case "commentReference": return serializeCommentReferenceRun(content.id);
|
|
579
503
|
case "insertion": return serializeTrackedChange("ins", content);
|
|
580
504
|
case "deletion": return serializeTrackedChange("del", content);
|
|
@@ -584,11 +508,20 @@ function serializeParagraphContent(content, explicitCommentReferenceIds) {
|
|
|
584
508
|
case "moveFromRangeEnd": return `<w:moveFromRangeEnd ${markupRangeAttributes(content).join(" ")}/>`;
|
|
585
509
|
case "moveToRangeStart": return serializeMoveRangeStart("moveToRangeStart", content);
|
|
586
510
|
case "moveToRangeEnd": return `<w:moveToRangeEnd ${markupRangeAttributes(content).join(" ")}/>`;
|
|
587
|
-
case "
|
|
588
|
-
const
|
|
589
|
-
|
|
511
|
+
case "inlineWrapper": {
|
|
512
|
+
const inner = content.content.map((child) => serializeParagraphContent(child, disposition)).join("");
|
|
513
|
+
switch (content.kind) {
|
|
514
|
+
case "bidi": {
|
|
515
|
+
const tag = content.control === "override" ? "bdo" : "dir";
|
|
516
|
+
return `<w:${tag}${content.direction === void 0 ? "" : ` w:val="${escapeXmlAttribute(content.direction)}"`}>${inner}</w:${tag}>`;
|
|
517
|
+
}
|
|
518
|
+
case "smartTag": return serializeTaggedWrapper("smartTag", content, inner);
|
|
519
|
+
case "customXml": return serializeTaggedWrapper("customXml", content, inner);
|
|
520
|
+
default: return content;
|
|
521
|
+
}
|
|
590
522
|
}
|
|
591
523
|
case "mathEquation": return content.ommlXml || "";
|
|
524
|
+
case "preservedInline": return content.xml;
|
|
592
525
|
default: return "";
|
|
593
526
|
}
|
|
594
527
|
}
|
|
@@ -604,18 +537,17 @@ function serializeParagraph(paragraph) {
|
|
|
604
537
|
if (paragraph.paraId) attrs.push(`w14:paraId="${escapeXmlAttribute(paragraph.paraId)}"`);
|
|
605
538
|
if (paragraph.textId) attrs.push(`w14:textId="${escapeXmlAttribute(paragraph.textId)}"`);
|
|
606
539
|
if (paragraph.reviewCarrier) attrs.push(`folio:reviewCarrier="${paragraph.reviewCarrier}"`);
|
|
607
|
-
const
|
|
540
|
+
const written = serializePreservedAttributes(attrs, paragraph.preservedAttributes);
|
|
541
|
+
const attrsStr = written.length > 0 ? ` ${written.join(" ")}` : "";
|
|
608
542
|
parts.push(serializeParagraphFormattingWithOptions(paragraph.formatting, {
|
|
609
543
|
propertyChanges: paragraph.propertyChanges,
|
|
610
544
|
paragraphMarkChange: paragraph.pPrMark,
|
|
611
545
|
propertySource: getParagraphPropertySource(paragraph),
|
|
612
546
|
sectionProperties: paragraph.sectionProperties
|
|
613
547
|
}));
|
|
614
|
-
const explicitCommentReferenceIds = /* @__PURE__ */ new Set();
|
|
615
|
-
for (const content of paragraph.content) if (content.type === "commentReference") explicitCommentReferenceIds.add(content.id);
|
|
616
548
|
let pendingRenderedPageBreak = paragraph.renderedPageBreakBefore === true;
|
|
617
549
|
for (const content of paragraph.content) {
|
|
618
|
-
let contentXml = serializeParagraphContent(content
|
|
550
|
+
let contentXml = serializeParagraphContent(content);
|
|
619
551
|
if (contentXml) {
|
|
620
552
|
if (pendingRenderedPageBreak) {
|
|
621
553
|
const next = injectRenderedPageBreakIntoFirstRun(contentXml);
|
|
@@ -700,17 +632,5 @@ function createTextParagraph(text, paragraphFormatting, textFormatting) {
|
|
|
700
632
|
}]
|
|
701
633
|
};
|
|
702
634
|
}
|
|
703
|
-
/**
|
|
704
|
-
* Check if paragraph is a list item
|
|
705
|
-
*/
|
|
706
|
-
function isListParagraph(paragraph) {
|
|
707
|
-
return paragraph.formatting?.numPr !== void 0;
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Get list level of a paragraph (0-8, or -1 if not a list)
|
|
711
|
-
*/
|
|
712
|
-
function getListLevel(paragraph) {
|
|
713
|
-
return paragraph.formatting?.numPr?.ilvl ?? -1;
|
|
714
|
-
}
|
|
715
635
|
//#endregion
|
|
716
|
-
export { createEmptyParagraph, createTextParagraph,
|
|
636
|
+
export { createEmptyParagraph, createTextParagraph, hasParagraphContent, hasParagraphFormatting, serializeParagraph, serializeParagraphFormatting, serializeParagraphs };
|
|
@@ -19,10 +19,6 @@ declare function serializeRun(run: document_d_exports.Run): string;
|
|
|
19
19
|
* @returns XML string for all runs
|
|
20
20
|
*/
|
|
21
21
|
declare function serializeRuns(runs: document_d_exports.Run[]): string;
|
|
22
|
-
/**
|
|
23
|
-
* Check if a run has any content
|
|
24
|
-
*/
|
|
25
|
-
declare function hasRunContent(run: document_d_exports.Run): boolean;
|
|
26
22
|
/**
|
|
27
23
|
* Check if a run has formatting
|
|
28
24
|
*/
|
|
@@ -48,4 +44,4 @@ declare function createBreakRun(breakType?: "page" | "column" | "textWrapping",
|
|
|
48
44
|
*/
|
|
49
45
|
declare function createTabRun(formatting?: document_d_exports.TextFormatting): document_d_exports.Run;
|
|
50
46
|
//#endregion
|
|
51
|
-
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText,
|
|
47
|
+
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText, hasRunFormatting, resetAutoIdCounter, serializeRun, serializeRuns };
|