@stll/folio-core 0.46.0 → 0.47.1
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.d.ts +17 -1
- package/dist/ai-edits/apply.js +31 -27
- package/dist/ai-edits/headless.d.ts +9 -2
- package/dist/ai-edits/headless.js +5 -3
- 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 -1
- package/dist/compare/content-alignment.js +192 -46
- 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.d.ts +9 -2
- package/dist/document-operations.js +5 -3
- 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
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { HIGHLIGHT_COLOR_VALUES } from "../../types/documentEnumValues.js";
|
|
2
2
|
import { isValidHexColor } from "../../utils/colorResolver.js";
|
|
3
3
|
import { roundHorizontalScalePercentForSerialization } from "../../utils/horizontalScale.js";
|
|
4
|
+
import { serializePreservedAttributes } from "../attributeRemainder.js";
|
|
4
5
|
import { intAttr } from "./xmlUtils.js";
|
|
5
|
-
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
6
|
+
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
7
|
+
import { themeColorToken } from "@stll/docx-core/model";
|
|
8
|
+
import { serializeSequenceChildren } from "@stll/docx-core/schema";
|
|
6
9
|
//#region src/docx/serializer/textFormattingSerializer.ts
|
|
7
10
|
const VALID_HIGHLIGHT_COLORS = new Set(HIGHLIGHT_COLOR_VALUES);
|
|
8
11
|
/**
|
|
@@ -14,7 +17,7 @@ function serializeColorElement(color) {
|
|
|
14
17
|
const attrs = [];
|
|
15
18
|
if (auto) attrs.push("w:val=\"auto\"");
|
|
16
19
|
else if (rgb && isValidHexColor(rgb)) attrs.push(`w:val="${escapeXmlAttribute(rgb)}"`);
|
|
17
|
-
if (themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColor)}"`);
|
|
20
|
+
if (themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColorToken(themeColor))}"`);
|
|
18
21
|
if (themeTint) attrs.push(`w:themeTint="${escapeXmlAttribute(themeTint)}"`);
|
|
19
22
|
if (themeShade) attrs.push(`w:themeShade="${escapeXmlAttribute(themeShade)}"`);
|
|
20
23
|
return attrs.length === 0 ? "" : `<w:color ${attrs.join(" ")}/>`;
|
|
@@ -24,122 +27,129 @@ function serializeColorElement(color) {
|
|
|
24
27
|
*/
|
|
25
28
|
function serializeShading(shading) {
|
|
26
29
|
if (!shading) return "";
|
|
27
|
-
const { pattern, color, fill } = shading;
|
|
30
|
+
const { pattern, color, fill, preservedAttributes } = shading;
|
|
28
31
|
const attrs = [];
|
|
29
32
|
if (pattern) attrs.push(`w:val="${escapeXmlAttribute(pattern)}"`);
|
|
30
33
|
else attrs.push("w:val=\"clear\"");
|
|
31
34
|
if (color) {
|
|
32
|
-
const { rgb, auto, themeColor
|
|
35
|
+
const { rgb, auto, themeColor, themeTint, themeShade } = color;
|
|
33
36
|
if (rgb && isValidHexColor(rgb)) attrs.push(`w:color="${escapeXmlAttribute(rgb)}"`);
|
|
34
37
|
else if (auto) attrs.push("w:color=\"auto\"");
|
|
38
|
+
if (themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColorToken(themeColor))}"`);
|
|
39
|
+
if (themeTint) attrs.push(`w:themeTint="${escapeXmlAttribute(themeTint)}"`);
|
|
40
|
+
if (themeShade) attrs.push(`w:themeShade="${escapeXmlAttribute(themeShade)}"`);
|
|
35
41
|
}
|
|
36
42
|
if (fill) {
|
|
37
43
|
const { rgb, auto, themeColor, themeTint, themeShade } = fill;
|
|
38
44
|
if (rgb && isValidHexColor(rgb)) attrs.push(`w:fill="${escapeXmlAttribute(rgb)}"`);
|
|
39
45
|
else if (auto) attrs.push("w:fill=\"auto\"");
|
|
40
|
-
if (themeColor) attrs.push(`w:themeFill="${escapeXmlAttribute(themeColor)}"`);
|
|
46
|
+
if (themeColor) attrs.push(`w:themeFill="${escapeXmlAttribute(themeColorToken(themeColor))}"`);
|
|
41
47
|
if (themeTint) attrs.push(`w:themeFillTint="${escapeXmlAttribute(themeTint)}"`);
|
|
42
48
|
if (themeShade) attrs.push(`w:themeFillShade="${escapeXmlAttribute(themeShade)}"`);
|
|
43
49
|
}
|
|
44
|
-
|
|
50
|
+
const written = serializePreservedAttributes(attrs, preservedAttributes);
|
|
51
|
+
return written.length === 0 ? "" : `<w:shd ${written.join(" ")}/>`;
|
|
45
52
|
}
|
|
53
|
+
const numberTag = (name, value) => value === void 0 ? "" : `<w:${name} w:val="${intAttr(value)}"/>`;
|
|
54
|
+
const serializeFontFamily = (fontFamily) => {
|
|
55
|
+
if (!fontFamily) return "";
|
|
56
|
+
const { ascii, hAnsi, eastAsia, cs: complexScript, hint, asciiTheme, hAnsiTheme, eastAsiaTheme, csTheme } = fontFamily;
|
|
57
|
+
const attrs = [];
|
|
58
|
+
if (ascii) attrs.push(`w:ascii="${escapeXmlAttribute(ascii)}"`);
|
|
59
|
+
if (hAnsi) attrs.push(`w:hAnsi="${escapeXmlAttribute(hAnsi)}"`);
|
|
60
|
+
if (eastAsia) attrs.push(`w:eastAsia="${escapeXmlAttribute(eastAsia)}"`);
|
|
61
|
+
if (complexScript) attrs.push(`w:cs="${escapeXmlAttribute(complexScript)}"`);
|
|
62
|
+
if (hint) attrs.push(`w:hint="${escapeXmlAttribute(hint)}"`);
|
|
63
|
+
if (asciiTheme) attrs.push(`w:asciiTheme="${escapeXmlAttribute(asciiTheme)}"`);
|
|
64
|
+
if (hAnsiTheme) attrs.push(`w:hAnsiTheme="${escapeXmlAttribute(hAnsiTheme)}"`);
|
|
65
|
+
if (eastAsiaTheme) attrs.push(`w:eastAsiaTheme="${escapeXmlAttribute(eastAsiaTheme)}"`);
|
|
66
|
+
if (csTheme) attrs.push(`w:cstheme="${escapeXmlAttribute(csTheme)}"`);
|
|
67
|
+
return attrs.length === 0 ? "" : `<w:rFonts ${attrs.join(" ")}/>`;
|
|
68
|
+
};
|
|
69
|
+
const serializeUnderline = (underline) => {
|
|
70
|
+
if (!underline) return "";
|
|
71
|
+
const { style, color } = underline;
|
|
72
|
+
const attrs = [`w:val="${style}"`];
|
|
73
|
+
if (color) {
|
|
74
|
+
const { rgb, themeColor, themeTint, themeShade, auto: _auto } = color;
|
|
75
|
+
if (rgb && isValidHexColor(rgb)) attrs.push(`w:color="${escapeXmlAttribute(rgb)}"`);
|
|
76
|
+
if (themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColorToken(themeColor))}"`);
|
|
77
|
+
if (themeTint) attrs.push(`w:themeTint="${escapeXmlAttribute(themeTint)}"`);
|
|
78
|
+
if (themeShade) attrs.push(`w:themeShade="${escapeXmlAttribute(themeShade)}"`);
|
|
79
|
+
}
|
|
80
|
+
return `<w:u ${attrs.join(" ")}/>`;
|
|
81
|
+
};
|
|
82
|
+
const serializeLanguage = (language) => {
|
|
83
|
+
if (!language) return "";
|
|
84
|
+
const { val, eastAsia, bidi } = language;
|
|
85
|
+
const attrs = [];
|
|
86
|
+
if (val) attrs.push(`w:val="${escapeXmlAttribute(val)}"`);
|
|
87
|
+
if (eastAsia) attrs.push(`w:eastAsia="${escapeXmlAttribute(eastAsia)}"`);
|
|
88
|
+
if (bidi) attrs.push(`w:bidi="${escapeXmlAttribute(bidi)}"`);
|
|
89
|
+
return attrs.length === 0 ? "" : `<w:lang ${attrs.join(" ")}/>`;
|
|
90
|
+
};
|
|
46
91
|
/**
|
|
47
|
-
*
|
|
92
|
+
* The single `w:rPr` writer.
|
|
93
|
+
*
|
|
94
|
+
* A run, the paragraph mark, a style, a numbering level and the snapshot
|
|
95
|
+
* inside either kind of `w:rPrChange` all write their run properties through
|
|
96
|
+
* here, so none of them can grow its own order or its own idea of which
|
|
97
|
+
* children exist. `EG_RPrBase` is an `xsd:choice` referenced
|
|
98
|
+
* `maxOccurs="unbounded"`, so a `w:rPr` in any order is valid and the order
|
|
99
|
+
* below is a canonical form rather than a validity rule: it is the one Word
|
|
100
|
+
* writes, and writing it from the generated declared-child list is what stops
|
|
101
|
+
* two of folio's serializers from disagreeing. The restatement is what
|
|
102
|
+
* drifted, and it is why folio wrote `w:vanish` before `w:noProof` while the
|
|
103
|
+
* schema declares the reverse.
|
|
104
|
+
*
|
|
105
|
+
* @param owned children a sibling record holds; see {@link OwnedRunPropertyChild}
|
|
48
106
|
*/
|
|
49
|
-
function serializeTextFormatting(input) {
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
else if (noProof === false) parts.push("<w:noProof w:val=\"0\"/>");
|
|
96
|
-
const colorXml = serializeColorElement(color);
|
|
97
|
-
if (colorXml) parts.push(colorXml);
|
|
98
|
-
if (spacing !== void 0) parts.push(`<w:spacing w:val="${intAttr(spacing)}"/>`);
|
|
99
|
-
const horizontalScale = roundHorizontalScalePercentForSerialization(scale);
|
|
100
|
-
if (horizontalScale !== void 0) parts.push(`<w:w w:val="${intAttr(horizontalScale)}"/>`);
|
|
101
|
-
if (kerning !== void 0) parts.push(`<w:kern w:val="${intAttr(kerning)}"/>`);
|
|
102
|
-
if (position !== void 0) parts.push(`<w:position w:val="${intAttr(position)}"/>`);
|
|
103
|
-
if (fontSize !== void 0) parts.push(`<w:sz w:val="${intAttr(fontSize)}"/>`);
|
|
104
|
-
if (fontSizeCs !== void 0) parts.push(`<w:szCs w:val="${intAttr(fontSizeCs)}"/>`);
|
|
105
|
-
let customHighlightShadingXml = "";
|
|
106
|
-
if (highlight) {
|
|
107
|
-
if (VALID_HIGHLIGHT_COLORS.has(highlight)) parts.push(`<w:highlight w:val="${highlight}"/>`);
|
|
108
|
-
else if (!shading) {
|
|
109
|
-
const hex = highlight.replace(/^#/u, "");
|
|
110
|
-
if (/^[0-9a-fA-F]{6}$/u.test(hex)) customHighlightShadingXml = `<w:shd w:val="clear" w:color="auto" w:fill="${hex}"/>`;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (underline) {
|
|
114
|
-
const { style, color: underlineColor } = underline;
|
|
115
|
-
const uAttrs = [`w:val="${style}"`];
|
|
116
|
-
if (underlineColor) {
|
|
117
|
-
const { rgb, themeColor, themeTint, themeShade, auto: _auto } = underlineColor;
|
|
118
|
-
if (rgb && isValidHexColor(rgb)) uAttrs.push(`w:color="${escapeXmlAttribute(rgb)}"`);
|
|
119
|
-
if (themeColor) uAttrs.push(`w:themeColor="${escapeXmlAttribute(themeColor)}"`);
|
|
120
|
-
if (themeTint) uAttrs.push(`w:themeTint="${escapeXmlAttribute(themeTint)}"`);
|
|
121
|
-
if (themeShade) uAttrs.push(`w:themeShade="${escapeXmlAttribute(themeShade)}"`);
|
|
122
|
-
}
|
|
123
|
-
parts.push(`<w:u ${uAttrs.join(" ")}/>`);
|
|
124
|
-
}
|
|
125
|
-
if (effect) parts.push(`<w:effect w:val="${effect}"/>`);
|
|
126
|
-
const shadingXml = serializeShading(shading) || customHighlightShadingXml;
|
|
127
|
-
if (shadingXml) parts.push(shadingXml);
|
|
128
|
-
if (vertAlign) parts.push(`<w:vertAlign w:val="${vertAlign}"/>`);
|
|
129
|
-
if (rtl === true) parts.push("<w:rtl/>");
|
|
130
|
-
else if (rtl === false) parts.push("<w:rtl w:val=\"0\"/>");
|
|
131
|
-
if (cs === true) parts.push("<w:cs/>");
|
|
132
|
-
else if (cs === false) parts.push("<w:cs w:val=\"0\"/>");
|
|
133
|
-
if (emphasisMark) parts.push(`<w:em w:val="${emphasisMark}"/>`);
|
|
134
|
-
if (language) {
|
|
135
|
-
const { val, eastAsia, bidi } = language;
|
|
136
|
-
const languageAttrs = [];
|
|
137
|
-
if (val) languageAttrs.push(`w:val="${escapeXmlAttribute(val)}"`);
|
|
138
|
-
if (eastAsia) languageAttrs.push(`w:eastAsia="${escapeXmlAttribute(eastAsia)}"`);
|
|
139
|
-
if (bidi) languageAttrs.push(`w:bidi="${escapeXmlAttribute(bidi)}"`);
|
|
140
|
-
if (languageAttrs.length > 0) parts.push(`<w:lang ${languageAttrs.join(" ")}/>`);
|
|
141
|
-
}
|
|
142
|
-
return parts.length === 0 ? "" : `<w:rPr>${parts.join("")}</w:rPr>`;
|
|
107
|
+
function serializeTextFormatting(input, owned = []) {
|
|
108
|
+
const { bold, boldCs, italic, italicCs, underline, strike, doubleStrike, vertAlign, smallCaps, allCaps, hidden, noProof, color, highlight, shading, fontSize, fontSizeCs, fontFamily, language, spacing, position, scale, kerning, effect, emphasisMark, emboss, imprint, outline, shadow, rtl, cs, styleId, preserved } = input ?? {};
|
|
109
|
+
const namedHighlight = highlight && VALID_HIGHLIGHT_COLORS.has(highlight) ? highlight : void 0;
|
|
110
|
+
const customHighlightHex = highlight && !namedHighlight && !shading ? highlight.replace(/^#/u, "") : "";
|
|
111
|
+
const customHighlightShadingXml = /^[0-9a-fA-F]{6}$/u.test(customHighlightHex) ? `<w:shd w:val="clear" w:color="auto" w:fill="${customHighlightHex}"/>` : "";
|
|
112
|
+
const parts = serializeSequenceChildren({
|
|
113
|
+
container: "run-properties",
|
|
114
|
+
modelled: [
|
|
115
|
+
...owned,
|
|
116
|
+
["rStyle", styleId ? `<w:rStyle w:val="${escapeXmlAttribute(styleId)}"/>` : ""],
|
|
117
|
+
["rFonts", serializeFontFamily(fontFamily)],
|
|
118
|
+
["b", serializeOnOffElement(bold, "b")],
|
|
119
|
+
["bCs", serializeOnOffElement(boldCs, "bCs")],
|
|
120
|
+
["i", serializeOnOffElement(italic, "i")],
|
|
121
|
+
["iCs", serializeOnOffElement(italicCs, "iCs")],
|
|
122
|
+
["caps", serializeOnOffElement(allCaps, "caps")],
|
|
123
|
+
["smallCaps", serializeOnOffElement(smallCaps, "smallCaps")],
|
|
124
|
+
["strike", serializeOnOffElement(strike, "strike")],
|
|
125
|
+
["dstrike", serializeOnOffElement(doubleStrike, "dstrike")],
|
|
126
|
+
["outline", serializeOnOffElement(outline, "outline")],
|
|
127
|
+
["shadow", serializeOnOffElement(shadow, "shadow")],
|
|
128
|
+
["emboss", serializeOnOffElement(emboss, "emboss")],
|
|
129
|
+
["imprint", serializeOnOffElement(imprint, "imprint")],
|
|
130
|
+
["noProof", serializeOnOffElement(noProof, "noProof")],
|
|
131
|
+
["vanish", serializeOnOffElement(hidden, "vanish")],
|
|
132
|
+
["color", serializeColorElement(color)],
|
|
133
|
+
["spacing", numberTag("spacing", spacing)],
|
|
134
|
+
["w", numberTag("w", roundHorizontalScalePercentForSerialization(scale))],
|
|
135
|
+
["kern", numberTag("kern", kerning)],
|
|
136
|
+
["position", numberTag("position", position)],
|
|
137
|
+
["sz", numberTag("sz", fontSize)],
|
|
138
|
+
["szCs", numberTag("szCs", fontSizeCs)],
|
|
139
|
+
["highlight", namedHighlight ? `<w:highlight w:val="${namedHighlight}"/>` : ""],
|
|
140
|
+
["u", serializeUnderline(underline)],
|
|
141
|
+
["effect", effect ? `<w:effect w:val="${effect}"/>` : ""],
|
|
142
|
+
["shd", serializeShading(shading) || customHighlightShadingXml],
|
|
143
|
+
["vertAlign", vertAlign ? `<w:vertAlign w:val="${vertAlign}"/>` : ""],
|
|
144
|
+
["rtl", serializeOnOffElement(rtl, "rtl")],
|
|
145
|
+
["cs", serializeOnOffElement(cs, "cs")],
|
|
146
|
+
["em", emphasisMark ? `<w:em w:val="${emphasisMark}"/>` : ""],
|
|
147
|
+
["lang", serializeLanguage(language)]
|
|
148
|
+
],
|
|
149
|
+
preserved
|
|
150
|
+
});
|
|
151
|
+
if (parts.length === 0) return input !== void 0 && Object.keys(input).length === 0 ? "<w:rPr/>" : "";
|
|
152
|
+
return `<w:rPr>${parts.join("")}</w:rPr>`;
|
|
143
153
|
}
|
|
144
154
|
//#endregion
|
|
145
155
|
export { serializeShading, serializeTextFormatting };
|
|
@@ -18,7 +18,7 @@ declare function intAttr(value: number | undefined | null): string;
|
|
|
18
18
|
/**
|
|
19
19
|
* Verify that `xml` parses to exactly one root element named `expectedLocalName`
|
|
20
20
|
* (namespace prefix ignored). Used to gate raw XML snapshots — e.g. an SDT's
|
|
21
|
-
* `
|
|
21
|
+
* `rawEndPropertiesXml` — before splicing it verbatim
|
|
22
22
|
* into a serialized document. Those snapshots are normally produced by our
|
|
23
23
|
* own parser, but they can also arrive from an untrusted surface (a
|
|
24
24
|
* programmatically constructed node, a collaboration payload); a value that
|
|
@@ -22,7 +22,7 @@ function intAttr(value) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Verify that `xml` parses to exactly one root element named `expectedLocalName`
|
|
24
24
|
* (namespace prefix ignored). Used to gate raw XML snapshots — e.g. an SDT's
|
|
25
|
-
* `
|
|
25
|
+
* `rawEndPropertiesXml` — before splicing it verbatim
|
|
26
26
|
* into a serialized document. Those snapshots are normally produced by our
|
|
27
27
|
* own parser, but they can also arrive from an untrusted surface (a
|
|
28
28
|
* programmatically constructed node, a collaboration payload); a value that
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deterministicHexId } from "../../utils/hexId.js";
|
|
2
2
|
import { createBuiltInStyleIndex, resolveHeadingLevel } from "../builtInStyles.js";
|
|
3
|
-
import {
|
|
3
|
+
import { mergeParagraphNumbering, paragraphNumberingReference, paragraphNumberingReferenceId } from "../numberingReference.js";
|
|
4
4
|
import { getParagraphText } from "../paragraphParser.js";
|
|
5
5
|
import { cloneParagraphWithoutPropertySource } from "../paragraphPropertySource.js";
|
|
6
6
|
import { getRunText } from "../runParser.js";
|
|
@@ -203,7 +203,7 @@ const flattenBlocks = (content) => {
|
|
|
203
203
|
out.push(block);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
if (block.type
|
|
206
|
+
if (block.type !== "blockSdt") return;
|
|
207
207
|
for (const child of block.content) visit(child);
|
|
208
208
|
};
|
|
209
209
|
for (const block of content) visit(block);
|
|
@@ -247,22 +247,24 @@ const classifyParagraph = (paragraph, styleById, builtInStyles) => {
|
|
|
247
247
|
if (effectiveNumPr(paragraph, styleById) !== void 0) return "listItem";
|
|
248
248
|
return "paragraph";
|
|
249
249
|
};
|
|
250
|
-
/** The numbering a paragraph renders with
|
|
250
|
+
/** The numbering a paragraph renders with after style and direct tiers fold. */
|
|
251
251
|
const effectiveNumPr = (paragraph, styleById) => {
|
|
252
|
-
const direct = paragraph.formatting?.numPr;
|
|
253
|
-
if (direct?.numId !== void 0) return isNumberingReference(direct.numId) ? direct : void 0;
|
|
254
252
|
const styleId = paragraph.formatting?.styleId;
|
|
255
|
-
|
|
253
|
+
const effective = mergeParagraphNumbering(styleId ? styleNumPr(styleById.get(styleId), styleById) : void 0, paragraph.formatting?.numPr);
|
|
254
|
+
return effective?.kind === "reference" ? effective : void 0;
|
|
256
255
|
};
|
|
257
256
|
const styleNumPr = (style, styleById) => {
|
|
258
257
|
const seen = /* @__PURE__ */ new Set();
|
|
258
|
+
const chain = [];
|
|
259
259
|
let current = style;
|
|
260
260
|
while (current && !seen.has(current.styleId)) {
|
|
261
261
|
seen.add(current.styleId);
|
|
262
|
-
|
|
263
|
-
if (numPr?.numId !== void 0) return isNumberingReference(numPr.numId) ? numPr : void 0;
|
|
262
|
+
if (current.pPr?.numPr !== void 0) chain.push(current.pPr.numPr);
|
|
264
263
|
current = current.basedOn ? styleById.get(current.basedOn) : void 0;
|
|
265
264
|
}
|
|
265
|
+
let effective;
|
|
266
|
+
for (const stated of chain.toReversed()) effective = mergeParagraphNumbering(effective, stated);
|
|
267
|
+
return effective?.kind === "reference" ? effective : void 0;
|
|
266
268
|
};
|
|
267
269
|
const createNumberingCloner = ({ numbering, styleById, warnings }) => {
|
|
268
270
|
const abstractNums = numbering?.abstractNums ?? [];
|
|
@@ -301,7 +303,7 @@ const createNumberingCloner = ({ numbering, styleById, warnings }) => {
|
|
|
301
303
|
let current = abstract;
|
|
302
304
|
while (current.numStyleLink && !seen.has(current.abstractNumId)) {
|
|
303
305
|
seen.add(current.abstractNumId);
|
|
304
|
-
const linkedNumId = styleById.get(current.numStyleLink)?.pPr?.numPr
|
|
306
|
+
const linkedNumId = paragraphNumberingReferenceId(styleById.get(current.numStyleLink)?.pPr?.numPr);
|
|
305
307
|
const linkedNum = linkedNumId === void 0 ? void 0 : numById.get(linkedNumId);
|
|
306
308
|
const linkedAbstract = linkedNum ? abstractById.get(linkedNum.abstractNumId) : void 0;
|
|
307
309
|
if (!linkedAbstract) {
|
|
@@ -355,7 +357,7 @@ const createStyleCloner = ({ styleById, suffix, cloner }) => {
|
|
|
355
357
|
const style = styleById.get(styleId);
|
|
356
358
|
if (!style || style.type !== "paragraph") return styleId;
|
|
357
359
|
const numPr = styleNumPr(style, styleById);
|
|
358
|
-
if (numPr
|
|
360
|
+
if (numPr === void 0) return styleId;
|
|
359
361
|
const cloneId = `${styleId}-${suffix}`;
|
|
360
362
|
if (styleById.has(cloneId)) return cloneId;
|
|
361
363
|
const clone = {
|
|
@@ -366,10 +368,10 @@ const createStyleCloner = ({ styleById, suffix, cloner }) => {
|
|
|
366
368
|
default: false,
|
|
367
369
|
pPr: {
|
|
368
370
|
...style.pPr,
|
|
369
|
-
numPr: {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
371
|
+
numPr: paragraphNumberingReference({
|
|
372
|
+
numId: cloner.cloneNumId(numPr.numId),
|
|
373
|
+
ilvl: numPr.ilvl
|
|
374
|
+
})
|
|
373
375
|
}
|
|
374
376
|
};
|
|
375
377
|
clones.set(styleId, clone);
|
|
@@ -389,11 +391,11 @@ const cloneParagraphForTarget = (paragraph, targetParaId, styleCloner, cloner, b
|
|
|
389
391
|
const nextFormatting = formatting && {
|
|
390
392
|
...formatting,
|
|
391
393
|
...formatting.styleId !== void 0 && { styleId: styleCloner.styleIdFor(formatting.styleId) },
|
|
392
|
-
...formatting.numPr
|
|
394
|
+
...formatting.numPr?.kind === "reference" && { numPr: {
|
|
393
395
|
...formatting.numPr,
|
|
394
396
|
numId: cloner.cloneNumId(formatting.numPr.numId)
|
|
395
397
|
} },
|
|
396
|
-
...formatting.numPrFromStyle
|
|
398
|
+
...formatting.numPrFromStyle?.kind === "reference" && { numPrFromStyle: {
|
|
397
399
|
...formatting.numPrFromStyle,
|
|
398
400
|
numId: cloner.cloneNumId(formatting.numPrFromStyle.numId)
|
|
399
401
|
} }
|
|
@@ -72,12 +72,12 @@ const migrateFolioYjsSnapshot = (update) => {
|
|
|
72
72
|
}));
|
|
73
73
|
}
|
|
74
74
|
const fromVersion = read.value;
|
|
75
|
-
if (fromVersion ===
|
|
75
|
+
if (fromVersion === 11) {
|
|
76
76
|
ydoc.destroy();
|
|
77
77
|
return Result.ok({
|
|
78
78
|
fromVersion,
|
|
79
79
|
paragraphsRewritten: 0,
|
|
80
|
-
toVersion:
|
|
80
|
+
toVersion: 11,
|
|
81
81
|
update
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -87,7 +87,7 @@ const migrateFolioYjsSnapshot = (update) => {
|
|
|
87
87
|
return Result.ok({
|
|
88
88
|
fromVersion,
|
|
89
89
|
paragraphsRewritten,
|
|
90
|
-
toVersion:
|
|
90
|
+
toVersion: 11,
|
|
91
91
|
update: migrated
|
|
92
92
|
});
|
|
93
93
|
};
|
|
@@ -28,11 +28,14 @@ function parseSettings(xml) {
|
|
|
28
28
|
const settings = { defaultTabStop: parseDefaultTabStop(root) };
|
|
29
29
|
const wordprocessingFlag = (localName) => {
|
|
30
30
|
const element = findChildByNamespaceUri(root, WORDPROCESSINGML_NAMESPACE_URIS, localName);
|
|
31
|
-
return element
|
|
31
|
+
return element === null ? void 0 : parseBooleanElement(element);
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
33
|
+
const evenAndOddHeaders = wordprocessingFlag("evenAndOddHeaders");
|
|
34
|
+
if (evenAndOddHeaders !== void 0) settings.evenAndOddHeaders = evenAndOddHeaders;
|
|
35
|
+
const mirrorMargins = wordprocessingFlag("mirrorMargins");
|
|
36
|
+
if (mirrorMargins !== void 0) settings.mirrorMargins = mirrorMargins;
|
|
37
|
+
const updateFields = wordprocessingFlag("updateFields");
|
|
38
|
+
if (updateFields !== void 0) settings.updateFields = updateFields;
|
|
36
39
|
const themeFontLangEl = root ? findChild(root, "w", "themeFontLang") : null;
|
|
37
40
|
const eastAsiaLang = themeFontLangEl ? getAttribute(themeFontLangEl, "w", "eastAsia") || void 0 : void 0;
|
|
38
41
|
const bidiLang = themeFontLangEl ? getAttribute(themeFontLangEl, "w", "bidi") || void 0 : void 0;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ParseContext } from "./parseContext.js";
|
|
2
3
|
import { XmlElement } from "./xmlParser.js";
|
|
3
4
|
//#region src/docx/shadingParser.d.ts
|
|
4
|
-
declare function parseShading(shd: XmlElement | null): document_d_exports.ShadingProperties | undefined;
|
|
5
|
+
declare function parseShading(shd: XmlElement | null, context?: ParseContext): document_d_exports.ShadingProperties | undefined;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { parseShading };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { isValidHexColor } from "../utils/colorResolver.js";
|
|
2
|
-
import {
|
|
2
|
+
import { readAttributeBag } from "./attributeRemainder.js";
|
|
3
|
+
import { ShadingPatternSchema, narrowEnum } from "./parserEnums.js";
|
|
4
|
+
import { SHADING_ATTRIBUTES } from "./propertyElementAttributes.js";
|
|
5
|
+
import { parseThemeColorAttribute } from "./themeColorAttribute.js";
|
|
3
6
|
import { getAttribute } from "./xmlParser.js";
|
|
4
7
|
//#region src/docx/shadingParser.ts
|
|
5
8
|
/** `ST_HexColor`'s reserved "let the consumer decide" token. */
|
|
@@ -8,25 +11,58 @@ const parseHexColor = (value) => {
|
|
|
8
11
|
if (value === AUTOMATIC_COLOR) return { auto: true };
|
|
9
12
|
if (value && isValidHexColor(value)) return { rgb: value };
|
|
10
13
|
};
|
|
11
|
-
function parseShading(shd) {
|
|
14
|
+
function parseShading(shd, context) {
|
|
12
15
|
if (!shd) return;
|
|
13
16
|
const props = {};
|
|
14
17
|
const color = parseHexColor(getAttribute(shd, "w", "color"));
|
|
15
18
|
if (color) props.color = color;
|
|
16
19
|
const fill = parseHexColor(getAttribute(shd, "w", "fill"));
|
|
17
20
|
if (fill) props.fill = fill;
|
|
18
|
-
const
|
|
19
|
-
|
|
21
|
+
const element = shd.name ?? "w:shd";
|
|
22
|
+
const themeColor = parseThemeColorAttribute({
|
|
23
|
+
raw: getAttribute(shd, "w", "themeColor"),
|
|
24
|
+
element,
|
|
25
|
+
context
|
|
26
|
+
});
|
|
27
|
+
if (themeColor !== void 0) {
|
|
28
|
+
props.color ??= {};
|
|
29
|
+
props.color.themeColor = themeColor;
|
|
30
|
+
}
|
|
31
|
+
const themeTint = getAttribute(shd, "w", "themeTint");
|
|
32
|
+
if (themeTint) {
|
|
33
|
+
props.color ??= {};
|
|
34
|
+
props.color.themeTint = themeTint;
|
|
35
|
+
}
|
|
36
|
+
const themeShade = getAttribute(shd, "w", "themeShade");
|
|
37
|
+
if (themeShade) {
|
|
38
|
+
props.color ??= {};
|
|
39
|
+
props.color.themeShade = themeShade;
|
|
40
|
+
}
|
|
41
|
+
const themeFill = parseThemeColorAttribute({
|
|
42
|
+
raw: getAttribute(shd, "w", "themeFill"),
|
|
43
|
+
element,
|
|
44
|
+
context
|
|
45
|
+
});
|
|
46
|
+
if (themeFill !== void 0) {
|
|
20
47
|
props.fill ??= {};
|
|
21
48
|
props.fill.themeColor = themeFill;
|
|
22
49
|
}
|
|
23
50
|
const themeFillTint = getAttribute(shd, "w", "themeFillTint");
|
|
24
|
-
if (themeFillTint
|
|
51
|
+
if (themeFillTint) {
|
|
52
|
+
props.fill ??= {};
|
|
53
|
+
props.fill.themeTint = themeFillTint;
|
|
54
|
+
}
|
|
25
55
|
const themeFillShade = getAttribute(shd, "w", "themeFillShade");
|
|
26
|
-
if (themeFillShade
|
|
56
|
+
if (themeFillShade) {
|
|
57
|
+
props.fill ??= {};
|
|
58
|
+
props.fill.themeShade = themeFillShade;
|
|
59
|
+
}
|
|
27
60
|
const pattern = narrowEnum(getAttribute(shd, "w", "val"), ShadingPatternSchema);
|
|
28
61
|
if (pattern) props.pattern = pattern;
|
|
29
|
-
|
|
62
|
+
if (Object.keys(props).length === 0) return;
|
|
63
|
+
const preservedAttributes = readAttributeBag(shd, SHADING_ATTRIBUTES);
|
|
64
|
+
if (preservedAttributes) props.preservedAttributes = preservedAttributes;
|
|
65
|
+
return props;
|
|
30
66
|
}
|
|
31
67
|
//#endregion
|
|
32
68
|
export { parseShading };
|
package/dist/docx/shapeParser.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseDrawingAnchor } from "./drawingAnchor.js";
|
|
2
|
+
import { parseAnchorPosition, parseAnchorWrap, parseFill, parseInlineWrap, parseOutline } from "./drawingUtils.js";
|
|
2
3
|
import { parseNonVisualDrawingNames } from "./nonVisualDrawingProps.js";
|
|
3
4
|
import { ShapeTypeSchema, narrowEnum } from "./parserEnums.js";
|
|
4
5
|
import { findAllDeep, findChildByLocalName, findChildren, getAttribute, getChildElements, parseNumericAttribute, parseOnOffAttribute } from "./xmlParser.js";
|
|
@@ -140,11 +141,13 @@ function parseShape(node) {
|
|
|
140
141
|
const fill = parseShapeFill(spPr);
|
|
141
142
|
const outline = parseOutline(spPr);
|
|
142
143
|
const id = cNvPr ? getAttribute(cNvPr, null, "id") ?? void 0 : void 0;
|
|
144
|
+
const names = parseNonVisualDrawingNames(cNvPr);
|
|
143
145
|
const shape = {
|
|
144
146
|
type: "shape",
|
|
145
147
|
shapeType,
|
|
146
148
|
size,
|
|
147
|
-
...
|
|
149
|
+
...names,
|
|
150
|
+
...Object.keys(names).length > 0 ? { shapeNames: names } : {}
|
|
148
151
|
};
|
|
149
152
|
const geometryAdjustments = parseGeometryAdjustments(spPr);
|
|
150
153
|
if (geometryAdjustments !== void 0) shape.geometryAdjustments = geometryAdjustments;
|
|
@@ -189,7 +192,9 @@ function parseShapeFromDrawing(drawingEl) {
|
|
|
189
192
|
if (position) shape.position = position;
|
|
190
193
|
const wrap = parseAnchorWrap(container);
|
|
191
194
|
if (wrap) shape.wrap = wrap;
|
|
192
|
-
|
|
195
|
+
const drawingAnchor = parseDrawingAnchor(container);
|
|
196
|
+
if (drawingAnchor) shape.anchor = drawingAnchor;
|
|
197
|
+
} else shape.wrap = parseInlineWrap(container);
|
|
193
198
|
const docPr = findChildByLocalName(container, "docPr");
|
|
194
199
|
if (docPr) {
|
|
195
200
|
const id = getAttribute(docPr, null, "id");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { XmlElement } from "./xmlParser.js";
|
|
2
|
+
import { RenamedSlot } from "./strictNames.gen.js";
|
|
3
|
+
//#region src/docx/strictNames.d.ts
|
|
4
|
+
/** A renamed child of `parent`, in whichever spelling the document used. */
|
|
5
|
+
declare const findChildAnySpelling: (parent: XmlElement | null | undefined, slot: RenamedSlot) => XmlElement | null;
|
|
6
|
+
/** A renamed attribute's number, in whichever spelling the document used. */
|
|
7
|
+
declare const numericAttributeAnySpelling: (element: XmlElement | null | undefined, slot: RenamedSlot) => number | undefined;
|
|
8
|
+
/** Whether the element carries a renamed attribute under either spelling. */
|
|
9
|
+
declare const hasAttributeAnySpelling: (element: XmlElement | null | undefined, slot: RenamedSlot) => boolean;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { findChildAnySpelling, hasAttributeAnySpelling, numericAttributeAnySpelling };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/docx/strictNames.gen.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* GENERATED FILE — do not edit.
|
|
4
|
+
*
|
|
5
|
+
* The WordprocessingML names ECMA-376 Part 1 spells by writing direction and
|
|
6
|
+
* Part 4 spells by physical side, derived from the cited list in
|
|
7
|
+
* `specifications/strict-names/renames.ts` and the committed schema graph by
|
|
8
|
+
* `scripts/generate-strict-names.ts`. Regenerate with:
|
|
9
|
+
*
|
|
10
|
+
* bun run generate:strict-names
|
|
11
|
+
*
|
|
12
|
+
* A key is the complex type the name belongs to — the element's own type, or
|
|
13
|
+
* the attribute's owner — then the local name, marked `@` for an attribute.
|
|
14
|
+
* The comment above each entry names the types that declare the pair.
|
|
15
|
+
*/
|
|
16
|
+
/** What folio writes for a name a Strict producer spelled by writing direction. */
|
|
17
|
+
declare const TRANSITIONAL_NAME_BY_STRICT_NAME: {
|
|
18
|
+
readonly "CT_Border end": "right";
|
|
19
|
+
readonly "CT_Border start": "left";
|
|
20
|
+
readonly "CT_Ind @end": "right";
|
|
21
|
+
readonly "CT_Ind @endChars": "rightChars";
|
|
22
|
+
readonly "CT_Ind @start": "left";
|
|
23
|
+
readonly "CT_Ind @startChars": "leftChars";
|
|
24
|
+
readonly "CT_TblWidth end": "right";
|
|
25
|
+
readonly "CT_TblWidth start": "left";
|
|
26
|
+
};
|
|
27
|
+
/** A name Part 1 renamed, keyed by the complex type it belongs to. */
|
|
28
|
+
type StrictName = keyof typeof TRANSITIONAL_NAME_BY_STRICT_NAME;
|
|
29
|
+
/** The same keys as a list, so a consumer can walk them without widening them. */
|
|
30
|
+
declare const STRICT_NAMES: readonly ["CT_Border end", "CT_Border start", "CT_Ind @end", "CT_Ind @endChars", "CT_Ind @start", "CT_Ind @startChars", "CT_TblWidth end", "CT_TblWidth start"];
|
|
31
|
+
/** What a Strict producer may have written where folio writes the Transitional name. */
|
|
32
|
+
declare const STRICT_NAMES_BY_TRANSITIONAL_NAME: {
|
|
33
|
+
readonly "CT_Border left": readonly ["start"];
|
|
34
|
+
readonly "CT_Border right": readonly ["end"];
|
|
35
|
+
readonly "CT_Ind @left": readonly ["start"];
|
|
36
|
+
readonly "CT_Ind @leftChars": readonly ["startChars"];
|
|
37
|
+
readonly "CT_Ind @right": readonly ["end"];
|
|
38
|
+
readonly "CT_Ind @rightChars": readonly ["endChars"];
|
|
39
|
+
readonly "CT_TblWidth left": readonly ["start"];
|
|
40
|
+
readonly "CT_TblWidth right": readonly ["end"];
|
|
41
|
+
};
|
|
42
|
+
/** A slot a reader must take in either spelling, keyed the same way. */
|
|
43
|
+
type RenamedSlot = keyof typeof STRICT_NAMES_BY_TRANSITIONAL_NAME;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { RenamedSlot, STRICT_NAMES, STRICT_NAMES_BY_TRANSITIONAL_NAME, StrictName, TRANSITIONAL_NAME_BY_STRICT_NAME };
|