@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
|
@@ -6,20 +6,21 @@ import { partitionRunsAtPageBreaks } from "../../internal/pageBreakRunPartition.
|
|
|
6
6
|
import { setHyperlinkInstanceIndex } from "../../layout-engine/measure/hyperlinkInstance.js";
|
|
7
7
|
import { setParagraphFrame } from "../../layout-engine/paragraphFrame.js";
|
|
8
8
|
import { setTextBoxGroupId } from "../../layout-engine/textBoxGroup.js";
|
|
9
|
-
import { DEFAULT_TEXTBOX_MARGINS } from "../../layout-engine/types.js";
|
|
9
|
+
import { DEFAULT_TEXTBOX_MARGINS, isListNumPr } from "../../layout-engine/types.js";
|
|
10
10
|
import { getPageNumbering } from "../../paged-layout/sectionGeometry.js";
|
|
11
|
-
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectSymbolAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../../prosemirror/attrs/index.js";
|
|
11
|
+
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectSymbolAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../../prosemirror/attrs/index.js";
|
|
12
12
|
import { autospacingMatchesBase } from "../../prosemirror/autospacingBase.js";
|
|
13
13
|
import { runShadingAttrsToShading } from "../../prosemirror/conversion/runShadingMark.js";
|
|
14
14
|
import { advanceListMarker, advanceVisibleListMarker, cloneListCounterState, formatCounter, resolveListTemplate } from "../../prosemirror/listMarker.js";
|
|
15
15
|
import { resolveNumberedRefFields } from "../../prosemirror/numberedRefFields.js";
|
|
16
|
-
import {
|
|
17
|
-
import { directionToBidi } from "../../prosemirror/paragraphDirection.js";
|
|
16
|
+
import { directionIsRtl, directionToBidi } from "../../prosemirror/paragraphDirection.js";
|
|
18
17
|
import { resolveEffectiveRunStyleFormatting } from "../../prosemirror/runStyleFormatting.js";
|
|
18
|
+
import { parseSectionBreakType } from "../../prosemirror/sectionCarrier.js";
|
|
19
19
|
import { expectTextBoxAnchorAttrs } from "../../prosemirror/textBoxAnchorAttrs.js";
|
|
20
20
|
import { assertValidProseMirrorDocument } from "../../prosemirror/validation.js";
|
|
21
21
|
import { createStyleEngine } from "../../style-engine/styleEngine.js";
|
|
22
22
|
import { normalizeShapeTextAnchor } from "../../types/documentEnumValues.js";
|
|
23
|
+
import { cssBorderStyle, cssBorderStyleOf } from "../../utils/borderCss.js";
|
|
23
24
|
import { resolveColor, resolveHighlightToCss } from "../../utils/colorResolver.js";
|
|
24
25
|
import { resolveThemeFont } from "../../utils/fontResolver.js";
|
|
25
26
|
import { resolveShadingFill } from "../../utils/formatToStyle.js";
|
|
@@ -32,6 +33,7 @@ import { AUTO_PARAGRAPH_SPACING_PX, halfPointsToPixels, halfPointsToPoints, poin
|
|
|
32
33
|
import { getColumns } from "../sectionColumns.js";
|
|
33
34
|
import { groupParagraphFrames } from "./paragraphFrames.js";
|
|
34
35
|
import { panic } from "better-result";
|
|
36
|
+
import { headingLevelOf, paragraphNumberingLevel, paragraphNumberingReferenceId, sameStatedParagraphNumbering, statesNoBorder } from "@stll/docx-core/model";
|
|
35
37
|
//#region src/layout-bridge/convert/toFlowBlocks.ts
|
|
36
38
|
const DETACHED_WATERMARK_HOST_ATTR = "_detachedWatermarkHost";
|
|
37
39
|
const expectDetachedWatermarkHostAttr = (attrs) => {
|
|
@@ -40,7 +42,14 @@ const expectDetachedWatermarkHostAttr = (attrs) => {
|
|
|
40
42
|
if (typeof value !== "boolean") panic("Invalid ProseMirror detached watermark host attrs:\nparagraph.attrs._detachedWatermarkHost: Expected a boolean.");
|
|
41
43
|
return value;
|
|
42
44
|
};
|
|
43
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Word's layout fallback when an imported OOXML style hierarchy never supplies
|
|
47
|
+
* `w:sz`. ECMA-376 deliberately leaves that terminal fallback to the consumer;
|
|
48
|
+
* this value matches Word and is therefore applied by the DOCX composition
|
|
49
|
+
* roots, while standalone ProseMirror documents keep the layout engine's 11pt
|
|
50
|
+
* default.
|
|
51
|
+
*/
|
|
52
|
+
const WORD_UNSPECIFIED_FONT_SIZE = 10;
|
|
44
53
|
const TEXT_BOX_ANCHOR_BLOCK_ID = Symbol.for("stll.textBoxAnchorBlockId");
|
|
45
54
|
const DEFAULT_TABLE_CELL_MARGIN_TWIPS = {
|
|
46
55
|
top: 0,
|
|
@@ -73,7 +82,6 @@ function constrainImageToPage(width, height, pageContentHeight) {
|
|
|
73
82
|
height: pageContentHeight
|
|
74
83
|
};
|
|
75
84
|
}
|
|
76
|
-
const DEFAULT_SIZE = 11;
|
|
77
85
|
/**
|
|
78
86
|
* Convert twips to pixels (1 twip = 1/1440 inch, 1 inch = 96 CSS px).
|
|
79
87
|
* No rounding — precision prevents cumulative layout drift across paragraphs.
|
|
@@ -102,6 +110,86 @@ function resetBlockIdCounter() {
|
|
|
102
110
|
blockIdCounter = 0;
|
|
103
111
|
}
|
|
104
112
|
/**
|
|
113
|
+
* What the painter does with each mark the schema declares.
|
|
114
|
+
*
|
|
115
|
+
* The switch below used to end in `default: break`, so a mark that reached it
|
|
116
|
+
* was silently not painted whether that was the decision or an omission. The
|
|
117
|
+
* table is total over {@link SchemaMarkName}: a mark added to the schema
|
|
118
|
+
* without a paint decision does not compile, and a mark this table says is
|
|
119
|
+
* painted but the switch does not handle panics rather than disappearing.
|
|
120
|
+
*/
|
|
121
|
+
const MARK_PAINT_DISPOSITIONS = {
|
|
122
|
+
bold: "runFormatting",
|
|
123
|
+
italic: "runFormatting",
|
|
124
|
+
underline: "runFormatting",
|
|
125
|
+
strike: "runFormatting",
|
|
126
|
+
textColor: "runFormatting",
|
|
127
|
+
runShading: "runFormatting",
|
|
128
|
+
highlight: "runFormatting",
|
|
129
|
+
fontSize: "runFormatting",
|
|
130
|
+
fontFamily: "runFormatting",
|
|
131
|
+
language: "runFormatting",
|
|
132
|
+
superscript: "runFormatting",
|
|
133
|
+
subscript: "runFormatting",
|
|
134
|
+
hyperlink: "runFormatting",
|
|
135
|
+
allCaps: "runFormatting",
|
|
136
|
+
smallCaps: "runFormatting",
|
|
137
|
+
footnoteRef: "runFormatting",
|
|
138
|
+
characterSpacing: "runFormatting",
|
|
139
|
+
emboss: "runFormatting",
|
|
140
|
+
imprint: "runFormatting",
|
|
141
|
+
hidden: "runFormatting",
|
|
142
|
+
textShadow: "runFormatting",
|
|
143
|
+
emphasisMark: "runFormatting",
|
|
144
|
+
textOutline: "runFormatting",
|
|
145
|
+
rtl: "runFormatting",
|
|
146
|
+
textEffect: "runFormatting",
|
|
147
|
+
runFormattingOverride: "runFormatting",
|
|
148
|
+
comment: "runFormatting",
|
|
149
|
+
insertion: "runFormatting",
|
|
150
|
+
deletion: "runFormatting",
|
|
151
|
+
inlineWrapper: "runFormatting",
|
|
152
|
+
characterStyle: "resolvedElsewhere",
|
|
153
|
+
runIdentity: "notPainted",
|
|
154
|
+
runPropertyChange: "notPainted"
|
|
155
|
+
};
|
|
156
|
+
const markPaintDisposition = (name) => {
|
|
157
|
+
return MARK_PAINT_DISPOSITIONS[name];
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Whether a layer states how its content is laid out.
|
|
161
|
+
*
|
|
162
|
+
* A smart tag and a custom-XML wrapper name an element in another vocabulary
|
|
163
|
+
* and say nothing about layout, so the painter draws the text exactly as it
|
|
164
|
+
* would without them. The `switch` is here rather than inline so a kind added
|
|
165
|
+
* to the model has to answer the question.
|
|
166
|
+
*/
|
|
167
|
+
const paintedDirection = (layer) => {
|
|
168
|
+
switch (layer.kind) {
|
|
169
|
+
case "bidi": return layer.direction === void 0 ? { control: layer.control } : {
|
|
170
|
+
control: layer.control,
|
|
171
|
+
direction: layer.direction
|
|
172
|
+
};
|
|
173
|
+
case "smartTag":
|
|
174
|
+
case "customXml": return;
|
|
175
|
+
default: return;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* The direction the innermost bidirectional layer of a stack lays its content out in.
|
|
180
|
+
*
|
|
181
|
+
* Innermost wins: a bidirectional wrapper inside another is the one the text is
|
|
182
|
+
* laid out in, and the outer layers are what the save leg rebuilds the nesting
|
|
183
|
+
* from. The layers that state no direction are skipped rather than ending the
|
|
184
|
+
* search, so a smart tag inside a `w:dir` still reads right to left.
|
|
185
|
+
*/
|
|
186
|
+
const innermostBidiWrapper = (stack) => {
|
|
187
|
+
for (const layer of stack.toReversed()) {
|
|
188
|
+
const direction = paintedDirection(layer);
|
|
189
|
+
if (direction !== void 0) return direction;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
105
193
|
* Extract run formatting from ProseMirror marks.
|
|
106
194
|
*/
|
|
107
195
|
function extractRunFormatting(marks, theme, fontAlternates) {
|
|
@@ -273,6 +361,7 @@ function extractRunFormatting(marks, theme, fontAlternates) {
|
|
|
273
361
|
case "deletion": {
|
|
274
362
|
const attrs = expectTrackedChangeMarkAttrs(mark);
|
|
275
363
|
formatting.isDeletion = true;
|
|
364
|
+
if (attrs._historicalFormatting) formatting.usesHistoricalFormatting = true;
|
|
276
365
|
formatting.changeAuthor = attrs.author;
|
|
277
366
|
if (attrs.date !== void 0) formatting.changeDate = attrs.date;
|
|
278
367
|
formatting.changeRevisionId = attrs.revisionId;
|
|
@@ -282,7 +371,14 @@ function extractRunFormatting(marks, theme, fontAlternates) {
|
|
|
282
371
|
}
|
|
283
372
|
break;
|
|
284
373
|
}
|
|
285
|
-
|
|
374
|
+
case "inlineWrapper": {
|
|
375
|
+
const bidiWrapper = innermostBidiWrapper(expectInlineWrapperMarkAttrs(mark).stack);
|
|
376
|
+
if (bidiWrapper) formatting.bidiWrapper = bidiWrapper;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
default:
|
|
380
|
+
if (markPaintDisposition(mark.type.name) === "runFormatting") panic(`Mark ${mark.type.name} is painted as run formatting but has no branch here`);
|
|
381
|
+
break;
|
|
286
382
|
}
|
|
287
383
|
if (runFormattingOverride) applyRunFormattingOverrides(formatting, runFormattingOverride);
|
|
288
384
|
if (hasNoteRef && formatting.subscript) delete formatting.superscript;
|
|
@@ -310,6 +406,7 @@ function markDefaultBlackTextColorSource(formatting, paraDefaults) {
|
|
|
310
406
|
};
|
|
311
407
|
}
|
|
312
408
|
function mergeRunFormatting(paraDefaults, formatting) {
|
|
409
|
+
if (formatting.isDeletion && formatting.usesHistoricalFormatting) return formatting;
|
|
313
410
|
const merged = {
|
|
314
411
|
...paraDefaults,
|
|
315
412
|
...markDefaultBlackTextColorSource(formatting, paraDefaults)
|
|
@@ -522,6 +619,7 @@ function buildImageRun(attrs, constrained, pmStart, pmEnd, trackedChange) {
|
|
|
522
619
|
const run = {
|
|
523
620
|
kind: "image",
|
|
524
621
|
src: attrs.src,
|
|
622
|
+
...attrs.preview ? { preview: attrs.preview } : {},
|
|
525
623
|
width: constrained.width,
|
|
526
624
|
height: constrained.height,
|
|
527
625
|
pmStart,
|
|
@@ -530,6 +628,8 @@ function buildImageRun(attrs, constrained, pmStart, pmEnd, trackedChange) {
|
|
|
530
628
|
if (attrs.alt !== void 0) run.alt = attrs.alt;
|
|
531
629
|
if (attrs.transform !== void 0) run.transform = attrs.transform;
|
|
532
630
|
if (attrs.opacity != null) run.opacity = attrs.opacity;
|
|
631
|
+
if (attrs.brightness != null) run.brightness = attrs.brightness;
|
|
632
|
+
if (attrs.contrast != null) run.contrast = attrs.contrast;
|
|
533
633
|
if (attrs.wrapType !== void 0) run.wrapType = attrs.wrapType;
|
|
534
634
|
if (attrs.displayMode !== void 0) run.displayMode = attrs.displayMode;
|
|
535
635
|
if (attrs.cssFloat !== void 0) run.cssFloat = attrs.cssFloat;
|
|
@@ -544,9 +644,10 @@ function buildImageRun(attrs, constrained, pmStart, pmEnd, trackedChange) {
|
|
|
544
644
|
if (attrs.cropLeft != null) run.cropLeft = attrs.cropLeft;
|
|
545
645
|
if (attrs.borderWidth != null) run.borderWidth = attrs.borderWidth;
|
|
546
646
|
if (attrs.borderColor) run.borderColor = attrs.borderColor;
|
|
547
|
-
|
|
647
|
+
const runBorderStyle = cssBorderStyleOf(attrs.borderStyle);
|
|
648
|
+
if (runBorderStyle) run.borderStyle = runBorderStyle;
|
|
548
649
|
if (attrs.position !== void 0) run.position = attrs.position;
|
|
549
|
-
if (attrs.layoutInCell !== void 0) run.layoutInCell = attrs.layoutInCell;
|
|
650
|
+
if (attrs.anchor?.layoutInCell !== void 0) run.layoutInCell = attrs.anchor.layoutInCell;
|
|
550
651
|
if (trackedChange?.isInsertion) run.isInsertion = true;
|
|
551
652
|
if (trackedChange?.isDeletion) run.isDeletion = true;
|
|
552
653
|
if (trackedChange?.changeAuthor !== void 0) run.changeAuthor = trackedChange.changeAuthor;
|
|
@@ -556,7 +657,11 @@ function buildImageRun(attrs, constrained, pmStart, pmEnd, trackedChange) {
|
|
|
556
657
|
}
|
|
557
658
|
/** A package image whose bytes cannot paint still owns its authored line box. */
|
|
558
659
|
const hasRelationshipBackedImageBox = (attrs) => typeof attrs.rId === "string" && attrs.rId.trim().length > 0 && typeof attrs.width === "number" && Number.isFinite(attrs.width) && attrs.width >= 0 && typeof attrs.height === "number" && Number.isFinite(attrs.height) && attrs.height >= 0;
|
|
559
|
-
|
|
660
|
+
/**
|
|
661
|
+
* A preview counts as a source: the bytes are not in the attrs, but the
|
|
662
|
+
* display list can produce them without I/O when it interns the descriptor.
|
|
663
|
+
*/
|
|
664
|
+
const hasPaintableImageSource = (attrs) => attrs.preview !== void 0 || sanitizeImageSrc(attrs.src) !== void 0;
|
|
560
665
|
/**
|
|
561
666
|
* In TOC paragraphs, strip the resolved Hyperlink character-style colour and
|
|
562
667
|
* underline so the painter's link fallback doesn't fire. The PM doc keeps the
|
|
@@ -684,6 +789,25 @@ function paragraphToRuns(node, startPos, _options, pageBreaks) {
|
|
|
684
789
|
});
|
|
685
790
|
return;
|
|
686
791
|
}
|
|
792
|
+
if (child.type.name === "preservedXml") {
|
|
793
|
+
const { text } = expectPreservedXmlAttrs(child);
|
|
794
|
+
if (text === "") return;
|
|
795
|
+
const formatting = extractRunFormatting(effectiveMarks, theme, fontAlternates);
|
|
796
|
+
applyCharacterStyleToggleFormatting({
|
|
797
|
+
formatting,
|
|
798
|
+
marks: effectiveMarks,
|
|
799
|
+
paragraphFormatting: pmAttrs.defaultTextFormatting,
|
|
800
|
+
styleResolver: _options.styleResolver
|
|
801
|
+
});
|
|
802
|
+
runs.push({
|
|
803
|
+
kind: "text",
|
|
804
|
+
text,
|
|
805
|
+
...mergeRunFormatting(paraDefaults, formatting),
|
|
806
|
+
pmStart: childPos,
|
|
807
|
+
pmEnd: childPos + child.nodeSize
|
|
808
|
+
});
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
687
811
|
if (child.type.name === "hardBreak") {
|
|
688
812
|
runs.push({
|
|
689
813
|
kind: "lineBreak",
|
|
@@ -711,7 +835,7 @@ function paragraphToRuns(node, startPos, _options, pageBreaks) {
|
|
|
711
835
|
}
|
|
712
836
|
if (child.type.name === "image") {
|
|
713
837
|
const attrs = expectImageAttrs(child);
|
|
714
|
-
if (!hasPaintableImageSource(attrs
|
|
838
|
+
if (!hasPaintableImageSource(attrs) && !hasRelationshipBackedImageBox(attrs)) return;
|
|
715
839
|
const constrained = constrainImageToPage(attrs.width ?? 100, attrs.height ?? 100, _options.pageContentHeight);
|
|
716
840
|
const trackedFmt = extractRunFormatting(effectiveMarks, theme, fontAlternates);
|
|
717
841
|
const run = buildImageRun(attrs, constrained, childPos, childPos + child.nodeSize, trackedFmt);
|
|
@@ -790,6 +914,20 @@ function paragraphToRuns(node, startPos, _options, pageBreaks) {
|
|
|
790
914
|
node.forEach((child, childOffset) => {
|
|
791
915
|
pushRunsForChild(child, offset + childOffset);
|
|
792
916
|
});
|
|
917
|
+
const { defaultFont, defaultSize } = _options;
|
|
918
|
+
if (defaultFont !== void 0 || defaultSize !== void 0) for (const run of runs) switch (run.kind) {
|
|
919
|
+
case "text":
|
|
920
|
+
case "tab":
|
|
921
|
+
case "renderedPageBreak":
|
|
922
|
+
case "field":
|
|
923
|
+
case "math":
|
|
924
|
+
if (defaultFont !== void 0) run.fontFamily ??= defaultFont;
|
|
925
|
+
if (defaultSize !== void 0) run.fontSize ??= defaultSize;
|
|
926
|
+
break;
|
|
927
|
+
case "image":
|
|
928
|
+
case "lineBreak": break;
|
|
929
|
+
default:
|
|
930
|
+
}
|
|
793
931
|
return runs;
|
|
794
932
|
}
|
|
795
933
|
function toListMarkerRevision(kind, info) {
|
|
@@ -809,13 +947,7 @@ function isRemovedNumberingChange(change) {
|
|
|
809
947
|
}
|
|
810
948
|
function isChangedNumberingChange(currentNumPr, change) {
|
|
811
949
|
const previousFormatting = change.previousFormatting;
|
|
812
|
-
return previousFormatting != null && Object.hasOwn(previousFormatting, "numPr") && isListNumPr(previousFormatting.numPr) && !
|
|
813
|
-
}
|
|
814
|
-
function areListNumPrEqual(left, right) {
|
|
815
|
-
return left.numId === right.numId && left.ilvl === right.ilvl;
|
|
816
|
-
}
|
|
817
|
-
function isListNumPr(value) {
|
|
818
|
-
return value !== void 0 && value !== null;
|
|
950
|
+
return previousFormatting != null && Object.hasOwn(previousFormatting, "numPr") && isListNumPr(previousFormatting.numPr) && !sameStatedParagraphNumbering(previousFormatting.numPr, currentNumPr);
|
|
819
951
|
}
|
|
820
952
|
function toPreviousListAttrs(previousFormatting) {
|
|
821
953
|
const attrs = {};
|
|
@@ -876,7 +1008,20 @@ function applyDeletedListMarkerAttrs(attrs, change, listCounterState, theme, fon
|
|
|
876
1008
|
if (previousListAttrs.listMarkerAlignment) attrs.listMarkerAlignment = previousListAttrs.listMarkerAlignment;
|
|
877
1009
|
if (previousListAttrs.listMarkerSuffix) attrs.listMarkerSuffix = previousListAttrs.listMarkerSuffix;
|
|
878
1010
|
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Every `ST_Jc` member, and the flow alignment that paints it.
|
|
1013
|
+
*
|
|
1014
|
+
* `start` and `end` stay unresolved here: they name an edge of the writing
|
|
1015
|
+
* direction, not a side of the page, so which of `left` and `right` paints
|
|
1016
|
+
* them depends on the paragraph's direction. `numTab` has no flow alignment at
|
|
1017
|
+
* all — it aligns the paragraph to the list number's tab stop, which the flow
|
|
1018
|
+
* engine does not model — so it falls back to the start edge, which is where a
|
|
1019
|
+
* numbered paragraph without one sits.
|
|
1020
|
+
*/
|
|
879
1021
|
const FLOW_ALIGNMENT_BY_PARAGRAPH_ALIGNMENT = {
|
|
1022
|
+
start: "start",
|
|
1023
|
+
end: "end",
|
|
1024
|
+
numTab: "start",
|
|
880
1025
|
left: "left",
|
|
881
1026
|
center: "center",
|
|
882
1027
|
right: "right",
|
|
@@ -887,10 +1032,19 @@ const FLOW_ALIGNMENT_BY_PARAGRAPH_ALIGNMENT = {
|
|
|
887
1032
|
lowKashida: "justify",
|
|
888
1033
|
thaiDistribute: "justify"
|
|
889
1034
|
};
|
|
1035
|
+
/** Resolve a logical alignment against the direction the paragraph runs in. */
|
|
1036
|
+
const resolveFlowAlignment = (alignment, rightToLeft) => {
|
|
1037
|
+
const flow = FLOW_ALIGNMENT_BY_PARAGRAPH_ALIGNMENT[alignment];
|
|
1038
|
+
switch (flow) {
|
|
1039
|
+
case "start": return rightToLeft ? "right" : "left";
|
|
1040
|
+
case "end": return rightToLeft ? "left" : "right";
|
|
1041
|
+
default: return flow;
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
890
1044
|
function convertParagraphAttrs(pmAttrs, { theme, fontAlternates, listCounterStreams, defaultTabStopTwips }) {
|
|
891
1045
|
const attrs = {};
|
|
892
|
-
if (pmAttrs.alignment) attrs.alignment =
|
|
893
|
-
if (
|
|
1046
|
+
if (pmAttrs.alignment) attrs.alignment = resolveFlowAlignment(pmAttrs.alignment, directionIsRtl(pmAttrs.direction));
|
|
1047
|
+
if (pmAttrs.outlineLevel !== void 0) attrs.outlineLevel = pmAttrs.outlineLevel;
|
|
894
1048
|
const spaceBefore = pmAttrs.spaceBefore;
|
|
895
1049
|
const spaceAfter = pmAttrs.spaceAfter;
|
|
896
1050
|
const lineSpacing = pmAttrs.lineSpacing;
|
|
@@ -927,8 +1081,8 @@ function convertParagraphAttrs(pmAttrs, { theme, fontAlternates, listCounterStre
|
|
|
927
1081
|
let indentLeft = typeof pmAttrs.indentLeft === "number" ? pmAttrs.indentLeft : void 0;
|
|
928
1082
|
let indentFirstLine = typeof pmAttrs.indentFirstLine === "number" ? pmAttrs.indentFirstLine : void 0;
|
|
929
1083
|
let hangingIndent = pmAttrs.hangingIndent;
|
|
930
|
-
if (pmAttrs.numPr
|
|
931
|
-
indentLeft = ((pmAttrs.numPr
|
|
1084
|
+
if (paragraphNumberingReferenceId(pmAttrs.numPr) !== void 0 && indentLeft === void 0 && indentFirstLine === void 0) {
|
|
1085
|
+
indentLeft = ((paragraphNumberingLevel(pmAttrs.numPr) ?? 0) + 1) * 720;
|
|
932
1086
|
if (indentFirstLine === void 0) {
|
|
933
1087
|
indentFirstLine = -360;
|
|
934
1088
|
hangingIndent = true;
|
|
@@ -962,14 +1116,17 @@ function convertParagraphAttrs(pmAttrs, { theme, fontAlternates, listCounterStre
|
|
|
962
1116
|
}
|
|
963
1117
|
const shadingRgb = pmAttrs.shading?.fill?.rgb?.toUpperCase();
|
|
964
1118
|
if (shadingRgb && shadingRgb !== "FFFFFF" && shadingRgb !== "FFFFFE") attrs.shading = `#${pmAttrs.shading?.fill?.rgb}`;
|
|
965
|
-
if (pmAttrs.tabs && pmAttrs.tabs.length > 0)
|
|
966
|
-
const
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1119
|
+
if (pmAttrs.tabs && pmAttrs.tabs.length > 0) {
|
|
1120
|
+
const rightToLeft = directionIsRtl(pmAttrs.direction);
|
|
1121
|
+
attrs.tabs = pmAttrs.tabs.map((tab) => {
|
|
1122
|
+
const tabStop = {
|
|
1123
|
+
val: resolveTabAlignment(tab.alignment, rightToLeft),
|
|
1124
|
+
pos: tab.position
|
|
1125
|
+
};
|
|
1126
|
+
if (tab.leader) tabStop.leader = tab.leader;
|
|
1127
|
+
return tabStop;
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
973
1130
|
if (pmAttrs.pageBreakBefore) attrs.pageBreakBefore = true;
|
|
974
1131
|
if (pmAttrs.kinsoku !== void 0 && pmAttrs.kinsoku !== null) attrs.kinsoku = pmAttrs.kinsoku;
|
|
975
1132
|
if (pmAttrs.overflowPunctuation !== void 0 && pmAttrs.overflowPunctuation !== null) attrs.overflowPunctuation = pmAttrs.overflowPunctuation;
|
|
@@ -986,10 +1143,7 @@ function convertParagraphAttrs(pmAttrs, { theme, fontAlternates, listCounterStre
|
|
|
986
1143
|
const propertyChanges = pmAttrs._propertyChanges ?? [];
|
|
987
1144
|
let changedNumberingChange;
|
|
988
1145
|
if (pmAttrs.numPr) {
|
|
989
|
-
|
|
990
|
-
if (pmAttrs.numPr.numId !== void 0) numPr.numId = pmAttrs.numPr.numId;
|
|
991
|
-
if (pmAttrs.numPr.ilvl !== void 0) numPr.ilvl = pmAttrs.numPr.ilvl;
|
|
992
|
-
attrs.numPr = numPr;
|
|
1146
|
+
attrs.numPr = pmAttrs.numPr;
|
|
993
1147
|
if (pmAttrs.pPrMark?.kind === "del") attrs.listMarkerRevision = toListMarkerRevision("del", pmAttrs.pPrMark.info);
|
|
994
1148
|
else if (pmAttrs.pPrMark?.kind === "ins") attrs.listMarkerRevision = toListMarkerRevision("ins", pmAttrs.pPrMark.info);
|
|
995
1149
|
else {
|
|
@@ -1036,20 +1190,35 @@ function convertParagraphAttrs(pmAttrs, { theme, fontAlternates, listCounterStre
|
|
|
1036
1190
|
return attrs;
|
|
1037
1191
|
}
|
|
1038
1192
|
/**
|
|
1039
|
-
*
|
|
1193
|
+
* Every `ST_TabJc` member, and the layout engine's name for it.
|
|
1194
|
+
*
|
|
1195
|
+
* The engine's `start` and `end` are its names for the left and right edges of
|
|
1196
|
+
* the line, not direction-aware ones, so `w:tab w:val="left"` maps to `start`
|
|
1197
|
+
* unconditionally. `ST_TabJc`'s own `start` and `end` *are* direction-aware
|
|
1198
|
+
* and stay unresolved here, under names the engine has no member for.
|
|
1199
|
+
* `num`, the tab a numbered paragraph's text hangs from, has no engine
|
|
1200
|
+
* alignment of its own and falls back to the line's start edge.
|
|
1040
1201
|
*/
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1202
|
+
const TAB_ALIGNMENT_BY_TAB_STOP_ALIGNMENT = {
|
|
1203
|
+
start: "logicalStart",
|
|
1204
|
+
end: "logicalEnd",
|
|
1205
|
+
num: "logicalStart",
|
|
1206
|
+
left: "start",
|
|
1207
|
+
right: "end",
|
|
1208
|
+
center: "center",
|
|
1209
|
+
decimal: "decimal",
|
|
1210
|
+
bar: "bar",
|
|
1211
|
+
clear: "clear"
|
|
1212
|
+
};
|
|
1213
|
+
/** Resolve a logical tab alignment against the direction the paragraph runs in. */
|
|
1214
|
+
const resolveTabAlignment = (alignment, rightToLeft) => {
|
|
1215
|
+
const mapped = TAB_ALIGNMENT_BY_TAB_STOP_ALIGNMENT[alignment];
|
|
1216
|
+
switch (mapped) {
|
|
1217
|
+
case "logicalStart": return rightToLeft ? "end" : "start";
|
|
1218
|
+
case "logicalEnd": return rightToLeft ? "start" : "end";
|
|
1219
|
+
default: return mapped;
|
|
1051
1220
|
}
|
|
1052
|
-
}
|
|
1221
|
+
};
|
|
1053
1222
|
/**
|
|
1054
1223
|
* Convert a paragraph node to a ParagraphBlock.
|
|
1055
1224
|
*/
|
|
@@ -1071,6 +1240,8 @@ function convertParagraph(node, startPos, options, pageBreaks) {
|
|
|
1071
1240
|
listCounterStreams: options.listCounterStreams,
|
|
1072
1241
|
defaultTabStopTwips: options.defaultTabStopTwips
|
|
1073
1242
|
});
|
|
1243
|
+
if (options.defaultFont !== void 0) attrs.defaultFontFamily ??= options.defaultFont;
|
|
1244
|
+
if (options.defaultSize !== void 0) attrs.defaultFontSize ??= options.defaultSize;
|
|
1074
1245
|
if (options.lineBreakRules) attrs.lineBreakRules = options.lineBreakRules;
|
|
1075
1246
|
if (options.justificationCompatibility) attrs.justificationCompatibility = options.justificationCompatibility;
|
|
1076
1247
|
if (options.automaticHyphenation) attrs.automaticHyphenation = options.automaticHyphenation;
|
|
@@ -1275,7 +1446,7 @@ function suppressFinalParagraphInRepeatedEmptySuffix(blocks) {
|
|
|
1275
1446
|
}
|
|
1276
1447
|
function reserveLeadingEmptyOutlineHeight(blocks) {
|
|
1277
1448
|
const firstBlock = blocks.at(0);
|
|
1278
|
-
if (firstBlock?.kind !== "paragraph" || firstBlock.runs.length !== 0 || firstBlock.attrs?.outlineLevel !== 0) return;
|
|
1449
|
+
if (firstBlock?.kind !== "paragraph" || firstBlock.runs.length !== 0 || headingLevelOf(firstBlock.attrs?.outlineLevel) !== 0) return;
|
|
1279
1450
|
firstBlock.attrs = {
|
|
1280
1451
|
...firstBlock.attrs,
|
|
1281
1452
|
reserveEmptyOutlineHeight: true
|
|
@@ -1288,31 +1459,14 @@ function reserveLeadingEmptyOutlineHeight(blocks) {
|
|
|
1288
1459
|
function borderWidthToPixels(eighthsOfPoint) {
|
|
1289
1460
|
return pointsToPixels(eighthsOfPoint / 8);
|
|
1290
1461
|
}
|
|
1291
|
-
const OOXML_TO_CSS_BORDER = {
|
|
1292
|
-
single: "solid",
|
|
1293
|
-
double: "double",
|
|
1294
|
-
dotted: "dotted",
|
|
1295
|
-
dashed: "dashed",
|
|
1296
|
-
thick: "solid",
|
|
1297
|
-
dashSmallGap: "dashed",
|
|
1298
|
-
dotDash: "dashed",
|
|
1299
|
-
dotDotDash: "dotted",
|
|
1300
|
-
triple: "double",
|
|
1301
|
-
wave: "solid",
|
|
1302
|
-
doubleWave: "double",
|
|
1303
|
-
threeDEmboss: "ridge",
|
|
1304
|
-
threeDEngrave: "groove",
|
|
1305
|
-
outset: "outset",
|
|
1306
|
-
inset: "inset"
|
|
1307
|
-
};
|
|
1308
1462
|
/**
|
|
1309
1463
|
* Convert an OOXML BorderSpec to a layout-engine BorderStyle.
|
|
1310
1464
|
* Shared by paragraph borders, cell borders, and header/footer borders.
|
|
1311
1465
|
*/
|
|
1312
1466
|
function convertBorderSpecToLayout(border, theme) {
|
|
1313
|
-
if (
|
|
1467
|
+
if (border.style === void 0 || statesNoBorder(border.style)) return;
|
|
1314
1468
|
const result = {
|
|
1315
|
-
style:
|
|
1469
|
+
style: cssBorderStyle(border.style),
|
|
1316
1470
|
width: border.size === void 0 ? 1 : borderWidthToPixels(border.size),
|
|
1317
1471
|
color: border.color ? resolveColor(border.color, theme) : "#000000"
|
|
1318
1472
|
};
|
|
@@ -1357,8 +1511,7 @@ function convertTableCell(node, startPos, options, tableCellMargins) {
|
|
|
1357
1511
|
const blocks = [];
|
|
1358
1512
|
let offset = startPos + 1;
|
|
1359
1513
|
const authoredPageBreakPosition = options.firstPageBreakRunPosition(node);
|
|
1360
|
-
const leadingParagraph = node.firstChild?.type.name === "paragraph" ? node.firstChild : void 0;
|
|
1361
|
-
if (authoredPageBreakPosition !== void 0 && (leadingParagraph === void 0 || countPageBreakRuns(node) !== 1 || options.firstPageBreakRunPosition(leadingParagraph) !== authoredPageBreakPosition)) panic(`An explicit page-break run at ${String(authoredPageBreakPosition)} cannot be projected inside a table cell`);
|
|
1514
|
+
const leadingParagraph = node.firstChild?.type.name === "paragraph" && countPageBreakRuns(node) === 1 && options.firstPageBreakRunPosition(node.firstChild) === authoredPageBreakPosition ? node.firstChild : void 0;
|
|
1362
1515
|
const pageBreaks = [];
|
|
1363
1516
|
node.forEach((child) => {
|
|
1364
1517
|
if (child.type.name === "paragraph") {
|
|
@@ -1406,24 +1559,41 @@ function convertTableCell(node, startPos, options, tableCellMargins) {
|
|
|
1406
1559
|
if (attrs.noWrap) cell.noWrap = true;
|
|
1407
1560
|
if (authoredPageBreakPosition === void 0 || pageBreaks.length === 0) return { cell };
|
|
1408
1561
|
const paragraph = blocks.at(0);
|
|
1409
|
-
if (paragraph?.kind !== "paragraph" || !hasSingleLeadingProjectedPageBreak(paragraph.runs, pageBreaks))
|
|
1562
|
+
if (paragraph?.kind !== "paragraph" || !hasSingleLeadingProjectedPageBreak(paragraph.runs, pageBreaks)) return { cell };
|
|
1410
1563
|
return {
|
|
1411
1564
|
cell,
|
|
1412
1565
|
breakBefore: "page"
|
|
1413
1566
|
};
|
|
1414
1567
|
}
|
|
1415
1568
|
/**
|
|
1416
|
-
*
|
|
1569
|
+
* Resolve an `ST_JcTable` placement to the flow engine's logical alignment.
|
|
1570
|
+
*
|
|
1571
|
+
* `start` and `end` name an edge of the writing direction, not a side of the
|
|
1572
|
+
* page, the same distinction `ST_Jc` draws for a paragraph. The flow engine
|
|
1573
|
+
* applies `w:bidiVisual` when it resolves that logical alignment to a physical
|
|
1574
|
+
* side, so the bridge must not mirror it first.
|
|
1417
1575
|
*/
|
|
1418
|
-
|
|
1576
|
+
const resolveTablePlacement = (placement) => {
|
|
1577
|
+
switch (placement) {
|
|
1578
|
+
case "start": return "left";
|
|
1579
|
+
case "end": return "right";
|
|
1580
|
+
case "left":
|
|
1581
|
+
case "center":
|
|
1582
|
+
case "right": return placement;
|
|
1583
|
+
default: return placement;
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
function convertTableRow(node, startPos, options, { cellMargins }) {
|
|
1419
1587
|
const cells = [];
|
|
1420
1588
|
let offset = startPos + 1;
|
|
1421
1589
|
let breakBefore;
|
|
1422
1590
|
node.forEach((child) => {
|
|
1423
1591
|
if (child.type.name === "tableCell" || child.type.name === "tableHeader") {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1592
|
+
if (!expectTableCellAttrs(child)._omittedGridSlot) {
|
|
1593
|
+
const converted = convertTableCell(child, offset, options, cellMargins);
|
|
1594
|
+
if (converted.breakBefore !== void 0) breakBefore = converted.breakBefore;
|
|
1595
|
+
cells.push(converted.cell);
|
|
1596
|
+
}
|
|
1427
1597
|
}
|
|
1428
1598
|
offset += child.nodeSize;
|
|
1429
1599
|
});
|
|
@@ -1441,7 +1611,7 @@ function convertTableRow(node, startPos, options, tableCellMargins) {
|
|
|
1441
1611
|
if (breakBefore !== void 0) row.breakBefore = breakBefore;
|
|
1442
1612
|
if (attrs.hidden) row.hidden = attrs.hidden;
|
|
1443
1613
|
const effectiveJustification = attrs._originalFormatting?.justification ?? attrs._resolvedJustification;
|
|
1444
|
-
if (effectiveJustification) row.justification = effectiveJustification;
|
|
1614
|
+
if (effectiveJustification) row.justification = resolveTablePlacement(effectiveJustification);
|
|
1445
1615
|
return row;
|
|
1446
1616
|
}
|
|
1447
1617
|
/**
|
|
@@ -1451,9 +1621,10 @@ function convertTable(node, startPos, options) {
|
|
|
1451
1621
|
const rows = [];
|
|
1452
1622
|
let offset = startPos + 1;
|
|
1453
1623
|
const attrs = expectTableAttrs(node);
|
|
1454
|
-
const
|
|
1624
|
+
const rightToLeft = (attrs._resolvedBidi ?? attrs._originalFormatting?.bidi) === true;
|
|
1625
|
+
const rowContext = { ...attrs.cellMargins === void 0 ? {} : { cellMargins: attrs.cellMargins } };
|
|
1455
1626
|
node.forEach((child) => {
|
|
1456
|
-
if (child.type.name === "tableRow") rows.push(convertTableRow(child, offset, options,
|
|
1627
|
+
if (child.type.name === "tableRow") rows.push(convertTableRow(child, offset, options, rowContext));
|
|
1457
1628
|
offset += child.nodeSize;
|
|
1458
1629
|
});
|
|
1459
1630
|
let columnWidths = attrs.columnWidths?.map(twipsToPixels);
|
|
@@ -1463,7 +1634,8 @@ function convertTable(node, startPos, options) {
|
|
|
1463
1634
|
const cellWidths = rows[0].cells.map((cell) => cell.width);
|
|
1464
1635
|
if (cellWidths.every((w) => w !== void 0 && w > 0)) columnWidths = cellWidths;
|
|
1465
1636
|
}
|
|
1466
|
-
const
|
|
1637
|
+
const authoredJustification = attrs.justification ?? attrs._resolvedJustification;
|
|
1638
|
+
const justification = authoredJustification === void 0 ? void 0 : resolveTablePlacement(authoredJustification);
|
|
1467
1639
|
const originalFormatting = attrs._originalFormatting;
|
|
1468
1640
|
const effectiveIndent = attrs._resolvedIndent ?? originalFormatting?.indent;
|
|
1469
1641
|
const indentPx = effectiveIndent?.value !== void 0 && effectiveIndent?.type === "dxa" ? twipsToPixels(effectiveIndent.value) : void 0;
|
|
@@ -1499,7 +1671,7 @@ function convertTable(node, startPos, options) {
|
|
|
1499
1671
|
if (indentPx !== void 0) tableBlock.indent = indentPx;
|
|
1500
1672
|
if (options.tableIndentCompatibility && !dropsAuthoredIndent) tableBlock.indentCompatibility = options.tableIndentCompatibility;
|
|
1501
1673
|
if (floatingPx) tableBlock.floating = floatingPx;
|
|
1502
|
-
if (
|
|
1674
|
+
if (rightToLeft) tableBlock.bidi = true;
|
|
1503
1675
|
return tableBlock;
|
|
1504
1676
|
}
|
|
1505
1677
|
/**
|
|
@@ -1507,7 +1679,7 @@ function convertTable(node, startPos, options) {
|
|
|
1507
1679
|
*/
|
|
1508
1680
|
function convertImage(node, startPos, pageContentHeight) {
|
|
1509
1681
|
const attrs = expectImageAttrs(node);
|
|
1510
|
-
if (!hasPaintableImageSource(attrs
|
|
1682
|
+
if (!hasPaintableImageSource(attrs) && !hasRelationshipBackedImageBox(attrs)) return;
|
|
1511
1683
|
const wrapType = attrs.wrapType;
|
|
1512
1684
|
const shouldAnchor = wrapType === "behind" || wrapType === "inFront";
|
|
1513
1685
|
const constrained = constrainImageToPage(attrs.width ?? 100, attrs.height ?? 100, pageContentHeight);
|
|
@@ -1515,6 +1687,7 @@ function convertImage(node, startPos, pageContentHeight) {
|
|
|
1515
1687
|
kind: "image",
|
|
1516
1688
|
id: nextBlockId(),
|
|
1517
1689
|
src: attrs.src,
|
|
1690
|
+
...attrs.preview ? { preview: attrs.preview } : {},
|
|
1518
1691
|
width: constrained.width,
|
|
1519
1692
|
height: constrained.height,
|
|
1520
1693
|
pmStart: startPos,
|
|
@@ -1523,6 +1696,8 @@ function convertImage(node, startPos, pageContentHeight) {
|
|
|
1523
1696
|
if (attrs.alt) imgBlock.alt = attrs.alt;
|
|
1524
1697
|
if (attrs.transform) imgBlock.transform = attrs.transform;
|
|
1525
1698
|
if (attrs.opacity != null) imgBlock.opacity = attrs.opacity;
|
|
1699
|
+
if (attrs.brightness != null) imgBlock.brightness = attrs.brightness;
|
|
1700
|
+
if (attrs.contrast != null) imgBlock.contrast = attrs.contrast;
|
|
1526
1701
|
if (shouldAnchor) {
|
|
1527
1702
|
const anchor = {
|
|
1528
1703
|
isAnchored: true,
|
|
@@ -1539,13 +1714,12 @@ function convertImage(node, startPos, pageContentHeight) {
|
|
|
1539
1714
|
if (attrs.cropLeft != null) imgBlock.cropLeft = attrs.cropLeft;
|
|
1540
1715
|
if (attrs.borderWidth != null) imgBlock.borderWidth = attrs.borderWidth;
|
|
1541
1716
|
if (attrs.borderColor) imgBlock.borderColor = attrs.borderColor;
|
|
1542
|
-
|
|
1717
|
+
const imageBorderStyle = cssBorderStyleOf(attrs.borderStyle);
|
|
1718
|
+
if (imageBorderStyle) imgBlock.borderStyle = imageBorderStyle;
|
|
1543
1719
|
return imgBlock;
|
|
1544
1720
|
}
|
|
1545
1721
|
/** Convert a textBox PM node to a TextBoxBlock. */
|
|
1546
1722
|
function convertTextBoxNode(node, startPos, opts) {
|
|
1547
|
-
const pageBreakPosition = opts.firstPageBreakRunPosition(node);
|
|
1548
|
-
if (pageBreakPosition !== void 0) panic(`An explicit page-break run at ${String(pageBreakPosition)} cannot be projected inside a text box`);
|
|
1549
1723
|
const attrs = expectTextBoxAttrs(node);
|
|
1550
1724
|
const contentBlocks = [];
|
|
1551
1725
|
node.forEach((child, offset) => {
|
|
@@ -1650,15 +1824,13 @@ function coalesceTrailingPageBreakBeforeContinuousSection(blocks, splitPageBreak
|
|
|
1650
1824
|
}
|
|
1651
1825
|
return result;
|
|
1652
1826
|
}
|
|
1827
|
+
/**
|
|
1828
|
+
* The last section's start mode, off a document attribute the schema types as
|
|
1829
|
+
* `any`. `parseSectionBreakType` owns the enumeration, so a member added to
|
|
1830
|
+
* `ST_SectionMark` reaches the paginator instead of being dropped here.
|
|
1831
|
+
*/
|
|
1653
1832
|
function readFinalSectionStart(doc) {
|
|
1654
|
-
|
|
1655
|
-
switch (sectionStart) {
|
|
1656
|
-
case "continuous":
|
|
1657
|
-
case "nextPage":
|
|
1658
|
-
case "oddPage":
|
|
1659
|
-
case "evenPage": return sectionStart;
|
|
1660
|
-
default: return;
|
|
1661
|
-
}
|
|
1833
|
+
return parseSectionBreakType(doc.attrs["_finalSectionStart"]) ?? void 0;
|
|
1662
1834
|
}
|
|
1663
1835
|
/**
|
|
1664
1836
|
* Convert a ProseMirror document to FlowBlock array.
|
|
@@ -1700,8 +1872,6 @@ function toFlowBlocks(doc, options = {}) {
|
|
|
1700
1872
|
const { firstPageBreakRunPosition } = buildPageBreakRunDescendantIndex(doc);
|
|
1701
1873
|
const opts = {
|
|
1702
1874
|
...options,
|
|
1703
|
-
defaultFont: options.defaultFont ?? DEFAULT_FONT,
|
|
1704
|
-
defaultSize: options.defaultSize ?? DEFAULT_SIZE,
|
|
1705
1875
|
listCounters: listCounterState.counters,
|
|
1706
1876
|
listAbstractCounters: listCounterState.abstractCounters,
|
|
1707
1877
|
listSeenNumIds: listCounterState.seenLevels,
|
|
@@ -1746,10 +1916,6 @@ function toFlowBlocks(doc, options = {}) {
|
|
|
1746
1916
|
const pushParagraphProjection = (node, pos, stripLeadingLineBreak = false) => {
|
|
1747
1917
|
const pageBreaks = [];
|
|
1748
1918
|
const paragraph = convertParagraph(node, pos, opts, pageBreaks);
|
|
1749
|
-
if (pageBreaks.length > 0) {
|
|
1750
|
-
const disposition = pageBreakRunParagraphProjectionDisposition(node);
|
|
1751
|
-
if (disposition.status === "unsupported" && (disposition.reason === "textBoxAnchor" || !hasSingleLeadingProjectedPageBreak(paragraph.runs, pageBreaks))) panic(disposition.message);
|
|
1752
|
-
}
|
|
1753
1919
|
if (stripLeadingLineBreak && paragraph.runs.at(0)?.kind === "lineBreak") paragraph.runs.shift();
|
|
1754
1920
|
for (const block of splitParagraphAtPageBreaks({
|
|
1755
1921
|
pageBreaks,
|
|
@@ -1765,7 +1931,7 @@ function toFlowBlocks(doc, options = {}) {
|
|
|
1765
1931
|
const child = parent.child(index);
|
|
1766
1932
|
const next = index + 1 < parent.childCount ? parent.child(index + 1) : void 0;
|
|
1767
1933
|
const paragraphAttrs = child.type.name === "paragraph" ? expectParagraphAttrs(child) : void 0;
|
|
1768
|
-
if (paragraphAttrs && next?.type.name === "pageBreak" && paragraphAttrs._trailingPageBreak === true &&
|
|
1934
|
+
if (paragraphAttrs && next?.type.name === "pageBreak" && paragraphAttrs._trailingPageBreak === true && paragraphAttrs._sectionProperties !== void 0) {
|
|
1769
1935
|
trailingPageBreakSectionPositions.add(childStart);
|
|
1770
1936
|
consumedPageBreakPositions.add(childStart + child.nodeSize);
|
|
1771
1937
|
}
|
|
@@ -1834,7 +2000,7 @@ function toFlowBlocks(doc, options = {}) {
|
|
|
1834
2000
|
case "paragraph": {
|
|
1835
2001
|
const pmAttrs = expectParagraphAttrs(node);
|
|
1836
2002
|
const secProps = pmAttrs._sectionProperties;
|
|
1837
|
-
const hasSectionBreak = secProps !== void 0
|
|
2003
|
+
const hasSectionBreak = secProps !== void 0;
|
|
1838
2004
|
const hasListFormatting = pmAttrs.numPr !== null && pmAttrs.numPr !== void 0 || pmAttrs.listMarker !== null && pmAttrs.listMarker !== void 0;
|
|
1839
2005
|
const firstChild = node.firstChild;
|
|
1840
2006
|
const startsWithColumnBreak = firstChild?.type.name === "hardBreak" && expectHardBreakAttrs(firstChild).breakType === "column";
|
|
@@ -1897,7 +2063,7 @@ function toFlowBlocks(doc, options = {}) {
|
|
|
1897
2063
|
kind: "sectionBreak",
|
|
1898
2064
|
id: nextBlockId()
|
|
1899
2065
|
};
|
|
1900
|
-
const breakType = secProps?.sectionStart
|
|
2066
|
+
const breakType = secProps?.sectionStart;
|
|
1901
2067
|
if (breakType) sectionBreak.type = breakType;
|
|
1902
2068
|
if (secProps) {
|
|
1903
2069
|
sectionBreak.pageNumbering = getPageNumbering(secProps);
|
|
@@ -2068,4 +2234,4 @@ function mergeRunInParagraphs(blocks) {
|
|
|
2068
2234
|
return out;
|
|
2069
2235
|
}
|
|
2070
2236
|
//#endregion
|
|
2071
|
-
export { convertBorderSpecToLayout, formatCounter, resetBlockIdCounter, resolveListTemplate, toFlowBlocks };
|
|
2237
|
+
export { WORD_UNSPECIFIED_FONT_SIZE, convertBorderSpecToLayout, formatCounter, resetBlockIdCounter, resolveListTemplate, toFlowBlocks };
|