@stll/folio-core 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +26 -24
- package/dist/ai-edits/headless.js +1 -1
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/content-controls/checkboxDisplay.d.ts +8 -2
- package/dist/content-controls/checkboxDisplay.js +11 -5
- package/dist/content-controls/mutateContentControls.js +41 -42
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +7 -7
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -20
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +93 -13
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +1 -19
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +34 -1
- package/dist/docx/attributeRemainder.js +49 -3
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +39 -67
- package/dist/docx/blockPlainText.js +3 -1
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentParser.js +3 -3
- package/dist/docx/commentRangeIntegrity.js +1 -1
- package/dist/docx/commentRangeJoin.js +1 -1
- package/dist/docx/commentReferenceNormalization.js +3 -2
- package/dist/docx/commentReplyMarkers.js +1 -1
- package/dist/docx/compatibility.js +56 -42
- package/dist/docx/containerChildren.d.ts +110 -13
- package/dist/docx/containerChildren.gen.d.ts +16 -1
- package/dist/docx/containerChildren.gen.js +18 -1
- package/dist/docx/containerChildren.js +63 -13
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.js +4 -1
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterReferenceNormalization.js +1 -1
- package/dist/docx/hyperlinkParser.d.ts +45 -7
- package/dist/docx/hyperlinkParser.js +126 -57
- package/dist/docx/imageParser.js +127 -107
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +84 -3
- package/dist/docx/inlineWrapperContent.js +85 -4
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +4 -2
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +91 -1
- package/dist/docx/paraIdAttribute.js +79 -1
- package/dist/docx/paragraphParser.d.ts +9 -24
- package/dist/docx/paragraphParser.js +212 -396
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +2 -0
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +14 -7
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +47 -49
- package/dist/docx/parseWarningMessage.js +3 -0
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.js +16 -6
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -2
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +78 -9
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +54 -18
- package/dist/docx/runParser.js +379 -295
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +236 -240
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +21 -2
- package/dist/docx/selectiveXmlPatch.js +195 -99
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +10 -8
- package/dist/docx/serializer/documentSerializer.js +3 -0
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +3 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +3 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +88 -188
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +109 -59
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +34 -45
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +268 -100
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +18 -16
- package/dist/docx/server/migrateYjsAttrSchema.js +3 -3
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +8 -3
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +10 -1
- package/dist/docx/tableParser.js +505 -181
- package/dist/docx/textBoxParser.d.ts +3 -1
- package/dist/docx/textBoxParser.js +18 -8
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/vmlImageParser.d.ts +13 -4
- package/dist/docx/vmlImageParser.js +74 -31
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlParser.d.ts +14 -1
- package/dist/docx/xmlParser.js +18 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +3 -1
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +177 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +47 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderPage.js +6 -4
- package/dist/layout-painter/renderParagraph.d.ts +2 -1
- package/dist/layout-painter/renderParagraph.js +13 -26
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/markdown/renderBlock.js +3 -1
- package/dist/markdown/renderRuns.js +7 -2
- package/dist/markdown/renderTable.js +2 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/prosemirror/attrs/index.d.ts +22 -4
- package/dist/prosemirror/attrs/index.js +498 -60
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +24 -19
- package/dist/prosemirror/commands/image.d.ts +1 -1
- package/dist/prosemirror/commands/image.js +4 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +18 -2
- package/dist/prosemirror/conversion/fromProseDoc.js +330 -183
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.js +371 -141
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +8 -2
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +19 -15
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +26 -2
- package/dist/prosemirror/extensions/markRegistry.js +73 -10
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +17 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.js +2 -1
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +10 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +8 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +4 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +141 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.js +20 -3
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.js +24 -6
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -0
- package/dist/prosemirror/runFormattingInlineCarriers.js +2 -0
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +23 -4
- package/dist/prosemirror/schema/nodes.d.ts +220 -24
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +17 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +2 -2
- package/dist/prosemirror/yjsDocumentMetadata.js +428 -7
- package/dist/prosemirror/zeroWidthAnchors.js +4 -0
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/mergeDocumentContent.js +5 -3
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -1
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -52
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
|
@@ -1,21 +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
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
17
|
const PRESERVED_XML_LEVEL_VALUES = new Set(Object.values(PRESERVED_XML_LEVELS));
|
|
13
|
-
const SECTION_BREAK_TYPES = [
|
|
14
|
-
"nextPage",
|
|
15
|
-
"continuous",
|
|
16
|
-
"oddPage",
|
|
17
|
-
"evenPage"
|
|
18
|
-
];
|
|
19
18
|
const IMAGE_DISPLAY_MODES = [
|
|
20
19
|
"inline",
|
|
21
20
|
"float",
|
|
@@ -142,6 +141,7 @@ const SECTION_VERTICAL_ALIGNMENTS = [
|
|
|
142
141
|
"both",
|
|
143
142
|
"bottom"
|
|
144
143
|
];
|
|
144
|
+
const OMITTED_GRID_SLOT_VALUES = ["before", "after"];
|
|
145
145
|
const paragraphAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
146
146
|
const hardBreakAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
147
147
|
const pageBreakRunAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -174,7 +174,7 @@ const footnoteRefAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
|
174
174
|
const commentAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
175
175
|
const trackedChangeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
176
176
|
const runPropertyChangeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
177
|
-
const
|
|
177
|
+
const runIdentityAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
178
178
|
const inlineWrapperAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
179
179
|
const runFormattingOverrideAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
180
180
|
const hyperlinkAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -203,7 +203,7 @@ const readParagraphAttrs = (node) => {
|
|
|
203
203
|
optionalNumber(attrs, "indentRight", "paragraph.attrs.indentRight", issues);
|
|
204
204
|
optionalNumber(attrs, "indentFirstLine", "paragraph.attrs.indentFirstLine", issues);
|
|
205
205
|
optionalBoolean(attrs, "hangingIndent", "paragraph.attrs.hangingIndent", issues);
|
|
206
|
-
|
|
206
|
+
optionalOutlineLevel(attrs, "outlineLevel", "paragraph.attrs.outlineLevel", issues);
|
|
207
207
|
optionalString(attrs, "listNumFmt", "paragraph.attrs.listNumFmt", issues);
|
|
208
208
|
optionalBoolean(attrs, "listIsBullet", "paragraph.attrs.listIsBullet", issues);
|
|
209
209
|
optionalBoolean(attrs, "listIsLegal", "paragraph.attrs.listIsLegal", issues);
|
|
@@ -235,7 +235,6 @@ const readParagraphAttrs = (node) => {
|
|
|
235
235
|
path: "paragraph.attrs.direction",
|
|
236
236
|
message: "Expected a ParagraphDirection."
|
|
237
237
|
});
|
|
238
|
-
optionalOneOf(attrs, "sectionBreakType", "paragraph.attrs.sectionBreakType", issues, SECTION_BREAK_TYPES);
|
|
239
238
|
optionalStringArray(attrs, "listLevelNumFmts", "paragraph.attrs.listLevelNumFmts", issues);
|
|
240
239
|
optionalNumberArray(attrs, "listLevelStarts", "paragraph.attrs.listLevelStarts", issues);
|
|
241
240
|
optionalNumber(attrs, "listAbstractNumId", "paragraph.attrs.listAbstractNumId", issues);
|
|
@@ -254,14 +253,15 @@ const readParagraphAttrs = (node) => {
|
|
|
254
253
|
optionalRecord(attrs, "spacingFromImplicitDefaultStyle", "paragraph.attrs.spacingFromImplicitDefaultStyle", issues);
|
|
255
254
|
optionalTextFormatting(attrs, "defaultTextFormatting", "paragraph.attrs.defaultTextFormatting", issues);
|
|
256
255
|
optionalTextFormatting(attrs, "_tableRunFormatting", "paragraph.attrs._tableRunFormatting", issues);
|
|
257
|
-
|
|
258
|
-
|
|
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);
|
|
259
259
|
optionalBookmarkArray(attrs["bookmarks"], issues);
|
|
260
260
|
optionalEmptyHyperlinkArray(attrs["_emptyHyperlinks"], issues);
|
|
261
261
|
optionalAutospacingBase(attrs, "paragraph.attrs._autospacingBase", issues);
|
|
262
262
|
optionalSectionProperties(attrs, "_sectionProperties", "paragraph.attrs._sectionProperties", issues);
|
|
263
263
|
optionalPropertyChanges(attrs, "_propertyChanges", "paragraph.attrs._propertyChanges", issues, ["paragraphPropertyChange"]);
|
|
264
|
-
optionalPreservedAttributes(attrs, "paragraph.attrs._preservedAttributes", issues);
|
|
264
|
+
optionalPreservedAttributes(attrs, "_preservedAttributes", "paragraph.attrs._preservedAttributes", issues);
|
|
265
265
|
return attrsResult(attrs, issues);
|
|
266
266
|
};
|
|
267
267
|
const expectParagraphAttrs = (node) => expectCachedNodeAttrs(node, paragraphAttrsCache, readParagraphAttrs, "paragraph attrs");
|
|
@@ -353,6 +353,8 @@ const readTableAttrs = (node) => {
|
|
|
353
353
|
optionalOneOf(attrs, "_resolvedJustification", "table.attrs._resolvedJustification", issues, TABLE_JUSTIFICATION_VALUES);
|
|
354
354
|
optionalBoolean(attrs, "_resolvedBidi", "table.attrs._resolvedBidi", issues);
|
|
355
355
|
optionalRecord(attrs, "_originalFormatting", "table.attrs._originalFormatting", issues);
|
|
356
|
+
optionalPositionedBookmarks(attrs, "table.attrs._bookmarks", issues);
|
|
357
|
+
optionalTablePreservedMarkup(attrs, "_preserved", "table.attrs._preserved", issues);
|
|
356
358
|
return attrsResult(attrs, issues);
|
|
357
359
|
};
|
|
358
360
|
const expectTableAttrs = (node) => expectCachedNodeAttrs(node, tableAttrsCache, readTableAttrs, "table attrs");
|
|
@@ -366,13 +368,17 @@ const readTableRowAttrs = (node) => {
|
|
|
366
368
|
optionalBoolean(attrs, "hidden", "tableRow.attrs.hidden", issues);
|
|
367
369
|
optionalOneOf(attrs, "_resolvedJustification", "tableRow.attrs._resolvedJustification", issues, TABLE_JUSTIFICATION_VALUES);
|
|
368
370
|
optionalRecord(attrs, "_originalFormatting", "tableRow.attrs._originalFormatting", issues);
|
|
371
|
+
optionalRecord(attrs, "_tablePropertyExceptions", "tableRow.attrs._tablePropertyExceptions", issues);
|
|
369
372
|
optionalTableRowRevision(attrs, "trIns", issues);
|
|
370
373
|
optionalTableRowRevision(attrs, "trDel", issues);
|
|
371
374
|
if (attrs["trIns"] != null && attrs["trDel"] != null) issues.push({
|
|
372
375
|
path: "tableRow.attrs",
|
|
373
376
|
message: "Expected at most one structural revision marker."
|
|
374
377
|
});
|
|
375
|
-
optionalPreservedAttributes(attrs, "tableRow.attrs._preservedAttributes", issues);
|
|
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);
|
|
376
382
|
return attrsResult(attrs, issues);
|
|
377
383
|
};
|
|
378
384
|
const expectTableRowAttrs = (node) => expectCachedNodeAttrs(node, tableRowAttrsCache, readTableRowAttrs, "table row attrs");
|
|
@@ -382,13 +388,15 @@ const readTableCellAttrs = (node) => {
|
|
|
382
388
|
expectNodeTypeOneOf(node, ["tableCell", "tableHeader"], issues);
|
|
383
389
|
requiredNumber(attrs, "colspan", "tableCell.attrs.colspan", issues);
|
|
384
390
|
requiredNumber(attrs, "rowspan", "tableCell.attrs.rowspan", issues);
|
|
391
|
+
optionalOneOf(attrs, "_omittedGridSlot", "tableCell.attrs._omittedGridSlot", issues, OMITTED_GRID_SLOT_VALUES);
|
|
385
392
|
optionalNumberArray(attrs, "colwidth", "tableCell.attrs.colwidth", issues, { allowNull: true });
|
|
386
393
|
optionalNumber(attrs, "width", "tableCell.attrs.width", issues);
|
|
387
394
|
optionalOneOf(attrs, "widthType", "tableCell.attrs.widthType", issues, TABLE_WIDTH_TYPE_VALUES);
|
|
395
|
+
optionalAuthoredWidth(attrs, issues);
|
|
388
396
|
optionalOneOf(attrs, "verticalAlign", "tableCell.attrs.verticalAlign", issues, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES);
|
|
389
397
|
optionalString(attrs, "backgroundColor", "tableCell.attrs.backgroundColor", issues);
|
|
390
398
|
optionalString(attrs, "_resolvedBackgroundColor", "tableCell.attrs._resolvedBackgroundColor", issues);
|
|
391
|
-
optionalOneOf(attrs, "textDirection", "tableCell.attrs.textDirection", issues,
|
|
399
|
+
optionalOneOf(attrs, "textDirection", "tableCell.attrs.textDirection", issues, TEXT_DIRECTION_VALUES);
|
|
392
400
|
optionalBoolean(attrs, "noWrap", "tableCell.attrs.noWrap", issues);
|
|
393
401
|
optionalBoolean(attrs, "hideMark", "tableCell.attrs.hideMark", issues);
|
|
394
402
|
optionalBorderMap(attrs, "borders", "tableCell.attrs.borders", issues, [
|
|
@@ -402,6 +410,7 @@ const readTableCellAttrs = (node) => {
|
|
|
402
410
|
optionalInsetMap(attrs, "margins", "tableCell.attrs.margins", issues);
|
|
403
411
|
optionalRecord(attrs, "_originalFormatting", "tableCell.attrs._originalFormatting", issues);
|
|
404
412
|
optionalTableCellRevision(attrs, issues);
|
|
413
|
+
optionalContentControls(attrs, "tableCell.attrs.contentControls", issues);
|
|
405
414
|
optionalBoolean(attrs, "_preserveVMergeRestart", "tableCell.attrs._preserveVMergeRestart", issues);
|
|
406
415
|
return attrsResult(attrs, issues);
|
|
407
416
|
};
|
|
@@ -440,7 +449,10 @@ const readImageAttrs = (node) => {
|
|
|
440
449
|
optionalNumber(attrs, "paddingBottom", "image.attrs.paddingBottom", issues);
|
|
441
450
|
optionalNumber(attrs, "paddingLeft", "image.attrs.paddingLeft", issues);
|
|
442
451
|
optionalImagePosition(attrs, "position", "image.attrs.position", issues);
|
|
443
|
-
|
|
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);
|
|
444
456
|
optionalBoolean(attrs, "decorative", "image.attrs.decorative", issues);
|
|
445
457
|
optionalBoolean(attrs, "hidden", "image.attrs.hidden", issues);
|
|
446
458
|
optionalStringArray(attrs, "docPrExtensions", "image.attrs.docPrExtensions", issues);
|
|
@@ -452,6 +464,9 @@ const readImageAttrs = (node) => {
|
|
|
452
464
|
optionalOneOf(attrs, "wrapText", "image.attrs.wrapText", issues, IMAGE_WRAP_TEXT_VALUES);
|
|
453
465
|
optionalString(attrs, "hlinkHref", "image.attrs.hlinkHref", issues);
|
|
454
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);
|
|
455
470
|
optionalString(attrs, "_docxRawXml", "image.attrs._docxRawXml", issues);
|
|
456
471
|
optionalOneOf(attrs, "_docxRawXmlMode", "image.attrs._docxRawXmlMode", issues, Object.values(DRAWING_RAW_XML_MODES));
|
|
457
472
|
optionalString(attrs, "_docxRawImageFingerprint", "image.attrs._docxRawImageFingerprint", issues);
|
|
@@ -514,8 +529,9 @@ const readBlockSdtAttrs = (node) => {
|
|
|
514
529
|
optionalString(attrs, "dropdownLastValue", "blockSdt.attrs.dropdownLastValue", issues);
|
|
515
530
|
optionalBoolean(attrs, "checked", "blockSdt.attrs.checked", issues);
|
|
516
531
|
optionalBoolean(attrs, "_originallyEmpty", "blockSdt.attrs._originallyEmpty", issues);
|
|
517
|
-
|
|
532
|
+
optionalPreservedMarkup(attrs, "_preserved", "blockSdt.attrs._preserved", issues);
|
|
518
533
|
optionalString(attrs, "rawEndPropertiesXml", "blockSdt.attrs.rawEndPropertiesXml", issues);
|
|
534
|
+
optionalSdtEndProperties(attrs, "blockSdt.attrs.endProperties", issues);
|
|
519
535
|
optionalString(attrs, "rawSdtChildrenBeforeContent", "blockSdt.attrs.rawSdtChildrenBeforeContent", issues);
|
|
520
536
|
optionalString(attrs, "rawSdtChildrenAfterContent", "blockSdt.attrs.rawSdtChildrenAfterContent", issues);
|
|
521
537
|
return attrsResult(attrs, issues);
|
|
@@ -561,6 +577,10 @@ const readShapeAttrs = (node) => {
|
|
|
561
577
|
optionalNumber(attrs, "distLeft", "shape.attrs.distLeft", issues);
|
|
562
578
|
optionalNumber(attrs, "distRight", "shape.attrs.distRight", issues);
|
|
563
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);
|
|
564
584
|
optionalString(attrs, "shadowColor", "shape.attrs.shadowColor", issues);
|
|
565
585
|
optionalNumber(attrs, "shadowBlur", "shape.attrs.shadowBlur", issues);
|
|
566
586
|
optionalNumber(attrs, "shadowOffsetX", "shape.attrs.shadowOffsetX", issues);
|
|
@@ -606,13 +626,17 @@ const readTextBoxAttrs = (node) => {
|
|
|
606
626
|
optionalNumber(attrs, "distLeft", "textBox.attrs.distLeft", issues);
|
|
607
627
|
optionalNumber(attrs, "distRight", "textBox.attrs.distRight", issues);
|
|
608
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);
|
|
609
633
|
optionalOneOf(attrs, "_docxPlacement", "textBox.attrs._docxPlacement", issues, TEXT_BOX_DOCX_PLACEMENTS);
|
|
610
634
|
optionalString(attrs, "_docxGroupId", "textBox.attrs._docxGroupId", issues);
|
|
611
635
|
optionalString(attrs, "_docxAnchorId", "textBox.attrs._docxAnchorId", issues);
|
|
612
636
|
requiredTextBoxBodyContentState(attrs, issues);
|
|
613
637
|
optionalTextBoxTrackedChange(attrs, issues);
|
|
614
638
|
optionalTextBoxInlineSdts(attrs, issues);
|
|
615
|
-
optionalPreservedAttributes(attrs, "textBox.attrs._preservedAttributes", issues);
|
|
639
|
+
optionalPreservedAttributes(attrs, "_preservedAttributes", "textBox.attrs._preservedAttributes", issues);
|
|
616
640
|
return attrsResult(attrs, issues);
|
|
617
641
|
};
|
|
618
642
|
const expectTextBoxAttrs = (node) => expectCachedNodeAttrs(node, textBoxAttrsCache, readTextBoxAttrs, "text box attrs");
|
|
@@ -766,6 +790,7 @@ const readTrackedChangeMarkAttrs = (mark) => {
|
|
|
766
790
|
optionalOneOf(attrs, "moveKind", `${mark.type.name}.attrs.moveKind`, issues, TRACKED_CHANGE_MOVE_KINDS);
|
|
767
791
|
optionalOneOf(attrs, "provenance", `${mark.type.name}.attrs.provenance`, issues, TRACKED_CHANGE_PROVENANCE_VALUES);
|
|
768
792
|
optionalString(attrs, "suggestionId", `${mark.type.name}.attrs.suggestionId`, issues);
|
|
793
|
+
optionalBoolean(attrs, "_historicalFormatting", `${mark.type.name}.attrs._historicalFormatting`, issues);
|
|
769
794
|
return attrsResult(attrs, issues);
|
|
770
795
|
};
|
|
771
796
|
const expectTrackedChangeMarkAttrs = (mark) => expectCachedMarkAttrs(mark, trackedChangeAttrsCache, readTrackedChangeMarkAttrs, "tracked change attrs");
|
|
@@ -779,18 +804,29 @@ const readRunPropertyChangeMarkAttrs = (mark) => {
|
|
|
779
804
|
return attrsResult(attrs, issues);
|
|
780
805
|
};
|
|
781
806
|
const expectRunPropertyChangeMarkAttrs = (mark) => expectCachedMarkAttrs(mark, runPropertyChangeAttrsCache, readRunPropertyChangeMarkAttrs, "run property change attrs");
|
|
782
|
-
|
|
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) => {
|
|
783
817
|
const attrs = attrsRecord(mark.attrs);
|
|
784
818
|
const issues = [];
|
|
785
|
-
expectMarkType(mark, "
|
|
819
|
+
expectMarkType(mark, "runIdentity", issues);
|
|
786
820
|
const id = attrs["id"];
|
|
787
821
|
if (typeof id !== "number" || !Number.isSafeInteger(id) || id < 0) issues.push({
|
|
788
|
-
path: "
|
|
822
|
+
path: "runIdentity.attrs.id",
|
|
789
823
|
message: "Expected a non-negative safe integer."
|
|
790
824
|
});
|
|
825
|
+
optionalPreservedAttributes(attrs, "preservedAttributes", "runIdentity.attrs.preservedAttributes", issues);
|
|
826
|
+
optionalPreservedMarkup(attrs, "preserved", "runIdentity.attrs.preserved", issues);
|
|
791
827
|
return attrsResult(attrs, issues);
|
|
792
828
|
};
|
|
793
|
-
const
|
|
829
|
+
const expectRunIdentityMarkAttrs = (mark) => expectCachedMarkAttrs(mark, runIdentityAttrsCache, readRunIdentityMarkAttrs, "run identity attrs");
|
|
794
830
|
const BIDI_LAYER_CONTROLS = ["embedding", "override"];
|
|
795
831
|
const BIDI_LAYER_DIRECTIONS = ["ltr", "rtl"];
|
|
796
832
|
const BIDI_LAYER_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -798,20 +834,49 @@ const BIDI_LAYER_KEYS = /* @__PURE__ */ new Set([
|
|
|
798
834
|
"control",
|
|
799
835
|
"direction"
|
|
800
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
|
+
};
|
|
801
862
|
/**
|
|
802
863
|
* One validator per wrapper kind, total over the kinds the model declares: a
|
|
803
864
|
* kind added without a field-by-field check does not compile, and a layer that
|
|
804
865
|
* states a field its kind does not carry (a smart tag with a bidi `control`)
|
|
805
866
|
* is rejected rather than stored and written back.
|
|
806
867
|
*/
|
|
807
|
-
const INLINE_WRAPPER_LAYER_VALIDATORS = {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
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
|
+
};
|
|
815
880
|
const inlineWrapperLayerValidator = (kind) => {
|
|
816
881
|
return typeof kind === "string" ? INLINE_WRAPPER_LAYER_VALIDATORS[kind] : void 0;
|
|
817
882
|
};
|
|
@@ -992,7 +1057,30 @@ const mergeImageAttrs = (node, patch) => {
|
|
|
992
1057
|
const mergeParagraphAttrs = (node, patch) => mergeNodeAttrs(node, readParagraphAttrs, "paragraph attrs", patch);
|
|
993
1058
|
const mergeTableAttrs = (node, patch) => mergeNodeAttrs(node, readTableAttrs, "table attrs", patch);
|
|
994
1059
|
const mergeTableRowAttrs = (node, patch) => mergeNodeAttrs(node, readTableRowAttrs, "table row attrs", patch);
|
|
995
|
-
|
|
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
|
+
};
|
|
996
1084
|
const attrsRecord = (attrs) => {
|
|
997
1085
|
if (isRecord(attrs)) return attrs;
|
|
998
1086
|
return {};
|
|
@@ -1261,7 +1349,7 @@ const optionalTextColor = (attrs, key, path, issues) => {
|
|
|
1261
1349
|
};
|
|
1262
1350
|
const optionalTextColorFields = (attrs, path, issues) => {
|
|
1263
1351
|
optionalString(attrs, "rgb", `${path}.rgb`, issues);
|
|
1264
|
-
optionalOneOf(attrs, "themeColor", `${path}.themeColor`, issues,
|
|
1352
|
+
optionalOneOf(attrs, "themeColor", `${path}.themeColor`, issues, THEME_COLORS);
|
|
1265
1353
|
optionalString(attrs, "themeTint", `${path}.themeTint`, issues);
|
|
1266
1354
|
optionalString(attrs, "themeShade", `${path}.themeShade`, issues);
|
|
1267
1355
|
};
|
|
@@ -1285,6 +1373,36 @@ const optionalBoolean = (attrs, key, path, issues) => {
|
|
|
1285
1373
|
message: "Expected a boolean."
|
|
1286
1374
|
});
|
|
1287
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
|
+
};
|
|
1288
1406
|
const optionalRecord = (attrs, key, path, issues) => {
|
|
1289
1407
|
const value = attrs[key];
|
|
1290
1408
|
if (value !== void 0 && value !== null && !isRecord(value)) issues.push({
|
|
@@ -1292,6 +1410,21 @@ const optionalRecord = (attrs, key, path, issues) => {
|
|
|
1292
1410
|
message: "Expected an object."
|
|
1293
1411
|
});
|
|
1294
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
|
+
};
|
|
1295
1428
|
const optionalTableRowRevision = (attrs, key, issues) => {
|
|
1296
1429
|
const value = attrs[key];
|
|
1297
1430
|
if (value === void 0 || value === null) return;
|
|
@@ -1425,8 +1558,9 @@ const validateSdtAttrsRecord = (attrs, path, issues) => {
|
|
|
1425
1558
|
optionalSdtListItems(attrs, "listItems", `${path}.listItems`, issues);
|
|
1426
1559
|
optionalString(attrs, "dropdownLastValue", `${path}.dropdownLastValue`, issues);
|
|
1427
1560
|
optionalBoolean(attrs, "checked", `${path}.checked`, issues);
|
|
1428
|
-
|
|
1561
|
+
optionalPreservedMarkup(attrs, "_preserved", `${path}._preserved`, issues);
|
|
1429
1562
|
optionalString(attrs, "rawEndPropertiesXml", `${path}.rawEndPropertiesXml`, issues);
|
|
1563
|
+
optionalSdtEndProperties(attrs, `${path}.endProperties`, issues);
|
|
1430
1564
|
};
|
|
1431
1565
|
/**
|
|
1432
1566
|
* The attribute remainder an authored element's record carries.
|
|
@@ -1435,8 +1569,64 @@ const validateSdtAttrsRecord = (attrs, path, issues) => {
|
|
|
1435
1569
|
* spelling, which is why the namespace is a URI and optional rather than a
|
|
1436
1570
|
* prefix. See `docx/attributeRemainder.ts`.
|
|
1437
1571
|
*/
|
|
1438
|
-
|
|
1439
|
-
|
|
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];
|
|
1440
1630
|
if (value === void 0 || value === null) return;
|
|
1441
1631
|
if (!Array.isArray(value)) {
|
|
1442
1632
|
issues.push({
|
|
@@ -1457,6 +1647,107 @@ const optionalPreservedAttributes = (attrs, path, issues) => {
|
|
|
1457
1647
|
requiredString(entry, "name", `${entryPath}.name`, issues);
|
|
1458
1648
|
requiredString(entry, "value", `${entryPath}.value`, issues);
|
|
1459
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);
|
|
1460
1751
|
}
|
|
1461
1752
|
};
|
|
1462
1753
|
const optionalAutospacingBase = (attrs, path, issues) => {
|
|
@@ -1499,6 +1790,7 @@ const validateBorderSpec = (value, path, issues) => {
|
|
|
1499
1790
|
optionalBoolean(value, "shadow", `${path}.shadow`, issues);
|
|
1500
1791
|
optionalBoolean(value, "frame", `${path}.frame`, issues);
|
|
1501
1792
|
optionalColorValue(value, "color", `${path}.color`, issues);
|
|
1793
|
+
optionalPreservedAttributes(value, "preservedAttributes", `${path}.preservedAttributes`, issues);
|
|
1502
1794
|
};
|
|
1503
1795
|
const optionalColorValue = (attrs, key, path, issues) => {
|
|
1504
1796
|
const value = attrs[key];
|
|
@@ -1512,7 +1804,7 @@ const optionalColorValue = (attrs, key, path, issues) => {
|
|
|
1512
1804
|
}
|
|
1513
1805
|
optionalString(value, "rgb", `${path}.rgb`, issues);
|
|
1514
1806
|
optionalBoolean(value, "auto", `${path}.auto`, issues);
|
|
1515
|
-
optionalOneOf(value, "themeColor", `${path}.themeColor`, issues,
|
|
1807
|
+
optionalOneOf(value, "themeColor", `${path}.themeColor`, issues, THEME_COLORS);
|
|
1516
1808
|
optionalString(value, "themeTint", `${path}.themeTint`, issues);
|
|
1517
1809
|
optionalString(value, "themeShade", `${path}.themeShade`, issues);
|
|
1518
1810
|
};
|
|
@@ -1529,6 +1821,7 @@ const optionalShading = (attrs, key, path, issues) => {
|
|
|
1529
1821
|
optionalColorValue(value, "color", `${path}.color`, issues);
|
|
1530
1822
|
optionalColorValue(value, "fill", `${path}.fill`, issues);
|
|
1531
1823
|
optionalOneOf(value, "pattern", `${path}.pattern`, issues, SHADING_PATTERN_VALUES);
|
|
1824
|
+
optionalPreservedAttributes(value, "preservedAttributes", `${path}.preservedAttributes`, issues);
|
|
1532
1825
|
};
|
|
1533
1826
|
const optionalTabStops = (attrs, key, path, issues) => {
|
|
1534
1827
|
const value = attrs[key];
|
|
@@ -1552,6 +1845,7 @@ const optionalTabStops = (attrs, key, path, issues) => {
|
|
|
1552
1845
|
requiredNumber(item, "position", `${itemPath}.position`, issues);
|
|
1553
1846
|
requiredOneOf(item, "alignment", `${itemPath}.alignment`, issues, TAB_STOP_ALIGNMENT_VALUES);
|
|
1554
1847
|
optionalOneOf(item, "leader", `${itemPath}.leader`, issues, TAB_LEADER_VALUES);
|
|
1848
|
+
optionalPreservedAttributes(item, "preservedAttributes", `${itemPath}.preservedAttributes`, issues);
|
|
1555
1849
|
}
|
|
1556
1850
|
};
|
|
1557
1851
|
const optionalTextFormatting = (attrs, key, path, issues) => {
|
|
@@ -1790,8 +2084,7 @@ const PARAGRAPH_FORMATTING_NUMBER_KEYS = [
|
|
|
1790
2084
|
"lineSpacing",
|
|
1791
2085
|
"indentLeft",
|
|
1792
2086
|
"indentRight",
|
|
1793
|
-
"indentFirstLine"
|
|
1794
|
-
"outlineLevel"
|
|
2087
|
+
"indentFirstLine"
|
|
1795
2088
|
];
|
|
1796
2089
|
const validateParagraphFormatting = (value, path, issues) => {
|
|
1797
2090
|
optionalOneOf(value, "alignment", `${path}.alignment`, issues, PARAGRAPH_ALIGNMENT_VALUES);
|
|
@@ -1804,6 +2097,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1804
2097
|
"listMarkerAllCaps"
|
|
1805
2098
|
]) optionalBoolean(value, key, `${path}.${key}`, issues);
|
|
1806
2099
|
for (const key of PARAGRAPH_FORMATTING_NUMBER_KEYS) optionalNumber(value, key, `${path}.${key}`, issues);
|
|
2100
|
+
optionalOutlineLevel(value, "outlineLevel", `${path}.outlineLevel`, issues);
|
|
1807
2101
|
for (const key of [
|
|
1808
2102
|
"listImplicitChildLevelAdvances",
|
|
1809
2103
|
"listMarkerSecondSlotOffsetTwips",
|
|
@@ -1813,7 +2107,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1813
2107
|
optionalOneOf(value, "lineSpacingRule", `${path}.lineSpacingRule`, issues, LINE_SPACING_RULE_VALUES);
|
|
1814
2108
|
optionalString(value, "styleId", `${path}.styleId`, issues);
|
|
1815
2109
|
optionalString(value, "numberingChangeXml", `${path}.numberingChangeXml`, issues);
|
|
1816
|
-
optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues,
|
|
2110
|
+
optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues, COUNTER_FORMAT_VALUES);
|
|
1817
2111
|
optionalString(value, "listMarker", `${path}.listMarker`, issues);
|
|
1818
2112
|
optionalString(value, "listMarkerTemplate", `${path}.listMarkerTemplate`, issues);
|
|
1819
2113
|
optionalTextFormatting(value, "listMarkerFormatting", `${path}.listMarkerFormatting`, issues);
|
|
@@ -1827,22 +2121,10 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1827
2121
|
"space",
|
|
1828
2122
|
"nothing"
|
|
1829
2123
|
]);
|
|
1830
|
-
optionalOneOfArray(value, "listLevelNumFmts", `${path}.listLevelNumFmts`, issues,
|
|
2124
|
+
optionalOneOfArray(value, "listLevelNumFmts", `${path}.listLevelNumFmts`, issues, COUNTER_FORMAT_VALUES);
|
|
1831
2125
|
optionalNumberArray(value, "listLevelStarts", `${path}.listLevelStarts`, issues);
|
|
1832
2126
|
optionalAutospacingBase(value, `${path}._autospacingBase`, issues);
|
|
1833
|
-
for (const key of ["numPr", "numPrFromStyle"]) {
|
|
1834
|
-
const nested = value[key];
|
|
1835
|
-
if (nested === void 0 || nested === null) continue;
|
|
1836
|
-
if (!isRecord(nested)) {
|
|
1837
|
-
issues.push({
|
|
1838
|
-
path: `${path}.${key}`,
|
|
1839
|
-
message: "Expected an object."
|
|
1840
|
-
});
|
|
1841
|
-
continue;
|
|
1842
|
-
}
|
|
1843
|
-
optionalNumber(nested, "numId", `${path}.${key}.numId`, issues);
|
|
1844
|
-
optionalNumber(nested, "ilvl", `${path}.${key}.ilvl`, issues);
|
|
1845
|
-
}
|
|
2127
|
+
for (const key of ["numPr", "numPrFromStyle"]) optionalParagraphNumbering(value, key, `${path}.${key}`, issues);
|
|
1846
2128
|
const direction = value["direction"];
|
|
1847
2129
|
if (direction !== void 0 && direction !== null && !isParagraphDirection(direction)) issues.push({
|
|
1848
2130
|
path: `${path}.direction`,
|
|
@@ -1875,6 +2157,8 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1875
2157
|
]);
|
|
1876
2158
|
optionalShading(value, "shading", `${path}.shading`, issues);
|
|
1877
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);
|
|
1878
2162
|
optionalNestedRecord(value, "runProperties", `${path}.runProperties`, issues, validateTextFormatting);
|
|
1879
2163
|
const frame = value["frame"];
|
|
1880
2164
|
if (frame !== void 0 && frame !== null) if (!isRecord(frame)) issues.push({
|
|
@@ -1929,6 +2213,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1929
2213
|
"x",
|
|
1930
2214
|
"y"
|
|
1931
2215
|
]) optionalNumber(frame, key, `${path}.frame.${key}`, issues);
|
|
2216
|
+
optionalPreservedAttributes(frame, "preservedAttributes", `${path}.frame.preservedAttributes`, issues);
|
|
1932
2217
|
}
|
|
1933
2218
|
};
|
|
1934
2219
|
const validatePropertyChangeInfo = (value, path, issues) => {
|
|
@@ -1987,6 +2272,20 @@ const WRAP_DISTANCE_ATTRS = [
|
|
|
1987
2272
|
"distLeft",
|
|
1988
2273
|
"distRight"
|
|
1989
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
|
+
];
|
|
1990
2289
|
const TEXT_BOX_MARGIN_ATTRS = [
|
|
1991
2290
|
"marginTop",
|
|
1992
2291
|
"marginBottom",
|
|
@@ -2018,6 +2317,150 @@ const optionalImageFrameLocks = (attrs, key, path, issues) => {
|
|
|
2018
2317
|
}
|
|
2019
2318
|
for (const lock of GRAPHIC_FRAME_LOCK_KEYS) optionalBoolean(value, lock, `${path}.${lock}`, issues);
|
|
2020
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
|
+
};
|
|
2021
2464
|
const optionalImagePosition = (attrs, key, path, issues) => {
|
|
2022
2465
|
const value = attrs[key];
|
|
2023
2466
|
if (value === void 0 || value === null) return;
|
|
@@ -2104,11 +2547,6 @@ const optionalOneOfArray = (attrs, key, path, issues, allowed) => {
|
|
|
2104
2547
|
message: `Expected one of ${allowed.join(", ")}.`
|
|
2105
2548
|
});
|
|
2106
2549
|
};
|
|
2107
|
-
const validateNumPr = (value, issues) => {
|
|
2108
|
-
if (value === void 0 || value === null || !isRecord(value)) return;
|
|
2109
|
-
validateNonNegativeInteger(value["numId"], "paragraph.attrs.numPr.numId", issues);
|
|
2110
|
-
validateNonNegativeInteger(value["ilvl"], "paragraph.attrs.numPr.ilvl", issues);
|
|
2111
|
-
};
|
|
2112
2550
|
const validateNonNegativeInteger = (value, path, issues) => {
|
|
2113
2551
|
if (value === void 0 || value === null) return;
|
|
2114
2552
|
if (typeof value !== "number") {
|
|
@@ -2177,4 +2615,4 @@ const optionalEmptyHyperlinkArray = (value, issues) => {
|
|
|
2177
2615
|
}
|
|
2178
2616
|
};
|
|
2179
2617
|
//#endregion
|
|
2180
|
-
export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, 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 };
|