@stll/folio-core 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +85 -43
- package/dist/ai-edits/headless.js +2 -2
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +17 -0
- package/dist/content-controls/checkboxDisplay.js +46 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +57 -43
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -18
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +113 -14
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +11 -21
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +76 -0
- package/dist/docx/attributeRemainder.js +111 -0
- package/dist/docx/blockContentParser.d.ts +3 -1
- package/dist/docx/blockContentParser.js +102 -106
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +3 -0
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +56 -39
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +3 -1
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/compatibility.js +56 -41
- package/dist/docx/containerChildren.d.ts +208 -0
- package/dist/docx/containerChildren.gen.d.ts +43 -0
- package/dist/docx/containerChildren.gen.js +263 -0
- package/dist/docx/containerChildren.js +153 -0
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +7 -4
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +66 -9
- package/dist/docx/hyperlinkParser.js +153 -26
- package/dist/docx/imageParser.js +160 -115
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +166 -0
- package/dist/docx/inlineWrapperContent.js +165 -0
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +12 -1
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +111 -0
- package/dist/docx/paraIdAttribute.js +142 -0
- package/dist/docx/paragraphParser.d.ts +10 -25
- package/dist/docx/paragraphParser.js +421 -496
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
- package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +53 -52
- package/dist/docx/parseWarningMessage.js +5 -1
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +96 -0
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +4 -6
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +152 -27
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +55 -19
- package/dist/docx/runParser.js +394 -306
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +241 -238
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +66 -3
- package/dist/docx/selectiveXmlPatch.js +276 -133
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +12 -10
- package/dist/docx/serializer/commentSerializer.js +5 -7
- package/dist/docx/serializer/documentSerializer.js +11 -11
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +10 -9
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +11 -8
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +156 -236
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +134 -75
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +283 -105
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +20 -16
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +13 -8
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +11 -2
- package/dist/docx/tableParser.js +665 -220
- package/dist/docx/textBoxParser.d.ts +28 -3
- package/dist/docx/textBoxParser.js +69 -9
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/unzip.js +5 -4
- package/dist/docx/vmlImageParser.d.ts +30 -5
- package/dist/docx/vmlImageParser.js +91 -32
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +23 -1
- package/dist/docx/xmlParser.js +31 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +12 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +267 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +69 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +10 -3
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +10 -4
- package/dist/layout-painter/renderParagraph.d.ts +14 -1
- package/dist/layout-painter/renderParagraph.js +34 -28
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +12 -4
- package/dist/markdown/renderBlock.js +3 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +34 -6
- package/dist/markdown/renderTable.js +24 -6
- package/dist/markdown/trailers.js +4 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +34 -5
- package/dist/prosemirror/attrs/index.js +639 -48
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +33 -20
- package/dist/prosemirror/commands/image.d.ts +10 -3
- package/dist/prosemirror/commands/image.js +46 -29
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
- package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +801 -411
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +14 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +65 -0
- package/dist/prosemirror/extensions/markRegistry.js +138 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +7 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +92 -0
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +183 -0
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +47 -4
- package/dist/prosemirror/schema/nodes.d.ts +309 -26
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +4 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +31 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
- package/dist/prosemirror/zeroWidthAnchors.js +6 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +27 -1
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +12 -20
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -0
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -50
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -1,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 };
|
|
@@ -2,17 +2,27 @@ import { document_d_exports } from "../types/document.js";
|
|
|
2
2
|
import { ParagraphAttrs } from "./schema/nodes.js";
|
|
3
3
|
import { Node } from "prosemirror-model";
|
|
4
4
|
//#region src/prosemirror/pageBreakRunProjection.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Paragraph shapes whose explicit page-break run the editor lays out
|
|
7
|
+
* approximately.
|
|
8
|
+
*
|
|
9
|
+
* Layout splits a paragraph into fragments at its breaks, and a paragraph
|
|
10
|
+
* property that describes the paragraph as a whole then applies to each
|
|
11
|
+
* fragment. That is an approximation, not a loss: the run is projected, it is
|
|
12
|
+
* saved, and the document opens. Folio used to refuse these instead, which
|
|
13
|
+
* meant a file Word opens could not be opened, laid out or exported at all.
|
|
14
|
+
*/
|
|
5
15
|
declare const PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES: {
|
|
6
|
-
readonly borders: "A bordered paragraph
|
|
7
|
-
readonly frame: "A framed paragraph
|
|
8
|
-
readonly outline: "An outline paragraph
|
|
9
|
-
readonly textBoxAnchor: "A
|
|
16
|
+
readonly borders: "A bordered paragraph is split at its explicit page-break run, so its border is drawn around each part";
|
|
17
|
+
readonly frame: "A framed paragraph is split at its explicit page-break run, so its frame applies to each part";
|
|
18
|
+
readonly outline: "An outline paragraph is split at its explicit page-break run, so each part carries the outline level";
|
|
19
|
+
readonly textBoxAnchor: "A text-box anchor following an explicit page-break run is hosted by the paragraph's first part";
|
|
10
20
|
};
|
|
11
21
|
type PageBreakRunParagraphProjectionReason = keyof typeof PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES;
|
|
12
22
|
type PageBreakRunParagraphProjectionDisposition = {
|
|
13
|
-
status: "
|
|
23
|
+
status: "exact";
|
|
14
24
|
} | {
|
|
15
|
-
status: "
|
|
25
|
+
status: "approximate";
|
|
16
26
|
reason: PageBreakRunParagraphProjectionReason;
|
|
17
27
|
message: (typeof PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES)[keyof typeof PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES];
|
|
18
28
|
};
|
|
@@ -25,7 +35,7 @@ type PageBreakRunParagraphFeatures = {
|
|
|
25
35
|
* Layout splits such a paragraph into fragments at its breaks, and only the
|
|
26
36
|
* first fragment keeps the paragraph's block id, which is what an anchor
|
|
27
37
|
* resolves its host through. An anchor before the first break is therefore
|
|
28
|
-
*
|
|
38
|
+
* laid out exactly; one after it falls back to the first fragment.
|
|
29
39
|
*/
|
|
30
40
|
textBoxAnchorAfterPageBreak: boolean;
|
|
31
41
|
};
|
|
@@ -1,34 +1,44 @@
|
|
|
1
1
|
import { expectParagraphAttrs } from "./attrs/index.js";
|
|
2
2
|
//#region src/prosemirror/pageBreakRunProjection.ts
|
|
3
|
+
/**
|
|
4
|
+
* Paragraph shapes whose explicit page-break run the editor lays out
|
|
5
|
+
* approximately.
|
|
6
|
+
*
|
|
7
|
+
* Layout splits a paragraph into fragments at its breaks, and a paragraph
|
|
8
|
+
* property that describes the paragraph as a whole then applies to each
|
|
9
|
+
* fragment. That is an approximation, not a loss: the run is projected, it is
|
|
10
|
+
* saved, and the document opens. Folio used to refuse these instead, which
|
|
11
|
+
* meant a file Word opens could not be opened, laid out or exported at all.
|
|
12
|
+
*/
|
|
3
13
|
const PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES = {
|
|
4
|
-
borders: "A bordered paragraph
|
|
5
|
-
frame: "A framed paragraph
|
|
6
|
-
outline: "An outline paragraph
|
|
7
|
-
textBoxAnchor: "A
|
|
14
|
+
borders: "A bordered paragraph is split at its explicit page-break run, so its border is drawn around each part",
|
|
15
|
+
frame: "A framed paragraph is split at its explicit page-break run, so its frame applies to each part",
|
|
16
|
+
outline: "An outline paragraph is split at its explicit page-break run, so each part carries the outline level",
|
|
17
|
+
textBoxAnchor: "A text-box anchor following an explicit page-break run is hosted by the paragraph's first part"
|
|
8
18
|
};
|
|
9
19
|
/** Keep source-import and ProseMirror-layout ownership decisions on one predicate. */
|
|
10
20
|
const pageBreakRunParagraphProjectionDispositionForFeatures = ({ attrs, effectiveFrame, textBoxAnchorAfterPageBreak }) => {
|
|
11
21
|
if (effectiveFrame !== void 0 && effectiveFrame.dropCap !== "drop" && effectiveFrame.dropCap !== "margin") return {
|
|
12
|
-
status: "
|
|
22
|
+
status: "approximate",
|
|
13
23
|
reason: "frame",
|
|
14
24
|
message: PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES.frame
|
|
15
25
|
};
|
|
16
26
|
if (attrs.outlineLevel !== void 0) return {
|
|
17
|
-
status: "
|
|
27
|
+
status: "approximate",
|
|
18
28
|
reason: "outline",
|
|
19
29
|
message: PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES.outline
|
|
20
30
|
};
|
|
21
31
|
if (attrs.borders !== void 0 && Object.values(attrs.borders).some((border) => border !== void 0)) return {
|
|
22
|
-
status: "
|
|
32
|
+
status: "approximate",
|
|
23
33
|
reason: "borders",
|
|
24
34
|
message: PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES.borders
|
|
25
35
|
};
|
|
26
36
|
if (textBoxAnchorAfterPageBreak) return {
|
|
27
|
-
status: "
|
|
37
|
+
status: "approximate",
|
|
28
38
|
reason: "textBoxAnchor",
|
|
29
39
|
message: PAGE_BREAK_RUN_PARAGRAPH_PROJECTION_MESSAGES.textBoxAnchor
|
|
30
40
|
};
|
|
31
|
-
return { status: "
|
|
41
|
+
return { status: "exact" };
|
|
32
42
|
};
|
|
33
43
|
const pageBreakRunParagraphProjectionDisposition = (paragraph) => {
|
|
34
44
|
const attrs = expectParagraphAttrs(paragraph);
|
|
@@ -67,6 +67,9 @@ declare const PARAGRAPH_FORMATTING_WRITE_BACK: {
|
|
|
67
67
|
readonly spacingExplicit: {
|
|
68
68
|
readonly kind: "derived";
|
|
69
69
|
};
|
|
70
|
+
readonly spacingPreservedAttributes: {
|
|
71
|
+
readonly kind: "original-only";
|
|
72
|
+
};
|
|
70
73
|
readonly indentLeft: {
|
|
71
74
|
readonly kind: "style-resolved-attr";
|
|
72
75
|
readonly attr: "indentLeft";
|
|
@@ -82,6 +85,9 @@ declare const PARAGRAPH_FORMATTING_WRITE_BACK: {
|
|
|
82
85
|
readonly hangingIndent: {
|
|
83
86
|
readonly kind: "direct-provenance";
|
|
84
87
|
};
|
|
88
|
+
readonly indentPreservedAttributes: {
|
|
89
|
+
readonly kind: "original-only";
|
|
90
|
+
};
|
|
85
91
|
readonly borders: {
|
|
86
92
|
readonly kind: "style-resolved-attr";
|
|
87
93
|
readonly attr: "borders";
|
|
@@ -147,6 +153,9 @@ declare const PARAGRAPH_FORMATTING_WRITE_BACK: {
|
|
|
147
153
|
readonly kind: "style-resolved-attr";
|
|
148
154
|
readonly attr: "runInWithNext";
|
|
149
155
|
};
|
|
156
|
+
readonly preserved: {
|
|
157
|
+
readonly kind: "original-only";
|
|
158
|
+
};
|
|
150
159
|
};
|
|
151
160
|
type StyleResolvedParagraphField = { [Field in keyof typeof PARAGRAPH_FORMATTING_WRITE_BACK]: (typeof PARAGRAPH_FORMATTING_WRITE_BACK)[Field] extends {
|
|
152
161
|
kind: "style-resolved-attr";
|
|
@@ -28,6 +28,7 @@ const PARAGRAPH_FORMATTING_WRITE_BACK = {
|
|
|
28
28
|
beforeAutospacing: { kind: "direct-provenance" },
|
|
29
29
|
afterAutospacing: { kind: "direct-provenance" },
|
|
30
30
|
spacingExplicit: { kind: "derived" },
|
|
31
|
+
spacingPreservedAttributes: { kind: "original-only" },
|
|
31
32
|
indentLeft: {
|
|
32
33
|
kind: "style-resolved-attr",
|
|
33
34
|
attr: "indentLeft"
|
|
@@ -41,6 +42,7 @@ const PARAGRAPH_FORMATTING_WRITE_BACK = {
|
|
|
41
42
|
attr: "indentFirstLine"
|
|
42
43
|
},
|
|
43
44
|
hangingIndent: { kind: "direct-provenance" },
|
|
45
|
+
indentPreservedAttributes: { kind: "original-only" },
|
|
44
46
|
borders: {
|
|
45
47
|
kind: "style-resolved-attr",
|
|
46
48
|
attr: "borders"
|
|
@@ -91,7 +93,8 @@ const PARAGRAPH_FORMATTING_WRITE_BACK = {
|
|
|
91
93
|
runInWithNext: {
|
|
92
94
|
kind: "style-resolved-attr",
|
|
93
95
|
attr: "runInWithNext"
|
|
94
|
-
}
|
|
96
|
+
},
|
|
97
|
+
preserved: { kind: "original-only" }
|
|
95
98
|
};
|
|
96
99
|
const STYLE_RESOLVED_PARAGRAPH_FIELDS = Object.keys(PARAGRAPH_FORMATTING_WRITE_BACK).filter((field) => PARAGRAPH_FORMATTING_WRITE_BACK[field].kind === "style-resolved-attr");
|
|
97
100
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { ListState } from "../listState.js";
|
|
2
3
|
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
3
4
|
//#region src/prosemirror/plugins/selectionTracker.d.ts
|
|
4
5
|
/**
|
|
@@ -17,12 +18,8 @@ type SelectionContext = {
|
|
|
17
18
|
startParagraphIndex: number;
|
|
18
19
|
/** End paragraph index */
|
|
19
20
|
endParagraphIndex: number;
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/** List type if in list */
|
|
23
|
-
listType?: "bullet" | "numbered";
|
|
24
|
-
/** List level (0-8) */
|
|
25
|
-
listLevel?: number;
|
|
21
|
+
/** Which list the cursor is in, resolved against the numbering definitions. */
|
|
22
|
+
listState: ListState;
|
|
26
23
|
/** Active comment IDs at cursor position */
|
|
27
24
|
activeCommentIds: number[];
|
|
28
25
|
/** Whether cursor is inside a tracked insertion */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expectCommentMarkAttrs, expectTrackedChangeMarkAttrs } from "../attrs/index.js";
|
|
2
|
+
import { sameListState } from "../listState.js";
|
|
2
3
|
import { extractSelectionSnapshot } from "../selectionState.js";
|
|
3
4
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
4
5
|
//#region src/prosemirror/plugins/selectionTracker.ts
|
|
@@ -26,12 +27,6 @@ function extractSelectionContext(state) {
|
|
|
26
27
|
...snapshot.paragraphFormatting,
|
|
27
28
|
styleId: snapshot.styleId
|
|
28
29
|
};
|
|
29
|
-
const numPr = snapshot.paragraphFormatting.numPr;
|
|
30
|
-
const inList = !!numPr?.numId;
|
|
31
|
-
let listType;
|
|
32
|
-
if (numPr?.numId === 1) listType = "bullet";
|
|
33
|
-
else if (numPr?.numId) listType = "numbered";
|
|
34
|
-
const listLevel = numPr?.ilvl;
|
|
35
30
|
const allMarks = state.storedMarks || (empty ? selection.$from.marks() : []);
|
|
36
31
|
const activeCommentIds = [];
|
|
37
32
|
let inInsertion = false;
|
|
@@ -54,9 +49,7 @@ function extractSelectionContext(state) {
|
|
|
54
49
|
paragraphFormatting,
|
|
55
50
|
startParagraphIndex: snapshot.startParagraphIndex,
|
|
56
51
|
endParagraphIndex: snapshot.endParagraphIndex,
|
|
57
|
-
|
|
58
|
-
...listType !== void 0 ? { listType } : {},
|
|
59
|
-
...listLevel !== void 0 ? { listLevel } : {},
|
|
52
|
+
listState: snapshot.listState,
|
|
60
53
|
activeCommentIds,
|
|
61
54
|
inInsertion,
|
|
62
55
|
inDeletion
|
|
@@ -99,7 +92,7 @@ function arraysEqual(a, b) {
|
|
|
99
92
|
* Compare two selection contexts for equality
|
|
100
93
|
*/
|
|
101
94
|
function contextsEqual(a, b) {
|
|
102
|
-
return a.hasSelection === b.hasSelection && a.isMultiParagraph === b.isMultiParagraph && a.startParagraphIndex === b.startParagraphIndex && a.endParagraphIndex === b.endParagraphIndex && a.
|
|
95
|
+
return a.hasSelection === b.hasSelection && a.isMultiParagraph === b.isMultiParagraph && a.startParagraphIndex === b.startParagraphIndex && a.endParagraphIndex === b.endParagraphIndex && sameListState(a.listState, b.listState) && a.inInsertion === b.inInsertion && a.inDeletion === b.inDeletion && arraysEqual(a.activeCommentIds, b.activeCommentIds) && JSON.stringify(a.textFormatting) === JSON.stringify(b.textFormatting) && JSON.stringify(a.paragraphFormatting) === JSON.stringify(b.paragraphFormatting);
|
|
103
96
|
}
|
|
104
97
|
/**
|
|
105
98
|
* Get current selection context from editor state
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReadProseMirrorAttrsResult } from "./attrs/index.js";
|
|
2
|
+
import { RangeAnchorAttrs } from "./emptyRangeAnchor.js";
|
|
3
|
+
import { Node } from "prosemirror-model";
|
|
4
|
+
//#region src/prosemirror/rangeAnchorAttrs.d.ts
|
|
5
|
+
/** The two marker values, checked for every field the DOCX serializer reads. */
|
|
6
|
+
declare const readRangeAnchorValues: (start: unknown, end: unknown) => ReadProseMirrorAttrsResult<RangeAnchorAttrs>;
|
|
7
|
+
/**
|
|
8
|
+
* The anchor's attrs, checked before a save can call string methods or emit
|
|
9
|
+
* invalid range-marker XML.
|
|
10
|
+
*/
|
|
11
|
+
declare const readRangeAnchorAttrs: (node: Node) => ReadProseMirrorAttrsResult<RangeAnchorAttrs>;
|
|
12
|
+
declare const expectRangeAnchorAttrs: (node: Node) => RangeAnchorAttrs;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { expectRangeAnchorAttrs, readRangeAnchorAttrs, readRangeAnchorValues };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { isDisplacedByCustomXml } from "./bookmarkBoundaryAttrs.js";
|
|
2
|
+
import { RANGE_END_FOR_START } from "./emptyRangeAnchor.js";
|
|
3
|
+
import { panic } from "better-result";
|
|
4
|
+
//#region src/prosemirror/rangeAnchorAttrs.ts
|
|
5
|
+
const attrsCache = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
7
|
+
const isMarkerId = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
8
|
+
const isRangeStartType = (value) => typeof value === "string" && value in RANGE_END_FOR_START;
|
|
9
|
+
const validateRangeMarkerAttrs = (marker, path, issues) => {
|
|
10
|
+
if (!isMarkerId(marker["id"])) issues.push({
|
|
11
|
+
path: `${path}.id`,
|
|
12
|
+
message: "Expected a non-negative integer."
|
|
13
|
+
});
|
|
14
|
+
const displacedByCustomXml = marker["displacedByCustomXml"];
|
|
15
|
+
if (displacedByCustomXml !== void 0 && !isDisplacedByCustomXml(displacedByCustomXml)) issues.push({
|
|
16
|
+
path: `${path}.displacedByCustomXml`,
|
|
17
|
+
message: "Expected \"next\" or \"prev\"."
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const validateMoveRangeStartAttrs = (marker, path, issues) => {
|
|
21
|
+
for (const required of ["name", "author"]) if (typeof marker[required] !== "string" || marker[required].trim() === "") issues.push({
|
|
22
|
+
path: `${path}.${required}`,
|
|
23
|
+
message: "Expected a non-empty string on a move range start."
|
|
24
|
+
});
|
|
25
|
+
const date = marker["date"];
|
|
26
|
+
if (date !== void 0 && typeof date !== "string") issues.push({
|
|
27
|
+
path: `${path}.date`,
|
|
28
|
+
message: "Expected a string."
|
|
29
|
+
});
|
|
30
|
+
for (const column of ["colFirst", "colLast"]) {
|
|
31
|
+
const value = marker[column];
|
|
32
|
+
if (value !== void 0 && (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)) issues.push({
|
|
33
|
+
path: `${path}.${column}`,
|
|
34
|
+
message: "Expected a non-negative integer."
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/** The two marker values, checked for every field the DOCX serializer reads. */
|
|
39
|
+
const readRangeAnchorValues = (start, end) => {
|
|
40
|
+
const issues = [];
|
|
41
|
+
if (!isRecord(start) || !isRangeStartType(start["type"])) {
|
|
42
|
+
issues.push({
|
|
43
|
+
path: "rangeAnchor.attrs.start",
|
|
44
|
+
message: `Expected one of ${Object.keys(RANGE_END_FOR_START).join(", ")}.`
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
issues
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const expectedEndType = RANGE_END_FOR_START[start["type"]];
|
|
52
|
+
if (!isRecord(end) || end["type"] !== expectedEndType) issues.push({
|
|
53
|
+
path: "rangeAnchor.attrs.end",
|
|
54
|
+
message: `Expected ${expectedEndType}.`
|
|
55
|
+
});
|
|
56
|
+
validateRangeMarkerAttrs(start, "rangeAnchor.attrs.start", issues);
|
|
57
|
+
if (isRecord(end)) {
|
|
58
|
+
validateRangeMarkerAttrs(end, "rangeAnchor.attrs.end", issues);
|
|
59
|
+
if (end["id"] !== start["id"]) issues.push({
|
|
60
|
+
path: "rangeAnchor.attrs.end.id",
|
|
61
|
+
message: "Expected the id its start carries."
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (start["type"] !== "commentRangeStart") validateMoveRangeStartAttrs(start, "rangeAnchor.attrs.start", issues);
|
|
65
|
+
if (issues.length > 0) return {
|
|
66
|
+
ok: false,
|
|
67
|
+
issues
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
ok: true,
|
|
71
|
+
value: {
|
|
72
|
+
start,
|
|
73
|
+
end
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* The anchor's attrs, checked before a save can call string methods or emit
|
|
79
|
+
* invalid range-marker XML.
|
|
80
|
+
*/
|
|
81
|
+
const readRangeAnchorAttrs = (node) => {
|
|
82
|
+
const result = readRangeAnchorValues(node.attrs["start"], node.attrs["end"]);
|
|
83
|
+
if (node.type.name === "rangeAnchor") return result;
|
|
84
|
+
return {
|
|
85
|
+
ok: false,
|
|
86
|
+
issues: [{
|
|
87
|
+
path: "rangeAnchor.type.name",
|
|
88
|
+
message: `Expected rangeAnchor, got ${node.type.name}.`
|
|
89
|
+
}, ...result.ok ? [] : result.issues]
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const expectRangeAnchorAttrs = (node) => {
|
|
93
|
+
const cached = attrsCache.get(node);
|
|
94
|
+
if (cached) return cached;
|
|
95
|
+
const result = readRangeAnchorAttrs(node);
|
|
96
|
+
if (!result.ok) panic(`Invalid ProseMirror range anchor attrs:\n${result.issues.map((issue) => `${issue.path}: ${issue.message}`).join("\n")}`);
|
|
97
|
+
attrsCache.set(node, result.value);
|
|
98
|
+
return result.value;
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { expectRangeAnchorAttrs, readRangeAnchorAttrs, readRangeAnchorValues };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Fragment, Mark, Node, Schema } from "prosemirror-model";
|
|
2
|
+
//#region src/prosemirror/replacedAnnotations.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* What a replacement does with each mark the schema declares
|
|
5
|
+
* `inclusive: false`. Boundary inheritance already handles every other mark,
|
|
6
|
+
* so this table is exactly the set that needs a decision; a new
|
|
7
|
+
* non-inclusive mark that is missing from it fails
|
|
8
|
+
* `replacedAnnotations.test.ts` rather than silently following the text.
|
|
9
|
+
*/
|
|
10
|
+
declare const NON_INCLUSIVE_MARK_DISPOSITION: {
|
|
11
|
+
readonly comment: "carry";
|
|
12
|
+
readonly hyperlink: "carry";
|
|
13
|
+
readonly footnoteRef: "followsTheText";
|
|
14
|
+
readonly runIdentity: "followsTheText";
|
|
15
|
+
readonly insertion: "followsTheText";
|
|
16
|
+
readonly deletion: "followsTheText";
|
|
17
|
+
readonly runPropertyChange: "followsTheText";
|
|
18
|
+
readonly inlineWrapper: "followsTheText";
|
|
19
|
+
};
|
|
20
|
+
/** The mark names in the schema that a replacement must not silently drop. */
|
|
21
|
+
declare const nonInclusiveMarkNames: (schema: Schema) => string[];
|
|
22
|
+
type ReplacedAnnotations = {
|
|
23
|
+
/** Marks the replacement must carry, in document order. */
|
|
24
|
+
carried: readonly Mark[];
|
|
25
|
+
/** Anchors restored before the replacement, in their original order. */
|
|
26
|
+
leading: readonly Node[];
|
|
27
|
+
/** Anchors restored after the replacement, in their original order. */
|
|
28
|
+
trailing: readonly Node[];
|
|
29
|
+
};
|
|
30
|
+
declare const hasReplacedAnnotations: ({ carried, leading, trailing }: ReplacedAnnotations) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The annotations carried by `[from, to)`. An anchor counts only when the
|
|
33
|
+
* range covers it whole: a partially covered atom is not deleted by the
|
|
34
|
+
* replacement either.
|
|
35
|
+
*/
|
|
36
|
+
declare const surveyReplacedAnnotations: (doc: Node, from: number, to: number) => ReplacedAnnotations;
|
|
37
|
+
type AnnotatedReplacementOptions = {
|
|
38
|
+
annotations: ReplacedAnnotations;
|
|
39
|
+
/** The replacement's own inline content, already carrying its formatting. */
|
|
40
|
+
content: Fragment;
|
|
41
|
+
};
|
|
42
|
+
type AnnotatedReplacement = {
|
|
43
|
+
fragment: Fragment;
|
|
44
|
+
/** Size of the anchors restored before the replacement's own content. */
|
|
45
|
+
leadingSize: number;
|
|
46
|
+
/** Size of the replacement's own content, once the marks are on it. */
|
|
47
|
+
contentSize: number;
|
|
48
|
+
};
|
|
49
|
+
/** `marks` with the carried marks added, each type's exclusions respected. */
|
|
50
|
+
declare const addCarriedMarks: (marks: readonly Mark[], carried: readonly Mark[]) => readonly Mark[];
|
|
51
|
+
/** `content` with the surveyed marks on it and the surveyed anchors around it. */
|
|
52
|
+
declare const annotatedReplacement: ({ annotations: { carried, leading, trailing }, content }: AnnotatedReplacementOptions) => AnnotatedReplacement;
|
|
53
|
+
/**
|
|
54
|
+
* The marks a replacement inherits at `[from, to)`, exactly as
|
|
55
|
+
* `Transaction.insertText` would compute them.
|
|
56
|
+
*/
|
|
57
|
+
declare const inheritedReplacementMarks: (doc: Node, from: number, to: number) => readonly Mark[];
|
|
58
|
+
//#endregion
|
|
59
|
+
export { NON_INCLUSIVE_MARK_DISPOSITION, ReplacedAnnotations, addCarriedMarks, annotatedReplacement, hasReplacedAnnotations, inheritedReplacementMarks, nonInclusiveMarkNames, surveyReplacedAnnotations };
|