@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
|
@@ -17,6 +17,14 @@ const paragraphNumberingAttr = (numbering) => {
|
|
|
17
17
|
default: return panic(`Unhandled paragraph numbering ${JSON.stringify(numbering)}`);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* The `numPr` that takes a paragraph out of its list. When its style supplies
|
|
22
|
+
* the numbering, the paragraph has to state the cancellation (`w:numId="0"`):
|
|
23
|
+
* clearing the attr would uncover the style tier, and the next save hands the
|
|
24
|
+
* numbering straight back. A cancellation states no level (17.9.18: there is
|
|
25
|
+
* no id left for a level to belong to).
|
|
26
|
+
*/
|
|
27
|
+
const removedNumberingAttr = (numPrFromStyle) => numPrFromStyle?.kind === "reference" ? paragraphNumberingAttr(NO_PARAGRAPH_NUMBERING) : null;
|
|
20
28
|
/** A `<w:numPr>` slot value: an ordinal, so a non-integer or a negative is not one. */
|
|
21
29
|
const isNumberingSlot = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
22
30
|
/**
|
|
@@ -71,4 +79,4 @@ const readParagraphNumberingAttr = (value) => {
|
|
|
71
79
|
return numbering;
|
|
72
80
|
};
|
|
73
81
|
//#endregion
|
|
74
|
-
export { paragraphNumberingAttr, paragraphNumberingFromAttrValue, readParagraphNumberingAttr };
|
|
82
|
+
export { paragraphNumberingAttr, paragraphNumberingFromAttrValue, readParagraphNumberingAttr, removedNumberingAttr };
|
|
@@ -17,7 +17,7 @@ import { headingOutlineLevel } from "@stll/docx-core/model";
|
|
|
17
17
|
const outlineLevelFromAttrValue = (value) => {
|
|
18
18
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
19
19
|
const kind = Reflect.get(value, "kind");
|
|
20
|
-
if (kind === "bodyText") return { kind: "bodyText" };
|
|
20
|
+
if (kind === "bodyText") return Reflect.has(value, "level") ? null : { kind: "bodyText" };
|
|
21
21
|
if (kind !== "heading") return null;
|
|
22
22
|
const level = Reflect.get(value, "level");
|
|
23
23
|
return typeof level === "number" ? headingOutlineLevel(level) ?? null : null;
|
|
@@ -6,7 +6,16 @@ import { ParagraphAttrs } from "./schema/nodes.js";
|
|
|
6
6
|
type DirectParagraphIndentation = FolioContentParagraphIndentation;
|
|
7
7
|
/** Project only authored `w:ind` attributes, preserving zero and false. */
|
|
8
8
|
declare const paragraphIndentationFromFormatting: (formatting: document_d_exports.ParagraphFormatting | null | undefined) => DirectParagraphIndentation | undefined;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Read direct indentation without materializing values inherited from a style:
|
|
11
|
+
* the `w:ind` a save writes for the paragraph.
|
|
12
|
+
*
|
|
13
|
+
* A field the source stated reads at its current value. A field it did not
|
|
14
|
+
* reads only when an edit set it to something the style cascade does not
|
|
15
|
+
* supply — reading `_originalFormatting` alone missed every indentation a
|
|
16
|
+
* command set on a paragraph whose source stated none. A hanging indent reads
|
|
17
|
+
* with a negative `indentFirstLine`, as the model states it.
|
|
18
|
+
*/
|
|
10
19
|
declare const directParagraphIndentation: (attrs: ParagraphAttrs) => DirectParagraphIndentation | undefined;
|
|
11
20
|
declare const paragraphIndentationEqual: (left: DirectParagraphIndentation | null | undefined, right: DirectParagraphIndentation | null | undefined) => boolean;
|
|
12
21
|
/** Replace the complete direct `w:ind` cluster in canonical formatting. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { paragraphNumberingReferenceId } from "../docx/numberingReference.js";
|
|
1
2
|
import { panic } from "better-result";
|
|
2
3
|
//#region src/prosemirror/paragraphIndentation.ts
|
|
3
4
|
const DIRECT_PARAGRAPH_INDENTATION_KEYS = [
|
|
@@ -31,19 +32,43 @@ const paragraphIndentationFromFormatting = (formatting) => {
|
|
|
31
32
|
if (indentation.indentFirstLine !== void 0 && indentation.hangingIndent === void 0) indentation.hangingIndent = false;
|
|
32
33
|
return Object.keys(indentation).length > 0 ? indentation : void 0;
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
+
const PARAGRAPH_INDENTATION_VALUE_KEYS = [
|
|
36
|
+
"indentLeft",
|
|
37
|
+
"indentRight",
|
|
38
|
+
"indentFirstLine"
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Read direct indentation without materializing values inherited from a style:
|
|
42
|
+
* the `w:ind` a save writes for the paragraph.
|
|
43
|
+
*
|
|
44
|
+
* A field the source stated reads at its current value. A field it did not
|
|
45
|
+
* reads only when an edit set it to something the style cascade does not
|
|
46
|
+
* supply — reading `_originalFormatting` alone missed every indentation a
|
|
47
|
+
* command set on a paragraph whose source stated none. A hanging indent reads
|
|
48
|
+
* with a negative `indentFirstLine`, as the model states it.
|
|
49
|
+
*/
|
|
35
50
|
const directParagraphIndentation = (attrs) => {
|
|
36
|
-
const original =
|
|
37
|
-
|
|
51
|
+
const original = attrs._originalFormatting ?? void 0;
|
|
52
|
+
const resolved = attrs._resolvedFormatting;
|
|
53
|
+
const numbered = paragraphNumberingReferenceId(attrs.numPr ?? void 0) !== void 0;
|
|
38
54
|
const indentation = {};
|
|
39
|
-
for (const key of
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
for (const key of PARAGRAPH_INDENTATION_VALUE_KEYS) {
|
|
56
|
+
const value = attrs[key];
|
|
57
|
+
if (typeof value !== "number") continue;
|
|
58
|
+
const stated = original?.[key] !== void 0;
|
|
59
|
+
const zeroIsDefault = key === "indentRight" || !numbered;
|
|
60
|
+
const inherited = resolved?.[key] === value || original === void 0 && value === 0 && zeroIsDefault;
|
|
61
|
+
if (stated || !inherited) copyIndentationValue({
|
|
42
62
|
target: indentation,
|
|
43
63
|
key,
|
|
44
|
-
value
|
|
64
|
+
value
|
|
45
65
|
});
|
|
46
66
|
}
|
|
67
|
+
if (indentation.indentFirstLine !== void 0) {
|
|
68
|
+
const hanging = attrs.hangingIndent === true;
|
|
69
|
+
indentation.hangingIndent = hanging;
|
|
70
|
+
if (hanging) indentation.indentFirstLine = -Math.abs(indentation.indentFirstLine);
|
|
71
|
+
} else if (original?.hangingIndent !== void 0 && original.indentFirstLine === void 0 && typeof attrs.hangingIndent === "boolean") indentation.hangingIndent = attrs.hangingIndent;
|
|
47
72
|
return Object.keys(indentation).length > 0 ? indentation : void 0;
|
|
48
73
|
};
|
|
49
74
|
const paragraphIndentationEqual = (left, right) => DIRECT_PARAGRAPH_INDENTATION_KEYS.every((key) => left?.[key] === right?.[key]);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RunStyleResolver } from "./runStyleFormatting.js";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import { Transaction } from "prosemirror-state";
|
|
4
|
+
//#region src/prosemirror/paragraphMarkJoin.d.ts
|
|
5
|
+
type JoinAtParagraphMarkOptions = {
|
|
6
|
+
tr: Transaction;
|
|
7
|
+
/** Position of the paragraph whose mark goes. */
|
|
8
|
+
paragraphPos: number;
|
|
9
|
+
paragraph: Node;
|
|
10
|
+
/** The paragraph directly after it, which the join runs into. */
|
|
11
|
+
next: Node;
|
|
12
|
+
/**
|
|
13
|
+
* Re-reads the moved runs' inherited formatting in the next paragraph's
|
|
14
|
+
* style. Without one, the editor's join restyler does it when the
|
|
15
|
+
* transaction is dispatched.
|
|
16
|
+
*/
|
|
17
|
+
styleResolver: RunStyleResolver | null;
|
|
18
|
+
};
|
|
19
|
+
declare const joinAtParagraphMark: ({ tr, paragraphPos, paragraph, next, styleResolver }: JoinAtParagraphMarkOptions) => void;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { joinAtParagraphMark };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { joinProseParagraphsWithRightPropertySource } from "../docx/paragraphPropertySource.js";
|
|
2
|
+
import { JOINED_RUNS_RESTYLED_META } from "./extensions/features/JoinedRunStyleExtension.js";
|
|
3
|
+
import { rebaseParagraphRuns } from "./rebaseParagraphRunFormatting.js";
|
|
4
|
+
import { paragraphRunStyleContext } from "./runStyleFormatting.js";
|
|
5
|
+
//#region src/prosemirror/paragraphMarkJoin.ts
|
|
6
|
+
const joinAtParagraphMark = ({ tr, paragraphPos, paragraph, next, styleResolver }) => {
|
|
7
|
+
joinProseParagraphsWithRightPropertySource({
|
|
8
|
+
attrs: next.attrs,
|
|
9
|
+
pos: paragraphPos + paragraph.nodeSize,
|
|
10
|
+
transaction: tr
|
|
11
|
+
});
|
|
12
|
+
if (!styleResolver) return;
|
|
13
|
+
if (paragraph.content.size > 0) rebaseParagraphRuns({
|
|
14
|
+
previousContext: paragraphRunStyleContext(paragraph, styleResolver),
|
|
15
|
+
paragraphPosition: paragraphPos,
|
|
16
|
+
range: {
|
|
17
|
+
from: 0,
|
|
18
|
+
to: paragraph.content.size
|
|
19
|
+
},
|
|
20
|
+
styleResolver,
|
|
21
|
+
tr
|
|
22
|
+
});
|
|
23
|
+
tr.setMeta(JOINED_RUNS_RESTYLED_META, true);
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { joinAtParagraphMark };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ParagraphPropertyChangeAttrs } from "./schema/nodes.js";
|
|
2
|
+
import { RunStyleResolver } from "./runStyleFormatting.js";
|
|
3
|
+
import { NumberingMap } from "../docx/numberingParser.js";
|
|
4
|
+
import { Node } from "prosemirror-model";
|
|
5
|
+
import { Transaction } from "prosemirror-state";
|
|
6
|
+
//#region src/prosemirror/paragraphPropertyCarry.d.ts
|
|
7
|
+
type CarryParagraphPropertiesOptions = {
|
|
8
|
+
tr: Transaction;
|
|
9
|
+
/** The paragraph that takes the properties. */
|
|
10
|
+
position: number;
|
|
11
|
+
/** The paragraph whose properties it takes. */
|
|
12
|
+
source: Node;
|
|
13
|
+
styleResolver: RunStyleResolver | null;
|
|
14
|
+
numbering: NumberingMap | null;
|
|
15
|
+
/** Records the change as a tracked property change; applied directly when omitted. */
|
|
16
|
+
revision?: ParagraphPropertyChangeAttrs["info"];
|
|
17
|
+
/** Properties the paragraph keeps its own values of: ones its own batch set. */
|
|
18
|
+
keep?: ReadonlySet<string>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Give a paragraph another one's properties: the pPr a property change
|
|
22
|
+
* covers. Its identity, mark, mark run properties and section stay its own,
|
|
23
|
+
* and its runs are re-read in the new style. `tracked` says whether a property
|
|
24
|
+
* change now records what it had: a paragraph holds one, and a pending one
|
|
25
|
+
* already records it.
|
|
26
|
+
*/
|
|
27
|
+
declare const carryParagraphProperties: ({ tr, position, source, styleResolver, numbering, revision, keep }: CarryParagraphPropertiesOptions) => {
|
|
28
|
+
tr: Transaction;
|
|
29
|
+
changed: boolean;
|
|
30
|
+
tracked: boolean;
|
|
31
|
+
};
|
|
32
|
+
type ParagraphLeftAfterOptions = {
|
|
33
|
+
doc: Node;
|
|
34
|
+
paragraphPos: number;
|
|
35
|
+
/** Breaks a batch's deferred final-paragraph deletion will remove. */
|
|
36
|
+
removedBreakPositions?: ReadonlySet<number>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The paragraph left once the break of the paragraph at `paragraphPos` goes:
|
|
40
|
+
* the next one, or, when its own break is pending deletion too, the first
|
|
41
|
+
* paragraph after it whose break stays. Null when no paragraph follows.
|
|
42
|
+
*/
|
|
43
|
+
declare const paragraphLeftAfter: ({ doc, paragraphPos, removedBreakPositions }: ParagraphLeftAfterOptions) => number | null;
|
|
44
|
+
/**
|
|
45
|
+
* A paragraph now holds the break another one had (a split, or a paste into
|
|
46
|
+
* it, leaves that break on the last part) but reads with other properties:
|
|
47
|
+
* record the other's as its property change. Rejecting the inserted breaks
|
|
48
|
+
* leaves this paragraph, which then reads as the one that was there. A
|
|
49
|
+
* pending property change on the other one travels as it is. Returns whether
|
|
50
|
+
* a change under `revision` was written.
|
|
51
|
+
*/
|
|
52
|
+
declare const recordReplacedParagraphProperties: ({ tr, position, replaced, revision }: {
|
|
53
|
+
tr: Transaction;
|
|
54
|
+
position: number;
|
|
55
|
+
replaced: Node;
|
|
56
|
+
revision: ParagraphPropertyChangeAttrs["info"];
|
|
57
|
+
}) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The properties a batch's own property change set on a paragraph: the ones
|
|
60
|
+
* whose value differs from what that change records as before.
|
|
61
|
+
*/
|
|
62
|
+
declare const propertiesSetInBatch: (node: Node, batchRevisionIds: ReadonlySet<number>) => ReadonlySet<string>;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { carryParagraphProperties, paragraphLeftAfter, propertiesSetInBatch, recordReplacedParagraphProperties };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { expectParagraphAttrs } from "./attrs/index.js";
|
|
2
|
+
import { hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot } from "./commands/propertyChangeScope.js";
|
|
3
|
+
import { resolveParagraphChangeAttrs } from "./commands/resolveParagraphProperties.js";
|
|
4
|
+
import { rebaseParagraphRuns } from "./rebaseParagraphRunFormatting.js";
|
|
5
|
+
import { paragraphRunStyleContext } from "./runStyleFormatting.js";
|
|
6
|
+
import { panic } from "better-result";
|
|
7
|
+
//#region src/prosemirror/paragraphPropertyCarry.ts
|
|
8
|
+
/**
|
|
9
|
+
* Handing one paragraph's properties to another, as a removed paragraph mark
|
|
10
|
+
* requires.
|
|
11
|
+
*
|
|
12
|
+
* A paragraph's properties live on its mark, and a removed mark leaves the
|
|
13
|
+
* paragraph after it: that is the paragraph left once the change is accepted.
|
|
14
|
+
* An edit that should read as the FIRST paragraph (a merge, a Backspace at a
|
|
15
|
+
* paragraph's start, a deletion across paragraphs) therefore gives the second
|
|
16
|
+
* the first's properties, recorded as a property change under the same
|
|
17
|
+
* revision, so accepting reads as the direct edit and rejecting restores the
|
|
18
|
+
* second's own.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Give a paragraph another one's properties: the pPr a property change
|
|
22
|
+
* covers. Its identity, mark, mark run properties and section stay its own,
|
|
23
|
+
* and its runs are re-read in the new style. `tracked` says whether a property
|
|
24
|
+
* change now records what it had: a paragraph holds one, and a pending one
|
|
25
|
+
* already records it.
|
|
26
|
+
*/
|
|
27
|
+
const carryParagraphProperties = ({ tr, position, source, styleResolver, numbering, revision, keep }) => {
|
|
28
|
+
const target = tr.doc.nodeAt(position);
|
|
29
|
+
if (!target || target.type !== source.type) return {
|
|
30
|
+
tr,
|
|
31
|
+
changed: false,
|
|
32
|
+
tracked: false
|
|
33
|
+
};
|
|
34
|
+
const previousFormatting = paragraphPropertiesSnapshot(target);
|
|
35
|
+
const own = previousFormatting;
|
|
36
|
+
const formatting = Object.fromEntries([...Object.entries(paragraphPropertiesSnapshot(source)).filter(([key]) => !keep?.has(key)), ...Object.entries(own).filter(([key]) => keep?.has(key))]);
|
|
37
|
+
if (JSON.stringify(previousFormatting) === JSON.stringify(formatting)) return {
|
|
38
|
+
tr,
|
|
39
|
+
changed: false,
|
|
40
|
+
tracked: false
|
|
41
|
+
};
|
|
42
|
+
const existing = expectParagraphAttrs(target)._propertyChanges;
|
|
43
|
+
const tracked = revision !== void 0 && !hasSerializableParagraphPropertyChange(existing);
|
|
44
|
+
const carried = resolveParagraphChangeAttrs({
|
|
45
|
+
node: target.type.create({
|
|
46
|
+
...target.attrs,
|
|
47
|
+
_propertyChanges: [{
|
|
48
|
+
type: "paragraphPropertyChange",
|
|
49
|
+
info: {
|
|
50
|
+
id: -1,
|
|
51
|
+
author: "",
|
|
52
|
+
date: "1970-01-01T00:00:00Z"
|
|
53
|
+
},
|
|
54
|
+
previousFormatting: formatting
|
|
55
|
+
}]
|
|
56
|
+
}, target.content, target.marks),
|
|
57
|
+
mode: "reject",
|
|
58
|
+
boundaryCovered: true,
|
|
59
|
+
revisionSet: null,
|
|
60
|
+
styleResolver,
|
|
61
|
+
numbering
|
|
62
|
+
});
|
|
63
|
+
if (!carried) return panic("Paragraph properties did not pass to the paragraph", { position });
|
|
64
|
+
const changes = [...Array.isArray(existing) ? existing : [], ...tracked && revision ? [{
|
|
65
|
+
type: "paragraphPropertyChange",
|
|
66
|
+
info: revision,
|
|
67
|
+
previousFormatting
|
|
68
|
+
}] : []];
|
|
69
|
+
tr.setNodeMarkup(position, void 0, {
|
|
70
|
+
...carried,
|
|
71
|
+
...carriedNumberingProvenance(source, target, keep),
|
|
72
|
+
_sectionProperties: target.attrs["_sectionProperties"],
|
|
73
|
+
_propertyChanges: changes.length > 0 ? changes : null
|
|
74
|
+
});
|
|
75
|
+
if (styleResolver) rebaseParagraphRuns({
|
|
76
|
+
previousContext: paragraphRunStyleContext(target, styleResolver),
|
|
77
|
+
paragraphPosition: position,
|
|
78
|
+
styleResolver,
|
|
79
|
+
tr
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
tr,
|
|
83
|
+
changed: true,
|
|
84
|
+
tracked
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Whether the carried numbering is the paragraph's own or its style's: the
|
|
89
|
+
* record holds `numPr` as the paragraph reads it, and a style's numbering
|
|
90
|
+
* stays the style's rather than becoming the paragraph's own `w:numPr`.
|
|
91
|
+
*/
|
|
92
|
+
const carriedNumberingProvenance = (source, target, keep) => ({ numPrFromStyle: expectParagraphAttrs(keep?.has("numPr") ? target : source).numPrFromStyle });
|
|
93
|
+
/**
|
|
94
|
+
* The paragraph left once the break of the paragraph at `paragraphPos` goes:
|
|
95
|
+
* the next one, or, when its own break is pending deletion too, the first
|
|
96
|
+
* paragraph after it whose break stays. Null when no paragraph follows.
|
|
97
|
+
*/
|
|
98
|
+
const paragraphLeftAfter = ({ doc, paragraphPos, removedBreakPositions }) => {
|
|
99
|
+
let position = paragraphPos;
|
|
100
|
+
const start = doc.nodeAt(position);
|
|
101
|
+
if (!start) return null;
|
|
102
|
+
let node = start;
|
|
103
|
+
for (;;) {
|
|
104
|
+
const nextPos = position + node.nodeSize;
|
|
105
|
+
const next = doc.resolve(nextPos).nodeAfter;
|
|
106
|
+
if (!next || next.type !== node.type) return null;
|
|
107
|
+
const mark = expectParagraphAttrs(next).pPrMark;
|
|
108
|
+
const nextGoes = removedBreakPositions?.has(nextPos) || mark != null && (mark.kind === "del" || mark.kind === "moveFrom");
|
|
109
|
+
const afterNext = doc.resolve(nextPos + next.nodeSize).nodeAfter;
|
|
110
|
+
if (!nextGoes || afterNext?.type !== node.type) return nextPos;
|
|
111
|
+
position = nextPos;
|
|
112
|
+
node = next;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const recordedFormatting = (node) => ({
|
|
116
|
+
...paragraphPropertiesSnapshot(node),
|
|
117
|
+
numPr: expectParagraphAttrs(node).numPr ?? null
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* A paragraph now holds the break another one had (a split, or a paste into
|
|
121
|
+
* it, leaves that break on the last part) but reads with other properties:
|
|
122
|
+
* record the other's as its property change. Rejecting the inserted breaks
|
|
123
|
+
* leaves this paragraph, which then reads as the one that was there. A
|
|
124
|
+
* pending property change on the other one travels as it is. Returns whether
|
|
125
|
+
* a change under `revision` was written.
|
|
126
|
+
*/
|
|
127
|
+
const recordReplacedParagraphProperties = ({ tr, position, replaced, revision }) => {
|
|
128
|
+
const target = tr.doc.nodeAt(position);
|
|
129
|
+
if (!target || target.type !== replaced.type) return false;
|
|
130
|
+
if (hasSerializableParagraphPropertyChange(expectParagraphAttrs(target)._propertyChanges)) return false;
|
|
131
|
+
const pending = expectParagraphAttrs(replaced)._propertyChanges;
|
|
132
|
+
if (hasSerializableParagraphPropertyChange(pending)) {
|
|
133
|
+
tr.setNodeAttribute(position, "_propertyChanges", pending);
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
const previousFormatting = recordedFormatting(replaced);
|
|
137
|
+
if (JSON.stringify(previousFormatting) === JSON.stringify(recordedFormatting(target))) return false;
|
|
138
|
+
tr.setNodeAttribute(position, "_propertyChanges", [{
|
|
139
|
+
type: "paragraphPropertyChange",
|
|
140
|
+
info: revision,
|
|
141
|
+
previousFormatting
|
|
142
|
+
}]);
|
|
143
|
+
return true;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* The properties a batch's own property change set on a paragraph: the ones
|
|
147
|
+
* whose value differs from what that change records as before.
|
|
148
|
+
*/
|
|
149
|
+
const propertiesSetInBatch = (node, batchRevisionIds) => {
|
|
150
|
+
const changes = expectParagraphAttrs(node)._propertyChanges;
|
|
151
|
+
const change = Array.isArray(changes) ? changes.find(({ info }) => batchRevisionIds.has(info.id)) : void 0;
|
|
152
|
+
if (change === void 0) return /* @__PURE__ */ new Set();
|
|
153
|
+
const before = change.previousFormatting ?? {};
|
|
154
|
+
const now = paragraphPropertiesSnapshot(node);
|
|
155
|
+
return new Set([.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(now)])].filter((key) => JSON.stringify(before[key]) !== JSON.stringify(now[key])));
|
|
156
|
+
};
|
|
157
|
+
//#endregion
|
|
158
|
+
export { carryParagraphProperties, paragraphLeftAfter, propertiesSetInBatch, recordReplacedParagraphProperties };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
2
1
|
import { Node } from "prosemirror-model";
|
|
2
|
+
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
3
3
|
//#region src/prosemirror/plugins/createDocScanPlugin.d.ts
|
|
4
4
|
declare const SET_META = "set";
|
|
5
5
|
type DocScanState<TConfig, TRange> = {
|
|
@@ -3,8 +3,34 @@ import { NumberingMap } from "../../docx/numberingParser.js";
|
|
|
3
3
|
import { EditorState, Plugin } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/plugins/documentNumbering.d.ts
|
|
5
5
|
declare const createDocumentNumberingPlugin: (definitions: document_d_exports.NumberingDefinitions | null | undefined) => Plugin;
|
|
6
|
+
/**
|
|
7
|
+
* The numbering the document's paragraphs resolve against: the package's
|
|
8
|
+
* definitions plus every instance a list command defined in this document.
|
|
9
|
+
* An instance whose paragraphs were all deleted may linger until the next
|
|
10
|
+
* completion; the save completes from the document itself.
|
|
11
|
+
*/
|
|
6
12
|
declare const getDocumentNumbering: (state: EditorState) => NumberingMap | null;
|
|
13
|
+
/** The package's own definitions, without the instances the document defines. */
|
|
14
|
+
declare const getPackageNumberingDefinitions: (state: EditorState) => document_d_exports.NumberingDefinitions | null;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the state knows its document's numbering at all. A state without
|
|
17
|
+
* the plugin cannot tell a package with no numbering part from one it was
|
|
18
|
+
* never told about.
|
|
19
|
+
*/
|
|
20
|
+
declare const hasDocumentNumbering: (state: EditorState) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The document's numbering definitions: `null` for a document without a
|
|
23
|
+
* numbering part, `undefined` when the state carries no numbering plugin and
|
|
24
|
+
* so cannot say what the document defines.
|
|
25
|
+
*/
|
|
26
|
+
declare const getStatedDocumentNumbering: (state: EditorState) => document_d_exports.NumberingDefinitions | null | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The numbering instances (`w:num` ids) the document defines, or `null` when
|
|
29
|
+
* the state carries no numbering plugin and so cannot say. A document without
|
|
30
|
+
* a numbering part defines none.
|
|
31
|
+
*/
|
|
32
|
+
declare const getDocumentNumberingInstanceIds: (state: EditorState) => ReadonlySet<number> | null;
|
|
7
33
|
/** Replace numbering state while retaining every unrelated plugin state. */
|
|
8
34
|
declare const withDocumentNumbering: (state: EditorState, definitions: document_d_exports.NumberingDefinitions) => EditorState;
|
|
9
35
|
//#endregion
|
|
10
|
-
export { createDocumentNumberingPlugin, getDocumentNumbering, withDocumentNumbering };
|
|
36
|
+
export { createDocumentNumberingPlugin, getDocumentNumbering, getDocumentNumberingInstanceIds, getPackageNumberingDefinitions, getStatedDocumentNumbering, hasDocumentNumbering, withDocumentNumbering };
|
|
@@ -1,19 +1,105 @@
|
|
|
1
1
|
import { getCachedNumberingMap } from "../../docx/numberingParser.js";
|
|
2
|
+
import { completeNumberingForDoc, paragraphListReferences } from "../listInstanceReferences.js";
|
|
3
|
+
import { AddMarkStep, DocAttrStep, RemoveMarkStep, ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
|
|
2
4
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
5
|
//#region src/prosemirror/plugins/documentNumbering.ts
|
|
4
|
-
/** Document-scoped numbering definitions for list-editing commands. */
|
|
5
6
|
const documentNumberingKey = new PluginKey("documentNumbering");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const completedState = (definitions, doc) => {
|
|
8
|
+
const completed = completeNumberingForDoc(definitions ?? void 0, doc);
|
|
9
|
+
return {
|
|
10
|
+
definitions,
|
|
11
|
+
map: completed ? getCachedNumberingMap(completed) : null
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/** Steps that can change a paragraph's attrs or bring paragraphs in, by what they replace. */
|
|
15
|
+
const isReplace = (step) => step instanceof ReplaceStep || step instanceof ReplaceAroundStep;
|
|
16
|
+
/** Steps that change nothing a numbering reference lives in. */
|
|
17
|
+
const leavesParagraphAttrs = (step) => step instanceof AddMarkStep || step instanceof RemoveMarkStep || step instanceof DocAttrStep;
|
|
18
|
+
/**
|
|
19
|
+
* Whether `tr` may have introduced a reference `map` does not define. Only the
|
|
20
|
+
* ranges its steps replaced are read, so typing costs one paragraph, not the
|
|
21
|
+
* document. A step that changes attrs in place (not by replacement) is not
|
|
22
|
+
* localised and answers yes.
|
|
23
|
+
*/
|
|
24
|
+
const mayReferenceUnknownInstance = (tr, map) => {
|
|
25
|
+
const ranges = [];
|
|
26
|
+
for (const [index, step] of tr.steps.entries()) {
|
|
27
|
+
if (leavesParagraphAttrs(step)) continue;
|
|
28
|
+
if (!isReplace(step)) return true;
|
|
29
|
+
const later = tr.mapping.slice(index + 1);
|
|
30
|
+
step.getMap().forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
31
|
+
ranges.push({
|
|
32
|
+
from: later.map(newStart, -1),
|
|
33
|
+
to: later.map(newEnd, 1)
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const size = tr.doc.content.size;
|
|
38
|
+
const isUnknown = (numId) => !(map?.hasNumbering(numId) ?? false);
|
|
39
|
+
return ranges.some(({ from, to }) => {
|
|
40
|
+
let unknown = false;
|
|
41
|
+
const start = Math.min(Math.max(0, from), size);
|
|
42
|
+
tr.doc.nodesBetween(start, Math.min(Math.max(start, to), size), (node) => {
|
|
43
|
+
if (unknown) return false;
|
|
44
|
+
if (node.type.name !== "paragraph") return true;
|
|
45
|
+
unknown = paragraphListReferences(node).some(isUnknown);
|
|
46
|
+
return false;
|
|
47
|
+
});
|
|
48
|
+
return unknown;
|
|
14
49
|
});
|
|
15
50
|
};
|
|
16
|
-
const
|
|
51
|
+
const createDocumentNumberingPlugin = (definitions) => new Plugin({
|
|
52
|
+
key: documentNumberingKey,
|
|
53
|
+
state: {
|
|
54
|
+
init: (_config, state) => completedState(definitions ?? null, state.doc),
|
|
55
|
+
apply: (tr, current, _oldState, state) => tr.docChanged && mayReferenceUnknownInstance(tr, current.map) ? completedState(current.definitions, state.doc) : current
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
/** Numbering for states without the plugin, one per document node. */
|
|
59
|
+
const untrackedNumbering = /* @__PURE__ */ new WeakMap();
|
|
60
|
+
/**
|
|
61
|
+
* The numbering the document's paragraphs resolve against: the package's
|
|
62
|
+
* definitions plus every instance a list command defined in this document.
|
|
63
|
+
* An instance whose paragraphs were all deleted may linger until the next
|
|
64
|
+
* completion; the save completes from the document itself.
|
|
65
|
+
*/
|
|
66
|
+
const getDocumentNumbering = (state) => {
|
|
67
|
+
const tracked = documentNumberingKey.getState(state);
|
|
68
|
+
if (tracked) return tracked.map;
|
|
69
|
+
let untracked = untrackedNumbering.get(state.doc);
|
|
70
|
+
if (!untracked) {
|
|
71
|
+
untracked = completedState(null, state.doc);
|
|
72
|
+
untrackedNumbering.set(state.doc, untracked);
|
|
73
|
+
}
|
|
74
|
+
return untracked.map;
|
|
75
|
+
};
|
|
76
|
+
/** The package's own definitions, without the instances the document defines. */
|
|
77
|
+
const getPackageNumberingDefinitions = (state) => documentNumberingKey.getState(state)?.definitions ?? null;
|
|
78
|
+
/**
|
|
79
|
+
* Whether the state knows its document's numbering at all. A state without
|
|
80
|
+
* the plugin cannot tell a package with no numbering part from one it was
|
|
81
|
+
* never told about.
|
|
82
|
+
*/
|
|
83
|
+
const hasDocumentNumbering = (state) => documentNumberingKey.get(state) !== void 0;
|
|
84
|
+
/**
|
|
85
|
+
* The document's numbering definitions: `null` for a document without a
|
|
86
|
+
* numbering part, `undefined` when the state carries no numbering plugin and
|
|
87
|
+
* so cannot say what the document defines.
|
|
88
|
+
*/
|
|
89
|
+
const getStatedDocumentNumbering = (state) => {
|
|
90
|
+
if (documentNumberingKey.get(state) === void 0) return;
|
|
91
|
+
return getDocumentNumbering(state)?.definitions ?? null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The numbering instances (`w:num` ids) the document defines, or `null` when
|
|
95
|
+
* the state carries no numbering plugin and so cannot say. A document without
|
|
96
|
+
* a numbering part defines none.
|
|
97
|
+
*/
|
|
98
|
+
const getDocumentNumberingInstanceIds = (state) => {
|
|
99
|
+
const numbering = getStatedDocumentNumbering(state);
|
|
100
|
+
if (numbering === void 0) return null;
|
|
101
|
+
return new Set(numbering?.nums.map(({ numId }) => numId) ?? []);
|
|
102
|
+
};
|
|
17
103
|
/** Replace numbering state while retaining every unrelated plugin state. */
|
|
18
104
|
const withDocumentNumbering = (state, definitions) => {
|
|
19
105
|
const previous = documentNumberingKey.get(state);
|
|
@@ -21,4 +107,4 @@ const withDocumentNumbering = (state, definitions) => {
|
|
|
21
107
|
return state.reconfigure({ plugins: retained }).reconfigure({ plugins: [...retained, createDocumentNumberingPlugin(definitions)] });
|
|
22
108
|
};
|
|
23
109
|
//#endregion
|
|
24
|
-
export { createDocumentNumberingPlugin, getDocumentNumbering, withDocumentNumbering };
|
|
110
|
+
export { createDocumentNumberingPlugin, getDocumentNumbering, getDocumentNumberingInstanceIds, getPackageNumberingDefinitions, getStatedDocumentNumbering, hasDocumentNumbering, withDocumentNumbering };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { BuiltInStyleIndex } from "../../docx/builtInStyles.js";
|
|
3
|
+
import { StyleResolver } from "../styles/styleResolver.js";
|
|
4
|
+
import { EditorState, PluginKey } from "prosemirror-state";
|
|
5
|
+
//#region src/prosemirror/plugins/documentStyleState.d.ts
|
|
6
|
+
declare const documentStylesKey: PluginKey<StyleResolver | null>;
|
|
7
|
+
/** Read the document's StyleResolver, or null when the plugin isn't installed. */
|
|
8
|
+
declare function getDocumentStyleResolver(state: EditorState): StyleResolver | null;
|
|
9
|
+
/**
|
|
10
|
+
* The document's style definitions by id, or `null` when the state carries no
|
|
11
|
+
* styles plugin and so cannot say what the document defines. A document
|
|
12
|
+
* without a styles part defines none.
|
|
13
|
+
*/
|
|
14
|
+
declare function getDocumentStyleDefinitions(state: EditorState): {
|
|
15
|
+
get: (styleId: string) => document_d_exports.Style | undefined;
|
|
16
|
+
paragraphStyles: () => document_d_exports.Style[];
|
|
17
|
+
} | null;
|
|
18
|
+
/**
|
|
19
|
+
* Read the document's built-in style index, for the callers that classify
|
|
20
|
+
* paragraphs (heading collection, markdown export, the AI snapshot). Without
|
|
21
|
+
* the plugin every lookup misses, which degrades classification to the
|
|
22
|
+
* paragraph's own outline level rather than to English style ids.
|
|
23
|
+
*/
|
|
24
|
+
declare function getDocumentBuiltInStyles(state: EditorState): BuiltInStyleIndex;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleDefinitions, getDocumentStyleResolver };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EMPTY_BUILT_IN_STYLE_INDEX } from "../../docx/builtInStyles.js";
|
|
2
|
+
import { PluginKey } from "prosemirror-state";
|
|
3
|
+
//#region src/prosemirror/plugins/documentStyleState.ts
|
|
4
|
+
const documentStylesKey = new PluginKey("documentStyles");
|
|
5
|
+
/** Read the document's StyleResolver, or null when the plugin isn't installed. */
|
|
6
|
+
function getDocumentStyleResolver(state) {
|
|
7
|
+
return documentStylesKey.getState(state) ?? null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The document's style definitions by id, or `null` when the state carries no
|
|
11
|
+
* styles plugin and so cannot say what the document defines. A document
|
|
12
|
+
* without a styles part defines none.
|
|
13
|
+
*/
|
|
14
|
+
function getDocumentStyleDefinitions(state) {
|
|
15
|
+
if (documentStylesKey.get(state) === void 0) return null;
|
|
16
|
+
const resolver = getDocumentStyleResolver(state);
|
|
17
|
+
return {
|
|
18
|
+
get: (styleId) => resolver?.getStyle(styleId),
|
|
19
|
+
paragraphStyles: () => resolver?.getParagraphStyles() ?? []
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read the document's built-in style index, for the callers that classify
|
|
24
|
+
* paragraphs (heading collection, markdown export, the AI snapshot). Without
|
|
25
|
+
* the plugin every lookup misses, which degrades classification to the
|
|
26
|
+
* paragraph's own outline level rather than to English style ids.
|
|
27
|
+
*/
|
|
28
|
+
function getDocumentBuiltInStyles(state) {
|
|
29
|
+
return getDocumentStyleResolver(state)?.builtInStyles ?? EMPTY_BUILT_IN_STYLE_INDEX;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleDefinitions, getDocumentStyleResolver };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
-
import { BuiltInStyleIndex } from "../../docx/builtInStyles.js";
|
|
3
2
|
import { StyleResolver } from "../styles/styleResolver.js";
|
|
4
|
-
import {
|
|
3
|
+
import { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleDefinitions, getDocumentStyleResolver } from "./documentStyleState.js";
|
|
4
|
+
import { EditorState, Plugin } from "prosemirror-state";
|
|
5
5
|
//#region src/prosemirror/plugins/documentStyles.d.ts
|
|
6
|
-
declare const documentStylesKey: PluginKey<StyleResolver | null>;
|
|
7
6
|
/**
|
|
8
7
|
* Create the plugin holding a StyleResolver for the document's `styles` for
|
|
9
8
|
* the lifetime of the EditorState. The resolver is fixed per document load;
|
|
@@ -12,16 +11,7 @@ declare const documentStylesKey: PluginKey<StyleResolver | null>;
|
|
|
12
11
|
* have one.
|
|
13
12
|
*/
|
|
14
13
|
declare function createDocumentStylesPlugin(styles: document_d_exports.StyleDefinitions | StyleResolver | null | undefined): Plugin;
|
|
15
|
-
/** Read the document's StyleResolver, or null when the plugin isn't installed. */
|
|
16
|
-
declare function getDocumentStyleResolver(state: EditorState): StyleResolver | null;
|
|
17
|
-
/**
|
|
18
|
-
* Read the document's built-in style index, for the callers that classify
|
|
19
|
-
* paragraphs (heading collection, markdown export, the AI snapshot). Without
|
|
20
|
-
* the plugin every lookup misses, which degrades classification to the
|
|
21
|
-
* paragraph's own outline level rather than to English style ids.
|
|
22
|
-
*/
|
|
23
|
-
declare function getDocumentBuiltInStyles(state: EditorState): BuiltInStyleIndex;
|
|
24
14
|
/** Reconfigure so ProseMirror replaces the keyed plugin's resolver state. */
|
|
25
15
|
declare const withDocumentStyles: (state: EditorState, styles: document_d_exports.StyleDefinitions | StyleResolver | null | undefined) => EditorState;
|
|
26
16
|
//#endregion
|
|
27
|
-
export { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver, withDocumentStyles };
|
|
17
|
+
export { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleDefinitions, getDocumentStyleResolver, withDocumentStyles };
|