@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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { BUILT_IN_STYLE_NAME } from "../docx/builtInStyles.js";
|
|
2
|
+
import { getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
3
|
+
import { isSuggestionModeActive, makeRevisionInfo, suggestRangeDeletion } from "./plugins/suggestionMode.js";
|
|
4
|
+
import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "./runFormattingReconciliation.js";
|
|
5
|
+
import { paragraphRunStyleContextAt } from "./runStyleFormatting.js";
|
|
6
|
+
//#region src/prosemirror/hyperlinkRemoval.ts
|
|
7
|
+
/** Contiguous stretches of linked, not yet deleted, text in [`from`, `to`) of `doc`. */
|
|
8
|
+
const linkedRanges = (doc, from, to) => {
|
|
9
|
+
const ranges = [];
|
|
10
|
+
doc.nodesBetween(from, to, (node, position) => {
|
|
11
|
+
if (!node.isText || !node.marks.some(({ type }) => type.name === "hyperlink") || node.marks.some(({ type }) => type.name === "deletion")) return true;
|
|
12
|
+
const start = Math.max(position, from);
|
|
13
|
+
const end = Math.min(position + node.nodeSize, to);
|
|
14
|
+
if (start >= end) return true;
|
|
15
|
+
const piece = {
|
|
16
|
+
from: start,
|
|
17
|
+
to: end,
|
|
18
|
+
node: node.cut(start - position, end - position)
|
|
19
|
+
};
|
|
20
|
+
const last = ranges.at(-1);
|
|
21
|
+
if (last && last.to === start) {
|
|
22
|
+
last.to = end;
|
|
23
|
+
last.pieces.push(piece);
|
|
24
|
+
} else ranges.push({
|
|
25
|
+
from: start,
|
|
26
|
+
to: end,
|
|
27
|
+
pieces: [piece]
|
|
28
|
+
});
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
return ranges;
|
|
32
|
+
};
|
|
33
|
+
/** A piece's marks once the Hyperlink character style is taken off it. */
|
|
34
|
+
const withoutHyperlinkStyle = (state, doc, piece) => {
|
|
35
|
+
const styleResolver = getDocumentStyleResolver(state);
|
|
36
|
+
const builtInStyles = getDocumentBuiltInStyles(state);
|
|
37
|
+
const context = paragraphRunStyleContextAt({
|
|
38
|
+
doc,
|
|
39
|
+
pos: piece.from,
|
|
40
|
+
styleResolver
|
|
41
|
+
});
|
|
42
|
+
const previousFormatting = readAuthoredRunFormatting({
|
|
43
|
+
context,
|
|
44
|
+
marks: piece.node.marks,
|
|
45
|
+
styleResolver
|
|
46
|
+
});
|
|
47
|
+
const styleId = previousFormatting.styleId;
|
|
48
|
+
if (!(styleId !== void 0 && (builtInStyles.builtInNameOf(styleId) === BUILT_IN_STYLE_NAME.hyperlink || styleId === "Hyperlink"))) return {
|
|
49
|
+
marks: piece.node.marks,
|
|
50
|
+
previousFormatting: null
|
|
51
|
+
};
|
|
52
|
+
const { styleId: _removed, ...formatting } = previousFormatting;
|
|
53
|
+
return {
|
|
54
|
+
marks: reconcileRunFormattingMarks({
|
|
55
|
+
authoredFormatting: formatting,
|
|
56
|
+
context,
|
|
57
|
+
node: piece.node,
|
|
58
|
+
styleResolver
|
|
59
|
+
}),
|
|
60
|
+
previousFormatting
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/** Replace the marks of the text at [`from`, `to`) of `tr.doc` with `marks`. */
|
|
64
|
+
const setTextMarks = (tr, from, to, current, marks) => {
|
|
65
|
+
for (const mark of current) if (!mark.isInSet(marks)) tr.removeMark(from, to, mark);
|
|
66
|
+
for (const mark of marks) if (!mark.isInSet(current)) tr.addMark(from, to, mark);
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Remove the hyperlinks from [`from`, `to`) of `tr.doc`: directly, or, with
|
|
70
|
+
* suggestions on, as a tracked replacement of the linked text by plain text.
|
|
71
|
+
*/
|
|
72
|
+
const removeHyperlinkInRange = (state, tr, from, to) => {
|
|
73
|
+
const { schema } = state;
|
|
74
|
+
const hyperlinkType = schema.marks["hyperlink"];
|
|
75
|
+
if (!hyperlinkType) return tr;
|
|
76
|
+
const insertionType = schema.marks["insertion"];
|
|
77
|
+
const deletionType = schema.marks["deletion"];
|
|
78
|
+
const propertyChangeType = schema.marks["runPropertyChange"];
|
|
79
|
+
const tracked = isSuggestionModeActive(state) && insertionType !== void 0 && deletionType !== void 0 && propertyChangeType !== void 0;
|
|
80
|
+
const revisionAttrs = () => {
|
|
81
|
+
const revision = makeRevisionInfo(state);
|
|
82
|
+
return revision ? {
|
|
83
|
+
id: revision.id,
|
|
84
|
+
author: revision.author,
|
|
85
|
+
date: revision.date
|
|
86
|
+
} : null;
|
|
87
|
+
};
|
|
88
|
+
const insertionInfo = tracked ? revisionAttrs() : null;
|
|
89
|
+
const insertion = insertionType && insertionInfo ? insertionType.create({
|
|
90
|
+
revisionId: insertionInfo.id,
|
|
91
|
+
author: insertionInfo.author,
|
|
92
|
+
date: insertionInfo.date
|
|
93
|
+
}) : null;
|
|
94
|
+
const propertyChange = (previousFormatting) => {
|
|
95
|
+
const info = revisionAttrs();
|
|
96
|
+
if (!propertyChangeType || !info) return null;
|
|
97
|
+
const change = {
|
|
98
|
+
type: "runPropertyChange",
|
|
99
|
+
info,
|
|
100
|
+
previousFormatting
|
|
101
|
+
};
|
|
102
|
+
return propertyChangeType.create({ changes: [change] });
|
|
103
|
+
};
|
|
104
|
+
const hasPendingPropertyChange = (marks) => marks.some(({ type }) => type === propertyChangeType);
|
|
105
|
+
for (const range of linkedRanges(tr.doc, from, to).toReversed()) {
|
|
106
|
+
const unlinked = range.pieces.map((piece) => ({
|
|
107
|
+
piece,
|
|
108
|
+
...withoutHyperlinkStyle(state, tr.doc, piece)
|
|
109
|
+
}));
|
|
110
|
+
if (!insertion || !deletionType) {
|
|
111
|
+
for (const { piece, marks } of unlinked) setTextMarks(tr, piece.from, piece.to, piece.node.marks, marks.filter(({ type }) => type !== hyperlinkType));
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const plain = unlinked.map(({ piece, marks, previousFormatting }) => {
|
|
115
|
+
const change = previousFormatting && !hasPendingPropertyChange(marks) ? propertyChange(previousFormatting) : null;
|
|
116
|
+
const kept = marks.filter(({ type }) => type !== hyperlinkType && type !== insertionType && type !== deletionType);
|
|
117
|
+
return piece.node.mark(insertion.addToSet(change ? change.addToSet(kept) : kept));
|
|
118
|
+
});
|
|
119
|
+
tr.insert(range.to, plain);
|
|
120
|
+
for (const { piece, marks, previousFormatting } of unlinked.toReversed()) {
|
|
121
|
+
const change = previousFormatting && !hasPendingPropertyChange(piece.node.marks) ? propertyChange(previousFormatting) : null;
|
|
122
|
+
setTextMarks(tr, piece.from, piece.to, piece.node.marks, change ? change.addToSet(marks) : marks);
|
|
123
|
+
}
|
|
124
|
+
suggestRangeDeletion(state, tr, range.from, range.to);
|
|
125
|
+
}
|
|
126
|
+
return tr;
|
|
127
|
+
};
|
|
128
|
+
//#endregion
|
|
129
|
+
export { removeHyperlinkInRange };
|
|
@@ -5,13 +5,14 @@ import { schema, singletonManager } from "./schema/index.js";
|
|
|
5
5
|
import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
|
|
6
6
|
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
7
7
|
import { TableBorderCommandSpec, TableCellBorderCommandSpec } from "./extensions/types.js";
|
|
8
|
+
import { ListNumberingMenuState, NO_LIST_NUMBERING_MENU, listNumberingMenuState } from "./listNumbering.js";
|
|
8
9
|
import { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./commands/formatPainter.js";
|
|
9
10
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
10
11
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
|
|
11
12
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
|
|
12
13
|
import { insertImageFromFile } from "./commands/image.js";
|
|
13
14
|
import { getListInfo, isInList } from "./extensions/features/ListExtension.js";
|
|
14
|
-
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
15
|
+
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, continueNumbering, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, restartNumbering, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setNumberingValue, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
15
16
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
|
|
16
17
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
17
18
|
import "./commands/index.js";
|
|
@@ -24,8 +25,9 @@ import { SelectionChangeCallback, SelectionContext, createSelectionTrackerPlugin
|
|
|
24
25
|
import { ensureParaIdsInState } from "./extensions/features/ParaIdAllocatorExtension.js";
|
|
25
26
|
import "./styles/index.js";
|
|
26
27
|
import { SelectionState, extractSelectionState } from "./selectionState.js";
|
|
27
|
-
import {
|
|
28
|
+
import { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
29
|
+
import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
|
|
28
30
|
import "./plugins/index.js";
|
|
29
31
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
30
32
|
import { TextSelection } from "prosemirror-state";
|
|
31
|
-
export { type ActiveListState, type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type FromProseDocOptions, type HyperlinkAttrs, type ImageAttrs, type ListState, type ListType, NO_LIST_STATE, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProjectionReuse, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderCommandSpec, type TableBorderPreset, type TableCellBorderCommandSpec, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
33
|
+
export { type ActiveListState, type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type FromProseDocOptions, type HyperlinkAttrs, type ImageAttrs, type ListNumberingMenuState, type ListState, type ListType, NO_LIST_NUMBERING_MENU, NO_LIST_STATE, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProjectionReuse, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderCommandSpec, type TableBorderPreset, type TableCellBorderCommandSpec, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listNumberingMenuState, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, restartNumbering, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
@@ -2,7 +2,7 @@ import { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./co
|
|
|
2
2
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
|
|
3
3
|
import { insertImageFromFile } from "./commands/image.js";
|
|
4
4
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
5
|
-
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
5
|
+
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, continueNumbering, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, restartNumbering, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setNumberingValue, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
6
6
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
|
|
7
7
|
import { fromProseDoc, updateDocumentContent } from "./conversion/fromProseDoc.js";
|
|
8
8
|
import { createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
@@ -13,12 +13,14 @@ import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensi
|
|
|
13
13
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
14
14
|
import { getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
15
15
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
16
|
+
import { NO_LIST_NUMBERING_MENU, listNumberingMenuState } from "./listNumbering.js";
|
|
16
17
|
import { NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
|
|
17
|
-
import {
|
|
18
|
+
import { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
19
|
+
import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
|
|
18
20
|
import { createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./plugins/selectionTracker.js";
|
|
19
21
|
import { schema, singletonManager } from "./schema/index.js";
|
|
20
22
|
import { extractSelectionState } from "./selectionState.js";
|
|
21
23
|
import { StyleResolver, createStyleResolver } from "./styles/styleResolver.js";
|
|
22
24
|
import { assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
|
|
23
25
|
import { TextSelection } from "prosemirror-state";
|
|
24
|
-
export { NO_LIST_STATE, PAINTABLE_MARK_NAMES, StyleResolver, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
26
|
+
export { NO_LIST_NUMBERING_MENU, NO_LIST_STATE, PAINTABLE_MARK_NAMES, StyleResolver, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listNumberingMenuState, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, restartNumbering, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
//#region src/prosemirror/indexedNodeLookup.d.ts
|
|
3
|
+
type NodesBetweenCallback = (node: Node, pos: number, parent: Node | null, index: number) => boolean | void;
|
|
4
|
+
/** `doc.nodesBetween(from, to, visit)`, locating `from` by binary search. */
|
|
5
|
+
declare const nodesBetweenIndexed: (doc: Node, from: number, to: number, visit: NodesBetweenCallback) => void;
|
|
6
|
+
/** `doc.nodeAt(pos)`. */
|
|
7
|
+
declare const nodeAtIndexed: (doc: Node, pos: number) => Node | null;
|
|
8
|
+
/**
|
|
9
|
+
* The innermost paragraph `doc.resolve(pos)` passes through, and the position
|
|
10
|
+
* before it (`$pos.before(depth)`), or null outside every paragraph.
|
|
11
|
+
*/
|
|
12
|
+
declare const enclosingParagraphIndexed: (doc: Node, pos: number) => {
|
|
13
|
+
node: Node;
|
|
14
|
+
pos: number;
|
|
15
|
+
} | null;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { enclosingParagraphIndexed, nodeAtIndexed, nodesBetweenIndexed };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/prosemirror/indexedNodeLookup.ts
|
|
2
|
+
/** Below this many children a linear scan is as fast as building the table. */
|
|
3
|
+
const LINEAR_SCAN_LIMIT = 16;
|
|
4
|
+
const childOffsetCache = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
/** `offsets[i]` is where child `i` starts; `offsets[childCount]` is the size. */
|
|
6
|
+
const childOffsets = (fragment) => {
|
|
7
|
+
const cached = childOffsetCache.get(fragment);
|
|
8
|
+
if (cached) return cached;
|
|
9
|
+
const offsets = new Int32Array(fragment.childCount + 1);
|
|
10
|
+
let pos = 0;
|
|
11
|
+
fragment.forEach((child, _offset, index) => {
|
|
12
|
+
offsets[index] = pos;
|
|
13
|
+
pos += child.nodeSize;
|
|
14
|
+
});
|
|
15
|
+
offsets[fragment.childCount] = pos;
|
|
16
|
+
childOffsetCache.set(fragment, offsets);
|
|
17
|
+
return offsets;
|
|
18
|
+
};
|
|
19
|
+
/** The first child that ends after `pos` (its end is past `pos`), and its start. */
|
|
20
|
+
const firstChildEndingAfter = (fragment, pos) => {
|
|
21
|
+
if (fragment.childCount <= LINEAR_SCAN_LIMIT) {
|
|
22
|
+
let start = 0;
|
|
23
|
+
for (let index = 0; index < fragment.childCount; index++) {
|
|
24
|
+
const end = start + fragment.child(index).nodeSize;
|
|
25
|
+
if (end > pos) return [index, start];
|
|
26
|
+
start = end;
|
|
27
|
+
}
|
|
28
|
+
return [fragment.childCount, start];
|
|
29
|
+
}
|
|
30
|
+
const offsets = childOffsets(fragment);
|
|
31
|
+
let low = 0;
|
|
32
|
+
let high = fragment.childCount;
|
|
33
|
+
while (low < high) {
|
|
34
|
+
const middle = low + high >>> 1;
|
|
35
|
+
if (offsets[middle + 1] > pos) high = middle;
|
|
36
|
+
else low = middle + 1;
|
|
37
|
+
}
|
|
38
|
+
return [low, offsets[low]];
|
|
39
|
+
};
|
|
40
|
+
const visitBetween = (parent, from, to, visit, nodeStart) => {
|
|
41
|
+
const fragment = parent.content;
|
|
42
|
+
let [index, pos] = firstChildEndingAfter(fragment, from);
|
|
43
|
+
for (; pos < to; index++) {
|
|
44
|
+
const child = fragment.child(index);
|
|
45
|
+
const end = pos + child.nodeSize;
|
|
46
|
+
if (visit(child, nodeStart + pos, parent, index) !== false && child.content.size) {
|
|
47
|
+
const start = pos + 1;
|
|
48
|
+
visitBetween(child, Math.max(0, from - start), Math.min(child.content.size, to - start), visit, nodeStart + start);
|
|
49
|
+
}
|
|
50
|
+
pos = end;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/** `doc.nodesBetween(from, to, visit)`, locating `from` by binary search. */
|
|
54
|
+
const nodesBetweenIndexed = (doc, from, to, visit) => {
|
|
55
|
+
visitBetween(doc, from, to, visit, 0);
|
|
56
|
+
};
|
|
57
|
+
/** `Fragment.findIndex(pos)`: the child at `pos`, or the one after a boundary. */
|
|
58
|
+
const findChildIndex = (fragment, pos) => {
|
|
59
|
+
if (pos === 0) return [0, 0];
|
|
60
|
+
if (pos === fragment.size) return [fragment.childCount, pos];
|
|
61
|
+
if (pos > fragment.size || pos < 0) throw new RangeError(`Position ${String(pos)} outside of fragment (${fragment.toString()})`);
|
|
62
|
+
const [index, start] = firstChildEndingAfter(fragment, pos - 1);
|
|
63
|
+
const end = start + fragment.child(index).nodeSize;
|
|
64
|
+
return end === pos ? [index + 1, end] : [index, start];
|
|
65
|
+
};
|
|
66
|
+
/** `doc.nodeAt(pos)`. */
|
|
67
|
+
const nodeAtIndexed = (doc, pos) => {
|
|
68
|
+
let rest = pos;
|
|
69
|
+
for (let node = doc;;) {
|
|
70
|
+
const [index, offset] = findChildIndex(node.content, rest);
|
|
71
|
+
const child = node.maybeChild(index);
|
|
72
|
+
if (!child) return null;
|
|
73
|
+
if (offset === rest || child.isText) return child;
|
|
74
|
+
rest -= offset + 1;
|
|
75
|
+
node = child;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The innermost paragraph `doc.resolve(pos)` passes through, and the position
|
|
80
|
+
* before it (`$pos.before(depth)`), or null outside every paragraph.
|
|
81
|
+
*/
|
|
82
|
+
const enclosingParagraphIndexed = (doc, pos) => {
|
|
83
|
+
if (!(pos >= 0 && pos <= doc.content.size)) throw new RangeError(`Position ${String(pos)} out of range`);
|
|
84
|
+
let paragraph = null;
|
|
85
|
+
let start = 0;
|
|
86
|
+
let parentOffset = pos;
|
|
87
|
+
for (let node = doc;;) {
|
|
88
|
+
const [index, offset] = findChildIndex(node.content, parentOffset);
|
|
89
|
+
const rest = parentOffset - offset;
|
|
90
|
+
if (!rest) return paragraph;
|
|
91
|
+
const child = node.child(index);
|
|
92
|
+
if (child.isText) return paragraph;
|
|
93
|
+
if (child.type.name === "paragraph") paragraph = {
|
|
94
|
+
node: child,
|
|
95
|
+
pos: start + offset
|
|
96
|
+
};
|
|
97
|
+
parentOffset = rest - 1;
|
|
98
|
+
start += offset + 1;
|
|
99
|
+
node = child;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
export { enclosingParagraphIndexed, nodeAtIndexed, nodesBetweenIndexed };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ListRequest } from "./listNumbering.js";
|
|
2
|
+
//#region src/prosemirror/listAutoformatMarkers.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A marker plus the space that triggers the conversion. The text before the
|
|
5
|
+
* caret must be exactly this, so a marker typed mid-paragraph never matches.
|
|
6
|
+
*/
|
|
7
|
+
declare const LIST_MARKER_PATTERN: RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* The lists `text` (the paragraph's text up to and including the typed space)
|
|
10
|
+
* may ask for, most likely first, or `null` when it is not a marker.
|
|
11
|
+
*
|
|
12
|
+
* A single letter that is also a roman digit is ambiguous: `i.` usually
|
|
13
|
+
* starts a roman list, but directly under an `h.` item it continues the
|
|
14
|
+
* letters. The caller prefers whichever interpretation a neighbouring list
|
|
15
|
+
* already has, and otherwise takes the first.
|
|
16
|
+
*/
|
|
17
|
+
declare const listRequestsForMarker: (text: string) => ListRequest[] | null;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { LIST_MARKER_PATTERN, listRequestsForMarker };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/prosemirror/listAutoformatMarkers.ts
|
|
2
|
+
/**
|
|
3
|
+
* A marker plus the space that triggers the conversion. The text before the
|
|
4
|
+
* caret must be exactly this, so a marker typed mid-paragraph never matches.
|
|
5
|
+
*/
|
|
6
|
+
const LIST_MARKER_PATTERN = /^(?:[-*]|\d{1,3}[.)]|[A-Za-z]+[.)]) $/u;
|
|
7
|
+
const BULLET_PATTERN = /^[-*] $/u;
|
|
8
|
+
const NUMBER_PATTERN = /^(?<value>\d{1,3})(?<punctuation>[.)]) $/u;
|
|
9
|
+
const LETTERS_PATTERN = /^(?<letters>[a-z]+|[A-Z]+)(?<punctuation>[.)]) $/u;
|
|
10
|
+
/**
|
|
11
|
+
* The largest roman numeral read as a list marker. Past it the letters spell
|
|
12
|
+
* words (`mix`, `civil`, `dim`) far more often than list items.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_ROMAN_MARKER = 50;
|
|
15
|
+
const ROMAN_VALUES = [
|
|
16
|
+
["m", 1e3],
|
|
17
|
+
["cm", 900],
|
|
18
|
+
["d", 500],
|
|
19
|
+
["cd", 400],
|
|
20
|
+
["c", 100],
|
|
21
|
+
["xc", 90],
|
|
22
|
+
["l", 50],
|
|
23
|
+
["xl", 40],
|
|
24
|
+
["x", 10],
|
|
25
|
+
["ix", 9],
|
|
26
|
+
["v", 5],
|
|
27
|
+
["iv", 4],
|
|
28
|
+
["i", 1]
|
|
29
|
+
];
|
|
30
|
+
const toRoman = (value) => {
|
|
31
|
+
let remaining = value;
|
|
32
|
+
let roman = "";
|
|
33
|
+
for (const [digits, digitValue] of ROMAN_VALUES) while (remaining >= digitValue) {
|
|
34
|
+
roman += digits;
|
|
35
|
+
remaining -= digitValue;
|
|
36
|
+
}
|
|
37
|
+
return roman;
|
|
38
|
+
};
|
|
39
|
+
const ROMAN_DIGIT_VALUES = {
|
|
40
|
+
i: 1,
|
|
41
|
+
v: 5,
|
|
42
|
+
x: 10,
|
|
43
|
+
l: 50,
|
|
44
|
+
c: 100,
|
|
45
|
+
d: 500,
|
|
46
|
+
m: 1e3
|
|
47
|
+
};
|
|
48
|
+
/** The value of a canonically spelled roman numeral, or `undefined`. */
|
|
49
|
+
const romanValue = (letters) => {
|
|
50
|
+
const lower = letters.toLowerCase();
|
|
51
|
+
let total = 0;
|
|
52
|
+
for (let index = 0; index < lower.length; index += 1) {
|
|
53
|
+
const value = ROMAN_DIGIT_VALUES[lower.charAt(index)];
|
|
54
|
+
if (value === void 0) return;
|
|
55
|
+
const next = ROMAN_DIGIT_VALUES[lower.charAt(index + 1)] ?? 0;
|
|
56
|
+
total += value < next ? -value : value;
|
|
57
|
+
}
|
|
58
|
+
return total > 0 && toRoman(total) === lower ? total : void 0;
|
|
59
|
+
};
|
|
60
|
+
const numbered = (numFmt, punctuation, start) => ({
|
|
61
|
+
kind: "numbered",
|
|
62
|
+
format: {
|
|
63
|
+
numFmt,
|
|
64
|
+
lvlText: `%1${punctuation}`
|
|
65
|
+
},
|
|
66
|
+
start
|
|
67
|
+
});
|
|
68
|
+
const letterFormat = (letters) => letters === letters.toUpperCase() ? "upperLetter" : "lowerLetter";
|
|
69
|
+
const romanFormat = (letters) => letters === letters.toUpperCase() ? "upperRoman" : "lowerRoman";
|
|
70
|
+
/**
|
|
71
|
+
* The lists `text` (the paragraph's text up to and including the typed space)
|
|
72
|
+
* may ask for, most likely first, or `null` when it is not a marker.
|
|
73
|
+
*
|
|
74
|
+
* A single letter that is also a roman digit is ambiguous: `i.` usually
|
|
75
|
+
* starts a roman list, but directly under an `h.` item it continues the
|
|
76
|
+
* letters. The caller prefers whichever interpretation a neighbouring list
|
|
77
|
+
* already has, and otherwise takes the first.
|
|
78
|
+
*/
|
|
79
|
+
const listRequestsForMarker = (text) => {
|
|
80
|
+
if (BULLET_PATTERN.test(text)) return [{ kind: "bullet" }];
|
|
81
|
+
const number = NUMBER_PATTERN.exec(text)?.groups;
|
|
82
|
+
if (number) {
|
|
83
|
+
const value = Number.parseInt(number["value"] ?? "", 10);
|
|
84
|
+
return value >= 1 ? [numbered("decimal", number["punctuation"] ?? ".", value)] : null;
|
|
85
|
+
}
|
|
86
|
+
const lettered = LETTERS_PATTERN.exec(text)?.groups;
|
|
87
|
+
if (!lettered) return null;
|
|
88
|
+
const letters = lettered["letters"] ?? "";
|
|
89
|
+
const punctuation = lettered["punctuation"] ?? ".";
|
|
90
|
+
const roman = romanValue(letters);
|
|
91
|
+
const asRoman = roman !== void 0 && roman <= MAX_ROMAN_MARKER ? numbered(romanFormat(letters), punctuation, roman) : void 0;
|
|
92
|
+
if (letters.length > 1) return asRoman ? [asRoman] : null;
|
|
93
|
+
const asLetter = numbered(letterFormat(letters), punctuation, letters.toLowerCase().charCodeAt(0) - "a".charCodeAt(0) + 1);
|
|
94
|
+
if (!asRoman) return [asLetter];
|
|
95
|
+
return roman === 1 ? [asRoman, asLetter] : [asLetter, asRoman];
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { LIST_MARKER_PATTERN, listRequestsForMarker };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
//#region src/prosemirror/listInstanceReferences.d.ts
|
|
4
|
+
/** The instances one paragraph names, live or as a tracked change's previous state. */
|
|
5
|
+
declare const paragraphListReferences: (node: Node) => number[];
|
|
6
|
+
/**
|
|
7
|
+
* `definitions` plus every instance `doc` references and only its paragraphs
|
|
8
|
+
* define: what the package's numbering part has to hold for `doc` to save.
|
|
9
|
+
*/
|
|
10
|
+
declare const completeNumberingForDoc: (definitions: document_d_exports.NumberingDefinitions | undefined, doc: Node) => document_d_exports.NumberingDefinitions | undefined;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { completeNumberingForDoc, paragraphListReferences };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { completeListNumbering } from "../docx/listNumberingInstances.js";
|
|
2
|
+
import { paragraphNumberingLevel, paragraphNumberingReferenceId } from "../docx/numberingReference.js";
|
|
3
|
+
import { expectParagraphAttrs } from "./attrs/index.js";
|
|
4
|
+
import { hasListRendering, listRenderingFromAttrs } from "./listRenderingAttrs.js";
|
|
5
|
+
//#region src/prosemirror/listInstanceReferences.ts
|
|
6
|
+
const PARAGRAPH_NODE = "paragraph";
|
|
7
|
+
/**
|
|
8
|
+
* Record `attrs`' reference when it names an instance the package lacks and
|
|
9
|
+
* states what it renders as. A reference with no rendering carries nothing to
|
|
10
|
+
* define an instance from.
|
|
11
|
+
*/
|
|
12
|
+
const collectReference = (attrs, sink) => {
|
|
13
|
+
const numId = paragraphNumberingReferenceId(attrs.numPr);
|
|
14
|
+
if (numId === void 0 || sink.isDefined(numId)) return;
|
|
15
|
+
if (!hasListRendering(attrs)) return;
|
|
16
|
+
sink.references.push({
|
|
17
|
+
numId,
|
|
18
|
+
ilvl: paragraphNumberingLevel(attrs.numPr) ?? 0,
|
|
19
|
+
rendering: listRenderingFromAttrs({
|
|
20
|
+
attrs,
|
|
21
|
+
numId
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Every reference in `doc`, live or recorded as a tracked change's previous
|
|
27
|
+
* state, to an instance `isDefined` does not know. A rejected change restores
|
|
28
|
+
* its previous numbering, so that instance has to exist as well.
|
|
29
|
+
*/
|
|
30
|
+
const undefinedListInstanceReferences = (doc, isDefined) => {
|
|
31
|
+
const sink = {
|
|
32
|
+
isDefined,
|
|
33
|
+
references: []
|
|
34
|
+
};
|
|
35
|
+
doc.descendants((node) => {
|
|
36
|
+
if (node.type.name !== PARAGRAPH_NODE) return true;
|
|
37
|
+
const attrs = expectParagraphAttrs(node);
|
|
38
|
+
collectReference(attrs, sink);
|
|
39
|
+
for (const change of attrs._propertyChanges ?? []) {
|
|
40
|
+
const previous = change.previousFormatting;
|
|
41
|
+
if (previous?.numPr) collectReference({
|
|
42
|
+
...previous,
|
|
43
|
+
numPr: previous.numPr
|
|
44
|
+
}, sink);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
});
|
|
48
|
+
return sink.references;
|
|
49
|
+
};
|
|
50
|
+
/** The instances one paragraph names, live or as a tracked change's previous state. */
|
|
51
|
+
const paragraphListReferences = (node) => {
|
|
52
|
+
if (node.type.name !== PARAGRAPH_NODE) return [];
|
|
53
|
+
const attrs = expectParagraphAttrs(node);
|
|
54
|
+
const numIds = [];
|
|
55
|
+
const add = (numPr) => {
|
|
56
|
+
const numId = paragraphNumberingReferenceId(numPr ?? void 0);
|
|
57
|
+
if (numId !== void 0) numIds.push(numId);
|
|
58
|
+
};
|
|
59
|
+
add(attrs.numPr);
|
|
60
|
+
for (const change of attrs._propertyChanges ?? []) add(change.previousFormatting?.numPr);
|
|
61
|
+
return numIds;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* `definitions` plus every instance `doc` references and only its paragraphs
|
|
65
|
+
* define: what the package's numbering part has to hold for `doc` to save.
|
|
66
|
+
*/
|
|
67
|
+
const completeNumberingForDoc = (definitions, doc) => {
|
|
68
|
+
const defined = new Set((definitions?.nums ?? []).map(({ numId }) => numId));
|
|
69
|
+
return completeListNumbering(definitions, undefinedListInstanceReferences(doc, (numId) => defined.has(numId)));
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { completeNumberingForDoc, paragraphListReferences };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ParagraphAttrs } from "./schema/nodes.js";
|
|
3
|
+
import { ParagraphNumberingOverride } from "../docx/numberingReference.js";
|
|
4
|
+
//#region src/prosemirror/listLabels.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The attrs the counter reads for a paragraph of the document model, as
|
|
7
|
+
* `toProseDoc` projects them (`listRenderingAttrPatch`), without the layout
|
|
8
|
+
* attrs no label depends on: a reader that walks the model (Markdown) counts
|
|
9
|
+
* every list paragraph through here.
|
|
10
|
+
*/
|
|
11
|
+
declare const listLabelAttrsFromRendering: (rendering: document_d_exports.ListRendering, numPrFromStyle: ParagraphNumberingOverride | undefined) => ParagraphAttrs;
|
|
12
|
+
/**
|
|
13
|
+
* Advances past one paragraph and answers the label it shows, or `undefined`
|
|
14
|
+
* when it shows none.
|
|
15
|
+
*/
|
|
16
|
+
type ListLabelCounter = (attrs: Readonly<ParagraphAttrs>) => string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* A counter over paragraph attrs in document order. Call it for every
|
|
19
|
+
* paragraph, numbered or not: whether a list continues depends on what stands
|
|
20
|
+
* between its items.
|
|
21
|
+
*/
|
|
22
|
+
declare const createListLabelCounter: () => ListLabelCounter;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ListLabelCounter, createListLabelCounter, listLabelAttrsFromRendering };
|