@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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { visitInlineContentSlots } from "./paragraphTraversal.js";
|
|
2
|
+
//#region src/docx/commentAnchorIndex.ts
|
|
3
|
+
const visitCommentMarkers = (blocks, visit) => {
|
|
4
|
+
const visitParagraph = (paragraph) => {
|
|
5
|
+
visitInlineContentSlots(paragraph, ({ content, index, item }) => {
|
|
6
|
+
if (item.type === "commentRangeStart" || item.type === "commentRangeEnd" || item.type === "commentReference") visit({
|
|
7
|
+
content,
|
|
8
|
+
index,
|
|
9
|
+
item
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const visitBlock = (block) => {
|
|
14
|
+
if (block.type === "paragraph") {
|
|
15
|
+
visitParagraph(block);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (block.type === "table") {
|
|
19
|
+
for (const row of block.rows) for (const cell of row.cells) visitBlocks(cell.content);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (block.type !== "blockSdt") return;
|
|
23
|
+
visitBlocks(block.content);
|
|
24
|
+
};
|
|
25
|
+
const visitBlocks = (nested) => {
|
|
26
|
+
for (const block of nested) visitBlock(block);
|
|
27
|
+
};
|
|
28
|
+
visitBlocks(blocks);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Comments that open a range anywhere in these blocks.
|
|
32
|
+
*
|
|
33
|
+
* A `commentReference` whose id is absent has no highlight of its own — the
|
|
34
|
+
* point-comment shape the model's `CommentReference` documents — and only that
|
|
35
|
+
* one needs its mark anchored onto neighbouring text. Anchoring one whose range
|
|
36
|
+
* exists stretches that range to wherever the reference sits, which is how a
|
|
37
|
+
* comment on one word came back covering the rest of the sentence. The range
|
|
38
|
+
* and the reference need not share a paragraph, so the question is asked of the
|
|
39
|
+
* whole story: a reference that trails the end of a range three paragraphs back
|
|
40
|
+
* is still not a point comment.
|
|
41
|
+
*/
|
|
42
|
+
const rangedCommentIds = (blocks) => {
|
|
43
|
+
const ids = /* @__PURE__ */ new Set();
|
|
44
|
+
visitCommentMarkers(blocks, ({ item }) => {
|
|
45
|
+
if (item.type === "commentRangeStart") ids.add(item.id);
|
|
46
|
+
});
|
|
47
|
+
return ids;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { rangedCommentIds, visitCommentMarkers };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import { StyleMap } from "./styleParser.js";
|
|
3
2
|
import { ParseContext } from "./parseContext.js";
|
|
3
|
+
import { StyleMap } from "./styleParser.js";
|
|
4
4
|
//#region src/docx/commentParser.d.ts
|
|
5
5
|
type CommentExtendedInfo = {
|
|
6
6
|
parentParaId?: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { commentThreadParaId } from "./commentThreadKey.js";
|
|
2
|
+
import { CAPTURE, dispatchChildren } from "./containerChildren.js";
|
|
3
|
+
import { PARA_ID_NAMESPACE_URIS, paraIdAttribute, paraIdParentAttribute } from "./paraIdAttribute.js";
|
|
2
4
|
import { parseParagraph } from "./paragraphParser.js";
|
|
3
5
|
import { cloneParagraphWithPropertySource } from "./paragraphPropertySource.js";
|
|
4
|
-
import { parseRunProperties } from "./runParser.js";
|
|
5
|
-
import {
|
|
6
|
+
import { RUN_PROPERTY_OWNERS, parseRunProperties } from "./runParser.js";
|
|
7
|
+
import { findChild, getAttribute, getAttributeByNamespaceUri, getChildElements, getLocalName, parseOnOffValue, parseXml } from "./xmlParser.js";
|
|
6
8
|
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
7
9
|
//#region src/docx/commentParser.ts
|
|
8
10
|
/**
|
|
@@ -26,26 +28,6 @@ import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
|
26
28
|
/** The whole lexical form of `ST_DecimalNumber`: an optional sign and digits. */
|
|
27
29
|
const DECIMAL_NUMBER = /^[+-]?\d+$/u;
|
|
28
30
|
const DEFAULT_ANNOTATION_REFERENCE_STYLE_ID = "CommentReference";
|
|
29
|
-
/**
|
|
30
|
-
* The namespaces a paraId may be written in: Word 2010 and Word 2012 wordml.
|
|
31
|
-
*
|
|
32
|
-
* Resolved by URI rather than by prefix, because the value is a thread key: an
|
|
33
|
-
* unrelated `vendor:paraId` picked up by local name alone would key a comment
|
|
34
|
-
* to the wrong thread and carry that thread's date, parent and resolved state.
|
|
35
|
-
*/
|
|
36
|
-
const PARA_ID_NAMESPACE_URIS = /* @__PURE__ */ new Set([NAMESPACES.w14, NAMESPACES.w15]);
|
|
37
|
-
/**
|
|
38
|
-
* A paraId join key, wherever an exporter writes it: on `w:comment` or `w:p`.
|
|
39
|
-
*
|
|
40
|
-
* One reading for both, so the wrapper and the paragraphs cannot come to
|
|
41
|
-
* disagree about what counts as a key. The literal reads are the fallback for
|
|
42
|
-
* a part that writes a conventional prefix without binding it, which no URI
|
|
43
|
-
* lookup can resolve.
|
|
44
|
-
*/
|
|
45
|
-
const paraIdAttribute = (element) => {
|
|
46
|
-
const raw = getAttributeByNamespaceUri(element, PARA_ID_NAMESPACE_URIS, "paraId") ?? element.attributes?.["w14:paraId"] ?? element.attributes?.["w15:paraId"] ?? getAttributeByNamespaceUri(element, WORDPROCESSINGML_NAMESPACE_URIS, "paraId") ?? element.attributes?.["w:paraId"];
|
|
47
|
-
return raw === null || raw === void 0 ? void 0 : String(raw);
|
|
48
|
-
};
|
|
49
31
|
const normalizeAnnotationReferenceFormatting = (formatting) => {
|
|
50
32
|
if (formatting?.styleId === DEFAULT_ANNOTATION_REFERENCE_STYLE_ID && Object.keys(formatting).length === 1) return;
|
|
51
33
|
return formatting;
|
|
@@ -54,10 +36,10 @@ const normalizeFirstCommentParagraph = (paragraphElement, paragraph, theme) => {
|
|
|
54
36
|
const firstContentElement = getChildElements(paragraphElement).find((element) => getLocalName(element.name) !== "pPr");
|
|
55
37
|
if (!firstContentElement || getLocalName(firstContentElement.name) !== "r" || !findChild(firstContentElement, "w", "annotationRef")) return { paragraph };
|
|
56
38
|
const runProperties = findChild(firstContentElement, "w", "rPr");
|
|
57
|
-
const annotationReferenceFormatting = normalizeAnnotationReferenceFormatting(runProperties ? parseRunProperties(runProperties, theme) : void 0);
|
|
39
|
+
const annotationReferenceFormatting = normalizeAnnotationReferenceFormatting(runProperties ? parseRunProperties(runProperties, theme, RUN_PROPERTY_OWNERS.standalone) : void 0);
|
|
58
40
|
const firstParsedContent = paragraph.content.at(0);
|
|
59
41
|
return {
|
|
60
|
-
paragraph: firstParsedContent?.type === "run" && firstParsedContent.content.
|
|
42
|
+
paragraph: firstParsedContent?.type === "run" && firstParsedContent.content.every((item) => item.type === "preservedXml" && item.text === "") ? cloneParagraphWithPropertySource(paragraph, { content: paragraph.content.slice(1) }) : paragraph,
|
|
61
43
|
...annotationReferenceFormatting !== void 0 ? { annotationReferenceFormatting } : {}
|
|
62
44
|
};
|
|
63
45
|
};
|
|
@@ -75,9 +57,9 @@ function parseCommentsExtensible(xml) {
|
|
|
75
57
|
const container = findChild(root, "w16cex", "commentsExtensible") ?? root;
|
|
76
58
|
for (const child of getChildElements(container)) {
|
|
77
59
|
if ((child.name?.replace(/^.*:/u, "") ?? "") !== "comment") continue;
|
|
78
|
-
const paraId =
|
|
79
|
-
const dateUtc =
|
|
80
|
-
const key = paraId ===
|
|
60
|
+
const paraId = paraIdAttribute(child);
|
|
61
|
+
const dateUtc = getAttributeByNamespaceUri(child, PARA_ID_NAMESPACE_URIS, "dateUtc") ?? child.attributes?.["w16cex:dateUtc"] ?? child.attributes?.["w15:dateUtc"];
|
|
62
|
+
const key = paraId === void 0 ? null : paraId.toUpperCase();
|
|
81
63
|
if (key && dateUtc && !dateUtcByParaId.has(key)) dateUtcByParaId.set(key, String(dateUtc));
|
|
82
64
|
}
|
|
83
65
|
return dateUtcByParaId;
|
|
@@ -102,11 +84,11 @@ function parseCommentsExtended(xml) {
|
|
|
102
84
|
const container = findChild(root, "w15", "commentsEx") ?? root;
|
|
103
85
|
for (const child of getChildElements(container)) {
|
|
104
86
|
if ((child.name?.replace(/^.*:/u, "") ?? "") !== "commentEx") continue;
|
|
105
|
-
const paraId =
|
|
87
|
+
const paraId = paraIdAttribute(child);
|
|
106
88
|
if (!paraId) continue;
|
|
107
|
-
const key =
|
|
89
|
+
const key = paraId.toUpperCase();
|
|
108
90
|
if (infoByParaId.has(key)) continue;
|
|
109
|
-
const parentParaId =
|
|
91
|
+
const parentParaId = paraIdParentAttribute(child);
|
|
110
92
|
const doneAttr = getAttribute(child, "w15", "done") ?? child.attributes?.["w15:done"];
|
|
111
93
|
const info = {};
|
|
112
94
|
if (parentParaId) info.parentParaId = String(parentParaId).toUpperCase();
|
|
@@ -155,16 +137,50 @@ function parseComments(commentsXml, styles, theme, rels, media, commentsExtensib
|
|
|
155
137
|
const done = (paraId ? extendedByParaId.get(paraId) : void 0)?.done;
|
|
156
138
|
const paragraphs = [];
|
|
157
139
|
let annotationReferenceFormatting;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
140
|
+
const preserved = dispatchChildren({
|
|
141
|
+
element: child,
|
|
142
|
+
container: "w:comment",
|
|
143
|
+
capturePosition: () => paragraphs.length,
|
|
144
|
+
handlers: {
|
|
145
|
+
p: (contentChild) => {
|
|
146
|
+
const paragraph = parseParagraph(contentChild, styles, theme, null, rels, media);
|
|
147
|
+
if (paragraphs.length > 0) {
|
|
148
|
+
paragraphs.push(paragraph);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const normalized = normalizeFirstCommentParagraph(contentChild, paragraph, theme);
|
|
152
|
+
annotationReferenceFormatting = normalized.annotationReferenceFormatting;
|
|
153
|
+
paragraphs.push(normalized.paragraph);
|
|
154
|
+
},
|
|
155
|
+
altChunk: CAPTURE,
|
|
156
|
+
bookmarkEnd: CAPTURE,
|
|
157
|
+
bookmarkStart: CAPTURE,
|
|
158
|
+
commentRangeEnd: CAPTURE,
|
|
159
|
+
commentRangeStart: CAPTURE,
|
|
160
|
+
customXml: CAPTURE,
|
|
161
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
162
|
+
customXmlDelRangeStart: CAPTURE,
|
|
163
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
164
|
+
customXmlInsRangeStart: CAPTURE,
|
|
165
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
166
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
167
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
168
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
169
|
+
del: CAPTURE,
|
|
170
|
+
ins: CAPTURE,
|
|
171
|
+
moveFrom: CAPTURE,
|
|
172
|
+
moveFromRangeEnd: CAPTURE,
|
|
173
|
+
moveFromRangeStart: CAPTURE,
|
|
174
|
+
moveTo: CAPTURE,
|
|
175
|
+
moveToRangeEnd: CAPTURE,
|
|
176
|
+
moveToRangeStart: CAPTURE,
|
|
177
|
+
permEnd: CAPTURE,
|
|
178
|
+
permStart: CAPTURE,
|
|
179
|
+
proofErr: CAPTURE,
|
|
180
|
+
sdt: CAPTURE,
|
|
181
|
+
tbl: CAPTURE
|
|
163
182
|
}
|
|
164
|
-
|
|
165
|
-
annotationReferenceFormatting = normalized.annotationReferenceFormatting;
|
|
166
|
-
paragraphs.push(normalized.paragraph);
|
|
167
|
-
}
|
|
183
|
+
});
|
|
168
184
|
if (paraId && !commentIdByParaId.has(paraId)) commentIdByParaId.set(paraId, id);
|
|
169
185
|
parsed.push({
|
|
170
186
|
comment: {
|
|
@@ -174,6 +190,7 @@ function parseComments(commentsXml, styles, theme, rels, media, commentsExtensib
|
|
|
174
190
|
...date !== void 0 ? { date } : {},
|
|
175
191
|
...done !== void 0 ? { done } : {},
|
|
176
192
|
...annotationReferenceFormatting !== void 0 ? { annotationReferenceFormatting } : {},
|
|
193
|
+
...preserved !== void 0 ? { preserved } : {},
|
|
177
194
|
content: paragraphs
|
|
178
195
|
},
|
|
179
196
|
threadParaId: paraId
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
//#region src/docx/commentRangeIntegrity.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Comment ids whose range is not a start followed by an end in this story's
|
|
5
|
+
* XML. Either half alone is invalid OOXML and anchors nothing: Word shows no
|
|
6
|
+
* comment for a range that never opens.
|
|
7
|
+
*/
|
|
8
|
+
declare const unbalancedCommentRangeIds: (xml: string) => Set<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Whether rewriting `originalXml` into `patchedXml` left a comment range with
|
|
11
|
+
* only one half. A save patches the paragraphs an edit touched and keeps the
|
|
12
|
+
* rest of the part byte-for-byte, so an edit that moves a range's only start
|
|
13
|
+
* out of a patched paragraph and into an untouched one writes an end with no
|
|
14
|
+
* start. Ranges the source already had unbalanced are not this save's doing
|
|
15
|
+
* and stay tolerated.
|
|
16
|
+
*/
|
|
17
|
+
declare const patchBreaksCommentRangeBalance: (originalXml: string, patchedXml: string) => boolean;
|
|
3
18
|
declare const withoutOrphanCommentRanges: (doc: document_d_exports.Document) => document_d_exports.Document;
|
|
4
19
|
//#endregion
|
|
5
|
-
export { withoutOrphanCommentRanges };
|
|
20
|
+
export { patchBreaksCommentRangeBalance, unbalancedCommentRangeIds, withoutOrphanCommentRanges };
|
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
import { cloneParagraphWithPropertySource } from "./paragraphPropertySource.js";
|
|
2
2
|
//#region src/docx/commentRangeIntegrity.ts
|
|
3
|
+
const COMMENT_RANGE_MARKER_PATTERN = /<w:commentRange(Start|End)\s[^>]*w:id="(\d+)"/gu;
|
|
4
|
+
/**
|
|
5
|
+
* Comment ids whose range is not a start followed by an end in this story's
|
|
6
|
+
* XML. Either half alone is invalid OOXML and anchors nothing: Word shows no
|
|
7
|
+
* comment for a range that never opens.
|
|
8
|
+
*/
|
|
9
|
+
const unbalancedCommentRangeIds = (xml) => {
|
|
10
|
+
const firstStart = /* @__PURE__ */ new Map();
|
|
11
|
+
const lastEnd = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const match of xml.matchAll(COMMENT_RANGE_MARKER_PATTERN)) {
|
|
13
|
+
const [, half, id] = match;
|
|
14
|
+
if (id === void 0) continue;
|
|
15
|
+
if (half === "Start") {
|
|
16
|
+
if (!firstStart.has(id)) firstStart.set(id, match.index);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
lastEnd.set(id, match.index);
|
|
20
|
+
}
|
|
21
|
+
const unbalanced = /* @__PURE__ */ new Set();
|
|
22
|
+
for (const id of /* @__PURE__ */ new Set([...firstStart.keys(), ...lastEnd.keys()])) {
|
|
23
|
+
const start = firstStart.get(id);
|
|
24
|
+
const end = lastEnd.get(id);
|
|
25
|
+
if (start === void 0 || end === void 0 || end < start) unbalanced.add(id);
|
|
26
|
+
}
|
|
27
|
+
return unbalanced;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Whether rewriting `originalXml` into `patchedXml` left a comment range with
|
|
31
|
+
* only one half. A save patches the paragraphs an edit touched and keeps the
|
|
32
|
+
* rest of the part byte-for-byte, so an edit that moves a range's only start
|
|
33
|
+
* out of a patched paragraph and into an untouched one writes an end with no
|
|
34
|
+
* start. Ranges the source already had unbalanced are not this save's doing
|
|
35
|
+
* and stay tolerated.
|
|
36
|
+
*/
|
|
37
|
+
const patchBreaksCommentRangeBalance = (originalXml, patchedXml) => {
|
|
38
|
+
const introduced = unbalancedCommentRangeIds(patchedXml);
|
|
39
|
+
if (introduced.size === 0) return false;
|
|
40
|
+
const preexisting = unbalancedCommentRangeIds(originalXml);
|
|
41
|
+
return [...introduced].some((id) => !preexisting.has(id));
|
|
42
|
+
};
|
|
3
43
|
const withoutOrphanCommentRanges = (doc) => {
|
|
4
44
|
const validCommentIds = new Set((doc.package.document.comments ?? []).map((comment) => comment.id));
|
|
5
45
|
const document = withoutOrphanDocumentBodyMarkers(doc.package.document, validCommentIds);
|
|
@@ -107,6 +147,7 @@ const withoutOrphanBlockMarkers = (blocks, validCommentIds) => {
|
|
|
107
147
|
const withoutOrphanBlockMarker = (block, validCommentIds) => {
|
|
108
148
|
if (block.type === "paragraph") return withoutOrphanParagraphMarkers(block, validCommentIds);
|
|
109
149
|
if (block.type === "table") return withoutOrphanTableMarkers(block, validCommentIds);
|
|
150
|
+
if (block.type !== "blockSdt") return block;
|
|
110
151
|
const content = withoutOrphanBlockMarkers(block.content, validCommentIds);
|
|
111
152
|
if (!content) return block;
|
|
112
153
|
return {
|
|
@@ -180,4 +221,4 @@ const withoutOrphanParagraphMarkers = (paragraph, validCommentIds) => {
|
|
|
180
221
|
};
|
|
181
222
|
const isCommentMarker = (content) => content.type === "commentRangeStart" || content.type === "commentRangeEnd" || content.type === "commentReference";
|
|
182
223
|
//#endregion
|
|
183
|
-
export { withoutOrphanCommentRanges };
|
|
224
|
+
export { patchBreaksCommentRangeBalance, unbalancedCommentRangeIds, withoutOrphanCommentRanges };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
//#region src/docx/commentRangeJoin.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Collapse each comment's range markers to its first start and its last end.
|
|
5
|
+
* Answers how many markers were dropped.
|
|
6
|
+
*/
|
|
7
|
+
declare const joinCommentRangesAcrossParagraphs: (blocks: readonly document_d_exports.BlockContent[]) => number;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { joinCommentRangesAcrossParagraphs };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { visitCommentMarkers } from "./commentAnchorIndex.js";
|
|
2
|
+
import { InlineContentRemovals } from "./inlineContentRemovals.js";
|
|
3
|
+
//#region src/docx/commentRangeJoin.ts
|
|
4
|
+
/**
|
|
5
|
+
* Collapse each comment's range markers to its first start and its last end.
|
|
6
|
+
* Answers how many markers were dropped.
|
|
7
|
+
*/
|
|
8
|
+
const joinCommentRangesAcrossParagraphs = (blocks) => {
|
|
9
|
+
const startsById = /* @__PURE__ */ new Map();
|
|
10
|
+
const endsById = /* @__PURE__ */ new Map();
|
|
11
|
+
visitCommentMarkers(blocks, ({ content, index, item }) => {
|
|
12
|
+
if (item.type === "commentReference") return;
|
|
13
|
+
const slotsById = item.type === "commentRangeStart" ? startsById : endsById;
|
|
14
|
+
const slots = slotsById.get(item.id);
|
|
15
|
+
if (slots) {
|
|
16
|
+
slots.push({
|
|
17
|
+
content,
|
|
18
|
+
index
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
slotsById.set(item.id, [{
|
|
23
|
+
content,
|
|
24
|
+
index
|
|
25
|
+
}]);
|
|
26
|
+
});
|
|
27
|
+
const removals = new InlineContentRemovals();
|
|
28
|
+
for (const slots of startsById.values()) for (const slot of slots.slice(1)) removals.mark(slot);
|
|
29
|
+
for (const slots of endsById.values()) for (const slot of slots.slice(0, -1)) removals.mark(slot);
|
|
30
|
+
return removals.apply();
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { joinCommentRangesAcrossParagraphs };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
//#region src/docx/commentReferenceCompletion.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Give every comment that a `commentRangeEnd` closes but no `commentReference`
|
|
5
|
+
* names a reference after its last end. Answers how many were added.
|
|
6
|
+
*/
|
|
7
|
+
declare const completeCommentReferences: (blocks: readonly document_d_exports.BlockContent[]) => number;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { completeCommentReferences };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { visitCommentMarkers } from "./commentAnchorIndex.js";
|
|
2
|
+
//#region src/docx/commentReferenceCompletion.ts
|
|
3
|
+
/**
|
|
4
|
+
* Give every comment that a `commentRangeEnd` closes but no `commentReference`
|
|
5
|
+
* names a reference after its last end. Answers how many were added.
|
|
6
|
+
*/
|
|
7
|
+
const completeCommentReferences = (blocks) => {
|
|
8
|
+
const lastRangeEnds = /* @__PURE__ */ new Map();
|
|
9
|
+
const referencedIds = /* @__PURE__ */ new Set();
|
|
10
|
+
visitCommentMarkers(blocks, ({ content, index, item }) => {
|
|
11
|
+
if (item.type === "commentReference") {
|
|
12
|
+
referencedIds.add(item.id);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (item.type === "commentRangeEnd") lastRangeEnds.set(item.id, {
|
|
16
|
+
content,
|
|
17
|
+
index
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
const insertionsByContent = /* @__PURE__ */ new Map();
|
|
21
|
+
for (const [id, { content, index }] of lastRangeEnds) {
|
|
22
|
+
if (referencedIds.has(id)) continue;
|
|
23
|
+
const pending = insertionsByContent.get(content);
|
|
24
|
+
if (pending) {
|
|
25
|
+
pending.push({
|
|
26
|
+
index,
|
|
27
|
+
id
|
|
28
|
+
});
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
insertionsByContent.set(content, [{
|
|
32
|
+
index,
|
|
33
|
+
id
|
|
34
|
+
}]);
|
|
35
|
+
}
|
|
36
|
+
let added = 0;
|
|
37
|
+
for (const [content, pending] of insertionsByContent) for (const { index, id } of pending.toSorted((first, second) => second.index - first.index || second.id - first.id)) {
|
|
38
|
+
content.splice(index + 1, 0, {
|
|
39
|
+
type: "commentReference",
|
|
40
|
+
id
|
|
41
|
+
});
|
|
42
|
+
added += 1;
|
|
43
|
+
}
|
|
44
|
+
return added;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { completeCommentReferences };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { InlineContentRemovals
|
|
1
|
+
import { InlineContentRemovals } from "./inlineContentRemovals.js";
|
|
2
|
+
import { visitInlineContentSlots } from "./paragraphTraversal.js";
|
|
2
3
|
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
3
4
|
//#region src/docx/commentReferenceNormalization.ts
|
|
4
5
|
/** The codes this normalisation is reported under, owned here, not at the caller. */
|
|
@@ -39,6 +40,7 @@ const normalizeCommentReferences = ({ documentBody, comments, headers, footers,
|
|
|
39
40
|
normalizeTable(block);
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
43
|
+
if (block.type !== "blockSdt") return;
|
|
42
44
|
normalizeBlocks(block.content);
|
|
43
45
|
};
|
|
44
46
|
const normalizeBlocks = (blocks) => {
|
|
@@ -25,34 +25,26 @@ const eachParagraph = (blocks, visit) => {
|
|
|
25
25
|
for (const row of block.rows ?? []) for (const cell of row.cells ?? []) eachParagraph(cell.content ?? [], visit);
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
+
if (block.type !== "blockSdt") continue;
|
|
28
29
|
eachParagraph(block.content ?? [], visit);
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
/** Comment ids with any anchor (a range start OR a `commentReference` run). */
|
|
33
|
+
const scanAnchoredIds = (surfaces) => {
|
|
33
34
|
const anchoredIds = /* @__PURE__ */ new Set();
|
|
34
35
|
for (const group of surfaceBlockGroups(surfaces)) eachParagraph(group, (paragraph) => {
|
|
35
|
-
for (const item of paragraph.content ?? []) if (item.type === "commentRangeStart")
|
|
36
|
-
rangeIds.add(item.id);
|
|
37
|
-
anchoredIds.add(item.id);
|
|
38
|
-
} else if (item.type === "commentReference") anchoredIds.add(item.id);
|
|
36
|
+
for (const item of paragraph.content ?? []) if (item.type === "commentRangeStart" || item.type === "commentReference") anchoredIds.add(item.id);
|
|
39
37
|
});
|
|
40
|
-
return
|
|
41
|
-
rangeIds,
|
|
42
|
-
anchoredIds
|
|
43
|
-
};
|
|
38
|
+
return anchoredIds;
|
|
44
39
|
};
|
|
45
40
|
/** Replies whose parent is another comment (the threaded-discussion shape). */
|
|
46
41
|
const commentParentedReplies = (comments) => {
|
|
47
42
|
const commentIds = new Set(comments.map((comment) => comment.id));
|
|
48
43
|
return comments.filter((comment) => comment.parentId !== void 0 && commentIds.has(comment.parentId));
|
|
49
44
|
};
|
|
50
|
-
const injectIntoParagraph = (paragraph, replyIdsByParent
|
|
45
|
+
const injectIntoParagraph = (paragraph, replyIdsByParent) => {
|
|
51
46
|
const content = paragraph.content ?? [];
|
|
52
|
-
if (!content.some((item) =>
|
|
53
|
-
if (item.type === "commentRangeStart" || item.type === "commentRangeEnd") return replyIdsByParent.has(item.id);
|
|
54
|
-
return item.type === "commentReference" && !parentsWithRange.has(item.id) ? replyIdsByParent.has(item.id) : false;
|
|
55
|
-
})) return 0;
|
|
47
|
+
if (!content.some((item) => (item.type === "commentRangeStart" || item.type === "commentRangeEnd" || item.type === "commentReference") && replyIdsByParent.has(item.id))) return 0;
|
|
56
48
|
const next = [];
|
|
57
49
|
let injected = 0;
|
|
58
50
|
for (const item of content) {
|
|
@@ -68,7 +60,7 @@ const injectIntoParagraph = (paragraph, replyIdsByParent, parentsWithRange) => {
|
|
|
68
60
|
type: "commentRangeEnd",
|
|
69
61
|
id: replyId
|
|
70
62
|
});
|
|
71
|
-
else if (item.type === "commentReference"
|
|
63
|
+
else if (item.type === "commentReference") for (const replyId of replyIdsByParent.get(item.id) ?? []) {
|
|
72
64
|
next.push({
|
|
73
65
|
type: "commentReference",
|
|
74
66
|
id: replyId
|
|
@@ -82,7 +74,7 @@ const injectIntoParagraph = (paragraph, replyIdsByParent, parentsWithRange) => {
|
|
|
82
74
|
const synthesizeReplyRangeMarkers = (surfaces) => {
|
|
83
75
|
const replies = commentParentedReplies(surfaces.comments);
|
|
84
76
|
if (replies.length === 0) return 0;
|
|
85
|
-
const
|
|
77
|
+
const anchoredIds = scanAnchoredIds(surfaces);
|
|
86
78
|
const replyIdsByParent = /* @__PURE__ */ new Map();
|
|
87
79
|
for (const reply of replies) {
|
|
88
80
|
if (anchoredIds.has(reply.id) || reply.parentId === void 0) continue;
|
|
@@ -93,7 +85,7 @@ const synthesizeReplyRangeMarkers = (surfaces) => {
|
|
|
93
85
|
if (replyIdsByParent.size === 0) return 0;
|
|
94
86
|
let injected = 0;
|
|
95
87
|
const visit = (paragraph) => {
|
|
96
|
-
injected += injectIntoParagraph(paragraph, replyIdsByParent
|
|
88
|
+
injected += injectIntoParagraph(paragraph, replyIdsByParent);
|
|
97
89
|
};
|
|
98
90
|
for (const group of surfaceBlockGroups(surfaces)) eachParagraph(group, visit);
|
|
99
91
|
return injected;
|
|
@@ -116,7 +108,7 @@ const hasUnsynthesizedReplyRanges = (doc) => {
|
|
|
116
108
|
const surfaces = surfacesFromDocument(doc);
|
|
117
109
|
const replies = commentParentedReplies(surfaces.comments);
|
|
118
110
|
if (replies.length === 0) return false;
|
|
119
|
-
const
|
|
111
|
+
const anchoredIds = scanAnchoredIds(surfaces);
|
|
120
112
|
return replies.some((reply) => !anchoredIds.has(reply.id));
|
|
121
113
|
};
|
|
122
114
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DRAWING_SAFETY_CLASSES, classifyDrawingSafety } from "./imageRawXml.js";
|
|
2
|
+
import { panic } from "better-result";
|
|
2
3
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
3
4
|
//#region src/docx/compatibility.ts
|
|
4
5
|
/**
|
|
@@ -97,6 +98,7 @@ function inspectBlocks(blocks, context) {
|
|
|
97
98
|
});
|
|
98
99
|
continue;
|
|
99
100
|
}
|
|
101
|
+
if (block.type !== "blockSdt") continue;
|
|
100
102
|
inspectBlocks(block.content, {
|
|
101
103
|
part: context.part,
|
|
102
104
|
path: `${blockPath}.content`,
|
|
@@ -113,53 +115,66 @@ function inspectParagraphContent(content, context) {
|
|
|
113
115
|
...context,
|
|
114
116
|
path: `${context.path}[${itemIndex}]`
|
|
115
117
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
switch (item.type) {
|
|
119
|
+
case "run":
|
|
120
|
+
inspectRun(item, itemContext);
|
|
121
|
+
continue;
|
|
122
|
+
case "hyperlink":
|
|
123
|
+
inspectHyperlink(item, itemContext);
|
|
124
|
+
continue;
|
|
125
|
+
case "inlineSdt":
|
|
126
|
+
case "inlineWrapper":
|
|
127
|
+
case "insertion":
|
|
128
|
+
case "deletion":
|
|
129
|
+
case "moveFrom":
|
|
130
|
+
case "moveTo":
|
|
131
|
+
case "simpleField":
|
|
132
|
+
inspectParagraphContent(item.content, {
|
|
133
|
+
...itemContext,
|
|
134
|
+
path: `${itemContext.path}.content`
|
|
135
|
+
});
|
|
136
|
+
continue;
|
|
137
|
+
case "complexField":
|
|
138
|
+
for (const [runIndex, run] of item.fieldCode.entries()) inspectRun(run, {
|
|
139
|
+
...itemContext,
|
|
140
|
+
path: `${itemContext.path}.fieldCode[${runIndex}]`
|
|
141
|
+
});
|
|
142
|
+
for (const [runIndex, run] of item.fieldResult.entries()) inspectRun(run, {
|
|
143
|
+
...itemContext,
|
|
144
|
+
path: `${itemContext.path}.fieldResult[${runIndex}]`
|
|
145
|
+
});
|
|
146
|
+
continue;
|
|
147
|
+
case "bookmarkStart":
|
|
148
|
+
case "bookmarkEnd":
|
|
149
|
+
case "commentRangeStart":
|
|
150
|
+
case "commentRangeEnd":
|
|
151
|
+
case "commentReference":
|
|
152
|
+
case "moveFromRangeStart":
|
|
153
|
+
case "moveFromRangeEnd":
|
|
154
|
+
case "moveToRangeStart":
|
|
155
|
+
case "moveToRangeEnd":
|
|
156
|
+
case "mathEquation":
|
|
157
|
+
case "preservedInline": continue;
|
|
158
|
+
default: panic(`Unsupported paragraph content: ${JSON.stringify(item)}`);
|
|
130
159
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
...itemContext,
|
|
141
|
-
path: `${itemContext.path}.content`
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function inspectHyperlink(hyperlink, context) {
|
|
163
|
+
for (const [childIndex, child] of hyperlink.children.entries()) {
|
|
164
|
+
const path = `${context.path}.children[${childIndex}]`;
|
|
165
|
+
if (child.type === "run") {
|
|
166
|
+
inspectRun(child, {
|
|
167
|
+
...context,
|
|
168
|
+
path
|
|
142
169
|
});
|
|
143
170
|
continue;
|
|
144
171
|
}
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
for (const [runIndex, run] of item.fieldResult.entries()) inspectRun(run, {
|
|
151
|
-
...itemContext,
|
|
152
|
-
path: `${itemContext.path}.fieldResult[${runIndex}]`
|
|
153
|
-
});
|
|
154
|
-
}
|
|
172
|
+
if (child.type === "inlineWrapper") inspectParagraphContent(child.content, {
|
|
173
|
+
...context,
|
|
174
|
+
path: `${path}.content`
|
|
175
|
+
});
|
|
155
176
|
}
|
|
156
177
|
}
|
|
157
|
-
function inspectHyperlink(hyperlink, context) {
|
|
158
|
-
for (const [childIndex, child] of hyperlink.children.entries()) if (child.type === "run") inspectRun(child, {
|
|
159
|
-
...context,
|
|
160
|
-
path: `${context.path}.children[${childIndex}]`
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
178
|
function inspectRun(run, context) {
|
|
164
179
|
for (const [contentIndex, content] of run.content.entries()) {
|
|
165
180
|
if (content.type !== "drawing") continue;
|