@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,7 @@
|
|
|
1
1
|
import { formatDate } from "../docx/fieldParser.js";
|
|
2
|
+
import { cloneParagraphWithPropertySource } from "../docx/paragraphPropertySource.js";
|
|
3
|
+
import { preservedSdtChild, withoutPreservedSdtChild } from "../docx/sdtProperties.js";
|
|
4
|
+
import { checkboxDisplayContent } from "./checkboxDisplay.js";
|
|
2
5
|
import { ContentControlBoundError, ContentControlLockedError, ContentControlTypeError } from "./errors.js";
|
|
3
6
|
import { sanitizeXmlCharacters } from "@stll/docx-core";
|
|
4
7
|
//#region src/content-controls/mutateContentControls.ts
|
|
@@ -93,22 +96,16 @@ function ensureSdtNotLocked(control, force) {
|
|
|
93
96
|
if (lock === "sdtLocked" || lock === "sdtContentLocked") throwLocked(control, lock);
|
|
94
97
|
}
|
|
95
98
|
function isRepeatingSection(control) {
|
|
96
|
-
|
|
97
|
-
return raw !== void 0 && REPEATING_SECTION_RE.test(raw);
|
|
99
|
+
return preservedSdtChild(control.properties.preserved, "repeatingSection") !== void 0;
|
|
98
100
|
}
|
|
99
|
-
const REPEATING_SECTION_RE = /<\w+:repeatingSection\b/u;
|
|
100
|
-
const DATA_BINDING_RE = /<\w+:dataBinding\b(?<attrs>[^>]*)\/?>/iu;
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
102
|
+
* The binding a `<w:dataBinding w:xpath="…"/>` states, for the error payload.
|
|
103
|
+
*
|
|
104
|
+
* Returns null when the control carries no binding.
|
|
105
105
|
*/
|
|
106
106
|
function readDataBinding(control) {
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
const match = DATA_BINDING_RE.exec(raw);
|
|
110
|
-
if (!match) return null;
|
|
111
|
-
const attrs = match.groups?.["attrs"] ?? "";
|
|
107
|
+
const attrs = preservedSdtChild(control.properties.preserved, "dataBinding");
|
|
108
|
+
if (attrs === void 0) return null;
|
|
112
109
|
const xpathMatch = /\bxpath="(?<xpath>[^"]*)"/iu.exec(attrs);
|
|
113
110
|
if (!xpathMatch) return null;
|
|
114
111
|
const xpath = xpathMatch.groups?.["xpath"] ?? "";
|
|
@@ -121,14 +118,13 @@ function readDataBinding(control) {
|
|
|
121
118
|
}
|
|
122
119
|
/**
|
|
123
120
|
* Refuse content mutations on bound SDTs unless the caller passes
|
|
124
|
-
* `{ force: true }`. When force is set, return the
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* for the rationale.
|
|
121
|
+
* `{ force: true }`. When force is set, return the property set without its
|
|
122
|
+
* `<w:dataBinding>` child so the caller's write actually sticks on next Word
|
|
123
|
+
* open. See `ContentControlBoundError` for the rationale.
|
|
128
124
|
*/
|
|
129
125
|
function ensureContentNotBound(control, force) {
|
|
130
126
|
const binding = readDataBinding(control);
|
|
131
|
-
if (!binding) return {
|
|
127
|
+
if (!binding) return { wasBound: false };
|
|
132
128
|
if (!force) throw new ContentControlBoundError({
|
|
133
129
|
message: `Control "${control.properties.tag ?? control.properties.alias ?? "(unnamed)"}" is bound to ${binding.xpath}. Word regenerates the body from the bound XML on open; pass { force: true } to strip the binding inline, or remove it explicitly before writing.`,
|
|
134
130
|
xpath: binding.xpath,
|
|
@@ -136,9 +132,19 @@ function ensureContentNotBound(control, force) {
|
|
|
136
132
|
...control.properties.tag !== void 0 ? { tag: control.properties.tag } : {},
|
|
137
133
|
...control.properties.alias !== void 0 ? { alias: control.properties.alias } : {}
|
|
138
134
|
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
return {
|
|
136
|
+
wasBound: true,
|
|
137
|
+
unbound: withoutPreservedSdtChild(control.properties.preserved, "dataBinding")
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** Write a {@link BindingRemoval} onto a copy of a control's properties. */
|
|
141
|
+
function applyBindingRemoval(properties, removal) {
|
|
142
|
+
if (!removal.wasBound) return;
|
|
143
|
+
if (removal.unbound === void 0) {
|
|
144
|
+
delete properties.preserved;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
properties.preserved = removal.unbound;
|
|
142
148
|
}
|
|
143
149
|
function mapBlock(block, match) {
|
|
144
150
|
if (block.type === "blockSdt") {
|
|
@@ -234,6 +240,20 @@ function makeParagraphFromText(rawText) {
|
|
|
234
240
|
}]
|
|
235
241
|
};
|
|
236
242
|
}
|
|
243
|
+
function makeCheckboxParagraph(control, checked) {
|
|
244
|
+
const paragraph = control.content.find((block) => block.type === "paragraph");
|
|
245
|
+
const run = paragraph?.content.find((item) => item.type === "run");
|
|
246
|
+
const content = [{
|
|
247
|
+
type: "run",
|
|
248
|
+
...run?.formatting !== void 0 ? { formatting: run.formatting } : {},
|
|
249
|
+
content: [checkboxDisplayContent(preservedSdtChild(control.properties.preserved, "checkbox"), checked)]
|
|
250
|
+
}];
|
|
251
|
+
if (!paragraph) return {
|
|
252
|
+
type: "paragraph",
|
|
253
|
+
content
|
|
254
|
+
};
|
|
255
|
+
return cloneParagraphWithPropertySource(paragraph, { content });
|
|
256
|
+
}
|
|
237
257
|
function cloneBlock(block) {
|
|
238
258
|
return structuredClone(block);
|
|
239
259
|
}
|
|
@@ -257,11 +277,11 @@ function setContentControlContent(doc, filter, input, options = {}) {
|
|
|
257
277
|
const match = (control) => {
|
|
258
278
|
if (!controlMatchesFilter(control, filter)) return;
|
|
259
279
|
ensureContentNotLocked(control, options.force);
|
|
260
|
-
const
|
|
280
|
+
const removal = ensureContentNotBound(control, options.force);
|
|
261
281
|
const blocks = typeof input === "string" ? [makeParagraphFromText(input)] : input.map(cloneBlock);
|
|
262
282
|
const properties = { ...control.properties };
|
|
263
283
|
properties.showingPlaceholder = false;
|
|
264
|
-
|
|
284
|
+
applyBindingRemoval(properties, removal);
|
|
265
285
|
return {
|
|
266
286
|
...control,
|
|
267
287
|
properties,
|
|
@@ -279,7 +299,17 @@ function setContentControlValue(doc, filter, input, options = {}) {
|
|
|
279
299
|
const match = (control) => {
|
|
280
300
|
if (!controlMatchesFilter(control, filter)) return;
|
|
281
301
|
ensureContentNotLocked(control, options.force);
|
|
282
|
-
const
|
|
302
|
+
const removal = ensureContentNotBound(control, options.force);
|
|
303
|
+
/** The control's properties, unbound, plus whatever this input sets. */
|
|
304
|
+
const nextProperties = (set) => {
|
|
305
|
+
const properties = {
|
|
306
|
+
...control.properties,
|
|
307
|
+
...set
|
|
308
|
+
};
|
|
309
|
+
properties.showingPlaceholder = false;
|
|
310
|
+
applyBindingRemoval(properties, removal);
|
|
311
|
+
return properties;
|
|
312
|
+
};
|
|
283
313
|
const sdtType = control.properties.sdtType;
|
|
284
314
|
if (input.kind === "dropdown") {
|
|
285
315
|
if (sdtType !== "dropdown" && sdtType !== "comboBox") throw new ContentControlTypeError({
|
|
@@ -300,12 +330,7 @@ function setContentControlValue(doc, filter, input, options = {}) {
|
|
|
300
330
|
const display = item?.displayText ?? input.value;
|
|
301
331
|
return {
|
|
302
332
|
...control,
|
|
303
|
-
properties: {
|
|
304
|
-
...control.properties,
|
|
305
|
-
dropdownLastValue: sanitizeXmlCharacters(input.value),
|
|
306
|
-
showingPlaceholder: false,
|
|
307
|
-
...strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {}
|
|
308
|
-
},
|
|
333
|
+
properties: nextProperties({ dropdownLastValue: sanitizeXmlCharacters(input.value) }),
|
|
309
334
|
content: [makeParagraphFromText(display)]
|
|
310
335
|
};
|
|
311
336
|
}
|
|
@@ -317,16 +342,10 @@ function setContentControlValue(doc, filter, input, options = {}) {
|
|
|
317
342
|
...control.properties.tag !== void 0 ? { tag: control.properties.tag } : {},
|
|
318
343
|
...control.properties.alias !== void 0 ? { alias: control.properties.alias } : {}
|
|
319
344
|
});
|
|
320
|
-
const glyph = input.checked ? "☒" : "☐";
|
|
321
345
|
return {
|
|
322
346
|
...control,
|
|
323
|
-
properties: {
|
|
324
|
-
|
|
325
|
-
checked: input.checked,
|
|
326
|
-
showingPlaceholder: false,
|
|
327
|
-
...strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {}
|
|
328
|
-
},
|
|
329
|
-
content: [makeParagraphFromText(glyph)]
|
|
347
|
+
properties: nextProperties({ checked: input.checked }),
|
|
348
|
+
content: [makeCheckboxParagraph(control, input.checked)]
|
|
330
349
|
};
|
|
331
350
|
}
|
|
332
351
|
if (sdtType !== "date") throw new ContentControlTypeError({
|
|
@@ -339,12 +358,7 @@ function setContentControlValue(doc, filter, input, options = {}) {
|
|
|
339
358
|
const display = formatDateForSdtBody(input.date, control.properties.dateFormat);
|
|
340
359
|
return {
|
|
341
360
|
...control,
|
|
342
|
-
properties: {
|
|
343
|
-
...control.properties,
|
|
344
|
-
dateValueISO: input.date,
|
|
345
|
-
showingPlaceholder: false,
|
|
346
|
-
...strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {}
|
|
347
|
-
},
|
|
361
|
+
properties: nextProperties({ dateValueISO: input.date }),
|
|
348
362
|
content: [makeParagraphFromText(display)]
|
|
349
363
|
};
|
|
350
364
|
};
|
|
@@ -46,6 +46,7 @@ declare class ContentControlWidgetController extends Subscribable<ContentControl
|
|
|
46
46
|
private readonly onPaintedClick;
|
|
47
47
|
private readonly onKeyDown;
|
|
48
48
|
private readonly onScroll;
|
|
49
|
+
private readonly onPointerDown;
|
|
49
50
|
private open;
|
|
50
51
|
private removeDismissListeners;
|
|
51
52
|
private unbindView;
|
|
@@ -113,15 +113,18 @@ var ContentControlWidgetController = class extends Subscribable {
|
|
|
113
113
|
if (event.key === "Escape") this.close();
|
|
114
114
|
};
|
|
115
115
|
onScroll = () => this.close();
|
|
116
|
+
onPointerDown = () => this.close();
|
|
116
117
|
open(snapshot) {
|
|
117
118
|
this.removeDismissListeners();
|
|
118
119
|
this.ownerWindow = this.viewDom?.ownerDocument.defaultView ?? null;
|
|
119
120
|
this.ownerWindow?.addEventListener("keydown", this.onKeyDown);
|
|
121
|
+
this.ownerWindow?.addEventListener("pointerdown", this.onPointerDown);
|
|
120
122
|
this.ownerWindow?.addEventListener("scroll", this.onScroll, true);
|
|
121
123
|
this.setSnapshot(snapshot);
|
|
122
124
|
}
|
|
123
125
|
removeDismissListeners() {
|
|
124
126
|
this.ownerWindow?.removeEventListener("keydown", this.onKeyDown);
|
|
127
|
+
this.ownerWindow?.removeEventListener("pointerdown", this.onPointerDown);
|
|
125
128
|
this.ownerWindow?.removeEventListener("scroll", this.onScroll, true);
|
|
126
129
|
this.ownerWindow = null;
|
|
127
130
|
}
|
|
@@ -45,7 +45,9 @@ const createHiddenEditorApi = (deps) => {
|
|
|
45
45
|
return stateToDocument(view.state, deps.getDocumentContext());
|
|
46
46
|
},
|
|
47
47
|
focus: () => {
|
|
48
|
-
deps.getView()
|
|
48
|
+
const view = deps.getView();
|
|
49
|
+
if (!view || view.hasFocus()) return;
|
|
50
|
+
view.focus();
|
|
49
51
|
},
|
|
50
52
|
blur: () => {
|
|
51
53
|
const view = deps.getView();
|
|
@@ -5,9 +5,9 @@ import { RemoteSelection } from "../types/remote-selection.js";
|
|
|
5
5
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
6
6
|
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
7
7
|
import { EditorView } from "prosemirror-view";
|
|
8
|
-
import * as YProseMirror from "y-prosemirror";
|
|
9
8
|
import * as Yjs from "yjs";
|
|
10
9
|
import { XmlFragment } from "yjs";
|
|
10
|
+
import * as YProseMirror from "y-prosemirror";
|
|
11
11
|
//#region src/controller/hiddenEditorManager.d.ts
|
|
12
12
|
type YProseMirrorModule = typeof YProseMirror;
|
|
13
13
|
type YjsModule = typeof Yjs;
|
|
@@ -8,7 +8,7 @@ import { createDocumentNumberingPlugin } from "../prosemirror/plugins/documentNu
|
|
|
8
8
|
import { createDocumentStylesPlugin } from "../prosemirror/plugins/documentStyles.js";
|
|
9
9
|
import { schema } from "../prosemirror/schema/index.js";
|
|
10
10
|
import { createTextInputPlugin } from "../prosemirror/textInput.js";
|
|
11
|
-
import { proseDocumentParagraphSourceContract, readYjsParagraphSourceContract, withParagraphSourceContract,
|
|
11
|
+
import { applyAttrSchemaMigrations, proseDocumentParagraphSourceContract, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract, writeYjsDocumentMetadata } from "../prosemirror/yjsDocumentMetadata.js";
|
|
12
12
|
import { createHiddenEditorApi } from "./hiddenEditorApi.js";
|
|
13
13
|
import { panic } from "better-result";
|
|
14
14
|
import { EditorState } from "prosemirror-state";
|
|
@@ -129,12 +129,15 @@ function createHiddenEditorState(options) {
|
|
|
129
129
|
collaborationModules.yProseMirror.prosemirrorToYXmlFragment(seedState.doc, collaboration.yXmlFragment);
|
|
130
130
|
const collaborationDocument = collaboration.yXmlFragment.doc;
|
|
131
131
|
if (!collaborationDocument) panic("A collaboration fragment must belong to a Yjs document before seeding.");
|
|
132
|
-
|
|
132
|
+
writeYjsDocumentMetadata(collaborationDocument, seedState.doc);
|
|
133
133
|
collaboration.onSeeded?.();
|
|
134
134
|
}
|
|
135
|
-
let { doc } = collaborationModules.yProseMirror.initProseMirrorDoc(collaboration.yXmlFragment, activeSchema);
|
|
136
135
|
const collaborationDocument = collaboration.yXmlFragment.doc;
|
|
137
136
|
if (!collaborationDocument) panic("A collaboration fragment must belong to a Yjs document before loading.");
|
|
137
|
+
const attrSchemaVersion = readYjsAttrSchemaVersion(collaborationDocument);
|
|
138
|
+
if (attrSchemaVersion.isErr()) throw attrSchemaVersion.error;
|
|
139
|
+
applyAttrSchemaMigrations(collaborationDocument, collaboration.yXmlFragment, attrSchemaVersion.value);
|
|
140
|
+
let { doc } = collaborationModules.yProseMirror.initProseMirrorDoc(collaboration.yXmlFragment, activeSchema);
|
|
138
141
|
const collaborationContract = readYjsParagraphSourceContract(collaborationDocument);
|
|
139
142
|
const localContract = proseDocumentParagraphSourceContract(localDoc);
|
|
140
143
|
if (localContract && collaborationContract !== localContract) panic("The collaboration state belongs to a different paragraph-property source.");
|
|
@@ -119,7 +119,8 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
119
119
|
const flowOpts = {
|
|
120
120
|
pageContentHeight,
|
|
121
121
|
fontAlternates,
|
|
122
|
-
...styles ? { styles } : {}
|
|
122
|
+
...styles ? { styles } : {},
|
|
123
|
+
...document === null ? {} : { defaultSize: 10 }
|
|
123
124
|
};
|
|
124
125
|
if (_theme !== void 0) flowOpts.theme = _theme;
|
|
125
126
|
if (defaultTabStop !== void 0) flowOpts.defaultTabStopTwips = defaultTabStop;
|
|
@@ -188,6 +189,7 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
188
189
|
const hfMeasureBlocks = (hfBlocks, hfWidth) => measureBlocks(hfBlocks, hfWidth, void 0, void 0, buildHeaderFooterFieldValues(hfBlocks, pageCount, hfClock, fieldInputs), { allowEndTabOverflow: true });
|
|
189
190
|
return {
|
|
190
191
|
...flowOpts.styles ? { styles: flowOpts.styles } : {},
|
|
192
|
+
...flowOpts.defaultSize === void 0 ? {} : { defaultSize: flowOpts.defaultSize },
|
|
191
193
|
..._theme !== void 0 ? { theme: _theme } : {},
|
|
192
194
|
fontAlternates,
|
|
193
195
|
measureBlocks: hfMeasureBlocks,
|
|
@@ -288,7 +290,8 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
288
290
|
marginBottom: blockMeasureInputs.physicalPageGeometry.marginBottoms
|
|
289
291
|
},
|
|
290
292
|
columnIndex: blockMeasureInputs.columnIndices,
|
|
291
|
-
columnCount: blockMeasureInputs.columnCounts
|
|
293
|
+
columnCount: blockMeasureInputs.columnCounts,
|
|
294
|
+
sectionAdvances: blockMeasureInputs.sectionAdvances
|
|
292
295
|
});
|
|
293
296
|
newBlocks = resolveEffectiveParagraphSpacingTree(newBlocks);
|
|
294
297
|
outcome.blocks = newBlocks;
|
|
@@ -338,6 +341,7 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
338
341
|
footnoteContentMap = buildFootnoteContentMap(documentFootnotes, footnoteRefs, contentWidth, (() => {
|
|
339
342
|
const footnoteOptions = { measureBlocks };
|
|
340
343
|
if (flowOpts.styles) footnoteOptions.styles = flowOpts.styles;
|
|
344
|
+
if (flowOpts.defaultSize !== void 0) footnoteOptions.defaultSize = flowOpts.defaultSize;
|
|
341
345
|
if (_theme !== void 0) footnoteOptions.theme = _theme;
|
|
342
346
|
footnoteOptions.fontAlternates = fontAlternates;
|
|
343
347
|
if (defaultTabStop !== void 0) footnoteOptions.defaultTabStopTwips = defaultTabStop;
|
|
@@ -416,7 +420,8 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
416
420
|
marginBottom: blockMeasureInputs.physicalPageGeometry.marginBottoms
|
|
417
421
|
},
|
|
418
422
|
columnIndex: blockMeasureInputs.columnIndices,
|
|
419
|
-
columnCount: blockMeasureInputs.columnCounts
|
|
423
|
+
columnCount: blockMeasureInputs.columnCounts,
|
|
424
|
+
sectionAdvances: blockMeasureInputs.sectionAdvances
|
|
420
425
|
}, values);
|
|
421
426
|
relayoutWithCurrentMeasures(layoutOptsUsed);
|
|
422
427
|
pendingArtifacts = {
|
|
@@ -11,7 +11,21 @@ import { blockRegion, createPageComposer } from "./regions.js";
|
|
|
11
11
|
import { paintTableFragment } from "./tablePrimitives.js";
|
|
12
12
|
import { paintTextBoxFragment } from "./textBoxPrimitives.js";
|
|
13
13
|
import { UNSUPPORTED_CONSTRUCT, UnsupportedCollector } from "./unsupported.js";
|
|
14
|
+
import { headingLevelOf } from "@stll/docx-core/model";
|
|
14
15
|
//#region src/display-list/build/buildDisplayList.ts
|
|
16
|
+
/**
|
|
17
|
+
* `Layout` + `BlockLookup` → `DisplayList`.
|
|
18
|
+
*
|
|
19
|
+
* The single source of truth for painting. Two backends consume the result and
|
|
20
|
+
* neither may look behind it, so anything missing here is painted nowhere.
|
|
21
|
+
*
|
|
22
|
+
* Purity is a hard requirement, not a preference: no clock, no randomness, no
|
|
23
|
+
* `globalThis.document`. The font and image tables intern in first-use page
|
|
24
|
+
* order, and author colours are assigned per build, so two builds of one layout
|
|
25
|
+
* are deeply equal. The one impure edge is the measure provider, which the
|
|
26
|
+
* composition root installs and which is deterministic for a given font set;
|
|
27
|
+
* that is the same seam line breaking already ran through, which is the point.
|
|
28
|
+
*/
|
|
15
29
|
/** Document-wide gaps are attributed to the first page, the only one certain to exist. */
|
|
16
30
|
const FIRST_PAGE_INDEX = 0;
|
|
17
31
|
/**
|
|
@@ -60,6 +74,11 @@ const paragraphTextOf = (block) => block.runs.map((run) => run.kind === "text" ?
|
|
|
60
74
|
* Resolve everything that needs the whole document before any page is painted:
|
|
61
75
|
* where each bookmark lands (a `#name` hyperlink cannot become a page target
|
|
62
76
|
* until then) and the heading outline.
|
|
77
|
+
*
|
|
78
|
+
* The outline takes the levels {@link headingLevelOf} names and no others:
|
|
79
|
+
* `w:outlineLvl` 9 is the reserved body-text value, not a tenth level, and a
|
|
80
|
+
* `TOC Heading` paragraph carrying it would otherwise become a PDF bookmark
|
|
81
|
+
* nested nine deep.
|
|
63
82
|
*/
|
|
64
83
|
const collectDocumentTargets = (layout, blockLookup) => {
|
|
65
84
|
const bookmarkTargets = /* @__PURE__ */ new Map();
|
|
@@ -73,7 +92,7 @@ const collectDocumentTargets = (layout, blockLookup) => {
|
|
|
73
92
|
pageIndex,
|
|
74
93
|
yPx: fragment.y
|
|
75
94
|
});
|
|
76
|
-
const level = block.attrs?.outlineLevel;
|
|
95
|
+
const level = headingLevelOf(block.attrs?.outlineLevel);
|
|
77
96
|
if (level !== void 0 && fragment.continuesFromPrev !== true) {
|
|
78
97
|
const title = paragraphTextOf(block);
|
|
79
98
|
if (title.length > 0) outline.push({
|
|
@@ -15,7 +15,7 @@ declare class ImageTable {
|
|
|
15
15
|
failureFor(src: string): string | undefined;
|
|
16
16
|
snapshot(): readonly DisplayImageSource[];
|
|
17
17
|
}
|
|
18
|
-
type ImageVisualSource = Pick<ImageBlock, "src" | "opacity" | "cropTop" | "cropRight" | "cropBottom" | "cropLeft" | "borderWidth" | "borderColor" | "borderStyle" | "transform">;
|
|
18
|
+
type ImageVisualSource = Pick<ImageBlock, "src" | "preview" | "opacity" | "brightness" | "contrast" | "cropTop" | "cropRight" | "cropBottom" | "cropLeft" | "borderWidth" | "borderColor" | "borderStyle" | "transform">;
|
|
19
19
|
type PaintImageOptions = {
|
|
20
20
|
readonly source: ImageVisualSource;
|
|
21
21
|
readonly rect: DisplayRect;
|
|
@@ -24,9 +24,9 @@ type PaintImageOptions = {
|
|
|
24
24
|
readonly label: string;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
* The primitives one picture draws: the bitmap
|
|
28
|
-
* source asks) followed by its border. Empty when the
|
|
29
|
-
* the reason already reported.
|
|
27
|
+
* The primitives one picture draws: the bitmap or the drawn preview (rotated
|
|
28
|
+
* and/or washed as the source asks) followed by its border. Empty when the
|
|
29
|
+
* bytes are unusable, with the reason already reported.
|
|
30
30
|
*/
|
|
31
31
|
declare const paintImage: ({ source, rect, context, label }: PaintImageOptions) => readonly DisplayPrimitive[];
|
|
32
32
|
/** An anchored or block image fragment placed by the layout engine. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseRotationDegrees } from "../../utils/rotationBoundingBox.js";
|
|
2
2
|
import { sanitizeImageSrc } from "../../utils/sanitizeImageSrc.js";
|
|
3
|
+
import { paintPreview } from "./previewPrimitives.js";
|
|
3
4
|
import { resolveBorderStroke } from "./strokes.js";
|
|
4
5
|
import { UNSUPPORTED_CONSTRUCT } from "./unsupported.js";
|
|
5
6
|
import { Result } from "better-result";
|
|
@@ -194,35 +195,54 @@ const cropOf = (source) => {
|
|
|
194
195
|
b
|
|
195
196
|
};
|
|
196
197
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
const opacityOf = (source) => source.opacity == null ? 1 : Math.min(1, Math.max(0, source.opacity));
|
|
199
|
+
const withOpacity = (children, opacity) => opacity === 1 || children.length === 0 ? children : [{
|
|
200
|
+
kind: "opacityGroup",
|
|
201
|
+
opacity,
|
|
202
|
+
children
|
|
203
|
+
}];
|
|
204
|
+
/** The bitmap one picture draws, or nothing, with the reason already reported. */
|
|
205
|
+
const paintBitmap = ({ source, rect, context, label }) => {
|
|
204
206
|
const ref = context.images.intern(source.src);
|
|
205
207
|
if (ref === void 0) {
|
|
206
208
|
const reason = context.images.failureFor(source.src) ?? "image could not be decoded";
|
|
207
209
|
const construct = reason.includes("not PNG or JPEG") ? UNSUPPORTED_CONSTRUCT.imageFormat : UNSUPPORTED_CONSTRUCT.imageSource;
|
|
208
210
|
context.unsupported.report(construct, context.pageIndex, `${label}: ${reason}`);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
const crop = cropOf(source);
|
|
214
|
+
return [{
|
|
215
|
+
kind: "image",
|
|
216
|
+
image: ref,
|
|
217
|
+
rect,
|
|
218
|
+
...crop === void 0 ? {} : { crop },
|
|
219
|
+
opacity: opacityOf(source),
|
|
220
|
+
...source.brightness == null ? {} : { brightness: source.brightness },
|
|
221
|
+
...source.contrast == null ? {} : { contrast: source.contrast }
|
|
222
|
+
}];
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* The primitives one picture draws: the bitmap or the drawn preview (rotated
|
|
226
|
+
* and/or washed as the source asks) followed by its border. Empty when the
|
|
227
|
+
* bytes are unusable, with the reason already reported.
|
|
228
|
+
*/
|
|
229
|
+
const paintImage = ({ source, rect, context, label }) => {
|
|
230
|
+
const primitives = [];
|
|
231
|
+
const drawn = source.preview === void 0 ? paintBitmap({
|
|
232
|
+
source,
|
|
233
|
+
rect,
|
|
234
|
+
context,
|
|
235
|
+
label
|
|
236
|
+
}) : withOpacity(paintPreview(source.preview, rect), opacityOf(source));
|
|
237
|
+
if (drawn.length > 0) {
|
|
218
238
|
const degrees = parseRotationDegrees(source.transform);
|
|
219
|
-
if (degrees === 0) primitives.push(
|
|
239
|
+
if (degrees === 0) primitives.push(...drawn);
|
|
220
240
|
else primitives.push({
|
|
221
241
|
kind: "rotateGroup",
|
|
222
242
|
degrees,
|
|
223
243
|
originXPx: rect.xPx + rect.widthPx / 2,
|
|
224
244
|
originYPx: rect.yPx + rect.heightPx / 2,
|
|
225
|
-
children:
|
|
245
|
+
children: drawn
|
|
226
246
|
});
|
|
227
247
|
}
|
|
228
248
|
if (source.borderWidth != null && source.borderWidth > 0) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cssBorderStyle } from "../../utils/borderCss.js";
|
|
1
2
|
import { resolveColor } from "../../utils/colorResolver.js";
|
|
2
3
|
import { eighthsToPixels, pointsToPixels } from "../../utils/units.js";
|
|
3
4
|
import { resolveBorderStroke } from "./strokes.js";
|
|
@@ -25,7 +26,7 @@ const strokeOf = (border, theme, context) => {
|
|
|
25
26
|
if (!border) return;
|
|
26
27
|
const { stroke, unresolvedColor } = resolveBorderStroke({
|
|
27
28
|
width: border.size === void 0 || border.size === 0 ? HAIRLINE_WIDTH_PX : eighthsToPixels(border.size),
|
|
28
|
-
style: border.style,
|
|
29
|
+
style: cssBorderStyle(border.style),
|
|
29
30
|
color: resolveColor(border.color, theme)
|
|
30
31
|
});
|
|
31
32
|
if (unresolvedColor !== void 0) context.unsupported.report(UNSUPPORTED_CONSTRUCT.unresolvedColor, context.pageIndex, `page border colour ${unresolvedColor}`);
|