@stll/folio-core 0.52.0 → 0.54.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/README.md +23 -0
- package/dist/ai-edits/apply.d.ts +26 -1
- package/dist/ai-edits/apply.js +1779 -141
- package/dist/ai-edits/batch-claims.d.ts +145 -0
- package/dist/ai-edits/batch-claims.js +275 -0
- package/dist/ai-edits/blockRange.js +9 -3
- package/dist/ai-edits/character-boundaries.d.ts +43 -0
- package/dist/ai-edits/character-boundaries.js +95 -0
- package/dist/ai-edits/clean-text.d.ts +33 -3
- package/dist/ai-edits/clean-text.js +52 -6
- package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
- package/dist/ai-edits/comment-lifecycle.js +52 -0
- package/dist/ai-edits/headless.d.ts +91 -7
- package/dist/ai-edits/headless.js +520 -51
- package/dist/ai-edits/index.d.ts +2 -1
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/minimal-replacement.d.ts +21 -6
- package/dist/ai-edits/minimal-replacement.js +134 -15
- package/dist/ai-edits/newListNumbering.d.ts +23 -0
- package/dist/ai-edits/newListNumbering.js +94 -0
- package/dist/ai-edits/note-references.d.ts +96 -0
- package/dist/ai-edits/note-references.js +139 -0
- package/dist/ai-edits/pending-suggestions.d.ts +79 -0
- package/dist/ai-edits/pending-suggestions.js +306 -0
- package/dist/ai-edits/read.d.ts +6 -4
- package/dist/ai-edits/read.js +113 -50
- package/dist/ai-edits/result-validation.d.ts +29 -0
- package/dist/ai-edits/result-validation.js +164 -0
- package/dist/ai-edits/revisionStretches.d.ts +17 -0
- package/dist/ai-edits/revisionStretches.js +80 -0
- package/dist/ai-edits/snapshot.d.ts +36 -3
- package/dist/ai-edits/snapshot.js +180 -25
- package/dist/ai-edits/table-cell-mutations.d.ts +4 -2
- package/dist/ai-edits/table-cell-mutations.js +6 -2
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +44 -17
- package/dist/ai-edits/table-row-column-mutations.js +86 -34
- package/dist/ai-edits/types.d.ts +155 -16
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/compare.js +65 -16
- package/dist/compare/content-alignment.d.ts +5 -1
- package/dist/compare/content-alignment.js +52 -34
- package/dist/compare/content-types.d.ts +7 -0
- package/dist/compare/content.d.ts +4 -1
- package/dist/compare/content.js +6 -1
- package/dist/compare/formatting.js +2 -1
- package/dist/compare/inline-atoms.d.ts +21 -4
- package/dist/compare/inline-atoms.js +138 -16
- package/dist/compare/inline-provenance.js +1 -1
- package/dist/compare/plan.js +10 -5
- package/dist/compare/scenario.js +14 -3
- package/dist/compare/section-boundary-properties.js +1 -1
- package/dist/compare/types.d.ts +4 -2
- package/dist/compare/types.js +2 -1
- package/dist/compare/verification.d.ts +1 -1
- package/dist/compare/verification.js +15 -3
- package/dist/controller/committedLayoutDiff.d.ts +25 -0
- package/dist/controller/committedLayoutDiff.js +71 -0
- package/dist/controller/contentControlWidgetController.d.ts +1 -1
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/fontReadiness.d.ts +70 -3
- package/dist/controller/fontReadiness.js +100 -10
- package/dist/controller/headerFooterEditorManager.js +6 -1
- package/dist/controller/layoutPipeline.d.ts +12 -10
- package/dist/controller/layoutPipeline.js +65 -11
- package/dist/controller/layoutRunOptions.d.ts +24 -0
- package/dist/controller/layoutRunOptions.js +17 -0
- package/dist/controller/layoutScheduler.d.ts +19 -14
- package/dist/controller/layoutScheduler.js +15 -12
- package/dist/controller/layoutSession.d.ts +26 -2
- package/dist/controller/layoutSession.js +1 -1
- package/dist/controller/noteEditorManager.js +8 -3
- package/dist/document-operations.d.ts +11 -2
- package/dist/document-operations.js +230 -21
- package/dist/docx/altChunk.d.ts +8 -0
- package/dist/docx/altChunk.js +17 -0
- package/dist/docx/archiveInflation.d.ts +127 -0
- package/dist/docx/archiveInflation.js +181 -0
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/blockContentParser.d.ts +64 -1
- package/dist/docx/blockContentParser.js +17 -4
- package/dist/docx/blockCustomXmlShell.d.ts +7 -0
- package/dist/docx/blockCustomXmlShell.js +14 -0
- package/dist/docx/blockPlainText.js +7 -0
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentRangeIntegrity.js +8 -3
- package/dist/docx/commentReferenceNormalization.js +1 -1
- package/dist/docx/commentReplyMarkers.js +20 -1
- package/dist/docx/compatibility.d.ts +1 -1
- package/dist/docx/compatibility.js +34 -13
- package/dist/docx/containerChildren.gen.d.ts +1 -1
- package/dist/docx/containerChildren.gen.js +1 -0
- package/dist/docx/documentParser.js +12 -12
- package/dist/docx/drawingIdNormalization.d.ts +3 -1
- package/dist/docx/drawingIdNormalization.js +6 -1
- package/dist/docx/ensureParaIds.js +119 -97
- package/dist/docx/footnoteParser.js +8 -4
- package/dist/docx/headerFooterParser.js +3 -3
- package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
- package/dist/docx/headerFooterReferenceNormalization.js +52 -27
- package/dist/docx/hyperlinkParser.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listNumberingInstances.d.ts +59 -0
- package/dist/docx/listNumberingInstances.js +249 -0
- package/dist/docx/metadataPrivacy.js +24 -1
- package/dist/docx/normalizeBaseDirection.js +2 -1
- package/dist/docx/noteReferenceMark.d.ts +15 -0
- package/dist/docx/noteReferenceMark.js +48 -0
- package/dist/docx/opaqueCarrier.d.ts +7 -0
- package/dist/docx/opaqueCarrier.js +38 -0
- package/dist/docx/packageParts.js +4 -1
- package/dist/docx/paragraphParser.js +96 -27
- package/dist/docx/paragraphPropertySource.d.ts +4 -2
- package/dist/docx/paragraphPropertySource.js +10 -2
- package/dist/docx/paragraphTraversal.js +1 -0
- package/dist/docx/parseWarningMessage.js +4 -1
- package/dist/docx/parser.js +175 -22
- package/dist/docx/rezip.js +31 -7
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sdtPropertiesPatch.js +3 -0
- package/dist/docx/selectiveSave.js +16 -9
- package/dist/docx/selectiveXmlPatch.d.ts +3 -1
- package/dist/docx/selectiveXmlPatch.js +186 -39
- package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
- package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
- package/dist/docx/serializer/documentSerializer.js +2 -0
- package/dist/docx/serializer/headerFooterSerializer.js +2 -0
- package/dist/docx/serializer/noteSerializer.js +3 -1
- package/dist/docx/serializer/paragraphSerializer.js +33 -9
- package/dist/docx/serializer/tableSerializer.js +25 -38
- package/dist/docx/server/boundedArchive.d.ts +8 -13
- package/dist/docx/server/boundedArchive.js +70 -59
- package/dist/docx/server/createBilingualDocument.js +3 -3
- package/dist/docx/server/extractDocxText.d.ts +8 -2
- package/dist/docx/server/extractDocxText.js +2 -2
- package/dist/docx/server/validateDocxConformance.d.ts +1 -1
- package/dist/docx/server/validateDocxConformance.js +1 -0
- package/dist/docx/tableParser.d.ts +157 -1
- package/dist/docx/tableParser.js +89 -10
- package/dist/docx/textBoxParser.js +1 -1
- package/dist/docx/unzip.d.ts +20 -2
- package/dist/docx/unzip.js +136 -25
- package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
- package/dist/docx/wordprocessingPrefixes.js +286 -0
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +170 -34
- package/dist/i18n/messages/catalogs.gen.js +187 -51
- package/dist/i18n/messages/messages.gen.d.ts +10 -2
- package/dist/internal/compare/inline-presentation.d.ts +2 -1
- package/dist/internal/compare/inline-presentation.js +11 -10
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
- package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
- package/dist/internal/indexedPositionMap.d.ts +11 -0
- package/dist/internal/indexedPositionMap.js +42 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/revisionResolutionEdits.d.ts +13 -0
- package/dist/internal/revisionResolutionEdits.js +19 -0
- package/dist/internal/revisionResolutionInline.d.ts +24 -0
- package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
- package/dist/internal/revisionResolutionStep.d.ts +34 -0
- package/dist/internal/revisionResolutionStep.js +282 -0
- package/dist/internal/revisionResolutionTracking.d.ts +11 -0
- package/dist/internal/revisionResolutionTracking.js +124 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
- package/dist/internal/wholeStoryRevisionResolution.js +600 -0
- package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
- package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
- package/dist/layout-bridge/convert/tableConversion.js +1 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
- package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
- package/dist/layout-engine/layoutInstrumentation.js +4 -1
- package/dist/layout-engine/measure/cache.d.ts +18 -1
- package/dist/layout-engine/measure/cache.js +31 -1
- package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
- package/dist/layout-engine/measure/measureContainer.js +7 -47
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
- package/dist/layout-engine/measure/measureHelpers.js +22 -2
- package/dist/layout-engine/measure/measureParagraph.js +2 -2
- package/dist/layout-engine/measure/measureWorker.js +2 -3
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
- package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
- package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +12 -1
- package/dist/layout-engine/measure/paragraphMeasureShared.js +14 -1
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/renderPage.js +1 -0
- package/dist/layout-painter/renderParagraph.js +1 -1
- package/dist/managers/ContextMenuManager.js +5 -2
- package/dist/managers/types.d.ts +3 -0
- package/dist/markdown/escape.d.ts +2 -2
- package/dist/markdown/escape.js +4 -5
- package/dist/markdown/fromMarkdown.js +2 -1
- package/dist/markdown/internals.d.ts +11 -1
- package/dist/markdown/internals.js +24 -3
- package/dist/markdown/renderBlock.js +121 -25
- package/dist/markdown/renderParagraph.d.ts +13 -1
- package/dist/markdown/renderParagraph.js +85 -38
- package/dist/markdown/renderRuns.d.ts +10 -1
- package/dist/markdown/renderRuns.js +323 -69
- package/dist/markdown/renderTable.js +24 -12
- package/dist/markdown/trailers.js +2 -2
- package/dist/markdown/types.d.ts +29 -7
- package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
- package/dist/paged-layout/incrementalMeasure.js +1 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
- package/dist/paged-layout/transactionDirtyRange.js +29 -41
- package/dist/panel-layout.d.ts +83 -0
- package/dist/panel-layout.js +96 -0
- package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
- package/dist/prosemirror/anchoredTextBoxes.js +156 -0
- package/dist/prosemirror/attrs/index.d.ts +6 -2
- package/dist/prosemirror/attrs/index.js +172 -1
- package/dist/prosemirror/clearRunColor.d.ts +6 -0
- package/dist/prosemirror/clearRunColor.js +46 -0
- package/dist/prosemirror/commands/comments.d.ts +7 -8
- package/dist/prosemirror/commands/comments.js +281 -212
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.js +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/hyperlink.js +2 -1
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +7 -1
- package/dist/prosemirror/commands/paragraph.js +9 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +3 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +24 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +620 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +73 -0
- package/dist/prosemirror/commands/sectionBreak.js +2 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +15 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.js +23 -7
- package/dist/prosemirror/containerFinalParagraph.d.ts +11 -5
- package/dist/prosemirror/containerFinalParagraph.js +7 -6
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +177 -605
- package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -11
- package/dist/prosemirror/conversion/toProseDoc.js +70 -154
- package/dist/prosemirror/documentSchema.d.ts +8 -0
- package/dist/prosemirror/documentSchema.js +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
- package/dist/prosemirror/extensions/StarterKit.js +5 -1
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +116 -63
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +4 -1
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +24 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +43 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +167 -128
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +124 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +33 -11
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +8 -4
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +15 -8
- package/dist/prosemirror/extensions/marks/markUtils.js +25 -10
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +2 -2
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +5 -3
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +121 -226
- package/dist/prosemirror/extensions/types.d.ts +11 -1
- package/dist/prosemirror/findReplaceSelection.js +1 -1
- package/dist/prosemirror/hyperlinkRemoval.d.ts +9 -0
- package/dist/prosemirror/hyperlinkRemoval.js +129 -0
- package/dist/prosemirror/index.d.ts +5 -3
- package/dist/prosemirror/index.js +5 -3
- package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
- package/dist/prosemirror/indexedNodeLookup.js +103 -0
- package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
- package/dist/prosemirror/listAutoformatMarkers.js +98 -0
- package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
- package/dist/prosemirror/listInstanceReferences.js +72 -0
- package/dist/prosemirror/listLabels.d.ts +24 -0
- package/dist/prosemirror/listLabels.js +111 -0
- package/dist/prosemirror/listNumbering.d.ts +92 -0
- package/dist/prosemirror/listNumbering.js +330 -0
- package/dist/prosemirror/listRendering.d.ts +27 -0
- package/dist/prosemirror/listRendering.js +27 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
- package/dist/prosemirror/listRenderingAttrs.js +8 -1
- package/dist/prosemirror/markupViewNotes.d.ts +8 -0
- package/dist/prosemirror/markupViewNotes.js +49 -0
- package/dist/prosemirror/markupViewProjection.d.ts +97 -0
- package/dist/prosemirror/markupViewProjection.js +88 -0
- package/dist/prosemirror/noteReferenceReview.d.ts +77 -0
- package/dist/prosemirror/noteReferenceReview.js +332 -0
- package/dist/prosemirror/numberingAttr.d.ts +9 -1
- package/dist/prosemirror/numberingAttr.js +9 -1
- package/dist/prosemirror/outlineLevelAttr.js +1 -1
- package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
- package/dist/prosemirror/paragraphIndentation.js +32 -7
- package/dist/prosemirror/paragraphMarkJoin.d.ts +21 -0
- package/dist/prosemirror/paragraphMarkJoin.js +26 -0
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +64 -0
- package/dist/prosemirror/paragraphPropertyCarry.js +158 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
- package/dist/prosemirror/plugins/documentNumbering.js +97 -11
- package/dist/prosemirror/plugins/documentStyleState.d.ts +26 -0
- package/dist/prosemirror/plugins/documentStyleState.js +32 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +3 -13
- package/dist/prosemirror/plugins/documentStyles.js +67 -17
- package/dist/prosemirror/plugins/index.d.ts +2 -1
- package/dist/prosemirror/plugins/index.js +2 -1
- package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +15 -0
- package/dist/prosemirror/plugins/paragraphStyleResolution.js +230 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +27 -3
- package/dist/prosemirror/plugins/suggestionMode.js +490 -63
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
- package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
- package/dist/prosemirror/positionSweep.d.ts +24 -0
- package/dist/prosemirror/positionSweep.js +222 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +23 -3
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +39 -13
- package/dist/prosemirror/rebaseParagraphRuns.d.ts +36 -0
- package/dist/prosemirror/rebaseParagraphRuns.js +99 -0
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
- package/dist/prosemirror/replacedAnnotations.js +170 -1
- package/dist/prosemirror/runFormattingFromMarks.d.ts +18 -0
- package/dist/prosemirror/runFormattingFromMarks.js +567 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/runFormattingReconciliation.js +10 -9
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +44 -11
- package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
- package/dist/prosemirror/sectionMarkEdits.js +59 -0
- package/dist/prosemirror/storyListNumbering.d.ts +17 -0
- package/dist/prosemirror/storyListNumbering.js +102 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +59 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +145 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +21 -2
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +38 -1
- package/dist/prosemirror/styles/tableStyleRegions.d.ts +31 -0
- package/dist/prosemirror/styles/tableStyleRegions.js +55 -0
- package/dist/prosemirror/tableCellPaste.d.ts +74 -0
- package/dist/prosemirror/tableCellPaste.js +525 -0
- package/dist/prosemirror/tableGridMutation.d.ts +87 -2
- package/dist/prosemirror/tableGridMutation.js +255 -2
- package/dist/prosemirror/tableRunIn.d.ts +51 -0
- package/dist/prosemirror/tableRunIn.js +165 -0
- package/dist/prosemirror/textInput.js +11 -2
- package/dist/prosemirror/trackedRevisionPath.d.ts +17 -0
- package/dist/prosemirror/trackedRevisionPath.js +32 -0
- package/dist/prosemirror/validation.js +5 -1
- package/dist/redline.js +93 -9
- package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
- package/dist/render-dom/BodySelectionOverlay.js +3 -2
- package/dist/server.d.ts +2 -2
- package/dist/utils/findReplace.js +2 -2
- package/dist/utils/mergeDocumentContent.js +1 -1
- package/dist/utils/noteReferenceLabels.d.ts +36 -0
- package/dist/utils/noteReferenceLabels.js +32 -0
- package/dist/utils/replaceText.js +1 -1
- package/dist/version-comparison.d.ts +1 -0
- package/dist/version-comparison.js +1 -0
- package/package.json +6 -5
- package/dist/internal/headlessRevisionResolution.d.ts +0 -23
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BUILT_IN_STYLE_NAME } from "../../../docx/builtInStyles.js";
|
|
2
2
|
import { PROSE_PARAGRAPH_SOURCE_TOKEN_ATTR } from "../../../docx/paragraphPropertySource.js";
|
|
3
|
+
import { isStyleSourcedParagraphNumbering } from "../../../internal/paragraphFormattingSerialization.js";
|
|
3
4
|
import { PARAGRAPH_ALIGNMENT_VALUES } from "../../../types/documentEnumValues.js";
|
|
4
5
|
import { paragraphToStyle } from "../../../utils/formatToStyle.js";
|
|
5
6
|
import { collectHeadings } from "../../../utils/headingCollector.js";
|
|
@@ -7,12 +8,16 @@ import { tableOfContentsStyleLevel } from "../../../utils/tableOfContentsStyle.j
|
|
|
7
8
|
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
8
9
|
import { autospacingMatchesBase } from "../../autospacingBase.js";
|
|
9
10
|
import { removeSectionBreakAtSelection, setSectionBreakType } from "../../commands/sectionBreak.js";
|
|
11
|
+
import { CLEARED_LIST_RENDERING_ATTRS } from "../../listMarker.js";
|
|
10
12
|
import { directParagraphAlignment } from "../../paragraphAlignment.js";
|
|
11
13
|
import { directionIsRtl } from "../../paragraphDirection.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
+
import { directParagraphIndentation } from "../../paragraphIndentation.js";
|
|
15
|
+
import { directParagraphSpacing, withDirectParagraphSpacing } from "../../paragraphSpacing.js";
|
|
16
|
+
import { getDocumentNumbering } from "../../plugins/documentNumbering.js";
|
|
17
|
+
import { getDocumentBuiltInStyles, getDocumentStyleResolver } from "../../plugins/documentStyleState.js";
|
|
18
|
+
import { rebaseParagraphRuns } from "../../rebaseParagraphRuns.js";
|
|
14
19
|
import { mintSectionProperties, parseSectionBreakType, sectionBreakTypeOf } from "../../sectionCarrier.js";
|
|
15
|
-
import { listAttrsFromResolvedStyle, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
20
|
+
import { listAttrsFromResolvedStyle, listLevelIndentAttrPatch, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
16
21
|
import { createNodeExtension } from "../create.js";
|
|
17
22
|
import { headingOutlineLevel, paragraphNumberingLevel, paragraphNumberingReferenceId } from "@stll/docx-core/model";
|
|
18
23
|
import { Fragment } from "prosemirror-model";
|
|
@@ -213,6 +218,7 @@ const paragraphNodeSpec = {
|
|
|
213
218
|
indentFirstLine: { default: null },
|
|
214
219
|
hangingIndent: { default: false },
|
|
215
220
|
numPr: { default: null },
|
|
221
|
+
_pastedHtmlList: { default: void 0 },
|
|
216
222
|
numPrFromStyle: { default: null },
|
|
217
223
|
listNumFmt: { default: null },
|
|
218
224
|
listIsBullet: { default: null },
|
|
@@ -273,11 +279,22 @@ const paragraphNodeSpec = {
|
|
|
273
279
|
const styleId = element.dataset["styleId"];
|
|
274
280
|
const tableOfContentsLevel = Number(element.dataset["tableOfContentsLevel"]);
|
|
275
281
|
const sectionBreakType = parseSectionBreakType(element.dataset["sectionBreak"]);
|
|
282
|
+
const pastedListGroup = Number(element.dataset["folioListGroup"]);
|
|
283
|
+
const pastedListLevel = Number(element.dataset["folioListLevel"]);
|
|
284
|
+
const pastedListKind = element.dataset["folioListKind"];
|
|
285
|
+
const pastedListStart = Number(element.dataset["folioListStart"]);
|
|
286
|
+
const pastedHtmlList = Number.isSafeInteger(pastedListGroup) && pastedListGroup > 0 && Number.isSafeInteger(pastedListLevel) && pastedListLevel >= 0 && pastedListLevel <= 8 && (pastedListKind === "bullet" || pastedListKind === "numbered") ? {
|
|
287
|
+
group: pastedListGroup,
|
|
288
|
+
level: pastedListLevel,
|
|
289
|
+
kind: pastedListKind,
|
|
290
|
+
...Number.isSafeInteger(pastedListStart) && pastedListStart > 0 ? { start: pastedListStart } : {}
|
|
291
|
+
} : void 0;
|
|
276
292
|
const attrs = {
|
|
277
293
|
...paraId ? { paraId } : {},
|
|
278
294
|
...alignment ? { alignment } : {},
|
|
279
295
|
...alignmentFromStyle ? { alignmentFromStyle } : {},
|
|
280
296
|
...styleId ? { styleId } : {},
|
|
297
|
+
...pastedHtmlList ? { _pastedHtmlList: pastedHtmlList } : {},
|
|
281
298
|
...Number.isSafeInteger(tableOfContentsLevel) && tableOfContentsLevel > 0 ? { _tableOfContentsLevel: tableOfContentsLevel } : {},
|
|
282
299
|
...sectionBreakType ? { _sectionProperties: mintSectionProperties(sectionBreakType) } : {}
|
|
283
300
|
};
|
|
@@ -387,6 +404,51 @@ function setParagraphSpacingAttr(side, twips) {
|
|
|
387
404
|
return true;
|
|
388
405
|
};
|
|
389
406
|
}
|
|
407
|
+
const DIRECT_PARAGRAPH_TOGGLES = [
|
|
408
|
+
"outlineLevel",
|
|
409
|
+
"borders",
|
|
410
|
+
"shading",
|
|
411
|
+
"tabs",
|
|
412
|
+
"keepNext",
|
|
413
|
+
"keepLines",
|
|
414
|
+
"widowControl",
|
|
415
|
+
"pageBreakBefore",
|
|
416
|
+
"contextualSpacing"
|
|
417
|
+
];
|
|
418
|
+
/** The attrs a paragraph states itself, over whatever style it reads. */
|
|
419
|
+
function directParagraphAttrs(attrs) {
|
|
420
|
+
const direct = {};
|
|
421
|
+
const alignment = directParagraphAlignment(attrs);
|
|
422
|
+
if (alignment !== void 0) direct["alignment"] = alignment;
|
|
423
|
+
const spacing = directParagraphSpacing(attrs);
|
|
424
|
+
for (const key of [
|
|
425
|
+
"spaceBefore",
|
|
426
|
+
"spaceAfter",
|
|
427
|
+
"lineSpacing",
|
|
428
|
+
"lineSpacingRule"
|
|
429
|
+
]) if (spacing?.[key] !== void 0) direct[key] = spacing[key];
|
|
430
|
+
const indentation = directParagraphIndentation(attrs);
|
|
431
|
+
if (indentation?.indentLeft !== void 0) direct["indentLeft"] = indentation.indentLeft;
|
|
432
|
+
if (indentation?.indentRight !== void 0) direct["indentRight"] = indentation.indentRight;
|
|
433
|
+
if (indentation?.indentFirstLine !== void 0) {
|
|
434
|
+
direct["indentFirstLine"] = Math.abs(indentation.indentFirstLine);
|
|
435
|
+
direct["hangingIndent"] = indentation.hangingIndent === true;
|
|
436
|
+
}
|
|
437
|
+
const original = attrs._originalFormatting;
|
|
438
|
+
for (const key of DIRECT_PARAGRAPH_TOGGLES) if (original?.[key] !== void 0) direct[key] = attrs[key];
|
|
439
|
+
return direct;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* The indentation a restyled paragraph still states itself: a field its
|
|
443
|
+
* source stated that the new style's attrs keep a value for. Every other
|
|
444
|
+
* field now reads the style's value, which a save leaves to the style.
|
|
445
|
+
*/
|
|
446
|
+
function restyledIndentation(styleAttrs, originalFormatting) {
|
|
447
|
+
const stated = {};
|
|
448
|
+
if (originalFormatting?.indentLeft !== void 0 && typeof styleAttrs.indentLeft === "number") stated.indentLeft = styleAttrs.indentLeft;
|
|
449
|
+
if (originalFormatting?.indentFirstLine !== void 0 && typeof styleAttrs.indentFirstLine === "number") stated.indentFirstLine = styleAttrs.indentFirstLine;
|
|
450
|
+
return stated;
|
|
451
|
+
}
|
|
390
452
|
function setParagraphAttrsCmd(attrs) {
|
|
391
453
|
return (state, dispatch) => {
|
|
392
454
|
const { $from, $to } = state.selection;
|
|
@@ -467,9 +529,10 @@ function makeDecreaseIndent(amount = 720) {
|
|
|
467
529
|
seen.add(pos);
|
|
468
530
|
const currentIndent = node.attrs["indentLeft"] || 0;
|
|
469
531
|
const newIndent = Math.max(0, currentIndent - amount);
|
|
532
|
+
const numbered = paragraphNumberingReferenceId(expectParagraphAttrs(node).numPr ?? void 0) !== void 0;
|
|
470
533
|
tr = tr.setNodeMarkup(pos, void 0, {
|
|
471
534
|
...node.attrs,
|
|
472
|
-
indentLeft: newIndent > 0 ? newIndent : null
|
|
535
|
+
indentLeft: newIndent > 0 || numbered ? newIndent : null
|
|
473
536
|
});
|
|
474
537
|
}
|
|
475
538
|
});
|
|
@@ -477,79 +540,61 @@ function makeDecreaseIndent(amount = 720) {
|
|
|
477
540
|
return true;
|
|
478
541
|
};
|
|
479
542
|
}
|
|
480
|
-
function makeApplyStyle(
|
|
543
|
+
function makeApplyStyle() {
|
|
481
544
|
return (styleId, resolvedAttrs) => (state, dispatch) => {
|
|
482
545
|
const { $from, $to } = state.selection;
|
|
483
546
|
if (!dispatch) return true;
|
|
484
547
|
let tr = state.tr;
|
|
485
548
|
const seen = /* @__PURE__ */ new Set();
|
|
486
|
-
const styleMarks = [];
|
|
487
|
-
if (resolvedAttrs?.runFormatting) {
|
|
488
|
-
const rpr = resolvedAttrs.runFormatting;
|
|
489
|
-
if (rpr.bold && schema.marks["bold"]) styleMarks.push(schema.marks["bold"].create());
|
|
490
|
-
if (rpr.italic && schema.marks["italic"]) styleMarks.push(schema.marks["italic"].create());
|
|
491
|
-
if (rpr.fontSize && schema.marks["fontSize"]) styleMarks.push(schema.marks["fontSize"].create({ size: rpr.fontSize }));
|
|
492
|
-
if (rpr.fontFamily && schema.marks["fontFamily"]) styleMarks.push(schema.marks["fontFamily"].create({
|
|
493
|
-
ascii: rpr.fontFamily.ascii,
|
|
494
|
-
hAnsi: rpr.fontFamily.hAnsi,
|
|
495
|
-
asciiTheme: rpr.fontFamily.asciiTheme
|
|
496
|
-
}));
|
|
497
|
-
if (rpr.color && !rpr.color.auto && schema.marks["textColor"]) styleMarks.push(schema.marks["textColor"].create({
|
|
498
|
-
rgb: rpr.color.rgb,
|
|
499
|
-
themeColor: rpr.color.themeColor,
|
|
500
|
-
themeTint: rpr.color.themeTint,
|
|
501
|
-
themeShade: rpr.color.themeShade
|
|
502
|
-
}));
|
|
503
|
-
if (rpr.underline && rpr.underline.style !== "none" && schema.marks["underline"]) styleMarks.push(schema.marks["underline"].create({
|
|
504
|
-
style: rpr.underline.style,
|
|
505
|
-
color: rpr.underline.color
|
|
506
|
-
}));
|
|
507
|
-
if ((rpr.strike || rpr.doubleStrike) && schema.marks["strike"]) styleMarks.push(schema.marks["strike"].create({ double: rpr.doubleStrike || false }));
|
|
508
|
-
}
|
|
509
|
-
const styleControlledMarks = [
|
|
510
|
-
schema.marks["bold"],
|
|
511
|
-
schema.marks["italic"],
|
|
512
|
-
schema.marks["fontSize"],
|
|
513
|
-
schema.marks["fontFamily"],
|
|
514
|
-
schema.marks["textColor"],
|
|
515
|
-
schema.marks["underline"],
|
|
516
|
-
schema.marks["strike"]
|
|
517
|
-
].filter(Boolean);
|
|
518
549
|
state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
519
550
|
if (node.type.name === "paragraph" && !seen.has(pos)) {
|
|
520
551
|
seen.add(pos);
|
|
521
552
|
const newAttrs = {
|
|
522
553
|
...node.attrs,
|
|
523
554
|
styleId,
|
|
524
|
-
_tableOfContentsLevel: tableOfContentsStyleLevel({ styleId }) ?? null
|
|
555
|
+
_tableOfContentsLevel: styleId ? tableOfContentsStyleLevel({ styleId }) ?? null : null
|
|
525
556
|
};
|
|
526
557
|
if (resolvedAttrs) {
|
|
527
|
-
|
|
528
|
-
|
|
558
|
+
const current = expectParagraphAttrs(node);
|
|
559
|
+
const styleAttrs = paragraphAttrsFromResolvedStyle(resolvedAttrs, {
|
|
560
|
+
styleId: styleId ?? "",
|
|
529
561
|
...resolvedAttrs.styleName ? { styleName: resolvedAttrs.styleName } : {}
|
|
530
|
-
})
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
Reflect.deleteProperty(originalFormatting, "
|
|
536
|
-
|
|
537
|
-
|
|
562
|
+
});
|
|
563
|
+
Object.assign(newAttrs, styleAttrs);
|
|
564
|
+
if (!styleId) newAttrs["_tableOfContentsLevel"] = null;
|
|
565
|
+
const originalFormatting = { ...current._originalFormatting };
|
|
566
|
+
if (styleId) originalFormatting.styleId = styleId;
|
|
567
|
+
else Reflect.deleteProperty(originalFormatting, "styleId");
|
|
568
|
+
let restyledOriginal = originalFormatting;
|
|
569
|
+
if (styleId) {
|
|
570
|
+
Reflect.deleteProperty(originalFormatting, "alignment");
|
|
571
|
+
Reflect.deleteProperty(originalFormatting, "outlineLevel");
|
|
572
|
+
restyledOriginal = withDirectParagraphSpacing(originalFormatting, void 0);
|
|
573
|
+
newAttrs["spacingExplicit"] = null;
|
|
574
|
+
} else Object.assign(newAttrs, directParagraphAttrs(current));
|
|
575
|
+
newAttrs["_originalFormatting"] = restyledOriginal ?? null;
|
|
538
576
|
const listAttrs = listAttrsFromResolvedStyle(resolvedAttrs, resolvedAttrs.numbering);
|
|
577
|
+
const directNumId = current.numPrFromStyle == null ? paragraphNumberingReferenceId(current.numPr ?? void 0) : void 0;
|
|
539
578
|
if (listAttrs) Object.assign(newAttrs, listAttrs);
|
|
579
|
+
else if (isStyleSourcedParagraphNumbering(current.numPr, current.numPrFromStyle)) Object.assign(newAttrs, CLEARED_LIST_RENDERING_ATTRS, {
|
|
580
|
+
numPr: null,
|
|
581
|
+
numPrFromStyle: null
|
|
582
|
+
});
|
|
583
|
+
else if (directNumId !== void 0) Object.assign(newAttrs, listLevelIndentAttrPatch(restyledIndentation(styleAttrs, restyledOriginal), {
|
|
584
|
+
numId: directNumId,
|
|
585
|
+
ilvl: paragraphNumberingLevel(current.numPr ?? void 0) ?? 0
|
|
586
|
+
}, resolvedAttrs.numbering ?? getDocumentNumbering(state)));
|
|
540
587
|
}
|
|
541
588
|
tr = tr.setNodeMarkup(pos, void 0, newAttrs);
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
589
|
+
rebaseParagraphRuns({
|
|
590
|
+
tr,
|
|
591
|
+
position: pos,
|
|
592
|
+
previous: node,
|
|
593
|
+
styleResolver: getDocumentStyleResolver(state),
|
|
594
|
+
storedMarks: state.storedMarks ?? state.selection.$from.marks()
|
|
595
|
+
});
|
|
550
596
|
}
|
|
551
597
|
});
|
|
552
|
-
if (styleMarks.length > 0) tr = tr.setStoredMarks(styleMarks);
|
|
553
598
|
dispatch(tr.scrollIntoView());
|
|
554
599
|
return true;
|
|
555
600
|
};
|
|
@@ -582,8 +627,8 @@ const ParagraphExtension = createNodeExtension({
|
|
|
582
627
|
name: "paragraph",
|
|
583
628
|
schemaNodeName: "paragraph",
|
|
584
629
|
nodeSpec: paragraphNodeSpec,
|
|
585
|
-
onSchemaReady(
|
|
586
|
-
const applyStyleFn = makeApplyStyle(
|
|
630
|
+
onSchemaReady() {
|
|
631
|
+
const applyStyleFn = makeApplyStyle();
|
|
587
632
|
return { commands: {
|
|
588
633
|
setAlignment: (alignment) => makeSetAlignment(alignment),
|
|
589
634
|
alignLeft: () => makeSetAlignment("left"),
|
|
@@ -605,10 +650,18 @@ const ParagraphExtension = createNodeExtension({
|
|
|
605
650
|
hangingIndent: hanging ?? false
|
|
606
651
|
}),
|
|
607
652
|
applyStyle: (styleId, resolvedAttrs) => applyStyleFn(styleId, resolvedAttrs),
|
|
608
|
-
clearStyle: () =>
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
653
|
+
clearStyle: () => (state, dispatch) => {
|
|
654
|
+
const resolver = getDocumentStyleResolver(state);
|
|
655
|
+
if (!resolver) return applyStyleFn(null)(state, dispatch);
|
|
656
|
+
const resolved = resolver.resolveParagraphStyle(null);
|
|
657
|
+
const styleName = resolver.getDefaultParagraphStyle()?.name;
|
|
658
|
+
return applyStyleFn(null, {
|
|
659
|
+
...resolved.paragraphFormatting && { paragraphFormatting: resolved.paragraphFormatting },
|
|
660
|
+
...resolved.runFormatting && { runFormatting: resolved.runFormatting },
|
|
661
|
+
...styleName && { styleName },
|
|
662
|
+
numbering: getDocumentNumbering(state)
|
|
663
|
+
})(state, dispatch);
|
|
664
|
+
},
|
|
612
665
|
insertSectionBreak: (breakType) => setSectionBreakType(breakType),
|
|
613
666
|
removeSectionBreak: () => removeSectionBreakAtSelection,
|
|
614
667
|
generateTOC: ({ title }) => (state, dispatch) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeTextFormatting } from "../../../utils/textFormattingMerge.js";
|
|
2
2
|
import { expectCharacterStyleMarkAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
|
|
3
3
|
import { keepSectionBreaksOnSurvivingMarks } from "../../commands/sectionBreak.js";
|
|
4
|
-
import { getDocumentStyleResolver } from "../../plugins/
|
|
4
|
+
import { getDocumentStyleResolver } from "../../plugins/documentStyleState.js";
|
|
5
5
|
import { RUN_FORMATTING_MARK_NAMES } from "../../runFormattingMarkNames.js";
|
|
6
6
|
import { authoredRunFormattingFromAttrs } from "../../runFormattingProvenance.js";
|
|
7
7
|
import { paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
@@ -63,6 +63,9 @@ const INHERITED_PARA_ATTRS = [
|
|
|
63
63
|
"snapToGrid",
|
|
64
64
|
"spaceAfter",
|
|
65
65
|
"spaceBefore",
|
|
66
|
+
"spacingExplicit",
|
|
67
|
+
"spacingFromDocDefaults",
|
|
68
|
+
"spacingFromImplicitDefaultStyle",
|
|
66
69
|
"contextualSpacing"
|
|
67
70
|
];
|
|
68
71
|
/** Style formatting needed when the caret has no marks of its own. */
|
|
@@ -2,6 +2,26 @@ import { createExtension } from "../create.js";
|
|
|
2
2
|
import { textFormattingToMarks } from "../marks/markUtils.js";
|
|
3
3
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/extensions/features/EmptyParagraphFormatExtension.ts
|
|
5
|
+
/**
|
|
6
|
+
* EmptyParagraphFormat — re-establishes stored marks for an empty styled
|
|
7
|
+
* paragraph so typed text inherits the style's run formatting (bold, color,
|
|
8
|
+
* size, font).
|
|
9
|
+
*
|
|
10
|
+
* Why this exists:
|
|
11
|
+
* An empty paragraph carries its run defaults in the `defaultTextFormatting`
|
|
12
|
+
* attr (set at load by `toProseDoc`, and when a style is applied via
|
|
13
|
+
* `applyStyle`). The visible painter only derives font/size from that attr,
|
|
14
|
+
* so an empty heading renders a correctly sized caret — but typed text only
|
|
15
|
+
* becomes bold/colored if it carries real marks. Those marks live in
|
|
16
|
+
* `storedMarks`, which ProseMirror clears on the next selection change
|
|
17
|
+
* (e.g. when the style picker dropdown returns focus to the editor).
|
|
18
|
+
*
|
|
19
|
+
* This plugin watches for the caret sitting in an empty paragraph with no
|
|
20
|
+
* stored marks and re-derives them from `defaultTextFormatting`, but only
|
|
21
|
+
* when the defaults carry formatting the painter can't reproduce on its own
|
|
22
|
+
* (bold/italic/color/…). Plain body paragraphs (font + size only) are left
|
|
23
|
+
* untouched so ordinary typed text stays mark-free and serializes cleanly.
|
|
24
|
+
*/
|
|
5
25
|
const emptyParagraphFormatKey = new PluginKey("emptyParagraphFormat");
|
|
6
26
|
/**
|
|
7
27
|
* Run-formatting properties the painter does NOT reproduce from
|
|
@@ -15,7 +35,7 @@ const FONT_ONLY_DEFAULTS = /* @__PURE__ */ new Set(["fontFamily", "fontSize"]);
|
|
|
15
35
|
function hasNonFontDefaults(dtf) {
|
|
16
36
|
return Object.entries(dtf).some(([property, value]) => value !== void 0 && !FONT_ONLY_DEFAULTS.has(property));
|
|
17
37
|
}
|
|
18
|
-
function createEmptyParagraphFormatPlugin(
|
|
38
|
+
function createEmptyParagraphFormatPlugin() {
|
|
19
39
|
return new Plugin({
|
|
20
40
|
key: emptyParagraphFormatKey,
|
|
21
41
|
appendTransaction(transactions, _oldState, newState) {
|
|
@@ -27,6 +47,7 @@ function createEmptyParagraphFormatPlugin(schema) {
|
|
|
27
47
|
if (para.type.name !== "paragraph" || para.content.size !== 0) return null;
|
|
28
48
|
const dtf = para.attrs["defaultTextFormatting"];
|
|
29
49
|
if (!dtf || !hasNonFontDefaults(dtf)) return null;
|
|
50
|
+
const { schema } = newState;
|
|
30
51
|
const marks = textFormattingToMarks(dtf, schema);
|
|
31
52
|
if (dtf.styleId) marks.push(schema.mark("characterStyle", { styleId: dtf.styleId }));
|
|
32
53
|
if (marks.length === 0) return null;
|
|
@@ -38,8 +59,8 @@ function createEmptyParagraphFormatPlugin(schema) {
|
|
|
38
59
|
}
|
|
39
60
|
const EmptyParagraphFormatExtension = createExtension({
|
|
40
61
|
name: "emptyParagraphFormat",
|
|
41
|
-
onSchemaReady(
|
|
42
|
-
return { plugins: [createEmptyParagraphFormatPlugin(
|
|
62
|
+
onSchemaReady() {
|
|
63
|
+
return { plugins: [createEmptyParagraphFormatPlugin()] };
|
|
43
64
|
}
|
|
44
65
|
});
|
|
45
66
|
//#endregion
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Extension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Runs that a join moves into another paragraph take that paragraph's style.
|
|
5
|
+
*
|
|
6
|
+
* Deleting across a paragraph break (Backspace or Delete at the break, a
|
|
7
|
+
* deletion or typing over a selection that spans paragraphs) runs the later
|
|
8
|
+
* paragraph's remaining text on into the earlier one. A run's direct
|
|
9
|
+
* formatting is its own and stays; what the later paragraph's style lent it
|
|
10
|
+
* does not travel, and it reads in the style of the paragraph it now belongs
|
|
11
|
+
* to. The document styles plugin re-reads those runs after an ordinary edit.
|
|
12
|
+
*
|
|
13
|
+
* A transaction that re-reads the runs it moves itself (resolving a tracked
|
|
14
|
+
* change, an operation that merges paragraphs) says so with
|
|
15
|
+
* {@link JOINED_RUNS_RESTYLED_META}, and is left as it is.
|
|
16
|
+
*/
|
|
17
|
+
declare const JOINED_RUNS_RESTYLED_META = "joinedRunsRestyled";
|
|
18
|
+
declare const JoinedRunStyleExtension: (options?: Partial<{}> | undefined) => Extension;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { JOINED_RUNS_RESTYLED_META, JoinedRunStyleExtension };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createExtension } from "../create.js";
|
|
2
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
|
+
//#region src/prosemirror/extensions/features/JoinedRunStyleExtension.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runs that a join moves into another paragraph take that paragraph's style.
|
|
6
|
+
*
|
|
7
|
+
* Deleting across a paragraph break (Backspace or Delete at the break, a
|
|
8
|
+
* deletion or typing over a selection that spans paragraphs) runs the later
|
|
9
|
+
* paragraph's remaining text on into the earlier one. A run's direct
|
|
10
|
+
* formatting is its own and stays; what the later paragraph's style lent it
|
|
11
|
+
* does not travel, and it reads in the style of the paragraph it now belongs
|
|
12
|
+
* to. The document styles plugin re-reads those runs after an ordinary edit.
|
|
13
|
+
*
|
|
14
|
+
* A transaction that re-reads the runs it moves itself (resolving a tracked
|
|
15
|
+
* change, an operation that merges paragraphs) says so with
|
|
16
|
+
* {@link JOINED_RUNS_RESTYLED_META}, and is left as it is.
|
|
17
|
+
*/
|
|
18
|
+
const JOINED_RUNS_RESTYLED_META = "joinedRunsRestyled";
|
|
19
|
+
const pastedTableEndKey = new PluginKey("pastedTableEnd");
|
|
20
|
+
/**
|
|
21
|
+
* A table pasted over a story's last paragraph leaves that paragraph, emptied,
|
|
22
|
+
* after it: a story ends with a paragraph, and the paste replaced the words,
|
|
23
|
+
* not the break that ends the story. ProseMirror's paste replaces the whole
|
|
24
|
+
* paragraph, so the empty one is put back.
|
|
25
|
+
*/
|
|
26
|
+
const createPastedTableEndPlugin = () => new Plugin({
|
|
27
|
+
key: pastedTableEndKey,
|
|
28
|
+
appendTransaction(transactions, oldState, newState) {
|
|
29
|
+
if (!transactions.some((transaction) => transaction.docChanged && transaction.getMeta("uiEvent") === "paste")) return null;
|
|
30
|
+
if (newState.doc.lastChild?.type.spec["tableRole"] !== "table" || oldState.doc.lastChild?.type.name !== "paragraph") return null;
|
|
31
|
+
const paragraph = newState.schema.nodes["paragraph"]?.createAndFill();
|
|
32
|
+
return paragraph ? newState.tr.insert(newState.doc.content.size, paragraph) : null;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const JoinedRunStyleExtension = createExtension({
|
|
36
|
+
name: "joinedRunStyle",
|
|
37
|
+
defaultOptions: {},
|
|
38
|
+
onSchemaReady() {
|
|
39
|
+
return { plugins: [createPastedTableEndPlugin()] };
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
export { JOINED_RUNS_RESTYLED_META, JoinedRunStyleExtension };
|