@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,5 +1,7 @@
|
|
|
1
1
|
import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, getProseDocumentParagraphPropertySourceContract } from "../docx/paragraphPropertySource.js";
|
|
2
|
+
import { mintSectionProperties, parseSectionBreakType } from "./sectionCarrier.js";
|
|
2
3
|
import { Result, TaggedError, panic } from "better-result";
|
|
4
|
+
import { DRAWING_RAW_XML_MODES, outlineLevelFromStatedValue, paragraphNumberingFromSlots } from "@stll/docx-core/model";
|
|
3
5
|
//#region src/prosemirror/yjsDocumentMetadata.ts
|
|
4
6
|
/**
|
|
5
7
|
* Folio's own keys inside a collaboration document: one map, two independent
|
|
@@ -19,6 +21,9 @@ const ATTR_SCHEMA_VERSION_KEY = "attrSchemaVersion";
|
|
|
19
21
|
* the identity: it only stamps the key.
|
|
20
22
|
*/
|
|
21
23
|
const stampMarkerOnly = () => 0;
|
|
24
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
25
|
+
/** A shared text node, identified structurally to keep Yjs a type-only import. */
|
|
26
|
+
const isXmlText = (child) => "toDelta" in child;
|
|
22
27
|
/** The node types whose `fldLock` and `dirty` attrs version 2 rewrites. */
|
|
23
28
|
const FIELD_ELEMENT_NAMES = /* @__PURE__ */ new Set(["field", "structuredField"]);
|
|
24
29
|
const STATED_FLAG_ATTRS = ["fldLock", "dirty"];
|
|
@@ -47,6 +52,83 @@ const dropUnstatedFieldFlags = (fragment) => {
|
|
|
47
52
|
visit(fragment);
|
|
48
53
|
return rewritten;
|
|
49
54
|
};
|
|
55
|
+
/** The node type whose `outlineLevel` attrs version 7 rewrites. */
|
|
56
|
+
const PARAGRAPH_ELEMENT_NAME = "paragraph";
|
|
57
|
+
/** A stored outline level, or the absence of one in this carrier. */
|
|
58
|
+
const versionSixOutlineLevel = (value) => {
|
|
59
|
+
if (typeof value !== "number") return;
|
|
60
|
+
return outlineLevelFromStatedValue(value) ?? null;
|
|
61
|
+
};
|
|
62
|
+
/** Rewrite one persisted paragraph-formatting carrier when it stores a v6 number. */
|
|
63
|
+
const versionSixFormatting = (value) => {
|
|
64
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
65
|
+
const outlineLevel = versionSixOutlineLevel(Reflect.get(value, "outlineLevel"));
|
|
66
|
+
if (outlineLevel === void 0) return null;
|
|
67
|
+
const migrated = { ...value };
|
|
68
|
+
if (outlineLevel === null) Reflect.deleteProperty(migrated, "outlineLevel");
|
|
69
|
+
else migrated["outlineLevel"] = outlineLevel;
|
|
70
|
+
return migrated;
|
|
71
|
+
};
|
|
72
|
+
/** Rewrite outline levels in paragraph-property-change formatting carriers. */
|
|
73
|
+
const versionSixPropertyChanges = (value) => {
|
|
74
|
+
if (!Array.isArray(value)) return null;
|
|
75
|
+
const changes = [];
|
|
76
|
+
let changed = false;
|
|
77
|
+
for (const change of value) {
|
|
78
|
+
if (typeof change !== "object" || change === null || Array.isArray(change)) return null;
|
|
79
|
+
const migrated = { ...change };
|
|
80
|
+
for (const tier of ["previousFormatting", "currentFormatting"]) {
|
|
81
|
+
const formatting = versionSixFormatting(change[tier]);
|
|
82
|
+
if (formatting !== null) {
|
|
83
|
+
migrated[tier] = formatting;
|
|
84
|
+
changed = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
changes.push(migrated);
|
|
88
|
+
}
|
|
89
|
+
return changed ? changes : null;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Version 6 stored `outlineLevel` as the `w:outlineLvl w:val` number, with 9
|
|
93
|
+
* meaning body text and every consumer deciding that for itself. Version 7
|
|
94
|
+
* stores `OutlineLevel`, so the number has to be mapped: 0..8 become the
|
|
95
|
+
* heading arm, 9 becomes the body-text arm, and anything else is dropped,
|
|
96
|
+
* matching the parse boundary. It cannot be left alone and read lazily,
|
|
97
|
+
* because ProseMirror copies a stored attr into the node without validating
|
|
98
|
+
* and the strict validator would then panic on the first read of an untouched
|
|
99
|
+
* room.
|
|
100
|
+
*/
|
|
101
|
+
const outlineLevelBecomesAUnion = (fragment) => {
|
|
102
|
+
let rewritten = 0;
|
|
103
|
+
const visit = (node) => {
|
|
104
|
+
if ("nodeName" in node && node.nodeName === PARAGRAPH_ELEMENT_NAME) {
|
|
105
|
+
const attributes = node.getAttributes();
|
|
106
|
+
let changed = false;
|
|
107
|
+
const outlineLevel = versionSixOutlineLevel(attributes["outlineLevel"]);
|
|
108
|
+
if (outlineLevel !== void 0) {
|
|
109
|
+
if (outlineLevel === null) node.removeAttribute("outlineLevel");
|
|
110
|
+
else node.setAttribute("outlineLevel", outlineLevel);
|
|
111
|
+
changed = true;
|
|
112
|
+
}
|
|
113
|
+
for (const attr of ["_originalFormatting", "_resolvedFormatting"]) {
|
|
114
|
+
const formatting = versionSixFormatting(attributes[attr]);
|
|
115
|
+
if (formatting !== null) {
|
|
116
|
+
node.setAttribute(attr, formatting);
|
|
117
|
+
changed = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const propertyChanges = versionSixPropertyChanges(attributes["_propertyChanges"]);
|
|
121
|
+
if (propertyChanges !== null) {
|
|
122
|
+
node.setAttribute("_propertyChanges", propertyChanges);
|
|
123
|
+
changed = true;
|
|
124
|
+
}
|
|
125
|
+
if (changed) rewritten += 1;
|
|
126
|
+
}
|
|
127
|
+
for (const child of node.toArray()) if (typeof child !== "string" && "toArray" in child) visit(child);
|
|
128
|
+
};
|
|
129
|
+
visit(fragment);
|
|
130
|
+
return rewritten;
|
|
131
|
+
};
|
|
50
132
|
/**
|
|
51
133
|
* Version 3 adds `docxRotation`, `docxFlipH` and `docxFlipV` to the drawing
|
|
52
134
|
* nodes. A v2 snapshot states none of them, and `readAuthoredTransform` reads
|
|
@@ -55,12 +137,343 @@ const dropUnstatedFieldFlags = (fragment) => {
|
|
|
55
137
|
* by a v2 build would have the three attrs dropped without a trace.
|
|
56
138
|
*/
|
|
57
139
|
const drawingTransformAttrsAreAdditive = () => 0;
|
|
140
|
+
/** The node type whose relationship and raw-XML attrs version 4 rewrites. */
|
|
141
|
+
const IMAGE_ELEMENT_NAME = "image";
|
|
142
|
+
/**
|
|
143
|
+
* Stands in for the capture marker a node migrated to `previewOnly` never had.
|
|
144
|
+
*
|
|
145
|
+
* `drawingFromImageAttrs` reads the marker's presence and never its value: the
|
|
146
|
+
* editor projection is lossy, so a value compared against the image rebuilt
|
|
147
|
+
* from it would report an untouched round trip as an edit. What the marker has
|
|
148
|
+
* to say here is that the node still holds the capture it was projected with,
|
|
149
|
+
* which is exactly the condition the step selects on.
|
|
150
|
+
*/
|
|
151
|
+
const CARRIED_PREVIEW_CAPTURE = "carriedPreviewCapture";
|
|
152
|
+
/** Rewrite one stored image node, answering whether anything changed. */
|
|
153
|
+
const migrateImageNode = (node) => {
|
|
154
|
+
const attributes = node.getAttributes();
|
|
155
|
+
const rId = attributes["rId"];
|
|
156
|
+
const dropsEmptyId = rId === "";
|
|
157
|
+
const classifies = !(typeof rId === "string" && rId.length > 0) && typeof attributes["_docxRawXml"] === "string" && attributes["_docxRawXmlMode"] === void 0;
|
|
158
|
+
if (dropsEmptyId) node.removeAttribute("rId");
|
|
159
|
+
if (classifies) {
|
|
160
|
+
node.setAttribute("_docxRawXmlMode", DRAWING_RAW_XML_MODES.PREVIEW_ONLY);
|
|
161
|
+
node.setAttribute("_docxRawImageFingerprint", CARRIED_PREVIEW_CAPTURE);
|
|
162
|
+
}
|
|
163
|
+
return dropsEmptyId || classifies;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Version 3 spelled "this drawing carries no relationship" two ways.
|
|
167
|
+
*
|
|
168
|
+
* `rId: ""` is not a key any relationship answers to, so an image that stated
|
|
169
|
+
* it was a drawing with no relationship saying it had one: it reached a save
|
|
170
|
+
* as `r:embed=""`, and only the lookups that knew to ask about both spellings
|
|
171
|
+
* read it as the absence it was. The model has one spelling now, so the attr
|
|
172
|
+
* loses the other.
|
|
173
|
+
*
|
|
174
|
+
* The same pass classifies the drawings that spelling hid. A VML shape folio
|
|
175
|
+
* cannot project is carried as a render of its markup, and version 3 projected
|
|
176
|
+
* that render as an ordinary editable picture: an edit dropped the capture, and
|
|
177
|
+
* the save wrote the render into the package as a picture in place of the
|
|
178
|
+
* shape. An image node that holds a capture, names no relationship and states
|
|
179
|
+
* no mode is exactly that drawing, because every other captured drawing either
|
|
180
|
+
* names a relationship or states its mode. Still holding the capture is what
|
|
181
|
+
* says the node has not been edited, which is what the stamped marker means.
|
|
182
|
+
*/
|
|
183
|
+
const classifyUnrelatedCapturedDrawings = (fragment) => {
|
|
184
|
+
let rewritten = 0;
|
|
185
|
+
const visit = (node) => {
|
|
186
|
+
if ("nodeName" in node && node.nodeName === IMAGE_ELEMENT_NAME && migrateImageNode(node)) rewritten += 1;
|
|
187
|
+
for (const child of node.toArray()) if (typeof child !== "string" && "toArray" in child) visit(child);
|
|
188
|
+
};
|
|
189
|
+
visit(fragment);
|
|
190
|
+
return rewritten;
|
|
191
|
+
};
|
|
192
|
+
/** The node types whose stated cell width version 5 backfills. */
|
|
193
|
+
const TABLE_CELL_ELEMENT_NAMES = /* @__PURE__ */ new Set(["tableCell", "tableHeader"]);
|
|
194
|
+
/** Write a node attribute the binding stores as JSON. */
|
|
195
|
+
const setJsonAttribute = (node, name, value) => {
|
|
196
|
+
node.setAttribute(name, value);
|
|
197
|
+
};
|
|
198
|
+
const statedWidthOf = (attributes) => {
|
|
199
|
+
const original = attributes["_originalFormatting"];
|
|
200
|
+
if (typeof original !== "object" || original === null || !("width" in original)) return;
|
|
201
|
+
const { width } = original;
|
|
202
|
+
if (typeof width !== "object" || width === null) return;
|
|
203
|
+
const value = attributes["width"];
|
|
204
|
+
return typeof value === "number" ? {
|
|
205
|
+
value,
|
|
206
|
+
type: attributes["widthType"] ?? Reflect.get(width, "type")
|
|
207
|
+
} : width;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Version 5 adds `_authoredWidth` to table cells. Version 4 wrote `w:tcW`
|
|
211
|
+
* from the resolved cell width, including cells that stated no preferred
|
|
212
|
+
* width. `_originalFormatting.width` records which cells authored one, so
|
|
213
|
+
* only those cells receive the new attr.
|
|
214
|
+
*/
|
|
215
|
+
const backfillStatedCellWidths = (fragment) => {
|
|
216
|
+
let rewritten = 0;
|
|
217
|
+
const visit = (node) => {
|
|
218
|
+
if ("nodeName" in node && TABLE_CELL_ELEMENT_NAMES.has(node.nodeName)) {
|
|
219
|
+
const attributes = node.getAttributes();
|
|
220
|
+
const stated = statedWidthOf(attributes);
|
|
221
|
+
if (stated !== void 0) {
|
|
222
|
+
setJsonAttribute(node, "_authoredWidth", stated);
|
|
223
|
+
rewritten += 1;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
for (const child of node.toArray()) if (typeof child !== "string" && "toArray" in child) visit(child);
|
|
227
|
+
};
|
|
228
|
+
visit(fragment);
|
|
229
|
+
return rewritten;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Version 6 gives `tableRow`'s `hidden` attr the `null` default the other
|
|
233
|
+
* tri-states carry. Up to version 5 it defaulted to `false`, and the reader
|
|
234
|
+
* that filled it took only an explicit on, so a row that authored
|
|
235
|
+
* `<w:hidden w:val="0"/>` and one that authored nothing were both stored as
|
|
236
|
+
* `false`. `false` therefore never meant an explicit off and cannot be kept as
|
|
237
|
+
* one: a version-5 snapshot's `false` would start writing an element the
|
|
238
|
+
* document never carried. The explicit offs it does hold travelled as captured
|
|
239
|
+
* bytes on `_originalFormatting`, which the step leaves alone.
|
|
240
|
+
*/
|
|
241
|
+
const dropUnstatedRowHidden = (fragment) => {
|
|
242
|
+
let rewritten = 0;
|
|
243
|
+
const visit = (node) => {
|
|
244
|
+
if ("nodeName" in node && node.nodeName === "tableRow") {
|
|
245
|
+
if (node.getAttributes()["hidden"] === false) {
|
|
246
|
+
node.removeAttribute("hidden");
|
|
247
|
+
rewritten += 1;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
for (const child of node.toArray()) if (typeof child !== "string" && "toArray" in child) visit(child);
|
|
251
|
+
};
|
|
252
|
+
visit(fragment);
|
|
253
|
+
return rewritten;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* The `_propertyChanges` entries a paragraph carries, as a version-7 snapshot
|
|
257
|
+
* stored them: an array of records whose `previousFormatting` may carry the
|
|
258
|
+
* numbering the paragraph had before a `w:pPrChange`.
|
|
259
|
+
*/
|
|
260
|
+
const versionSevenPropertyChanges = (value) => {
|
|
261
|
+
if (!Array.isArray(value)) return null;
|
|
262
|
+
const changes = [];
|
|
263
|
+
for (const change of value) {
|
|
264
|
+
if (typeof change !== "object" || change === null || Array.isArray(change)) return null;
|
|
265
|
+
changes.push(change);
|
|
266
|
+
}
|
|
267
|
+
return changes;
|
|
268
|
+
};
|
|
269
|
+
/** The two paragraph attrs, and the two formatting fields, that state numbering. */
|
|
270
|
+
const NUMBERING_ATTR_KEYS = ["numPr", "numPrFromStyle"];
|
|
271
|
+
/**
|
|
272
|
+
* One stored two-slot value, as the union. `null` is an object that stated
|
|
273
|
+
* neither slot, which stated nothing; `undefined` is a value this step must
|
|
274
|
+
* leave exactly as it found it.
|
|
275
|
+
*
|
|
276
|
+
* A value that already carries a `kind` is one of those. Version 7 wrote the
|
|
277
|
+
* model's union into `_originalFormatting` and into a recorded
|
|
278
|
+
* `currentFormatting` while the `numPr` attr beside them still held the two
|
|
279
|
+
* slots, so a version-7 paragraph can hold both spellings at once: that
|
|
280
|
+
* divergence is what version 8 exists to end.
|
|
281
|
+
*/
|
|
282
|
+
const versionSevenNumbering = (value) => {
|
|
283
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return;
|
|
284
|
+
if (typeof Reflect.get(value, "kind") === "string") return;
|
|
285
|
+
const numId = Reflect.get(value, "numId");
|
|
286
|
+
const ilvl = Reflect.get(value, "ilvl");
|
|
287
|
+
return paragraphNumberingFromSlots({
|
|
288
|
+
ilvl: typeof ilvl === "number" ? ilvl : void 0,
|
|
289
|
+
numId: typeof numId === "number" ? numId : void 0
|
|
290
|
+
}) ?? null;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* A stored formatting record with its numbering keys carried forward, or
|
|
294
|
+
* `null` when it holds nothing this step rewrites. `null` inside the record
|
|
295
|
+
* survives: in `previousFormatting` it is the tombstone for "the paragraph
|
|
296
|
+
* carried no numbering before the change".
|
|
297
|
+
*/
|
|
298
|
+
const versionSevenFormatting = (value) => {
|
|
299
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
300
|
+
const stored = { ...value };
|
|
301
|
+
let changed = false;
|
|
302
|
+
for (const key of NUMBERING_ATTR_KEYS) {
|
|
303
|
+
const migrated = versionSevenNumbering(stored[key]);
|
|
304
|
+
if (migrated === void 0) continue;
|
|
305
|
+
changed = true;
|
|
306
|
+
if (migrated === null) Reflect.deleteProperty(stored, key);
|
|
307
|
+
else stored[key] = migrated;
|
|
308
|
+
}
|
|
309
|
+
return changed ? stored : null;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Version 7 stored `numPr` as the two `<w:numPr>` slots, with the reserved
|
|
313
|
+
* `numId` 0 for a cancellation and a bare `ilvl` for a level stated without an
|
|
314
|
+
* id. Version 8 stores the model's union, so the pair has to be mapped:
|
|
315
|
+
* `numId` 0 becomes `none` whatever level sat beside it (a cancellation names
|
|
316
|
+
* no id for a level to belong to), an `ilvl` without a `numId` becomes
|
|
317
|
+
* `levelOnly`, the two together become `reference`, and an object stating
|
|
318
|
+
* neither slot stated nothing is dropped. An absent attr stays absent.
|
|
319
|
+
*
|
|
320
|
+
* Like the version-7 step it cannot be left to a lazy read: ProseMirror copies
|
|
321
|
+
* a stored attr into the node without validating, and
|
|
322
|
+
* `optionalParagraphNumbering` would then refuse the first read of an
|
|
323
|
+
* untouched room.
|
|
324
|
+
*/
|
|
325
|
+
const numberingBecomesAUnion = (fragment) => {
|
|
326
|
+
let rewritten = 0;
|
|
327
|
+
const visit = (node) => {
|
|
328
|
+
if ("nodeName" in node && node.nodeName === PARAGRAPH_ELEMENT_NAME) {
|
|
329
|
+
const attributes = node.getAttributes();
|
|
330
|
+
let changed = false;
|
|
331
|
+
for (const attr of NUMBERING_ATTR_KEYS) {
|
|
332
|
+
const migrated = versionSevenNumbering(attributes[attr]);
|
|
333
|
+
if (migrated === void 0) continue;
|
|
334
|
+
changed = true;
|
|
335
|
+
if (migrated === null) node.removeAttribute(attr);
|
|
336
|
+
else node.setAttribute(attr, migrated);
|
|
337
|
+
}
|
|
338
|
+
const originalFormatting = versionSevenFormatting(attributes["_originalFormatting"]);
|
|
339
|
+
if (originalFormatting !== null) {
|
|
340
|
+
changed = true;
|
|
341
|
+
node.setAttribute("_originalFormatting", originalFormatting);
|
|
342
|
+
}
|
|
343
|
+
const changes = versionSevenPropertyChanges(attributes["_propertyChanges"]);
|
|
344
|
+
if (changes !== null) {
|
|
345
|
+
let changesChanged = false;
|
|
346
|
+
const migratedChanges = [];
|
|
347
|
+
for (const change of changes) {
|
|
348
|
+
const migrated = Object.assign({}, change);
|
|
349
|
+
for (const tier of ["previousFormatting", "currentFormatting"]) {
|
|
350
|
+
const formatting = versionSevenFormatting(change[tier]);
|
|
351
|
+
if (formatting !== null) {
|
|
352
|
+
migrated[tier] = formatting;
|
|
353
|
+
changesChanged = true;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
migratedChanges.push(migrated);
|
|
357
|
+
}
|
|
358
|
+
if (changesChanged) {
|
|
359
|
+
changed = true;
|
|
360
|
+
node.setAttribute("_propertyChanges", migratedChanges);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (changed) rewritten += 1;
|
|
364
|
+
}
|
|
365
|
+
for (const child of node.toArray()) if (typeof child !== "string" && "toArray" in child) visit(child);
|
|
366
|
+
};
|
|
367
|
+
visit(fragment);
|
|
368
|
+
return rewritten;
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Version 9 makes `_sectionProperties` the one carrier of a section break.
|
|
372
|
+
* Earlier snapshots could state `sectionBreakType` instead, and the save leg
|
|
373
|
+
* minted a `SectionProperties` from it. The attr is gone from the schema, so
|
|
374
|
+
* the migration must mint that record before ProseMirror drops the old key.
|
|
375
|
+
* A paragraph that already has the record keeps it as the authority.
|
|
376
|
+
*/
|
|
377
|
+
const SECTION_BREAK_TYPE_ATTR = "sectionBreakType";
|
|
378
|
+
const SECTION_PROPERTIES_ATTR = "_sectionProperties";
|
|
379
|
+
const mintSectionPropertiesFromBreakType = (fragment) => {
|
|
380
|
+
let rewritten = 0;
|
|
381
|
+
const visit = (node) => {
|
|
382
|
+
if ("nodeName" in node && node.nodeName === PARAGRAPH_ELEMENT_NAME) {
|
|
383
|
+
const attributes = node.getAttributes();
|
|
384
|
+
if (SECTION_BREAK_TYPE_ATTR in attributes) {
|
|
385
|
+
const breakType = parseSectionBreakType(attributes[SECTION_BREAK_TYPE_ATTR]);
|
|
386
|
+
if (breakType !== null && attributes[SECTION_PROPERTIES_ATTR] == null) node.setAttribute(SECTION_PROPERTIES_ATTR, mintSectionProperties(breakType));
|
|
387
|
+
node.removeAttribute(SECTION_BREAK_TYPE_ATTR);
|
|
388
|
+
rewritten += 1;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
for (const child of node.toArray()) if (typeof child !== "string" && "toArray" in child) visit(child);
|
|
392
|
+
};
|
|
393
|
+
visit(fragment);
|
|
394
|
+
return rewritten;
|
|
395
|
+
};
|
|
396
|
+
/** The node types whose `showingPlaceholder` attr version 10 rewrites. */
|
|
397
|
+
const SDT_ELEMENT_NAMES = /* @__PURE__ */ new Set(["sdt", "blockSdt"]);
|
|
398
|
+
/**
|
|
399
|
+
* Version 9 stored `showingPlaceholder` as a boolean defaulting to `false`.
|
|
400
|
+
* A control that authored an explicit off and one that authored nothing were
|
|
401
|
+
* both stored as `false`, so the old false cannot become a newly authored
|
|
402
|
+
* `<w:showingPlcHdr w:val="0"/>` when the absence is now `null`.
|
|
403
|
+
*/
|
|
404
|
+
const dropUnstatedPlaceholderFlags = (fragment) => {
|
|
405
|
+
let rewritten = 0;
|
|
406
|
+
const visit = (node) => {
|
|
407
|
+
if ("nodeName" in node && SDT_ELEMENT_NAMES.has(node.nodeName)) {
|
|
408
|
+
if (node.getAttributes()["showingPlaceholder"] === false) {
|
|
409
|
+
node.removeAttribute("showingPlaceholder");
|
|
410
|
+
rewritten += 1;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
for (const child of node.toArray()) if (typeof child !== "string" && "toArray" in child) visit(child);
|
|
414
|
+
};
|
|
415
|
+
visit(fragment);
|
|
416
|
+
return rewritten;
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* Version 11 renames the persisted `pageBreakRunOwner` mark to `runIdentity`.
|
|
420
|
+
* Unknown mark names make y-prosemirror delete their covered text, so the
|
|
421
|
+
* Y.Text delta must be rewritten before the ProseMirror document is built.
|
|
422
|
+
*/
|
|
423
|
+
const renamePageBreakRunOwnerMarkAttr = (fragment) => {
|
|
424
|
+
const OLD_MARK_NAME = "pageBreakRunOwner";
|
|
425
|
+
const NEW_MARK_NAME = "runIdentity";
|
|
426
|
+
let rewritten = 0;
|
|
427
|
+
const rewriteText = (sharedText) => {
|
|
428
|
+
let index = 0;
|
|
429
|
+
const ranges = [];
|
|
430
|
+
for (const op of sharedText.toDelta()) {
|
|
431
|
+
const insert = op.insert;
|
|
432
|
+
const length = typeof insert === "string" ? insert.length : 1;
|
|
433
|
+
const attributes = op.attributes;
|
|
434
|
+
if (isRecord(attributes) && OLD_MARK_NAME in attributes) ranges.push({
|
|
435
|
+
at: index,
|
|
436
|
+
length,
|
|
437
|
+
owner: attributes[OLD_MARK_NAME]
|
|
438
|
+
});
|
|
439
|
+
index += length;
|
|
440
|
+
}
|
|
441
|
+
for (const { at, length, owner } of ranges) {
|
|
442
|
+
const identity = isRecord(owner) && typeof owner["id"] === "number" ? { id: owner["id"] } : {};
|
|
443
|
+
sharedText.format(at, length, {
|
|
444
|
+
[OLD_MARK_NAME]: null,
|
|
445
|
+
[NEW_MARK_NAME]: identity
|
|
446
|
+
});
|
|
447
|
+
rewritten += 1;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
const visit = (node) => {
|
|
451
|
+
for (const child of node.toArray()) {
|
|
452
|
+
if (typeof child === "string") continue;
|
|
453
|
+
if (isXmlText(child)) {
|
|
454
|
+
rewriteText(child);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if ("toArray" in child) visit(child);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
visit(fragment);
|
|
461
|
+
return rewritten;
|
|
462
|
+
};
|
|
58
463
|
/** Every attr-schema version this build reads, oldest first, with no gaps. */
|
|
59
464
|
const FOLIO_YJS_ATTR_SCHEMA_VERSIONS = [
|
|
60
465
|
0,
|
|
61
466
|
1,
|
|
62
467
|
2,
|
|
63
|
-
3
|
|
468
|
+
3,
|
|
469
|
+
4,
|
|
470
|
+
5,
|
|
471
|
+
6,
|
|
472
|
+
7,
|
|
473
|
+
8,
|
|
474
|
+
9,
|
|
475
|
+
10,
|
|
476
|
+
11
|
|
64
477
|
];
|
|
65
478
|
/**
|
|
66
479
|
* The one place a persisted attr-shape change is decided.
|
|
@@ -76,13 +489,21 @@ const ATTR_SCHEMA_MIGRATIONS = {
|
|
|
76
489
|
0: stampMarkerOnly,
|
|
77
490
|
1: dropUnstatedFieldFlags,
|
|
78
491
|
2: drawingTransformAttrsAreAdditive,
|
|
79
|
-
3:
|
|
492
|
+
3: classifyUnrelatedCapturedDrawings,
|
|
493
|
+
4: backfillStatedCellWidths,
|
|
494
|
+
5: dropUnstatedRowHidden,
|
|
495
|
+
6: outlineLevelBecomesAUnion,
|
|
496
|
+
7: numberingBecomesAUnion,
|
|
497
|
+
8: mintSectionPropertiesFromBreakType,
|
|
498
|
+
9: dropUnstatedPlaceholderFlags,
|
|
499
|
+
10: renamePageBreakRunOwnerMarkAttr,
|
|
500
|
+
11: "current"
|
|
80
501
|
};
|
|
81
502
|
/**
|
|
82
503
|
* The attr-schema version this build writes. Derived against the migration map
|
|
83
504
|
* so the constant and the map cannot disagree.
|
|
84
505
|
*/
|
|
85
|
-
const FOLIO_YJS_ATTR_SCHEMA_VERSION =
|
|
506
|
+
const FOLIO_YJS_ATTR_SCHEMA_VERSION = 11;
|
|
86
507
|
/**
|
|
87
508
|
* The steps that carry a snapshot written under `fromVersion` up to
|
|
88
509
|
* {@link FOLIO_YJS_ATTR_SCHEMA_VERSION}, in order. Empty when the snapshot is
|
|
@@ -107,7 +528,7 @@ const attrSchemaMigrationSteps = (fromVersion) => FOLIO_YJS_ATTR_SCHEMA_VERSIONS
|
|
|
107
528
|
* Returns how many elements the steps rewrote.
|
|
108
529
|
*/
|
|
109
530
|
const applyAttrSchemaMigrations = (ydoc, fragment, fromVersion) => {
|
|
110
|
-
if (fromVersion ===
|
|
531
|
+
if (fromVersion === 11) return 0;
|
|
111
532
|
let rewritten = 0;
|
|
112
533
|
ydoc.transact(() => {
|
|
113
534
|
for (const step of attrSchemaMigrationSteps(fromVersion)) rewritten += step(fragment);
|
|
@@ -117,7 +538,7 @@ const applyAttrSchemaMigrations = (ydoc, fragment, fromVersion) => {
|
|
|
117
538
|
};
|
|
118
539
|
/** Raised when a snapshot's attr-schema marker is ahead of the running code. */
|
|
119
540
|
var FolioYjsAttrSchemaVersionError = class extends TaggedError("FolioYjsAttrSchemaVersionError") {};
|
|
120
|
-
const isReadableVersion = (marker) => typeof marker === "number" && Number.isInteger(marker) && marker >= 0 && marker <=
|
|
541
|
+
const isReadableVersion = (marker) => typeof marker === "number" && Number.isInteger(marker) && marker >= 0 && marker <= 11;
|
|
121
542
|
/**
|
|
122
543
|
* The attr-schema version a collaboration document was written under.
|
|
123
544
|
*
|
|
@@ -135,7 +556,7 @@ const readYjsAttrSchemaVersion = (ydoc) => {
|
|
|
135
556
|
return Result.err(new FolioYjsAttrSchemaVersionError({
|
|
136
557
|
marker,
|
|
137
558
|
message: "The collaboration snapshot was written by a newer Folio attr schema than this build reads.",
|
|
138
|
-
supportedVersion:
|
|
559
|
+
supportedVersion: 11
|
|
139
560
|
}));
|
|
140
561
|
};
|
|
141
562
|
const proseDocumentParagraphSourceContract = (document) => {
|
|
@@ -143,7 +564,7 @@ const proseDocumentParagraphSourceContract = (document) => {
|
|
|
143
564
|
};
|
|
144
565
|
/** Stamp the attr-schema version of the build that wrote the current fragment. */
|
|
145
566
|
const writeYjsAttrSchemaVersion = (ydoc) => {
|
|
146
|
-
ydoc.getMap(FOLIO_YJS_METADATA_MAP_NAME).set(ATTR_SCHEMA_VERSION_KEY,
|
|
567
|
+
ydoc.getMap(FOLIO_YJS_METADATA_MAP_NAME).set(ATTR_SCHEMA_VERSION_KEY, 11);
|
|
147
568
|
};
|
|
148
569
|
/**
|
|
149
570
|
* Write both metadata bindings for a freshly seeded collaboration document.
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { BOOKMARK_BOUNDARY_NODE_NAME } from "./extensions/nodes/BookmarkBoundaryExtension.js";
|
|
2
2
|
import { COMMENT_REFERENCE_NODE_NAME } from "./extensions/nodes/CommentReferenceExtension.js";
|
|
3
|
+
import { MOVE_RANGE_BOUNDARY_NODE_NAME } from "./extensions/nodes/MoveRangeBoundaryExtension.js";
|
|
4
|
+
import { RANGE_ANCHOR_NODE_NAME } from "./extensions/nodes/RangeAnchorExtension.js";
|
|
3
5
|
import { RENDERED_PAGE_BREAK_NODE_NAME } from "./extensions/nodes/RenderedPageBreakExtension.js";
|
|
4
6
|
import { TEXT_BOX_ANCHOR_NODE_NAME } from "./extensions/nodes/TextBoxAnchorExtension.js";
|
|
5
7
|
//#region src/prosemirror/zeroWidthAnchors.ts
|
|
6
8
|
const ZERO_WIDTH_ANCHOR_NODE_NAMES = /* @__PURE__ */ new Set([
|
|
7
9
|
BOOKMARK_BOUNDARY_NODE_NAME,
|
|
8
10
|
COMMENT_REFERENCE_NODE_NAME,
|
|
11
|
+
MOVE_RANGE_BOUNDARY_NODE_NAME,
|
|
12
|
+
RANGE_ANCHOR_NODE_NAME,
|
|
9
13
|
RENDERED_PAGE_BREAK_NODE_NAME,
|
|
10
14
|
TEXT_BOX_ANCHOR_NODE_NAME
|
|
11
15
|
]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mintDefaultParagraphStyle, resolveDefaultParagraphStyle } from "../docx/defaultParagraphStyle.js";
|
|
2
2
|
import { getCachedNumberingMap } from "../docx/numberingParser.js";
|
|
3
|
-
import {
|
|
3
|
+
import { paragraphNumberingReferenceId } from "../docx/numberingReference.js";
|
|
4
4
|
import { normalizeStyleNumberingReferences } from "../docx/numberingReferenceNormalization.js";
|
|
5
5
|
import { parseDocx } from "../docx/parser.js";
|
|
6
6
|
import "./types.js";
|
|
@@ -105,8 +105,8 @@ const extractReferencedNumbering = (styles, document) => {
|
|
|
105
105
|
if (!source) return;
|
|
106
106
|
const referencedNumIds = /* @__PURE__ */ new Set();
|
|
107
107
|
for (const style of styles) {
|
|
108
|
-
const numId = style.pPr?.numPr
|
|
109
|
-
if (
|
|
108
|
+
const numId = paragraphNumberingReferenceId(style.pPr?.numPr);
|
|
109
|
+
if (numId !== void 0) referencedNumIds.add(numId);
|
|
110
110
|
}
|
|
111
111
|
if (referencedNumIds.size === 0) return;
|
|
112
112
|
const nums = source.nums.filter((numbering) => referencedNumIds.has(numbering.numId));
|
|
@@ -133,7 +133,7 @@ const toCatalogEntry = (style) => {
|
|
|
133
133
|
style.link
|
|
134
134
|
].filter((dependency) => dependency !== void 0))]
|
|
135
135
|
};
|
|
136
|
-
const numberingId = style.pPr?.numPr
|
|
136
|
+
const numberingId = paragraphNumberingReferenceId(style.pPr?.numPr);
|
|
137
137
|
if (numberingId !== void 0) entry.numberingId = numberingId;
|
|
138
138
|
return entry;
|
|
139
139
|
};
|