@stll/folio-core 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +85 -43
- package/dist/ai-edits/headless.js +2 -2
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +17 -0
- package/dist/content-controls/checkboxDisplay.js +46 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +57 -43
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -18
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +113 -14
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +11 -21
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +76 -0
- package/dist/docx/attributeRemainder.js +111 -0
- package/dist/docx/blockContentParser.d.ts +3 -1
- package/dist/docx/blockContentParser.js +102 -106
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +3 -0
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +56 -39
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +3 -1
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/compatibility.js +56 -41
- package/dist/docx/containerChildren.d.ts +208 -0
- package/dist/docx/containerChildren.gen.d.ts +43 -0
- package/dist/docx/containerChildren.gen.js +263 -0
- package/dist/docx/containerChildren.js +153 -0
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +7 -4
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +66 -9
- package/dist/docx/hyperlinkParser.js +153 -26
- package/dist/docx/imageParser.js +160 -115
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +166 -0
- package/dist/docx/inlineWrapperContent.js +165 -0
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +12 -1
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +111 -0
- package/dist/docx/paraIdAttribute.js +142 -0
- package/dist/docx/paragraphParser.d.ts +10 -25
- package/dist/docx/paragraphParser.js +421 -496
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
- package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +53 -52
- package/dist/docx/parseWarningMessage.js +5 -1
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +96 -0
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +4 -6
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +152 -27
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +55 -19
- package/dist/docx/runParser.js +394 -306
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +241 -238
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +66 -3
- package/dist/docx/selectiveXmlPatch.js +276 -133
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +12 -10
- package/dist/docx/serializer/commentSerializer.js +5 -7
- package/dist/docx/serializer/documentSerializer.js +11 -11
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +10 -9
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +11 -8
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +156 -236
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +134 -75
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +283 -105
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +20 -16
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +13 -8
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +11 -2
- package/dist/docx/tableParser.js +665 -220
- package/dist/docx/textBoxParser.d.ts +28 -3
- package/dist/docx/textBoxParser.js +69 -9
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/unzip.js +5 -4
- package/dist/docx/vmlImageParser.d.ts +30 -5
- package/dist/docx/vmlImageParser.js +91 -32
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +23 -1
- package/dist/docx/xmlParser.js +31 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +12 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +267 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +69 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +10 -3
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +10 -4
- package/dist/layout-painter/renderParagraph.d.ts +14 -1
- package/dist/layout-painter/renderParagraph.js +34 -28
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +12 -4
- package/dist/markdown/renderBlock.js +3 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +34 -6
- package/dist/markdown/renderTable.js +24 -6
- package/dist/markdown/trailers.js +4 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +34 -5
- package/dist/prosemirror/attrs/index.js +639 -48
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +33 -20
- package/dist/prosemirror/commands/image.d.ts +10 -3
- package/dist/prosemirror/commands/image.js +46 -29
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
- package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +801 -411
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +14 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +65 -0
- package/dist/prosemirror/extensions/markRegistry.js +138 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +7 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +92 -0
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +183 -0
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +47 -4
- package/dist/prosemirror/schema/nodes.d.ts +309 -26
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +4 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +31 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
- package/dist/prosemirror/zeroWidthAnchors.js +6 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +27 -1
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +12 -20
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -0
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -50
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { expectInlineWrapperMarkAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { INLINE_WRAPPER_STACK_ATTRIBUTE, parseInlineWrapperStack, serializeInlineWrapperStack } from "../../inlineWrapperStack.js";
|
|
3
|
+
import { createMarkExtension } from "../create.js";
|
|
4
|
+
import { panic } from "better-result";
|
|
5
|
+
//#region src/prosemirror/extensions/marks/InlineWrapperExtension.ts
|
|
6
|
+
/**
|
|
7
|
+
* Inline wrapper mark — the transparent wrappers a leaf sits inside.
|
|
8
|
+
*
|
|
9
|
+
* One mark for every wrapper kind rather than one mark per kind: ProseMirror's
|
|
10
|
+
* mark set is unordered across types, so two marks could not say which wrapper
|
|
11
|
+
* is inside which. The nesting lives in the `stack` attr, outermost first, and
|
|
12
|
+
* the mark excludes itself (ProseMirror's default) because a second one would
|
|
13
|
+
* be a second answer to the same question.
|
|
14
|
+
*
|
|
15
|
+
* `inclusive: false` so typing at the end of a wrapped span does not silently
|
|
16
|
+
* extend the wrapper over text the author wrote outside it.
|
|
17
|
+
*/
|
|
18
|
+
const INLINE_WRAPPER_MARK_NAME = "inlineWrapper";
|
|
19
|
+
/** What a tagged layer's element name is spelled as on the rendered span. */
|
|
20
|
+
const TAGGED_ELEMENT_ATTRIBUTES = {
|
|
21
|
+
smartTag: "data-smart-tag-element",
|
|
22
|
+
customXml: "data-custom-xml-element"
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* How one layer is spelled in HTML.
|
|
26
|
+
*
|
|
27
|
+
* `w:bdo` is `unicode-bidi: bidi-override`, which HTML gives an element of its
|
|
28
|
+
* own; `w:dir` is `unicode-bidi: embed`, which a `dir`-carrying span states.
|
|
29
|
+
* A smart tag and a custom-XML wrapper say nothing about layout, so they are a
|
|
30
|
+
* passthrough `<span>` that names the tagged element for a stylesheet or a
|
|
31
|
+
* host that wants to show it; the stack attribute is what carries them back.
|
|
32
|
+
*/
|
|
33
|
+
const layerElement = (layer, attributes) => {
|
|
34
|
+
switch (layer.kind) {
|
|
35
|
+
case "bidi":
|
|
36
|
+
if (layer.direction !== void 0) attributes["dir"] = layer.direction;
|
|
37
|
+
return [
|
|
38
|
+
layer.control === "override" ? "bdo" : "span",
|
|
39
|
+
attributes,
|
|
40
|
+
0
|
|
41
|
+
];
|
|
42
|
+
case "smartTag":
|
|
43
|
+
case "customXml":
|
|
44
|
+
attributes[TAGGED_ELEMENT_ATTRIBUTES[layer.kind]] = layer.element;
|
|
45
|
+
return [
|
|
46
|
+
"span",
|
|
47
|
+
attributes,
|
|
48
|
+
0
|
|
49
|
+
];
|
|
50
|
+
default: panic(`Unspelled inline wrapper layer: ${JSON.stringify(layer)}`);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const InlineWrapperExtension = createMarkExtension({
|
|
54
|
+
name: INLINE_WRAPPER_MARK_NAME,
|
|
55
|
+
schemaMarkName: INLINE_WRAPPER_MARK_NAME,
|
|
56
|
+
markSpec: {
|
|
57
|
+
attrs: {
|
|
58
|
+
/** Outermost first. `null` is no wrapper, which is the absence of the mark. */
|
|
59
|
+
stack: { default: null } },
|
|
60
|
+
inclusive: false,
|
|
61
|
+
parseDOM: [{
|
|
62
|
+
tag: `[${INLINE_WRAPPER_STACK_ATTRIBUTE}]`,
|
|
63
|
+
getAttrs(dom) {
|
|
64
|
+
const stack = parseInlineWrapperStack(dom.getAttribute(INLINE_WRAPPER_STACK_ATTRIBUTE));
|
|
65
|
+
return stack === null ? false : { stack };
|
|
66
|
+
}
|
|
67
|
+
}],
|
|
68
|
+
toDOM(mark) {
|
|
69
|
+
const { stack } = expectInlineWrapperMarkAttrs(mark);
|
|
70
|
+
const innermost = stack.at(-1);
|
|
71
|
+
if (innermost === void 0) panic("An inline wrapper mark carries at least one layer");
|
|
72
|
+
return layerElement(innermost, { [INLINE_WRAPPER_STACK_ATTRIBUTE]: serializeInlineWrapperStack(stack) });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//#endregion
|
|
77
|
+
export { INLINE_WRAPPER_MARK_NAME, InlineWrapperExtension };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MarkExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/marks/RunIdentityExtension.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Editor-side identity for one authored `w:r`, and the payload that element
|
|
5
|
+
* carried which no formatting mark holds.
|
|
6
|
+
*
|
|
7
|
+
* Ordinary formatting marks cannot tell two adjacent source runs with
|
|
8
|
+
* identical properties apart, so the save leg would fold them into one and
|
|
9
|
+
* discard whichever record it did not keep. This mark is what keeps them
|
|
10
|
+
* apart: it is in `getMarksKey`, so a change of identity is a run boundary,
|
|
11
|
+
* and `joinsOwnedSourceRun` rejoins the leaves a page break cut out of one
|
|
12
|
+
* authored run.
|
|
13
|
+
*
|
|
14
|
+
* `inclusive: false` settles the edges. The interior is settled by the strip
|
|
15
|
+
* below: ProseMirror's stored marks at a position inside a span include every
|
|
16
|
+
* mark of the preceding character, so text typed inside an authored run would
|
|
17
|
+
* otherwise ride that run's `w:rsidR` — a claim about which editing session
|
|
18
|
+
* wrote it. folio cannot register a session (`settings.xml`'s `w:rsids` is
|
|
19
|
+
* copied through on every repack, and no save path mints one), so it must
|
|
20
|
+
* never write a session id it did not read. Typed text becomes its own run
|
|
21
|
+
* with no attributes instead, and `w:rsidRDefault` on the parent `w:p`
|
|
22
|
+
* supplies the session the format itself says such a run belongs to.
|
|
23
|
+
*/
|
|
24
|
+
declare const RunIdentityExtension: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { RunIdentityExtension };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { expectRunIdentityMarkAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { RUN_IDENTITY_ATTRIBUTE, RUN_IDENTITY_MARK_NAME, runIdentityAttrs } from "../../runIdentity.js";
|
|
3
|
+
import { createMarkExtension } from "../create.js";
|
|
4
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
5
|
+
//#region src/prosemirror/extensions/marks/RunIdentityExtension.ts
|
|
6
|
+
/**
|
|
7
|
+
* Editor-side identity for one authored `w:r`, and the payload that element
|
|
8
|
+
* carried which no formatting mark holds.
|
|
9
|
+
*
|
|
10
|
+
* Ordinary formatting marks cannot tell two adjacent source runs with
|
|
11
|
+
* identical properties apart, so the save leg would fold them into one and
|
|
12
|
+
* discard whichever record it did not keep. This mark is what keeps them
|
|
13
|
+
* apart: it is in `getMarksKey`, so a change of identity is a run boundary,
|
|
14
|
+
* and `joinsOwnedSourceRun` rejoins the leaves a page break cut out of one
|
|
15
|
+
* authored run.
|
|
16
|
+
*
|
|
17
|
+
* `inclusive: false` settles the edges. The interior is settled by the strip
|
|
18
|
+
* below: ProseMirror's stored marks at a position inside a span include every
|
|
19
|
+
* mark of the preceding character, so text typed inside an authored run would
|
|
20
|
+
* otherwise ride that run's `w:rsidR` — a claim about which editing session
|
|
21
|
+
* wrote it. folio cannot register a session (`settings.xml`'s `w:rsids` is
|
|
22
|
+
* copied through on every repack, and no save path mints one), so it must
|
|
23
|
+
* never write a session id it did not read. Typed text becomes its own run
|
|
24
|
+
* with no attributes instead, and `w:rsidRDefault` on the parent `w:p`
|
|
25
|
+
* supplies the session the format itself says such a run belongs to.
|
|
26
|
+
*/
|
|
27
|
+
const CANONICAL_RUN_IDENTITY_ID = /^(?:0|[1-9]\d*)$/u;
|
|
28
|
+
const runIdentityStripKey = new PluginKey("runIdentityStrip");
|
|
29
|
+
/**
|
|
30
|
+
* Every range `transactions` inserted, in the document they produced.
|
|
31
|
+
*
|
|
32
|
+
* A step map reports each replacement as an old span and the new span it
|
|
33
|
+
* became; a new span longer than nothing is content the step put there, which
|
|
34
|
+
* is exactly the text that may not claim an authored run. Each range is then
|
|
35
|
+
* carried through the steps that followed it — the rest of its own
|
|
36
|
+
* transaction, then every later one — so a batch applied together reports
|
|
37
|
+
* positions in the document this hook is looking at rather than in an
|
|
38
|
+
* intermediate one.
|
|
39
|
+
*/
|
|
40
|
+
const insertedRanges = (transactions) => {
|
|
41
|
+
const ranges = [];
|
|
42
|
+
for (const [transactionIndex, transaction] of transactions.entries()) {
|
|
43
|
+
const later = transactions.slice(transactionIndex + 1);
|
|
44
|
+
const carryForward = (pos, bias) => {
|
|
45
|
+
let mapped = pos;
|
|
46
|
+
for (const next of later) mapped = next.mapping.map(mapped, bias);
|
|
47
|
+
return mapped;
|
|
48
|
+
};
|
|
49
|
+
transaction.mapping.maps.forEach((stepMap, stepIndex) => {
|
|
50
|
+
const rest = transaction.mapping.slice(stepIndex + 1);
|
|
51
|
+
stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
52
|
+
if (newEnd <= newStart) return;
|
|
53
|
+
ranges.push({
|
|
54
|
+
from: carryForward(rest.map(newStart, -1), -1),
|
|
55
|
+
to: carryForward(rest.map(newEnd, 1), 1)
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return ranges;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Remove `runIdentity` from what a transaction inserted.
|
|
64
|
+
*
|
|
65
|
+
* Runs after the edit rather than in front of it because an insertion's marks
|
|
66
|
+
* are decided by ProseMirror from the text around it, and there is no hook
|
|
67
|
+
* that sees every route to that decision: typing, paste, a command and a
|
|
68
|
+
* collaborative apply all arrive here and nowhere else in common.
|
|
69
|
+
*/
|
|
70
|
+
const createRunIdentityStripPlugin = () => new Plugin({
|
|
71
|
+
key: runIdentityStripKey,
|
|
72
|
+
appendTransaction(transactions, _oldState, newState) {
|
|
73
|
+
if (!transactions.some((transaction) => transaction.docChanged)) return null;
|
|
74
|
+
const markType = newState.schema.marks[RUN_IDENTITY_MARK_NAME];
|
|
75
|
+
if (markType === void 0) return null;
|
|
76
|
+
const ranges = insertedRanges(transactions);
|
|
77
|
+
if (ranges.length === 0) return null;
|
|
78
|
+
const tr = newState.tr;
|
|
79
|
+
const stripRange = ({ from, to }) => {
|
|
80
|
+
const clampedTo = Math.min(to, newState.doc.content.size);
|
|
81
|
+
const clampedFrom = Math.min(from, clampedTo);
|
|
82
|
+
if (clampedFrom === clampedTo) return false;
|
|
83
|
+
let rangeStripped = false;
|
|
84
|
+
newState.doc.nodesBetween(clampedFrom, clampedTo, (node, pos) => {
|
|
85
|
+
if (!node.isInline || !markType.isInSet(node.marks)) return true;
|
|
86
|
+
tr.removeMark(Math.max(pos, clampedFrom), Math.min(pos + node.nodeSize, clampedTo), markType);
|
|
87
|
+
rangeStripped = true;
|
|
88
|
+
return true;
|
|
89
|
+
});
|
|
90
|
+
return rangeStripped;
|
|
91
|
+
};
|
|
92
|
+
let stripped = false;
|
|
93
|
+
for (const range of ranges) stripped = stripRange(range) || stripped;
|
|
94
|
+
if (!stripped) return null;
|
|
95
|
+
tr.setMeta("addToHistory", false);
|
|
96
|
+
tr.setMeta(runIdentityStripKey, "stripped");
|
|
97
|
+
if (newState.storedMarks !== null) tr.setStoredMarks(newState.storedMarks.filter((mark) => mark.type !== markType));
|
|
98
|
+
return tr;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const RunIdentityExtension = createMarkExtension({
|
|
102
|
+
name: RUN_IDENTITY_MARK_NAME,
|
|
103
|
+
schemaMarkName: RUN_IDENTITY_MARK_NAME,
|
|
104
|
+
markSpec: {
|
|
105
|
+
attrs: {
|
|
106
|
+
id: {},
|
|
107
|
+
preservedAttributes: { default: null },
|
|
108
|
+
preserved: { default: null }
|
|
109
|
+
},
|
|
110
|
+
inclusive: false,
|
|
111
|
+
parseDOM: [{
|
|
112
|
+
tag: `span[${RUN_IDENTITY_ATTRIBUTE}]`,
|
|
113
|
+
getAttrs(dom) {
|
|
114
|
+
const rawId = dom.dataset["docxRunIdentity"];
|
|
115
|
+
if (rawId === void 0 || !CANONICAL_RUN_IDENTITY_ID.test(rawId)) return false;
|
|
116
|
+
const id = Number(rawId);
|
|
117
|
+
return Number.isSafeInteger(id) ? runIdentityAttrs(id) : false;
|
|
118
|
+
}
|
|
119
|
+
}],
|
|
120
|
+
toDOM(mark) {
|
|
121
|
+
const { id } = expectRunIdentityMarkAttrs(mark);
|
|
122
|
+
return [
|
|
123
|
+
"span",
|
|
124
|
+
{ [RUN_IDENTITY_ATTRIBUTE]: String(id) },
|
|
125
|
+
0
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
onSchemaReady() {
|
|
130
|
+
return { plugins: [createRunIdentityStripPlugin()] };
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
//#endregion
|
|
134
|
+
export { RunIdentityExtension };
|
|
@@ -100,7 +100,8 @@ const DeletionExtension = createMarkExtension({
|
|
|
100
100
|
moveKind: { default: null },
|
|
101
101
|
initials: { default: null },
|
|
102
102
|
provenance: { default: "user" },
|
|
103
|
-
suggestionId: { default: null }
|
|
103
|
+
suggestionId: { default: null },
|
|
104
|
+
_historicalFormatting: { default: null }
|
|
104
105
|
},
|
|
105
106
|
inclusive: false,
|
|
106
107
|
parseDOM: [{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PLAIN_UNDERLINE, underlineDecorationCss, underlineStyleFromCssDecoration } from "../../../utils/formatToStyle.js";
|
|
1
2
|
import { expectUnderlineMarkAttrs } from "../../attrs/index.js";
|
|
2
3
|
import { createMarkExtension } from "../create.js";
|
|
3
4
|
import { setMark, toggleUnderlineMark } from "./markUtils.js";
|
|
@@ -6,39 +7,32 @@ import { panic } from "better-result";
|
|
|
6
7
|
/**
|
|
7
8
|
* Underline Mark Extension
|
|
8
9
|
*/
|
|
10
|
+
/** `w:u w:val="none"`: the token that cancels an inherited underline. */
|
|
11
|
+
const NO_UNDERLINE = "none";
|
|
9
12
|
const UnderlineExtension = createMarkExtension({
|
|
10
13
|
name: "underline",
|
|
11
14
|
schemaMarkName: "underline",
|
|
12
15
|
markSpec: {
|
|
13
16
|
attrs: {
|
|
14
|
-
style: { default:
|
|
17
|
+
style: { default: PLAIN_UNDERLINE },
|
|
15
18
|
color: { default: null }
|
|
16
19
|
},
|
|
17
20
|
parseDOM: [{ tag: "u" }, {
|
|
18
21
|
style: "text-decoration",
|
|
19
22
|
getAttrs: (value) => {
|
|
20
|
-
if (value.includes("underline")) return {};
|
|
21
|
-
return value.includes(
|
|
23
|
+
if (value.includes("underline")) return { style: underlineStyleFromCssDecoration(value) };
|
|
24
|
+
return value.includes(NO_UNDERLINE) ? { style: NO_UNDERLINE } : false;
|
|
22
25
|
}
|
|
23
26
|
}],
|
|
24
27
|
toDOM(mark) {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
const cssDecorationStyle = {
|
|
31
|
-
double: "double",
|
|
32
|
-
dotted: "dotted",
|
|
33
|
-
dash: "dashed",
|
|
34
|
-
wave: "wavy"
|
|
35
|
-
}[style];
|
|
36
|
-
if (cssDecorationStyle) cssStyle.push(`text-decoration-style: ${cssDecorationStyle}`);
|
|
37
|
-
}
|
|
38
|
-
if (colorRgb) cssStyle.push(`text-decoration-color: #${colorRgb}`);
|
|
28
|
+
const { style = PLAIN_UNDERLINE, color } = expectUnderlineMarkAttrs(mark);
|
|
29
|
+
const { decorationStyle, decorationThickness } = underlineDecorationCss(style);
|
|
30
|
+
const declarations = [`text-decoration: ${decorationStyle === void 0 ? NO_UNDERLINE : `underline ${decorationStyle}`}`];
|
|
31
|
+
if (decorationThickness !== void 0) declarations.push(`text-decoration-thickness: ${decorationThickness}`);
|
|
32
|
+
if (color?.rgb) declarations.push(`text-decoration-color: #${color.rgb}`);
|
|
39
33
|
return [
|
|
40
34
|
"span",
|
|
41
|
-
{ style:
|
|
35
|
+
{ style: declarations.join("; ") },
|
|
42
36
|
0
|
|
43
37
|
];
|
|
44
38
|
}
|
|
@@ -3,6 +3,7 @@ import { Command, EditorState } from "prosemirror-state";
|
|
|
3
3
|
import { Mark, MarkType, Schema } from "prosemirror-model";
|
|
4
4
|
//#region src/prosemirror/extensions/marks/markUtils.d.ts
|
|
5
5
|
type MarkAttrs = Record<string, unknown>;
|
|
6
|
+
declare function marksToTextFormatting(marks: readonly Mark[]): document_d_exports.TextFormatting;
|
|
6
7
|
declare function setMark(markType: MarkType, attrs: MarkAttrs): Command;
|
|
7
8
|
type PairedToggleProperty = "bold" | "italic";
|
|
8
9
|
/** UI toggle whose direct-formatting contract explicitly targets both script families. */
|
|
@@ -46,4 +47,4 @@ declare function createSetMarkCommand(markType: MarkType, attrs?: Record<string,
|
|
|
46
47
|
*/
|
|
47
48
|
declare function createRemoveMarkCommand(markType: MarkType): Command;
|
|
48
49
|
//#endregion
|
|
49
|
-
export { AuthoredRunFormattingCarrier, clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
50
|
+
export { AuthoredRunFormattingCarrier, clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, marksToTextFormatting, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { FONT_THEME_VALUES } from "../../../types/documentEnumValues.js";
|
|
2
2
|
import { mergeFontFamily } from "../../../utils/fontFamilyMerge.js";
|
|
3
3
|
import { normalizeHorizontalScalePercent } from "../../../utils/horizontalScale.js";
|
|
4
|
-
import { expectFontFamilyMarkAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
|
|
5
|
-
import { shadingToRunShadingAttrs } from "../../conversion/runShadingMark.js";
|
|
4
|
+
import { expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectEmphasisMarkAttrs, expectFontFamilyMarkAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectStrikeMarkAttrs, expectTextEffectMarkAttrs } from "../../attrs/index.js";
|
|
5
|
+
import { runShadingAttrsToShading, shadingToRunShadingAttrs } from "../../conversion/runShadingMark.js";
|
|
6
6
|
import { selectRunFormattingCarrierRepresentations } from "../../runFormattingInlineCarriers.js";
|
|
7
7
|
import { hasRunFormattingOverrideAttrs } from "../../runFormattingProvenance.js";
|
|
8
8
|
import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS } from "../../schema/marks.js";
|
|
9
9
|
import { applyRunFormattingOverrideMark, buildRunFormattingOverrideAttrs } from "./RunFormattingOverrideExtension.js";
|
|
10
|
+
import { readThemeColor } from "@stll/docx-core/model";
|
|
10
11
|
import { toggleMark } from "prosemirror-commands";
|
|
11
12
|
//#region src/prosemirror/extensions/marks/markUtils.ts
|
|
12
13
|
const isFontTheme = (value) => value !== void 0 && FONT_THEME_VALUES.some((theme) => theme === value);
|
|
@@ -37,11 +38,12 @@ function marksToTextFormatting(marks) {
|
|
|
37
38
|
};
|
|
38
39
|
break;
|
|
39
40
|
case "strike":
|
|
40
|
-
formatting.
|
|
41
|
+
if (expectStrikeMarkAttrs(mark).double) formatting.doubleStrike = true;
|
|
42
|
+
else formatting.strike = true;
|
|
41
43
|
break;
|
|
42
44
|
case "textColor": {
|
|
43
45
|
const colorRgb = mark.attrs["rgb"] !== null && mark.attrs["rgb"] !== void 0 ? String(mark.attrs["rgb"]) : void 0;
|
|
44
|
-
const colorTheme = mark.attrs["themeColor"] !== null && mark.attrs["themeColor"] !== void 0 ? String(mark.attrs["themeColor"]) : void 0;
|
|
46
|
+
const colorTheme = mark.attrs["themeColor"] !== null && mark.attrs["themeColor"] !== void 0 ? readThemeColor(String(mark.attrs["themeColor"])) : void 0;
|
|
45
47
|
const colorTint = mark.attrs["themeTint"] !== null && mark.attrs["themeTint"] !== void 0 ? String(mark.attrs["themeTint"]) : void 0;
|
|
46
48
|
const colorShade = mark.attrs["themeShade"] !== null && mark.attrs["themeShade"] !== void 0 ? String(mark.attrs["themeShade"]) : void 0;
|
|
47
49
|
formatting.color = {
|
|
@@ -55,6 +57,9 @@ function marksToTextFormatting(marks) {
|
|
|
55
57
|
case "highlight":
|
|
56
58
|
formatting.highlight = String(mark.attrs["color"]);
|
|
57
59
|
break;
|
|
60
|
+
case "runShading":
|
|
61
|
+
formatting.shading = runShadingAttrsToShading(expectRunShadingMarkAttrs(mark));
|
|
62
|
+
break;
|
|
58
63
|
case "fontSize":
|
|
59
64
|
formatting.fontSize = Number(mark.attrs["size"]);
|
|
60
65
|
break;
|
|
@@ -78,12 +83,51 @@ function marksToTextFormatting(marks) {
|
|
|
78
83
|
case "subscript":
|
|
79
84
|
formatting.vertAlign = "subscript";
|
|
80
85
|
break;
|
|
86
|
+
case "allCaps":
|
|
87
|
+
formatting.allCaps = true;
|
|
88
|
+
break;
|
|
89
|
+
case "smallCaps":
|
|
90
|
+
formatting.smallCaps = true;
|
|
91
|
+
break;
|
|
92
|
+
case "characterSpacing": {
|
|
93
|
+
const attrs = expectCharacterSpacingMarkAttrs(mark);
|
|
94
|
+
if (attrs.spacing !== void 0) formatting.spacing = attrs.spacing;
|
|
95
|
+
if (attrs.position !== void 0) formatting.position = attrs.position;
|
|
96
|
+
const scale = normalizeHorizontalScalePercent(attrs.scale);
|
|
97
|
+
if (scale !== void 0) formatting.scale = scale;
|
|
98
|
+
if (attrs.kerning !== void 0) formatting.kerning = attrs.kerning;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case "emboss":
|
|
102
|
+
formatting.emboss = true;
|
|
103
|
+
break;
|
|
104
|
+
case "imprint":
|
|
105
|
+
formatting.imprint = true;
|
|
106
|
+
break;
|
|
107
|
+
case "hidden":
|
|
108
|
+
formatting.hidden = true;
|
|
109
|
+
break;
|
|
110
|
+
case "textShadow":
|
|
111
|
+
formatting.shadow = true;
|
|
112
|
+
break;
|
|
113
|
+
case "emphasisMark":
|
|
114
|
+
formatting.emphasisMark = expectEmphasisMarkAttrs(mark).type || "dot";
|
|
115
|
+
break;
|
|
116
|
+
case "textOutline":
|
|
117
|
+
formatting.outline = true;
|
|
118
|
+
break;
|
|
81
119
|
case "rtl":
|
|
82
120
|
formatting.rtl = true;
|
|
83
121
|
break;
|
|
122
|
+
case "textEffect":
|
|
123
|
+
formatting.effect = expectTextEffectMarkAttrs(mark).effect;
|
|
124
|
+
break;
|
|
84
125
|
case "runFormattingOverride":
|
|
85
126
|
applyRunFormattingOverrideMark(formatting, mark);
|
|
86
127
|
break;
|
|
128
|
+
case "characterStyle":
|
|
129
|
+
formatting.styleId = expectCharacterStyleMarkAttrs(mark).styleId;
|
|
130
|
+
break;
|
|
87
131
|
default: break;
|
|
88
132
|
}
|
|
89
133
|
return formatting;
|
|
@@ -486,4 +530,4 @@ function createRemoveMarkCommand(markType) {
|
|
|
486
530
|
return removeMark(markType);
|
|
487
531
|
}
|
|
488
532
|
//#endregion
|
|
489
|
-
export { clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
533
|
+
export { clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, marksToTextFormatting, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NodeExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A bookmark boundary that stands between two blocks.
|
|
5
|
+
*
|
|
6
|
+
* The block-level twin of `bookmarkBoundary`. `CT_Body`, `CT_Tc` and
|
|
7
|
+
* `CT_SdtContentBlock` declare `w:bookmarkStart`/`w:bookmarkEnd` beside their
|
|
8
|
+
* paragraphs and tables, and Word writes them there whenever the selection was
|
|
9
|
+
* whole blocks: `_GoBack` after an edit, a table-of-contents range around the
|
|
10
|
+
* headings it lists. ProseMirror decides inline or block per node type, so the
|
|
11
|
+
* inline atom cannot also sit here and this is its own node — with the same
|
|
12
|
+
* attributes, read by the same reader, so the two levels cannot describe a
|
|
13
|
+
* bookmark differently.
|
|
14
|
+
*
|
|
15
|
+
* **Position is structure, not an attribute**, for the reason
|
|
16
|
+
* `PreservedBlockExtension` gives: the node sits between the same two blocks it
|
|
17
|
+
* sat between in the source and ProseMirror's own mapping keeps it there, so an
|
|
18
|
+
* edit inside the range cannot change what the range covers.
|
|
19
|
+
*
|
|
20
|
+
* Pairing is owned one level up. A bookmark may open at block level and close
|
|
21
|
+
* inside a paragraph, which is the commoner shape in real documents, so the
|
|
22
|
+
* integrity pass in `BookmarkBoundaryExtension` reads both node types together;
|
|
23
|
+
* a rule enforced here would see half of each such pair and delete it.
|
|
24
|
+
*/
|
|
25
|
+
/** The node name, for callers asking what a block container holds. */
|
|
26
|
+
declare const BLOCK_BOOKMARK_BOUNDARY_NODE_NAME = "blockBookmarkBoundary";
|
|
27
|
+
declare const BlockBookmarkBoundaryExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtension;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { BLOCK_BOOKMARK_BOUNDARY_NODE_NAME, BlockBookmarkBoundaryExtension };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createNodeExtension } from "../create.js";
|
|
2
|
+
import { bookmarkBoundaryAttrSpec, bookmarkBoundaryDomAttributes, parseBookmarkBoundaryDom } from "./bookmarkBoundaryDom.js";
|
|
3
|
+
//#region src/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.ts
|
|
4
|
+
/**
|
|
5
|
+
* A bookmark boundary that stands between two blocks.
|
|
6
|
+
*
|
|
7
|
+
* The block-level twin of `bookmarkBoundary`. `CT_Body`, `CT_Tc` and
|
|
8
|
+
* `CT_SdtContentBlock` declare `w:bookmarkStart`/`w:bookmarkEnd` beside their
|
|
9
|
+
* paragraphs and tables, and Word writes them there whenever the selection was
|
|
10
|
+
* whole blocks: `_GoBack` after an edit, a table-of-contents range around the
|
|
11
|
+
* headings it lists. ProseMirror decides inline or block per node type, so the
|
|
12
|
+
* inline atom cannot also sit here and this is its own node — with the same
|
|
13
|
+
* attributes, read by the same reader, so the two levels cannot describe a
|
|
14
|
+
* bookmark differently.
|
|
15
|
+
*
|
|
16
|
+
* **Position is structure, not an attribute**, for the reason
|
|
17
|
+
* `PreservedBlockExtension` gives: the node sits between the same two blocks it
|
|
18
|
+
* sat between in the source and ProseMirror's own mapping keeps it there, so an
|
|
19
|
+
* edit inside the range cannot change what the range covers.
|
|
20
|
+
*
|
|
21
|
+
* Pairing is owned one level up. A bookmark may open at block level and close
|
|
22
|
+
* inside a paragraph, which is the commoner shape in real documents, so the
|
|
23
|
+
* integrity pass in `BookmarkBoundaryExtension` reads both node types together;
|
|
24
|
+
* a rule enforced here would see half of each such pair and delete it.
|
|
25
|
+
*/
|
|
26
|
+
/** The node name, for callers asking what a block container holds. */
|
|
27
|
+
const BLOCK_BOOKMARK_BOUNDARY_NODE_NAME = "blockBookmarkBoundary";
|
|
28
|
+
const BlockBookmarkBoundaryExtension = createNodeExtension({
|
|
29
|
+
name: BLOCK_BOOKMARK_BOUNDARY_NODE_NAME,
|
|
30
|
+
schemaNodeName: BLOCK_BOOKMARK_BOUNDARY_NODE_NAME,
|
|
31
|
+
nodeSpec: {
|
|
32
|
+
group: "block",
|
|
33
|
+
atom: true,
|
|
34
|
+
selectable: false,
|
|
35
|
+
attrs: bookmarkBoundaryAttrSpec,
|
|
36
|
+
parseDOM: [{
|
|
37
|
+
tag: "div[data-docx-bookmark-boundary]",
|
|
38
|
+
getAttrs: parseBookmarkBoundaryDom
|
|
39
|
+
}],
|
|
40
|
+
toDOM(node) {
|
|
41
|
+
return ["div", bookmarkBoundaryDomAttributes(node)];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
export { BLOCK_BOOKMARK_BOUNDARY_NODE_NAME, BlockBookmarkBoundaryExtension };
|
|
@@ -12,9 +12,10 @@ import { NodeExtension } from "../types.js";
|
|
|
12
12
|
* - `sdtType` / `alias` / `tag` / `lock` / `placeholder` /
|
|
13
13
|
* `showingPlaceholder` / `dateFormat` / `listItems` / `checked` — modeled
|
|
14
14
|
* projection of `w:sdtPr`; drives addressing and widget UX.
|
|
15
|
-
* - `
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* - `_preserved` — the `w:sdtPr` children folio does not model, at their
|
|
16
|
+
* schema ordinal, so `w:dataBinding`, `w15:repeatingSection` and the
|
|
17
|
+
* control-kind element round-trip without being enumerated here.
|
|
18
|
+
* - `rawEndPropertiesXml` — the verbatim `<w:sdtEndPr>`.
|
|
18
19
|
*/
|
|
19
20
|
declare const BlockSdtExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtension;
|
|
20
21
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { onOffFromDataset } from "../../conversion/sdtAttrs.js";
|
|
1
2
|
import { createNodeExtension } from "../create.js";
|
|
2
3
|
//#region src/prosemirror/extensions/nodes/BlockSdtExtension.ts
|
|
3
4
|
/**
|
|
@@ -12,9 +13,10 @@ import { createNodeExtension } from "../create.js";
|
|
|
12
13
|
* - `sdtType` / `alias` / `tag` / `lock` / `placeholder` /
|
|
13
14
|
* `showingPlaceholder` / `dateFormat` / `listItems` / `checked` — modeled
|
|
14
15
|
* projection of `w:sdtPr`; drives addressing and widget UX.
|
|
15
|
-
* - `
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* - `_preserved` — the `w:sdtPr` children folio does not model, at their
|
|
17
|
+
* schema ordinal, so `w:dataBinding`, `w15:repeatingSection` and the
|
|
18
|
+
* control-kind element round-trip without being enumerated here.
|
|
19
|
+
* - `rawEndPropertiesXml` — the verbatim `<w:sdtEndPr>`.
|
|
18
20
|
*/
|
|
19
21
|
const BlockSdtExtension = createNodeExtension({
|
|
20
22
|
name: "blockSdt",
|
|
@@ -31,7 +33,8 @@ const BlockSdtExtension = createNodeExtension({
|
|
|
31
33
|
id: { default: null },
|
|
32
34
|
lock: { default: null },
|
|
33
35
|
placeholder: { default: null },
|
|
34
|
-
|
|
36
|
+
/** `w:showingPlcHdr`: `null` when the control states nothing. */
|
|
37
|
+
showingPlaceholder: { default: null },
|
|
35
38
|
dateFormat: { default: null },
|
|
36
39
|
/** ISO 8601 bound date value (`w:date@w:fullDate`). */
|
|
37
40
|
dateValueISO: { default: null },
|
|
@@ -52,9 +55,14 @@ const BlockSdtExtension = createNodeExtension({
|
|
|
52
55
|
* `<w:sdtContent><w:p/></w:sdtContent>` empty-paragraph content too.
|
|
53
56
|
*/
|
|
54
57
|
_originallyEmpty: { default: false },
|
|
55
|
-
|
|
58
|
+
_preserved: { default: null },
|
|
56
59
|
rawEndPropertiesXml: { default: null },
|
|
57
60
|
/**
|
|
61
|
+
* `w:sdtEndPr` as a record, so a control the editor rebuilds still
|
|
62
|
+
* writes its end mark once the captured bytes are gone.
|
|
63
|
+
*/
|
|
64
|
+
endProperties: { default: null },
|
|
65
|
+
/**
|
|
58
66
|
* Verbatim XML for direct sdt siblings of sdtContent (range markers
|
|
59
67
|
* per MS-OE376 §2.5.2.30). Two slots so position is preserved.
|
|
60
68
|
*/
|
|
@@ -65,10 +73,6 @@ const BlockSdtExtension = createNodeExtension({
|
|
|
65
73
|
tag: "div.docx-block-sdt",
|
|
66
74
|
getAttrs(dom) {
|
|
67
75
|
if (!(dom instanceof HTMLElement)) return false;
|
|
68
|
-
const checkedRaw = dom.dataset["checked"];
|
|
69
|
-
let checked = null;
|
|
70
|
-
if (checkedRaw === "true") checked = true;
|
|
71
|
-
else if (checkedRaw === "false") checked = false;
|
|
72
76
|
const idRaw = dom.dataset["sdtId"];
|
|
73
77
|
const id = idRaw ? Number.parseInt(idRaw, 10) : null;
|
|
74
78
|
return {
|
|
@@ -78,15 +82,16 @@ const BlockSdtExtension = createNodeExtension({
|
|
|
78
82
|
id: id !== null && !Number.isNaN(id) ? id : null,
|
|
79
83
|
lock: dom.dataset["lock"] ?? null,
|
|
80
84
|
placeholder: dom.dataset["placeholder"] ?? null,
|
|
81
|
-
showingPlaceholder: dom.dataset["showingPlaceholder"]
|
|
85
|
+
showingPlaceholder: onOffFromDataset(dom.dataset["showingPlaceholder"]),
|
|
82
86
|
dateFormat: dom.dataset["dateFormat"] ?? null,
|
|
83
87
|
dateValueISO: dom.dataset["dateValueIso"] ?? null,
|
|
84
88
|
listItems: dom.dataset["listItems"] ?? null,
|
|
85
89
|
dropdownLastValue: dom.dataset["dropdownLastValue"] ?? null,
|
|
86
|
-
checked,
|
|
90
|
+
checked: onOffFromDataset(dom.dataset["checked"]),
|
|
87
91
|
_originallyEmpty: dom.dataset["originallyEmpty"] === "true",
|
|
88
|
-
|
|
92
|
+
_preserved: null,
|
|
89
93
|
rawEndPropertiesXml: null,
|
|
94
|
+
endProperties: null,
|
|
90
95
|
rawSdtChildrenBeforeContent: null,
|
|
91
96
|
rawSdtChildrenAfterContent: null
|
|
92
97
|
};
|
|
@@ -103,7 +108,7 @@ const BlockSdtExtension = createNodeExtension({
|
|
|
103
108
|
if (attrs["id"] !== null && attrs["id"] !== void 0) data["data-sdt-id"] = String(attrs["id"]);
|
|
104
109
|
if (attrs["lock"]) data["data-lock"] = String(attrs["lock"]);
|
|
105
110
|
if (attrs["placeholder"]) data["data-placeholder"] = String(attrs["placeholder"]);
|
|
106
|
-
if (attrs["showingPlaceholder"]) data["data-showing-placeholder"] = "
|
|
111
|
+
if (attrs["showingPlaceholder"] !== null && attrs["showingPlaceholder"] !== void 0) data["data-showing-placeholder"] = String(attrs["showingPlaceholder"]);
|
|
107
112
|
if (attrs["dateFormat"]) data["data-date-format"] = String(attrs["dateFormat"]);
|
|
108
113
|
if (attrs["dateValueISO"]) data["data-date-value-iso"] = String(attrs["dateValueISO"]);
|
|
109
114
|
if (attrs["listItems"]) data["data-list-items"] = String(attrs["listItems"]);
|