@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,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NO_PARAGRAPH_NUMBERING, paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId } from "../../../docx/numberingReference.js";
|
|
1
|
+
import { paragraphNumberingLevel, paragraphNumberingReferenceId } from "../../../docx/numberingReference.js";
|
|
3
2
|
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
4
|
-
import {
|
|
3
|
+
import { LIST_MARKER_PATTERN, listRequestsForMarker } from "../../listAutoformatMarkers.js";
|
|
5
4
|
import { CLEARED_LIST_RENDERING_ATTRS } from "../../listMarker.js";
|
|
6
|
-
import {
|
|
5
|
+
import { applyParagraphUpdates, continueNumbering, listItemAttrs, resolveListTarget, restartNumbering, setNumberingValue } from "../../listNumbering.js";
|
|
7
6
|
import { resolveListState } from "../../listState.js";
|
|
8
|
-
import {
|
|
7
|
+
import { removedNumberingAttr } from "../../numberingAttr.js";
|
|
9
8
|
import { getDocumentNumbering } from "../../plugins/documentNumbering.js";
|
|
10
|
-
import { SUGGESTION_META, makeRevisionInfo } from "../../plugins/suggestionMode.js";
|
|
11
|
-
import { listLevelAttrPatch } from "../../styles/resolvedStyleAttrs.js";
|
|
9
|
+
import { SUGGESTION_META, makeRevisionInfo, suggestRangeDeletion } from "../../plugins/suggestionMode.js";
|
|
10
|
+
import { listLevelAttrPatch, listLevelIndentRemovalPatch } from "../../styles/resolvedStyleAttrs.js";
|
|
12
11
|
import { createExtension } from "../create.js";
|
|
13
12
|
import { goToNextCell, goToPrevCell } from "../nodes/TableExtension.js";
|
|
14
13
|
import { Priority } from "../types.js";
|
|
15
14
|
import { panic } from "better-result";
|
|
15
|
+
import { Plugin } from "prosemirror-state";
|
|
16
16
|
import { InputRule, inputRules, undoInputRule } from "prosemirror-inputrules";
|
|
17
17
|
//#region src/prosemirror/extensions/features/ListExtension.ts
|
|
18
18
|
/**
|
|
@@ -27,113 +27,88 @@ function chainCommands(...commands) {
|
|
|
27
27
|
return false;
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function clearListAttrs(attrs, numbering) {
|
|
31
31
|
return {
|
|
32
32
|
...attrs,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
info: {
|
|
36
|
-
id: rev.id,
|
|
37
|
-
author: rev.author,
|
|
38
|
-
date: rev.date
|
|
39
|
-
},
|
|
40
|
-
previousFormatting
|
|
41
|
-
}]
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function getPreviousListFormatting(attrs) {
|
|
45
|
-
const previousFormatting = {};
|
|
46
|
-
for (const key of PPR_CHANGE_SCOPED_ATTR_KEYS) {
|
|
47
|
-
const value = attrs[key];
|
|
48
|
-
if (value != null) previousFormatting[key] = value;
|
|
49
|
-
}
|
|
50
|
-
previousFormatting["numPr"] = attrs["numPr"] ?? null;
|
|
51
|
-
for (const key of LIST_RENDERING_ATTR_KEYS) previousFormatting[key] = attrs[key] ?? null;
|
|
52
|
-
return previousFormatting;
|
|
53
|
-
}
|
|
54
|
-
function clearListAttrs(attrs) {
|
|
55
|
-
const numPr = paragraphNumberingReferenceId(attrs.numPrFromStyle) === void 0 ? null : paragraphNumberingAttr(NO_PARAGRAPH_NUMBERING);
|
|
56
|
-
return {
|
|
57
|
-
...attrs,
|
|
58
|
-
numPr,
|
|
33
|
+
...listLevelIndentRemovalPatch(attrs, numbering),
|
|
34
|
+
numPr: removedNumberingAttr(attrs.numPrFromStyle),
|
|
59
35
|
...CLEARED_LIST_RENDERING_ATTRS
|
|
60
36
|
};
|
|
61
37
|
}
|
|
62
38
|
function hasActiveListNumbering(attrs) {
|
|
63
39
|
return attrs.numPr?.kind === "reference";
|
|
64
40
|
}
|
|
41
|
+
const paragraphsBetween = (doc, from, to) => {
|
|
42
|
+
const paragraphs = [];
|
|
43
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
44
|
+
if (node.type.name !== "paragraph") return true;
|
|
45
|
+
paragraphs.push({
|
|
46
|
+
pos,
|
|
47
|
+
node
|
|
48
|
+
});
|
|
49
|
+
return false;
|
|
50
|
+
});
|
|
51
|
+
return paragraphs;
|
|
52
|
+
};
|
|
65
53
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
54
|
+
* Make every paragraph from `from` to `to` an item of one list: the list next
|
|
55
|
+
* to them when it matches, else a new one (see `listNumbering.ts`). One
|
|
56
|
+
* target for the whole range, so a selection of plain paragraphs becomes one
|
|
57
|
+
* list rather than one list apiece.
|
|
70
58
|
*/
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
78
|
-
if (
|
|
79
|
-
|
|
59
|
+
const numberParagraphs = ({ state, tr, from, to, requests }) => {
|
|
60
|
+
const target = resolveListTarget({
|
|
61
|
+
numbering: getDocumentNumbering(state),
|
|
62
|
+
$from: tr.doc.resolve(from),
|
|
63
|
+
$to: tr.doc.resolve(to),
|
|
64
|
+
requests
|
|
65
|
+
});
|
|
66
|
+
if (!target) return false;
|
|
67
|
+
applyParagraphUpdates({
|
|
68
|
+
tr,
|
|
69
|
+
state,
|
|
70
|
+
updates: paragraphsBetween(tr.doc, from, to).map(({ pos, node }) => ({
|
|
71
|
+
pos,
|
|
72
|
+
node,
|
|
73
|
+
next: listItemAttrs(expectParagraphAttrs(node), {
|
|
74
|
+
numId: target.numId,
|
|
75
|
+
ilvl: paragraphNumberingLevel(expectParagraphAttrs(node).numPr) ?? target.ilvl
|
|
76
|
+
}, target.numbering)
|
|
77
|
+
}))
|
|
78
|
+
});
|
|
79
|
+
return true;
|
|
80
80
|
};
|
|
81
|
-
function toggleList(
|
|
81
|
+
function toggleList(intent) {
|
|
82
82
|
return (state, dispatch) => {
|
|
83
83
|
const { $from, $to } = state.selection;
|
|
84
84
|
const paragraph = $from.parent;
|
|
85
85
|
if (paragraph.type.name !== "paragraph") return false;
|
|
86
|
-
const numbering = getDocumentNumbering(state);
|
|
87
|
-
const isInSameList = resolveListState(numbering, expectParagraphAttrs(paragraph).numPr).type === intent;
|
|
88
|
-
const rev = makeRevisionInfo(state);
|
|
89
|
-
if (rev) {
|
|
90
|
-
let hasPendingChange = false;
|
|
91
|
-
state.doc.nodesBetween($from.pos, $to.pos, (node) => {
|
|
92
|
-
if (node.type.name === "paragraph" && hasSerializableParagraphPropertyChange(expectParagraphAttrs(node)._propertyChanges)) {
|
|
93
|
-
hasPendingChange = true;
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
if (hasPendingChange) return false;
|
|
98
|
-
}
|
|
99
86
|
if (!dispatch) return true;
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
})),
|
|
119
|
-
listIsBullet: isBullet,
|
|
120
|
-
listNumFmt: isBullet ? null : definition?.numFmt ?? "decimal"
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
if (rev) {
|
|
124
|
-
const existing = expectParagraphAttrs(node)._propertyChanges;
|
|
125
|
-
nextAttrs = appendParagraphPropertyChange(nextAttrs, existing, getPreviousListFormatting(node.attrs), rev);
|
|
126
|
-
}
|
|
127
|
-
tr = tr.setNodeMarkup(pos, void 0, nextAttrs);
|
|
128
|
-
}
|
|
87
|
+
const numbering = getDocumentNumbering(state);
|
|
88
|
+
const isItemOfKind = (node) => resolveListState(numbering, expectParagraphAttrs(node).numPr).type === intent;
|
|
89
|
+
const tr = state.tr;
|
|
90
|
+
if (isItemOfKind(paragraph)) applyParagraphUpdates({
|
|
91
|
+
tr,
|
|
92
|
+
state,
|
|
93
|
+
updates: paragraphsBetween(state.doc, $from.pos, $to.pos).filter(({ node }) => isItemOfKind(node)).map(({ pos, node }) => ({
|
|
94
|
+
pos,
|
|
95
|
+
node,
|
|
96
|
+
next: clearListAttrs(expectParagraphAttrs(node), getDocumentNumbering(state))
|
|
97
|
+
}))
|
|
98
|
+
});
|
|
99
|
+
else numberParagraphs({
|
|
100
|
+
state,
|
|
101
|
+
tr,
|
|
102
|
+
from: $from.pos,
|
|
103
|
+
to: $to.pos,
|
|
104
|
+
requests: [{ kind: intent }]
|
|
129
105
|
});
|
|
130
|
-
if (rev) tr.setMeta(SUGGESTION_META, true);
|
|
131
106
|
dispatch(tr.scrollIntoView());
|
|
132
107
|
return true;
|
|
133
108
|
};
|
|
134
109
|
}
|
|
135
|
-
const toggleBulletList = (state, dispatch) => toggleList(
|
|
136
|
-
const toggleNumberedList = (state, dispatch) => toggleList(
|
|
110
|
+
const toggleBulletList = (state, dispatch) => toggleList("bullet")(state, dispatch);
|
|
111
|
+
const toggleNumberedList = (state, dispatch) => toggleList("numbered")(state, dispatch);
|
|
137
112
|
const attrsForListLevel = (state, attrs, level) => {
|
|
138
113
|
if (!hasActiveListNumbering(attrs)) panic("Cannot change the level of a list without a numbering id");
|
|
139
114
|
return {
|
|
@@ -167,7 +142,7 @@ const decreaseListLevel = (state, dispatch) => {
|
|
|
167
142
|
if (!dispatch) return true;
|
|
168
143
|
const paragraphPos = $from.before($from.depth);
|
|
169
144
|
if (currentLevel <= 0) dispatch(state.tr.setNodeMarkup(paragraphPos, void 0, {
|
|
170
|
-
...clearListAttrs(attrs),
|
|
145
|
+
...clearListAttrs(attrs, getDocumentNumbering(state)),
|
|
171
146
|
indentLeft: null,
|
|
172
147
|
indentFirstLine: null,
|
|
173
148
|
hangingIndent: null
|
|
@@ -183,7 +158,7 @@ const removeList = (state, dispatch) => {
|
|
|
183
158
|
state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
184
159
|
if (node.type.name === "paragraph" && hasActiveListNumbering(expectParagraphAttrs(node)) && !seen.has(pos)) {
|
|
185
160
|
seen.add(pos);
|
|
186
|
-
tr = tr.setNodeMarkup(pos, void 0, clearListAttrs(expectParagraphAttrs(node)));
|
|
161
|
+
tr = tr.setNodeMarkup(pos, void 0, clearListAttrs(expectParagraphAttrs(node), getDocumentNumbering(state)));
|
|
187
162
|
}
|
|
188
163
|
});
|
|
189
164
|
dispatch(tr.scrollIntoView());
|
|
@@ -215,7 +190,19 @@ function exitListOnEmptyEnter() {
|
|
|
215
190
|
const attrs = expectParagraphAttrs(paragraph);
|
|
216
191
|
if (!hasActiveListNumbering(attrs)) return false;
|
|
217
192
|
if (paragraph.textContent.length > 0) return false;
|
|
218
|
-
if (dispatch)
|
|
193
|
+
if (dispatch) {
|
|
194
|
+
const tr = state.tr;
|
|
195
|
+
applyParagraphUpdates({
|
|
196
|
+
tr,
|
|
197
|
+
state,
|
|
198
|
+
updates: [{
|
|
199
|
+
pos: $from.before(),
|
|
200
|
+
node: paragraph,
|
|
201
|
+
next: clearListAttrs(attrs, getDocumentNumbering(state))
|
|
202
|
+
}]
|
|
203
|
+
});
|
|
204
|
+
dispatch(tr);
|
|
205
|
+
}
|
|
219
206
|
return true;
|
|
220
207
|
};
|
|
221
208
|
}
|
|
@@ -229,10 +216,19 @@ function splitListItem() {
|
|
|
229
216
|
if (dispatch) {
|
|
230
217
|
const { tr } = state;
|
|
231
218
|
const pos = $from.pos;
|
|
219
|
+
const paragraphPos = $from.before();
|
|
220
|
+
const revision = makeRevisionInfo(state);
|
|
232
221
|
tr.split(pos, 1, [{
|
|
233
222
|
type: state.schema.nodes["paragraph"],
|
|
234
223
|
attrs: { ...paragraph.attrs }
|
|
235
224
|
}]);
|
|
225
|
+
if (revision && paragraph.attrs["pPrMark"] == null) {
|
|
226
|
+
tr.setNodeAttribute(paragraphPos, "pPrMark", {
|
|
227
|
+
kind: "ins",
|
|
228
|
+
info: revision
|
|
229
|
+
});
|
|
230
|
+
tr.setMeta(SUGGESTION_META, true);
|
|
231
|
+
}
|
|
236
232
|
dispatch(tr.scrollIntoView());
|
|
237
233
|
}
|
|
238
234
|
return true;
|
|
@@ -247,7 +243,19 @@ function backspaceExitList() {
|
|
|
247
243
|
if (paragraph.type.name !== "paragraph") return false;
|
|
248
244
|
const attrs = expectParagraphAttrs(paragraph);
|
|
249
245
|
if (!hasActiveListNumbering(attrs)) return false;
|
|
250
|
-
if (dispatch)
|
|
246
|
+
if (dispatch) {
|
|
247
|
+
const tr = state.tr;
|
|
248
|
+
applyParagraphUpdates({
|
|
249
|
+
tr,
|
|
250
|
+
state,
|
|
251
|
+
updates: [{
|
|
252
|
+
pos: $from.before(),
|
|
253
|
+
node: paragraph,
|
|
254
|
+
next: clearListAttrs(attrs, getDocumentNumbering(state))
|
|
255
|
+
}]
|
|
256
|
+
});
|
|
257
|
+
dispatch(tr);
|
|
258
|
+
}
|
|
251
259
|
return true;
|
|
252
260
|
};
|
|
253
261
|
}
|
|
@@ -293,7 +301,7 @@ function decreaseListIndent() {
|
|
|
293
301
|
for (const { pos, attrs } of positions) {
|
|
294
302
|
const currentLevel = attrs.numPr.ilvl ?? 0;
|
|
295
303
|
if (currentLevel <= 0) tr = tr.setNodeMarkup(pos, void 0, {
|
|
296
|
-
...clearListAttrs(attrs),
|
|
304
|
+
...clearListAttrs(attrs, getDocumentNumbering(state)),
|
|
297
305
|
indentLeft: null,
|
|
298
306
|
indentFirstLine: null,
|
|
299
307
|
hangingIndent: null
|
|
@@ -314,53 +322,84 @@ function insertTab() {
|
|
|
314
322
|
return true;
|
|
315
323
|
};
|
|
316
324
|
}
|
|
325
|
+
/** Whether a typed marker may become a list here at all. */
|
|
326
|
+
const acceptsListMarker = (paragraph) => paragraph.type.name === "paragraph" && paragraphNumberingReferenceId(expectParagraphAttrs(paragraph).numPr) === void 0;
|
|
317
327
|
/**
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
328
|
+
* Replace a typed marker with the list the toolbar button produces: the same
|
|
329
|
+
* target resolution and the same attrs, so an autoformatted list saves exactly
|
|
330
|
+
* like a clicked one. The marker's format and value choose the list (see
|
|
331
|
+
* `listAutoformatMarkers.ts`).
|
|
321
332
|
*/
|
|
322
|
-
const
|
|
323
|
-
const NUMBERED_AUTOFORMAT = /^1\. $/u;
|
|
324
|
-
const captureTransaction = (command, state) => {
|
|
325
|
-
const captured = { transaction: null };
|
|
326
|
-
command(state, (transaction) => {
|
|
327
|
-
captured.transaction = transaction;
|
|
328
|
-
});
|
|
329
|
-
return captured.transaction;
|
|
330
|
-
};
|
|
331
|
-
/**
|
|
332
|
-
* Replace a typed marker with the list the toolbar button produces. Running the
|
|
333
|
-
* command itself (rather than writing `numPr` here) keeps an autoformatted list
|
|
334
|
-
* identical to a clicked one, down to what the document saves.
|
|
335
|
-
*/
|
|
336
|
-
const listAutoformat = (marker, toggleCommand) => new InputRule(marker, (state, _match, start, end) => {
|
|
333
|
+
const listAutoformatRule = () => new InputRule(LIST_MARKER_PATTERN, (state, match, start, end) => {
|
|
337
334
|
const { $from } = state.selection;
|
|
338
|
-
if ($from.parent
|
|
335
|
+
if (!acceptsListMarker($from.parent)) return null;
|
|
339
336
|
if (start !== $from.start()) return null;
|
|
340
|
-
if (paragraphNumberingReferenceId(expectParagraphAttrs($from.parent).numPr) !== void 0) return null;
|
|
341
337
|
if (makeRevisionInfo(state)) return null;
|
|
342
|
-
const
|
|
343
|
-
if (!
|
|
338
|
+
const requests = listRequestsForMarker(match[0]);
|
|
339
|
+
if (!requests) return null;
|
|
344
340
|
const tr = state.tr.delete(start, end);
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
341
|
+
return numberParagraphs({
|
|
342
|
+
state,
|
|
343
|
+
tr,
|
|
344
|
+
from: start,
|
|
345
|
+
to: start,
|
|
346
|
+
requests
|
|
347
|
+
}) ? tr : null;
|
|
350
348
|
});
|
|
351
|
-
|
|
349
|
+
/**
|
|
350
|
+
* List autoformat while suggesting. The suggestion plugin has already
|
|
351
|
+
* recorded the typed space as a tracked insertion; this follows it with the
|
|
352
|
+
* marker's removal (a retraction of the author's own typing, or a tracked
|
|
353
|
+
* deletion of text that was there before) and the list as a tracked
|
|
354
|
+
* paragraph-property change. The follow-up is appended to the typing
|
|
355
|
+
* transaction, so one undo reverts both, and it is stored as the input rule's
|
|
356
|
+
* last conversion, so Backspace puts the marker back as it does while editing.
|
|
357
|
+
*/
|
|
358
|
+
const suggestedListAutoformat = (autoformat) => new Plugin({ appendTransaction(transactions, _oldState, state) {
|
|
359
|
+
if (!transactions.some((tr) => tr.getMeta("suggestionModeTextInput") === " ")) return null;
|
|
360
|
+
const { $head, empty } = state.selection;
|
|
361
|
+
if (!empty || !makeRevisionInfo(state) || !acceptsListMarker($head.parent)) return null;
|
|
362
|
+
const requests = listRequestsForMarker($head.parent.textBetween(0, $head.parentOffset, null, ""));
|
|
363
|
+
if (!requests) return null;
|
|
364
|
+
const start = $head.start();
|
|
365
|
+
const tr = state.tr;
|
|
366
|
+
if (!suggestRangeDeletion(state, tr, start, $head.pos)) return null;
|
|
367
|
+
const from = tr.mapping.map(start);
|
|
368
|
+
if (!numberParagraphs({
|
|
369
|
+
state,
|
|
370
|
+
tr,
|
|
371
|
+
from,
|
|
372
|
+
to: from,
|
|
373
|
+
requests
|
|
374
|
+
})) return null;
|
|
375
|
+
const caret = tr.mapping.map($head.pos);
|
|
376
|
+
tr.setMeta(autoformat, {
|
|
377
|
+
transform: tr,
|
|
378
|
+
from: caret,
|
|
379
|
+
to: caret,
|
|
380
|
+
text: ""
|
|
381
|
+
});
|
|
382
|
+
return tr;
|
|
383
|
+
} });
|
|
384
|
+
const listAutoformatPlugins = () => {
|
|
385
|
+
const autoformat = inputRules({ rules: [listAutoformatRule()] });
|
|
386
|
+
return [autoformat, suggestedListAutoformat(autoformat)];
|
|
387
|
+
};
|
|
352
388
|
const ListExtension = createExtension({
|
|
353
389
|
name: "list",
|
|
354
390
|
priority: Priority.High,
|
|
355
391
|
onSchemaReady() {
|
|
356
392
|
return {
|
|
357
|
-
plugins:
|
|
393
|
+
plugins: listAutoformatPlugins(),
|
|
358
394
|
commands: {
|
|
359
395
|
toggleBulletList: () => toggleBulletList,
|
|
360
396
|
toggleNumberedList: () => toggleNumberedList,
|
|
361
397
|
increaseListLevel: () => increaseListLevel,
|
|
362
398
|
decreaseListLevel: () => decreaseListLevel,
|
|
363
|
-
removeList: () => removeList
|
|
399
|
+
removeList: () => removeList,
|
|
400
|
+
restartNumbering: () => restartNumbering,
|
|
401
|
+
continueNumbering: () => continueNumbering,
|
|
402
|
+
setNumberingValue: (value) => setNumberingValue(value)
|
|
364
403
|
},
|
|
365
404
|
keyboardShortcuts: {
|
|
366
405
|
Tab: chainCommands(goToNextCell(), increaseListIndent(), insertTab()),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Extension } from "../types.js";
|
|
2
|
-
import { EditorState, PluginKey, Transaction } from "prosemirror-state";
|
|
3
2
|
import { Node } from "prosemirror-model";
|
|
3
|
+
import { EditorState, PluginKey, Transaction } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts
|
|
5
5
|
type ParagraphPropertySourceSeed = {
|
|
6
6
|
contract: string | null;
|
|
@@ -20,6 +20,23 @@ declare const paraIdAllocatorKey: PluginKey<ParagraphPropertySourceSeed>;
|
|
|
20
20
|
declare const deterministicParaIdSeedKey: PluginKey<string>;
|
|
21
21
|
/** Ask the allocator to mint reproducible ids for the paragraphs `tr` creates. */
|
|
22
22
|
declare const requestDeterministicParaIds: (tr: Transaction, seed: string) => Transaction;
|
|
23
|
+
type ParagraphPropertySourceKeeper = {
|
|
24
|
+
status: "ambiguous";
|
|
25
|
+
} | {
|
|
26
|
+
pos: number;
|
|
27
|
+
status: "deleted" | "mapped";
|
|
28
|
+
};
|
|
29
|
+
type MappedParagraphKeepers = {
|
|
30
|
+
paraIds: Map<string, number>;
|
|
31
|
+
sourceTokens: Map<string, ParagraphPropertySourceKeeper>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Where each id's and each seeded source token's owner went: the first
|
|
35
|
+
* occurrence that survives the batch keeps an id.
|
|
36
|
+
*
|
|
37
|
+
* @internal Exported for the per-step equivalence test.
|
|
38
|
+
*/
|
|
39
|
+
declare const mapParagraphKeepers: (oldDoc: Node, transactions: readonly Transaction[], sourceSeed: ParagraphPropertySourceSeed) => MappedParagraphKeepers;
|
|
23
40
|
/**
|
|
24
41
|
* Allocate initial paragraph IDs before constructing editor state.
|
|
25
42
|
*
|
|
@@ -31,4 +48,4 @@ declare const ensureParaIdsInDoc: (doc: Node) => Node;
|
|
|
31
48
|
declare const ensureParaIdsInState: (state: EditorState) => EditorState;
|
|
32
49
|
declare const ParaIdAllocatorExtension: (options?: Partial<{}> | undefined) => Extension;
|
|
33
50
|
//#endregion
|
|
34
|
-
export { ParaIdAllocatorExtension, deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, paraIdAllocatorKey, requestDeterministicParaIds };
|
|
51
|
+
export { ParaIdAllocatorExtension, deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, mapParagraphKeepers, paraIdAllocatorKey, requestDeterministicParaIds };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PROSE_PARAGRAPH_SOURCE_TOKEN_ATTR, getExplicitParagraphPropertySourceTransfers, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, setProseParagraphMarkupWithPropertySource, transferProseParagraphPropertySource } from "../../../docx/paragraphPropertySource.js";
|
|
2
2
|
import { deterministicHexId, generateHexId } from "../../../utils/hexId.js";
|
|
3
|
+
import { sweepPositions } from "../../positionSweep.js";
|
|
3
4
|
import { createExtension } from "../create.js";
|
|
4
5
|
import { ignoreTrackedChanges } from "./ParagraphChangeTrackerExtension.js";
|
|
5
6
|
import { panic } from "better-result";
|
|
@@ -92,33 +93,45 @@ const collectParagraphPropertySourceSeed = (doc) => {
|
|
|
92
93
|
tokens: new Set([...counts].filter(([, count]) => count === 1).map(([token]) => token))
|
|
93
94
|
};
|
|
94
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Where each id's and each seeded source token's owner went: the first
|
|
98
|
+
* occurrence that survives the batch keeps an id.
|
|
99
|
+
*
|
|
100
|
+
* @internal Exported for the per-step equivalence test.
|
|
101
|
+
*/
|
|
95
102
|
const mapParagraphKeepers = (oldDoc, transactions, sourceSeed) => {
|
|
96
|
-
const
|
|
97
|
-
const sourceTokens = /* @__PURE__ */ new Map();
|
|
103
|
+
const paragraphs = [];
|
|
98
104
|
oldDoc.descendants((node, pos) => {
|
|
99
105
|
if (node.type.name !== "paragraph") return true;
|
|
100
106
|
const id = node.attrs["paraId"];
|
|
101
107
|
const token = getProseParagraphPropertySourceToken(node);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
let mappedInterior = pos + 1;
|
|
107
|
-
let deleted = false;
|
|
108
|
-
for (const transaction of transactions) {
|
|
109
|
-
const ownerResult = transaction.mapping.mapResult(mapped);
|
|
110
|
-
const interiorResult = transaction.mapping.mapResult(mappedInterior, -1);
|
|
111
|
-
deleted ||= interiorResult.deletedAcross;
|
|
112
|
-
mapped = ownerResult.pos;
|
|
113
|
-
mappedInterior = interiorResult.pos;
|
|
114
|
-
}
|
|
115
|
-
if (mapsParaId && !deleted) paraIds.set(id, mapped);
|
|
116
|
-
if (mapsSourceToken) sourceTokens.set(token, sourceTokens.has(token) ? { status: "ambiguous" } : {
|
|
117
|
-
pos: mapped,
|
|
118
|
-
status: deleted ? "deleted" : "mapped"
|
|
108
|
+
if (isUsableParaId(id) || typeof token === "string" && sourceSeed.tokens.has(token)) paragraphs.push({
|
|
109
|
+
pos,
|
|
110
|
+
id,
|
|
111
|
+
token
|
|
119
112
|
});
|
|
120
113
|
return false;
|
|
121
114
|
});
|
|
115
|
+
const swept = sweepPositions(transactions.map((transaction) => transaction.mapping), paragraphs.flatMap(({ pos }) => [{
|
|
116
|
+
pos,
|
|
117
|
+
assoc: 1,
|
|
118
|
+
from: 0
|
|
119
|
+
}, {
|
|
120
|
+
pos: pos + 1,
|
|
121
|
+
assoc: -1,
|
|
122
|
+
from: 0
|
|
123
|
+
}]));
|
|
124
|
+
const paraIds = /* @__PURE__ */ new Map();
|
|
125
|
+
const sourceTokens = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const [index, { id, token }] of paragraphs.entries()) {
|
|
127
|
+
const mapped = swept[2 * index].pos;
|
|
128
|
+
const deleted = swept[2 * index + 1].deletedAcross;
|
|
129
|
+
if (isUsableParaId(id) && !paraIds.has(id) && !deleted) paraIds.set(id, mapped);
|
|
130
|
+
if (typeof token === "string" && sourceSeed.tokens.has(token)) sourceTokens.set(token, sourceTokens.has(token) ? { status: "ambiguous" } : {
|
|
131
|
+
pos: mapped,
|
|
132
|
+
status: deleted ? "deleted" : "mapped"
|
|
133
|
+
});
|
|
134
|
+
}
|
|
122
135
|
return {
|
|
123
136
|
paraIds,
|
|
124
137
|
sourceTokens
|
|
@@ -334,4 +347,4 @@ const ParaIdAllocatorExtension = createExtension({
|
|
|
334
347
|
}
|
|
335
348
|
});
|
|
336
349
|
//#endregion
|
|
337
|
-
export { ParaIdAllocatorExtension, deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, paraIdAllocatorKey, requestDeterministicParaIds };
|
|
350
|
+
export { ParaIdAllocatorExtension, deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, mapParagraphKeepers, paraIdAllocatorKey, requestDeterministicParaIds };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { document_d_exports } from "../../../types/document.js";
|
|
1
2
|
import { Extension } from "../types.js";
|
|
2
3
|
import { RemovedSectionReference, TrackedSectionEndpointRemoval } from "../../../internal/sectionEndpointResolution.js";
|
|
3
|
-
import { EditorState, PluginKey, Transaction } from "prosemirror-state";
|
|
4
4
|
import { Node } from "prosemirror-model";
|
|
5
|
+
import { EditorState, PluginKey, Transaction } from "prosemirror-state";
|
|
5
6
|
//#region src/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts
|
|
6
7
|
declare const paragraphChangeTrackerKey: PluginKey<InternalParagraphChangeTrackerState>;
|
|
7
8
|
type ParagraphChangeTrackerState = {
|
|
@@ -26,6 +27,8 @@ type InternalParagraphChangeTrackerState = ParagraphChangeTrackerState & {
|
|
|
26
27
|
/** Editing an already unidentified source paragraph cannot become selective. */
|
|
27
28
|
hasUntrackedSourceChanges: boolean;
|
|
28
29
|
blockStructureFingerprint: string;
|
|
30
|
+
/** The section records themselves, by identity. */
|
|
31
|
+
sectionRecords: ReadonlySet<document_d_exports.SectionProperties>;
|
|
29
32
|
};
|
|
30
33
|
/**
|
|
31
34
|
* Get the change tracker state from an EditorState
|
|
@@ -45,6 +48,24 @@ declare function hasStructuralChanges(state: EditorState): boolean;
|
|
|
45
48
|
declare function hasUntrackedChanges(state: EditorState): boolean;
|
|
46
49
|
/** Exact section-count transition authorized by tracked paragraph-mark resolution. */
|
|
47
50
|
declare function getTrackedSectionEndpointRemoval(state: EditorState): TrackedSectionEndpointRemoval | null;
|
|
51
|
+
type RepackWithEditorSectionRemovalsOptions<T> = {
|
|
52
|
+
/** The editor state the document was built from. */
|
|
53
|
+
state: EditorState;
|
|
54
|
+
/** The exact document object `repack` hands to `repackDocx`. */
|
|
55
|
+
document: document_d_exports.Document;
|
|
56
|
+
repack: () => Promise<T>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Run an editor save's full repack with the section removals the editor's own
|
|
60
|
+
* edits made.
|
|
61
|
+
*
|
|
62
|
+
* A save refuses a package with fewer sections than its source unless it is
|
|
63
|
+
* told which removals were meant: deleting the paragraph that ends a section,
|
|
64
|
+
* or accepting its tracked deletion, removes that section on purpose. The
|
|
65
|
+
* tracker records exactly those removals; without them the repack throws and
|
|
66
|
+
* the edit cannot be saved.
|
|
67
|
+
*/
|
|
68
|
+
declare const repackWithEditorSectionRemovals: <T>({ state, document, repack }: RepackWithEditorSectionRemovalsOptions<T>) => Promise<T>;
|
|
48
69
|
type MarkTrackedSectionEndpointRemovalOptions = {
|
|
49
70
|
sourceDoc: Node;
|
|
50
71
|
removedEndpointCount: number;
|
|
@@ -52,6 +73,13 @@ type MarkTrackedSectionEndpointRemovalOptions = {
|
|
|
52
73
|
};
|
|
53
74
|
/** Record only a complete, internally consistent endpoint-removal transition. */
|
|
54
75
|
declare function markTrackedSectionEndpointRemoval(tr: Transaction, { sourceDoc, removedEndpointCount, removedReferences }: MarkTrackedSectionEndpointRemovalOptions): Transaction;
|
|
76
|
+
/**
|
|
77
|
+
* Record that `tr` removed section breaks on purpose: a command whose job is
|
|
78
|
+
* to remove the break (not to delete its paragraph mark, which the tracker
|
|
79
|
+
* reads for itself). Only a plain removal is recorded; a transaction that also
|
|
80
|
+
* adds or replaces a record is left as it is.
|
|
81
|
+
*/
|
|
82
|
+
declare function markSectionBreakRemoval(tr: Transaction, sourceDoc: Node): Transaction;
|
|
55
83
|
/**
|
|
56
84
|
* Create a transaction that clears the change tracker
|
|
57
85
|
*/
|
|
@@ -64,9 +92,10 @@ type MarkChangedParagraphRangesOptions = {
|
|
|
64
92
|
to: number;
|
|
65
93
|
}[];
|
|
66
94
|
mappingFrom: number;
|
|
95
|
+
replacesStepMapAt?: number;
|
|
67
96
|
};
|
|
68
97
|
/** Record mark-only paragraph changes whose replacement step has a granular map. */
|
|
69
98
|
declare function markChangedParagraphRanges(tr: Transaction, batch: MarkChangedParagraphRangesOptions): Transaction;
|
|
70
99
|
declare const ParagraphChangeTrackerExtension: (options?: Partial<{}> | undefined) => Extension;
|
|
71
100
|
//#endregion
|
|
72
|
-
export { ParagraphChangeTrackerExtension, ParagraphChangeTrackerState, clearTrackedChanges, getChangeTrackerState, getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges, ignoreTrackedChanges, markChangedParagraphRanges, markStructuralChange, markTrackedSectionEndpointRemoval, paragraphChangeTrackerKey };
|
|
101
|
+
export { ParagraphChangeTrackerExtension, ParagraphChangeTrackerState, clearTrackedChanges, getChangeTrackerState, getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges, ignoreTrackedChanges, markChangedParagraphRanges, markSectionBreakRemoval, markStructuralChange, markTrackedSectionEndpointRemoval, paragraphChangeTrackerKey, repackWithEditorSectionRemovals };
|