@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,8 +1,11 @@
|
|
|
1
1
|
import { HIGHLIGHT_COLOR_VALUES } from "../../types/documentEnumValues.js";
|
|
2
2
|
import { isValidHexColor } from "../../utils/colorResolver.js";
|
|
3
3
|
import { roundHorizontalScalePercentForSerialization } from "../../utils/horizontalScale.js";
|
|
4
|
+
import { serializePreservedAttributes } from "../attributeRemainder.js";
|
|
4
5
|
import { intAttr } from "./xmlUtils.js";
|
|
5
|
-
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
6
|
+
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
7
|
+
import { themeColorToken } from "@stll/docx-core/model";
|
|
8
|
+
import { serializeSequenceChildren } from "@stll/docx-core/schema";
|
|
6
9
|
//#region src/docx/serializer/textFormattingSerializer.ts
|
|
7
10
|
const VALID_HIGHLIGHT_COLORS = new Set(HIGHLIGHT_COLOR_VALUES);
|
|
8
11
|
/**
|
|
@@ -14,7 +17,7 @@ function serializeColorElement(color) {
|
|
|
14
17
|
const attrs = [];
|
|
15
18
|
if (auto) attrs.push("w:val=\"auto\"");
|
|
16
19
|
else if (rgb && isValidHexColor(rgb)) attrs.push(`w:val="${escapeXmlAttribute(rgb)}"`);
|
|
17
|
-
if (themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColor)}"`);
|
|
20
|
+
if (themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColorToken(themeColor))}"`);
|
|
18
21
|
if (themeTint) attrs.push(`w:themeTint="${escapeXmlAttribute(themeTint)}"`);
|
|
19
22
|
if (themeShade) attrs.push(`w:themeShade="${escapeXmlAttribute(themeShade)}"`);
|
|
20
23
|
return attrs.length === 0 ? "" : `<w:color ${attrs.join(" ")}/>`;
|
|
@@ -24,122 +27,129 @@ function serializeColorElement(color) {
|
|
|
24
27
|
*/
|
|
25
28
|
function serializeShading(shading) {
|
|
26
29
|
if (!shading) return "";
|
|
27
|
-
const { pattern, color, fill } = shading;
|
|
30
|
+
const { pattern, color, fill, preservedAttributes } = shading;
|
|
28
31
|
const attrs = [];
|
|
29
32
|
if (pattern) attrs.push(`w:val="${escapeXmlAttribute(pattern)}"`);
|
|
30
33
|
else attrs.push("w:val=\"clear\"");
|
|
31
34
|
if (color) {
|
|
32
|
-
const { rgb, auto, themeColor
|
|
35
|
+
const { rgb, auto, themeColor, themeTint, themeShade } = color;
|
|
33
36
|
if (rgb && isValidHexColor(rgb)) attrs.push(`w:color="${escapeXmlAttribute(rgb)}"`);
|
|
34
37
|
else if (auto) attrs.push("w:color=\"auto\"");
|
|
38
|
+
if (themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColorToken(themeColor))}"`);
|
|
39
|
+
if (themeTint) attrs.push(`w:themeTint="${escapeXmlAttribute(themeTint)}"`);
|
|
40
|
+
if (themeShade) attrs.push(`w:themeShade="${escapeXmlAttribute(themeShade)}"`);
|
|
35
41
|
}
|
|
36
42
|
if (fill) {
|
|
37
43
|
const { rgb, auto, themeColor, themeTint, themeShade } = fill;
|
|
38
44
|
if (rgb && isValidHexColor(rgb)) attrs.push(`w:fill="${escapeXmlAttribute(rgb)}"`);
|
|
39
45
|
else if (auto) attrs.push("w:fill=\"auto\"");
|
|
40
|
-
if (themeColor) attrs.push(`w:themeFill="${escapeXmlAttribute(themeColor)}"`);
|
|
46
|
+
if (themeColor) attrs.push(`w:themeFill="${escapeXmlAttribute(themeColorToken(themeColor))}"`);
|
|
41
47
|
if (themeTint) attrs.push(`w:themeFillTint="${escapeXmlAttribute(themeTint)}"`);
|
|
42
48
|
if (themeShade) attrs.push(`w:themeFillShade="${escapeXmlAttribute(themeShade)}"`);
|
|
43
49
|
}
|
|
44
|
-
|
|
50
|
+
const written = serializePreservedAttributes(attrs, preservedAttributes);
|
|
51
|
+
return written.length === 0 ? "" : `<w:shd ${written.join(" ")}/>`;
|
|
45
52
|
}
|
|
53
|
+
const numberTag = (name, value) => value === void 0 ? "" : `<w:${name} w:val="${intAttr(value)}"/>`;
|
|
54
|
+
const serializeFontFamily = (fontFamily) => {
|
|
55
|
+
if (!fontFamily) return "";
|
|
56
|
+
const { ascii, hAnsi, eastAsia, cs: complexScript, hint, asciiTheme, hAnsiTheme, eastAsiaTheme, csTheme } = fontFamily;
|
|
57
|
+
const attrs = [];
|
|
58
|
+
if (ascii) attrs.push(`w:ascii="${escapeXmlAttribute(ascii)}"`);
|
|
59
|
+
if (hAnsi) attrs.push(`w:hAnsi="${escapeXmlAttribute(hAnsi)}"`);
|
|
60
|
+
if (eastAsia) attrs.push(`w:eastAsia="${escapeXmlAttribute(eastAsia)}"`);
|
|
61
|
+
if (complexScript) attrs.push(`w:cs="${escapeXmlAttribute(complexScript)}"`);
|
|
62
|
+
if (hint) attrs.push(`w:hint="${escapeXmlAttribute(hint)}"`);
|
|
63
|
+
if (asciiTheme) attrs.push(`w:asciiTheme="${escapeXmlAttribute(asciiTheme)}"`);
|
|
64
|
+
if (hAnsiTheme) attrs.push(`w:hAnsiTheme="${escapeXmlAttribute(hAnsiTheme)}"`);
|
|
65
|
+
if (eastAsiaTheme) attrs.push(`w:eastAsiaTheme="${escapeXmlAttribute(eastAsiaTheme)}"`);
|
|
66
|
+
if (csTheme) attrs.push(`w:cstheme="${escapeXmlAttribute(csTheme)}"`);
|
|
67
|
+
return attrs.length === 0 ? "" : `<w:rFonts ${attrs.join(" ")}/>`;
|
|
68
|
+
};
|
|
69
|
+
const serializeUnderline = (underline) => {
|
|
70
|
+
if (!underline) return "";
|
|
71
|
+
const { style, color } = underline;
|
|
72
|
+
const attrs = [`w:val="${style}"`];
|
|
73
|
+
if (color) {
|
|
74
|
+
const { rgb, themeColor, themeTint, themeShade, auto: _auto } = color;
|
|
75
|
+
if (rgb && isValidHexColor(rgb)) attrs.push(`w:color="${escapeXmlAttribute(rgb)}"`);
|
|
76
|
+
if (themeColor) attrs.push(`w:themeColor="${escapeXmlAttribute(themeColorToken(themeColor))}"`);
|
|
77
|
+
if (themeTint) attrs.push(`w:themeTint="${escapeXmlAttribute(themeTint)}"`);
|
|
78
|
+
if (themeShade) attrs.push(`w:themeShade="${escapeXmlAttribute(themeShade)}"`);
|
|
79
|
+
}
|
|
80
|
+
return `<w:u ${attrs.join(" ")}/>`;
|
|
81
|
+
};
|
|
82
|
+
const serializeLanguage = (language) => {
|
|
83
|
+
if (!language) return "";
|
|
84
|
+
const { val, eastAsia, bidi } = language;
|
|
85
|
+
const attrs = [];
|
|
86
|
+
if (val) attrs.push(`w:val="${escapeXmlAttribute(val)}"`);
|
|
87
|
+
if (eastAsia) attrs.push(`w:eastAsia="${escapeXmlAttribute(eastAsia)}"`);
|
|
88
|
+
if (bidi) attrs.push(`w:bidi="${escapeXmlAttribute(bidi)}"`);
|
|
89
|
+
return attrs.length === 0 ? "" : `<w:lang ${attrs.join(" ")}/>`;
|
|
90
|
+
};
|
|
46
91
|
/**
|
|
47
|
-
*
|
|
92
|
+
* The single `w:rPr` writer.
|
|
93
|
+
*
|
|
94
|
+
* A run, the paragraph mark, a style, a numbering level and the snapshot
|
|
95
|
+
* inside either kind of `w:rPrChange` all write their run properties through
|
|
96
|
+
* here, so none of them can grow its own order or its own idea of which
|
|
97
|
+
* children exist. `EG_RPrBase` is an `xsd:choice` referenced
|
|
98
|
+
* `maxOccurs="unbounded"`, so a `w:rPr` in any order is valid and the order
|
|
99
|
+
* below is a canonical form rather than a validity rule: it is the one Word
|
|
100
|
+
* writes, and writing it from the generated declared-child list is what stops
|
|
101
|
+
* two of folio's serializers from disagreeing. The restatement is what
|
|
102
|
+
* drifted, and it is why folio wrote `w:vanish` before `w:noProof` while the
|
|
103
|
+
* schema declares the reverse.
|
|
104
|
+
*
|
|
105
|
+
* @param owned children a sibling record holds; see {@link OwnedRunPropertyChild}
|
|
48
106
|
*/
|
|
49
|
-
function serializeTextFormatting(input) {
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
else if (noProof === false) parts.push("<w:noProof w:val=\"0\"/>");
|
|
96
|
-
const colorXml = serializeColorElement(color);
|
|
97
|
-
if (colorXml) parts.push(colorXml);
|
|
98
|
-
if (spacing !== void 0) parts.push(`<w:spacing w:val="${intAttr(spacing)}"/>`);
|
|
99
|
-
const horizontalScale = roundHorizontalScalePercentForSerialization(scale);
|
|
100
|
-
if (horizontalScale !== void 0) parts.push(`<w:w w:val="${intAttr(horizontalScale)}"/>`);
|
|
101
|
-
if (kerning !== void 0) parts.push(`<w:kern w:val="${intAttr(kerning)}"/>`);
|
|
102
|
-
if (position !== void 0) parts.push(`<w:position w:val="${intAttr(position)}"/>`);
|
|
103
|
-
if (fontSize !== void 0) parts.push(`<w:sz w:val="${intAttr(fontSize)}"/>`);
|
|
104
|
-
if (fontSizeCs !== void 0) parts.push(`<w:szCs w:val="${intAttr(fontSizeCs)}"/>`);
|
|
105
|
-
let customHighlightShadingXml = "";
|
|
106
|
-
if (highlight) {
|
|
107
|
-
if (VALID_HIGHLIGHT_COLORS.has(highlight)) parts.push(`<w:highlight w:val="${highlight}"/>`);
|
|
108
|
-
else if (!shading) {
|
|
109
|
-
const hex = highlight.replace(/^#/u, "");
|
|
110
|
-
if (/^[0-9a-fA-F]{6}$/u.test(hex)) customHighlightShadingXml = `<w:shd w:val="clear" w:color="auto" w:fill="${hex}"/>`;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (underline) {
|
|
114
|
-
const { style, color: underlineColor } = underline;
|
|
115
|
-
const uAttrs = [`w:val="${style}"`];
|
|
116
|
-
if (underlineColor) {
|
|
117
|
-
const { rgb, themeColor, themeTint, themeShade, auto: _auto } = underlineColor;
|
|
118
|
-
if (rgb && isValidHexColor(rgb)) uAttrs.push(`w:color="${escapeXmlAttribute(rgb)}"`);
|
|
119
|
-
if (themeColor) uAttrs.push(`w:themeColor="${escapeXmlAttribute(themeColor)}"`);
|
|
120
|
-
if (themeTint) uAttrs.push(`w:themeTint="${escapeXmlAttribute(themeTint)}"`);
|
|
121
|
-
if (themeShade) uAttrs.push(`w:themeShade="${escapeXmlAttribute(themeShade)}"`);
|
|
122
|
-
}
|
|
123
|
-
parts.push(`<w:u ${uAttrs.join(" ")}/>`);
|
|
124
|
-
}
|
|
125
|
-
if (effect) parts.push(`<w:effect w:val="${effect}"/>`);
|
|
126
|
-
const shadingXml = serializeShading(shading) || customHighlightShadingXml;
|
|
127
|
-
if (shadingXml) parts.push(shadingXml);
|
|
128
|
-
if (vertAlign) parts.push(`<w:vertAlign w:val="${vertAlign}"/>`);
|
|
129
|
-
if (rtl === true) parts.push("<w:rtl/>");
|
|
130
|
-
else if (rtl === false) parts.push("<w:rtl w:val=\"0\"/>");
|
|
131
|
-
if (cs === true) parts.push("<w:cs/>");
|
|
132
|
-
else if (cs === false) parts.push("<w:cs w:val=\"0\"/>");
|
|
133
|
-
if (emphasisMark) parts.push(`<w:em w:val="${emphasisMark}"/>`);
|
|
134
|
-
if (language) {
|
|
135
|
-
const { val, eastAsia, bidi } = language;
|
|
136
|
-
const languageAttrs = [];
|
|
137
|
-
if (val) languageAttrs.push(`w:val="${escapeXmlAttribute(val)}"`);
|
|
138
|
-
if (eastAsia) languageAttrs.push(`w:eastAsia="${escapeXmlAttribute(eastAsia)}"`);
|
|
139
|
-
if (bidi) languageAttrs.push(`w:bidi="${escapeXmlAttribute(bidi)}"`);
|
|
140
|
-
if (languageAttrs.length > 0) parts.push(`<w:lang ${languageAttrs.join(" ")}/>`);
|
|
141
|
-
}
|
|
142
|
-
return parts.length === 0 ? "" : `<w:rPr>${parts.join("")}</w:rPr>`;
|
|
107
|
+
function serializeTextFormatting(input, owned = []) {
|
|
108
|
+
const { bold, boldCs, italic, italicCs, underline, strike, doubleStrike, vertAlign, smallCaps, allCaps, hidden, noProof, color, highlight, shading, fontSize, fontSizeCs, fontFamily, language, spacing, position, scale, kerning, effect, emphasisMark, emboss, imprint, outline, shadow, rtl, cs, styleId, preserved } = input ?? {};
|
|
109
|
+
const namedHighlight = highlight && VALID_HIGHLIGHT_COLORS.has(highlight) ? highlight : void 0;
|
|
110
|
+
const customHighlightHex = highlight && !namedHighlight && !shading ? highlight.replace(/^#/u, "") : "";
|
|
111
|
+
const customHighlightShadingXml = /^[0-9a-fA-F]{6}$/u.test(customHighlightHex) ? `<w:shd w:val="clear" w:color="auto" w:fill="${customHighlightHex}"/>` : "";
|
|
112
|
+
const parts = serializeSequenceChildren({
|
|
113
|
+
container: "run-properties",
|
|
114
|
+
modelled: [
|
|
115
|
+
...owned,
|
|
116
|
+
["rStyle", styleId ? `<w:rStyle w:val="${escapeXmlAttribute(styleId)}"/>` : ""],
|
|
117
|
+
["rFonts", serializeFontFamily(fontFamily)],
|
|
118
|
+
["b", serializeOnOffElement(bold, "b")],
|
|
119
|
+
["bCs", serializeOnOffElement(boldCs, "bCs")],
|
|
120
|
+
["i", serializeOnOffElement(italic, "i")],
|
|
121
|
+
["iCs", serializeOnOffElement(italicCs, "iCs")],
|
|
122
|
+
["caps", serializeOnOffElement(allCaps, "caps")],
|
|
123
|
+
["smallCaps", serializeOnOffElement(smallCaps, "smallCaps")],
|
|
124
|
+
["strike", serializeOnOffElement(strike, "strike")],
|
|
125
|
+
["dstrike", serializeOnOffElement(doubleStrike, "dstrike")],
|
|
126
|
+
["outline", serializeOnOffElement(outline, "outline")],
|
|
127
|
+
["shadow", serializeOnOffElement(shadow, "shadow")],
|
|
128
|
+
["emboss", serializeOnOffElement(emboss, "emboss")],
|
|
129
|
+
["imprint", serializeOnOffElement(imprint, "imprint")],
|
|
130
|
+
["noProof", serializeOnOffElement(noProof, "noProof")],
|
|
131
|
+
["vanish", serializeOnOffElement(hidden, "vanish")],
|
|
132
|
+
["color", serializeColorElement(color)],
|
|
133
|
+
["spacing", numberTag("spacing", spacing)],
|
|
134
|
+
["w", numberTag("w", roundHorizontalScalePercentForSerialization(scale))],
|
|
135
|
+
["kern", numberTag("kern", kerning)],
|
|
136
|
+
["position", numberTag("position", position)],
|
|
137
|
+
["sz", numberTag("sz", fontSize)],
|
|
138
|
+
["szCs", numberTag("szCs", fontSizeCs)],
|
|
139
|
+
["highlight", namedHighlight ? `<w:highlight w:val="${namedHighlight}"/>` : ""],
|
|
140
|
+
["u", serializeUnderline(underline)],
|
|
141
|
+
["effect", effect ? `<w:effect w:val="${effect}"/>` : ""],
|
|
142
|
+
["shd", serializeShading(shading) || customHighlightShadingXml],
|
|
143
|
+
["vertAlign", vertAlign ? `<w:vertAlign w:val="${vertAlign}"/>` : ""],
|
|
144
|
+
["rtl", serializeOnOffElement(rtl, "rtl")],
|
|
145
|
+
["cs", serializeOnOffElement(cs, "cs")],
|
|
146
|
+
["em", emphasisMark ? `<w:em w:val="${emphasisMark}"/>` : ""],
|
|
147
|
+
["lang", serializeLanguage(language)]
|
|
148
|
+
],
|
|
149
|
+
preserved
|
|
150
|
+
});
|
|
151
|
+
if (parts.length === 0) return input !== void 0 && Object.keys(input).length === 0 ? "<w:rPr/>" : "";
|
|
152
|
+
return `<w:rPr>${parts.join("")}</w:rPr>`;
|
|
143
153
|
}
|
|
144
154
|
//#endregion
|
|
145
155
|
export { serializeShading, serializeTextFormatting };
|
|
@@ -18,7 +18,7 @@ declare function intAttr(value: number | undefined | null): string;
|
|
|
18
18
|
/**
|
|
19
19
|
* Verify that `xml` parses to exactly one root element named `expectedLocalName`
|
|
20
20
|
* (namespace prefix ignored). Used to gate raw XML snapshots — e.g. an SDT's
|
|
21
|
-
* `
|
|
21
|
+
* `rawEndPropertiesXml` — before splicing it verbatim
|
|
22
22
|
* into a serialized document. Those snapshots are normally produced by our
|
|
23
23
|
* own parser, but they can also arrive from an untrusted surface (a
|
|
24
24
|
* programmatically constructed node, a collaboration payload); a value that
|
|
@@ -22,7 +22,7 @@ function intAttr(value) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Verify that `xml` parses to exactly one root element named `expectedLocalName`
|
|
24
24
|
* (namespace prefix ignored). Used to gate raw XML snapshots — e.g. an SDT's
|
|
25
|
-
* `
|
|
25
|
+
* `rawEndPropertiesXml` — before splicing it verbatim
|
|
26
26
|
* into a serialized document. Those snapshots are normally produced by our
|
|
27
27
|
* own parser, but they can also arrive from an untrusted surface (a
|
|
28
28
|
* programmatically constructed node, a collaboration payload); a value that
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deterministicHexId } from "../../utils/hexId.js";
|
|
2
2
|
import { createBuiltInStyleIndex, resolveHeadingLevel } from "../builtInStyles.js";
|
|
3
|
-
import {
|
|
3
|
+
import { mergeParagraphNumbering, paragraphNumberingReference, paragraphNumberingReferenceId } from "../numberingReference.js";
|
|
4
4
|
import { getParagraphText } from "../paragraphParser.js";
|
|
5
5
|
import { cloneParagraphWithoutPropertySource } from "../paragraphPropertySource.js";
|
|
6
6
|
import { getRunText } from "../runParser.js";
|
|
@@ -203,6 +203,7 @@ const flattenBlocks = (content) => {
|
|
|
203
203
|
out.push(block);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
+
if (block.type !== "blockSdt") return;
|
|
206
207
|
for (const child of block.content) visit(child);
|
|
207
208
|
};
|
|
208
209
|
for (const block of content) visit(block);
|
|
@@ -246,22 +247,24 @@ const classifyParagraph = (paragraph, styleById, builtInStyles) => {
|
|
|
246
247
|
if (effectiveNumPr(paragraph, styleById) !== void 0) return "listItem";
|
|
247
248
|
return "paragraph";
|
|
248
249
|
};
|
|
249
|
-
/** The numbering a paragraph renders with
|
|
250
|
+
/** The numbering a paragraph renders with after style and direct tiers fold. */
|
|
250
251
|
const effectiveNumPr = (paragraph, styleById) => {
|
|
251
|
-
const direct = paragraph.formatting?.numPr;
|
|
252
|
-
if (direct?.numId !== void 0) return isNumberingReference(direct.numId) ? direct : void 0;
|
|
253
252
|
const styleId = paragraph.formatting?.styleId;
|
|
254
|
-
|
|
253
|
+
const effective = mergeParagraphNumbering(styleId ? styleNumPr(styleById.get(styleId), styleById) : void 0, paragraph.formatting?.numPr);
|
|
254
|
+
return effective?.kind === "reference" ? effective : void 0;
|
|
255
255
|
};
|
|
256
256
|
const styleNumPr = (style, styleById) => {
|
|
257
257
|
const seen = /* @__PURE__ */ new Set();
|
|
258
|
+
const chain = [];
|
|
258
259
|
let current = style;
|
|
259
260
|
while (current && !seen.has(current.styleId)) {
|
|
260
261
|
seen.add(current.styleId);
|
|
261
|
-
|
|
262
|
-
if (numPr?.numId !== void 0) return isNumberingReference(numPr.numId) ? numPr : void 0;
|
|
262
|
+
if (current.pPr?.numPr !== void 0) chain.push(current.pPr.numPr);
|
|
263
263
|
current = current.basedOn ? styleById.get(current.basedOn) : void 0;
|
|
264
264
|
}
|
|
265
|
+
let effective;
|
|
266
|
+
for (const stated of chain.toReversed()) effective = mergeParagraphNumbering(effective, stated);
|
|
267
|
+
return effective?.kind === "reference" ? effective : void 0;
|
|
265
268
|
};
|
|
266
269
|
const createNumberingCloner = ({ numbering, styleById, warnings }) => {
|
|
267
270
|
const abstractNums = numbering?.abstractNums ?? [];
|
|
@@ -300,7 +303,7 @@ const createNumberingCloner = ({ numbering, styleById, warnings }) => {
|
|
|
300
303
|
let current = abstract;
|
|
301
304
|
while (current.numStyleLink && !seen.has(current.abstractNumId)) {
|
|
302
305
|
seen.add(current.abstractNumId);
|
|
303
|
-
const linkedNumId = styleById.get(current.numStyleLink)?.pPr?.numPr
|
|
306
|
+
const linkedNumId = paragraphNumberingReferenceId(styleById.get(current.numStyleLink)?.pPr?.numPr);
|
|
304
307
|
const linkedNum = linkedNumId === void 0 ? void 0 : numById.get(linkedNumId);
|
|
305
308
|
const linkedAbstract = linkedNum ? abstractById.get(linkedNum.abstractNumId) : void 0;
|
|
306
309
|
if (!linkedAbstract) {
|
|
@@ -354,7 +357,7 @@ const createStyleCloner = ({ styleById, suffix, cloner }) => {
|
|
|
354
357
|
const style = styleById.get(styleId);
|
|
355
358
|
if (!style || style.type !== "paragraph") return styleId;
|
|
356
359
|
const numPr = styleNumPr(style, styleById);
|
|
357
|
-
if (numPr
|
|
360
|
+
if (numPr === void 0) return styleId;
|
|
358
361
|
const cloneId = `${styleId}-${suffix}`;
|
|
359
362
|
if (styleById.has(cloneId)) return cloneId;
|
|
360
363
|
const clone = {
|
|
@@ -365,10 +368,10 @@ const createStyleCloner = ({ styleById, suffix, cloner }) => {
|
|
|
365
368
|
default: false,
|
|
366
369
|
pPr: {
|
|
367
370
|
...style.pPr,
|
|
368
|
-
numPr: {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}
|
|
371
|
+
numPr: paragraphNumberingReference({
|
|
372
|
+
numId: cloner.cloneNumId(numPr.numId),
|
|
373
|
+
ilvl: numPr.ilvl
|
|
374
|
+
})
|
|
372
375
|
}
|
|
373
376
|
};
|
|
374
377
|
clones.set(styleId, clone);
|
|
@@ -388,11 +391,11 @@ const cloneParagraphForTarget = (paragraph, targetParaId, styleCloner, cloner, b
|
|
|
388
391
|
const nextFormatting = formatting && {
|
|
389
392
|
...formatting,
|
|
390
393
|
...formatting.styleId !== void 0 && { styleId: styleCloner.styleIdFor(formatting.styleId) },
|
|
391
|
-
...formatting.numPr
|
|
394
|
+
...formatting.numPr?.kind === "reference" && { numPr: {
|
|
392
395
|
...formatting.numPr,
|
|
393
396
|
numId: cloner.cloneNumId(formatting.numPr.numId)
|
|
394
397
|
} },
|
|
395
|
-
...formatting.numPrFromStyle
|
|
398
|
+
...formatting.numPrFromStyle?.kind === "reference" && { numPrFromStyle: {
|
|
396
399
|
...formatting.numPrFromStyle,
|
|
397
400
|
numId: cloner.cloneNumId(formatting.numPrFromStyle.numId)
|
|
398
401
|
} }
|
|
@@ -462,7 +465,7 @@ const remapListRendering = (rendering, cloner) => {
|
|
|
462
465
|
const collectTableParagraphs = (table) => {
|
|
463
466
|
const out = [];
|
|
464
467
|
for (const row of table.rows) for (const cell of row.cells) for (const item of cell.content) if (item.type === "paragraph") out.push(item);
|
|
465
|
-
else out.push(...collectTableParagraphs(item));
|
|
468
|
+
else if (item.type === "table") out.push(...collectTableParagraphs(item));
|
|
466
469
|
return out;
|
|
467
470
|
};
|
|
468
471
|
const cloneTableForTarget = ({ table, editableParagraphIds, paraIds, styleCloner, cloner, bookmarkIds }) => {
|
|
@@ -475,6 +478,7 @@ const cloneTableForTarget = ({ table, editableParagraphIds, paraIds, styleCloner
|
|
|
475
478
|
...structuredClone(cell),
|
|
476
479
|
content: cell.content.map((item) => {
|
|
477
480
|
if (item.type === "table") return cloneTable(item);
|
|
481
|
+
if (item.type !== "paragraph") return structuredClone(item);
|
|
478
482
|
const targetParaId = paraIds.mint(item.paraId);
|
|
479
483
|
const copy = cloneParagraphForTarget(item, targetParaId, styleCloner, cloner, bookmarkIds);
|
|
480
484
|
if (isTranslatableParagraph(item, editableParagraphIds)) paragraphs.push({
|
|
@@ -4,7 +4,7 @@ declare const FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME = "prosemirror";
|
|
|
4
4
|
/** Maximum accepted size of a complete Yjs collaboration state update. */
|
|
5
5
|
declare const FOLIO_YJS_UPDATE_MAX_BYTES: number;
|
|
6
6
|
/** Stable failure codes returned by server-side Yjs-to-DOCX materialization. */
|
|
7
|
-
declare const FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES: readonly ["empty_update", "invalid_update", "missing_document", "source_mismatch", "update_too_large"];
|
|
7
|
+
declare const FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES: readonly ["empty_update", "invalid_update", "missing_document", "source_mismatch", "stale_attr_schema", "update_too_large"];
|
|
8
8
|
/** Failure code for a rejected Yjs-to-DOCX materialization request. */
|
|
9
9
|
type FolioYjsDocxMaterializationErrorCode = (typeof FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES)[number];
|
|
10
10
|
declare const FolioYjsDocxMaterializationError_base: import("better-result").TaggedErrorClass<"FolioYjsDocxMaterializationError">;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fromProseDoc } from "../../prosemirror/conversion/fromProseDoc.js";
|
|
2
2
|
import { schema } from "../../prosemirror/schema/index.js";
|
|
3
|
-
import { readYjsParagraphSourceContract, withParagraphSourceContract } from "../../prosemirror/
|
|
3
|
+
import { applyAttrSchemaMigrations, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
4
4
|
import { ParagraphPropertySourceValidationError } from "../paragraphPropertySource.js";
|
|
5
5
|
import { parseDocx } from "../parser.js";
|
|
6
6
|
import { repackDocx } from "../rezip.js";
|
|
@@ -18,6 +18,7 @@ const FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES = [
|
|
|
18
18
|
"invalid_update",
|
|
19
19
|
"missing_document",
|
|
20
20
|
"source_mismatch",
|
|
21
|
+
"stale_attr_schema",
|
|
21
22
|
"update_too_large"
|
|
22
23
|
];
|
|
23
24
|
/** Typed failure raised when a collaboration snapshot cannot be materialized. */
|
|
@@ -40,6 +41,13 @@ const readProseMirrorDocument = (yjsUpdate) => {
|
|
|
40
41
|
code: "missing_document",
|
|
41
42
|
message: "Yjs update does not contain a Folio document."
|
|
42
43
|
});
|
|
44
|
+
const attrSchemaVersion = readYjsAttrSchemaVersion(ydoc);
|
|
45
|
+
if (attrSchemaVersion.isErr()) throw new FolioYjsDocxMaterializationError({
|
|
46
|
+
cause: attrSchemaVersion.error,
|
|
47
|
+
code: "stale_attr_schema",
|
|
48
|
+
message: attrSchemaVersion.error.message
|
|
49
|
+
});
|
|
50
|
+
applyAttrSchemaMigrations(ydoc, fragment, attrSchemaVersion.value);
|
|
43
51
|
const contract = readYjsParagraphSourceContract(ydoc);
|
|
44
52
|
if (!contract) throw new FolioYjsDocxMaterializationError({
|
|
45
53
|
code: "source_mismatch",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { FolioYjsAttrSchemaVersion } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
2
|
+
import { Result } from "better-result";
|
|
3
|
+
//#region src/docx/server/migrateYjsAttrSchema.d.ts
|
|
4
|
+
/** Stable failure codes returned by an offline snapshot migration. */
|
|
5
|
+
declare const FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES: readonly ["invalid_update", "unsupported_version", "update_too_large"];
|
|
6
|
+
/** Failure code for a snapshot that could not be migrated. */
|
|
7
|
+
type FolioYjsSnapshotMigrationErrorCode = (typeof FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES)[number];
|
|
8
|
+
declare const FolioYjsSnapshotMigrationError_base: import("better-result").TaggedErrorClass<"FolioYjsSnapshotMigrationError">;
|
|
9
|
+
/** Typed failure raised when a collaboration snapshot cannot be migrated. */
|
|
10
|
+
declare class FolioYjsSnapshotMigrationError extends FolioYjsSnapshotMigrationError_base<{
|
|
11
|
+
code: FolioYjsSnapshotMigrationErrorCode;
|
|
12
|
+
message: string;
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
}> {}
|
|
15
|
+
/** What an offline migration did to one snapshot. */
|
|
16
|
+
type FolioYjsSnapshotMigrationResult = {
|
|
17
|
+
/** The complete state update to store in place of the input. */
|
|
18
|
+
update: Uint8Array;
|
|
19
|
+
/** The attr-schema version the input was written under. */
|
|
20
|
+
fromVersion: FolioYjsAttrSchemaVersion;
|
|
21
|
+
/** The attr-schema version the output carries. */
|
|
22
|
+
toVersion: FolioYjsAttrSchemaVersion;
|
|
23
|
+
/** Paragraphs whose attrs the migration rewrote. */
|
|
24
|
+
paragraphsRewritten: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Carry a stored collaboration snapshot forward to the attr schema this build
|
|
28
|
+
* writes, without a ProseMirror schema and without rebuilding a single node.
|
|
29
|
+
*
|
|
30
|
+
* A Yjs XML element's attributes are ordinary CRDT map entries holding JSON, so
|
|
31
|
+
* {@link applyAttrSchemaMigrations} rewrites values in the fragment directly.
|
|
32
|
+
* Nothing here can trip y-prosemirror's node rebuild, which deletes an element
|
|
33
|
+
* it fails to construct. The function is pure and offline: no network, no
|
|
34
|
+
* DOCX, no editor.
|
|
35
|
+
*
|
|
36
|
+
* A snapshot already at the current version is returned byte for byte, so a
|
|
37
|
+
* host may run this over its whole corpus repeatedly.
|
|
38
|
+
*
|
|
39
|
+
* **The contract a reseed must respect.** This function never reseeds and never
|
|
40
|
+
* touches the paragraph-source contract: it preserves whichever source binding
|
|
41
|
+
* the snapshot already carries. A reseed does the opposite, and Folio holds it
|
|
42
|
+
* to one rule: *the DOCX handed to the seeding editor must be the same bytes
|
|
43
|
+
* the host will later pass to `materializeYjsDocx` as that room's source*.
|
|
44
|
+
* The contract is a digest of those bytes, so seeding from one document while
|
|
45
|
+
* recording another as the room's source makes every later save fail with
|
|
46
|
+
* `source_mismatch`. The reverse mistake is worse and Folio cannot see it: a
|
|
47
|
+
* host that reseeds from the document a room was *created* from, rather than
|
|
48
|
+
* from the latest content it published, produces a perfectly well-formed
|
|
49
|
+
* snapshot whose collaborative history has been replaced by an older document.
|
|
50
|
+
* Rebind the recorded source in the same statement that clears the seed, or do
|
|
51
|
+
* not clear it.
|
|
52
|
+
*/
|
|
53
|
+
declare const migrateFolioYjsSnapshot: (update: Uint8Array) => Result<FolioYjsSnapshotMigrationResult, FolioYjsSnapshotMigrationError>;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES, FolioYjsSnapshotMigrationError, FolioYjsSnapshotMigrationErrorCode, FolioYjsSnapshotMigrationResult, migrateFolioYjsSnapshot };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { applyAttrSchemaMigrations, readYjsAttrSchemaVersion } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
2
|
+
import { FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME } from "./materializeYjsDocx.js";
|
|
3
|
+
import { Result, TaggedError } from "better-result";
|
|
4
|
+
import * as Y from "yjs";
|
|
5
|
+
//#region src/docx/server/migrateYjsAttrSchema.ts
|
|
6
|
+
/** Stable failure codes returned by an offline snapshot migration. */
|
|
7
|
+
const FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES = [
|
|
8
|
+
"invalid_update",
|
|
9
|
+
"unsupported_version",
|
|
10
|
+
"update_too_large"
|
|
11
|
+
];
|
|
12
|
+
/** Typed failure raised when a collaboration snapshot cannot be migrated. */
|
|
13
|
+
var FolioYjsSnapshotMigrationError = class extends TaggedError("FolioYjsSnapshotMigrationError") {};
|
|
14
|
+
/**
|
|
15
|
+
* Carry a stored collaboration snapshot forward to the attr schema this build
|
|
16
|
+
* writes, without a ProseMirror schema and without rebuilding a single node.
|
|
17
|
+
*
|
|
18
|
+
* A Yjs XML element's attributes are ordinary CRDT map entries holding JSON, so
|
|
19
|
+
* {@link applyAttrSchemaMigrations} rewrites values in the fragment directly.
|
|
20
|
+
* Nothing here can trip y-prosemirror's node rebuild, which deletes an element
|
|
21
|
+
* it fails to construct. The function is pure and offline: no network, no
|
|
22
|
+
* DOCX, no editor.
|
|
23
|
+
*
|
|
24
|
+
* A snapshot already at the current version is returned byte for byte, so a
|
|
25
|
+
* host may run this over its whole corpus repeatedly.
|
|
26
|
+
*
|
|
27
|
+
* **The contract a reseed must respect.** This function never reseeds and never
|
|
28
|
+
* touches the paragraph-source contract: it preserves whichever source binding
|
|
29
|
+
* the snapshot already carries. A reseed does the opposite, and Folio holds it
|
|
30
|
+
* to one rule: *the DOCX handed to the seeding editor must be the same bytes
|
|
31
|
+
* the host will later pass to `materializeYjsDocx` as that room's source*.
|
|
32
|
+
* The contract is a digest of those bytes, so seeding from one document while
|
|
33
|
+
* recording another as the room's source makes every later save fail with
|
|
34
|
+
* `source_mismatch`. The reverse mistake is worse and Folio cannot see it: a
|
|
35
|
+
* host that reseeds from the document a room was *created* from, rather than
|
|
36
|
+
* from the latest content it published, produces a perfectly well-formed
|
|
37
|
+
* snapshot whose collaborative history has been replaced by an older document.
|
|
38
|
+
* Rebind the recorded source in the same statement that clears the seed, or do
|
|
39
|
+
* not clear it.
|
|
40
|
+
*/
|
|
41
|
+
const migrateFolioYjsSnapshot = (update) => {
|
|
42
|
+
if (update.byteLength === 0) return Result.err(new FolioYjsSnapshotMigrationError({
|
|
43
|
+
code: "invalid_update",
|
|
44
|
+
message: "Cannot migrate an empty Yjs update."
|
|
45
|
+
}));
|
|
46
|
+
if (update.byteLength > 10485760) return Result.err(new FolioYjsSnapshotMigrationError({
|
|
47
|
+
code: "update_too_large",
|
|
48
|
+
message: "Yjs update exceeds the snapshot migration limit."
|
|
49
|
+
}));
|
|
50
|
+
const ydoc = new Y.Doc();
|
|
51
|
+
const applied = Result.try({
|
|
52
|
+
try: () => {
|
|
53
|
+
Y.applyUpdate(ydoc, update);
|
|
54
|
+
},
|
|
55
|
+
catch: (cause) => new FolioYjsSnapshotMigrationError({
|
|
56
|
+
cause,
|
|
57
|
+
code: "invalid_update",
|
|
58
|
+
message: "Yjs update is not a valid Folio collaboration snapshot."
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
if (applied.isErr()) {
|
|
62
|
+
ydoc.destroy();
|
|
63
|
+
return Result.err(applied.error);
|
|
64
|
+
}
|
|
65
|
+
const read = readYjsAttrSchemaVersion(ydoc);
|
|
66
|
+
if (read.isErr()) {
|
|
67
|
+
ydoc.destroy();
|
|
68
|
+
return Result.err(new FolioYjsSnapshotMigrationError({
|
|
69
|
+
cause: read.error,
|
|
70
|
+
code: "unsupported_version",
|
|
71
|
+
message: read.error.message
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
const fromVersion = read.value;
|
|
75
|
+
if (fromVersion === 11) {
|
|
76
|
+
ydoc.destroy();
|
|
77
|
+
return Result.ok({
|
|
78
|
+
fromVersion,
|
|
79
|
+
paragraphsRewritten: 0,
|
|
80
|
+
toVersion: 11,
|
|
81
|
+
update
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const paragraphsRewritten = applyAttrSchemaMigrations(ydoc, ydoc.getXmlFragment(FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME), fromVersion);
|
|
85
|
+
const migrated = Y.encodeStateAsUpdate(ydoc);
|
|
86
|
+
ydoc.destroy();
|
|
87
|
+
return Result.ok({
|
|
88
|
+
fromVersion,
|
|
89
|
+
paragraphsRewritten,
|
|
90
|
+
toVersion: 11,
|
|
91
|
+
update: migrated
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
export { FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES, FolioYjsSnapshotMigrationError, migrateFolioYjsSnapshot };
|
|
@@ -28,11 +28,14 @@ function parseSettings(xml) {
|
|
|
28
28
|
const settings = { defaultTabStop: parseDefaultTabStop(root) };
|
|
29
29
|
const wordprocessingFlag = (localName) => {
|
|
30
30
|
const element = findChildByNamespaceUri(root, WORDPROCESSINGML_NAMESPACE_URIS, localName);
|
|
31
|
-
return element
|
|
31
|
+
return element === null ? void 0 : parseBooleanElement(element);
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
33
|
+
const evenAndOddHeaders = wordprocessingFlag("evenAndOddHeaders");
|
|
34
|
+
if (evenAndOddHeaders !== void 0) settings.evenAndOddHeaders = evenAndOddHeaders;
|
|
35
|
+
const mirrorMargins = wordprocessingFlag("mirrorMargins");
|
|
36
|
+
if (mirrorMargins !== void 0) settings.mirrorMargins = mirrorMargins;
|
|
37
|
+
const updateFields = wordprocessingFlag("updateFields");
|
|
38
|
+
if (updateFields !== void 0) settings.updateFields = updateFields;
|
|
36
39
|
const themeFontLangEl = root ? findChild(root, "w", "themeFontLang") : null;
|
|
37
40
|
const eastAsiaLang = themeFontLangEl ? getAttribute(themeFontLangEl, "w", "eastAsia") || void 0 : void 0;
|
|
38
41
|
const bidiLang = themeFontLangEl ? getAttribute(themeFontLangEl, "w", "bidi") || void 0 : void 0;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ParseContext } from "./parseContext.js";
|
|
2
3
|
import { XmlElement } from "./xmlParser.js";
|
|
3
4
|
//#region src/docx/shadingParser.d.ts
|
|
4
|
-
declare function parseShading(shd: XmlElement | null): document_d_exports.ShadingProperties | undefined;
|
|
5
|
+
declare function parseShading(shd: XmlElement | null, context?: ParseContext): document_d_exports.ShadingProperties | undefined;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { parseShading };
|