@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,53 @@
|
|
|
1
|
+
import { ParagraphContent } from "../types/content.js";
|
|
2
|
+
//#region src/prosemirror/emptyRangeAnchor.d.ts
|
|
3
|
+
/** A marker that opens a range the editor otherwise projects as a mark. */
|
|
4
|
+
type RangeStartType = Extract<ParagraphContent["type"], `${string}RangeStart`>;
|
|
5
|
+
/**
|
|
6
|
+
* Which end closes which start.
|
|
7
|
+
*
|
|
8
|
+
* Both sides are derived from the model's own content union rather than
|
|
9
|
+
* listed, so a `…RangeStart` added to `ParagraphContent` fails this
|
|
10
|
+
* `satisfies` until somebody has said what closes it.
|
|
11
|
+
*/
|
|
12
|
+
declare const RANGE_END_FOR_START: {
|
|
13
|
+
readonly commentRangeStart: "commentRangeEnd";
|
|
14
|
+
readonly moveFromRangeStart: "moveFromRangeEnd";
|
|
15
|
+
readonly moveToRangeStart: "moveToRangeEnd";
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The `rangeAnchor` node's attributes: a start and the end that closes it,
|
|
19
|
+
* with nothing between them.
|
|
20
|
+
*
|
|
21
|
+
* Distributing over the start types pairs each start with exactly its own end,
|
|
22
|
+
* so a comment start holding a move end is not a value this type has.
|
|
23
|
+
*/
|
|
24
|
+
type RangeAnchorAttrs = { [Start in RangeStartType]: {
|
|
25
|
+
start: Extract<ParagraphContent, {
|
|
26
|
+
type: Start;
|
|
27
|
+
}>;
|
|
28
|
+
end: Extract<ParagraphContent, {
|
|
29
|
+
type: (typeof RANGE_END_FOR_START)[Start];
|
|
30
|
+
}>;
|
|
31
|
+
}; }[RangeStartType];
|
|
32
|
+
/** Whether this content is one of the six range markers, either half. */
|
|
33
|
+
declare const isRangeMarker: (content: ParagraphContent) => boolean;
|
|
34
|
+
type EmptyRangePlan = {
|
|
35
|
+
/** The anchor to emit in place of the marker at this index. */
|
|
36
|
+
anchorAt: ReadonlyMap<number, RangeAnchorAttrs>;
|
|
37
|
+
/** An index whose marker an anchor at an earlier index already holds. */
|
|
38
|
+
closedAt: ReadonlySet<number>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The empty ranges in one inline sequence, by the index each one's start sits
|
|
42
|
+
* at.
|
|
43
|
+
*
|
|
44
|
+
* The window a pair may close within is a maximal run of range markers and
|
|
45
|
+
* nothing else, which is what "spans no content" means once the transparent
|
|
46
|
+
* wrappers are lifted. Nesting inside such a run is not meaningful — neither
|
|
47
|
+
* order covers anything — so the pairs are taken nearest first and each anchor
|
|
48
|
+
* stays at its own start's index. A start whose end is outside the run is a
|
|
49
|
+
* range over content and keeps the mark path; so does an end with no start.
|
|
50
|
+
*/
|
|
51
|
+
declare const planEmptyRanges: (content: readonly ParagraphContent[]) => EmptyRangePlan;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { EmptyRangePlan, RANGE_END_FOR_START, RangeAnchorAttrs, isRangeMarker, planEmptyRanges };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
2
|
+
//#region src/prosemirror/emptyRangeAnchor.ts
|
|
3
|
+
/**
|
|
4
|
+
* A comment or tracked-move range that spans no content, carried across the
|
|
5
|
+
* editor projection as one zero-width atom.
|
|
6
|
+
*
|
|
7
|
+
* A reviewer who comments at an insertion point rather than over a selection
|
|
8
|
+
* gets `w:commentRangeStart` immediately followed by `w:commentRangeEnd`, and
|
|
9
|
+
* then the `w:commentReference` run. The editor spells a comment as a `comment`
|
|
10
|
+
* mark over the inline content its range covers, and a range over nothing has
|
|
11
|
+
* no leaf to mark, so the projection dropped both markers. The comment still
|
|
12
|
+
* listed — the reference survives as its own atom — but its anchor position was
|
|
13
|
+
* gone, and the save wrote a reference with no range at all. A tracked move
|
|
14
|
+
* whose range spans nothing loses its `w:name` the same way, and with it the
|
|
15
|
+
* only thing binding the move's source to its destination.
|
|
16
|
+
*
|
|
17
|
+
* The pair is one thing rather than two, so it is one node. Two adjacent
|
|
18
|
+
* boundary nodes, which is what the bookmark precedent would suggest, would
|
|
19
|
+
* leave a position between them for a caret to sit in; typing there would turn
|
|
20
|
+
* a point comment into a range the reviewer never drew.
|
|
21
|
+
*
|
|
22
|
+
* What the node holds is the model's own markers, not a copy of their fields:
|
|
23
|
+
* an attribute added to `CT_MoveBookmark` is carried without being named here.
|
|
24
|
+
*
|
|
25
|
+
* A range that spans a bookmark boundary, a comment reference or captured
|
|
26
|
+
* markup is not in this class and needs no anchor: each of those is an inline
|
|
27
|
+
* node that carries a mark, so the mark path already keeps the range. Only a
|
|
28
|
+
* range with nothing whatever between its two markers has no carrier.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Which end closes which start.
|
|
32
|
+
*
|
|
33
|
+
* Both sides are derived from the model's own content union rather than
|
|
34
|
+
* listed, so a `…RangeStart` added to `ParagraphContent` fails this
|
|
35
|
+
* `satisfies` until somebody has said what closes it.
|
|
36
|
+
*/
|
|
37
|
+
const RANGE_END_FOR_START = {
|
|
38
|
+
commentRangeStart: "commentRangeEnd",
|
|
39
|
+
moveFromRangeStart: "moveFromRangeEnd",
|
|
40
|
+
moveToRangeStart: "moveToRangeEnd"
|
|
41
|
+
};
|
|
42
|
+
const RANGE_MARKER_TYPES = /* @__PURE__ */ new Set([...Object.keys(RANGE_END_FOR_START), ...Object.values(RANGE_END_FOR_START)]);
|
|
43
|
+
/** Whether this content is one of the six range markers, either half. */
|
|
44
|
+
const isRangeMarker = (content) => RANGE_MARKER_TYPES.has(content.type);
|
|
45
|
+
const isRangeStart = (content) => content.type in RANGE_END_FOR_START;
|
|
46
|
+
const isRangeEnd = (content) => content.type === "commentRangeEnd" || content.type === "moveFromRangeEnd" || content.type === "moveToRangeEnd";
|
|
47
|
+
const NO_EMPTY_RANGES = {
|
|
48
|
+
anchorAt: /* @__PURE__ */ new Map(),
|
|
49
|
+
closedAt: /* @__PURE__ */ new Set()
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The empty ranges in one inline sequence, by the index each one's start sits
|
|
53
|
+
* at.
|
|
54
|
+
*
|
|
55
|
+
* The window a pair may close within is a maximal run of range markers and
|
|
56
|
+
* nothing else, which is what "spans no content" means once the transparent
|
|
57
|
+
* wrappers are lifted. Nesting inside such a run is not meaningful — neither
|
|
58
|
+
* order covers anything — so the pairs are taken nearest first and each anchor
|
|
59
|
+
* stays at its own start's index. A start whose end is outside the run is a
|
|
60
|
+
* range over content and keeps the mark path; so does an end with no start.
|
|
61
|
+
*/
|
|
62
|
+
const planEmptyRanges = (content) => {
|
|
63
|
+
const anchorAt = /* @__PURE__ */ new Map();
|
|
64
|
+
const closedAt = /* @__PURE__ */ new Set();
|
|
65
|
+
let index = 0;
|
|
66
|
+
while (index < content.length) {
|
|
67
|
+
const item = content[index];
|
|
68
|
+
if (item === void 0 || !isRangeMarker(item)) {
|
|
69
|
+
index += 1;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
let runEnd = index;
|
|
73
|
+
while (runEnd < content.length) {
|
|
74
|
+
const candidate = content[runEnd];
|
|
75
|
+
if (candidate === void 0 || !isRangeMarker(candidate)) break;
|
|
76
|
+
runEnd += 1;
|
|
77
|
+
}
|
|
78
|
+
pairWithinRun({
|
|
79
|
+
content,
|
|
80
|
+
from: index,
|
|
81
|
+
to: runEnd,
|
|
82
|
+
anchorAt,
|
|
83
|
+
closedAt
|
|
84
|
+
});
|
|
85
|
+
index = runEnd;
|
|
86
|
+
}
|
|
87
|
+
if (anchorAt.size === 0) return NO_EMPTY_RANGES;
|
|
88
|
+
return {
|
|
89
|
+
anchorAt,
|
|
90
|
+
closedAt
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The two markers as one anchor, or `null` when the closer does not close this
|
|
95
|
+
* start.
|
|
96
|
+
*
|
|
97
|
+
* The branches restate no pairing: `RangeAnchorAttrs` is derived from
|
|
98
|
+
* {@link RANGE_END_FOR_START}, so a branch that named the wrong end would not
|
|
99
|
+
* be assignable, and a start type the model gains fails the exhaustiveness
|
|
100
|
+
* check below.
|
|
101
|
+
*/
|
|
102
|
+
const pairedAnchor = (opener, closer) => {
|
|
103
|
+
switch (opener.type) {
|
|
104
|
+
case "commentRangeStart": return closer.type === "commentRangeEnd" && closer.id === opener.id ? {
|
|
105
|
+
start: opener,
|
|
106
|
+
end: closer
|
|
107
|
+
} : null;
|
|
108
|
+
case "moveFromRangeStart": return closer.type === "moveFromRangeEnd" && closer.id === opener.id ? {
|
|
109
|
+
start: opener,
|
|
110
|
+
end: closer
|
|
111
|
+
} : null;
|
|
112
|
+
case "moveToRangeStart": return closer.type === "moveToRangeEnd" && closer.id === opener.id ? {
|
|
113
|
+
start: opener,
|
|
114
|
+
end: closer
|
|
115
|
+
} : null;
|
|
116
|
+
default: panic(`Unsupported range start: ${JSON.stringify(opener)}`);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const pairWithinRun = ({ content, from, to, anchorAt, closedAt }) => {
|
|
120
|
+
const endIndexesByTypeAndId = /* @__PURE__ */ new Map();
|
|
121
|
+
for (let end = from; end < to; end += 1) {
|
|
122
|
+
const closer = content[end];
|
|
123
|
+
if (closer === void 0 || !isRangeEnd(closer)) continue;
|
|
124
|
+
const key = rangeKey(closer.type, closer.id);
|
|
125
|
+
const indexes = endIndexesByTypeAndId.get(key);
|
|
126
|
+
if (indexes === void 0) {
|
|
127
|
+
endIndexesByTypeAndId.set(key, [end]);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
indexes.push(end);
|
|
131
|
+
}
|
|
132
|
+
const nextEndByTypeAndId = /* @__PURE__ */ new Map();
|
|
133
|
+
for (let start = from; start < to; start += 1) {
|
|
134
|
+
const opener = content[start];
|
|
135
|
+
if (opener === void 0 || closedAt.has(start) || !isRangeStart(opener)) continue;
|
|
136
|
+
const key = rangeKey(RANGE_END_FOR_START[opener.type], opener.id);
|
|
137
|
+
const indexes = endIndexesByTypeAndId.get(key);
|
|
138
|
+
if (indexes === void 0) continue;
|
|
139
|
+
let nextEnd = nextEndByTypeAndId.get(key) ?? 0;
|
|
140
|
+
while (nextEnd < indexes.length && (indexes[nextEnd] ?? -1) <= start) nextEnd += 1;
|
|
141
|
+
const end = indexes[nextEnd];
|
|
142
|
+
if (end === void 0) {
|
|
143
|
+
nextEndByTypeAndId.set(key, nextEnd);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
nextEndByTypeAndId.set(key, nextEnd + 1);
|
|
147
|
+
const closer = content[end];
|
|
148
|
+
if (closer === void 0) continue;
|
|
149
|
+
const anchor = pairedAnchor(opener, closer);
|
|
150
|
+
if (anchor === null) continue;
|
|
151
|
+
anchorAt.set(start, anchor);
|
|
152
|
+
closedAt.add(start);
|
|
153
|
+
closedAt.add(end);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const rangeKey = (type, id) => `${type}:${id}`;
|
|
157
|
+
//#endregion
|
|
158
|
+
export { RANGE_END_FOR_START, isRangeMarker, planEmptyRanges };
|
|
@@ -17,41 +17,22 @@ import { ParagraphChangeTrackerExtension } from "./features/ParagraphChangeTrack
|
|
|
17
17
|
import { PasteCleanupExtension } from "./features/PasteCleanupExtension.js";
|
|
18
18
|
import { PasteStyleInlinerExtension } from "./features/PasteStyleInlinerExtension.js";
|
|
19
19
|
import { SelectionTrackerExtension } from "./features/SelectionTrackerExtension.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { CharacterSpacingExtension } from "./marks/CharacterSpacingExtension.js";
|
|
23
|
-
import { CharacterStyleExtension } from "./marks/CharacterStyleExtension.js";
|
|
24
|
-
import { CommentExtension } from "./marks/CommentExtension.js";
|
|
25
|
-
import { FontFamilyExtension } from "./marks/FontFamilyExtension.js";
|
|
26
|
-
import { FontSizeExtension } from "./marks/FontSizeExtension.js";
|
|
27
|
-
import { FootnoteRefExtension } from "./marks/FootnoteRefExtension.js";
|
|
28
|
-
import { HiddenTextExtension } from "./marks/HiddenTextExtension.js";
|
|
29
|
-
import { HighlightExtension } from "./marks/HighlightExtension.js";
|
|
30
|
-
import { HyperlinkExtension } from "./marks/HyperlinkExtension.js";
|
|
31
|
-
import { ItalicExtension } from "./marks/ItalicExtension.js";
|
|
32
|
-
import { LanguageExtension } from "./marks/LanguageExtension.js";
|
|
33
|
-
import { PageBreakRunOwnerExtension } from "./marks/PageBreakRunOwnerExtension.js";
|
|
34
|
-
import { RtlExtension } from "./marks/RtlExtension.js";
|
|
35
|
-
import { RunFormattingOverrideExtension } from "./marks/RunFormattingOverrideExtension.js";
|
|
36
|
-
import { RunShadingExtension } from "./marks/RunShadingExtension.js";
|
|
37
|
-
import { SmallCapsExtension } from "./marks/SmallCapsExtension.js";
|
|
38
|
-
import { StrikeExtension } from "./marks/StrikeExtension.js";
|
|
39
|
-
import { SubscriptExtension } from "./marks/SubscriptExtension.js";
|
|
40
|
-
import { SuperscriptExtension } from "./marks/SuperscriptExtension.js";
|
|
41
|
-
import { TextColorExtension } from "./marks/TextColorExtension.js";
|
|
42
|
-
import { TextEffectExtension } from "./marks/TextEffectExtension.js";
|
|
43
|
-
import { EmbossExtension, EmphasisMarkExtension, ImprintExtension, TextOutlineExtension, TextShadowExtension } from "./marks/TextEffectsExtensions.js";
|
|
44
|
-
import { DeletionExtension, InsertionExtension, RunPropertyChangeExtension } from "./marks/TrackedChangeExtensions.js";
|
|
45
|
-
import { UnderlineExtension } from "./marks/UnderlineExtension.js";
|
|
20
|
+
import { MARK_EXTENSIONS, MARK_NESTING_ORDER } from "./markRegistry.js";
|
|
21
|
+
import { BlockBookmarkBoundaryExtension } from "./nodes/BlockBookmarkBoundaryExtension.js";
|
|
46
22
|
import { BlockSdtExtension } from "./nodes/BlockSdtExtension.js";
|
|
47
23
|
import { BookmarkBoundaryExtension } from "./nodes/BookmarkBoundaryExtension.js";
|
|
24
|
+
import { CommentReferenceExtension } from "./nodes/CommentReferenceExtension.js";
|
|
48
25
|
import { FieldExtension, StructuredFieldExtension } from "./nodes/FieldExtension.js";
|
|
49
26
|
import { HardBreakExtension } from "./nodes/HardBreakExtension.js";
|
|
50
27
|
import { HorizontalRuleExtension } from "./nodes/HorizontalRuleExtension.js";
|
|
51
28
|
import { ImageExtension } from "./nodes/ImageExtension.js";
|
|
52
29
|
import { MathExtension } from "./nodes/MathExtension.js";
|
|
30
|
+
import { MoveRangeBoundaryExtension } from "./nodes/MoveRangeBoundaryExtension.js";
|
|
53
31
|
import { PageBreakExtension } from "./nodes/PageBreakExtension.js";
|
|
54
32
|
import { PageBreakRunExtension } from "./nodes/PageBreakRunExtension.js";
|
|
33
|
+
import { PreservedBlockExtension } from "./nodes/PreservedBlockExtension.js";
|
|
34
|
+
import { PreservedXmlExtension } from "./nodes/PreservedXmlExtension.js";
|
|
35
|
+
import { RangeAnchorExtension } from "./nodes/RangeAnchorExtension.js";
|
|
55
36
|
import { RenderedPageBreakExtension } from "./nodes/RenderedPageBreakExtension.js";
|
|
56
37
|
import { SdtExtension } from "./nodes/SdtExtension.js";
|
|
57
38
|
import { ShapeExtension } from "./nodes/ShapeExtension.js";
|
|
@@ -82,42 +63,16 @@ function createStarterKit(options = {}) {
|
|
|
82
63
|
...options.historyDepth !== void 0 ? { depth: options.historyDepth } : {},
|
|
83
64
|
...options.historyNewGroupDelay !== void 0 ? { newGroupDelay: options.historyNewGroupDelay } : {}
|
|
84
65
|
}));
|
|
85
|
-
add(
|
|
86
|
-
add("italic", ItalicExtension());
|
|
87
|
-
add("underline", UnderlineExtension());
|
|
88
|
-
add("strike", StrikeExtension());
|
|
89
|
-
add("textColor", TextColorExtension());
|
|
90
|
-
add("runShading", RunShadingExtension());
|
|
91
|
-
add("highlight", HighlightExtension());
|
|
92
|
-
add("fontSize", FontSizeExtension());
|
|
93
|
-
add("fontFamily", FontFamilyExtension());
|
|
94
|
-
add("language", LanguageExtension());
|
|
95
|
-
add("superscript", SuperscriptExtension());
|
|
96
|
-
add("subscript", SubscriptExtension());
|
|
97
|
-
add("hyperlink", HyperlinkExtension());
|
|
98
|
-
add("allCaps", AllCapsExtension());
|
|
99
|
-
add("smallCaps", SmallCapsExtension());
|
|
100
|
-
add("footnoteRef", FootnoteRefExtension());
|
|
101
|
-
add("characterSpacing", CharacterSpacingExtension());
|
|
102
|
-
add("emboss", EmbossExtension());
|
|
103
|
-
add("imprint", ImprintExtension());
|
|
104
|
-
add("hidden", HiddenTextExtension());
|
|
105
|
-
add("textShadow", TextShadowExtension());
|
|
106
|
-
add("emphasisMark", EmphasisMarkExtension());
|
|
107
|
-
add("textOutline", TextOutlineExtension());
|
|
108
|
-
add("rtl", RtlExtension());
|
|
109
|
-
add("textEffect", TextEffectExtension());
|
|
110
|
-
add("runFormattingOverride", RunFormattingOverrideExtension());
|
|
111
|
-
add("characterStyle", CharacterStyleExtension());
|
|
112
|
-
add("pageBreakRunOwner", PageBreakRunOwnerExtension());
|
|
113
|
-
add("comment", CommentExtension());
|
|
114
|
-
add("insertion", InsertionExtension());
|
|
115
|
-
add("deletion", DeletionExtension());
|
|
116
|
-
add("runPropertyChange", RunPropertyChangeExtension());
|
|
66
|
+
for (const name of MARK_NESTING_ORDER) add(name, MARK_EXTENSIONS[name]());
|
|
117
67
|
add("bookmarkBoundary", BookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
68
|
+
add("blockBookmarkBoundary", BlockBookmarkBoundaryExtension());
|
|
69
|
+
add("commentReference", CommentReferenceExtension({ getInternalClipboardToken }));
|
|
70
|
+
add("moveRangeBoundary", MoveRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
71
|
+
add("rangeAnchor", RangeAnchorExtension({ getInternalClipboardToken }));
|
|
118
72
|
add("hardBreak", HardBreakExtension());
|
|
119
73
|
add("tab", TabExtension());
|
|
120
74
|
add("symbol", SymbolExtension());
|
|
75
|
+
add("preservedXml", PreservedXmlExtension());
|
|
121
76
|
add("image", ImageExtension());
|
|
122
77
|
add("textBox", TextBoxExtension());
|
|
123
78
|
add("textBoxAnchor", TextBoxAnchorExtension({ getInternalClipboardToken }));
|
|
@@ -134,6 +89,7 @@ function createStarterKit(options = {}) {
|
|
|
134
89
|
add("field", StructuredFieldExtension({ getInternalClipboardToken }));
|
|
135
90
|
add("sdt", SdtExtension());
|
|
136
91
|
add("blockSdt", BlockSdtExtension());
|
|
92
|
+
add("preservedBlock", PreservedBlockExtension());
|
|
137
93
|
add("math", MathExtension());
|
|
138
94
|
if (!disabled.has("table")) extensions.push(...createTableExtensions());
|
|
139
95
|
add("pasteCleanup", PasteCleanupExtension({ getInternalClipboardToken }));
|
|
@@ -13,7 +13,7 @@ const DocExtension = createNodeExtension({
|
|
|
13
13
|
_finalSectionStart: { default: null },
|
|
14
14
|
_adjustLineHeightInTable: { default: false }
|
|
15
15
|
},
|
|
16
|
-
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt)+"
|
|
16
|
+
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | preservedBlock | blockBookmarkBoundary)+"
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
//#endregion
|
|
@@ -6,12 +6,15 @@ import { collectHeadings } from "../../../utils/headingCollector.js";
|
|
|
6
6
|
import { tableOfContentsStyleLevel } from "../../../utils/tableOfContentsStyle.js";
|
|
7
7
|
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
8
8
|
import { autospacingMatchesBase } from "../../autospacingBase.js";
|
|
9
|
+
import { removeSectionBreakAtSelection, setSectionBreakType } from "../../commands/sectionBreak.js";
|
|
9
10
|
import { directParagraphAlignment } from "../../paragraphAlignment.js";
|
|
10
11
|
import { directionIsRtl } from "../../paragraphDirection.js";
|
|
11
12
|
import { withDirectParagraphSpacing } from "../../paragraphSpacing.js";
|
|
12
13
|
import { getDocumentBuiltInStyles } from "../../plugins/documentStyles.js";
|
|
14
|
+
import { mintSectionProperties, parseSectionBreakType, sectionBreakTypeOf } from "../../sectionCarrier.js";
|
|
13
15
|
import { listAttrsFromResolvedStyle, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
14
16
|
import { createNodeExtension } from "../create.js";
|
|
17
|
+
import { headingOutlineLevel, paragraphNumberingLevel, paragraphNumberingReferenceId } from "@stll/docx-core/model";
|
|
15
18
|
import { Fragment } from "prosemirror-model";
|
|
16
19
|
//#region src/prosemirror/extensions/core/ParagraphExtension.ts
|
|
17
20
|
/**
|
|
@@ -24,7 +27,7 @@ import { Fragment } from "prosemirror-model";
|
|
|
24
27
|
function paragraphAttrsToDOMStyle(attrs) {
|
|
25
28
|
const rawIndentLeft = Reflect.get(attrs, "indentLeft");
|
|
26
29
|
let indentLeft = typeof rawIndentLeft === "number" ? rawIndentLeft : void 0;
|
|
27
|
-
if (attrs.numPr
|
|
30
|
+
if (paragraphNumberingReferenceId(attrs.numPr) !== void 0 && (rawIndentLeft === null || rawIndentLeft === void 0)) indentLeft = ((paragraphNumberingLevel(attrs.numPr) ?? 0) + 1) * 720;
|
|
28
31
|
const style = paragraphToStyle({
|
|
29
32
|
...attrs.alignment !== void 0 ? { alignment: attrs.alignment } : {},
|
|
30
33
|
...attrs.spaceBefore !== void 0 ? { spaceBefore: attrs.spaceBefore } : {},
|
|
@@ -60,8 +63,8 @@ function numFmtToClass(numFmt) {
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
function getListClass(numPr, listIsBullet, listNumFmt) {
|
|
63
|
-
if (
|
|
64
|
-
const level = numPr
|
|
66
|
+
if (paragraphNumberingReferenceId(numPr) === void 0) return "";
|
|
67
|
+
const level = paragraphNumberingLevel(numPr) ?? 0;
|
|
65
68
|
if (listIsBullet) return `docx-list-bullet docx-list-level-${level}`;
|
|
66
69
|
return `docx-list-numbered ${numFmtToClass(listNumFmt)} docx-list-level-${level}`;
|
|
67
70
|
}
|
|
@@ -92,11 +95,11 @@ function cssLengthToTwips(value) {
|
|
|
92
95
|
*/
|
|
93
96
|
function cssTextAlignToAlignment(value) {
|
|
94
97
|
switch (value.trim().toLowerCase()) {
|
|
95
|
-
case "left":
|
|
96
|
-
case "start": return "
|
|
98
|
+
case "left": return "left";
|
|
99
|
+
case "start": return "start";
|
|
97
100
|
case "center": return "center";
|
|
98
|
-
case "right":
|
|
99
|
-
case "end": return "
|
|
101
|
+
case "right": return "right";
|
|
102
|
+
case "end": return "end";
|
|
100
103
|
case "justify": return "both";
|
|
101
104
|
default: return;
|
|
102
105
|
}
|
|
@@ -244,7 +247,6 @@ const paragraphNodeSpec = {
|
|
|
244
247
|
runInWithNext: { default: null },
|
|
245
248
|
defaultTextFormatting: { default: null },
|
|
246
249
|
_tableRunFormatting: { default: void 0 },
|
|
247
|
-
sectionBreakType: { default: null },
|
|
248
250
|
direction: { default: null },
|
|
249
251
|
outlineLevel: { default: null },
|
|
250
252
|
bookmarks: { default: null },
|
|
@@ -254,6 +256,7 @@ const paragraphNodeSpec = {
|
|
|
254
256
|
_autospacingBase: { default: null },
|
|
255
257
|
_sectionProperties: { default: null },
|
|
256
258
|
_propertyChanges: { default: null },
|
|
259
|
+
_preservedAttributes: { default: null },
|
|
257
260
|
pPrMark: { default: null },
|
|
258
261
|
_suggestedInsert: { default: null }
|
|
259
262
|
},
|
|
@@ -268,14 +271,14 @@ const paragraphNodeSpec = {
|
|
|
268
271
|
const alignmentFromStyle = parseParagraphAlignment(element.dataset["alignmentFromStyle"]);
|
|
269
272
|
const styleId = element.dataset["styleId"];
|
|
270
273
|
const tableOfContentsLevel = Number(element.dataset["tableOfContentsLevel"]);
|
|
271
|
-
const sectionBreakType = element.dataset["sectionBreak"];
|
|
274
|
+
const sectionBreakType = parseSectionBreakType(element.dataset["sectionBreak"]);
|
|
272
275
|
const attrs = {
|
|
273
276
|
...paraId ? { paraId } : {},
|
|
274
277
|
...alignment ? { alignment } : {},
|
|
275
278
|
...alignmentFromStyle ? { alignmentFromStyle } : {},
|
|
276
279
|
...styleId ? { styleId } : {},
|
|
277
280
|
...Number.isSafeInteger(tableOfContentsLevel) && tableOfContentsLevel > 0 ? { _tableOfContentsLevel: tableOfContentsLevel } : {},
|
|
278
|
-
...sectionBreakType ? { sectionBreakType } : {}
|
|
281
|
+
...sectionBreakType ? { _sectionProperties: mintSectionProperties(sectionBreakType) } : {}
|
|
279
282
|
};
|
|
280
283
|
const styleAttrs = extractParagraphAttrsFromStyle(element);
|
|
281
284
|
const mergedAlignment = attrs.alignment || styleAttrs.alignment;
|
|
@@ -303,11 +306,12 @@ const paragraphNodeSpec = {
|
|
|
303
306
|
getAttrs(dom) {
|
|
304
307
|
const level = Number.parseInt(tag.charAt(1), 10);
|
|
305
308
|
const styleAttrs = extractParagraphAttrsFromStyle(dom);
|
|
309
|
+
const outlineLevel = headingOutlineLevel(level - 1);
|
|
306
310
|
return {
|
|
307
311
|
...styleAttrs,
|
|
308
312
|
...styleAttrs.alignment ? { _originalFormatting: { alignment: styleAttrs.alignment } } : {},
|
|
309
313
|
styleId: `Heading${level}`,
|
|
310
|
-
outlineLevel:
|
|
314
|
+
...outlineLevel === void 0 ? {} : { outlineLevel }
|
|
311
315
|
};
|
|
312
316
|
}
|
|
313
317
|
}))],
|
|
@@ -327,8 +331,9 @@ const paragraphNodeSpec = {
|
|
|
327
331
|
if (typeof attrs._tableOfContentsLevel === "number") domAttrs["data-table-of-contents-level"] = String(attrs._tableOfContentsLevel);
|
|
328
332
|
if (attrs.listMarker) domAttrs["data-list-marker"] = attrs.listMarker;
|
|
329
333
|
if (directionIsRtl(attrs.direction)) domAttrs["dir"] = "rtl";
|
|
330
|
-
|
|
331
|
-
|
|
334
|
+
const sectionBreakType = sectionBreakTypeOf(attrs._sectionProperties);
|
|
335
|
+
if (sectionBreakType) {
|
|
336
|
+
domAttrs["data-section-break"] = sectionBreakType;
|
|
332
337
|
domAttrs["class"] = `${domAttrs["class"] ? `${domAttrs["class"]} ` : ""}docx-section-break`;
|
|
333
338
|
}
|
|
334
339
|
return [
|
|
@@ -603,8 +608,8 @@ const ParagraphExtension = createNodeExtension({
|
|
|
603
608
|
styleId: null,
|
|
604
609
|
_tableOfContentsLevel: null
|
|
605
610
|
}),
|
|
606
|
-
insertSectionBreak: (breakType) =>
|
|
607
|
-
removeSectionBreak: () =>
|
|
611
|
+
insertSectionBreak: (breakType) => setSectionBreakType(breakType),
|
|
612
|
+
removeSectionBreak: () => removeSectionBreakAtSelection,
|
|
608
613
|
generateTOC: ({ title }) => (state, dispatch) => {
|
|
609
614
|
const builtInStyles = getDocumentBuiltInStyles(state);
|
|
610
615
|
const headings = collectHeadings(state.doc, builtInStyles);
|
|
@@ -664,7 +669,7 @@ const ParagraphExtension = createNodeExtension({
|
|
|
664
669
|
instruction: `PAGEREF ${entry.name} \\h`,
|
|
665
670
|
displayText: "1",
|
|
666
671
|
fieldKind: "complex",
|
|
667
|
-
fldLock:
|
|
672
|
+
fldLock: null,
|
|
668
673
|
dirty: true
|
|
669
674
|
}));
|
|
670
675
|
tocNodes.push(s.node("paragraph", {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeTextFormatting } from "../../../utils/textFormattingMerge.js";
|
|
2
|
+
import { expectCharacterStyleMarkAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
|
|
3
|
+
import { keepSectionBreaksOnSurvivingMarks } from "../../commands/sectionBreak.js";
|
|
2
4
|
import { getDocumentStyleResolver } from "../../plugins/documentStyles.js";
|
|
5
|
+
import { RUN_FORMATTING_MARK_NAMES } from "../../runFormattingMarkNames.js";
|
|
6
|
+
import { authoredRunFormattingFromAttrs } from "../../runFormattingProvenance.js";
|
|
3
7
|
import { paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
4
8
|
import { createExtension } from "../create.js";
|
|
5
|
-
import { textFormattingToMarks } from "../marks/markUtils.js";
|
|
9
|
+
import { marksToTextFormatting, textFormattingToMarks } from "../marks/markUtils.js";
|
|
6
10
|
import { Priority } from "../types.js";
|
|
7
11
|
import { baseKeymap, deleteSelection, joinBackward, joinForward, selectAll, selectParentNode, splitBlock } from "prosemirror-commands";
|
|
8
12
|
//#region src/prosemirror/extensions/features/BaseKeymapExtension.ts
|
|
@@ -44,7 +48,7 @@ const clearIndentOnBackspace = (state, dispatch) => {
|
|
|
44
48
|
};
|
|
45
49
|
/**
|
|
46
50
|
* Custom Enter handler: splits the block, inherits style-related attrs,
|
|
47
|
-
* clears paragraph borders, and preserves
|
|
51
|
+
* clears paragraph borders, and preserves run formatting on the new paragraph.
|
|
48
52
|
*
|
|
49
53
|
* splitBlock creates a new paragraph with default attrs (all null),
|
|
50
54
|
* so we must manually copy style-related attrs from the source paragraph.
|
|
@@ -61,12 +65,31 @@ const INHERITED_PARA_ATTRS = [
|
|
|
61
65
|
"spaceBefore",
|
|
62
66
|
"contextualSpacing"
|
|
63
67
|
];
|
|
64
|
-
/**
|
|
68
|
+
/** Style formatting needed when the caret has no marks of its own. */
|
|
65
69
|
const STYLE_MARK_NAMES = /* @__PURE__ */ new Set([
|
|
66
70
|
"fontFamily",
|
|
67
71
|
"fontSize",
|
|
68
72
|
"textColor"
|
|
69
73
|
]);
|
|
74
|
+
const directFormattingFromMarks = (marks) => {
|
|
75
|
+
const override = marks.find(({ type }) => type.name === "runFormattingOverride");
|
|
76
|
+
const directFormatting = override ? authoredRunFormattingFromAttrs(expectRunFormattingOverrideMarkAttrs(override)) : void 0;
|
|
77
|
+
const characterStyle = marks.find(({ type }) => type.name === "characterStyle");
|
|
78
|
+
if (!characterStyle) return directFormatting;
|
|
79
|
+
return {
|
|
80
|
+
...directFormatting,
|
|
81
|
+
styleId: expectCharacterStyleMarkAttrs(characterStyle).styleId
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const marksForParagraphFormatting = (formatting, directFormatting, schema) => {
|
|
85
|
+
const marks = textFormattingToMarks(formatting, schema, {
|
|
86
|
+
authoredCarrier: "preserve",
|
|
87
|
+
directFormatting,
|
|
88
|
+
overrideFormatting: directFormatting
|
|
89
|
+
});
|
|
90
|
+
if (formatting.styleId) marks.push(schema.mark("characterStyle", { styleId: formatting.styleId }));
|
|
91
|
+
return marks;
|
|
92
|
+
};
|
|
70
93
|
/**
|
|
71
94
|
* If `sourcePara`'s style defines a `w:next`, replace the empty `newPara`
|
|
72
95
|
* with that style's resolved attrs and seed stored marks from its run
|
|
@@ -94,7 +117,8 @@ function applyNextParagraphStyle(tr, sourcePara, newPara, resolver) {
|
|
|
94
117
|
const splitBlockClearBorders = (state, dispatch, view) => {
|
|
95
118
|
const { $from: preSplitFrom } = state.selection;
|
|
96
119
|
const sourcePara = preSplitFrom.parent.type.name === "paragraph" ? preSplitFrom.parent : null;
|
|
97
|
-
const
|
|
120
|
+
const caretFormattingMarks = (state.storedMarks || preSplitFrom.marks()).filter((mark) => RUN_FORMATTING_MARK_NAMES.has(mark.type.name));
|
|
121
|
+
const resolver = getDocumentStyleResolver(state);
|
|
98
122
|
const splitResult = { tr: null };
|
|
99
123
|
if (!splitBlock(state, dispatch ? (tr) => {
|
|
100
124
|
splitResult.tr = tr;
|
|
@@ -104,8 +128,18 @@ const splitBlockClearBorders = (state, dispatch, view) => {
|
|
|
104
128
|
const { $from } = tr.selection;
|
|
105
129
|
const newPara = $from.parent;
|
|
106
130
|
if (newPara.type.name === "paragraph") {
|
|
107
|
-
const resolver = getDocumentStyleResolver(state);
|
|
108
131
|
if (resolver !== null && sourcePara !== null && newPara.content.size === 0 && applyNextParagraphStyle(tr, sourcePara, newPara, resolver)) {
|
|
132
|
+
const directFormatting = directFormattingFromMarks(caretFormattingMarks);
|
|
133
|
+
if (directFormatting && Object.keys(directFormatting).length > 0) {
|
|
134
|
+
const nextParagraph = tr.selection.$from.parent;
|
|
135
|
+
const nextStyleFormatting = nextParagraph.attrs["defaultTextFormatting"];
|
|
136
|
+
const defaultTextFormatting = mergeTextFormatting(nextStyleFormatting, directFormatting) ?? directFormatting;
|
|
137
|
+
tr.setNodeMarkup(tr.selection.$from.before(), void 0, {
|
|
138
|
+
...nextParagraph.attrs,
|
|
139
|
+
defaultTextFormatting
|
|
140
|
+
});
|
|
141
|
+
tr.setStoredMarks(marksForParagraphFormatting(defaultTextFormatting, directFormatting, state.schema));
|
|
142
|
+
}
|
|
109
143
|
dispatch(tr.scrollIntoView());
|
|
110
144
|
return true;
|
|
111
145
|
}
|
|
@@ -124,33 +158,18 @@ const splitBlockClearBorders = (state, dispatch, view) => {
|
|
|
124
158
|
}
|
|
125
159
|
if (attrsChanged) tr.setNodeMarkup($from.before(), void 0, newAttrs);
|
|
126
160
|
if (newPara.textContent.length === 0) {
|
|
127
|
-
let effectiveMarks =
|
|
161
|
+
let effectiveMarks = caretFormattingMarks;
|
|
128
162
|
if (effectiveMarks.length === 0 && sourcePara) {
|
|
129
163
|
const dtf = sourcePara.attrs["defaultTextFormatting"];
|
|
130
164
|
if (dtf) effectiveMarks = textFormattingToMarks(dtf, state.schema).filter((m) => STYLE_MARK_NAMES.has(m.type.name));
|
|
131
165
|
}
|
|
132
166
|
if (effectiveMarks.length > 0) {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
dtf.fontSize = m.attrs["size"];
|
|
138
|
-
dtfChanged = true;
|
|
139
|
-
}
|
|
140
|
-
if (m.type.name === "fontFamily") {
|
|
141
|
-
const ascii = m.attrs["ascii"];
|
|
142
|
-
if (ascii && (!dtf.fontFamily || dtf.fontFamily.ascii !== ascii)) {
|
|
143
|
-
const nextFontFamily = { ascii };
|
|
144
|
-
const hAnsi = m.attrs["hAnsi"];
|
|
145
|
-
if (hAnsi !== void 0) nextFontFamily.hAnsi = hAnsi;
|
|
146
|
-
dtf.fontFamily = mergeFontFamily(dtf.fontFamily, nextFontFamily);
|
|
147
|
-
dtfChanged = true;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (dtfChanged) tr.setNodeMarkup($from.before(), void 0, {
|
|
167
|
+
const previousFormatting = newAttrs["defaultTextFormatting"];
|
|
168
|
+
const markFormatting = marksToTextFormatting(effectiveMarks);
|
|
169
|
+
const defaultTextFormatting = mergeTextFormatting(previousFormatting, markFormatting) ?? markFormatting;
|
|
170
|
+
tr.setNodeMarkup($from.before(), void 0, {
|
|
152
171
|
...newAttrs,
|
|
153
|
-
defaultTextFormatting
|
|
172
|
+
defaultTextFormatting
|
|
154
173
|
});
|
|
155
174
|
tr.setStoredMarks(effectiveMarks);
|
|
156
175
|
}
|
|
@@ -167,8 +186,8 @@ const BaseKeymapExtension = createExtension({
|
|
|
167
186
|
return { keyboardShortcuts: {
|
|
168
187
|
...baseKeymap,
|
|
169
188
|
Enter: splitBlockClearBorders,
|
|
170
|
-
Backspace: chainCommands(deleteSelection, clearIndentOnBackspace, joinBackward),
|
|
171
|
-
Delete: chainCommands(deleteSelection, joinForward),
|
|
189
|
+
Backspace: keepSectionBreaksOnSurvivingMarks(chainCommands(deleteSelection, clearIndentOnBackspace, joinBackward)),
|
|
190
|
+
Delete: keepSectionBreaksOnSurvivingMarks(chainCommands(deleteSelection, joinForward)),
|
|
172
191
|
"Mod-a": selectAll,
|
|
173
192
|
Escape: selectParentNode
|
|
174
193
|
} };
|
|
@@ -11,8 +11,9 @@ const emptyParagraphFormatKey = new PluginKey("emptyParagraphFormat");
|
|
|
11
11
|
* must be one `textFormattingToMarks` can turn into a mark, or the gate would
|
|
12
12
|
* open for work that produces nothing.
|
|
13
13
|
*/
|
|
14
|
+
const FONT_ONLY_DEFAULTS = /* @__PURE__ */ new Set(["fontFamily", "fontSize"]);
|
|
14
15
|
function hasNonFontDefaults(dtf) {
|
|
15
|
-
return
|
|
16
|
+
return Object.entries(dtf).some(([property, value]) => value !== void 0 && !FONT_ONLY_DEFAULTS.has(property));
|
|
16
17
|
}
|
|
17
18
|
function createEmptyParagraphFormatPlugin(schema) {
|
|
18
19
|
return new Plugin({
|
|
@@ -27,6 +28,7 @@ function createEmptyParagraphFormatPlugin(schema) {
|
|
|
27
28
|
const dtf = para.attrs["defaultTextFormatting"];
|
|
28
29
|
if (!dtf || !hasNonFontDefaults(dtf)) return null;
|
|
29
30
|
const marks = textFormattingToMarks(dtf, schema);
|
|
31
|
+
if (dtf.styleId) marks.push(schema.mark("characterStyle", { styleId: dtf.styleId }));
|
|
30
32
|
if (marks.length === 0) return null;
|
|
31
33
|
const tr = newState.tr.setStoredMarks(marks);
|
|
32
34
|
tr.setMeta("addToHistory", false);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FOLIO_INSERTED_PICTURE_FRAME_LOCKS } from "../../../docx/graphicFrameLocks.js";
|
|
2
|
+
import { getStandaloneClipboardImageFiles } from "../../../utils/clipboard.js";
|
|
2
3
|
import { isSafeImageFile } from "../../../utils/imageValidation.js";
|
|
3
4
|
import { sanitizeImageSrc } from "../../../utils/sanitizeImageSrc.js";
|
|
4
5
|
import { createExtension } from "../create.js";
|
|
@@ -73,7 +74,8 @@ async function insertImageFiles(view, files) {
|
|
|
73
74
|
height,
|
|
74
75
|
rId: `rId_img_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
75
76
|
wrapType: "inline",
|
|
76
|
-
displayMode: "inline"
|
|
77
|
+
displayMode: "inline",
|
|
78
|
+
frameLocks: FOLIO_INSERTED_PICTURE_FRAME_LOCKS
|
|
77
79
|
});
|
|
78
80
|
const tr = view.state.tr.insert(insertPos, imageNode);
|
|
79
81
|
insertPos += imageNode.nodeSize;
|
|
@@ -86,7 +88,7 @@ const ImagePasteExtension = createExtension({
|
|
|
86
88
|
name: "imagePaste",
|
|
87
89
|
onSchemaReady(_ctx) {
|
|
88
90
|
return { plugins: [new Plugin({ props: { handleDOMEvents: { paste(view, event) {
|
|
89
|
-
const imageFiles =
|
|
91
|
+
const imageFiles = getStandaloneClipboardImageFiles(event.clipboardData);
|
|
90
92
|
if (imageFiles.length === 0) return false;
|
|
91
93
|
if (!view.state.schema.nodes["image"]) return false;
|
|
92
94
|
event.preventDefault();
|