@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
|
@@ -6,17 +6,17 @@ import { countCompressibleSpaces, toPaintedText } from "../../layout-engine/meas
|
|
|
6
6
|
import { isFloatingImageRun } from "../../layout-engine/types.js";
|
|
7
7
|
import { resolveParagraphBorderHorizontalOutsets } from "../../layout-painter/borderStroke.js";
|
|
8
8
|
import { getAutomaticTextColorForBackground } from "../../layout-painter/documentColors.js";
|
|
9
|
-
import { getLeaderChar, getRenderableTextColor, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap } from "../../layout-painter/renderParagraph.js";
|
|
9
|
+
import { UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableTextColor, paragraphHasTrackedChanges, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap } from "../../layout-painter/renderParagraph.js";
|
|
10
10
|
import { getHorizontalScaleFactor } from "../../utils/horizontalScale.js";
|
|
11
11
|
import { resolvePhysicalParagraphInlineLayout } from "../../utils/paragraphInlineLayout.js";
|
|
12
12
|
import { inlineImageBoundingBox } from "../../utils/rotationBoundingBox.js";
|
|
13
13
|
import { sanitizeExternalUrl } from "../../utils/urlSecurity.js";
|
|
14
|
-
import { HIT_REGION_KINDS } from "../primitives.js";
|
|
14
|
+
import { HIT_REGION_KINDS, strokeCrossExtentPx } from "../primitives.js";
|
|
15
15
|
import { trackedChangeColor } from "./buildContext.js";
|
|
16
16
|
import { DOC_CANVAS_TEXT, parseDisplayColor } from "./colors.js";
|
|
17
17
|
import { buildGlyphs, glyphRunText } from "./glyphs.js";
|
|
18
18
|
import { paintImage } from "./imagePrimitives.js";
|
|
19
|
-
import {
|
|
19
|
+
import { resolveBorderStroke, underlinePattern, underlineStrokeCount, underlineWeight } from "./strokes.js";
|
|
20
20
|
import { strikethroughCenterYPx, underlineCenterYPx, underlineThicknessPx } from "./textDecorations.js";
|
|
21
21
|
import { UNSUPPORTED_CONSTRUCT } from "./unsupported.js";
|
|
22
22
|
//#region src/display-list/build/paragraphPrimitives.ts
|
|
@@ -66,6 +66,14 @@ const SUBSCRIPT_DROP_RATIO = .2;
|
|
|
66
66
|
const WIDTH_EPSILON_PX = .5;
|
|
67
67
|
/** `w:pBdr` bar borders hang this far left of the text (`renderParagraph.ts:3072`). */
|
|
68
68
|
const BAR_BORDER_OFFSET_PX = 8;
|
|
69
|
+
/** Word's review indicator sits in the page margin outside the paragraph. */
|
|
70
|
+
const REVIEW_BAR_OFFSET_PX = 24;
|
|
71
|
+
const REVIEW_BAR_COLOR = {
|
|
72
|
+
r: 0,
|
|
73
|
+
g: 0,
|
|
74
|
+
b: 0,
|
|
75
|
+
a: 1
|
|
76
|
+
};
|
|
69
77
|
const AUTOMATIC_TEXT_COLOR_VALUES = /* @__PURE__ */ new Set(["auto", "windowtext"]);
|
|
70
78
|
/** `w:color w:val="auto"` and its `windowtext` spelling, normalized as the painter normalizes them. */
|
|
71
79
|
const isAutomaticTextColor = (color) => AUTOMATIC_TEXT_COLOR_VALUES.has(color.trim().toLowerCase().replace(/^#/u, ""));
|
|
@@ -151,6 +159,18 @@ const paintParagraphChrome = ({ fragment, block, context, prevBorders, nextBorde
|
|
|
151
159
|
});
|
|
152
160
|
else context.unsupported.report(UNSUPPORTED_CONSTRUCT.unresolvedColor, context.pageIndex, `paragraph shading ${shading}`);
|
|
153
161
|
}
|
|
162
|
+
if (paragraphHasTrackedChanges(block)) primitives.push({
|
|
163
|
+
kind: "line",
|
|
164
|
+
x1Px: fragment.x - REVIEW_BAR_OFFSET_PX,
|
|
165
|
+
y1Px: fragment.y,
|
|
166
|
+
x2Px: fragment.x - REVIEW_BAR_OFFSET_PX,
|
|
167
|
+
y2Px: fragment.y + fragment.height,
|
|
168
|
+
stroke: {
|
|
169
|
+
color: REVIEW_BAR_COLOR,
|
|
170
|
+
thicknessPx: 2,
|
|
171
|
+
pattern: "solid"
|
|
172
|
+
}
|
|
173
|
+
});
|
|
154
174
|
const borders = block.attrs?.borders;
|
|
155
175
|
if (!borders) return primitives;
|
|
156
176
|
const topBorder = bordersFormGroup(prevBorders, borders) ? borders.between : borders.top;
|
|
@@ -278,6 +298,23 @@ const modelRangeOf = (run, context) => run.pmStart === void 0 || run.pmEnd === v
|
|
|
278
298
|
story: context.story
|
|
279
299
|
};
|
|
280
300
|
/**
|
|
301
|
+
* The base direction one run's glyphs are laid out in.
|
|
302
|
+
*
|
|
303
|
+
* A bidirectional wrapper the author wrote around the run states it, and is
|
|
304
|
+
* nearer than the paragraph's own base direction: an override (`w:bdo`) lays
|
|
305
|
+
* every character out that way, and an embedding (`w:dir`) opens a level in
|
|
306
|
+
* that direction. A wrapper with no `w:val` states nothing, and the paragraph
|
|
307
|
+
* decides as before.
|
|
308
|
+
*/
|
|
309
|
+
const runGlyphDirection = (run, paragraphIsRtl) => run.bidiWrapper?.direction ?? (paragraphIsRtl ? "rtl" : "ltr");
|
|
310
|
+
/**
|
|
311
|
+
* The wrapper's control, for the backend that resolves the order itself.
|
|
312
|
+
*
|
|
313
|
+
* The direction alone does not separate the two: an override forces the
|
|
314
|
+
* order, an embedding leaves the algorithm to resolve within it.
|
|
315
|
+
*/
|
|
316
|
+
const runUnicodeBidi = (run) => run.bidiWrapper === void 0 ? void 0 : UNICODE_BIDI_BY_WRAPPER_CONTROL[run.bidiWrapper.control];
|
|
317
|
+
/**
|
|
281
318
|
* One `glyphRun` plus everything painted around it: the run's background rect
|
|
282
319
|
* first, then the glyphs, then the decorations whose geometry CSS would have
|
|
283
320
|
* derived from the font.
|
|
@@ -342,6 +379,7 @@ const emitGlyphRun = ({ sink, context, run, glyphs, style, paintXPx, baselineYPx
|
|
|
342
379
|
thicknessPx: 1,
|
|
343
380
|
pattern: "solid"
|
|
344
381
|
} : void 0;
|
|
382
|
+
const unicodeBidi = runUnicodeBidi(run);
|
|
345
383
|
sink.glyphs.push({
|
|
346
384
|
kind: "glyphRun",
|
|
347
385
|
font,
|
|
@@ -350,7 +388,8 @@ const emitGlyphRun = ({ sink, context, run, glyphs, style, paintXPx, baselineYPx
|
|
|
350
388
|
xPx: paintXPx,
|
|
351
389
|
baselineYPx: runBaselineYPx,
|
|
352
390
|
...glyphRunText(glyphs),
|
|
353
|
-
direction: isRtl
|
|
391
|
+
direction: runGlyphDirection(run, isRtl),
|
|
392
|
+
...unicodeBidi === void 0 ? {} : { unicodeBidi },
|
|
354
393
|
...stroke === void 0 ? {} : { stroke },
|
|
355
394
|
...pmRange === void 0 ? {} : { pmRange },
|
|
356
395
|
...collapsedEdge === void 0 ? {} : { collapsedEdge }
|
|
@@ -361,7 +400,7 @@ const emitGlyphRun = ({ sink, context, run, glyphs, style, paintXPx, baselineYPx
|
|
|
361
400
|
color,
|
|
362
401
|
context,
|
|
363
402
|
xPx: paintXPx,
|
|
364
|
-
|
|
403
|
+
glyphs,
|
|
365
404
|
baselineYPx: runBaselineYPx,
|
|
366
405
|
fontSizePx
|
|
367
406
|
});
|
|
@@ -380,23 +419,83 @@ const emitGlyphRun = ({ sink, context, run, glyphs, style, paintXPx, baselineYPx
|
|
|
380
419
|
}
|
|
381
420
|
reportRunEffects(run, context);
|
|
382
421
|
};
|
|
383
|
-
|
|
422
|
+
/**
|
|
423
|
+
* The ordinary space, the only character `words` breaks an underline at.
|
|
424
|
+
*
|
|
425
|
+
* It is the same character justification stretches (`countCompressibleSpaces`):
|
|
426
|
+
* a no-break space holds two words together, so Word underlines through it.
|
|
427
|
+
*/
|
|
428
|
+
const WORD_SEPARATOR = " ";
|
|
429
|
+
/**
|
|
430
|
+
* Where an underline is drawn under a run: the whole run, or one span per word.
|
|
431
|
+
*
|
|
432
|
+
* Word's `words` member underlines the words and not the gaps between them.
|
|
433
|
+
* CSS cannot express that, so the editor underlines the run whole
|
|
434
|
+
* (`text-decoration-skip-ink` skips descender ink, and
|
|
435
|
+
* `text-decoration-skip: spaces` never shipped). A display list carries one
|
|
436
|
+
* advance per code point, so here the member is exact rather than approximated.
|
|
437
|
+
*/
|
|
438
|
+
const underlineSpans = (glyphs, xPx, perWord) => {
|
|
439
|
+
if (!perWord) return [{
|
|
440
|
+
xPx,
|
|
441
|
+
widthPx: glyphs.widthPx
|
|
442
|
+
}];
|
|
443
|
+
const spans = [];
|
|
444
|
+
let cursorPx = xPx;
|
|
445
|
+
let wordStartPx;
|
|
446
|
+
let index = 0;
|
|
447
|
+
const pushWord = (endPx) => {
|
|
448
|
+
if (wordStartPx !== void 0 && endPx > wordStartPx) spans.push({
|
|
449
|
+
xPx: wordStartPx,
|
|
450
|
+
widthPx: endPx - wordStartPx
|
|
451
|
+
});
|
|
452
|
+
wordStartPx = void 0;
|
|
453
|
+
};
|
|
454
|
+
for (const char of glyphs.text) {
|
|
455
|
+
const advancePx = glyphs.advancesPx[index] ?? 0;
|
|
456
|
+
index += 1;
|
|
457
|
+
if (char === WORD_SEPARATOR) pushWord(cursorPx);
|
|
458
|
+
else if (wordStartPx === void 0) wordStartPx = cursorPx;
|
|
459
|
+
cursorPx += advancePx;
|
|
460
|
+
}
|
|
461
|
+
pushWord(cursorPx);
|
|
462
|
+
return spans;
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* Where each stroke of a stacked decoration sits, relative to the path.
|
|
466
|
+
*
|
|
467
|
+
* One stroke sits on the path. Two are pushed apart by the band each occupies
|
|
468
|
+
* plus the gap a `double` stroke leaves between its rules, so `wavyDouble`'s
|
|
469
|
+
* waves clear each other by the same margin and stay centred on the underline.
|
|
470
|
+
*/
|
|
471
|
+
const stackedStrokeOffsetsPx = (stroke, count) => {
|
|
472
|
+
if (count < 2) return [0];
|
|
473
|
+
const separationPx = strokeCrossExtentPx(stroke) + 1 * stroke.thicknessPx;
|
|
474
|
+
return Array.from({ length: count }, (_, index) => (index - (count - 1) / 2) * separationPx);
|
|
475
|
+
};
|
|
476
|
+
const emitDecorations = ({ sink, run, color, context, xPx, glyphs, baselineYPx, fontSizePx }) => {
|
|
477
|
+
const { widthPx } = glyphs;
|
|
384
478
|
if (widthPx <= 0) return;
|
|
385
|
-
const
|
|
479
|
+
const plainThicknessPx = underlineThicknessPx(fontSizePx);
|
|
386
480
|
const trackedColor = run.isInsertion || run.isDeletion ? trackedChangeColor(context.authorColors, run.changeAuthor, run.isSuggestion) : void 0;
|
|
387
481
|
if (Boolean(run.underline) && !isNoteReferenceRun(run) || run.isInsertion) {
|
|
388
482
|
const authored = typeof run.underline === "object" ? run.underline : void 0;
|
|
389
483
|
const authoredColor = authored?.color === void 0 ? void 0 : parseDisplayColor(authored.color);
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
484
|
+
const style = run.isSuggestion ? void 0 : authored?.style;
|
|
485
|
+
const pattern = run.isSuggestion ? "dotted" : underlinePattern(style);
|
|
486
|
+
if (pattern !== "none") {
|
|
487
|
+
const stroke = {
|
|
488
|
+
color: trackedColor ?? authoredColor ?? color,
|
|
489
|
+
thicknessPx: plainThicknessPx * underlineWeight(style),
|
|
490
|
+
pattern
|
|
491
|
+
};
|
|
492
|
+
const centerYPx = underlineCenterYPx(baselineYPx, fontSizePx);
|
|
493
|
+
for (const span of underlineSpans(glyphs, xPx, style === "words")) for (const offsetPx of stackedStrokeOffsetsPx(stroke, underlineStrokeCount(style))) sink.decorations.push(horizontalLine(span.xPx, span.widthPx, centerYPx + offsetPx, stroke));
|
|
494
|
+
}
|
|
396
495
|
}
|
|
397
496
|
if (run.strike || run.isDeletion) sink.decorations.push(horizontalLine(xPx, widthPx, strikethroughCenterYPx(baselineYPx, fontSizePx), {
|
|
398
497
|
color: trackedColor ?? color,
|
|
399
|
-
thicknessPx,
|
|
498
|
+
thicknessPx: plainThicknessPx,
|
|
400
499
|
pattern: run.isSuggestion ? "dotted" : "solid"
|
|
401
500
|
}));
|
|
402
501
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { DisplayPrimitive, DisplayRect } from "../types.js";
|
|
3
|
+
//#region src/display-list/build/previewPrimitives.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The marks a descriptor makes inside `box`, back to front: the backdrop, then
|
|
6
|
+
* each shape in the order the drawing lists them.
|
|
7
|
+
*/
|
|
8
|
+
declare const paintPreview: (descriptor: document_d_exports.PreviewDescriptor, box: DisplayRect) => readonly DisplayPrimitive[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { paintPreview };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { parseDisplayColor } from "./colors.js";
|
|
2
|
+
import { panic } from "better-result";
|
|
3
|
+
//#region src/display-list/build/previewPrimitives.ts
|
|
4
|
+
/**
|
|
5
|
+
* The primitives a preview descriptor draws.
|
|
6
|
+
*
|
|
7
|
+
* A drawing with no image data used to be given one: a megapixel PNG built the
|
|
8
|
+
* moment something was about to paint it, which the DOM backend showed as an
|
|
9
|
+
* `<img>` and the PDF exporter embedded as a bitmap — a photograph of a
|
|
10
|
+
* drawing that is nothing but flat rectangles.
|
|
11
|
+
*
|
|
12
|
+
* The descriptor already holds those rectangles, in the drawing's own
|
|
13
|
+
* coordinate space, and `rect` is a primitive both backends draw natively. So
|
|
14
|
+
* the preview is drawn rather than sampled: the extent maps affinely onto the
|
|
15
|
+
* image's box, every shape becomes a filled rectangle inside it, and no raster
|
|
16
|
+
* exists at any point. The DOM backend paints each one as the absolutely
|
|
17
|
+
* positioned div it paints every other `rect` as, and the PDF backend emits
|
|
18
|
+
* `re`/`f` operators, so the drawing stays a drawing at any zoom.
|
|
19
|
+
*/
|
|
20
|
+
/** The flat backdrop a preview is drawn on, behind every shape. */
|
|
21
|
+
const PREVIEW_BACKGROUND = {
|
|
22
|
+
r: 238,
|
|
23
|
+
g: 242,
|
|
24
|
+
b: 247,
|
|
25
|
+
a: 1
|
|
26
|
+
};
|
|
27
|
+
/** A shape whose `a:srgbClr` was missing or is not a colour. */
|
|
28
|
+
const PREVIEW_SHAPE_FILL = {
|
|
29
|
+
r: 232,
|
|
30
|
+
g: 238,
|
|
31
|
+
b: 247,
|
|
32
|
+
a: 1
|
|
33
|
+
};
|
|
34
|
+
const clampFraction = (value) => Math.min(1, Math.max(0, value));
|
|
35
|
+
/**
|
|
36
|
+
* One shape's box, as the fraction of the extent it covers applied to the
|
|
37
|
+
* image's box. `undefined` for a shape the box keeps nothing of, which is the
|
|
38
|
+
* clip the raster did by clamping to its own bounds.
|
|
39
|
+
*/
|
|
40
|
+
const shapeRect = ({ shape, extent, box }) => {
|
|
41
|
+
const left = clampFraction(shape.x / extent.width);
|
|
42
|
+
const right = clampFraction((shape.x + shape.width) / extent.width);
|
|
43
|
+
const top = clampFraction(shape.y / extent.height);
|
|
44
|
+
const bottom = clampFraction((shape.y + shape.height) / extent.height);
|
|
45
|
+
if (right <= left || bottom <= top) return;
|
|
46
|
+
return {
|
|
47
|
+
xPx: box.xPx + left * box.widthPx,
|
|
48
|
+
yPx: box.yPx + top * box.heightPx,
|
|
49
|
+
widthPx: (right - left) * box.widthPx,
|
|
50
|
+
heightPx: (bottom - top) * box.heightPx
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The marks a descriptor makes inside `box`, back to front: the backdrop, then
|
|
55
|
+
* each shape in the order the drawing lists them.
|
|
56
|
+
*/
|
|
57
|
+
const paintPreview = (descriptor, box) => {
|
|
58
|
+
switch (descriptor.kind) {
|
|
59
|
+
case "diagram": {
|
|
60
|
+
const primitives = [{
|
|
61
|
+
kind: "rect",
|
|
62
|
+
rect: box,
|
|
63
|
+
fill: PREVIEW_BACKGROUND
|
|
64
|
+
}];
|
|
65
|
+
const { extent } = descriptor;
|
|
66
|
+
if (!(extent.width > 0 && extent.height > 0)) return primitives;
|
|
67
|
+
for (const shape of descriptor.shapes) {
|
|
68
|
+
const rect = shapeRect({
|
|
69
|
+
shape,
|
|
70
|
+
extent,
|
|
71
|
+
box
|
|
72
|
+
});
|
|
73
|
+
if (rect === void 0) continue;
|
|
74
|
+
primitives.push({
|
|
75
|
+
kind: "rect",
|
|
76
|
+
rect,
|
|
77
|
+
fill: parseDisplayColor(shape.color) ?? PREVIEW_SHAPE_FILL
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return primitives;
|
|
81
|
+
}
|
|
82
|
+
default: {
|
|
83
|
+
const unreachable = descriptor.kind;
|
|
84
|
+
return panic(`unhandled preview kind: ${String(unreachable)}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
export { paintPreview };
|
|
@@ -1,19 +1,188 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CssBorderStyle } from "../../utils/borderCss.js";
|
|
2
2
|
import { DisplayStroke, DisplayStrokePattern } from "../types.js";
|
|
3
|
+
import { PresetLineDashVal, UnderlineStyle } from "@stll/docx-core/model";
|
|
3
4
|
//#region src/display-list/build/strokes.d.ts
|
|
4
|
-
|
|
5
|
+
/** A pattern, or the absence of a line: an edge that paints nothing. */
|
|
6
|
+
type StrokePattern = DisplayStrokePattern | "none";
|
|
7
|
+
type BorderInput = {
|
|
8
|
+
color?: string | undefined;
|
|
9
|
+
style?: CssBorderStyle | undefined;
|
|
10
|
+
width?: number | undefined;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Every CSS `border-style` folio paints, as a display-list pattern.
|
|
14
|
+
*
|
|
15
|
+
* The bevelled keywords have no display-list pattern, and Word draws
|
|
16
|
+
* `threeDEmboss`/`threeDEngrave` as a plain line where the shading is
|
|
17
|
+
* unavailable, so they stroke solid.
|
|
18
|
+
*/
|
|
19
|
+
declare const CSS_BORDER_STROKE_PATTERNS: {
|
|
20
|
+
readonly none: "none";
|
|
21
|
+
readonly solid: "solid";
|
|
22
|
+
readonly double: "double";
|
|
23
|
+
readonly dotted: "dotted";
|
|
24
|
+
readonly dashed: "dashed";
|
|
25
|
+
readonly groove: "solid";
|
|
26
|
+
readonly ridge: "solid";
|
|
27
|
+
readonly inset: "solid";
|
|
28
|
+
readonly outset: "solid";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Every `ST_PresetLineDashVal` member, as a display-list pattern.
|
|
32
|
+
*
|
|
33
|
+
* DrawingML distinguishes dash length (`lgDash`) and the system patterns
|
|
34
|
+
* (`sysDash`) from the plain ones; a display list has three periodic patterns,
|
|
35
|
+
* so the distinction collapses to dotted or dashed. It collapses here, once,
|
|
36
|
+
* rather than at whichever consumer happened to know the spelling.
|
|
37
|
+
*/
|
|
38
|
+
declare const PRESET_DASH_STROKE_PATTERNS: {
|
|
39
|
+
readonly solid: "solid";
|
|
40
|
+
readonly dot: "dotted";
|
|
41
|
+
readonly dash: "dashed";
|
|
42
|
+
readonly lgDash: "dashed";
|
|
43
|
+
readonly dashDot: "dashed";
|
|
44
|
+
readonly lgDashDot: "dashed";
|
|
45
|
+
readonly lgDashDotDot: "dashed";
|
|
46
|
+
readonly sysDash: "dashed";
|
|
47
|
+
readonly sysDot: "dotted";
|
|
48
|
+
readonly sysDashDot: "dashed";
|
|
49
|
+
readonly sysDashDotDot: "dashed";
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Every `ST_Underline` member the model carries, one row per member.
|
|
53
|
+
*
|
|
54
|
+
* The three fields are one decision and belong on one line: `wavyDouble` is
|
|
55
|
+
* Word's two waves, which is the `wavy` pattern drawn twice rather than the
|
|
56
|
+
* `double` pattern, so a reader who has the pattern without the count has half
|
|
57
|
+
* the member. `double` is one stroke, because the display list's `double`
|
|
58
|
+
* pattern already carries the second rule and the gap between them. CSS can
|
|
59
|
+
* draw neither two waves nor `words`, so the editor approximates them; the page
|
|
60
|
+
* and the PDF do not have to.
|
|
61
|
+
*
|
|
62
|
+
* Word draws `thick` and the seven `*Heavy` members at twice the rule the font
|
|
63
|
+
* asks for, and the rest at the plain rule. Without the weight the display list
|
|
64
|
+
* strokes every member at the plain thickness, so `dottedHeavy` and `dotted`
|
|
65
|
+
* come out as the same line on the page and in the PDF while the editor draws
|
|
66
|
+
* them apart. The DOM spells this same weight as a
|
|
67
|
+
* `text-decoration-thickness` length (`utils/formatToStyle.ts`), so which
|
|
68
|
+
* members are heavy is decided here and nowhere else.
|
|
69
|
+
*
|
|
70
|
+
* `none` states no decoration: a run whose underline says so paints nothing,
|
|
71
|
+
* and its weight and stroke count are the plain ones by default rather than by
|
|
72
|
+
* decision.
|
|
73
|
+
*/
|
|
74
|
+
declare const UNDERLINE_STROKES: {
|
|
75
|
+
readonly none: {
|
|
76
|
+
readonly pattern: "none";
|
|
77
|
+
readonly weight: 1;
|
|
78
|
+
readonly strokes: 1;
|
|
79
|
+
};
|
|
80
|
+
readonly single: {
|
|
81
|
+
readonly pattern: "solid";
|
|
82
|
+
readonly weight: 1;
|
|
83
|
+
readonly strokes: 1;
|
|
84
|
+
};
|
|
85
|
+
readonly words: {
|
|
86
|
+
readonly pattern: "solid";
|
|
87
|
+
readonly weight: 1;
|
|
88
|
+
readonly strokes: 1;
|
|
89
|
+
};
|
|
90
|
+
readonly double: {
|
|
91
|
+
readonly pattern: "double";
|
|
92
|
+
readonly weight: 1;
|
|
93
|
+
readonly strokes: 1;
|
|
94
|
+
};
|
|
95
|
+
readonly thick: {
|
|
96
|
+
readonly pattern: "solid";
|
|
97
|
+
readonly weight: 2;
|
|
98
|
+
readonly strokes: 1;
|
|
99
|
+
};
|
|
100
|
+
readonly dotted: {
|
|
101
|
+
readonly pattern: "dotted";
|
|
102
|
+
readonly weight: 1;
|
|
103
|
+
readonly strokes: 1;
|
|
104
|
+
};
|
|
105
|
+
readonly dottedHeavy: {
|
|
106
|
+
readonly pattern: "dotted";
|
|
107
|
+
readonly weight: 2;
|
|
108
|
+
readonly strokes: 1;
|
|
109
|
+
};
|
|
110
|
+
readonly dash: {
|
|
111
|
+
readonly pattern: "dashed";
|
|
112
|
+
readonly weight: 1;
|
|
113
|
+
readonly strokes: 1;
|
|
114
|
+
};
|
|
115
|
+
readonly dashedHeavy: {
|
|
116
|
+
readonly pattern: "dashed";
|
|
117
|
+
readonly weight: 2;
|
|
118
|
+
readonly strokes: 1;
|
|
119
|
+
};
|
|
120
|
+
readonly dashLong: {
|
|
121
|
+
readonly pattern: "dashed";
|
|
122
|
+
readonly weight: 1;
|
|
123
|
+
readonly strokes: 1;
|
|
124
|
+
};
|
|
125
|
+
readonly dashLongHeavy: {
|
|
126
|
+
readonly pattern: "dashed";
|
|
127
|
+
readonly weight: 2;
|
|
128
|
+
readonly strokes: 1;
|
|
129
|
+
};
|
|
130
|
+
readonly dotDash: {
|
|
131
|
+
readonly pattern: "dashed";
|
|
132
|
+
readonly weight: 1;
|
|
133
|
+
readonly strokes: 1;
|
|
134
|
+
};
|
|
135
|
+
readonly dashDotHeavy: {
|
|
136
|
+
readonly pattern: "dashed";
|
|
137
|
+
readonly weight: 2;
|
|
138
|
+
readonly strokes: 1;
|
|
139
|
+
};
|
|
140
|
+
readonly dotDotDash: {
|
|
141
|
+
readonly pattern: "dashed";
|
|
142
|
+
readonly weight: 1;
|
|
143
|
+
readonly strokes: 1;
|
|
144
|
+
};
|
|
145
|
+
readonly dashDotDotHeavy: {
|
|
146
|
+
readonly pattern: "dashed";
|
|
147
|
+
readonly weight: 2;
|
|
148
|
+
readonly strokes: 1;
|
|
149
|
+
};
|
|
150
|
+
readonly wave: {
|
|
151
|
+
readonly pattern: "wavy";
|
|
152
|
+
readonly weight: 1;
|
|
153
|
+
readonly strokes: 1;
|
|
154
|
+
};
|
|
155
|
+
readonly wavyHeavy: {
|
|
156
|
+
readonly pattern: "wavy";
|
|
157
|
+
readonly weight: 2;
|
|
158
|
+
readonly strokes: 1;
|
|
159
|
+
};
|
|
160
|
+
readonly wavyDouble: {
|
|
161
|
+
readonly pattern: "wavy";
|
|
162
|
+
readonly weight: 1;
|
|
163
|
+
readonly strokes: 2;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
5
166
|
type ResolveStrokeResult = {
|
|
6
167
|
readonly stroke?: DisplayStroke;
|
|
7
168
|
/** The authored colour, when it could not be parsed. Report it, do not paint. */
|
|
8
169
|
readonly unresolvedColor?: string;
|
|
9
170
|
};
|
|
10
171
|
/**
|
|
11
|
-
* Turn an authored border into a paintable stroke. `undefined` stroke means
|
|
12
|
-
* "draw nothing": an explicit `none
|
|
13
|
-
*
|
|
172
|
+
* Turn an authored CSS border into a paintable stroke. `undefined` stroke means
|
|
173
|
+
* "draw nothing": an explicit `none` style, a non-positive width, or a colour
|
|
174
|
+
* this producer cannot resolve.
|
|
14
175
|
*/
|
|
15
176
|
declare const resolveBorderStroke: (border: BorderInput) => ResolveStrokeResult;
|
|
16
|
-
|
|
17
|
-
|
|
177
|
+
type OutlineInput = {
|
|
178
|
+
color?: string;
|
|
179
|
+
dash?: PresetLineDashVal;
|
|
180
|
+
width?: number;
|
|
181
|
+
};
|
|
182
|
+
/** Turn a shape or text-box outline into a paintable stroke. */
|
|
183
|
+
declare const resolveOutlineStroke: (outline: OutlineInput) => ResolveStrokeResult;
|
|
184
|
+
declare const underlinePattern: (style: UnderlineStyle | undefined) => StrokePattern;
|
|
185
|
+
declare const underlineWeight: (style: UnderlineStyle | undefined) => number;
|
|
186
|
+
declare const underlineStrokeCount: (style: UnderlineStyle | undefined) => number;
|
|
18
187
|
//#endregion
|
|
19
|
-
export { ResolveStrokeResult,
|
|
188
|
+
export { CSS_BORDER_STROKE_PATTERNS, PRESET_DASH_STROKE_PATTERNS, ResolveStrokeResult, UNDERLINE_STROKES, resolveBorderStroke, resolveOutlineStroke, underlinePattern, underlineStrokeCount, underlineWeight };
|