@stll/folio-core 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +85 -43
- package/dist/ai-edits/headless.js +2 -2
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +17 -0
- package/dist/content-controls/checkboxDisplay.js +46 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +57 -43
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -18
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +113 -14
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +11 -21
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +76 -0
- package/dist/docx/attributeRemainder.js +111 -0
- package/dist/docx/blockContentParser.d.ts +3 -1
- package/dist/docx/blockContentParser.js +102 -106
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +3 -0
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +56 -39
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +3 -1
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/compatibility.js +56 -41
- package/dist/docx/containerChildren.d.ts +208 -0
- package/dist/docx/containerChildren.gen.d.ts +43 -0
- package/dist/docx/containerChildren.gen.js +263 -0
- package/dist/docx/containerChildren.js +153 -0
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +7 -4
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +66 -9
- package/dist/docx/hyperlinkParser.js +153 -26
- package/dist/docx/imageParser.js +160 -115
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +166 -0
- package/dist/docx/inlineWrapperContent.js +165 -0
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +12 -1
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +111 -0
- package/dist/docx/paraIdAttribute.js +142 -0
- package/dist/docx/paragraphParser.d.ts +10 -25
- package/dist/docx/paragraphParser.js +421 -496
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
- package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +53 -52
- package/dist/docx/parseWarningMessage.js +5 -1
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +96 -0
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +4 -6
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +152 -27
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +55 -19
- package/dist/docx/runParser.js +394 -306
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +241 -238
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +66 -3
- package/dist/docx/selectiveXmlPatch.js +276 -133
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +12 -10
- package/dist/docx/serializer/commentSerializer.js +5 -7
- package/dist/docx/serializer/documentSerializer.js +11 -11
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +10 -9
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +11 -8
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +156 -236
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +134 -75
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +283 -105
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +20 -16
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +13 -8
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +11 -2
- package/dist/docx/tableParser.js +665 -220
- package/dist/docx/textBoxParser.d.ts +28 -3
- package/dist/docx/textBoxParser.js +69 -9
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/unzip.js +5 -4
- package/dist/docx/vmlImageParser.d.ts +30 -5
- package/dist/docx/vmlImageParser.js +91 -32
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +23 -1
- package/dist/docx/xmlParser.js +31 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +12 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +267 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +69 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +10 -3
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +10 -4
- package/dist/layout-painter/renderParagraph.d.ts +14 -1
- package/dist/layout-painter/renderParagraph.js +34 -28
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +12 -4
- package/dist/markdown/renderBlock.js +3 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +34 -6
- package/dist/markdown/renderTable.js +24 -6
- package/dist/markdown/trailers.js +4 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +34 -5
- package/dist/prosemirror/attrs/index.js +639 -48
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +33 -20
- package/dist/prosemirror/commands/image.d.ts +10 -3
- package/dist/prosemirror/commands/image.js +46 -29
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
- package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +801 -411
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +14 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +65 -0
- package/dist/prosemirror/extensions/markRegistry.js +138 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +7 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +92 -0
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +183 -0
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +47 -4
- package/dist/prosemirror/schema/nodes.d.ts +309 -26
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +4 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +31 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
- package/dist/prosemirror/zeroWidthAnchors.js +6 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +27 -1
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +12 -20
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -0
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -50
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { NO_MODELLED_ATTRIBUTES, attributeRemainder } from "./attributeRemainder.js";
|
|
1
2
|
import { parseBorderSpec } from "./borderParser.js";
|
|
3
|
+
import { CAPTURE, dispatchChildren, keptUnless, sequencePositions } from "./containerChildren.js";
|
|
2
4
|
import { parseFooterReference, parseHeaderReference } from "./headerFooterRefParser.js";
|
|
3
5
|
import { parseEndnoteProperties, parseFootnoteProperties } from "./notePropertiesParser.js";
|
|
4
|
-
import { NumberFormatSchema,
|
|
6
|
+
import { NumberFormatSchema, TextDirectionSchema, narrowEnum } from "./parserEnums.js";
|
|
5
7
|
import { parseSectionReferenceHistory } from "./sectionReferenceHistory.js";
|
|
8
|
+
import { parseThemeColorAttribute } from "./themeColorAttribute.js";
|
|
6
9
|
import { parsePropertyChangeInfo } from "./trackedChangeInfo.js";
|
|
7
|
-
import { findChild, findChildren, getAttribute,
|
|
10
|
+
import { findChild, findChildren, getAttribute, parseBooleanElement, parseNumericAttribute, parseOnOffAttribute } from "./xmlParser.js";
|
|
8
11
|
//#region src/docx/sectionParser.ts
|
|
9
12
|
/**
|
|
10
13
|
* Sanity cap on `w:cols/@w:num`. Word's column picker tops out well below
|
|
@@ -18,37 +21,6 @@ const MAX_SECTION_COLUMNS = 45;
|
|
|
18
21
|
* ruler tick generators, which are sized off the page dimensions.
|
|
19
22
|
*/
|
|
20
23
|
const MAX_PAGE_DIMENSION_TWIPS = 31680;
|
|
21
|
-
const serializedSectionPropertyChildNames = /* @__PURE__ */ new Set([
|
|
22
|
-
"headerReference",
|
|
23
|
-
"footerReference",
|
|
24
|
-
"footnotePr",
|
|
25
|
-
"footnoteColumns",
|
|
26
|
-
"endnotePr",
|
|
27
|
-
"type",
|
|
28
|
-
"pgSz",
|
|
29
|
-
"pgMar",
|
|
30
|
-
"paperSrc",
|
|
31
|
-
"pgBorders",
|
|
32
|
-
"background",
|
|
33
|
-
"lnNumType",
|
|
34
|
-
"pgNumType",
|
|
35
|
-
"cols",
|
|
36
|
-
"formProt",
|
|
37
|
-
"vAlign",
|
|
38
|
-
"noEndnote",
|
|
39
|
-
"titlePg",
|
|
40
|
-
"textDirection",
|
|
41
|
-
"bidi",
|
|
42
|
-
"rtlGutter",
|
|
43
|
-
"docGrid",
|
|
44
|
-
"printerSettings",
|
|
45
|
-
"sectPrChange"
|
|
46
|
-
]);
|
|
47
|
-
const unserializedSectionPropertyChildNames = Symbol("unserializedSectionPropertyChildNames");
|
|
48
|
-
function getUnserializedSectionPropertyChildNames(props) {
|
|
49
|
-
const descriptor = Object.getOwnPropertyDescriptor(props, unserializedSectionPropertyChildNames);
|
|
50
|
-
return Array.isArray(descriptor?.value) ? descriptor.value : void 0;
|
|
51
|
-
}
|
|
52
24
|
/**
|
|
53
25
|
* Parse page orientation
|
|
54
26
|
*/
|
|
@@ -84,23 +56,6 @@ function parseVerticalAlign(align) {
|
|
|
84
56
|
default: return;
|
|
85
57
|
}
|
|
86
58
|
}
|
|
87
|
-
function parseTextDirection(val) {
|
|
88
|
-
switch (val) {
|
|
89
|
-
case "lrTb":
|
|
90
|
-
case "tbRl":
|
|
91
|
-
case "btLr":
|
|
92
|
-
case "lrTbV":
|
|
93
|
-
case "tbRlV":
|
|
94
|
-
case "tbLrV":
|
|
95
|
-
case "tb":
|
|
96
|
-
case "rl":
|
|
97
|
-
case "lr":
|
|
98
|
-
case "tbV":
|
|
99
|
-
case "rlV":
|
|
100
|
-
case "lrV": return val;
|
|
101
|
-
default: return;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
59
|
/**
|
|
105
60
|
* Parse line number restart type
|
|
106
61
|
*/
|
|
@@ -121,201 +76,249 @@ function parseLineNumberRestart(restart) {
|
|
|
121
76
|
function parseSectionProperties(sectPr, context) {
|
|
122
77
|
const props = {};
|
|
123
78
|
if (!sectPr) return props;
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
|
|
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
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
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);
|
|
173
243
|
}
|
|
174
|
-
if (props.columnCount === void 0) props.columnCount = colElements.length;
|
|
175
244
|
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (typeEl) {
|
|
179
|
-
const sectionStart = parseSectionStart(getAttribute(typeEl, "w", "val"));
|
|
180
|
-
if (sectionStart) props.sectionStart = sectionStart;
|
|
181
|
-
}
|
|
182
|
-
const vAlign = findChild(sectPr, "w", "vAlign");
|
|
183
|
-
if (vAlign) {
|
|
184
|
-
const verticalAlign = parseVerticalAlign(getAttribute(vAlign, "w", "val"));
|
|
185
|
-
if (verticalAlign) props.verticalAlign = verticalAlign;
|
|
186
|
-
}
|
|
187
|
-
const textDirection = findChild(sectPr, "w", "textDirection");
|
|
188
|
-
if (textDirection) {
|
|
189
|
-
const textDirectionValue = parseTextDirection(getAttribute(textDirection, "w", "val"));
|
|
190
|
-
if (textDirectionValue) props.textDirection = textDirectionValue;
|
|
191
|
-
else addUnhandledChildName("textDirection");
|
|
192
|
-
}
|
|
193
|
-
const bidi = findChild(sectPr, "w", "bidi");
|
|
194
|
-
if (bidi) props.bidi = parseBooleanElement(bidi, "w", context);
|
|
195
|
-
const headerRefs = findChildren(sectPr, "w", "headerReference").flatMap((el) => parseHeaderReference(el, context) ?? []);
|
|
245
|
+
});
|
|
246
|
+
if (preserved) props.preserved = preserved;
|
|
196
247
|
if (headerRefs.length > 0) props.headerReferences = headerRefs;
|
|
197
|
-
const footerRefs = findChildren(sectPr, "w", "footerReference").flatMap((el) => parseFooterReference(el, context) ?? []);
|
|
198
248
|
if (footerRefs.length > 0) props.footerReferences = footerRefs;
|
|
199
|
-
const titlePg = findChild(sectPr, "w", "titlePg");
|
|
200
|
-
if (titlePg) props.titlePg = parseBooleanElement(titlePg, "w", context);
|
|
201
|
-
const evenAndOddHeaders = findChild(sectPr, "w", "evenAndOddHeaders");
|
|
202
|
-
if (evenAndOddHeaders) props.evenAndOddHeaders = parseBooleanElement(evenAndOddHeaders, "w", context);
|
|
203
|
-
const lnNumType = findChild(sectPr, "w", "lnNumType");
|
|
204
|
-
if (lnNumType) {
|
|
205
|
-
props.lineNumbers = {};
|
|
206
|
-
const start = parseNumericAttribute(lnNumType, "w", "start");
|
|
207
|
-
if (start !== void 0) props.lineNumbers.start = start;
|
|
208
|
-
const countBy = parseNumericAttribute(lnNumType, "w", "countBy");
|
|
209
|
-
if (countBy !== void 0) props.lineNumbers.countBy = countBy;
|
|
210
|
-
const distance = parseNumericAttribute(lnNumType, "w", "distance");
|
|
211
|
-
if (distance !== void 0) props.lineNumbers.distance = distance;
|
|
212
|
-
const restartValue = parseLineNumberRestart(getAttribute(lnNumType, "w", "restart"));
|
|
213
|
-
if (restartValue) props.lineNumbers.restart = restartValue;
|
|
214
|
-
}
|
|
215
|
-
const pgNumType = findChild(sectPr, "w", "pgNumType");
|
|
216
|
-
if (pgNumType) {
|
|
217
|
-
const pageNumbering = {};
|
|
218
|
-
const format = narrowEnum(getAttribute(pgNumType, "w", "fmt"), NumberFormatSchema);
|
|
219
|
-
if (format) pageNumbering.format = format;
|
|
220
|
-
const start = parseNumericAttribute(pgNumType, "w", "start");
|
|
221
|
-
if (start !== void 0) pageNumbering.start = start;
|
|
222
|
-
const chapterStyle = parseNumericAttribute(pgNumType, "w", "chapStyle");
|
|
223
|
-
if (chapterStyle !== void 0) pageNumbering.chapterStyle = chapterStyle;
|
|
224
|
-
const chapterSeparator = getAttribute(pgNumType, "w", "chapSep");
|
|
225
|
-
if (chapterSeparator) pageNumbering.chapterSeparator = chapterSeparator;
|
|
226
|
-
if (Object.keys(pageNumbering).length > 0) props.pageNumbering = pageNumbering;
|
|
227
|
-
}
|
|
228
|
-
const pgBorders = findChild(sectPr, "w", "pgBorders");
|
|
229
|
-
if (pgBorders) {
|
|
230
|
-
props.pageBorders = {};
|
|
231
|
-
const topBorder = parseBorderSpec(findChild(pgBorders, "w", "top"), context);
|
|
232
|
-
if (topBorder) props.pageBorders.top = topBorder;
|
|
233
|
-
const bottomBorder = parseBorderSpec(findChild(pgBorders, "w", "bottom"), context);
|
|
234
|
-
if (bottomBorder) props.pageBorders.bottom = bottomBorder;
|
|
235
|
-
const leftBorder = parseBorderSpec(findChild(pgBorders, "w", "left"), context);
|
|
236
|
-
if (leftBorder) props.pageBorders.left = leftBorder;
|
|
237
|
-
const rightBorder = parseBorderSpec(findChild(pgBorders, "w", "right"), context);
|
|
238
|
-
if (rightBorder) props.pageBorders.right = rightBorder;
|
|
239
|
-
const display = getAttribute(pgBorders, "w", "display");
|
|
240
|
-
if (display === "allPages" || display === "firstPage" || display === "notFirstPage") props.pageBorders.display = display;
|
|
241
|
-
const offsetFrom = getAttribute(pgBorders, "w", "offsetFrom");
|
|
242
|
-
if (offsetFrom === "page" || offsetFrom === "text") props.pageBorders.offsetFrom = offsetFrom;
|
|
243
|
-
const zOrder = getAttribute(pgBorders, "w", "zOrder");
|
|
244
|
-
if (zOrder === "front" || zOrder === "back") props.pageBorders.zOrder = zOrder;
|
|
245
|
-
}
|
|
246
|
-
const background = findChild(sectPr, "w", "background");
|
|
247
|
-
if (background) {
|
|
248
|
-
props.background = {};
|
|
249
|
-
const colorVal = getAttribute(background, "w", "color");
|
|
250
|
-
if (colorVal && colorVal !== "auto") props.background.color = { rgb: colorVal };
|
|
251
|
-
const backgroundThemeColor = narrowEnum(getAttribute(background, "w", "themeColor"), ThemeColorSlotSchema);
|
|
252
|
-
if (backgroundThemeColor) props.background.themeColor = backgroundThemeColor;
|
|
253
|
-
const themeTint = getAttribute(background, "w", "themeTint");
|
|
254
|
-
if (themeTint) props.background.themeTint = themeTint;
|
|
255
|
-
const themeShade = getAttribute(background, "w", "themeShade");
|
|
256
|
-
if (themeShade) props.background.themeShade = themeShade;
|
|
257
|
-
}
|
|
258
|
-
const footnotePr = findChild(sectPr, "w", "footnotePr");
|
|
259
|
-
if (footnotePr) {
|
|
260
|
-
const fnProps = parseFootnoteProperties(footnotePr);
|
|
261
|
-
if (Object.keys(fnProps).length > 0) props.footnotePr = fnProps;
|
|
262
|
-
}
|
|
263
|
-
const footnoteColumns = findChild(sectPr, "w15", "footnoteColumns");
|
|
264
|
-
if (footnoteColumns) {
|
|
265
|
-
const columns = parseNumericAttribute(footnoteColumns, "w", "val");
|
|
266
|
-
if (columns !== void 0) props.footnoteColumns = columns;
|
|
267
|
-
}
|
|
268
|
-
const endnotePr = findChild(sectPr, "w", "endnotePr");
|
|
269
|
-
if (endnotePr) {
|
|
270
|
-
const enProps = parseEndnoteProperties(endnotePr);
|
|
271
|
-
if (Object.keys(enProps).length > 0) props.endnotePr = enProps;
|
|
272
|
-
}
|
|
273
|
-
const formProt = findChild(sectPr, "w", "formProt");
|
|
274
|
-
if (formProt) props.formProtection = parseBooleanElement(formProt, "w", context);
|
|
275
|
-
const noEndnote = findChild(sectPr, "w", "noEndnote");
|
|
276
|
-
if (noEndnote) props.noEndnote = parseBooleanElement(noEndnote, "w", context);
|
|
277
|
-
const rtlGutter = findChild(sectPr, "w", "rtlGutter");
|
|
278
|
-
if (rtlGutter) props.rtlGutter = parseBooleanElement(rtlGutter, "w", context);
|
|
279
|
-
const docGrid = findChild(sectPr, "w", "docGrid");
|
|
280
|
-
if (docGrid) {
|
|
281
|
-
props.docGrid = {};
|
|
282
|
-
const gridType = getAttribute(docGrid, "w", "type");
|
|
283
|
-
if (gridType === "default" || gridType === "lines" || gridType === "linesAndChars" || gridType === "snapToChars") props.docGrid.type = gridType;
|
|
284
|
-
const linePitch = parseNumericAttribute(docGrid, "w", "linePitch");
|
|
285
|
-
if (linePitch !== void 0) props.docGrid.linePitch = linePitch;
|
|
286
|
-
const charSpace = parseNumericAttribute(docGrid, "w", "charSpace");
|
|
287
|
-
if (charSpace !== void 0) props.docGrid.charSpace = charSpace;
|
|
288
|
-
}
|
|
289
|
-
const paperSrc = findChild(sectPr, "w", "paperSrc");
|
|
290
|
-
if (paperSrc) {
|
|
291
|
-
const first = parseNumericAttribute(paperSrc, "w", "first");
|
|
292
|
-
if (first !== void 0) props.paperSrcFirst = first;
|
|
293
|
-
const other = parseNumericAttribute(paperSrc, "w", "other");
|
|
294
|
-
if (other !== void 0) props.paperSrcOther = other;
|
|
295
|
-
}
|
|
296
|
-
const printerSettings = findChild(sectPr, "w", "printerSettings");
|
|
297
|
-
if (printerSettings) {
|
|
298
|
-
const relationshipId = getAttribute(printerSettings, "r", "id");
|
|
299
|
-
if (relationshipId) props.printerSettingsRelationshipId = relationshipId;
|
|
300
|
-
}
|
|
301
|
-
const propertyChanges = findChildren(sectPr, "w", "sectPrChange").map((changeElement) => {
|
|
302
|
-
const previousSectPr = findChild(changeElement, "w", "sectPr");
|
|
303
|
-
const change = {
|
|
304
|
-
type: "sectionPropertyChange",
|
|
305
|
-
info: parsePropertyChangeInfo(changeElement)
|
|
306
|
-
};
|
|
307
|
-
if (previousSectPr) change.previousProperties = parseSectionProperties(previousSectPr);
|
|
308
|
-
const previousReferences = parseSectionReferenceHistory(changeElement);
|
|
309
|
-
if (previousReferences !== void 0) change.previousReferences = previousReferences;
|
|
310
|
-
return change;
|
|
311
|
-
});
|
|
312
249
|
if (propertyChanges.length > 0) props.propertyChanges = propertyChanges;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
250
|
+
const remainder = attributeRemainder({
|
|
251
|
+
element: sectPr,
|
|
252
|
+
modelled: NO_MODELLED_ATTRIBUTES
|
|
316
253
|
});
|
|
254
|
+
if (remainder) props.preservedAttributes = remainder;
|
|
317
255
|
return props;
|
|
318
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
|
+
}
|
|
319
322
|
/**
|
|
320
323
|
* Get page width in pixels (96 DPI)
|
|
321
324
|
*
|
|
@@ -489,4 +492,4 @@ function mergeSectionProperties(base, override) {
|
|
|
489
492
|
return result;
|
|
490
493
|
}
|
|
491
494
|
//#endregion
|
|
492
|
-
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
|
*/
|
|
@@ -109,6 +128,24 @@ declare function buildPatchedDocumentXml(originalXml: string, serializedXml: str
|
|
|
109
128
|
* the caller can fall back to preserving the original part verbatim.
|
|
110
129
|
*/
|
|
111
130
|
declare function buildPatchedNoteXml(originalXml: string, serializedXml: string, changedIds: Set<string>): string | null;
|
|
131
|
+
/** One region of a part replaced by re-serialized XML. */
|
|
132
|
+
type XmlSplice = {
|
|
133
|
+
start: number;
|
|
134
|
+
end: number;
|
|
135
|
+
newXml: string;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Apply `splices` to `xml`, end-to-start so earlier offsets stay valid.
|
|
139
|
+
*
|
|
140
|
+
* Every selective patch is a splice, and every splice goes through here, so
|
|
141
|
+
* the refusal below is a property of the operation rather than a check each
|
|
142
|
+
* site has to remember. A patch rewrites the regions an edit touched and keeps
|
|
143
|
+
* the rest of the part byte-for-byte, so it can write half a comment range:
|
|
144
|
+
* invalid OOXML that anchors the comment to nothing. Answers null when it
|
|
145
|
+
* would, leaving the caller to rewrite a wider region — ultimately the whole
|
|
146
|
+
* part from the model, which is balanced with itself.
|
|
147
|
+
*/
|
|
148
|
+
declare const spliceXml: (xml: string, splices: readonly XmlSplice[]) => string | null;
|
|
112
149
|
type NoteElementName = "footnote" | "endnote";
|
|
113
150
|
declare const collectChangedNoteParaIds: (baselineXml: string, currentXml: string) => Set<string>;
|
|
114
151
|
type BuildPatchedNotePartXmlOptions = {
|
|
@@ -119,6 +156,25 @@ type BuildPatchedNotePartXmlOptions = {
|
|
|
119
156
|
elementName: NoteElementName;
|
|
120
157
|
changedParaIds?: ReadonlySet<string>;
|
|
121
158
|
};
|
|
159
|
+
/** Why a note part could not be patched; see {@link NotePartPatch}. */
|
|
160
|
+
type NotePartPatchRefusal =
|
|
161
|
+
/** A note element, or a changed paragraph, was missing or ambiguous. */
|
|
162
|
+
"unroutable-paragraph" |
|
|
163
|
+
/** Even rewriting whole notes would leave a comment range with one half. */
|
|
164
|
+
"comment-range-balance";
|
|
165
|
+
/**
|
|
166
|
+
* What patching a note part produced. `refused` is not a failure to serialize:
|
|
167
|
+
* the caller writes the part from the model instead, the note-part reading of
|
|
168
|
+
* the fall back to a full repack the document story takes when its own splice
|
|
169
|
+
* is refused.
|
|
170
|
+
*/
|
|
171
|
+
type NotePartPatch = {
|
|
172
|
+
type: "patched";
|
|
173
|
+
xml: string;
|
|
174
|
+
} | {
|
|
175
|
+
type: "refused";
|
|
176
|
+
reason: NotePartPatchRefusal;
|
|
177
|
+
};
|
|
122
178
|
/**
|
|
123
179
|
* Patch an existing note part from its model serialization.
|
|
124
180
|
*
|
|
@@ -130,8 +186,15 @@ type BuildPatchedNotePartXmlOptions = {
|
|
|
130
186
|
* notes, and unaffected equal-shape paragraphs remain byte-exact.
|
|
131
187
|
* `replacementXml` also supplies synthesized automatic note-reference marks,
|
|
132
188
|
* which the parsed model intentionally omits.
|
|
189
|
+
*
|
|
190
|
+
* A comment can be anchored on a note's own text, so its range spans that
|
|
191
|
+
* note's paragraphs and an edit inside the span moves a range half from one
|
|
192
|
+
* paragraph to another. Replacing only the dirty paragraph then drops the half
|
|
193
|
+
* it held and leaves the other standing, so {@link spliceXml} refuses the
|
|
194
|
+
* result and the changed notes are rewritten whole instead — model content on
|
|
195
|
+
* both sides of the range, with every other note still byte-exact.
|
|
133
196
|
*/
|
|
134
|
-
declare function buildPatchedNotePartXml({ originalXml, baselineXml, serializedXml, replacementXml, elementName, changedParaIds }: BuildPatchedNotePartXmlOptions):
|
|
197
|
+
declare function buildPatchedNotePartXml({ originalXml, baselineXml, serializedXml, replacementXml, elementName, changedParaIds }: BuildPatchedNotePartXmlOptions): NotePartPatch;
|
|
135
198
|
type ChangedNumberingDefs = {
|
|
136
199
|
abstractNums: Set<string>;
|
|
137
200
|
nums: Set<string>;
|
|
@@ -178,4 +241,4 @@ declare const patchNumberingDefinitions: ({ originalXml, baselineXml, currentXml
|
|
|
178
241
|
*/
|
|
179
242
|
declare function appendNumberingDefs(xml: string, currentXml: string, added: ChangedNumberingDefs): string | null;
|
|
180
243
|
//#endregion
|
|
181
|
-
export { ChangedNumberingDefs, ParagraphOffsets, PatchSafetyOptions, PatchValidationResult, appendNumberingDefs, buildParagraphOffsetIndex, buildPatchedDocumentXml, buildPatchedNotePartXml, buildPatchedNoteXml, buildPatchedNumberingXml, collectAddedNumberingDefs, collectChangedNoteParaIds, collectChangedNumberingDefs, collectParaIds, countParagraphElements, extractParagraphXml, findParagraphOffsets, isXmlNameBoundary, patchNumberingDefinitions, 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 };
|