@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,20 +1,20 @@
|
|
|
1
|
+
import { isSerializablePreservedAttribute } from "../../docx/attributeRemainder.js";
|
|
2
|
+
import { DRAWING_ANCHOR_FLAG_KEYS } from "../../docx/drawingAnchor.js";
|
|
1
3
|
import { GRAPHIC_FRAME_LOCK_KEYS } from "../../docx/graphicFrameLocks.js";
|
|
2
4
|
import { allowsDirectDrawingEdit, isDrawingRawXmlMode } from "../../docx/imageRawXml.js";
|
|
3
|
-
import { EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LINE_SPACING_RULE_VALUES,
|
|
5
|
+
import { COUNTER_FORMAT_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LINE_SPACING_RULE_VALUES, OUTLINE_STYLE_ATTR_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_DIRECTION_VALUES, TEXT_EFFECT_VALUES, UNDERLINE_STYLE_VALUES } from "../../types/documentEnumValues.js";
|
|
4
6
|
import { canonicalJson } from "../../utils/canonicalJson.js";
|
|
5
7
|
import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
|
|
8
|
+
import { paragraphNumberingFromAttrValue } from "../numberingAttr.js";
|
|
9
|
+
import { outlineLevelFromAttrValue } from "../outlineLevelAttr.js";
|
|
6
10
|
import { isParagraphDirection } from "../paragraphDirection.js";
|
|
7
11
|
import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_VALUE_PROPERTIES, TRACKED_CHANGE_PROVENANCE_VALUES } from "../schema/marks.js";
|
|
8
|
-
import { TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES } from "../schema/nodes.js";
|
|
12
|
+
import { PRESERVED_XML_LEVELS, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES } from "../schema/nodes.js";
|
|
9
13
|
import { panic } from "better-result";
|
|
10
|
-
import { DRAWING_RAW_XML_MODES, isOoxmlSymbolCharacter } from "@stll/docx-core/model";
|
|
14
|
+
import { DRAWING_RAW_XML_MODES, THEME_COLORS, isOoxmlSymbolCharacter } from "@stll/docx-core/model";
|
|
15
|
+
import { isSafePreservedChildXml, isWithinPreservedMarkupBudget } from "@stll/docx-core/schema";
|
|
11
16
|
//#region src/prosemirror/attrs/index.ts
|
|
12
|
-
const
|
|
13
|
-
"nextPage",
|
|
14
|
-
"continuous",
|
|
15
|
-
"oddPage",
|
|
16
|
-
"evenPage"
|
|
17
|
-
];
|
|
17
|
+
const PRESERVED_XML_LEVEL_VALUES = new Set(Object.values(PRESERVED_XML_LEVELS));
|
|
18
18
|
const IMAGE_DISPLAY_MODES = [
|
|
19
19
|
"inline",
|
|
20
20
|
"float",
|
|
@@ -141,11 +141,14 @@ const SECTION_VERTICAL_ALIGNMENTS = [
|
|
|
141
141
|
"both",
|
|
142
142
|
"bottom"
|
|
143
143
|
];
|
|
144
|
+
const OMITTED_GRID_SLOT_VALUES = ["before", "after"];
|
|
144
145
|
const paragraphAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
145
146
|
const hardBreakAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
146
147
|
const pageBreakRunAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
147
148
|
const tabAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
148
149
|
const symbolAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
150
|
+
const preservedXmlAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
151
|
+
const preservedBlockAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
149
152
|
const tableAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
150
153
|
const tableRowAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
151
154
|
const tableCellAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -171,7 +174,8 @@ const footnoteRefAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
|
171
174
|
const commentAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
172
175
|
const trackedChangeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
173
176
|
const runPropertyChangeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
174
|
-
const
|
|
177
|
+
const runIdentityAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
178
|
+
const inlineWrapperAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
175
179
|
const runFormattingOverrideAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
176
180
|
const hyperlinkAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
177
181
|
const readParagraphAttrs = (node) => {
|
|
@@ -199,7 +203,7 @@ const readParagraphAttrs = (node) => {
|
|
|
199
203
|
optionalNumber(attrs, "indentRight", "paragraph.attrs.indentRight", issues);
|
|
200
204
|
optionalNumber(attrs, "indentFirstLine", "paragraph.attrs.indentFirstLine", issues);
|
|
201
205
|
optionalBoolean(attrs, "hangingIndent", "paragraph.attrs.hangingIndent", issues);
|
|
202
|
-
|
|
206
|
+
optionalOutlineLevel(attrs, "outlineLevel", "paragraph.attrs.outlineLevel", issues);
|
|
203
207
|
optionalString(attrs, "listNumFmt", "paragraph.attrs.listNumFmt", issues);
|
|
204
208
|
optionalBoolean(attrs, "listIsBullet", "paragraph.attrs.listIsBullet", issues);
|
|
205
209
|
optionalBoolean(attrs, "listIsLegal", "paragraph.attrs.listIsLegal", issues);
|
|
@@ -231,7 +235,6 @@ const readParagraphAttrs = (node) => {
|
|
|
231
235
|
path: "paragraph.attrs.direction",
|
|
232
236
|
message: "Expected a ParagraphDirection."
|
|
233
237
|
});
|
|
234
|
-
optionalOneOf(attrs, "sectionBreakType", "paragraph.attrs.sectionBreakType", issues, SECTION_BREAK_TYPES);
|
|
235
238
|
optionalStringArray(attrs, "listLevelNumFmts", "paragraph.attrs.listLevelNumFmts", issues);
|
|
236
239
|
optionalNumberArray(attrs, "listLevelStarts", "paragraph.attrs.listLevelStarts", issues);
|
|
237
240
|
optionalNumber(attrs, "listAbstractNumId", "paragraph.attrs.listAbstractNumId", issues);
|
|
@@ -250,13 +253,15 @@ const readParagraphAttrs = (node) => {
|
|
|
250
253
|
optionalRecord(attrs, "spacingFromImplicitDefaultStyle", "paragraph.attrs.spacingFromImplicitDefaultStyle", issues);
|
|
251
254
|
optionalTextFormatting(attrs, "defaultTextFormatting", "paragraph.attrs.defaultTextFormatting", issues);
|
|
252
255
|
optionalTextFormatting(attrs, "_tableRunFormatting", "paragraph.attrs._tableRunFormatting", issues);
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
optionalParagraphNumbering(attrs, "numPr", "paragraph.attrs.numPr", issues);
|
|
257
|
+
optionalParagraphNumbering(attrs, "numPrFromStyle", "paragraph.attrs.numPrFromStyle", issues);
|
|
258
|
+
optionalNestedRecord(attrs, "_originalFormatting", "paragraph.attrs._originalFormatting", issues, validateParagraphFormatting);
|
|
255
259
|
optionalBookmarkArray(attrs["bookmarks"], issues);
|
|
256
260
|
optionalEmptyHyperlinkArray(attrs["_emptyHyperlinks"], issues);
|
|
257
261
|
optionalAutospacingBase(attrs, "paragraph.attrs._autospacingBase", issues);
|
|
258
262
|
optionalSectionProperties(attrs, "_sectionProperties", "paragraph.attrs._sectionProperties", issues);
|
|
259
263
|
optionalPropertyChanges(attrs, "_propertyChanges", "paragraph.attrs._propertyChanges", issues, ["paragraphPropertyChange"]);
|
|
264
|
+
optionalPreservedAttributes(attrs, "_preservedAttributes", "paragraph.attrs._preservedAttributes", issues);
|
|
260
265
|
return attrsResult(attrs, issues);
|
|
261
266
|
};
|
|
262
267
|
const expectParagraphAttrs = (node) => expectCachedNodeAttrs(node, paragraphAttrsCache, readParagraphAttrs, "paragraph attrs");
|
|
@@ -304,6 +309,27 @@ const readSymbolAttrs = (node) => {
|
|
|
304
309
|
return attrsResult(attrs, issues);
|
|
305
310
|
};
|
|
306
311
|
const expectSymbolAttrs = (node) => expectCachedNodeAttrs(node, symbolAttrsCache, readSymbolAttrs, "symbol attrs");
|
|
312
|
+
const readPreservedXmlAttrs = (node) => {
|
|
313
|
+
const attrs = attrsRecord(node.attrs);
|
|
314
|
+
const issues = [];
|
|
315
|
+
expectNodeType(node, "preservedXml", issues);
|
|
316
|
+
requiredString(attrs, "xml", "preservedXml.attrs.xml", issues);
|
|
317
|
+
requiredString(attrs, "text", "preservedXml.attrs.text", issues);
|
|
318
|
+
if (!PRESERVED_XML_LEVEL_VALUES.has(attrs["level"])) issues.push({
|
|
319
|
+
path: "preservedXml.attrs.level",
|
|
320
|
+
message: `Expected one of ${[...PRESERVED_XML_LEVEL_VALUES].join(", ")}.`
|
|
321
|
+
});
|
|
322
|
+
return attrsResult(attrs, issues);
|
|
323
|
+
};
|
|
324
|
+
const expectPreservedXmlAttrs = (node) => expectCachedNodeAttrs(node, preservedXmlAttrsCache, readPreservedXmlAttrs, "preservedXml attrs");
|
|
325
|
+
const readPreservedBlockAttrs = (node) => {
|
|
326
|
+
const attrs = attrsRecord(node.attrs);
|
|
327
|
+
const issues = [];
|
|
328
|
+
expectNodeType(node, "preservedBlock", issues);
|
|
329
|
+
requiredString(attrs, "xml", "preservedBlock.attrs.xml", issues);
|
|
330
|
+
return attrsResult(attrs, issues);
|
|
331
|
+
};
|
|
332
|
+
const expectPreservedBlockAttrs = (node) => expectCachedNodeAttrs(node, preservedBlockAttrsCache, readPreservedBlockAttrs, "preservedBlock attrs");
|
|
307
333
|
const readTableAttrs = (node) => {
|
|
308
334
|
const attrs = attrsRecord(node.attrs);
|
|
309
335
|
const issues = [];
|
|
@@ -327,6 +353,8 @@ const readTableAttrs = (node) => {
|
|
|
327
353
|
optionalOneOf(attrs, "_resolvedJustification", "table.attrs._resolvedJustification", issues, TABLE_JUSTIFICATION_VALUES);
|
|
328
354
|
optionalBoolean(attrs, "_resolvedBidi", "table.attrs._resolvedBidi", issues);
|
|
329
355
|
optionalRecord(attrs, "_originalFormatting", "table.attrs._originalFormatting", issues);
|
|
356
|
+
optionalPositionedBookmarks(attrs, "table.attrs._bookmarks", issues);
|
|
357
|
+
optionalTablePreservedMarkup(attrs, "_preserved", "table.attrs._preserved", issues);
|
|
330
358
|
return attrsResult(attrs, issues);
|
|
331
359
|
};
|
|
332
360
|
const expectTableAttrs = (node) => expectCachedNodeAttrs(node, tableAttrsCache, readTableAttrs, "table attrs");
|
|
@@ -340,12 +368,17 @@ const readTableRowAttrs = (node) => {
|
|
|
340
368
|
optionalBoolean(attrs, "hidden", "tableRow.attrs.hidden", issues);
|
|
341
369
|
optionalOneOf(attrs, "_resolvedJustification", "tableRow.attrs._resolvedJustification", issues, TABLE_JUSTIFICATION_VALUES);
|
|
342
370
|
optionalRecord(attrs, "_originalFormatting", "tableRow.attrs._originalFormatting", issues);
|
|
371
|
+
optionalRecord(attrs, "_tablePropertyExceptions", "tableRow.attrs._tablePropertyExceptions", issues);
|
|
343
372
|
optionalTableRowRevision(attrs, "trIns", issues);
|
|
344
373
|
optionalTableRowRevision(attrs, "trDel", issues);
|
|
345
374
|
if (attrs["trIns"] != null && attrs["trDel"] != null) issues.push({
|
|
346
375
|
path: "tableRow.attrs",
|
|
347
376
|
message: "Expected at most one structural revision marker."
|
|
348
377
|
});
|
|
378
|
+
optionalPreservedAttributes(attrs, "_preservedAttributes", "tableRow.attrs._preservedAttributes", issues);
|
|
379
|
+
optionalPositionedBookmarks(attrs, "tableRow.attrs._bookmarks", issues);
|
|
380
|
+
optionalContentControls(attrs, "tableRow.attrs.contentControls", issues);
|
|
381
|
+
optionalTablePreservedMarkup(attrs, "_preserved", "tableRow.attrs._preserved", issues);
|
|
349
382
|
return attrsResult(attrs, issues);
|
|
350
383
|
};
|
|
351
384
|
const expectTableRowAttrs = (node) => expectCachedNodeAttrs(node, tableRowAttrsCache, readTableRowAttrs, "table row attrs");
|
|
@@ -355,13 +388,15 @@ const readTableCellAttrs = (node) => {
|
|
|
355
388
|
expectNodeTypeOneOf(node, ["tableCell", "tableHeader"], issues);
|
|
356
389
|
requiredNumber(attrs, "colspan", "tableCell.attrs.colspan", issues);
|
|
357
390
|
requiredNumber(attrs, "rowspan", "tableCell.attrs.rowspan", issues);
|
|
391
|
+
optionalOneOf(attrs, "_omittedGridSlot", "tableCell.attrs._omittedGridSlot", issues, OMITTED_GRID_SLOT_VALUES);
|
|
358
392
|
optionalNumberArray(attrs, "colwidth", "tableCell.attrs.colwidth", issues, { allowNull: true });
|
|
359
393
|
optionalNumber(attrs, "width", "tableCell.attrs.width", issues);
|
|
360
394
|
optionalOneOf(attrs, "widthType", "tableCell.attrs.widthType", issues, TABLE_WIDTH_TYPE_VALUES);
|
|
395
|
+
optionalAuthoredWidth(attrs, issues);
|
|
361
396
|
optionalOneOf(attrs, "verticalAlign", "tableCell.attrs.verticalAlign", issues, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES);
|
|
362
397
|
optionalString(attrs, "backgroundColor", "tableCell.attrs.backgroundColor", issues);
|
|
363
398
|
optionalString(attrs, "_resolvedBackgroundColor", "tableCell.attrs._resolvedBackgroundColor", issues);
|
|
364
|
-
optionalOneOf(attrs, "textDirection", "tableCell.attrs.textDirection", issues,
|
|
399
|
+
optionalOneOf(attrs, "textDirection", "tableCell.attrs.textDirection", issues, TEXT_DIRECTION_VALUES);
|
|
365
400
|
optionalBoolean(attrs, "noWrap", "tableCell.attrs.noWrap", issues);
|
|
366
401
|
optionalBoolean(attrs, "hideMark", "tableCell.attrs.hideMark", issues);
|
|
367
402
|
optionalBorderMap(attrs, "borders", "tableCell.attrs.borders", issues, [
|
|
@@ -375,6 +410,7 @@ const readTableCellAttrs = (node) => {
|
|
|
375
410
|
optionalInsetMap(attrs, "margins", "tableCell.attrs.margins", issues);
|
|
376
411
|
optionalRecord(attrs, "_originalFormatting", "tableCell.attrs._originalFormatting", issues);
|
|
377
412
|
optionalTableCellRevision(attrs, issues);
|
|
413
|
+
optionalContentControls(attrs, "tableCell.attrs.contentControls", issues);
|
|
378
414
|
optionalBoolean(attrs, "_preserveVMergeRestart", "tableCell.attrs._preserveVMergeRestart", issues);
|
|
379
415
|
return attrsResult(attrs, issues);
|
|
380
416
|
};
|
|
@@ -394,11 +430,16 @@ const readImageAttrs = (node) => {
|
|
|
394
430
|
optionalOneOf(attrs, "displayMode", "image.attrs.displayMode", issues, IMAGE_DISPLAY_MODES);
|
|
395
431
|
optionalOneOf(attrs, "cssFloat", "image.attrs.cssFloat", issues, IMAGE_CSS_FLOATS);
|
|
396
432
|
optionalString(attrs, "transform", "image.attrs.transform", issues);
|
|
433
|
+
optionalNumber(attrs, "docxRotation", "image.attrs.docxRotation", issues);
|
|
434
|
+
optionalBoolean(attrs, "docxFlipH", "image.attrs.docxFlipH", issues);
|
|
435
|
+
optionalBoolean(attrs, "docxFlipV", "image.attrs.docxFlipV", issues);
|
|
397
436
|
optionalNumber(attrs, "distTop", "image.attrs.distTop", issues);
|
|
398
437
|
optionalNumber(attrs, "distBottom", "image.attrs.distBottom", issues);
|
|
399
438
|
optionalNumber(attrs, "distLeft", "image.attrs.distLeft", issues);
|
|
400
439
|
optionalNumber(attrs, "distRight", "image.attrs.distRight", issues);
|
|
401
440
|
optionalNumber(attrs, "opacity", "image.attrs.opacity", issues);
|
|
441
|
+
optionalNumber(attrs, "brightness", "image.attrs.brightness", issues);
|
|
442
|
+
optionalNumber(attrs, "contrast", "image.attrs.contrast", issues);
|
|
402
443
|
optionalNumber(attrs, "cropTop", "image.attrs.cropTop", issues);
|
|
403
444
|
optionalNumber(attrs, "cropRight", "image.attrs.cropRight", issues);
|
|
404
445
|
optionalNumber(attrs, "cropBottom", "image.attrs.cropBottom", issues);
|
|
@@ -408,7 +449,10 @@ const readImageAttrs = (node) => {
|
|
|
408
449
|
optionalNumber(attrs, "paddingBottom", "image.attrs.paddingBottom", issues);
|
|
409
450
|
optionalNumber(attrs, "paddingLeft", "image.attrs.paddingLeft", issues);
|
|
410
451
|
optionalImagePosition(attrs, "position", "image.attrs.position", issues);
|
|
411
|
-
|
|
452
|
+
optionalDrawingAnchor(attrs, "anchor", "image.attrs.anchor", issues);
|
|
453
|
+
optionalWrapDistanceSlots(attrs, "wrapDistanceSlots", "image.attrs.wrapDistanceSlots", issues);
|
|
454
|
+
optionalEffectExtentSlots(attrs, "wrapEffectExtentSlots", "image.attrs.wrapEffectExtentSlots", issues);
|
|
455
|
+
optionalWrapPolygon(attrs, "wrapPolygon", "image.attrs.wrapPolygon", issues);
|
|
412
456
|
optionalBoolean(attrs, "decorative", "image.attrs.decorative", issues);
|
|
413
457
|
optionalBoolean(attrs, "hidden", "image.attrs.hidden", issues);
|
|
414
458
|
optionalStringArray(attrs, "docPrExtensions", "image.attrs.docPrExtensions", issues);
|
|
@@ -420,6 +464,9 @@ const readImageAttrs = (node) => {
|
|
|
420
464
|
optionalOneOf(attrs, "wrapText", "image.attrs.wrapText", issues, IMAGE_WRAP_TEXT_VALUES);
|
|
421
465
|
optionalString(attrs, "hlinkHref", "image.attrs.hlinkHref", issues);
|
|
422
466
|
optionalString(attrs, "hlinkRId", "image.attrs.hlinkRId", issues);
|
|
467
|
+
optionalDocPrLink(attrs, "hlinkClickSource", "image.attrs.hlinkClickSource", issues);
|
|
468
|
+
optionalString(attrs, "hlinkHoverXml", "image.attrs.hlinkHoverXml", issues);
|
|
469
|
+
optionalString(attrs, "docPrId", "image.attrs.docPrId", issues);
|
|
423
470
|
optionalString(attrs, "_docxRawXml", "image.attrs._docxRawXml", issues);
|
|
424
471
|
optionalOneOf(attrs, "_docxRawXmlMode", "image.attrs._docxRawXmlMode", issues, Object.values(DRAWING_RAW_XML_MODES));
|
|
425
472
|
optionalString(attrs, "_docxRawImageFingerprint", "image.attrs._docxRawImageFingerprint", issues);
|
|
@@ -482,8 +529,9 @@ const readBlockSdtAttrs = (node) => {
|
|
|
482
529
|
optionalString(attrs, "dropdownLastValue", "blockSdt.attrs.dropdownLastValue", issues);
|
|
483
530
|
optionalBoolean(attrs, "checked", "blockSdt.attrs.checked", issues);
|
|
484
531
|
optionalBoolean(attrs, "_originallyEmpty", "blockSdt.attrs._originallyEmpty", issues);
|
|
485
|
-
|
|
532
|
+
optionalPreservedMarkup(attrs, "_preserved", "blockSdt.attrs._preserved", issues);
|
|
486
533
|
optionalString(attrs, "rawEndPropertiesXml", "blockSdt.attrs.rawEndPropertiesXml", issues);
|
|
534
|
+
optionalSdtEndProperties(attrs, "blockSdt.attrs.endProperties", issues);
|
|
487
535
|
optionalString(attrs, "rawSdtChildrenBeforeContent", "blockSdt.attrs.rawSdtChildrenBeforeContent", issues);
|
|
488
536
|
optionalString(attrs, "rawSdtChildrenAfterContent", "blockSdt.attrs.rawSdtChildrenAfterContent", issues);
|
|
489
537
|
return attrsResult(attrs, issues);
|
|
@@ -517,6 +565,9 @@ const readShapeAttrs = (node) => {
|
|
|
517
565
|
optionalShapeLineEnd(attrs, "outlineHeadEnd", "shape.attrs.outlineHeadEnd", issues);
|
|
518
566
|
optionalShapeLineEnd(attrs, "outlineTailEnd", "shape.attrs.outlineTailEnd", issues);
|
|
519
567
|
optionalString(attrs, "transform", "shape.attrs.transform", issues);
|
|
568
|
+
optionalNumber(attrs, "docxRotation", "shape.attrs.docxRotation", issues);
|
|
569
|
+
optionalBoolean(attrs, "docxFlipH", "shape.attrs.docxFlipH", issues);
|
|
570
|
+
optionalBoolean(attrs, "docxFlipV", "shape.attrs.docxFlipV", issues);
|
|
520
571
|
optionalOneOf(attrs, "displayMode", "shape.attrs.displayMode", issues, IMAGE_DISPLAY_MODES);
|
|
521
572
|
optionalOneOf(attrs, "cssFloat", "shape.attrs.cssFloat", issues, IMAGE_CSS_FLOATS);
|
|
522
573
|
optionalOneOf(attrs, "wrapType", "shape.attrs.wrapType", issues, IMAGE_WRAP_TYPE_VALUES);
|
|
@@ -526,6 +577,10 @@ const readShapeAttrs = (node) => {
|
|
|
526
577
|
optionalNumber(attrs, "distLeft", "shape.attrs.distLeft", issues);
|
|
527
578
|
optionalNumber(attrs, "distRight", "shape.attrs.distRight", issues);
|
|
528
579
|
optionalImagePosition(attrs, "position", "shape.attrs.position", issues);
|
|
580
|
+
optionalDrawingAnchor(attrs, "anchor", "shape.attrs.anchor", issues);
|
|
581
|
+
optionalWrapDistanceSlots(attrs, "wrapDistanceSlots", "shape.attrs.wrapDistanceSlots", issues);
|
|
582
|
+
optionalEffectExtentSlots(attrs, "wrapEffectExtentSlots", "shape.attrs.wrapEffectExtentSlots", issues);
|
|
583
|
+
optionalWrapPolygon(attrs, "wrapPolygon", "shape.attrs.wrapPolygon", issues);
|
|
529
584
|
optionalString(attrs, "shadowColor", "shape.attrs.shadowColor", issues);
|
|
530
585
|
optionalNumber(attrs, "shadowBlur", "shape.attrs.shadowBlur", issues);
|
|
531
586
|
optionalNumber(attrs, "shadowOffsetX", "shape.attrs.shadowOffsetX", issues);
|
|
@@ -554,6 +609,9 @@ const readTextBoxAttrs = (node) => {
|
|
|
554
609
|
optionalString(attrs, "outlineColor", "textBox.attrs.outlineColor", issues);
|
|
555
610
|
optionalOneOf(attrs, "outlineStyle", "textBox.attrs.outlineStyle", issues, OUTLINE_STYLE_ATTR_VALUES);
|
|
556
611
|
optionalTextBoxTransform(attrs, "transform", "textBox.attrs.transform", issues);
|
|
612
|
+
optionalNumber(attrs, "docxRotation", "textBox.attrs.docxRotation", issues);
|
|
613
|
+
optionalBoolean(attrs, "docxFlipH", "textBox.attrs.docxFlipH", issues);
|
|
614
|
+
optionalBoolean(attrs, "docxFlipV", "textBox.attrs.docxFlipV", issues);
|
|
557
615
|
optionalNumber(attrs, "marginTop", "textBox.attrs.marginTop", issues);
|
|
558
616
|
optionalNumber(attrs, "marginBottom", "textBox.attrs.marginBottom", issues);
|
|
559
617
|
optionalNumber(attrs, "marginLeft", "textBox.attrs.marginLeft", issues);
|
|
@@ -568,12 +626,17 @@ const readTextBoxAttrs = (node) => {
|
|
|
568
626
|
optionalNumber(attrs, "distLeft", "textBox.attrs.distLeft", issues);
|
|
569
627
|
optionalNumber(attrs, "distRight", "textBox.attrs.distRight", issues);
|
|
570
628
|
optionalImagePosition(attrs, "position", "textBox.attrs.position", issues);
|
|
629
|
+
optionalDrawingAnchor(attrs, "anchor", "textBox.attrs.anchor", issues);
|
|
630
|
+
optionalWrapDistanceSlots(attrs, "wrapDistanceSlots", "textBox.attrs.wrapDistanceSlots", issues);
|
|
631
|
+
optionalEffectExtentSlots(attrs, "wrapEffectExtentSlots", "textBox.attrs.wrapEffectExtentSlots", issues);
|
|
632
|
+
optionalWrapPolygon(attrs, "wrapPolygon", "textBox.attrs.wrapPolygon", issues);
|
|
571
633
|
optionalOneOf(attrs, "_docxPlacement", "textBox.attrs._docxPlacement", issues, TEXT_BOX_DOCX_PLACEMENTS);
|
|
572
634
|
optionalString(attrs, "_docxGroupId", "textBox.attrs._docxGroupId", issues);
|
|
573
635
|
optionalString(attrs, "_docxAnchorId", "textBox.attrs._docxAnchorId", issues);
|
|
574
636
|
requiredTextBoxBodyContentState(attrs, issues);
|
|
575
637
|
optionalTextBoxTrackedChange(attrs, issues);
|
|
576
638
|
optionalTextBoxInlineSdts(attrs, issues);
|
|
639
|
+
optionalPreservedAttributes(attrs, "_preservedAttributes", "textBox.attrs._preservedAttributes", issues);
|
|
577
640
|
return attrsResult(attrs, issues);
|
|
578
641
|
};
|
|
579
642
|
const expectTextBoxAttrs = (node) => expectCachedNodeAttrs(node, textBoxAttrsCache, readTextBoxAttrs, "text box attrs");
|
|
@@ -727,6 +790,7 @@ const readTrackedChangeMarkAttrs = (mark) => {
|
|
|
727
790
|
optionalOneOf(attrs, "moveKind", `${mark.type.name}.attrs.moveKind`, issues, TRACKED_CHANGE_MOVE_KINDS);
|
|
728
791
|
optionalOneOf(attrs, "provenance", `${mark.type.name}.attrs.provenance`, issues, TRACKED_CHANGE_PROVENANCE_VALUES);
|
|
729
792
|
optionalString(attrs, "suggestionId", `${mark.type.name}.attrs.suggestionId`, issues);
|
|
793
|
+
optionalBoolean(attrs, "_historicalFormatting", `${mark.type.name}.attrs._historicalFormatting`, issues);
|
|
730
794
|
return attrsResult(attrs, issues);
|
|
731
795
|
};
|
|
732
796
|
const expectTrackedChangeMarkAttrs = (mark) => expectCachedMarkAttrs(mark, trackedChangeAttrsCache, readTrackedChangeMarkAttrs, "tracked change attrs");
|
|
@@ -740,18 +804,141 @@ const readRunPropertyChangeMarkAttrs = (mark) => {
|
|
|
740
804
|
return attrsResult(attrs, issues);
|
|
741
805
|
};
|
|
742
806
|
const expectRunPropertyChangeMarkAttrs = (mark) => expectCachedMarkAttrs(mark, runPropertyChangeAttrsCache, readRunPropertyChangeMarkAttrs, "run property change attrs");
|
|
743
|
-
|
|
807
|
+
/**
|
|
808
|
+
* The identity mark's payload, field by field.
|
|
809
|
+
*
|
|
810
|
+
* Every field is read strictly because the mark reaches this build from three
|
|
811
|
+
* places it does not control: a paste, a collaboration snapshot written by
|
|
812
|
+
* another build, and a host that edited the document through the public API.
|
|
813
|
+
* A remainder entry that is not a resolved name and a string value would be
|
|
814
|
+
* written straight back into a `w:r` start tag.
|
|
815
|
+
*/
|
|
816
|
+
const readRunIdentityMarkAttrs = (mark) => {
|
|
744
817
|
const attrs = attrsRecord(mark.attrs);
|
|
745
818
|
const issues = [];
|
|
746
|
-
expectMarkType(mark, "
|
|
819
|
+
expectMarkType(mark, "runIdentity", issues);
|
|
747
820
|
const id = attrs["id"];
|
|
748
821
|
if (typeof id !== "number" || !Number.isSafeInteger(id) || id < 0) issues.push({
|
|
749
|
-
path: "
|
|
822
|
+
path: "runIdentity.attrs.id",
|
|
750
823
|
message: "Expected a non-negative safe integer."
|
|
751
824
|
});
|
|
825
|
+
optionalPreservedAttributes(attrs, "preservedAttributes", "runIdentity.attrs.preservedAttributes", issues);
|
|
826
|
+
optionalPreservedMarkup(attrs, "preserved", "runIdentity.attrs.preserved", issues);
|
|
827
|
+
return attrsResult(attrs, issues);
|
|
828
|
+
};
|
|
829
|
+
const expectRunIdentityMarkAttrs = (mark) => expectCachedMarkAttrs(mark, runIdentityAttrsCache, readRunIdentityMarkAttrs, "run identity attrs");
|
|
830
|
+
const BIDI_LAYER_CONTROLS = ["embedding", "override"];
|
|
831
|
+
const BIDI_LAYER_DIRECTIONS = ["ltr", "rtl"];
|
|
832
|
+
const BIDI_LAYER_KEYS = /* @__PURE__ */ new Set([
|
|
833
|
+
"kind",
|
|
834
|
+
"control",
|
|
835
|
+
"direction"
|
|
836
|
+
]);
|
|
837
|
+
const TAGGED_LAYER_KEYS = /* @__PURE__ */ new Set([
|
|
838
|
+
"kind",
|
|
839
|
+
"element",
|
|
840
|
+
"uri",
|
|
841
|
+
"propertiesXml"
|
|
842
|
+
]);
|
|
843
|
+
/**
|
|
844
|
+
* `w:smartTag` and the run-level `w:customXml` declare the same three slots.
|
|
845
|
+
*
|
|
846
|
+
* `element` is required by both content models. `uri` and `propertiesXml` are
|
|
847
|
+
* optional and must be absent rather than `null`: the model spells an absent
|
|
848
|
+
* field as absent, and a `null` stored on the layer would reach the serializer
|
|
849
|
+
* as a `w:uri=""` the source never wrote.
|
|
850
|
+
*/
|
|
851
|
+
const taggedLayerValidator = (label) => (layer, path, issues) => {
|
|
852
|
+
requiredString(layer, "element", `${path}.element`, issues);
|
|
853
|
+
for (const key of ["uri", "propertiesXml"]) if (layer[key] !== void 0 && typeof layer[key] !== "string") issues.push({
|
|
854
|
+
path: `${path}.${key}`,
|
|
855
|
+
message: "Expected a string."
|
|
856
|
+
});
|
|
857
|
+
for (const key of Object.keys(layer)) if (!TAGGED_LAYER_KEYS.has(key)) issues.push({
|
|
858
|
+
path: `${path}.${key}`,
|
|
859
|
+
message: `Unexpected ${label} wrapper property.`
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
/**
|
|
863
|
+
* One validator per wrapper kind, total over the kinds the model declares: a
|
|
864
|
+
* kind added without a field-by-field check does not compile, and a layer that
|
|
865
|
+
* states a field its kind does not carry (a smart tag with a bidi `control`)
|
|
866
|
+
* is rejected rather than stored and written back.
|
|
867
|
+
*/
|
|
868
|
+
const INLINE_WRAPPER_LAYER_VALIDATORS = {
|
|
869
|
+
bidi: (layer, path, issues) => {
|
|
870
|
+
requiredOneOf(layer, "control", `${path}.control`, issues, BIDI_LAYER_CONTROLS);
|
|
871
|
+
optionalOneOf(layer, "direction", `${path}.direction`, issues, BIDI_LAYER_DIRECTIONS);
|
|
872
|
+
for (const key of Object.keys(layer)) if (!BIDI_LAYER_KEYS.has(key)) issues.push({
|
|
873
|
+
path: `${path}.${key}`,
|
|
874
|
+
message: "Unexpected bidi wrapper property."
|
|
875
|
+
});
|
|
876
|
+
},
|
|
877
|
+
smartTag: taggedLayerValidator("smart tag"),
|
|
878
|
+
customXml: taggedLayerValidator("custom XML")
|
|
879
|
+
};
|
|
880
|
+
const inlineWrapperLayerValidator = (kind) => {
|
|
881
|
+
return typeof kind === "string" ? INLINE_WRAPPER_LAYER_VALIDATORS[kind] : void 0;
|
|
882
|
+
};
|
|
883
|
+
const validateInlineWrapperStack = (value, path, issues) => {
|
|
884
|
+
if (!Array.isArray(value)) {
|
|
885
|
+
issues.push({
|
|
886
|
+
path,
|
|
887
|
+
message: "Expected an array of inline wrapper layers."
|
|
888
|
+
});
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (value.length === 0) {
|
|
892
|
+
issues.push({
|
|
893
|
+
path,
|
|
894
|
+
message: "Expected at least one inline wrapper layer."
|
|
895
|
+
});
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
for (const [index, layer] of value.entries()) {
|
|
899
|
+
const layerPath = `${path}[${index}]`;
|
|
900
|
+
if (!isRecord(layer)) {
|
|
901
|
+
issues.push({
|
|
902
|
+
path: layerPath,
|
|
903
|
+
message: "Expected an inline wrapper layer object."
|
|
904
|
+
});
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
const validator = inlineWrapperLayerValidator(layer["kind"]);
|
|
908
|
+
if (!validator) {
|
|
909
|
+
issues.push({
|
|
910
|
+
path: `${layerPath}.kind`,
|
|
911
|
+
message: `Expected one of ${Object.keys(INLINE_WRAPPER_LAYER_VALIDATORS).join(", ")}.`
|
|
912
|
+
});
|
|
913
|
+
continue;
|
|
914
|
+
}
|
|
915
|
+
validator(layer, layerPath, issues);
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* A wrapper stack read from outside the editor — the DOM on paste, a stored
|
|
920
|
+
* snapshot — validated layer by layer.
|
|
921
|
+
*/
|
|
922
|
+
const readInlineWrapperStack = (value, path = "inlineWrapper.attrs.stack") => {
|
|
923
|
+
const issues = [];
|
|
924
|
+
validateInlineWrapperStack(value, path, issues);
|
|
925
|
+
if (issues.length > 0) return {
|
|
926
|
+
ok: false,
|
|
927
|
+
issues
|
|
928
|
+
};
|
|
929
|
+
return {
|
|
930
|
+
ok: true,
|
|
931
|
+
value
|
|
932
|
+
};
|
|
933
|
+
};
|
|
934
|
+
const readInlineWrapperMarkAttrs = (mark) => {
|
|
935
|
+
const attrs = attrsRecord(mark.attrs);
|
|
936
|
+
const issues = [];
|
|
937
|
+
expectMarkType(mark, "inlineWrapper", issues);
|
|
938
|
+
validateInlineWrapperStack(attrs["stack"], "inlineWrapper.attrs.stack", issues);
|
|
752
939
|
return attrsResult(attrs, issues);
|
|
753
940
|
};
|
|
754
|
-
const
|
|
941
|
+
const expectInlineWrapperMarkAttrs = (mark) => expectCachedMarkAttrs(mark, inlineWrapperAttrsCache, readInlineWrapperMarkAttrs, "inline wrapper attrs");
|
|
755
942
|
const readRunFormattingOverrideMarkAttrs = (mark) => {
|
|
756
943
|
const attrs = attrsRecord(mark.attrs);
|
|
757
944
|
const issues = [];
|
|
@@ -870,7 +1057,30 @@ const mergeImageAttrs = (node, patch) => {
|
|
|
870
1057
|
const mergeParagraphAttrs = (node, patch) => mergeNodeAttrs(node, readParagraphAttrs, "paragraph attrs", patch);
|
|
871
1058
|
const mergeTableAttrs = (node, patch) => mergeNodeAttrs(node, readTableAttrs, "table attrs", patch);
|
|
872
1059
|
const mergeTableRowAttrs = (node, patch) => mergeNodeAttrs(node, readTableRowAttrs, "table row attrs", patch);
|
|
873
|
-
|
|
1060
|
+
/**
|
|
1061
|
+
* A command that moves a cell's width states one.
|
|
1062
|
+
*
|
|
1063
|
+
* `width` is also where the table's resolved grid width lands for a cell that
|
|
1064
|
+
* declares no `w:tcW`, so the save leg reads `_authoredWidth` instead. Deriving
|
|
1065
|
+
* it here rather than at each command keeps the two from drifting: a command
|
|
1066
|
+
* cannot set a width without recording that the cell now states it, and one
|
|
1067
|
+
* that clears the width clears the record with it.
|
|
1068
|
+
*/
|
|
1069
|
+
const mergeTableCellAttrs = (node, patch) => {
|
|
1070
|
+
const merged = mergeNodeAttrs(node, readTableCellAttrs, "table cell attrs", patch);
|
|
1071
|
+
if (!("width" in patch) && !("widthType" in patch)) return merged;
|
|
1072
|
+
if (merged.width === void 0) {
|
|
1073
|
+
const { _authoredWidth: _cleared, ...withoutStatedWidth } = merged;
|
|
1074
|
+
return withoutStatedWidth;
|
|
1075
|
+
}
|
|
1076
|
+
return {
|
|
1077
|
+
...merged,
|
|
1078
|
+
_authoredWidth: {
|
|
1079
|
+
value: merged.width,
|
|
1080
|
+
type: merged.widthType ?? "dxa"
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
};
|
|
874
1084
|
const attrsRecord = (attrs) => {
|
|
875
1085
|
if (isRecord(attrs)) return attrs;
|
|
876
1086
|
return {};
|
|
@@ -1139,7 +1349,7 @@ const optionalTextColor = (attrs, key, path, issues) => {
|
|
|
1139
1349
|
};
|
|
1140
1350
|
const optionalTextColorFields = (attrs, path, issues) => {
|
|
1141
1351
|
optionalString(attrs, "rgb", `${path}.rgb`, issues);
|
|
1142
|
-
optionalOneOf(attrs, "themeColor", `${path}.themeColor`, issues,
|
|
1352
|
+
optionalOneOf(attrs, "themeColor", `${path}.themeColor`, issues, THEME_COLORS);
|
|
1143
1353
|
optionalString(attrs, "themeTint", `${path}.themeTint`, issues);
|
|
1144
1354
|
optionalString(attrs, "themeShade", `${path}.themeShade`, issues);
|
|
1145
1355
|
};
|
|
@@ -1163,6 +1373,36 @@ const optionalBoolean = (attrs, key, path, issues) => {
|
|
|
1163
1373
|
message: "Expected a boolean."
|
|
1164
1374
|
});
|
|
1165
1375
|
};
|
|
1376
|
+
/**
|
|
1377
|
+
* `outlineLevel` is a union, and a bare number is the shape a pre-union
|
|
1378
|
+
* snapshot carries. Rejecting it is what keeps that snapshot from being read
|
|
1379
|
+
* as if it were this one: ProseMirror's `computeAttrs` copies a stored value
|
|
1380
|
+
* into the node without validating, so an unrecognised shape would otherwise
|
|
1381
|
+
* reach every consumer as an outline level none of them can read and all of
|
|
1382
|
+
* them ignore.
|
|
1383
|
+
*/
|
|
1384
|
+
const optionalOutlineLevel = (attrs, key, path, issues) => {
|
|
1385
|
+
const value = attrs[key];
|
|
1386
|
+
if (value === void 0 || value === null) return;
|
|
1387
|
+
if (outlineLevelFromAttrValue(value) === null) issues.push({
|
|
1388
|
+
path,
|
|
1389
|
+
message: "Expected { kind: \"bodyText\" } or { kind: \"heading\", level: 0-8 }."
|
|
1390
|
+
});
|
|
1391
|
+
};
|
|
1392
|
+
/**
|
|
1393
|
+
* Strict, field by field, per arm. An object with no known `kind` is refused
|
|
1394
|
+
* rather than read as the arm it is not: the pre-union shape (the two
|
|
1395
|
+
* `<w:numPr>` slots) is exactly such an object, ProseMirror copies a stored
|
|
1396
|
+
* attr into the node without validating, and every consumer switches on `kind`.
|
|
1397
|
+
*/
|
|
1398
|
+
const optionalParagraphNumbering = (attrs, key, path, issues) => {
|
|
1399
|
+
const value = attrs[key];
|
|
1400
|
+
if (value === void 0 || value === null) return;
|
|
1401
|
+
if (paragraphNumberingFromAttrValue(value) === null) issues.push({
|
|
1402
|
+
path,
|
|
1403
|
+
message: "Expected { kind: \"none\" }, { kind: \"reference\", numId: 1+, ilvl?: 0+ } or { kind: \"levelOnly\", ilvl: 0+ }."
|
|
1404
|
+
});
|
|
1405
|
+
};
|
|
1166
1406
|
const optionalRecord = (attrs, key, path, issues) => {
|
|
1167
1407
|
const value = attrs[key];
|
|
1168
1408
|
if (value !== void 0 && value !== null && !isRecord(value)) issues.push({
|
|
@@ -1170,6 +1410,21 @@ const optionalRecord = (attrs, key, path, issues) => {
|
|
|
1170
1410
|
message: "Expected an object."
|
|
1171
1411
|
});
|
|
1172
1412
|
};
|
|
1413
|
+
/** `TableCellAttrs._authoredWidth`: a measurement, or absent. */
|
|
1414
|
+
const optionalAuthoredWidth = (attrs, issues) => {
|
|
1415
|
+
const value = attrs["_authoredWidth"];
|
|
1416
|
+
if (value === void 0 || value === null) return;
|
|
1417
|
+
const path = "tableCell.attrs._authoredWidth";
|
|
1418
|
+
if (!isRecord(value)) {
|
|
1419
|
+
issues.push({
|
|
1420
|
+
path,
|
|
1421
|
+
message: "Expected an object."
|
|
1422
|
+
});
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
requiredNumber(value, "value", `${path}.value`, issues);
|
|
1426
|
+
requiredOneOf(value, "type", `${path}.type`, issues, TABLE_WIDTH_TYPE_VALUES);
|
|
1427
|
+
};
|
|
1173
1428
|
const optionalTableRowRevision = (attrs, key, issues) => {
|
|
1174
1429
|
const value = attrs[key];
|
|
1175
1430
|
if (value === void 0 || value === null) return;
|
|
@@ -1303,8 +1558,197 @@ const validateSdtAttrsRecord = (attrs, path, issues) => {
|
|
|
1303
1558
|
optionalSdtListItems(attrs, "listItems", `${path}.listItems`, issues);
|
|
1304
1559
|
optionalString(attrs, "dropdownLastValue", `${path}.dropdownLastValue`, issues);
|
|
1305
1560
|
optionalBoolean(attrs, "checked", `${path}.checked`, issues);
|
|
1306
|
-
|
|
1561
|
+
optionalPreservedMarkup(attrs, "_preserved", `${path}._preserved`, issues);
|
|
1307
1562
|
optionalString(attrs, "rawEndPropertiesXml", `${path}.rawEndPropertiesXml`, issues);
|
|
1563
|
+
optionalSdtEndProperties(attrs, `${path}.endProperties`, issues);
|
|
1564
|
+
};
|
|
1565
|
+
/**
|
|
1566
|
+
* The attribute remainder an authored element's record carries.
|
|
1567
|
+
*
|
|
1568
|
+
* Every entry is a resolved name and a string value; nothing here is a
|
|
1569
|
+
* spelling, which is why the namespace is a URI and optional rather than a
|
|
1570
|
+
* prefix. See `docx/attributeRemainder.ts`.
|
|
1571
|
+
*/
|
|
1572
|
+
/**
|
|
1573
|
+
* The stack of row- or cell-level content controls a table node carries.
|
|
1574
|
+
*
|
|
1575
|
+
* Only `sdtType` is required: the rest of `SdtProperties` is an optional
|
|
1576
|
+
* projection over a `w:sdtPr` whose bytes the record also carries, and a
|
|
1577
|
+
* reader that demanded more would reject a control folio itself built.
|
|
1578
|
+
*/
|
|
1579
|
+
const optionalContentControls = (attrs, path, issues) => {
|
|
1580
|
+
const value = attrs["contentControls"];
|
|
1581
|
+
if (value === void 0 || value === null) return;
|
|
1582
|
+
if (!Array.isArray(value)) {
|
|
1583
|
+
issues.push({
|
|
1584
|
+
path,
|
|
1585
|
+
message: "Expected an array."
|
|
1586
|
+
});
|
|
1587
|
+
return;
|
|
1588
|
+
}
|
|
1589
|
+
for (const [index, entry] of value.entries()) {
|
|
1590
|
+
const entryPath = `${path}[${index}]`;
|
|
1591
|
+
if (!isRecord(entry)) {
|
|
1592
|
+
issues.push({
|
|
1593
|
+
path: entryPath,
|
|
1594
|
+
message: "Expected an object."
|
|
1595
|
+
});
|
|
1596
|
+
continue;
|
|
1597
|
+
}
|
|
1598
|
+
requiredString(entry, "sdtType", `${entryPath}.sdtType`, issues);
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
/** A table sink entry may itself sit inside a row- or cell-level control. */
|
|
1602
|
+
const optionalTablePreservedMarkup = (attrs, key, path, issues) => {
|
|
1603
|
+
optionalPreservedMarkup(attrs, key, path, issues);
|
|
1604
|
+
const value = attrs[key];
|
|
1605
|
+
if (!isRecord(value) || !Array.isArray(value["children"])) return;
|
|
1606
|
+
for (const [index, child] of value["children"].entries()) {
|
|
1607
|
+
if (!isRecord(child)) continue;
|
|
1608
|
+
optionalContentControls(child, `${path}.children[${index}].contentControls`, issues);
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
/**
|
|
1612
|
+
* `w:sdtEndPr` as a record: an object whose presence is the element's, with
|
|
1613
|
+
* optional run properties inside. `optionalTextFormatting` owns the shape of
|
|
1614
|
+
* those, so the reader stays one line rather than a second copy of `w:rPr`.
|
|
1615
|
+
*/
|
|
1616
|
+
const optionalSdtEndProperties = (attrs, path, issues) => {
|
|
1617
|
+
const value = attrs["endProperties"];
|
|
1618
|
+
if (value === void 0 || value === null) return;
|
|
1619
|
+
if (!isRecord(value)) {
|
|
1620
|
+
issues.push({
|
|
1621
|
+
path,
|
|
1622
|
+
message: "Expected an object."
|
|
1623
|
+
});
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
optionalTextFormatting(value, "runProperties", `${path}.runProperties`, issues);
|
|
1627
|
+
};
|
|
1628
|
+
const optionalPreservedAttributes = (attrs, key, path, issues) => {
|
|
1629
|
+
const value = attrs[key];
|
|
1630
|
+
if (value === void 0 || value === null) return;
|
|
1631
|
+
if (!Array.isArray(value)) {
|
|
1632
|
+
issues.push({
|
|
1633
|
+
path,
|
|
1634
|
+
message: "Expected an array."
|
|
1635
|
+
});
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1638
|
+
for (const [index, entry] of value.entries()) {
|
|
1639
|
+
const entryPath = `${path}[${index}]`;
|
|
1640
|
+
if (!isRecord(entry)) {
|
|
1641
|
+
issues.push({
|
|
1642
|
+
path: entryPath,
|
|
1643
|
+
message: "Expected an object."
|
|
1644
|
+
});
|
|
1645
|
+
continue;
|
|
1646
|
+
}
|
|
1647
|
+
requiredString(entry, "name", `${entryPath}.name`, issues);
|
|
1648
|
+
requiredString(entry, "value", `${entryPath}.value`, issues);
|
|
1649
|
+
optionalString(entry, "namespace", `${entryPath}.namespace`, issues);
|
|
1650
|
+
const name = entry["name"];
|
|
1651
|
+
const namespace = entry["namespace"];
|
|
1652
|
+
if (typeof name === "string" && (namespace === void 0 || typeof namespace === "string") && !isSerializablePreservedAttribute({
|
|
1653
|
+
name,
|
|
1654
|
+
...namespace === void 0 ? {} : { namespace }
|
|
1655
|
+
})) issues.push({
|
|
1656
|
+
path: `${entryPath}.name`,
|
|
1657
|
+
message: "Expected an XML local name in a namespace the serializer binds."
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
};
|
|
1661
|
+
const optionalPreservedMarkup = (attrs, key, path, issues) => {
|
|
1662
|
+
const value = attrs[key];
|
|
1663
|
+
if (value === void 0 || value === null) return;
|
|
1664
|
+
if (!isRecord(value)) {
|
|
1665
|
+
issues.push({
|
|
1666
|
+
path,
|
|
1667
|
+
message: "Expected an object."
|
|
1668
|
+
});
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
const children = value["children"];
|
|
1672
|
+
if (children === void 0 || children === null) return;
|
|
1673
|
+
if (!Array.isArray(children)) {
|
|
1674
|
+
issues.push({
|
|
1675
|
+
path: `${path}.children`,
|
|
1676
|
+
message: "Expected an array."
|
|
1677
|
+
});
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
if (!isWithinPreservedMarkupBudget(children)) {
|
|
1681
|
+
issues.push({
|
|
1682
|
+
path: `${path}.children`,
|
|
1683
|
+
message: "Preserved XML exceeds its aggregate count or character budget."
|
|
1684
|
+
});
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
for (const [index, entry] of children.entries()) {
|
|
1688
|
+
const entryPath = `${path}.children[${index}]`;
|
|
1689
|
+
if (!isRecord(entry)) {
|
|
1690
|
+
issues.push({
|
|
1691
|
+
path: entryPath,
|
|
1692
|
+
message: "Expected an object."
|
|
1693
|
+
});
|
|
1694
|
+
continue;
|
|
1695
|
+
}
|
|
1696
|
+
requiredNumber(entry, "index", `${entryPath}.index`, issues);
|
|
1697
|
+
requiredString(entry, "xml", `${entryPath}.xml`, issues);
|
|
1698
|
+
const xml = entry["xml"];
|
|
1699
|
+
if (typeof xml === "string" && !isSafePreservedChildXml(xml)) issues.push({
|
|
1700
|
+
path: `${entryPath}.xml`,
|
|
1701
|
+
message: "Expected one bounded, well-formed XML element."
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
/**
|
|
1706
|
+
* Bookmark markers a table or a row held beside its own children.
|
|
1707
|
+
*
|
|
1708
|
+
* Each entry is a position among those children and the marker that stood
|
|
1709
|
+
* there. The marker itself is the same shape the boundary node carries, so it
|
|
1710
|
+
* is validated the same way: an id, and a name when it is a start.
|
|
1711
|
+
*/
|
|
1712
|
+
const optionalPositionedBookmarks = (attrs, path, issues) => {
|
|
1713
|
+
const value = attrs["_bookmarks"];
|
|
1714
|
+
if (value === void 0 || value === null) return;
|
|
1715
|
+
if (!Array.isArray(value)) {
|
|
1716
|
+
issues.push({
|
|
1717
|
+
path,
|
|
1718
|
+
message: "Expected an array."
|
|
1719
|
+
});
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
for (const [index, entry] of value.entries()) {
|
|
1723
|
+
const entryPath = `${path}[${index}]`;
|
|
1724
|
+
if (!isRecord(entry)) {
|
|
1725
|
+
issues.push({
|
|
1726
|
+
path: entryPath,
|
|
1727
|
+
message: "Expected an object."
|
|
1728
|
+
});
|
|
1729
|
+
continue;
|
|
1730
|
+
}
|
|
1731
|
+
requiredNumber(entry, "index", `${entryPath}.index`, issues);
|
|
1732
|
+
const marker = entry["marker"];
|
|
1733
|
+
if (!isRecord(marker)) {
|
|
1734
|
+
issues.push({
|
|
1735
|
+
path: `${entryPath}.marker`,
|
|
1736
|
+
message: "Expected an object."
|
|
1737
|
+
});
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1740
|
+
const type = marker["type"];
|
|
1741
|
+
if (type !== "bookmarkStart" && type !== "bookmarkEnd") {
|
|
1742
|
+
issues.push({
|
|
1743
|
+
path: `${entryPath}.marker.type`,
|
|
1744
|
+
message: "Expected \"bookmarkStart\" or \"bookmarkEnd\"."
|
|
1745
|
+
});
|
|
1746
|
+
continue;
|
|
1747
|
+
}
|
|
1748
|
+
requiredNumber(marker, "id", `${entryPath}.marker.id`, issues);
|
|
1749
|
+
if (type === "bookmarkStart") requiredString(marker, "name", `${entryPath}.marker.name`, issues);
|
|
1750
|
+
optionalContentControls(entry, `${entryPath}.contentControls`, issues);
|
|
1751
|
+
}
|
|
1308
1752
|
};
|
|
1309
1753
|
const optionalAutospacingBase = (attrs, path, issues) => {
|
|
1310
1754
|
const value = attrs["_autospacingBase"];
|
|
@@ -1346,6 +1790,7 @@ const validateBorderSpec = (value, path, issues) => {
|
|
|
1346
1790
|
optionalBoolean(value, "shadow", `${path}.shadow`, issues);
|
|
1347
1791
|
optionalBoolean(value, "frame", `${path}.frame`, issues);
|
|
1348
1792
|
optionalColorValue(value, "color", `${path}.color`, issues);
|
|
1793
|
+
optionalPreservedAttributes(value, "preservedAttributes", `${path}.preservedAttributes`, issues);
|
|
1349
1794
|
};
|
|
1350
1795
|
const optionalColorValue = (attrs, key, path, issues) => {
|
|
1351
1796
|
const value = attrs[key];
|
|
@@ -1359,7 +1804,7 @@ const optionalColorValue = (attrs, key, path, issues) => {
|
|
|
1359
1804
|
}
|
|
1360
1805
|
optionalString(value, "rgb", `${path}.rgb`, issues);
|
|
1361
1806
|
optionalBoolean(value, "auto", `${path}.auto`, issues);
|
|
1362
|
-
optionalOneOf(value, "themeColor", `${path}.themeColor`, issues,
|
|
1807
|
+
optionalOneOf(value, "themeColor", `${path}.themeColor`, issues, THEME_COLORS);
|
|
1363
1808
|
optionalString(value, "themeTint", `${path}.themeTint`, issues);
|
|
1364
1809
|
optionalString(value, "themeShade", `${path}.themeShade`, issues);
|
|
1365
1810
|
};
|
|
@@ -1376,6 +1821,7 @@ const optionalShading = (attrs, key, path, issues) => {
|
|
|
1376
1821
|
optionalColorValue(value, "color", `${path}.color`, issues);
|
|
1377
1822
|
optionalColorValue(value, "fill", `${path}.fill`, issues);
|
|
1378
1823
|
optionalOneOf(value, "pattern", `${path}.pattern`, issues, SHADING_PATTERN_VALUES);
|
|
1824
|
+
optionalPreservedAttributes(value, "preservedAttributes", `${path}.preservedAttributes`, issues);
|
|
1379
1825
|
};
|
|
1380
1826
|
const optionalTabStops = (attrs, key, path, issues) => {
|
|
1381
1827
|
const value = attrs[key];
|
|
@@ -1399,6 +1845,7 @@ const optionalTabStops = (attrs, key, path, issues) => {
|
|
|
1399
1845
|
requiredNumber(item, "position", `${itemPath}.position`, issues);
|
|
1400
1846
|
requiredOneOf(item, "alignment", `${itemPath}.alignment`, issues, TAB_STOP_ALIGNMENT_VALUES);
|
|
1401
1847
|
optionalOneOf(item, "leader", `${itemPath}.leader`, issues, TAB_LEADER_VALUES);
|
|
1848
|
+
optionalPreservedAttributes(item, "preservedAttributes", `${itemPath}.preservedAttributes`, issues);
|
|
1402
1849
|
}
|
|
1403
1850
|
};
|
|
1404
1851
|
const optionalTextFormatting = (attrs, key, path, issues) => {
|
|
@@ -1637,8 +2084,7 @@ const PARAGRAPH_FORMATTING_NUMBER_KEYS = [
|
|
|
1637
2084
|
"lineSpacing",
|
|
1638
2085
|
"indentLeft",
|
|
1639
2086
|
"indentRight",
|
|
1640
|
-
"indentFirstLine"
|
|
1641
|
-
"outlineLevel"
|
|
2087
|
+
"indentFirstLine"
|
|
1642
2088
|
];
|
|
1643
2089
|
const validateParagraphFormatting = (value, path, issues) => {
|
|
1644
2090
|
optionalOneOf(value, "alignment", `${path}.alignment`, issues, PARAGRAPH_ALIGNMENT_VALUES);
|
|
@@ -1651,6 +2097,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1651
2097
|
"listMarkerAllCaps"
|
|
1652
2098
|
]) optionalBoolean(value, key, `${path}.${key}`, issues);
|
|
1653
2099
|
for (const key of PARAGRAPH_FORMATTING_NUMBER_KEYS) optionalNumber(value, key, `${path}.${key}`, issues);
|
|
2100
|
+
optionalOutlineLevel(value, "outlineLevel", `${path}.outlineLevel`, issues);
|
|
1654
2101
|
for (const key of [
|
|
1655
2102
|
"listImplicitChildLevelAdvances",
|
|
1656
2103
|
"listMarkerSecondSlotOffsetTwips",
|
|
@@ -1660,7 +2107,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1660
2107
|
optionalOneOf(value, "lineSpacingRule", `${path}.lineSpacingRule`, issues, LINE_SPACING_RULE_VALUES);
|
|
1661
2108
|
optionalString(value, "styleId", `${path}.styleId`, issues);
|
|
1662
2109
|
optionalString(value, "numberingChangeXml", `${path}.numberingChangeXml`, issues);
|
|
1663
|
-
optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues,
|
|
2110
|
+
optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues, COUNTER_FORMAT_VALUES);
|
|
1664
2111
|
optionalString(value, "listMarker", `${path}.listMarker`, issues);
|
|
1665
2112
|
optionalString(value, "listMarkerTemplate", `${path}.listMarkerTemplate`, issues);
|
|
1666
2113
|
optionalTextFormatting(value, "listMarkerFormatting", `${path}.listMarkerFormatting`, issues);
|
|
@@ -1674,22 +2121,10 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1674
2121
|
"space",
|
|
1675
2122
|
"nothing"
|
|
1676
2123
|
]);
|
|
1677
|
-
optionalOneOfArray(value, "listLevelNumFmts", `${path}.listLevelNumFmts`, issues,
|
|
2124
|
+
optionalOneOfArray(value, "listLevelNumFmts", `${path}.listLevelNumFmts`, issues, COUNTER_FORMAT_VALUES);
|
|
1678
2125
|
optionalNumberArray(value, "listLevelStarts", `${path}.listLevelStarts`, issues);
|
|
1679
2126
|
optionalAutospacingBase(value, `${path}._autospacingBase`, issues);
|
|
1680
|
-
for (const key of ["numPr", "numPrFromStyle"]) {
|
|
1681
|
-
const nested = value[key];
|
|
1682
|
-
if (nested === void 0 || nested === null) continue;
|
|
1683
|
-
if (!isRecord(nested)) {
|
|
1684
|
-
issues.push({
|
|
1685
|
-
path: `${path}.${key}`,
|
|
1686
|
-
message: "Expected an object."
|
|
1687
|
-
});
|
|
1688
|
-
continue;
|
|
1689
|
-
}
|
|
1690
|
-
optionalNumber(nested, "numId", `${path}.${key}.numId`, issues);
|
|
1691
|
-
optionalNumber(nested, "ilvl", `${path}.${key}.ilvl`, issues);
|
|
1692
|
-
}
|
|
2127
|
+
for (const key of ["numPr", "numPrFromStyle"]) optionalParagraphNumbering(value, key, `${path}.${key}`, issues);
|
|
1693
2128
|
const direction = value["direction"];
|
|
1694
2129
|
if (direction !== void 0 && direction !== null && !isParagraphDirection(direction)) issues.push({
|
|
1695
2130
|
path: `${path}.direction`,
|
|
@@ -1722,6 +2157,8 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1722
2157
|
]);
|
|
1723
2158
|
optionalShading(value, "shading", `${path}.shading`, issues);
|
|
1724
2159
|
optionalTabStops(value, "tabs", `${path}.tabs`, issues);
|
|
2160
|
+
optionalPreservedMarkup(value, "preserved", `${path}.preserved`, issues);
|
|
2161
|
+
for (const key of ["indentPreservedAttributes", "spacingPreservedAttributes"]) optionalPreservedAttributes(value, key, `${path}.${key}`, issues);
|
|
1725
2162
|
optionalNestedRecord(value, "runProperties", `${path}.runProperties`, issues, validateTextFormatting);
|
|
1726
2163
|
const frame = value["frame"];
|
|
1727
2164
|
if (frame !== void 0 && frame !== null) if (!isRecord(frame)) issues.push({
|
|
@@ -1776,6 +2213,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1776
2213
|
"x",
|
|
1777
2214
|
"y"
|
|
1778
2215
|
]) optionalNumber(frame, key, `${path}.frame.${key}`, issues);
|
|
2216
|
+
optionalPreservedAttributes(frame, "preservedAttributes", `${path}.frame.preservedAttributes`, issues);
|
|
1779
2217
|
}
|
|
1780
2218
|
};
|
|
1781
2219
|
const validatePropertyChangeInfo = (value, path, issues) => {
|
|
@@ -1834,6 +2272,20 @@ const WRAP_DISTANCE_ATTRS = [
|
|
|
1834
2272
|
"distLeft",
|
|
1835
2273
|
"distRight"
|
|
1836
2274
|
];
|
|
2275
|
+
/** The inset keys the model names them by, which the slot records are keyed on. */
|
|
2276
|
+
const WRAP_DISTANCE_MODEL_KEYS = [
|
|
2277
|
+
"distT",
|
|
2278
|
+
"distB",
|
|
2279
|
+
"distL",
|
|
2280
|
+
"distR"
|
|
2281
|
+
];
|
|
2282
|
+
/** The `wp:effectExtent` sides the model names them by, keyed as the slots are. */
|
|
2283
|
+
const EFFECT_EXTENT_MODEL_KEYS = [
|
|
2284
|
+
"top",
|
|
2285
|
+
"right",
|
|
2286
|
+
"bottom",
|
|
2287
|
+
"left"
|
|
2288
|
+
];
|
|
1837
2289
|
const TEXT_BOX_MARGIN_ATTRS = [
|
|
1838
2290
|
"marginTop",
|
|
1839
2291
|
"marginBottom",
|
|
@@ -1865,6 +2317,150 @@ const optionalImageFrameLocks = (attrs, key, path, issues) => {
|
|
|
1865
2317
|
}
|
|
1866
2318
|
for (const lock of GRAPHIC_FRAME_LOCK_KEYS) optionalBoolean(value, lock, `${path}.${lock}`, issues);
|
|
1867
2319
|
};
|
|
2320
|
+
/**
|
|
2321
|
+
* `wp:anchor`'s own attributes, carried through the editor as one record.
|
|
2322
|
+
*
|
|
2323
|
+
* The walk is over {@link DRAWING_ANCHOR_FLAG_KEYS}, which the serializer's own
|
|
2324
|
+
* total map produces, so a flag added to the model is validated here without a
|
|
2325
|
+
* second list to keep in step.
|
|
2326
|
+
*/
|
|
2327
|
+
const optionalDrawingAnchor = (attrs, key, path, issues) => {
|
|
2328
|
+
const value = attrs[key];
|
|
2329
|
+
if (value === void 0 || value === null) return;
|
|
2330
|
+
if (!isRecord(value)) {
|
|
2331
|
+
issues.push({
|
|
2332
|
+
path,
|
|
2333
|
+
message: "Expected an object."
|
|
2334
|
+
});
|
|
2335
|
+
return;
|
|
2336
|
+
}
|
|
2337
|
+
for (const flag of DRAWING_ANCHOR_FLAG_KEYS) optionalBoolean(value, flag, `${path}.${flag}`, issues);
|
|
2338
|
+
optionalNumber(value, "relativeHeight", `${path}.relativeHeight`, issues);
|
|
2339
|
+
const simplePosition = value["simplePosition"];
|
|
2340
|
+
if (simplePosition === void 0 || simplePosition === null) return;
|
|
2341
|
+
if (!isRecord(simplePosition)) {
|
|
2342
|
+
issues.push({
|
|
2343
|
+
path: `${path}.simplePosition`,
|
|
2344
|
+
message: "Expected an object."
|
|
2345
|
+
});
|
|
2346
|
+
return;
|
|
2347
|
+
}
|
|
2348
|
+
optionalNumber(simplePosition, "x", `${path}.simplePosition.x`, issues);
|
|
2349
|
+
optionalNumber(simplePosition, "y", `${path}.simplePosition.y`, issues);
|
|
2350
|
+
};
|
|
2351
|
+
/** The EMU insets one of the two elements that can carry them stated. */
|
|
2352
|
+
const readWrapDistances = (slots, key, path, issues) => {
|
|
2353
|
+
const value = slots[key];
|
|
2354
|
+
if (value === void 0 || value === null) return;
|
|
2355
|
+
if (!isRecord(value)) {
|
|
2356
|
+
issues.push({
|
|
2357
|
+
path,
|
|
2358
|
+
message: "Expected an object."
|
|
2359
|
+
});
|
|
2360
|
+
return;
|
|
2361
|
+
}
|
|
2362
|
+
for (const inset of WRAP_DISTANCE_MODEL_KEYS) optionalNumber(value, inset, `${path}.${inset}`, issues);
|
|
2363
|
+
};
|
|
2364
|
+
/**
|
|
2365
|
+
* Which element stated each wrap inset, carried so a rebuild writes it back
|
|
2366
|
+
* there. The insets themselves reach the editor twice over — in pixels, and in
|
|
2367
|
+
* EMU on the authored carrier — and neither says which element they came from.
|
|
2368
|
+
*/
|
|
2369
|
+
const optionalWrapDistanceSlots = (attrs, key, path, issues) => {
|
|
2370
|
+
const value = attrs[key];
|
|
2371
|
+
if (value === void 0 || value === null) return;
|
|
2372
|
+
if (!isRecord(value)) {
|
|
2373
|
+
issues.push({
|
|
2374
|
+
path,
|
|
2375
|
+
message: "Expected an object."
|
|
2376
|
+
});
|
|
2377
|
+
return;
|
|
2378
|
+
}
|
|
2379
|
+
readWrapDistances(value, "drawing", `${path}.drawing`, issues);
|
|
2380
|
+
readWrapDistances(value, "wrapChild", `${path}.wrapChild`, issues);
|
|
2381
|
+
};
|
|
2382
|
+
/** The EMU sides one of the two elements that can carry a reservation stated. */
|
|
2383
|
+
const readEffectExtent = (slots, key, path, issues) => {
|
|
2384
|
+
const value = slots[key];
|
|
2385
|
+
if (value === void 0 || value === null) return;
|
|
2386
|
+
if (!isRecord(value)) {
|
|
2387
|
+
issues.push({
|
|
2388
|
+
path,
|
|
2389
|
+
message: "Expected an object."
|
|
2390
|
+
});
|
|
2391
|
+
return;
|
|
2392
|
+
}
|
|
2393
|
+
for (const side of EFFECT_EXTENT_MODEL_KEYS) optionalNumber(value, side, `${path}.${side}`, issues);
|
|
2394
|
+
};
|
|
2395
|
+
/**
|
|
2396
|
+
* Which element stated a `wp:effectExtent`, carried so a rebuild writes each
|
|
2397
|
+
* back there. The drawing's reaches the editor a second time as `padding*`;
|
|
2398
|
+
* the wrap child's has no other carrier at all.
|
|
2399
|
+
*/
|
|
2400
|
+
const optionalEffectExtentSlots = (attrs, key, path, issues) => {
|
|
2401
|
+
const value = attrs[key];
|
|
2402
|
+
if (value === void 0 || value === null) return;
|
|
2403
|
+
if (!isRecord(value)) {
|
|
2404
|
+
issues.push({
|
|
2405
|
+
path,
|
|
2406
|
+
message: "Expected an object."
|
|
2407
|
+
});
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2410
|
+
readEffectExtent(value, "drawing", `${path}.drawing`, issues);
|
|
2411
|
+
readEffectExtent(value, "wrapChild", `${path}.wrapChild`, issues);
|
|
2412
|
+
};
|
|
2413
|
+
/** A `CT_Point2D` on a wrap polygon: both coordinates, in the path's own units. */
|
|
2414
|
+
const readWrapPolygonPoint = (value, path, issues) => {
|
|
2415
|
+
if (!isRecord(value)) {
|
|
2416
|
+
issues.push({
|
|
2417
|
+
path,
|
|
2418
|
+
message: "Expected an object."
|
|
2419
|
+
});
|
|
2420
|
+
return;
|
|
2421
|
+
}
|
|
2422
|
+
requiredNumber(value, "x", `${path}.x`, issues);
|
|
2423
|
+
requiredNumber(value, "y", `${path}.y`, issues);
|
|
2424
|
+
};
|
|
2425
|
+
/** `wp:wrapPolygon` as authored, in the path's own units rather than EMU. */
|
|
2426
|
+
const optionalWrapPolygon = (attrs, key, path, issues) => {
|
|
2427
|
+
const value = attrs[key];
|
|
2428
|
+
if (value === void 0 || value === null) return;
|
|
2429
|
+
if (!isRecord(value)) {
|
|
2430
|
+
issues.push({
|
|
2431
|
+
path,
|
|
2432
|
+
message: "Expected an object."
|
|
2433
|
+
});
|
|
2434
|
+
return;
|
|
2435
|
+
}
|
|
2436
|
+
optionalBoolean(value, "edited", `${path}.edited`, issues);
|
|
2437
|
+
readWrapPolygonPoint(value["start"], `${path}.start`, issues);
|
|
2438
|
+
const lineTo = value["lineTo"];
|
|
2439
|
+
if (!Array.isArray(lineTo)) {
|
|
2440
|
+
issues.push({
|
|
2441
|
+
path: `${path}.lineTo`,
|
|
2442
|
+
message: "Expected an array."
|
|
2443
|
+
});
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
lineTo.forEach((point, index) => {
|
|
2447
|
+
readWrapPolygonPoint(point, `${path}.lineTo[${index}]`, issues);
|
|
2448
|
+
});
|
|
2449
|
+
};
|
|
2450
|
+
/** `a:hlinkClick` as captured: its own bytes, plus the target it named. */
|
|
2451
|
+
const optionalDocPrLink = (attrs, key, path, issues) => {
|
|
2452
|
+
const value = attrs[key];
|
|
2453
|
+
if (value === void 0 || value === null) return;
|
|
2454
|
+
if (!isRecord(value)) {
|
|
2455
|
+
issues.push({
|
|
2456
|
+
path,
|
|
2457
|
+
message: "Expected an object."
|
|
2458
|
+
});
|
|
2459
|
+
return;
|
|
2460
|
+
}
|
|
2461
|
+
requiredString(value, "xml", `${path}.xml`, issues);
|
|
2462
|
+
optionalString(value, "rId", `${path}.rId`, issues);
|
|
2463
|
+
};
|
|
1868
2464
|
const optionalImagePosition = (attrs, key, path, issues) => {
|
|
1869
2465
|
const value = attrs[key];
|
|
1870
2466
|
if (value === void 0 || value === null) return;
|
|
@@ -1951,11 +2547,6 @@ const optionalOneOfArray = (attrs, key, path, issues, allowed) => {
|
|
|
1951
2547
|
message: `Expected one of ${allowed.join(", ")}.`
|
|
1952
2548
|
});
|
|
1953
2549
|
};
|
|
1954
|
-
const validateNumPr = (value, issues) => {
|
|
1955
|
-
if (value === void 0 || value === null || !isRecord(value)) return;
|
|
1956
|
-
validateNonNegativeInteger(value["numId"], "paragraph.attrs.numPr.numId", issues);
|
|
1957
|
-
validateNonNegativeInteger(value["ilvl"], "paragraph.attrs.numPr.ilvl", issues);
|
|
1958
|
-
};
|
|
1959
2550
|
const validateNonNegativeInteger = (value, path, issues) => {
|
|
1960
2551
|
if (value === void 0 || value === null) return;
|
|
1961
2552
|
if (typeof value !== "number") {
|
|
@@ -2024,4 +2615,4 @@ const optionalEmptyHyperlinkArray = (value, issues) => {
|
|
|
2024
2615
|
}
|
|
2025
2616
|
};
|
|
2026
2617
|
//#endregion
|
|
2027
|
-
export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs,
|
|
2618
|
+
export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readInlineWrapperStack, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunIdentityMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|