@stll/folio-core 0.46.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 +26 -24
- package/dist/ai-edits/headless.js +1 -1
- 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/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/section-boundary-properties.js +1 -2
- package/dist/content-controls/checkboxDisplay.d.ts +8 -2
- package/dist/content-controls/checkboxDisplay.js +11 -5
- package/dist/content-controls/mutateContentControls.js +41 -42
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +7 -7
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -20
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +93 -13
- 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 +1 -19
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +34 -1
- package/dist/docx/attributeRemainder.js +49 -3
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +39 -67
- package/dist/docx/blockPlainText.js +3 -1
- 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.js +1 -1
- package/dist/docx/commentParser.js +3 -3
- package/dist/docx/commentRangeIntegrity.js +1 -1
- package/dist/docx/commentRangeJoin.js +1 -1
- package/dist/docx/commentReferenceNormalization.js +3 -2
- package/dist/docx/commentReplyMarkers.js +1 -1
- package/dist/docx/compatibility.js +56 -42
- package/dist/docx/containerChildren.d.ts +110 -13
- package/dist/docx/containerChildren.gen.d.ts +16 -1
- package/dist/docx/containerChildren.gen.js +18 -1
- package/dist/docx/containerChildren.js +63 -13
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.js +4 -1
- 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/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterReferenceNormalization.js +1 -1
- package/dist/docx/hyperlinkParser.d.ts +45 -7
- package/dist/docx/hyperlinkParser.js +126 -57
- package/dist/docx/imageParser.js +127 -107
- 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 +84 -3
- package/dist/docx/inlineWrapperContent.js +85 -4
- 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 +4 -2
- 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 +91 -1
- package/dist/docx/paraIdAttribute.js +79 -1
- package/dist/docx/paragraphParser.d.ts +9 -24
- package/dist/docx/paragraphParser.js +212 -396
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +2 -0
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +14 -7
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +47 -49
- package/dist/docx/parseWarningMessage.js +3 -0
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.js +16 -6
- 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 +2 -2
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +78 -9
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +54 -18
- package/dist/docx/runParser.js +379 -295
- 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 +236 -240
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +21 -2
- package/dist/docx/selectiveXmlPatch.js +195 -99
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +10 -8
- package/dist/docx/serializer/documentSerializer.js +3 -0
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +3 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +3 -0
- 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 +88 -188
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +109 -59
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +34 -45
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +268 -100
- 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 +18 -16
- package/dist/docx/server/migrateYjsAttrSchema.js +3 -3
- 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 +8 -3
- 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 +10 -1
- package/dist/docx/tableParser.js +505 -181
- package/dist/docx/textBoxParser.d.ts +3 -1
- package/dist/docx/textBoxParser.js +18 -8
- 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/vmlImageParser.d.ts +13 -4
- package/dist/docx/vmlImageParser.js +74 -31
- 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/xmlParser.d.ts +14 -1
- package/dist/docx/xmlParser.js +18 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +2 -0
- 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/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +3 -1
- 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 +177 -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/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 +47 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderPage.js +6 -4
- package/dist/layout-painter/renderParagraph.d.ts +2 -1
- package/dist/layout-painter/renderParagraph.js +13 -26
- 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/markdown/renderBlock.js +3 -1
- package/dist/markdown/renderRuns.js +7 -2
- package/dist/markdown/renderTable.js +2 -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/prosemirror/attrs/index.d.ts +22 -4
- package/dist/prosemirror/attrs/index.js +498 -60
- 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 +24 -19
- package/dist/prosemirror/commands/image.d.ts +1 -1
- package/dist/prosemirror/commands/image.js +4 -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/conversion/fromProseDoc.d.ts +18 -2
- package/dist/prosemirror/conversion/fromProseDoc.js +330 -183
- 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.js +371 -141
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +8 -2
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +19 -15
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- 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 +26 -2
- package/dist/prosemirror/extensions/markRegistry.js +73 -10
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +17 -3
- 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.js +2 -1
- 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.js +10 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +8 -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/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 +4 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +141 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -0
- 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.js +20 -3
- 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/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 +1 -1
- package/dist/prosemirror/replacedAnnotations.js +24 -6
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -0
- package/dist/prosemirror/runFormattingInlineCarriers.js +2 -0
- 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 +2 -2
- package/dist/prosemirror/schema/marks.d.ts +23 -4
- package/dist/prosemirror/schema/nodes.d.ts +220 -24
- 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 +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +17 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +2 -2
- package/dist/prosemirror/yjsDocumentMetadata.js +428 -7
- package/dist/prosemirror/zeroWidthAnchors.js +4 -0
- 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/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/mergeDocumentContent.js +5 -3
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -1
- 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/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -52
- 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
|
@@ -36,6 +36,88 @@ declare function borderToStyle(border: document_d_exports.BorderSpec | undefined
|
|
|
36
36
|
* @returns CSS color string or empty string
|
|
37
37
|
*/
|
|
38
38
|
declare function resolveShadingFill(shading: document_d_exports.ShadingProperties | undefined | null, theme?: document_d_exports.Theme | null): string;
|
|
39
|
+
/** The CSS `text-decoration-style` keywords folio paints an underline with. */
|
|
40
|
+
type CssTextDecorationStyle = "solid" | "double" | "dotted" | "dashed" | "wavy";
|
|
41
|
+
/**
|
|
42
|
+
* What an authored underline paints as, in CSS.
|
|
43
|
+
*
|
|
44
|
+
* `decorationStyle` is absent for the member that paints no line at all; the
|
|
45
|
+
* caller decides whether that means "omit the decoration" or "inherit".
|
|
46
|
+
* `decorationThickness` is absent wherever the font's own underline weight is
|
|
47
|
+
* what Word draws.
|
|
48
|
+
*/
|
|
49
|
+
type UnderlineDecorationCss = {
|
|
50
|
+
readonly decorationStyle?: CssTextDecorationStyle;
|
|
51
|
+
readonly decorationThickness?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The underline every DOM backend draws when the author named no member.
|
|
55
|
+
*
|
|
56
|
+
* It is also what an underline CSS cannot spell parses back as; see
|
|
57
|
+
* `underlineStyleFromCssDecoration`.
|
|
58
|
+
*/
|
|
59
|
+
declare const PLAIN_UNDERLINE = "single";
|
|
60
|
+
/**
|
|
61
|
+
* Every `ST_Underline` member's CSS line. The one table: the ProseMirror mark's
|
|
62
|
+
* `toDOM`, the DOM painter and `textToStyle` all render a run from this, so a
|
|
63
|
+
* member cannot paint one line in the editor and another on the page.
|
|
64
|
+
*
|
|
65
|
+
* `none` cancels an underline inherited from the style chain rather than
|
|
66
|
+
* naming a line style, and `text-decoration-style: none` is not a CSS keyword,
|
|
67
|
+
* so that member names no keyword and carries no declarations at all.
|
|
68
|
+
*
|
|
69
|
+
* Where CSS has no keyword for what Word draws, the member is approximated and
|
|
70
|
+
* the approximation is stated here rather than at a call site: `words`
|
|
71
|
+
* underlines the spaces between words too (`text-decoration-skip-ink` skips
|
|
72
|
+
* descender ink, not spaces, and `text-decoration-skip: spaces` never
|
|
73
|
+
* shipped); `wavyDouble` draws two straight lines rather than two wavy ones;
|
|
74
|
+
* `dashLong`, `dotDash` and `dotDotDash` draw the single dash pattern CSS has.
|
|
75
|
+
* The `*Heavy` members and `thick` differ from their plain counterparts in
|
|
76
|
+
* weight only, which the thickness carries, so the line they name is their
|
|
77
|
+
* plain counterpart's.
|
|
78
|
+
*/
|
|
79
|
+
declare const UNDERLINE_DECORATION_STYLES: {
|
|
80
|
+
readonly none: undefined;
|
|
81
|
+
readonly single: "solid";
|
|
82
|
+
readonly words: "solid";
|
|
83
|
+
readonly double: "double";
|
|
84
|
+
readonly thick: "solid";
|
|
85
|
+
readonly dotted: "dotted";
|
|
86
|
+
readonly dottedHeavy: "dotted";
|
|
87
|
+
readonly dash: "dashed";
|
|
88
|
+
readonly dashedHeavy: "dashed";
|
|
89
|
+
readonly dashLong: "dashed";
|
|
90
|
+
readonly dashLongHeavy: "dashed";
|
|
91
|
+
readonly dotDash: "dashed";
|
|
92
|
+
readonly dashDotHeavy: "dashed";
|
|
93
|
+
readonly dotDotDash: "dashed";
|
|
94
|
+
readonly dashDotDotHeavy: "dashed";
|
|
95
|
+
readonly wave: "wavy";
|
|
96
|
+
readonly wavyHeavy: "wavy";
|
|
97
|
+
readonly wavyDouble: "double";
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The CSS an authored underline paints with.
|
|
101
|
+
*
|
|
102
|
+
* CSS has no heavy keyword, so a weight is stated as a length: the plain ratio
|
|
103
|
+
* the display list strokes with, times the weight the member's own row carries
|
|
104
|
+
* (`display-list/build/strokes.ts`). Both backends therefore scale the same way
|
|
105
|
+
* with the font size, and which members are heavy is read off the row rather
|
|
106
|
+
* than listed again here, so the page and the editor cannot disagree about it.
|
|
107
|
+
*/
|
|
108
|
+
declare const underlineDecorationCss: (style: document_d_exports.UnderlineStyle) => UnderlineDecorationCss;
|
|
109
|
+
/**
|
|
110
|
+
* The `ST_Underline` member an authored `text-decoration` or
|
|
111
|
+
* `text-decoration-style` value parses back as.
|
|
112
|
+
*
|
|
113
|
+
* The table is many-to-one, so the inverse cannot be: several members share
|
|
114
|
+
* every keyword. It resolves each keyword to that keyword's canonical author,
|
|
115
|
+
* the plain member whose own CSS is exactly the keyword, so a member folio
|
|
116
|
+
* cannot spell in CSS comes back as the sibling it is drawn as: `dottedHeavy`
|
|
117
|
+
* as `dotted`, `words` and `thick` as `single`, `wavyDouble` as `double`. A
|
|
118
|
+
* value naming no keyword folio writes parses as the plain underline.
|
|
119
|
+
*/
|
|
120
|
+
declare const underlineStyleFromCssDecoration: (value: string) => document_d_exports.UnderlineStyle;
|
|
39
121
|
/**
|
|
40
122
|
* Merge multiple CSSProperties objects
|
|
41
123
|
*
|
|
@@ -54,7 +136,7 @@ declare function mergeStyles(...styles: (CSSProperties | undefined | null)[]): C
|
|
|
54
136
|
*/
|
|
55
137
|
declare function tableCellToStyle(formatting: {
|
|
56
138
|
verticalAlign?: "top" | "center" | "bottom";
|
|
57
|
-
textDirection?:
|
|
139
|
+
textDirection?: document_d_exports.TextDirection;
|
|
58
140
|
shading?: document_d_exports.ShadingProperties;
|
|
59
141
|
borders?: {
|
|
60
142
|
top?: document_d_exports.BorderSpec;
|
|
@@ -99,4 +181,4 @@ declare function sectionToStyle(sectionProps: {
|
|
|
99
181
|
};
|
|
100
182
|
} | undefined | null, theme?: document_d_exports.Theme | null): CSSProperties;
|
|
101
183
|
//#endregion
|
|
102
|
-
export { borderToStyle, mergeStyles, paragraphToStyle, resolveShadingFill, sectionToStyle, tableCellToStyle, textToStyle };
|
|
184
|
+
export { CssTextDecorationStyle, PLAIN_UNDERLINE, UNDERLINE_DECORATION_STYLES, UnderlineDecorationCss, borderToStyle, mergeStyles, paragraphToStyle, resolveShadingFill, sectionToStyle, tableCellToStyle, textToStyle, underlineDecorationCss, underlineStyleFromCssDecoration };
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { UNDERLINE_STROKES } from "../display-list/build/strokes.js";
|
|
2
|
+
import { UNDERLINE_THICKNESS_RATIO } from "../display-list/build/textDecorations.js";
|
|
3
|
+
import { UNDERLINE_STYLE_VALUES } from "../types/documentEnumValues.js";
|
|
4
|
+
import { cssBorderStyle } from "./borderCss.js";
|
|
1
5
|
import { resolveColor, resolveHighlightToCss, resolveShadingColor } from "./colorResolver.js";
|
|
2
6
|
import { resolveFontFamily, resolveThemeFont } from "./fontResolver.js";
|
|
3
7
|
import { getHorizontalScaleFactor, normalizeHorizontalScalePercent } from "./horizontalScale.js";
|
|
8
|
+
import { textFlowCss } from "./textDirectionFlow.js";
|
|
4
9
|
import { AUTO_PARAGRAPH_SPACING_PX, eighthsToPixels, formatPx, halfPointsToPixels, halfPointsToPoints, twipsToPixels } from "./units.js";
|
|
10
|
+
import { statesNoBorder } from "@stll/docx-core/model";
|
|
5
11
|
//#region src/utils/formatToStyle.ts
|
|
6
12
|
/**
|
|
7
13
|
* Convert TextFormatting to CSS properties for a run/span
|
|
@@ -31,10 +37,12 @@ function textToStyle(formatting, theme) {
|
|
|
31
37
|
const decorations = [];
|
|
32
38
|
const decorationStyles = [];
|
|
33
39
|
const decorationColors = [];
|
|
40
|
+
let decorationThickness;
|
|
34
41
|
if (formatting.underline && formatting.underline.style !== "none") {
|
|
35
42
|
decorations.push("underline");
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
43
|
+
const underline = underlineDecorationCss(formatting.underline.style);
|
|
44
|
+
if (underline.decorationStyle !== void 0 && underline.decorationStyle !== "solid") decorationStyles.push(underline.decorationStyle);
|
|
45
|
+
decorationThickness = underline.decorationThickness;
|
|
38
46
|
if (formatting.underline.color) decorationColors.push(resolveColor(formatting.underline.color, theme));
|
|
39
47
|
}
|
|
40
48
|
if (formatting.strike) decorations.push("line-through");
|
|
@@ -43,6 +51,7 @@ function textToStyle(formatting, theme) {
|
|
|
43
51
|
style.textDecoration = decorations.join(" ");
|
|
44
52
|
if (decorationStyles.length > 0) style.textDecorationStyle = decorationStyles[0];
|
|
45
53
|
if (decorationColors.length > 0) style.textDecorationColor = decorationColors[0];
|
|
54
|
+
if (decorationThickness !== void 0) style.textDecorationThickness = decorationThickness;
|
|
46
55
|
}
|
|
47
56
|
if (formatting.vertAlign) switch (formatting.vertAlign) {
|
|
48
57
|
case "superscript":
|
|
@@ -90,7 +99,7 @@ function textToStyle(formatting, theme) {
|
|
|
90
99
|
function paragraphToStyle(formatting, theme) {
|
|
91
100
|
if (!formatting) return {};
|
|
92
101
|
const style = {};
|
|
93
|
-
if (formatting.alignment) style.textAlign =
|
|
102
|
+
if (formatting.alignment) style.textAlign = CSS_TEXT_ALIGN_BY_PARAGRAPH_ALIGNMENT[formatting.alignment];
|
|
94
103
|
if (formatting.beforeAutospacing) style.marginTop = formatPx(AUTO_PARAGRAPH_SPACING_PX);
|
|
95
104
|
else if (formatting.spaceBefore !== void 0) style.marginTop = formatPx(twipsToPixels(formatting.spaceBefore));
|
|
96
105
|
if (formatting.afterAutospacing) style.marginBottom = formatPx(AUTO_PARAGRAPH_SPACING_PX);
|
|
@@ -136,11 +145,11 @@ function paragraphToStyle(formatting, theme) {
|
|
|
136
145
|
* @returns Partial CSSProperties with border styles
|
|
137
146
|
*/
|
|
138
147
|
function borderToStyle(border, side = "", theme) {
|
|
139
|
-
if (!border || border.style
|
|
148
|
+
if (!border || statesNoBorder(border.style)) return {};
|
|
140
149
|
const style = {};
|
|
141
150
|
const widthPx = border.size !== void 0 && border.size !== 0 ? eighthsToPixels(border.size) : 1;
|
|
142
151
|
const color = border.color ? resolveColor(border.color, theme) : "#000000";
|
|
143
|
-
const cssStyle =
|
|
152
|
+
const cssStyle = cssBorderStyle(border.style);
|
|
144
153
|
const widthKey = `border${side}Width`;
|
|
145
154
|
const styleKey = `border${side}Style`;
|
|
146
155
|
const colorKey = `border${side}Color`;
|
|
@@ -211,58 +220,126 @@ function resolveShadingFill(shading, theme) {
|
|
|
211
220
|
return "";
|
|
212
221
|
}
|
|
213
222
|
/**
|
|
214
|
-
*
|
|
223
|
+
* The underline every DOM backend draws when the author named no member.
|
|
224
|
+
*
|
|
225
|
+
* It is also what an underline CSS cannot spell parses back as; see
|
|
226
|
+
* `underlineStyleFromCssDecoration`.
|
|
215
227
|
*/
|
|
216
|
-
|
|
217
|
-
switch (underlineStyle) {
|
|
218
|
-
case "double": return "double";
|
|
219
|
-
case "dotted":
|
|
220
|
-
case "dottedHeavy": return "dotted";
|
|
221
|
-
case "dash":
|
|
222
|
-
case "dashedHeavy":
|
|
223
|
-
case "dashLong":
|
|
224
|
-
case "dashLongHeavy":
|
|
225
|
-
case "dotDash":
|
|
226
|
-
case "dashDotHeavy":
|
|
227
|
-
case "dotDotDash":
|
|
228
|
-
case "dashDotDotHeavy": return "dashed";
|
|
229
|
-
case "wave":
|
|
230
|
-
case "wavyHeavy":
|
|
231
|
-
case "wavyDouble": return "wavy";
|
|
232
|
-
default: return "solid";
|
|
233
|
-
}
|
|
234
|
-
}
|
|
228
|
+
const PLAIN_UNDERLINE = "single";
|
|
235
229
|
/**
|
|
236
|
-
*
|
|
230
|
+
* Every `ST_Underline` member's CSS line. The one table: the ProseMirror mark's
|
|
231
|
+
* `toDOM`, the DOM painter and `textToStyle` all render a run from this, so a
|
|
232
|
+
* member cannot paint one line in the editor and another on the page.
|
|
233
|
+
*
|
|
234
|
+
* `none` cancels an underline inherited from the style chain rather than
|
|
235
|
+
* naming a line style, and `text-decoration-style: none` is not a CSS keyword,
|
|
236
|
+
* so that member names no keyword and carries no declarations at all.
|
|
237
|
+
*
|
|
238
|
+
* Where CSS has no keyword for what Word draws, the member is approximated and
|
|
239
|
+
* the approximation is stated here rather than at a call site: `words`
|
|
240
|
+
* underlines the spaces between words too (`text-decoration-skip-ink` skips
|
|
241
|
+
* descender ink, not spaces, and `text-decoration-skip: spaces` never
|
|
242
|
+
* shipped); `wavyDouble` draws two straight lines rather than two wavy ones;
|
|
243
|
+
* `dashLong`, `dotDash` and `dotDotDash` draw the single dash pattern CSS has.
|
|
244
|
+
* The `*Heavy` members and `thick` differ from their plain counterparts in
|
|
245
|
+
* weight only, which the thickness carries, so the line they name is their
|
|
246
|
+
* plain counterpart's.
|
|
237
247
|
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
248
|
+
const UNDERLINE_DECORATION_STYLES = {
|
|
249
|
+
none: void 0,
|
|
250
|
+
single: "solid",
|
|
251
|
+
words: "solid",
|
|
252
|
+
double: "double",
|
|
253
|
+
thick: "solid",
|
|
254
|
+
dotted: "dotted",
|
|
255
|
+
dottedHeavy: "dotted",
|
|
256
|
+
dash: "dashed",
|
|
257
|
+
dashedHeavy: "dashed",
|
|
258
|
+
dashLong: "dashed",
|
|
259
|
+
dashLongHeavy: "dashed",
|
|
260
|
+
dotDash: "dashed",
|
|
261
|
+
dashDotHeavy: "dashed",
|
|
262
|
+
dotDotDash: "dashed",
|
|
263
|
+
dashDotDotHeavy: "dashed",
|
|
264
|
+
wave: "wavy",
|
|
265
|
+
wavyHeavy: "wavy",
|
|
266
|
+
wavyDouble: "double"
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* The CSS an authored underline paints with.
|
|
270
|
+
*
|
|
271
|
+
* CSS has no heavy keyword, so a weight is stated as a length: the plain ratio
|
|
272
|
+
* the display list strokes with, times the weight the member's own row carries
|
|
273
|
+
* (`display-list/build/strokes.ts`). Both backends therefore scale the same way
|
|
274
|
+
* with the font size, and which members are heavy is read off the row rather
|
|
275
|
+
* than listed again here, so the page and the editor cannot disagree about it.
|
|
276
|
+
*/
|
|
277
|
+
const underlineDecorationCss = (style) => {
|
|
278
|
+
const decorationStyle = UNDERLINE_DECORATION_STYLES[style];
|
|
279
|
+
if (decorationStyle === void 0) return {};
|
|
280
|
+
const { weight } = UNDERLINE_STROKES[style];
|
|
281
|
+
if (weight === 1) return { decorationStyle };
|
|
282
|
+
return {
|
|
283
|
+
decorationStyle,
|
|
284
|
+
decorationThickness: `${(UNDERLINE_THICKNESS_RATIO * weight).toFixed(4)}em`
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Each CSS keyword's canonical author, derived from the one table: the first
|
|
289
|
+
* member in enumeration order that paints exactly that keyword at the font's
|
|
290
|
+
* own weight.
|
|
291
|
+
*/
|
|
292
|
+
const CANONICAL_UNDERLINE_STYLE_BY_CSS = (() => {
|
|
293
|
+
const canonical = /* @__PURE__ */ new Map();
|
|
294
|
+
for (const style of UNDERLINE_STYLE_VALUES) {
|
|
295
|
+
const { decorationStyle, decorationThickness } = underlineDecorationCss(style);
|
|
296
|
+
if (decorationStyle === void 0 || decorationThickness !== void 0) continue;
|
|
297
|
+
if (!canonical.has(decorationStyle)) canonical.set(decorationStyle, style);
|
|
245
298
|
}
|
|
246
|
-
|
|
299
|
+
return canonical;
|
|
300
|
+
})();
|
|
247
301
|
/**
|
|
248
|
-
*
|
|
302
|
+
* The `ST_Underline` member an authored `text-decoration` or
|
|
303
|
+
* `text-decoration-style` value parses back as.
|
|
304
|
+
*
|
|
305
|
+
* The table is many-to-one, so the inverse cannot be: several members share
|
|
306
|
+
* every keyword. It resolves each keyword to that keyword's canonical author,
|
|
307
|
+
* the plain member whose own CSS is exactly the keyword, so a member folio
|
|
308
|
+
* cannot spell in CSS comes back as the sibling it is drawn as: `dottedHeavy`
|
|
309
|
+
* as `dotted`, `words` and `thick` as `single`, `wavyDouble` as `double`. A
|
|
310
|
+
* value naming no keyword folio writes parses as the plain underline.
|
|
249
311
|
*/
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
case "double":
|
|
255
|
-
case "triple": return "double";
|
|
256
|
-
case "dotted": return "dotted";
|
|
257
|
-
case "dashed":
|
|
258
|
-
case "dashSmallGap": return "dashed";
|
|
259
|
-
case "threeDEmboss": return "ridge";
|
|
260
|
-
case "threeDEngrave": return "groove";
|
|
261
|
-
case "outset": return "outset";
|
|
262
|
-
case "inset": return "inset";
|
|
263
|
-
default: return "solid";
|
|
312
|
+
const underlineStyleFromCssDecoration = (value) => {
|
|
313
|
+
for (const token of value.toLowerCase().split(/[\s,]+/u)) {
|
|
314
|
+
const style = CANONICAL_UNDERLINE_STYLE_BY_CSS.get(token);
|
|
315
|
+
if (style !== void 0) return style;
|
|
264
316
|
}
|
|
265
|
-
|
|
317
|
+
return PLAIN_UNDERLINE;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Every `ST_Jc` member, and the CSS `text-align` that renders it.
|
|
321
|
+
*
|
|
322
|
+
* `start` and `end` carry straight over: CSS spells the direction-aware edges
|
|
323
|
+
* the same way and resolves them against the element's direction, as Word
|
|
324
|
+
* does. The Kashida justifications and `distribute` all render as `justify`,
|
|
325
|
+
* which is as close as CSS gets. `numTab` aligns to the list number's tab
|
|
326
|
+
* stop, which CSS cannot express, so it renders at the start edge — where a
|
|
327
|
+
* numbered paragraph without one sits.
|
|
328
|
+
*/
|
|
329
|
+
const CSS_TEXT_ALIGN_BY_PARAGRAPH_ALIGNMENT = {
|
|
330
|
+
start: "start",
|
|
331
|
+
end: "end",
|
|
332
|
+
numTab: "start",
|
|
333
|
+
left: "left",
|
|
334
|
+
center: "center",
|
|
335
|
+
right: "right",
|
|
336
|
+
both: "justify",
|
|
337
|
+
distribute: "justify",
|
|
338
|
+
mediumKashida: "justify",
|
|
339
|
+
highKashida: "justify",
|
|
340
|
+
lowKashida: "justify",
|
|
341
|
+
thaiDistribute: "justify"
|
|
342
|
+
};
|
|
266
343
|
/**
|
|
267
344
|
* Merge multiple CSSProperties objects
|
|
268
345
|
*
|
|
@@ -287,7 +364,11 @@ function tableCellToStyle(formatting, theme) {
|
|
|
287
364
|
if (!formatting) return {};
|
|
288
365
|
const style = {};
|
|
289
366
|
if (formatting.verticalAlign) style.verticalAlign = formatting.verticalAlign;
|
|
290
|
-
if (formatting.textDirection
|
|
367
|
+
if (formatting.textDirection) {
|
|
368
|
+
const flow = textFlowCss(formatting.textDirection);
|
|
369
|
+
if (flow.writingMode !== "horizontal-tb") style.writingMode = flow.writingMode;
|
|
370
|
+
if (flow.rotateDegrees !== void 0) style.transform = `rotate(${String(flow.rotateDegrees)}deg)`;
|
|
371
|
+
}
|
|
291
372
|
if (formatting.shading) {
|
|
292
373
|
const bgColor = resolveShadingFill(formatting.shading, theme);
|
|
293
374
|
if (bgColor) style.backgroundColor = bgColor;
|
|
@@ -328,4 +409,4 @@ function sectionToStyle(sectionProps, theme) {
|
|
|
328
409
|
return style;
|
|
329
410
|
}
|
|
330
411
|
//#endregion
|
|
331
|
-
export { borderToStyle, mergeStyles, paragraphToStyle, resolveShadingFill, sectionToStyle, tableCellToStyle, textToStyle };
|
|
412
|
+
export { PLAIN_UNDERLINE, UNDERLINE_DECORATION_STYLES, borderToStyle, mergeStyles, paragraphToStyle, resolveShadingFill, sectionToStyle, tableCellToStyle, textToStyle, underlineDecorationCss, underlineStyleFromCssDecoration };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveHeadingLevel } from "../docx/builtInStyles.js";
|
|
2
|
+
import { readOutlineLevelAttr } from "../prosemirror/outlineLevelAttr.js";
|
|
2
3
|
//#region src/utils/headingCollector.ts
|
|
3
4
|
/**
|
|
4
5
|
* Collect all headings from a ProseMirror document, in document order.
|
|
@@ -14,8 +15,8 @@ function collectHeadings(doc, styles) {
|
|
|
14
15
|
doc.descendants((node, pos) => {
|
|
15
16
|
if (node.type.name !== "paragraph") return;
|
|
16
17
|
const level = resolveHeadingLevel({
|
|
17
|
-
outlineLevel: node.attrs["outlineLevel"],
|
|
18
|
-
styleId: node.attrs["styleId"]
|
|
18
|
+
outlineLevel: readOutlineLevelAttr(node.attrs["outlineLevel"]),
|
|
19
|
+
styleId: typeof node.attrs["styleId"] === "string" ? node.attrs["styleId"] : null
|
|
19
20
|
}, styles);
|
|
20
21
|
if (level === void 0) return;
|
|
21
22
|
let text = "";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { paragraphNumberingReferenceId } from "../docx/numberingReference.js";
|
|
1
2
|
import { cloneParagraphWithoutPropertySource } from "../docx/paragraphPropertySource.js";
|
|
2
3
|
//#region src/utils/mergeDocumentContent.ts
|
|
3
4
|
/**
|
|
@@ -110,14 +111,15 @@ function remapTable(table, numIdRemap, abstractNumIdRemap) {
|
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
113
|
function remapParagraph(paragraph, numIdRemap, abstractNumIdRemap) {
|
|
113
|
-
const
|
|
114
|
+
const numPr = paragraph.formatting?.numPr;
|
|
115
|
+
const numId = paragraphNumberingReferenceId(numPr);
|
|
114
116
|
const remappedNumId = numId === void 0 ? void 0 : numIdRemap.get(numId);
|
|
115
|
-
if (remappedNumId === void 0) return paragraph;
|
|
117
|
+
if (remappedNumId === void 0 || numPr?.kind !== "reference") return paragraph;
|
|
116
118
|
return cloneParagraphWithoutPropertySource(paragraph, {
|
|
117
119
|
formatting: {
|
|
118
120
|
...paragraph.formatting,
|
|
119
121
|
numPr: {
|
|
120
|
-
...
|
|
122
|
+
...numPr,
|
|
121
123
|
numId: remappedNumId
|
|
122
124
|
}
|
|
123
125
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mergeTextFormatting } from "./textFormattingMerge.js";
|
|
2
|
+
import { mergeParagraphNumbering } from "@stll/docx-core/model";
|
|
2
3
|
//#region src/utils/paragraphFormattingMerge.ts
|
|
3
4
|
const PARAGRAPH_REPLACE_KEYS = [
|
|
4
5
|
"alignment",
|
|
@@ -41,6 +42,28 @@ function mergeParagraphTabStops(inherited, direct) {
|
|
|
41
42
|
return [...stopsByPosition.values()].toSorted((a, b) => a.position - b.position);
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
45
|
+
* A resolved cascade carries no captured bytes.
|
|
46
|
+
*
|
|
47
|
+
* `preserved` holds the markup of the one element it was read from, and the
|
|
48
|
+
* two attribute remainders beside it hold the attributes of the `w:ind` and
|
|
49
|
+
* `w:spacing` that element carried. A style's `w:pPr` is not a paragraph's
|
|
50
|
+
* direct formatting, and a merge that let a spread carry either would write
|
|
51
|
+
* the same bytes at two tiers and make an inherited value outrank the tier it
|
|
52
|
+
* came from — the rule #873 states for every other inherited `w:pPr` value.
|
|
53
|
+
* Every caller of the merge below builds a resolved cascade rather than a
|
|
54
|
+
* saved element, so the drop is unconditional and belongs here, where a new
|
|
55
|
+
* field cannot slip past it in a spread.
|
|
56
|
+
*
|
|
57
|
+
* The remainders inside `borders`, `shading` and `tabs` are not dropped, and
|
|
58
|
+
* that is the same rule rather than an exception: those records replace
|
|
59
|
+
* wholesale, so an inherited one is written back only where the whole record
|
|
60
|
+
* is, and the attributes the author wrote on it belong with it.
|
|
61
|
+
*/
|
|
62
|
+
const withoutPreservedMarkup = (formatting) => {
|
|
63
|
+
const { preserved: _preserved, indentPreservedAttributes: _indentPreservedAttributes, spacingPreservedAttributes: _spacingPreservedAttributes, ...resolved } = formatting;
|
|
64
|
+
return resolved;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
44
67
|
* Merge paragraph properties for OOXML style cascade resolution.
|
|
45
68
|
*
|
|
46
69
|
* The source is the higher-priority layer. Most `w:pPr` properties replace an
|
|
@@ -51,11 +74,11 @@ function mergeParagraphTabStops(inherited, direct) {
|
|
|
51
74
|
function mergeParagraphFormatting(target, source) {
|
|
52
75
|
if (!source) return target;
|
|
53
76
|
if (!target) {
|
|
54
|
-
const result =
|
|
77
|
+
const result = withoutPreservedMarkup(source);
|
|
55
78
|
if (source.tabs !== void 0) result.tabs = [...source.tabs];
|
|
56
79
|
return result;
|
|
57
80
|
}
|
|
58
|
-
const result =
|
|
81
|
+
const result = withoutPreservedMarkup(target);
|
|
59
82
|
for (const key of PARAGRAPH_REPLACE_KEYS) copyDefinedParagraphProperty(result, source, key);
|
|
60
83
|
if (source.indentFirstLine !== void 0) result.hangingIndent = source.hangingIndent === true;
|
|
61
84
|
const mergedRunProperties = mergeTextFormatting(result.runProperties, source.runProperties);
|
|
@@ -64,10 +87,8 @@ function mergeParagraphFormatting(target, source) {
|
|
|
64
87
|
...result.borders,
|
|
65
88
|
...source.borders
|
|
66
89
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
...source.numPr
|
|
70
|
-
};
|
|
90
|
+
const mergedNumbering = mergeParagraphNumbering(result.numPr, source.numPr);
|
|
91
|
+
if (mergedNumbering !== void 0) result.numPr = mergedNumbering;
|
|
71
92
|
if (source.frame !== void 0) result.frame = {
|
|
72
93
|
...result.frame,
|
|
73
94
|
...source.frame
|
|
@@ -3,8 +3,10 @@ import { document_d_exports } from "../types/document.js";
|
|
|
3
3
|
type TablePropertiesCommand = {
|
|
4
4
|
width?: number | null;
|
|
5
5
|
widthType?: document_d_exports.TableWidthType | null;
|
|
6
|
-
justification?:
|
|
6
|
+
justification?: document_d_exports.TableAlignment | null;
|
|
7
7
|
};
|
|
8
|
+
declare const TABLE_PROPERTY_JUSTIFICATIONS: readonly ("start" | "center" | "end" | "left" | "right")[];
|
|
9
|
+
declare const toTablePropertyJustification: (value: string | null | undefined) => NonNullable<TablePropertiesCommand["justification"]>;
|
|
8
10
|
type TableAction = "addRowAbove" | "addRowBelow" | "addColumnLeft" | "addColumnRight" | "deleteRow" | "deleteColumn" | "mergeCells" | "splitCell" | "deleteTable" | "selectTable" | "selectRow" | "selectColumn" | "borderAll" | "borderOutside" | "borderInside" | "borderNone" | "borderTop" | "borderBottom" | "borderLeft" | "borderRight" | {
|
|
9
11
|
type: "cellFillColor";
|
|
10
12
|
color: string | null;
|
|
@@ -17,7 +19,7 @@ type TableAction = "addRowAbove" | "addRowBelow" | "addColumnLeft" | "addColumnR
|
|
|
17
19
|
} | {
|
|
18
20
|
type: "cellBorder";
|
|
19
21
|
side: "top" | "bottom" | "left" | "right" | "all";
|
|
20
|
-
style:
|
|
22
|
+
style: document_d_exports.BorderStyle;
|
|
21
23
|
size: number;
|
|
22
24
|
color: string;
|
|
23
25
|
} | {
|
|
@@ -84,4 +86,4 @@ declare const deleteColumn: (table: document_d_exports.Table, columnIndex: numbe
|
|
|
84
86
|
declare const mergeCells: (table: document_d_exports.Table, selection: TableSelection) => document_d_exports.Table;
|
|
85
87
|
declare const splitCell: (table: document_d_exports.Table, rowIndex: number, columnIndex: number) => document_d_exports.Table;
|
|
86
88
|
//#endregion
|
|
87
|
-
export { TableAction, TableContext, TablePropertiesCommand, TableSelection, addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell };
|
|
89
|
+
export { TABLE_PROPERTY_JUSTIFICATIONS, TableAction, TableContext, TablePropertiesCommand, TableSelection, addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell, toTablePropertyJustification };
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import { TABLE_JUSTIFICATION_VALUES } from "../types/documentEnumValues.js";
|
|
1
2
|
//#region src/utils/tableOperations.ts
|
|
3
|
+
const TABLE_PROPERTY_JUSTIFICATION_ORDER = {
|
|
4
|
+
left: 0,
|
|
5
|
+
center: 1,
|
|
6
|
+
right: 2,
|
|
7
|
+
start: 3,
|
|
8
|
+
end: 4
|
|
9
|
+
};
|
|
10
|
+
const TABLE_PROPERTY_JUSTIFICATIONS = Object.freeze(TABLE_JUSTIFICATION_VALUES.toSorted((left, right) => TABLE_PROPERTY_JUSTIFICATION_ORDER[left] - TABLE_PROPERTY_JUSTIFICATION_ORDER[right]));
|
|
11
|
+
const toTablePropertyJustification = (value) => {
|
|
12
|
+
for (const justification of TABLE_PROPERTY_JUSTIFICATIONS) if (value === justification) return justification;
|
|
13
|
+
return "left";
|
|
14
|
+
};
|
|
2
15
|
const getColumnCount = (table) => {
|
|
3
16
|
let maxCols = 0;
|
|
4
17
|
for (const row of table.rows) {
|
|
@@ -256,4 +269,4 @@ const splitCell = (table, rowIndex, columnIndex) => {
|
|
|
256
269
|
};
|
|
257
270
|
};
|
|
258
271
|
//#endregion
|
|
259
|
-
export { addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell };
|
|
272
|
+
export { TABLE_PROPERTY_JUSTIFICATIONS, addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell, toTablePropertyJustification };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TableAlignment } from "../types/formatting.js";
|
|
2
|
+
//#region src/utils/tablePlacement.d.ts
|
|
3
|
+
type PhysicalTableAlignment = "left" | "center" | "right";
|
|
4
|
+
/** Resolve an OOXML table placement to a physical inline alignment. */
|
|
5
|
+
declare const resolveTablePlacementAlignment: (placement: TableAlignment, rightToLeft: boolean) => PhysicalTableAlignment;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { PhysicalTableAlignment, resolveTablePlacementAlignment };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/utils/tablePlacement.ts
|
|
2
|
+
/** Resolve an OOXML table placement to a physical inline alignment. */
|
|
3
|
+
const resolveTablePlacementAlignment = (placement, rightToLeft) => {
|
|
4
|
+
switch (placement) {
|
|
5
|
+
case "center": return "center";
|
|
6
|
+
case "left":
|
|
7
|
+
case "start": return rightToLeft ? "right" : "left";
|
|
8
|
+
case "right":
|
|
9
|
+
case "end": return rightToLeft ? "left" : "right";
|
|
10
|
+
default: return placement;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { resolveTablePlacementAlignment };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TextDirection } from "@stll/docx-core/model";
|
|
2
|
+
//#region src/utils/textDirectionFlow.d.ts
|
|
3
|
+
type TextFlowCss = {
|
|
4
|
+
/** `horizontal-tb` needs no declaration; the others are written out. */
|
|
5
|
+
writingMode: "horizontal-tb" | "vertical-lr" | "vertical-rl";
|
|
6
|
+
/**
|
|
7
|
+
* CSS has no writing mode for a bottom-to-top flow, so the nearest one is
|
|
8
|
+
* turned upside down.
|
|
9
|
+
*/
|
|
10
|
+
rotateDegrees?: 180;
|
|
11
|
+
};
|
|
12
|
+
/** The CSS a `w:textDirection` token renders as, through the flow it names. */
|
|
13
|
+
declare const textFlowCss: (direction: TextDirection) => TextFlowCss;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { TextFlowCss, textFlowCss };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TEXT_DIRECTION_FLOW_BY_TOKEN } from "@stll/docx-core/model";
|
|
2
|
+
//#region src/utils/textDirectionFlow.ts
|
|
3
|
+
/**
|
|
4
|
+
* The CSS one `w:textDirection` flow renders as.
|
|
5
|
+
*
|
|
6
|
+
* `ST_TextDirection` spells each of its six flows twice — a Strict spelling
|
|
7
|
+
* and a Transitional one — so rendering is decided per flow and read through
|
|
8
|
+
* `TEXT_DIRECTION_FLOW_BY_TOKEN`. Both CSS projections, the editor's inline
|
|
9
|
+
* style and `tableCellToStyle`, read this one map: a cell written `tbRl` and
|
|
10
|
+
* its Strict twin written `rl` cannot render differently in one and the same
|
|
11
|
+
* in the other.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Each text flow, and the CSS that renders it.
|
|
15
|
+
*
|
|
16
|
+
* `tb` and `tbV` are the horizontal flows. `rl` and `rlV` run their lines
|
|
17
|
+
* right to left, `lrV` runs them left to right, and `lr` runs them left to
|
|
18
|
+
* right with its characters bottom-to-top, which CSS cannot express: it takes
|
|
19
|
+
* the nearest writing mode turned over.
|
|
20
|
+
*
|
|
21
|
+
* Total over the flows on purpose: a flow nobody mapped would otherwise render
|
|
22
|
+
* as horizontal text with nothing to say it had been dropped.
|
|
23
|
+
*/
|
|
24
|
+
const TEXT_FLOW_CSS = {
|
|
25
|
+
tb: { writingMode: "horizontal-tb" },
|
|
26
|
+
tbV: { writingMode: "horizontal-tb" },
|
|
27
|
+
rl: { writingMode: "vertical-rl" },
|
|
28
|
+
rlV: { writingMode: "vertical-rl" },
|
|
29
|
+
lrV: { writingMode: "vertical-lr" },
|
|
30
|
+
lr: {
|
|
31
|
+
writingMode: "vertical-lr",
|
|
32
|
+
rotateDegrees: 180
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/** The CSS a `w:textDirection` token renders as, through the flow it names. */
|
|
36
|
+
const textFlowCss = (direction) => TEXT_FLOW_CSS[TEXT_DIRECTION_FLOW_BY_TOKEN[direction]];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { textFlowCss };
|
|
@@ -31,14 +31,26 @@ function mergeStyleTextFormatting(target, source) {
|
|
|
31
31
|
}
|
|
32
32
|
return result;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* A merge answers "what does this text look like once the style, the paragraph
|
|
36
|
+
* mark and the run have all had their say". `preserved` is not a value: it is
|
|
37
|
+
* the bytes one specific `w:rPr` held, and carrying it across a merge would
|
|
38
|
+
* write a style's or a paragraph mark's markup into every run that inherits
|
|
39
|
+
* from it. So no merged formatting has one, on any path out of the function.
|
|
40
|
+
*/
|
|
41
|
+
const withoutPreserved = (formatting) => {
|
|
42
|
+
if (formatting.preserved === void 0) return formatting;
|
|
43
|
+
const { preserved: _preserved, ...values } = formatting;
|
|
44
|
+
return values;
|
|
45
|
+
};
|
|
34
46
|
function mergeTextFormatting(target, source) {
|
|
35
47
|
if (!source && !target) return;
|
|
36
|
-
if (!source) return target;
|
|
37
|
-
if (!target) return { ...source };
|
|
38
|
-
const result = { ...target };
|
|
48
|
+
if (!source) return target && withoutPreserved(target);
|
|
49
|
+
if (!target) return withoutPreserved({ ...source });
|
|
50
|
+
const result = { ...withoutPreserved(target) };
|
|
39
51
|
for (const key of Object.keys(source)) {
|
|
40
52
|
const value = source[key];
|
|
41
|
-
if (value === void 0) continue;
|
|
53
|
+
if (value === void 0 || key === "preserved") continue;
|
|
42
54
|
if (key === "fontFamily" && typeof value === "object") {
|
|
43
55
|
result["fontFamily"] = mergeFontFamily(target.fontFamily, value);
|
|
44
56
|
continue;
|