@stll/folio-core 0.46.0 → 0.47.1
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.d.ts +17 -1
- package/dist/ai-edits/apply.js +31 -27
- package/dist/ai-edits/headless.d.ts +9 -2
- package/dist/ai-edits/headless.js +5 -3
- 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 -1
- package/dist/compare/content-alignment.js +192 -46
- 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.d.ts +9 -2
- package/dist/document-operations.js +5 -3
- 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
|
@@ -4,6 +4,7 @@ import { ResolvedParagraphStyle, StyleResolver, createStyleResolver } from "./st
|
|
|
4
4
|
import { schema, singletonManager } from "./schema/index.js";
|
|
5
5
|
import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
|
|
6
6
|
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
7
|
+
import { TableBorderCommandSpec, TableCellBorderCommandSpec } from "./extensions/types.js";
|
|
7
8
|
import { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./commands/formatPainter.js";
|
|
8
9
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
9
10
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
|
|
@@ -14,10 +15,11 @@ import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyl
|
|
|
14
15
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
|
|
15
16
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
16
17
|
import "./commands/index.js";
|
|
17
|
-
import { fromProseDoc, updateDocumentContent } from "./conversion/fromProseDoc.js";
|
|
18
|
+
import { FromProseDocOptions, ProjectionReuse, fromProseDoc, updateDocumentContent } from "./conversion/fromProseDoc.js";
|
|
18
19
|
import { ToProseDocOptions, createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
19
20
|
import { ProseMirrorDocumentValidationIssue, ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
|
|
20
21
|
import "./conversion/index.js";
|
|
22
|
+
import { ActiveListState, ListState, ListType, NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
|
|
21
23
|
import { SelectionChangeCallback, SelectionContext, createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./plugins/selectionTracker.js";
|
|
22
24
|
import { ensureParaIdsInState } from "./extensions/features/ParaIdAllocatorExtension.js";
|
|
23
25
|
import "./styles/index.js";
|
|
@@ -26,4 +28,4 @@ import { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles
|
|
|
26
28
|
import "./plugins/index.js";
|
|
27
29
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
28
30
|
import { TextSelection } from "prosemirror-state";
|
|
29
|
-
export { type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type HyperlinkAttrs, type ImageAttrs, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderPreset, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
31
|
+
export { type ActiveListState, type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type FromProseDocOptions, type HyperlinkAttrs, type ImageAttrs, type ListState, type ListType, NO_LIST_STATE, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProjectionReuse, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderCommandSpec, type TableBorderPreset, type TableCellBorderCommandSpec, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
@@ -13,6 +13,7 @@ import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensi
|
|
|
13
13
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
14
14
|
import { getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
15
15
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
16
|
+
import { NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
|
|
16
17
|
import { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyles.js";
|
|
17
18
|
import { createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./plugins/selectionTracker.js";
|
|
18
19
|
import { schema, singletonManager } from "./schema/index.js";
|
|
@@ -20,4 +21,4 @@ import { extractSelectionState } from "./selectionState.js";
|
|
|
20
21
|
import { StyleResolver, createStyleResolver } from "./styles/styleResolver.js";
|
|
21
22
|
import { assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
|
|
22
23
|
import { TextSelection } from "prosemirror-state";
|
|
23
|
-
export { PAINTABLE_MARK_NAMES, StyleResolver, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
24
|
+
export { NO_LIST_STATE, PAINTABLE_MARK_NAMES, StyleResolver, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
@@ -15,6 +15,23 @@ import { Result, panic } from "better-result";
|
|
|
15
15
|
*/
|
|
16
16
|
/** The DOM attribute that carries a serialised stack through copy and paste. */
|
|
17
17
|
const INLINE_WRAPPER_STACK_ATTRIBUTE = "data-inline-wrapper";
|
|
18
|
+
/**
|
|
19
|
+
* A tagged layer's keys in canonical order.
|
|
20
|
+
*
|
|
21
|
+
* `propertiesXml` is part of the layer, so it is part of the stack key the
|
|
22
|
+
* save leg groups by: two adjacent smart tags whose properties differ are two
|
|
23
|
+
* wrappers, and folding them into one would attribute the second tag's text to
|
|
24
|
+
* the first tag's properties.
|
|
25
|
+
*/
|
|
26
|
+
const taggedLayer = (kind, layer) => {
|
|
27
|
+
const canonical = {
|
|
28
|
+
kind,
|
|
29
|
+
element: layer.element
|
|
30
|
+
};
|
|
31
|
+
if (layer.uri !== void 0) canonical.uri = layer.uri;
|
|
32
|
+
if (layer.propertiesXml !== void 0) canonical.propertiesXml = layer.propertiesXml;
|
|
33
|
+
return canonical;
|
|
34
|
+
};
|
|
18
35
|
/** A layer with its keys in canonical order, absent fields left absent. */
|
|
19
36
|
const inlineWrapperLayer = (layer) => {
|
|
20
37
|
switch (layer.kind) {
|
|
@@ -26,9 +43,9 @@ const inlineWrapperLayer = (layer) => {
|
|
|
26
43
|
control: layer.control,
|
|
27
44
|
direction: layer.direction
|
|
28
45
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
case "smartTag": return taggedLayer("smartTag", layer);
|
|
47
|
+
case "customXml": return taggedLayer("customXml", layer);
|
|
48
|
+
default: panic(`Unsupported inline wrapper layer: ${JSON.stringify(layer)}`);
|
|
32
49
|
}
|
|
33
50
|
};
|
|
34
51
|
/**
|
|
@@ -69,11 +69,11 @@ declare function cloneListCounterState(state: ListCounterState): ListCounterStat
|
|
|
69
69
|
* paragraphs advance only the document view in which they exist.
|
|
70
70
|
*/
|
|
71
71
|
declare function advanceVisibleListMarker(attrs: ParagraphAttrs, streams: ListCounterStreams): VisibleListMarker;
|
|
72
|
-
declare function formatCounter(value: number, format: document_d_exports.
|
|
72
|
+
declare function formatCounter(value: number, format: document_d_exports.CounterFormat | undefined): string;
|
|
73
73
|
type ResolveListTemplateOptions = {
|
|
74
74
|
template: string;
|
|
75
75
|
counters: number[];
|
|
76
|
-
levelFormats?: document_d_exports.
|
|
76
|
+
levelFormats?: document_d_exports.CounterFormat[] | undefined;
|
|
77
77
|
forceDecimal?: boolean | undefined;
|
|
78
78
|
};
|
|
79
79
|
declare function resolveListTemplate(options: ResolveListTemplateOptions): string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { convertBulletToUnicode } from "../docx/bulletMarkers.js";
|
|
2
|
-
import {
|
|
2
|
+
import { paragraphNumberingLevel, paragraphNumberingReferenceId, sameStatedParagraphNumbering } from "../docx/numberingReference.js";
|
|
3
3
|
import { formatOoxmlCounter } from "../docx/ooxmlCounterFormatter.js";
|
|
4
|
+
import { isListNumPr } from "../layout-engine/types.js";
|
|
4
5
|
import { LIST_RENDERING_ATTR_KEYS } from "./listRenderingAttrs.js";
|
|
5
6
|
//#region src/prosemirror/listMarker.ts
|
|
6
7
|
const MAX_LIST_LEVEL = 8;
|
|
@@ -61,12 +62,10 @@ function cloneListCounterState(state) {
|
|
|
61
62
|
...state.lastAdvancedNumId !== void 0 ? { lastAdvancedNumId: state.lastAdvancedNumId } : {}
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
|
-
const isListNumPr = (value) => value !== void 0 && value !== null;
|
|
65
|
-
const sameListNumPr = (left, right) => left.numId === right.numId && left.ilvl === right.ilvl;
|
|
66
65
|
function previousListAttrs(attrs) {
|
|
67
66
|
const previous = (attrs._propertyChanges?.find(({ previousFormatting }) => {
|
|
68
67
|
const previousNumPr = previousFormatting?.numPr;
|
|
69
|
-
return isListNumPr(previousNumPr) && (!attrs.numPr || !
|
|
68
|
+
return isListNumPr(previousNumPr) && (!attrs.numPr || !sameStatedParagraphNumbering(previousNumPr, attrs.numPr));
|
|
70
69
|
}))?.previousFormatting;
|
|
71
70
|
if (!previous || !isListNumPr(previous.numPr)) return null;
|
|
72
71
|
return {
|
|
@@ -117,7 +116,7 @@ function advanceVisibleListMarker(attrs, streams) {
|
|
|
117
116
|
advances
|
|
118
117
|
};
|
|
119
118
|
const numberingWasAdded = attrs._propertyChanges?.some(({ previousFormatting }) => previousFormatting && Object.hasOwn(previousFormatting, "numPr") && previousFormatting.numPr == null);
|
|
120
|
-
const numberingChanged = previous?.numPr !== void 0 && !
|
|
119
|
+
const numberingChanged = previous?.numPr !== void 0 && !sameStatedParagraphNumbering(previous.numPr, attrs.numPr);
|
|
121
120
|
const visible = advance(attrs, "final");
|
|
122
121
|
if (attrs.pPrMark?.kind !== "ins" && !numberingWasAdded && !numberingChanged) advance(attrs, "original");
|
|
123
122
|
else if (numberingChanged && previous) advance(previous, "original");
|
|
@@ -177,10 +176,10 @@ function formatNumberedMarker(counters, level) {
|
|
|
177
176
|
}
|
|
178
177
|
function advanceListMarker(attrs, state) {
|
|
179
178
|
const markerTemplate = attrs.listMarkerTemplate ?? attrs.listMarker;
|
|
180
|
-
const level = attrs.numPr
|
|
179
|
+
const level = paragraphNumberingLevel(attrs.numPr) ?? 0;
|
|
181
180
|
if (!Number.isInteger(level) || level < 0 || level > 8) return null;
|
|
182
|
-
const numId = attrs.numPr
|
|
183
|
-
if (
|
|
181
|
+
const numId = paragraphNumberingReferenceId(attrs.numPr);
|
|
182
|
+
if (numId === void 0) {
|
|
184
183
|
let marker = null;
|
|
185
184
|
if (markerTemplate?.includes("%") && !attrs.listIsBullet) {
|
|
186
185
|
const counters = getLastListCounters(state);
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
import { paragraphNumberingLevel } from "@stll/docx-core/model";
|
|
1
2
|
//#region src/prosemirror/listRenderingAttrs.ts
|
|
3
|
+
/**
|
|
4
|
+
* The one table that ties `Paragraph.listRendering` to the editor's `list*`
|
|
5
|
+
* attrs. Both projections (model → attrs in `toProseDoc`, attrs → model in
|
|
6
|
+
* `fromProseDoc`) and the cleared-attr set derive from it, so a field added
|
|
7
|
+
* to `ListRendering` without a projection fails to compile instead of being
|
|
8
|
+
* silently dropped on the way out of the editor.
|
|
9
|
+
*
|
|
10
|
+
* `level` and `numId` are not here: they travel in `numPr`.
|
|
11
|
+
*/
|
|
2
12
|
const LIST_RENDERING_ATTR_BY_FIELD = {
|
|
3
13
|
marker: "listMarker",
|
|
4
14
|
markerTemplate: "listMarkerTemplate",
|
|
@@ -70,7 +80,7 @@ const listRenderingFromAttrs = ({ attrs, numId }) => {
|
|
|
70
80
|
};
|
|
71
81
|
return {
|
|
72
82
|
marker: attrs.listMarker ?? "",
|
|
73
|
-
level: attrs.numPr
|
|
83
|
+
level: paragraphNumberingLevel(attrs.numPr) ?? 0,
|
|
74
84
|
numId,
|
|
75
85
|
isBullet: attrs.listIsBullet ?? false,
|
|
76
86
|
...definedFields(optional)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { NumberingMap } from "../docx/numberingParser.js";
|
|
2
|
+
import { ParagraphNumberingOverride } from "@stll/docx-core/model";
|
|
3
|
+
//#region src/prosemirror/listState.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Which list the selection sits in, for a toolbar.
|
|
6
|
+
*
|
|
7
|
+
* One union, in core, for both adapters. There used to be three declarations
|
|
8
|
+
* of this — React's `ui/ListButtons`, Vue's `utils/listState`, and a third in
|
|
9
|
+
* Vue's editor types whose `type` had widened to `string` — none importing
|
|
10
|
+
* another and none covered by a parity gate, so they drifted without anything
|
|
11
|
+
* able to see it.
|
|
12
|
+
*
|
|
13
|
+
* The union also retires the `isInList` flag, which restated `type !== "none"`,
|
|
14
|
+
* and the `numId` that was meaningful only when it was set: a state such as
|
|
15
|
+
* `{ type: "none", isInList: true, numId: 7, level: -1 }` was representable and
|
|
16
|
+
* meant nothing.
|
|
17
|
+
*/
|
|
18
|
+
type ListState = {
|
|
19
|
+
readonly type: "none";
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: "bullet";
|
|
22
|
+
readonly level: number;
|
|
23
|
+
readonly numId?: number;
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: "numbered";
|
|
26
|
+
readonly level: number;
|
|
27
|
+
readonly numId?: number;
|
|
28
|
+
};
|
|
29
|
+
/** The kinds of list a toolbar distinguishes. */
|
|
30
|
+
type ListType = ListState["type"];
|
|
31
|
+
/** The selection is in no list. */
|
|
32
|
+
declare const NO_LIST_STATE: {
|
|
33
|
+
readonly type: "none";
|
|
34
|
+
};
|
|
35
|
+
/** A selection that is in a list, so it has a level. */
|
|
36
|
+
type ActiveListState = Exclude<ListState, {
|
|
37
|
+
type: "none";
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the selection is in a list at all: the one reader over the
|
|
41
|
+
* discriminator, so no consumer spells the empty arm itself.
|
|
42
|
+
*/
|
|
43
|
+
declare const isInListState: (state: ListState | undefined) => state is ActiveListState;
|
|
44
|
+
/** The list level the selection sits at, zero when it is in no list. */
|
|
45
|
+
declare const listStateLevel: (state: ListState | undefined) => number;
|
|
46
|
+
/**
|
|
47
|
+
* The toolbar's view of a paragraph's stated numbering.
|
|
48
|
+
*
|
|
49
|
+
* Which kind of list it is comes from the numbering definitions, through the
|
|
50
|
+
* registry's own reader: a level whose `w:numFmt` is `bullet` is a bullet list
|
|
51
|
+
* and anything else is a numbered one. The adapters used to decide it from the
|
|
52
|
+
* id — `numId === 1` meant bullets — which was true only of documents Folio
|
|
53
|
+
* had created itself, and read a hundred-item bulleted import as numbered.
|
|
54
|
+
*
|
|
55
|
+
* A cancellation and a level with no resolved id are not lists. Callers that
|
|
56
|
+
* have a style tier must merge it before asking for toolbar state.
|
|
57
|
+
*/
|
|
58
|
+
declare const resolveListState: (numbering: NumberingMap | null | undefined, numPr: ParagraphNumberingOverride | undefined) => ListState;
|
|
59
|
+
/** Whether two toolbar list states say the same thing. */
|
|
60
|
+
declare const sameListState: (left: ListState | undefined, right: ListState | undefined) => boolean;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { ActiveListState, ListState, ListType, NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isBulletLevel } from "../docx/numberingParser.js";
|
|
2
|
+
import { panic } from "better-result";
|
|
3
|
+
import { resolveParagraphNumbering } from "@stll/docx-core/model";
|
|
4
|
+
//#region src/prosemirror/listState.ts
|
|
5
|
+
/** The selection is in no list. */
|
|
6
|
+
const NO_LIST_STATE = { type: "none" };
|
|
7
|
+
/**
|
|
8
|
+
* Whether the selection is in a list at all: the one reader over the
|
|
9
|
+
* discriminator, so no consumer spells the empty arm itself.
|
|
10
|
+
*/
|
|
11
|
+
const isInListState = (state) => state !== void 0 && state.type !== "none";
|
|
12
|
+
/** The list level the selection sits at, zero when it is in no list. */
|
|
13
|
+
const listStateLevel = (state) => isInListState(state) ? state.level : 0;
|
|
14
|
+
/**
|
|
15
|
+
* The toolbar's view of a paragraph's stated numbering.
|
|
16
|
+
*
|
|
17
|
+
* Which kind of list it is comes from the numbering definitions, through the
|
|
18
|
+
* registry's own reader: a level whose `w:numFmt` is `bullet` is a bullet list
|
|
19
|
+
* and anything else is a numbered one. The adapters used to decide it from the
|
|
20
|
+
* id — `numId === 1` meant bullets — which was true only of documents Folio
|
|
21
|
+
* had created itself, and read a hundred-item bulleted import as numbered.
|
|
22
|
+
*
|
|
23
|
+
* A cancellation and a level with no resolved id are not lists. Callers that
|
|
24
|
+
* have a style tier must merge it before asking for toolbar state.
|
|
25
|
+
*/
|
|
26
|
+
const resolveListState = (numbering, numPr) => {
|
|
27
|
+
if (numPr === void 0) return NO_LIST_STATE;
|
|
28
|
+
const resolved = resolveParagraphNumbering(numPr);
|
|
29
|
+
if (resolved.kind === "none") return NO_LIST_STATE;
|
|
30
|
+
const { numId, ilvl: level } = resolved;
|
|
31
|
+
const definition = numbering?.getLevel(numId, level) ?? null;
|
|
32
|
+
return {
|
|
33
|
+
type: definition !== null && isBulletLevel(definition) ? "bullet" : "numbered",
|
|
34
|
+
level,
|
|
35
|
+
numId
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/** Whether two toolbar list states say the same thing. */
|
|
39
|
+
const sameListState = (left, right) => {
|
|
40
|
+
if (left === void 0 || right === void 0) return left === right;
|
|
41
|
+
switch (left.type) {
|
|
42
|
+
case "none": return right.type === left.type;
|
|
43
|
+
case "bullet":
|
|
44
|
+
case "numbered": return left.type === right.type && left.level === right.level && left.numId === right.numId;
|
|
45
|
+
default: return panic(`Unhandled list state ${JSON.stringify(left)}`);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ReadProseMirrorAttrsResult } from "./attrs/index.js";
|
|
3
|
+
import { Node } from "prosemirror-model";
|
|
4
|
+
//#region src/prosemirror/moveRangeBoundaryAttrs.d.ts
|
|
5
|
+
type MoveRangeMarker = Extract<document_d_exports.ParagraphContent, {
|
|
6
|
+
type: "moveFromRangeStart" | "moveFromRangeEnd" | "moveToRangeStart" | "moveToRangeEnd";
|
|
7
|
+
}>;
|
|
8
|
+
/** Read one hidden move-range boundary from an untyped editor or clipboard attribute. */
|
|
9
|
+
declare const readMoveRangeMarker: (value: unknown, path?: string) => ReadProseMirrorAttrsResult<MoveRangeMarker>;
|
|
10
|
+
declare const readMoveRangeBoundaryAttrs: (node: Node) => ReadProseMirrorAttrsResult<MoveRangeMarker>;
|
|
11
|
+
declare const expectMoveRangeBoundaryAttrs: (node: Node) => MoveRangeMarker;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { MoveRangeMarker, expectMoveRangeBoundaryAttrs, readMoveRangeBoundaryAttrs, readMoveRangeMarker };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
2
|
+
//#region src/prosemirror/moveRangeBoundaryAttrs.ts
|
|
3
|
+
const MOVE_RANGE_START_TYPES = /* @__PURE__ */ new Set(["moveFromRangeStart", "moveToRangeStart"]);
|
|
4
|
+
const MOVE_RANGE_END_TYPES = /* @__PURE__ */ new Set(["moveFromRangeEnd", "moveToRangeEnd"]);
|
|
5
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
+
const isNonNegativeSafeInteger = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
7
|
+
const displacementOf = (value) => value === "next" || value === "prev" ? value : void 0;
|
|
8
|
+
/** Read one hidden move-range boundary from an untyped editor or clipboard attribute. */
|
|
9
|
+
const readMoveRangeMarker = (value, path = "moveRangeBoundary.attrs.marker") => {
|
|
10
|
+
const issues = [];
|
|
11
|
+
if (!isRecord(value)) return {
|
|
12
|
+
ok: false,
|
|
13
|
+
issues: [{
|
|
14
|
+
path,
|
|
15
|
+
message: "Expected a move range marker object."
|
|
16
|
+
}]
|
|
17
|
+
};
|
|
18
|
+
const type = value["type"];
|
|
19
|
+
const isStart = typeof type === "string" && MOVE_RANGE_START_TYPES.has(type);
|
|
20
|
+
const isEnd = typeof type === "string" && MOVE_RANGE_END_TYPES.has(type);
|
|
21
|
+
if (!isStart && !isEnd) issues.push({
|
|
22
|
+
path: `${path}.type`,
|
|
23
|
+
message: "Expected a move range marker type."
|
|
24
|
+
});
|
|
25
|
+
const id = value["id"];
|
|
26
|
+
if (!isNonNegativeSafeInteger(id)) issues.push({
|
|
27
|
+
path: `${path}.id`,
|
|
28
|
+
message: "Expected a non-negative safe integer."
|
|
29
|
+
});
|
|
30
|
+
const displacedByCustomXml = displacementOf(value["displacedByCustomXml"]);
|
|
31
|
+
if (value["displacedByCustomXml"] !== void 0 && displacedByCustomXml === void 0) issues.push({
|
|
32
|
+
path: `${path}.displacedByCustomXml`,
|
|
33
|
+
message: "Expected \"next\" or \"prev\"."
|
|
34
|
+
});
|
|
35
|
+
const name = value["name"];
|
|
36
|
+
const author = value["author"];
|
|
37
|
+
const date = value["date"];
|
|
38
|
+
const colFirst = value["colFirst"];
|
|
39
|
+
const colLast = value["colLast"];
|
|
40
|
+
if (isStart) {
|
|
41
|
+
if (typeof name !== "string" || name.trim().length === 0) issues.push({
|
|
42
|
+
path: `${path}.name`,
|
|
43
|
+
message: "Expected a non-empty string."
|
|
44
|
+
});
|
|
45
|
+
if (typeof author !== "string" || author.trim().length === 0) issues.push({
|
|
46
|
+
path: `${path}.author`,
|
|
47
|
+
message: "Expected a non-empty string."
|
|
48
|
+
});
|
|
49
|
+
if (date !== void 0 && typeof date !== "string") issues.push({
|
|
50
|
+
path: `${path}.date`,
|
|
51
|
+
message: "Expected a string."
|
|
52
|
+
});
|
|
53
|
+
for (const [key, column] of [["colFirst", colFirst], ["colLast", colLast]]) if (column !== void 0 && !isNonNegativeSafeInteger(column)) issues.push({
|
|
54
|
+
path: `${path}.${key}`,
|
|
55
|
+
message: "Expected a non-negative safe integer."
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (issues.length > 0 || !isNonNegativeSafeInteger(id) || !isStart && !isEnd) return {
|
|
59
|
+
ok: false,
|
|
60
|
+
issues
|
|
61
|
+
};
|
|
62
|
+
const displacement = displacedByCustomXml === void 0 ? {} : { displacedByCustomXml };
|
|
63
|
+
if (type === "moveFromRangeEnd" || type === "moveToRangeEnd") return {
|
|
64
|
+
ok: true,
|
|
65
|
+
value: {
|
|
66
|
+
type,
|
|
67
|
+
id,
|
|
68
|
+
...displacement
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
if (type !== "moveFromRangeStart" && type !== "moveToRangeStart" || typeof name !== "string" || typeof author !== "string") return {
|
|
72
|
+
ok: false,
|
|
73
|
+
issues
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
ok: true,
|
|
77
|
+
value: {
|
|
78
|
+
type,
|
|
79
|
+
id,
|
|
80
|
+
name,
|
|
81
|
+
author,
|
|
82
|
+
...typeof date === "string" ? { date } : {},
|
|
83
|
+
...typeof colFirst === "number" ? { colFirst } : {},
|
|
84
|
+
...typeof colLast === "number" ? { colLast } : {},
|
|
85
|
+
...displacement
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const attrsCache = /* @__PURE__ */ new WeakMap();
|
|
90
|
+
const readMoveRangeBoundaryAttrs = (node) => {
|
|
91
|
+
const result = readMoveRangeMarker(node.attrs["marker"]);
|
|
92
|
+
if (node.type.name === "moveRangeBoundary") return result;
|
|
93
|
+
const issue = {
|
|
94
|
+
path: "moveRangeBoundary.type.name",
|
|
95
|
+
message: `Expected moveRangeBoundary, got ${node.type.name}.`
|
|
96
|
+
};
|
|
97
|
+
return result.ok ? {
|
|
98
|
+
ok: false,
|
|
99
|
+
issues: [issue]
|
|
100
|
+
} : {
|
|
101
|
+
ok: false,
|
|
102
|
+
issues: [issue, ...result.issues]
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
const expectMoveRangeBoundaryAttrs = (node) => {
|
|
106
|
+
const cached = attrsCache.get(node);
|
|
107
|
+
if (cached) return cached;
|
|
108
|
+
const result = readMoveRangeBoundaryAttrs(node);
|
|
109
|
+
if (!result.ok) panic(`Invalid ProseMirror move range boundary attrs:\n${result.issues.map((issue) => `${issue.path}: ${issue.message}`).join("\n")}`);
|
|
110
|
+
attrsCache.set(node, result.value);
|
|
111
|
+
return result.value;
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { expectMoveRangeBoundaryAttrs, readMoveRangeBoundaryAttrs, readMoveRangeMarker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { paragraphNumberingLevel, paragraphNumberingReferenceId } from "../docx/numberingReference.js";
|
|
2
2
|
import { expectFieldAttrs, expectParagraphAttrs } from "./attrs/index.js";
|
|
3
3
|
import { expectBookmarkBoundaryAttrs } from "./bookmarkBoundaryAttrs.js";
|
|
4
4
|
import { advanceVisibleListMarker, createListCounterState, resolveListTemplateWithComponents } from "./listMarker.js";
|
|
@@ -79,10 +79,10 @@ function numberTargetForParagraph(node, contextStreams, streams) {
|
|
|
79
79
|
return visibleTarget;
|
|
80
80
|
}
|
|
81
81
|
function numberTargetForAdvancedMarker(attrs, resolvedMarker, state, contexts) {
|
|
82
|
-
const numId = attrs.numPr
|
|
83
|
-
if (
|
|
82
|
+
const numId = paragraphNumberingReferenceId(attrs.numPr);
|
|
83
|
+
if (numId === void 0 || attrs.listIsBullet || attrs.listMarkerHidden || attrs.listNumFmt === "none" || !resolvedMarker) return null;
|
|
84
84
|
const marker = attrs.listMarkerAllCaps ? resolvedMarker.toLocaleUpperCase() : resolvedMarker;
|
|
85
|
-
const level = attrs.numPr
|
|
85
|
+
const level = paragraphNumberingLevel(attrs.numPr) ?? 0;
|
|
86
86
|
if (!Number.isInteger(level) || level < 0 || level > 8) return null;
|
|
87
87
|
const counters = state.counters.get(numId)?.slice(0, level + 1);
|
|
88
88
|
const levelFormats = attrs.listLevelNumFmts ?? (attrs.listNumFmt ? [attrs.listNumFmt] : void 0);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ParagraphNumberingOverride } from "@stll/docx-core/model";
|
|
2
|
+
//#region src/prosemirror/numberingAttr.d.ts
|
|
3
|
+
declare const PARAGRAPH_NUMBERING_ATTR: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* The only value a persisted `numPr` attr slot may hold.
|
|
6
|
+
*
|
|
7
|
+
* It is the model's union, minted by {@link paragraphNumberingAttr} and by
|
|
8
|
+
* nothing else. The brand is what makes the mint unavoidable: a
|
|
9
|
+
* `ParagraphFormatting.numPr` read off a model object, or a record assembled
|
|
10
|
+
* by hand, does not carry it and so cannot be assigned to an attr. That is the
|
|
11
|
+
* defect the two tiers kept trading — a model value stored verbatim in an attr
|
|
12
|
+
* (`toProseDoc`'s `_propertyChanges` projection) and an attr value stored
|
|
13
|
+
* verbatim in the model-typed `_originalFormatting`
|
|
14
|
+
* (`paragraphRejectOriginalFormatting`) — each of which read as the other's
|
|
15
|
+
* shape on the far side.
|
|
16
|
+
*
|
|
17
|
+
* Reading needs no unbranding: the brand is a phantom property, so an attr
|
|
18
|
+
* value is already a `ParagraphNumberingOverride` to every consumer.
|
|
19
|
+
*/
|
|
20
|
+
type ParagraphNumberingAttr = ParagraphNumberingOverride & {
|
|
21
|
+
readonly [PARAGRAPH_NUMBERING_ATTR]: true;
|
|
22
|
+
};
|
|
23
|
+
/** Mint the attr value for a stated override: the one model-to-attr crossing. */
|
|
24
|
+
declare const paragraphNumberingAttr: (numbering: ParagraphNumberingOverride) => ParagraphNumberingAttr;
|
|
25
|
+
/**
|
|
26
|
+
* The one shape check over a persisted `numPr` attr.
|
|
27
|
+
*
|
|
28
|
+
* The attr validator and the readers that go straight to `node.attrs` share
|
|
29
|
+
* it, so a snapshot shape can be accepted in one place and rejected in the
|
|
30
|
+
* other only by deleting this function.
|
|
31
|
+
*
|
|
32
|
+
* It is deliberately strict. ProseMirror's `computeAttrs` copies whatever a
|
|
33
|
+
* stored document holds into the node without validating, so the pre-union
|
|
34
|
+
* shape — the two `<w:numPr>` slots, where `numId` 0 meant a cancellation —
|
|
35
|
+
* would otherwise arrive as a `numPr` whose `kind` is `undefined`, which every
|
|
36
|
+
* `switch` over the union reads as the arm it is not. Returning `null` for it
|
|
37
|
+
* is what lets the caller refuse.
|
|
38
|
+
*
|
|
39
|
+
* `ilvl` is bounded below and not above: real packages carry levels past the
|
|
40
|
+
* nine the format defines, and docx-core preserves them.
|
|
41
|
+
*/
|
|
42
|
+
declare const paragraphNumberingFromAttrValue: (value: unknown) => ParagraphNumberingAttr | null;
|
|
43
|
+
/**
|
|
44
|
+
* A paragraph's stated numbering, read straight from an unvalidated attrs
|
|
45
|
+
* record. `null` is the attr's absent state, which is what the node spec's
|
|
46
|
+
* default stores.
|
|
47
|
+
*
|
|
48
|
+
* A value that is present and not a {@link ParagraphNumberingAttr} panics
|
|
49
|
+
* rather than being ignored: it can only come from a document written under an
|
|
50
|
+
* attr schema this build does not read, and `yjsDocumentMetadata`'s version
|
|
51
|
+
* gate exists to make that unreachable.
|
|
52
|
+
*/
|
|
53
|
+
declare const readParagraphNumberingAttr: (value: unknown) => ParagraphNumberingAttr | null;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ParagraphNumberingAttr, paragraphNumberingAttr, paragraphNumberingFromAttrValue, readParagraphNumberingAttr };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
2
|
+
import { NO_PARAGRAPH_NUMBERING, paragraphNumberingFromSlots, paragraphNumberingReference } from "@stll/docx-core/model";
|
|
3
|
+
//#region src/prosemirror/numberingAttr.ts
|
|
4
|
+
const branded = (numbering) => numbering;
|
|
5
|
+
/** Mint the attr value for a stated override: the one model-to-attr crossing. */
|
|
6
|
+
const paragraphNumberingAttr = (numbering) => {
|
|
7
|
+
switch (numbering.kind) {
|
|
8
|
+
case "none": return branded(NO_PARAGRAPH_NUMBERING);
|
|
9
|
+
case "reference": return branded(paragraphNumberingReference({
|
|
10
|
+
numId: numbering.numId,
|
|
11
|
+
ilvl: numbering.ilvl
|
|
12
|
+
}));
|
|
13
|
+
case "levelOnly": return branded({
|
|
14
|
+
kind: "levelOnly",
|
|
15
|
+
ilvl: numbering.ilvl
|
|
16
|
+
});
|
|
17
|
+
default: return panic(`Unhandled paragraph numbering ${JSON.stringify(numbering)}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** A `<w:numPr>` slot value: an ordinal, so a non-integer or a negative is not one. */
|
|
21
|
+
const isNumberingSlot = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
22
|
+
/**
|
|
23
|
+
* The one shape check over a persisted `numPr` attr.
|
|
24
|
+
*
|
|
25
|
+
* The attr validator and the readers that go straight to `node.attrs` share
|
|
26
|
+
* it, so a snapshot shape can be accepted in one place and rejected in the
|
|
27
|
+
* other only by deleting this function.
|
|
28
|
+
*
|
|
29
|
+
* It is deliberately strict. ProseMirror's `computeAttrs` copies whatever a
|
|
30
|
+
* stored document holds into the node without validating, so the pre-union
|
|
31
|
+
* shape — the two `<w:numPr>` slots, where `numId` 0 meant a cancellation —
|
|
32
|
+
* would otherwise arrive as a `numPr` whose `kind` is `undefined`, which every
|
|
33
|
+
* `switch` over the union reads as the arm it is not. Returning `null` for it
|
|
34
|
+
* is what lets the caller refuse.
|
|
35
|
+
*
|
|
36
|
+
* `ilvl` is bounded below and not above: real packages carry levels past the
|
|
37
|
+
* nine the format defines, and docx-core preserves them.
|
|
38
|
+
*/
|
|
39
|
+
const paragraphNumberingFromAttrValue = (value) => {
|
|
40
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
41
|
+
const kind = Reflect.get(value, "kind");
|
|
42
|
+
if (kind === "none") return branded(NO_PARAGRAPH_NUMBERING);
|
|
43
|
+
const ilvl = Reflect.get(value, "ilvl");
|
|
44
|
+
if (kind === "levelOnly") return isNumberingSlot(ilvl) ? branded({
|
|
45
|
+
kind: "levelOnly",
|
|
46
|
+
ilvl
|
|
47
|
+
}) : null;
|
|
48
|
+
if (kind !== "reference") return null;
|
|
49
|
+
const numId = Reflect.get(value, "numId");
|
|
50
|
+
if (!isNumberingSlot(numId) || ilvl !== void 0 && !isNumberingSlot(ilvl)) return null;
|
|
51
|
+
const stated = paragraphNumberingFromSlots({
|
|
52
|
+
ilvl,
|
|
53
|
+
numId
|
|
54
|
+
});
|
|
55
|
+
return stated?.kind === "reference" ? branded(stated) : null;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A paragraph's stated numbering, read straight from an unvalidated attrs
|
|
59
|
+
* record. `null` is the attr's absent state, which is what the node spec's
|
|
60
|
+
* default stores.
|
|
61
|
+
*
|
|
62
|
+
* A value that is present and not a {@link ParagraphNumberingAttr} panics
|
|
63
|
+
* rather than being ignored: it can only come from a document written under an
|
|
64
|
+
* attr schema this build does not read, and `yjsDocumentMetadata`'s version
|
|
65
|
+
* gate exists to make that unreachable.
|
|
66
|
+
*/
|
|
67
|
+
const readParagraphNumberingAttr = (value) => {
|
|
68
|
+
if (value === void 0 || value === null) return null;
|
|
69
|
+
const numbering = paragraphNumberingFromAttrValue(value);
|
|
70
|
+
if (numbering === null) panic(`Invalid paragraph numPr attr: ${JSON.stringify(value)}`);
|
|
71
|
+
return numbering;
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { paragraphNumberingAttr, paragraphNumberingFromAttrValue, readParagraphNumberingAttr };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { OutlineLevel } from "@stll/docx-core/model";
|
|
2
|
+
//#region src/prosemirror/outlineLevelAttr.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The one shape check over a persisted `outlineLevel` node attr.
|
|
5
|
+
*
|
|
6
|
+
* The attr validator and the readers that go straight to `node.attrs` share
|
|
7
|
+
* it, so a snapshot shape can be accepted in one place and rejected in the
|
|
8
|
+
* other only by deleting this function.
|
|
9
|
+
*
|
|
10
|
+
* It is deliberately strict. ProseMirror's `computeAttrs` copies whatever a
|
|
11
|
+
* stored document holds into the node without validating, so the pre-union
|
|
12
|
+
* shape — a bare `number`, where `9` meant body text — would otherwise arrive
|
|
13
|
+
* as an `outlineLevel` no consumer recognises and every consumer silently
|
|
14
|
+
* ignores. Returning `null` for it is what lets the caller refuse.
|
|
15
|
+
*/
|
|
16
|
+
declare const outlineLevelFromAttrValue: (value: unknown) => OutlineLevel | null;
|
|
17
|
+
/**
|
|
18
|
+
* A paragraph's stated outline level, read straight from an unvalidated attrs
|
|
19
|
+
* record. `null` is the attr's absent state, which is what the node spec's
|
|
20
|
+
* default stores.
|
|
21
|
+
*
|
|
22
|
+
* A value that is present and not an {@link OutlineLevel} panics rather than
|
|
23
|
+
* being ignored: it can only come from a document written under an attr schema
|
|
24
|
+
* this build does not read, and `yjsDocumentMetadata`'s version gate exists to
|
|
25
|
+
* make that unreachable.
|
|
26
|
+
*/
|
|
27
|
+
declare const readOutlineLevelAttr: (value: unknown) => OutlineLevel | null;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { outlineLevelFromAttrValue, readOutlineLevelAttr };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
2
|
+
import { headingOutlineLevel } from "@stll/docx-core/model";
|
|
3
|
+
//#region src/prosemirror/outlineLevelAttr.ts
|
|
4
|
+
/**
|
|
5
|
+
* The one shape check over a persisted `outlineLevel` node attr.
|
|
6
|
+
*
|
|
7
|
+
* The attr validator and the readers that go straight to `node.attrs` share
|
|
8
|
+
* it, so a snapshot shape can be accepted in one place and rejected in the
|
|
9
|
+
* other only by deleting this function.
|
|
10
|
+
*
|
|
11
|
+
* It is deliberately strict. ProseMirror's `computeAttrs` copies whatever a
|
|
12
|
+
* stored document holds into the node without validating, so the pre-union
|
|
13
|
+
* shape — a bare `number`, where `9` meant body text — would otherwise arrive
|
|
14
|
+
* as an `outlineLevel` no consumer recognises and every consumer silently
|
|
15
|
+
* ignores. Returning `null` for it is what lets the caller refuse.
|
|
16
|
+
*/
|
|
17
|
+
const outlineLevelFromAttrValue = (value) => {
|
|
18
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
19
|
+
const kind = Reflect.get(value, "kind");
|
|
20
|
+
if (kind === "bodyText") return { kind: "bodyText" };
|
|
21
|
+
if (kind !== "heading") return null;
|
|
22
|
+
const level = Reflect.get(value, "level");
|
|
23
|
+
return typeof level === "number" ? headingOutlineLevel(level) ?? null : null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A paragraph's stated outline level, read straight from an unvalidated attrs
|
|
27
|
+
* record. `null` is the attr's absent state, which is what the node spec's
|
|
28
|
+
* default stores.
|
|
29
|
+
*
|
|
30
|
+
* A value that is present and not an {@link OutlineLevel} panics rather than
|
|
31
|
+
* being ignored: it can only come from a document written under an attr schema
|
|
32
|
+
* this build does not read, and `yjsDocumentMetadata`'s version gate exists to
|
|
33
|
+
* make that unreachable.
|
|
34
|
+
*/
|
|
35
|
+
const readOutlineLevelAttr = (value) => {
|
|
36
|
+
if (value === void 0 || value === null) return null;
|
|
37
|
+
const outlineLevel = outlineLevelFromAttrValue(value);
|
|
38
|
+
if (outlineLevel === null) panic(`Invalid paragraph outlineLevel attr: ${JSON.stringify(value)}`);
|
|
39
|
+
return outlineLevel;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { outlineLevelFromAttrValue, readOutlineLevelAttr };
|