@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
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { NO_MODELLED_ATTRIBUTES, attributeRemainder } from "./attributeRemainder.js";
|
|
2
2
|
import { parseBorderSpec } from "./borderParser.js";
|
|
3
|
+
import { CAPTURE, dispatchChildren, keptUnless, sequencePositions } from "./containerChildren.js";
|
|
3
4
|
import { parseFooterReference, parseHeaderReference } from "./headerFooterRefParser.js";
|
|
4
5
|
import { parseEndnoteProperties, parseFootnoteProperties } from "./notePropertiesParser.js";
|
|
5
|
-
import { NumberFormatSchema,
|
|
6
|
+
import { NumberFormatSchema, TextDirectionSchema, narrowEnum } from "./parserEnums.js";
|
|
6
7
|
import { parseSectionReferenceHistory } from "./sectionReferenceHistory.js";
|
|
8
|
+
import { parseThemeColorAttribute } from "./themeColorAttribute.js";
|
|
7
9
|
import { parsePropertyChangeInfo } from "./trackedChangeInfo.js";
|
|
8
|
-
import { findChild, findChildren, getAttribute,
|
|
10
|
+
import { findChild, findChildren, getAttribute, parseBooleanElement, parseNumericAttribute, parseOnOffAttribute } from "./xmlParser.js";
|
|
9
11
|
//#region src/docx/sectionParser.ts
|
|
10
12
|
/**
|
|
11
13
|
* Sanity cap on `w:cols/@w:num`. Word's column picker tops out well below
|
|
@@ -19,37 +21,6 @@ const MAX_SECTION_COLUMNS = 45;
|
|
|
19
21
|
* ruler tick generators, which are sized off the page dimensions.
|
|
20
22
|
*/
|
|
21
23
|
const MAX_PAGE_DIMENSION_TWIPS = 31680;
|
|
22
|
-
const serializedSectionPropertyChildNames = /* @__PURE__ */ new Set([
|
|
23
|
-
"headerReference",
|
|
24
|
-
"footerReference",
|
|
25
|
-
"footnotePr",
|
|
26
|
-
"footnoteColumns",
|
|
27
|
-
"endnotePr",
|
|
28
|
-
"type",
|
|
29
|
-
"pgSz",
|
|
30
|
-
"pgMar",
|
|
31
|
-
"paperSrc",
|
|
32
|
-
"pgBorders",
|
|
33
|
-
"background",
|
|
34
|
-
"lnNumType",
|
|
35
|
-
"pgNumType",
|
|
36
|
-
"cols",
|
|
37
|
-
"formProt",
|
|
38
|
-
"vAlign",
|
|
39
|
-
"noEndnote",
|
|
40
|
-
"titlePg",
|
|
41
|
-
"textDirection",
|
|
42
|
-
"bidi",
|
|
43
|
-
"rtlGutter",
|
|
44
|
-
"docGrid",
|
|
45
|
-
"printerSettings",
|
|
46
|
-
"sectPrChange"
|
|
47
|
-
]);
|
|
48
|
-
const unserializedSectionPropertyChildNames = Symbol("unserializedSectionPropertyChildNames");
|
|
49
|
-
function getUnserializedSectionPropertyChildNames(props) {
|
|
50
|
-
const descriptor = Object.getOwnPropertyDescriptor(props, unserializedSectionPropertyChildNames);
|
|
51
|
-
return Array.isArray(descriptor?.value) ? descriptor.value : void 0;
|
|
52
|
-
}
|
|
53
24
|
/**
|
|
54
25
|
* Parse page orientation
|
|
55
26
|
*/
|
|
@@ -85,23 +56,6 @@ function parseVerticalAlign(align) {
|
|
|
85
56
|
default: return;
|
|
86
57
|
}
|
|
87
58
|
}
|
|
88
|
-
function parseTextDirection(val) {
|
|
89
|
-
switch (val) {
|
|
90
|
-
case "lrTb":
|
|
91
|
-
case "tbRl":
|
|
92
|
-
case "btLr":
|
|
93
|
-
case "lrTbV":
|
|
94
|
-
case "tbRlV":
|
|
95
|
-
case "tbLrV":
|
|
96
|
-
case "tb":
|
|
97
|
-
case "rl":
|
|
98
|
-
case "lr":
|
|
99
|
-
case "tbV":
|
|
100
|
-
case "rlV":
|
|
101
|
-
case "lrV": return val;
|
|
102
|
-
default: return;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
59
|
/**
|
|
106
60
|
* Parse line number restart type
|
|
107
61
|
*/
|
|
@@ -122,207 +76,249 @@ function parseLineNumberRestart(restart) {
|
|
|
122
76
|
function parseSectionProperties(sectPr, context) {
|
|
123
77
|
const props = {};
|
|
124
78
|
if (!sectPr) return props;
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
79
|
+
const headerRefs = [];
|
|
80
|
+
const footerRefs = [];
|
|
81
|
+
const propertyChanges = [];
|
|
82
|
+
const preserved = dispatchChildren({
|
|
83
|
+
element: sectPr,
|
|
84
|
+
container: "section-properties",
|
|
85
|
+
handlers: {
|
|
86
|
+
headerReference: (child) => {
|
|
87
|
+
const reference = parseHeaderReference(child, context);
|
|
88
|
+
if (reference) headerRefs.push(reference);
|
|
89
|
+
},
|
|
90
|
+
footerReference: (child) => {
|
|
91
|
+
const reference = parseFooterReference(child, context);
|
|
92
|
+
if (reference) footerRefs.push(reference);
|
|
93
|
+
},
|
|
94
|
+
footnotePr: (child) => {
|
|
95
|
+
const footnotePr = parseFootnoteProperties(child);
|
|
96
|
+
if (Object.keys(footnotePr).length > 0) {
|
|
97
|
+
props.footnotePr = footnotePr;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
return CAPTURE;
|
|
101
|
+
},
|
|
102
|
+
endnotePr: (child) => {
|
|
103
|
+
const endnotePr = parseEndnoteProperties(child);
|
|
104
|
+
if (Object.keys(endnotePr).length > 0) {
|
|
105
|
+
props.endnotePr = endnotePr;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
return CAPTURE;
|
|
109
|
+
},
|
|
110
|
+
type: (child) => {
|
|
111
|
+
const sectionStart = parseSectionStart(getAttribute(child, "w", "val"));
|
|
112
|
+
if (sectionStart) props.sectionStart = sectionStart;
|
|
113
|
+
return keptUnless(sectionStart !== void 0);
|
|
114
|
+
},
|
|
115
|
+
pgSz: (child) => {
|
|
116
|
+
const width = parseNumericAttribute(child, "w", "w");
|
|
117
|
+
if (width !== void 0) props.pageWidth = Math.min(width, MAX_PAGE_DIMENSION_TWIPS);
|
|
118
|
+
const height = parseNumericAttribute(child, "w", "h");
|
|
119
|
+
if (height !== void 0) props.pageHeight = Math.min(height, MAX_PAGE_DIMENSION_TWIPS);
|
|
120
|
+
const orientation = parseOrientation(getAttribute(child, "w", "orient"));
|
|
121
|
+
if (orientation) props.orientation = orientation;
|
|
122
|
+
return keptUnless(width !== void 0 || height !== void 0 || orientation !== void 0);
|
|
123
|
+
},
|
|
124
|
+
pgMar: (child) => {
|
|
125
|
+
const margins = [
|
|
126
|
+
["top", "marginTop"],
|
|
127
|
+
["bottom", "marginBottom"],
|
|
128
|
+
["left", "marginLeft"],
|
|
129
|
+
["right", "marginRight"],
|
|
130
|
+
["header", "headerDistance"],
|
|
131
|
+
["footer", "footerDistance"],
|
|
132
|
+
["gutter", "gutter"]
|
|
133
|
+
];
|
|
134
|
+
let taken = false;
|
|
135
|
+
for (const [attribute, field] of margins) {
|
|
136
|
+
const value = parseNumericAttribute(child, "w", attribute);
|
|
137
|
+
if (value !== void 0) {
|
|
138
|
+
props[field] = value;
|
|
139
|
+
taken = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return keptUnless(taken);
|
|
143
|
+
},
|
|
144
|
+
paperSrc: (child) => {
|
|
145
|
+
const first = parseNumericAttribute(child, "w", "first");
|
|
146
|
+
if (first !== void 0) props.paperSrcFirst = first;
|
|
147
|
+
const other = parseNumericAttribute(child, "w", "other");
|
|
148
|
+
if (other !== void 0) props.paperSrcOther = other;
|
|
149
|
+
return keptUnless(first !== void 0 || other !== void 0);
|
|
150
|
+
},
|
|
151
|
+
pgBorders: (child) => keptUnless(readPageBorders(props, child, context)),
|
|
152
|
+
lnNumType: (child) => {
|
|
153
|
+
const lineNumbers = {};
|
|
154
|
+
for (const [attribute, field] of [
|
|
155
|
+
["start", "start"],
|
|
156
|
+
["countBy", "countBy"],
|
|
157
|
+
["distance", "distance"]
|
|
158
|
+
]) {
|
|
159
|
+
const value = parseNumericAttribute(child, "w", attribute);
|
|
160
|
+
if (value !== void 0) lineNumbers[field] = value;
|
|
161
|
+
}
|
|
162
|
+
const restart = parseLineNumberRestart(getAttribute(child, "w", "restart"));
|
|
163
|
+
if (restart) lineNumbers.restart = restart;
|
|
164
|
+
if (Object.keys(lineNumbers).length === 0) return CAPTURE;
|
|
165
|
+
props.lineNumbers = lineNumbers;
|
|
166
|
+
},
|
|
167
|
+
pgNumType: (child) => {
|
|
168
|
+
const pageNumbering = {};
|
|
169
|
+
const format = narrowEnum(getAttribute(child, "w", "fmt"), NumberFormatSchema);
|
|
170
|
+
if (format) pageNumbering.format = format;
|
|
171
|
+
const start = parseNumericAttribute(child, "w", "start");
|
|
172
|
+
if (start !== void 0) pageNumbering.start = start;
|
|
173
|
+
const chapterStyle = parseNumericAttribute(child, "w", "chapStyle");
|
|
174
|
+
if (chapterStyle !== void 0) pageNumbering.chapterStyle = chapterStyle;
|
|
175
|
+
const chapterSeparator = getAttribute(child, "w", "chapSep");
|
|
176
|
+
if (chapterSeparator) pageNumbering.chapterSeparator = chapterSeparator;
|
|
177
|
+
if (Object.keys(pageNumbering).length === 0) return CAPTURE;
|
|
178
|
+
props.pageNumbering = pageNumbering;
|
|
179
|
+
},
|
|
180
|
+
cols: (child) => keptUnless(readColumns(props, child)),
|
|
181
|
+
formProt: (child) => {
|
|
182
|
+
props.formProtection = parseBooleanElement(child, "w", context);
|
|
183
|
+
},
|
|
184
|
+
vAlign: (child) => {
|
|
185
|
+
const verticalAlign = parseVerticalAlign(getAttribute(child, "w", "val"));
|
|
186
|
+
if (verticalAlign) props.verticalAlign = verticalAlign;
|
|
187
|
+
return keptUnless(verticalAlign !== void 0);
|
|
188
|
+
},
|
|
189
|
+
noEndnote: (child) => {
|
|
190
|
+
props.noEndnote = parseBooleanElement(child, "w", context);
|
|
191
|
+
},
|
|
192
|
+
titlePg: (child) => {
|
|
193
|
+
props.titlePg = parseBooleanElement(child, "w", context);
|
|
194
|
+
},
|
|
195
|
+
textDirection: (child) => {
|
|
196
|
+
const textDirection = narrowEnum(getAttribute(child, "w", "val"), TextDirectionSchema);
|
|
197
|
+
if (textDirection) props.textDirection = textDirection;
|
|
198
|
+
return keptUnless(textDirection !== void 0);
|
|
199
|
+
},
|
|
200
|
+
bidi: (child) => {
|
|
201
|
+
props.bidi = parseBooleanElement(child, "w", context);
|
|
202
|
+
},
|
|
203
|
+
rtlGutter: (child) => {
|
|
204
|
+
props.rtlGutter = parseBooleanElement(child, "w", context);
|
|
205
|
+
},
|
|
206
|
+
docGrid: (child) => {
|
|
207
|
+
const docGrid = {};
|
|
208
|
+
const gridType = getAttribute(child, "w", "type");
|
|
209
|
+
if (gridType === "default" || gridType === "lines" || gridType === "linesAndChars" || gridType === "snapToChars") docGrid.type = gridType;
|
|
210
|
+
const linePitch = parseNumericAttribute(child, "w", "linePitch");
|
|
211
|
+
if (linePitch !== void 0) docGrid.linePitch = linePitch;
|
|
212
|
+
const charSpace = parseNumericAttribute(child, "w", "charSpace");
|
|
213
|
+
if (charSpace !== void 0) docGrid.charSpace = charSpace;
|
|
214
|
+
props.docGrid = docGrid;
|
|
215
|
+
},
|
|
216
|
+
printerSettings: (child) => {
|
|
217
|
+
const relationshipId = getAttribute(child, "r", "id");
|
|
218
|
+
if (relationshipId) props.printerSettingsRelationshipId = relationshipId;
|
|
219
|
+
return keptUnless(Boolean(relationshipId));
|
|
220
|
+
},
|
|
221
|
+
sectPrChange: (child) => {
|
|
222
|
+
const previousSectPr = findChild(child, "w", "sectPr");
|
|
223
|
+
const change = {
|
|
224
|
+
type: "sectionPropertyChange",
|
|
225
|
+
info: parsePropertyChangeInfo(child)
|
|
226
|
+
};
|
|
227
|
+
if (previousSectPr) change.previousProperties = parseSectionProperties(previousSectPr);
|
|
228
|
+
const previousReferences = parseSectionReferenceHistory(child);
|
|
229
|
+
if (previousReferences !== void 0) change.previousReferences = previousReferences;
|
|
230
|
+
propertyChanges.push(change);
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
capturePosition: sequencePositions("section-properties", sectPr),
|
|
234
|
+
undeclared: {
|
|
235
|
+
background: (child) => keptUnless(readBackground(props, child, context)),
|
|
236
|
+
evenAndOddHeaders: (child) => {
|
|
237
|
+
props.evenAndOddHeaders = parseBooleanElement(child, "w", context);
|
|
238
|
+
},
|
|
239
|
+
footnoteColumns: (child) => {
|
|
240
|
+
const columns = parseNumericAttribute(child, "w", "val");
|
|
241
|
+
if (columns !== void 0) props.footnoteColumns = columns;
|
|
242
|
+
return keptUnless(columns !== void 0);
|
|
175
243
|
}
|
|
176
|
-
if (props.columnCount === void 0) props.columnCount = colElements.length;
|
|
177
244
|
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (typeEl) {
|
|
181
|
-
const sectionStart = parseSectionStart(getAttribute(typeEl, "w", "val"));
|
|
182
|
-
if (sectionStart) props.sectionStart = sectionStart;
|
|
183
|
-
}
|
|
184
|
-
const vAlign = findChild(sectPr, "w", "vAlign");
|
|
185
|
-
if (vAlign) {
|
|
186
|
-
const verticalAlign = parseVerticalAlign(getAttribute(vAlign, "w", "val"));
|
|
187
|
-
if (verticalAlign) props.verticalAlign = verticalAlign;
|
|
188
|
-
}
|
|
189
|
-
const textDirection = findChild(sectPr, "w", "textDirection");
|
|
190
|
-
if (textDirection) {
|
|
191
|
-
const textDirectionValue = parseTextDirection(getAttribute(textDirection, "w", "val"));
|
|
192
|
-
if (textDirectionValue) props.textDirection = textDirectionValue;
|
|
193
|
-
else addUnhandledChildName("textDirection");
|
|
194
|
-
}
|
|
195
|
-
const bidi = findChild(sectPr, "w", "bidi");
|
|
196
|
-
if (bidi) props.bidi = parseBooleanElement(bidi, "w", context);
|
|
197
|
-
const headerRefs = findChildren(sectPr, "w", "headerReference").flatMap((el) => parseHeaderReference(el, context) ?? []);
|
|
245
|
+
});
|
|
246
|
+
if (preserved) props.preserved = preserved;
|
|
198
247
|
if (headerRefs.length > 0) props.headerReferences = headerRefs;
|
|
199
|
-
const footerRefs = findChildren(sectPr, "w", "footerReference").flatMap((el) => parseFooterReference(el, context) ?? []);
|
|
200
248
|
if (footerRefs.length > 0) props.footerReferences = footerRefs;
|
|
201
|
-
const titlePg = findChild(sectPr, "w", "titlePg");
|
|
202
|
-
if (titlePg) props.titlePg = parseBooleanElement(titlePg, "w", context);
|
|
203
|
-
const evenAndOddHeaders = findChild(sectPr, "w", "evenAndOddHeaders");
|
|
204
|
-
if (evenAndOddHeaders) props.evenAndOddHeaders = parseBooleanElement(evenAndOddHeaders, "w", context);
|
|
205
|
-
const lnNumType = findChild(sectPr, "w", "lnNumType");
|
|
206
|
-
if (lnNumType) {
|
|
207
|
-
props.lineNumbers = {};
|
|
208
|
-
const start = parseNumericAttribute(lnNumType, "w", "start");
|
|
209
|
-
if (start !== void 0) props.lineNumbers.start = start;
|
|
210
|
-
const countBy = parseNumericAttribute(lnNumType, "w", "countBy");
|
|
211
|
-
if (countBy !== void 0) props.lineNumbers.countBy = countBy;
|
|
212
|
-
const distance = parseNumericAttribute(lnNumType, "w", "distance");
|
|
213
|
-
if (distance !== void 0) props.lineNumbers.distance = distance;
|
|
214
|
-
const restartValue = parseLineNumberRestart(getAttribute(lnNumType, "w", "restart"));
|
|
215
|
-
if (restartValue) props.lineNumbers.restart = restartValue;
|
|
216
|
-
}
|
|
217
|
-
const pgNumType = findChild(sectPr, "w", "pgNumType");
|
|
218
|
-
if (pgNumType) {
|
|
219
|
-
const pageNumbering = {};
|
|
220
|
-
const format = narrowEnum(getAttribute(pgNumType, "w", "fmt"), NumberFormatSchema);
|
|
221
|
-
if (format) pageNumbering.format = format;
|
|
222
|
-
const start = parseNumericAttribute(pgNumType, "w", "start");
|
|
223
|
-
if (start !== void 0) pageNumbering.start = start;
|
|
224
|
-
const chapterStyle = parseNumericAttribute(pgNumType, "w", "chapStyle");
|
|
225
|
-
if (chapterStyle !== void 0) pageNumbering.chapterStyle = chapterStyle;
|
|
226
|
-
const chapterSeparator = getAttribute(pgNumType, "w", "chapSep");
|
|
227
|
-
if (chapterSeparator) pageNumbering.chapterSeparator = chapterSeparator;
|
|
228
|
-
if (Object.keys(pageNumbering).length > 0) props.pageNumbering = pageNumbering;
|
|
229
|
-
}
|
|
230
|
-
const pgBorders = findChild(sectPr, "w", "pgBorders");
|
|
231
|
-
if (pgBorders) {
|
|
232
|
-
props.pageBorders = {};
|
|
233
|
-
const topBorder = parseBorderSpec(findChild(pgBorders, "w", "top"), context);
|
|
234
|
-
if (topBorder) props.pageBorders.top = topBorder;
|
|
235
|
-
const bottomBorder = parseBorderSpec(findChild(pgBorders, "w", "bottom"), context);
|
|
236
|
-
if (bottomBorder) props.pageBorders.bottom = bottomBorder;
|
|
237
|
-
const leftBorder = parseBorderSpec(findChild(pgBorders, "w", "left"), context);
|
|
238
|
-
if (leftBorder) props.pageBorders.left = leftBorder;
|
|
239
|
-
const rightBorder = parseBorderSpec(findChild(pgBorders, "w", "right"), context);
|
|
240
|
-
if (rightBorder) props.pageBorders.right = rightBorder;
|
|
241
|
-
const display = getAttribute(pgBorders, "w", "display");
|
|
242
|
-
if (display === "allPages" || display === "firstPage" || display === "notFirstPage") props.pageBorders.display = display;
|
|
243
|
-
const offsetFrom = getAttribute(pgBorders, "w", "offsetFrom");
|
|
244
|
-
if (offsetFrom === "page" || offsetFrom === "text") props.pageBorders.offsetFrom = offsetFrom;
|
|
245
|
-
const zOrder = getAttribute(pgBorders, "w", "zOrder");
|
|
246
|
-
if (zOrder === "front" || zOrder === "back") props.pageBorders.zOrder = zOrder;
|
|
247
|
-
}
|
|
248
|
-
const background = findChild(sectPr, "w", "background");
|
|
249
|
-
if (background) {
|
|
250
|
-
props.background = {};
|
|
251
|
-
const colorVal = getAttribute(background, "w", "color");
|
|
252
|
-
if (colorVal && colorVal !== "auto") props.background.color = { rgb: colorVal };
|
|
253
|
-
const backgroundThemeColor = narrowEnum(getAttribute(background, "w", "themeColor"), ThemeColorSlotSchema);
|
|
254
|
-
if (backgroundThemeColor) props.background.themeColor = backgroundThemeColor;
|
|
255
|
-
const themeTint = getAttribute(background, "w", "themeTint");
|
|
256
|
-
if (themeTint) props.background.themeTint = themeTint;
|
|
257
|
-
const themeShade = getAttribute(background, "w", "themeShade");
|
|
258
|
-
if (themeShade) props.background.themeShade = themeShade;
|
|
259
|
-
}
|
|
260
|
-
const footnotePr = findChild(sectPr, "w", "footnotePr");
|
|
261
|
-
if (footnotePr) {
|
|
262
|
-
const fnProps = parseFootnoteProperties(footnotePr);
|
|
263
|
-
if (Object.keys(fnProps).length > 0) props.footnotePr = fnProps;
|
|
264
|
-
}
|
|
265
|
-
const footnoteColumns = findChild(sectPr, "w15", "footnoteColumns");
|
|
266
|
-
if (footnoteColumns) {
|
|
267
|
-
const columns = parseNumericAttribute(footnoteColumns, "w", "val");
|
|
268
|
-
if (columns !== void 0) props.footnoteColumns = columns;
|
|
269
|
-
}
|
|
270
|
-
const endnotePr = findChild(sectPr, "w", "endnotePr");
|
|
271
|
-
if (endnotePr) {
|
|
272
|
-
const enProps = parseEndnoteProperties(endnotePr);
|
|
273
|
-
if (Object.keys(enProps).length > 0) props.endnotePr = enProps;
|
|
274
|
-
}
|
|
275
|
-
const formProt = findChild(sectPr, "w", "formProt");
|
|
276
|
-
if (formProt) props.formProtection = parseBooleanElement(formProt, "w", context);
|
|
277
|
-
const noEndnote = findChild(sectPr, "w", "noEndnote");
|
|
278
|
-
if (noEndnote) props.noEndnote = parseBooleanElement(noEndnote, "w", context);
|
|
279
|
-
const rtlGutter = findChild(sectPr, "w", "rtlGutter");
|
|
280
|
-
if (rtlGutter) props.rtlGutter = parseBooleanElement(rtlGutter, "w", context);
|
|
281
|
-
const docGrid = findChild(sectPr, "w", "docGrid");
|
|
282
|
-
if (docGrid) {
|
|
283
|
-
props.docGrid = {};
|
|
284
|
-
const gridType = getAttribute(docGrid, "w", "type");
|
|
285
|
-
if (gridType === "default" || gridType === "lines" || gridType === "linesAndChars" || gridType === "snapToChars") props.docGrid.type = gridType;
|
|
286
|
-
const linePitch = parseNumericAttribute(docGrid, "w", "linePitch");
|
|
287
|
-
if (linePitch !== void 0) props.docGrid.linePitch = linePitch;
|
|
288
|
-
const charSpace = parseNumericAttribute(docGrid, "w", "charSpace");
|
|
289
|
-
if (charSpace !== void 0) props.docGrid.charSpace = charSpace;
|
|
290
|
-
}
|
|
291
|
-
const paperSrc = findChild(sectPr, "w", "paperSrc");
|
|
292
|
-
if (paperSrc) {
|
|
293
|
-
const first = parseNumericAttribute(paperSrc, "w", "first");
|
|
294
|
-
if (first !== void 0) props.paperSrcFirst = first;
|
|
295
|
-
const other = parseNumericAttribute(paperSrc, "w", "other");
|
|
296
|
-
if (other !== void 0) props.paperSrcOther = other;
|
|
297
|
-
}
|
|
298
|
-
const printerSettings = findChild(sectPr, "w", "printerSettings");
|
|
299
|
-
if (printerSettings) {
|
|
300
|
-
const relationshipId = getAttribute(printerSettings, "r", "id");
|
|
301
|
-
if (relationshipId) props.printerSettingsRelationshipId = relationshipId;
|
|
302
|
-
}
|
|
303
|
-
const propertyChanges = findChildren(sectPr, "w", "sectPrChange").map((changeElement) => {
|
|
304
|
-
const previousSectPr = findChild(changeElement, "w", "sectPr");
|
|
305
|
-
const change = {
|
|
306
|
-
type: "sectionPropertyChange",
|
|
307
|
-
info: parsePropertyChangeInfo(changeElement)
|
|
308
|
-
};
|
|
309
|
-
if (previousSectPr) change.previousProperties = parseSectionProperties(previousSectPr);
|
|
310
|
-
const previousReferences = parseSectionReferenceHistory(changeElement);
|
|
311
|
-
if (previousReferences !== void 0) change.previousReferences = previousReferences;
|
|
312
|
-
return change;
|
|
313
|
-
});
|
|
314
249
|
if (propertyChanges.length > 0) props.propertyChanges = propertyChanges;
|
|
315
250
|
const remainder = attributeRemainder({
|
|
316
251
|
element: sectPr,
|
|
317
252
|
modelled: NO_MODELLED_ATTRIBUTES
|
|
318
253
|
});
|
|
319
254
|
if (remainder) props.preservedAttributes = remainder;
|
|
320
|
-
Object.defineProperty(props, unserializedSectionPropertyChildNames, {
|
|
321
|
-
enumerable: true,
|
|
322
|
-
value: unhandledChildNames
|
|
323
|
-
});
|
|
324
255
|
return props;
|
|
325
256
|
}
|
|
257
|
+
/** `w:cols`, into the four scalars and the per-column list. Did it state anything? */
|
|
258
|
+
function readColumns(props, cols) {
|
|
259
|
+
const num = parseNumericAttribute(cols, "w", "num");
|
|
260
|
+
if (num !== void 0) props.columnCount = Math.min(num, MAX_SECTION_COLUMNS);
|
|
261
|
+
const space = parseNumericAttribute(cols, "w", "space");
|
|
262
|
+
if (space !== void 0) props.columnSpace = space;
|
|
263
|
+
const equalWidth = parseOnOffAttribute(cols, "w", "equalWidth");
|
|
264
|
+
if (equalWidth !== void 0) props.equalWidth = equalWidth;
|
|
265
|
+
const separator = parseOnOffAttribute(cols, "w", "sep");
|
|
266
|
+
if (separator !== void 0) props.separator = separator;
|
|
267
|
+
const colElements = findChildren(cols, "w", "col");
|
|
268
|
+
if (colElements.length > 0) {
|
|
269
|
+
props.columns = colElements.map((colEl) => {
|
|
270
|
+
const column = {};
|
|
271
|
+
const colWidth = parseNumericAttribute(colEl, "w", "w");
|
|
272
|
+
if (colWidth !== void 0) column.width = colWidth;
|
|
273
|
+
const colSpace = parseNumericAttribute(colEl, "w", "space");
|
|
274
|
+
if (colSpace !== void 0) column.space = colSpace;
|
|
275
|
+
return column;
|
|
276
|
+
});
|
|
277
|
+
if (props.columnCount === void 0) props.columnCount = colElements.length;
|
|
278
|
+
}
|
|
279
|
+
return num !== void 0 || space !== void 0 || equalWidth !== void 0 || separator !== void 0 || colElements.length > 0;
|
|
280
|
+
}
|
|
281
|
+
/** `w:pgBorders`, into the four sides and the three placement attributes. */
|
|
282
|
+
function readPageBorders(props, pgBorders, context) {
|
|
283
|
+
const pageBorders = {};
|
|
284
|
+
for (const side of [
|
|
285
|
+
"top",
|
|
286
|
+
"bottom",
|
|
287
|
+
"left",
|
|
288
|
+
"right"
|
|
289
|
+
]) {
|
|
290
|
+
const border = parseBorderSpec(findChild(pgBorders, "w", side), context);
|
|
291
|
+
if (border) pageBorders[side] = border;
|
|
292
|
+
}
|
|
293
|
+
const display = getAttribute(pgBorders, "w", "display");
|
|
294
|
+
if (display === "allPages" || display === "firstPage" || display === "notFirstPage") pageBorders.display = display;
|
|
295
|
+
const offsetFrom = getAttribute(pgBorders, "w", "offsetFrom");
|
|
296
|
+
if (offsetFrom === "page" || offsetFrom === "text") pageBorders.offsetFrom = offsetFrom;
|
|
297
|
+
const zOrder = getAttribute(pgBorders, "w", "zOrder");
|
|
298
|
+
if (zOrder === "front" || zOrder === "back") pageBorders.zOrder = zOrder;
|
|
299
|
+
if (Object.keys(pageBorders).length === 0) return false;
|
|
300
|
+
props.pageBorders = pageBorders;
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
/** `w:background`, the page colour a producer wrote on the section. */
|
|
304
|
+
function readBackground(props, background, context) {
|
|
305
|
+
const pageBackground = {};
|
|
306
|
+
const colorVal = getAttribute(background, "w", "color");
|
|
307
|
+
if (colorVal && colorVal !== "auto") pageBackground.color = { rgb: colorVal };
|
|
308
|
+
const backgroundThemeColor = parseThemeColorAttribute({
|
|
309
|
+
raw: getAttribute(background, "w", "themeColor"),
|
|
310
|
+
element: background.name ?? "w:background",
|
|
311
|
+
context
|
|
312
|
+
});
|
|
313
|
+
if (backgroundThemeColor !== void 0) pageBackground.themeColor = backgroundThemeColor;
|
|
314
|
+
const themeTint = getAttribute(background, "w", "themeTint");
|
|
315
|
+
if (themeTint) pageBackground.themeTint = themeTint;
|
|
316
|
+
const themeShade = getAttribute(background, "w", "themeShade");
|
|
317
|
+
if (themeShade) pageBackground.themeShade = themeShade;
|
|
318
|
+
if (Object.keys(pageBackground).length === 0) return false;
|
|
319
|
+
props.background = pageBackground;
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
326
322
|
/**
|
|
327
323
|
* Get page width in pixels (96 DPI)
|
|
328
324
|
*
|
|
@@ -496,4 +492,4 @@ function mergeSectionProperties(base, override) {
|
|
|
496
492
|
return result;
|
|
497
493
|
}
|
|
498
494
|
//#endregion
|
|
499
|
-
export { getColumnCount, getContentHeightPixels, getContentWidthPixels, getDefaultSectionProperties, getMarginsPixels, getPageHeightPixels, getPageWidthPixels,
|
|
495
|
+
export { getColumnCount, getContentHeightPixels, getContentWidthPixels, getDefaultSectionProperties, getMarginsPixels, getPageHeightPixels, getPageWidthPixels, hasDifferentFirstPage, hasDifferentOddEven, hasLineNumbers, hasPageBorders, isLandscape, mergeSectionProperties, parseSectionProperties };
|
|
@@ -199,7 +199,8 @@ async function attemptSelectiveSave(doc, originalBuffer, options) {
|
|
|
199
199
|
const docXmlFile = zip.file("word/document.xml");
|
|
200
200
|
if (!docXmlFile) return null;
|
|
201
201
|
const originalDocXml = await docXmlFile.async("text");
|
|
202
|
-
const
|
|
202
|
+
const serializedDocXml = serializeDocument(doc, readRootNamespaceBindings(originalDocXml));
|
|
203
|
+
const bodyParaIds = collectParaIds(serializedDocXml);
|
|
203
204
|
const bodyChangedIds = /* @__PURE__ */ new Set();
|
|
204
205
|
const noteCandidateIds = /* @__PURE__ */ new Set();
|
|
205
206
|
for (const id of changedParaIds) if (bodyParaIds.has(id)) bodyChangedIds.add(id);
|
|
@@ -209,7 +210,7 @@ async function attemptSelectiveSave(doc, originalBuffer, options) {
|
|
|
209
210
|
if (unrouted === null || unrouted.size > 0) return null;
|
|
210
211
|
}
|
|
211
212
|
if (bodyChangedIds.size > 0) {
|
|
212
|
-
const patchedDocXml = buildPatchedDocumentXml(originalDocXml,
|
|
213
|
+
const patchedDocXml = buildPatchedDocumentXml(originalDocXml, serializedDocXml, bodyChangedIds);
|
|
213
214
|
if (!patchedDocXml) return null;
|
|
214
215
|
updates.set("word/document.xml", patchedDocXml);
|
|
215
216
|
}
|
|
@@ -54,6 +54,24 @@ type ParagraphOffsets = {
|
|
|
54
54
|
* function would return null.
|
|
55
55
|
*/
|
|
56
56
|
declare function buildParagraphOffsetIndex(xml: string): Map<string, ParagraphOffsets>;
|
|
57
|
+
/** One `<w:p>` of a part: its byte range and the paraId its open tag carries. */
|
|
58
|
+
type ScannedParagraph = ParagraphOffsets & {
|
|
59
|
+
paraId: string | undefined;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Every `<w:p>` element of `xml`, in the document order of its opening tags,
|
|
63
|
+
* with the `w14:paraId` that tag carries.
|
|
64
|
+
*
|
|
65
|
+
* Document order is what makes the array an ordinal space: the *n*th entry of
|
|
66
|
+
* the source part and the *n*th entry of the model's serialization name the
|
|
67
|
+
* same paragraph, which is the only way to address a paragraph the producer
|
|
68
|
+
* gave no id. A `<w:p>` nested inside another (inside `mc:AlternateContent`,
|
|
69
|
+
* a text box) is one entry of its own, exactly as
|
|
70
|
+
* {@link countParagraphElements} counts it, so the two never disagree about
|
|
71
|
+
* what an ordinal is. An unterminated paragraph keeps `end === start`: it
|
|
72
|
+
* occupies its ordinal but no splice can be built from it.
|
|
73
|
+
*/
|
|
74
|
+
declare function scanParagraphs(xml: string): ScannedParagraph[];
|
|
57
75
|
/**
|
|
58
76
|
* Count <w:p> elements in an XML string (top-level paragraph count).
|
|
59
77
|
* Counts opening <w:p tags that are NOT self-closing.
|
|
@@ -81,7 +99,8 @@ type PatchSafetyOptions = {
|
|
|
81
99
|
* Validate that a selective patch can be safely applied.
|
|
82
100
|
*
|
|
83
101
|
* Checks:
|
|
84
|
-
* -
|
|
102
|
+
* - Every changed paraId routes to one region of the original XML, by its
|
|
103
|
+
* authored id or, when the producer wrote none, by its paragraph ordinal
|
|
85
104
|
* - All changed paraIds exist in serialized XML (exactly once)
|
|
86
105
|
* - Paragraph count matches between original and serialized (unless disabled)
|
|
87
106
|
*/
|
|
@@ -222,4 +241,4 @@ declare const patchNumberingDefinitions: ({ originalXml, baselineXml, currentXml
|
|
|
222
241
|
*/
|
|
223
242
|
declare function appendNumberingDefs(xml: string, currentXml: string, added: ChangedNumberingDefs): string | null;
|
|
224
243
|
//#endregion
|
|
225
|
-
export { ChangedNumberingDefs, NotePartPatch, NotePartPatchRefusal, ParagraphOffsets, PatchSafetyOptions, PatchValidationResult, XmlSplice, appendNumberingDefs, buildParagraphOffsetIndex, buildPatchedDocumentXml, buildPatchedNotePartXml, buildPatchedNoteXml, buildPatchedNumberingXml, collectAddedNumberingDefs, collectChangedNoteParaIds, collectChangedNumberingDefs, collectParaIds, countParagraphElements, extractParagraphXml, findParagraphOffsets, isXmlNameBoundary, patchNumberingDefinitions, spliceXml, validatePatchSafety };
|
|
244
|
+
export { ChangedNumberingDefs, NotePartPatch, NotePartPatchRefusal, ParagraphOffsets, PatchSafetyOptions, PatchValidationResult, ScannedParagraph, XmlSplice, appendNumberingDefs, buildParagraphOffsetIndex, buildPatchedDocumentXml, buildPatchedNotePartXml, buildPatchedNoteXml, buildPatchedNumberingXml, collectAddedNumberingDefs, collectChangedNoteParaIds, collectChangedNumberingDefs, collectParaIds, countParagraphElements, extractParagraphXml, findParagraphOffsets, isXmlNameBoundary, patchNumberingDefinitions, scanParagraphs, spliceXml, validatePatchSafety };
|